akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define int long long int
int32_t main()
{
    int n;
    cin >> n;
    int ans = 0;
    int c1 = n / 500;
    ans += c1 * 1000;
    n = n % 500;

    int c2 = n / 5;
    ans += c2 * 5;

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}


const int MAX_N = 112345;
vector<int> g[MAX_N];

int vis[MAX_N][4];

void make_h(int start, int cur, int depth, vector<int> &v) {
  if (vis[cur][depth] == start) return;
  vis[cur][depth] = start;
  if (depth == 0) {
    v.push_back(cur);
    return;
  }
  for (int nxt : g[cur]) {
    make_h(start, nxt, depth - 1, v);
  }
}

int memo[MAX_N];

int main2() {
  REP(i, MAX_N) g[i].clear();

  int N = nextInt();
  int M = nextInt();
  REP(i, M) {
    int a = nextInt() - 1;
    int b = nextInt() - 1;
    g[a].push_back(b);
  }

  CLR(vis, -1);

  int S = nextInt() - 1;
  int T = nextInt() - 1;

  REP(i, MAX_N) memo[i] = 987654321;
  queue<int> q;
  q.push(S);
  memo[S] = 0;
  while (!q.empty()) {
    int cur = q.front(); q.pop();
    vector<int> v;
    make_h(cur, cur, 3, v);
    for (int nxt : v) {
      if (memo[nxt] > memo[cur] + 1) {
        memo[nxt] = memo[cur] + 1;
        q.push(nxt);
        if (nxt == T) {
          goto END;
        }
      }
    }
  }
END:
  int ans = memo[T] == 987654321 ? -1 : memo[T];
  cout << ans << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


Measured memory_bytes: 8192
#include<bits/stdc++.h>
using namespace std;
constexpr int64_t mod=1e9+7;

int main()
{
  int64_t n,a,b;
  cin>>n>>a>>b;
  vector<int64_t> x(n);
  for(auto&& e: x) {
    cin>>e;
  }
  int64_t lim=b/a;
  int64_t ans=0;
  for (int i = 0; i < n-1; ++i)
  {
    if(x[i+1]-x[i]>lim)
      ans+=b;
    else ans+=a*(x[i+1]-x[i]);
  }
  cout<<ans;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main() {
  int A, B;
  cin >> A >> B;
  if (A != 1 && B != 1) {cout << 1 << endl;}
  else if (A != 2 && B != 2) {cout << 2 << endl;}
  else {cout << 3 << endl;}
}

Measured memory_bytes: 3568
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<string>
#include<cmath>
#include<ctime>
#include<cassert>
#include<climits>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<bitset>
#define to edge[i].v
#define mp make_pair
#define rint register int
#define debug(x) cerr<<#x<<"="<<x<<endl
#define fgx cerr<<"-------------"<<endl
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
int a[1000000];
int main()
{	int n,sum=0; cin>>n;
	for(rint i=1;i<=n;i++) cin>>a[i],sum+=abs(a[i-1]-a[i]); sum+=abs(a[n]); a[++n]=0;
	for(rint i=1;i<n;i++) cout<<sum-abs(a[i]-a[i-1])-abs(a[i+1]-a[i])+abs(a[i+1]-a[i-1])<<endl;
	return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)

int main() {
    int64_t n; cin >> n;
    int64_t sum1 = n*(n+1)/2;
    int64_t sum3 = 3*(n/3)*(n/3+1)/2;
    int64_t sum5 = 5*(n/5)*(n/5+1)/2;
    int64_t sum15 = 15*(n/15)*(n/15+1)/2;
    int64_t ans = sum1-sum3-sum5+sum15;

    cout << ans << endl;
}


Measured memory_bytes: 3632
a, b = map(int, input().split())
# 大きい値をaに
if a < b:
    a, b = b, a
A, B = a, b
while a % b != 0:
    tmp = b
    b = a % b
    a = tmp

# b is 最大公約数
ans = A * B / b
print(int(ans))


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<double> vd;
typedef pair<double,double> PD;
typedef pair<int,P> ed;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;

int main() {
  int N;
  cin >> N;
  vvi G(N,vi(N));
  rep(i,N) {
    rep(j,N) {
      cin >> G[i][j];
    }
  }
  set<P> s;
  rep(i,N) {
    srep(j,i+1,N) {
      s.insert(P(i,j));
    }
  }
  rep(k,N) {
    rep(i,N) {
      rep(j,N) {
        if(G[i][j]>G[i][k]+G[k][j]) {
          cout << -1 << endl;
          return 0;
        }
        if(k!=i&&k!=j&&G[i][j]==G[i][k]+G[k][j]) {
          s.erase(P(i,j));
        }
      }
    }
  }
  ll ans = 0;
  for(P k:s) {
    ans += G[k.first][k.second];
  }
  cout << ans<< endl;
  return 0;
}

Measured memory_bytes: 2688
#[allow(unused_imports)]
use std::{cmp::Reverse, collections::*};

#[allow(unused_imports)]
use proconio::{
    fastout, input,
    marker::{Chars, Usize1},
};

#[allow(unused_imports)]
use itertools::Itertools;

#[allow(unused_imports)]
use num::Integer;

#[fastout]
pub fn main() {
    input! {
        a: i64, b: i64,
    }
    if a <= 0 && b >= 0 {
        println!("Zero");
    } else if a > 0 {
        println!("Positive");
    } else {
        if (b - a + 1) % 2 == 0 {
            println!("Positive");
        } else {
            println!("Negative");
        }
    }
}


Measured memory_bytes: 2156
#include <stdio.h>

void swap(int *, int *);

int main(void){

    int x, y;
    int t;

    scanf("%d%d", &x, &y);

    if(y>x){
        swap(&x, &y);
    }

   if(x>=y){
    while(y>0){
        t = x%y;
        x = y;
        y = t;
   }
        printf("%d\n", x);
    }

    return 0;
}

void swap(int *x, int *y){
    int temp;
    temp = *x;
    *x = *y;
    *y = temp;
}

Measured memory_bytes: 592
N,A,B = map(int,input().split())
l = 0
num = 0
Sum = 0
for i in range(1,N+1):
    i = str(i)
    l = len(i)
    for j in range(l):
        num += int(i[j])
    if A<=num and B >= num:
        Sum += int(i)
    num = 0
print(Sum)

Measured memory_bytes: 9012
/*input
10
1 3 2 3 3 2 3 2 1 3
*/
#include<bits/stdc++.h>
using namespace std;

#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test int t;cin>>t;while(t--)
#define X first
#define Y second
#define pb push_back
#define all(s) s.begin(),s.end()

typedef pair<int,int> ii;
typedef long long ll;

const int MOD = 1e9+7;
const int MX = 307;

long double dp[MX+5][MX+5][MX+5];

void solve(){
    long double n;
    cin >> n;
    int c1=0,c2=0,c3=0;
    for(int i=0,x;i<n;i++){
        cin >> x;
        if(x==1)
            c1++;
        if(x==2)
            c2++;
        if(x==3)
            c3++;

        // (x==1) ? c1++ : ((x==2) ? c2++ : c3++);
    }
    // cout << c1;

    for(int k=0;k<MX;k++){
        for(int j=0;j+k<MX;j++){
            for(int i=0;k+i+j<MX;i++){
                if(i==0 && j==0 && k==0){
                    continue;
                }
                long double wait = 1.0*n/(i+j+k);
                long double pi = 1.0*i/(i+j+k);
                long double pj = 1.0*j/(i+j+k);
                long double pk = 1.0*k/(i+j+k);
                if(i){
                    dp[i][j][k] += pi*dp[i-1][j][k];
                }
                if(j){
                    dp[i][j][k] += pj*dp[i+1][j-1][k];
                }
                if(k){
                    dp[i][j][k] += pk*dp[i][j+1][k-1];
                }
                dp[i][j][k] += wait;
            }
        }
        
    }
    cout << fixed << setprecision(16);
    cout << dp[c1][c2][c3];

}

int main(){
    FIN;   
    // test
    solve();
}


Measured memory_bytes: 467200
#include <iostream>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for (int i=a; i<(b);++i)
typedef long long ll;

int N,A,t,sum;
int x[55];
ll dp[55][2505*2];

int main(){
    cin >> N >> A;
    REP(i,N){
        cin >> t;
        sum += t;
        x[i] = t - A;
    }

    dp[0][2500] = 1; // 最終的に和が0のものの組み合わせの個数を見るので、jは可能ならなんでも良い
    REP(i,N){
        REP(j,2500*2+1){
            dp[i+1][j] = dp[i][j]; // i番目の数字を使わない
            if(j - x[i] >= 0) dp[i+1][j] += dp[i][j - x[i]]; // (使える場合)使う
        }
    }

    ll ans = 0;
    cout << dp[N][2500] - 1 << endl;
}

Measured memory_bytes: 2176
def main():
    buf = input()
    buflist = buf.split()
    K = int(buflist[0])
    A = int(buflist[1])
    B = int(buflist[2])
    biscuit = 1
    if A >= B - 2:
        biscuit += K
    else:
        if K <= A - 1:
            biscuit += K
        else:
            biscuit += A - 1
            remaining = K - (A - 1)
            buysell_count = remaining // 2
            biscuit += (B - A) * buysell_count
            remaining -= buysell_count * 2
            if remaining == 1:
                biscuit += 1
    print(biscuit)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;

int main() {
  int64_t a,b,c,d;
  int64_t S;
  cin >>S;
  a=1000000000;
  if( S == a*a){
    b=0;
    c=0;
    d=a;
  }
  else{
    b=a-(S%a);
    c=1;
    d=(S/a)+1;
  }
  cout<<0<<" "<<0<<" "<<a<<" "<<b<<" "<<c<<" "<<d;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
using namespace std;

int main(){
	int i;
	int n;
	cin>>n;
	int x;
	i=1;
	while(i<=n)
	{
		x=i;
		if(x%3==0)
		{
			cout<<" "<<i;
			i++;
			continue;
		}
		while(x)
		{
			if(x%10==3)
			{
				cout<<" "<<i;
				break;
			}
			x/=10;
		}
		i++;
	}
	cout<<endl;
}


Measured memory_bytes: 3096
#include<stdio.h>
int main(void)
{
    int a,b;
    scanf("%d",&a);   
    scanf("%d",&b);
    int x=(a+b)/2;
    if((a+b)%2==0)
    {printf("%d\n",x);
    }
    else
    {x=x+1;
    printf("%d\n",x);
    }
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdlib>
#include<string>
#include<vector>
#include<map>
#include<unordered_map>
#include<queue>
#include<algorithm>
#include<iomanip>
#include<typeinfo>
#include<complex>
using namespace std;
using ll = long long int;
const int mod = 1e9 + 7;
#define rep(i, a, b) for(ll i = a;i < b; i++)

int main() {

	int n, k;
	cin >> n >> k;

	vector<int> h(n);
	int cnt = 0;

	rep(i, 0, n) {
		cin >> h[i];
		if (h[i] >= k) cnt++;
	}

	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>

using namespace std;
typedef unsigned long long ll;
ll p[2000005];
ll m[2000005];
ll mp[2000005];

int main()
{
   ll a;
 cin>>a;
 ll mm=1e6;
   for(ll i=0;i<a;i++){
    cin>>p[i];
    mm=max(mm,p[i]);
    mp[p[i]]++;
   }

   sort(p,p+a);

   ll n = unique(p, p+a) - p;
   ll ans=0;

   
   
   
   for(ll i=0;i<n;i++)
   {
       if(m[p[i]]==0)
       {
           if(mp[p[i]]==1)
            ans++;
            for(ll j=p[i]*2;j<=mm;j+=p[i])
            m[j]=1;

       }
   }



   cout<<ans;

    return 0;
}


Measured memory_bytes: 20604
#include <iostream>
#include <vector>
using namespace std;

int main(int argc, char *argv[]){
  int N;
  int count=0;
  int count_max=0;
  cin>>N;
  vector<int> v;
  int m;
  for(int i=0; i<N; i++){
    cin>>m;
    v.push_back(m);
  }
  for(int i=0; i<N-1; i++){
    count=0;
    if(N-i<count_max) break;
    for(int j=i; j<N-1; j++){
      if(v[j]<v[j+1]) break;
      else{
	count++;
	//	continue;
      }
    }
    if(count>count_max) count_max=count;
  }
  cout<<count_max<<endl;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>

using namespace std;
typedef vector<int> VI;
typedef long long LL;
typedef pair<int,int> PI; 
typedef pair<LL,LL> PLL;
typedef unsigned long long ULL;

#define IOSWORK ios::sync_with_stdio(0); cin.tie(0)
#define FOR(x, b, e) for(int x = b; x<= (e); x++)
#define FORD(x, b, e) for(int x = b; x>= (e); x--)
#define REP(x, n) for(int x = 0; x<(n); ++x)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(x) ((int)(x).size())
#define VAR(v, n) typeof(n) v = (n)
#define FOREACH(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)

#define PB push_back
#define IN insert
#define ST first
#define ND second
#define INF 2000000011
#define MOD 1000000007

#define MAXSIZE 100
int tab[MAXSIZE][MAXSIZE]={0};
int h,w;

int main(){
	
	IOSWORK;
	cin>>h>>w;
	
	FOR(i,1,h){
		string s;
		cin>>s;
		FOR(j,1,w){
			if(s.at(j-1)=='#')
				tab[i][j]=1;
		}
	}
	
	FOR(i,1,h){
		
		FOR(j,1,w){
			int c=0;
			if(tab[i][j]){
			c+=tab[i][j+1];
			c+=tab[i][j-1];
			c+=tab[i+1][j];
			c+=tab[i-1][j];
					if(c==0){
			cout<<"No\n";
			return 0;
			}
			}
		}

	}
	cout<<"Yes\n";
	
	
	return 0;
}


Measured memory_bytes: 256
N,M = map(int,input().split())
origindestination = {}

for i in range(1,N+1):
    origindestination[i] = []
    
for i in range(M):
    a,b = map(int,input().split())
    origindestination[a].append(b)

for destination in origindestination[1]:
    if N in origindestination[destination]:
        print("POSSIBLE")
        break
else:
    print("IMPOSSIBLE")


Measured memory_bytes: 46160
#include<bits/stdc++.h>

using namespace std;

#define INF INT_MAX
#define F first
#define S second

typedef long long ll;
typedef pair<int,int>P;

int main(){
  int n;
  int b[105];
  int ans=0;
  cin>>n;
  for(int i=0;i<n-1;i++){
    cin>>b[i];
  }
  ans+=b[0];
  b[n-1]=100005;
  for(int i=1;i<n;i++){
    ans+=min(b[i-1],b[i]);
  }
  cout<<ans<<endl;
  
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

int main() {
  	int x, y;
  	scanf("%d %d", &x, &y);
  	if (y % 2 != 0) {
     	cout << "No" << endl;
     	return 0;
    }
  	if (y < x * 2 || x * 4 < y) {
      	cout << "No" << endl;
        return 0;
    }
  	for(int i = 0; i <= x; i++) {
    	int d = i * 2 + (x - i) * 4;
      	if(d == y) {
        	cout << "Yes" << endl;
          	return 0;
        }
    }
  	cout << "No" << endl; 
	return 0;
}

Measured memory_bytes: 3756
#include <bits/stdc++.h>

#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef long long int ll;

using namespace std;

int main() {
  string S;
  cin >> S;
  size_t cnt = 0;
  REP(i, S.size()) {
    if (S[i] == '0') cnt++;
  }
  cout << 2 * min(cnt, S.size() - cnt) << endl;
}

Measured memory_bytes: 512
N=int(input())
l=[[0,0,0]]+[list(map(int,input().split())) for _ in range(N)]

sum=[[0]*3 for _ in range(N+1)]
for i in range(1,N+1):
    sum[i][0]=max(sum[i-1][1],sum[i-1][2])+l[i][0]
    sum[i][1]=max(sum[i-1][0],sum[i-1][2])+l[i][1]
    sum[i][2]=max(sum[i-1][0],sum[i-1][1])+l[i][2]
ans=max(sum[N])
print(ans)

Measured memory_bytes: 49952
#include <cstdio>
#include <algorithm>
#include <vector>
#define ll long long
using namespace std;

int n,k;
ll sum=1,mod=1000000007ll;
vector <int> dis[100005];

int read(){
	int t=1,s=0;
	char c=getchar();
	while((c<'0'||c>'9')&&c!='-')c=getchar();
	if(c=='-')t=-1,c=getchar();
	while(c>='0'&&c<='9')
	s=s*10+c-'0',c=getchar();
	return s*t;
}

void dfs(int u,int last){
	int s;
	if(last==0)s=k-1;
	else s=k-2;
	int len=dis[u].size();
	for(int i=0;i<len;i++){
		if(dis[u][i]==last)continue;
		dfs(dis[u][i],u);
		sum=sum*s%mod;
		s--;
	}
	return ;
}

int main(void){
	n=read();
	k=read();
	for(int i=1;i<n;i++){
		int a,b;
		a=read();
		b=read();
		dis[a].push_back(b);
		dis[b].push_back(a);
	}
	dfs(1,0);
	printf("%lld",k*sum%mod);
}

Measured memory_bytes: 10368
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10 ** 7)


def solve(A: int, B: int, T: int):
    ans, t = 0, 0
    while True:
        t += A
        if t > T + 0.5:
            break
        ans += B
    print(ans)
    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools
# (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    T = int(next(tokens))  # type: int
    solve(A, B, T)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(lint (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
const lint MOD =1000000007;
const lint MAX = 1000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;
typedef map<lint,lint> M;
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
 
lint fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() 
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }
 
    return 1;
}
   long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }
     lint gcd(lint a,lint b){
        return __gcd(a,b);
    } 

    int main(){
        lint n;
        cin>>n;
        lint x=modpow(10,n,MOD);
        lint y=modpow(9,n,MOD);
        lint z=modpow(8,n,MOD);
        lint ans=x-y*2+z+MOD+MOD;
        ans%=MOD;
        cout<<ans<<endl;
    
    }
      

Measured memory_bytes: 3684
#include <bits/stdc++.h>
using namespace std;

int main() {
    long long N;
    cin >> N;
    vector<long long> A(N);
    for(int i=0; i<N; ++i) cin >> A[i];
    long long sum = accumulate(A.begin(), A.end(), 0LL);
    if(sum % (N * (N + 1) / 2LL)) {
        cout << "NO" << endl;
        return 0;
    }
    long long k = sum / (N * (N + 1) / 2LL);

    vector<long long> d(N);
    for(int i=0; i<N; ++i) {
        d[i] = A[(i + 1) % N] - A[i] - k;
    }
    
    for(int i=0; i<N; ++i) {
        if(d[i]) {
            if(d[i] % N != 0 || d[i] > 0) {
                cout << "NO" << endl;
                return 0;
            } else {
                k += d[i] / N;
            }
        }
    }

    if(k == 0) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;

int main(){
int M, i, d; cin >> M; long long c, L, S;
for(L=S=i=0; i<M; i++){ cin >> d >> c; L+=c; S+=d*c; }
cout << L-1+(S-1)/9 << "\n";
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
    long int n,i,l;
    char s[20000];
    while(~scanf("%ld%s",&n,s))
    {
        l=strlen(s);
        for(i=0;i<l;i++)
        {
            if(s[i]+n>'Z')
                s[i]=s[i]+n-26;
            else
                s[i]+=n;
//            printf("%d\n",s[i]);
        }
        printf("%s\n",s);
//        printf("%d\n",z);
    }
    return 0;
}


Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication3
{
    class Program
    {
        static void Main(string[] args)
        {

            var abc = Console.ReadLine().Split().Select(int.Parse).ToArray();
            Array.Sort(abc);



            var a = abc[0];
            var b = abc[1];
            var c = abc[2];
            Console.WriteLine("{0} {1} {2}", a, b, c);
            /* 
             if (a<b && b<c)
             {
                 Console.WriteLine("Yes");
                }
             else
                 Console.WriteLine("No");
              }
            */
        }
     }
 }
           
          
     

Measured memory_bytes: 9748
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N;
  cin >> N;

  for (int i=0; i<N; i++) {
    string C;
    cin >> C;
    if (C == "Y") {
      	cout << "Four" << endl;
      	break;
    }
    else {
      if (i == N-1) {
        cout << "Three" << endl;
      }
    }
  }
}


Measured memory_bytes: 256
// C - Write and Erase
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define all(x) (x).begin(),(x).end()

int main(){
	int N; cin>>N;
	vi A(N); rp(i, 0, N) scanf("%d", &A[i]);
	sort(all(A));
	int ans = 0;
	int preIx = 0;
	rp(i, 1, N)
		if(A[preIx] != A[i]){
			ans += (i - preIx)&1? 1:0;
			preIx = i;
		}
	if((N - preIx)&1) ans++;
	printf("%d\n", ans);
}

Measured memory_bytes: 768
#!/usr/bin/env python3
 
import re
 
n = input()
n = re.split(" ",n)
for i in range(3):
    n[i] = int(n[i])
n.sort()
a = int(n[2]) - int(n[0])
b = int(n[2]) - int(n[1])
 
#a,bともに奇数
if(a % 2 == 1 and b % 2 == 1):
    print(int(a/2)+int(b/2) + 1)
#a,bともに偶数
elif(a % 2 == 0 and b % 2 == 0):
    print(int(a/2) + int(b/2))
#それ以外
else:
    print(int(a/2) + int(b/2) + 2)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;

const int N=2e5+100;
const int mod=1e9+7;
typedef long long ll;


typedef pair<int,int> pa;

vector<int>ve0,ve1,ve2;
int p[502][502];
int n,c;

void floyd()
{

    for(int i=1;i<=c;i++){
        for(int j=1;j<=c;j++){
            for(int r=1;r<=c;r++){
                p[j][r]=min(p[j][r],p[j][i]+p[i][r]);
            }
        }
    }
}
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);
     cin>>n>>c;
     for(int i=1;i<=c;i++) {
            for(int j=1;j<=c;j++)
        cin>>p[i][j];
     }
    //floyd();
     for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            int x;cin>>x;
            if((i+j)%3==0) ve0.push_back(x);
            else if((i+j)%3==1) ve1.push_back(x);
            else ve2.push_back(x);
        }
     }
     ll sum=0,sum1=0,sum2=0,ans=1e9;

     for(int i=1;i<=c;i++){
            sum=0;
            for(auto v:ve0){
                sum+=p[v][i];
            }
        for(int j=1;j<=c;j++){
                sum1=0;
                if(j==i) continue;
                for(auto v:ve1){
                    sum1+=p[v][j];
                }
            for (int r=1;r<=c;r++){
                    sum2=0;
                if(r==i || r==j) continue;
                for(auto v:ve2){
                    sum2+=p[v][r];
                }
//                cout<<i<<" "<<j<<":"<<r<<endl;
//                cout<<sum<<" "<<sum1<<" "<<sum2<<endl;
                //if(sum==0 || sum1==0 || sum2==0) continue;
                ans=min(ans,sum+sum1+sum2);
            }

        }

     }
     cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 4516
#include <iostream>
#include <vector>

using namespace std;

#define INF 1e15

int main() {
	int n; cin >> n;
	vector <long long> h(n + 2);
	vector<long long> dp(n + 2,INF);
	dp[0] = 0;
	for (int i = 0; i < n; ++i) cin >> h[i];
	for (int i = 0; i < n; ++i) {
		if (dp[i + 2] > dp[i] + abs(h[i] - h[i + 2])) dp[i + 2] = dp[i] + abs(h[i] - h[i + 2]);
		if (dp[i + 1] > dp[i] + abs(h[i] - h[i + 1])) dp[i + 1] = dp[i] + abs(h[i] - h[i + 1]);
	}
	cout << dp[n - 1] << endl;

	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i,n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<"\n"
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define mp make_pair
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using vc = vector<char>;
using vvc = vector<vc>;
template<class T> inline bool chmax(T& a, T b) { 
 if (a < b) { a = b; return true; } return false; 
}
template<class T> inline bool chmin(T& a, T b) {
 if (a > b) { a = b; return true; } return false; 
}
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  string s;
  cin>>s;
  string h="ACGT";
  ll ans=0;
  rep(i,sz(s)){
    for(int j=i;j<sz(s);j++){
      bool t=true;
      for(int z=i;z<=j;z++){
        rep(q,4){
          if(s[z]==h[q]){
            break;
          }
          if(q==3){
            t=false;
          }
        }
      }
      if(t) chmax(ans,j-i+1);
    }
  }
  COUT(ans);
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;

int main(){
    int N;
    int a,b,c,d;
    cin >> N;

a = N/1000;
b = (N - 1000*a)/100;
c = (N - 1000*a - 100*b)/10;
d = N - 1000*a - 100*b - 10*c;
if(a == b && b == c){
    cout << "Yes" << endl;
}

else if(b == c && c == d){
    cout << "Yes" << endl;
}

else{
    cout << "No" << endl;
}

}

Measured memory_bytes: 3620
import java.util.Scanner;

public class Main{
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int n = sc.nextInt();
		Bridge[] b = new Bridge[n];
		for(int i = 0; i < n; i++){
			String in = sc.next();
			int x = Integer.parseInt(in.substring(0, in.indexOf(",")));
			int y = Integer.parseInt(in.substring(in.indexOf(",") + 1,
					in.length()));
			b[i] = new Bridge(x, y);
		}
		Lot l = new Lot(b);
		
		int[] result = new int[w];
		for(int i = 1; i <= w; i++){
			result[l.lot(i) - 1] = i;
		}
		for(int i = 0; i < result.length; i++)
			System.out.println(result[i]);
		sc.close();
	}
	
}

class Bridge{
	
	int x;
	int y;
	
	Bridge(int x, int y){
		this.x = x;
		this.y = y;
	}
}

class Lot{
	
	Bridge[] bridges;
	
	Lot(Bridge... b){
		this.bridges = b;
	}
	
	int lot(int num){
		int result = num;
		for(Bridge b: this.bridges){
			if(result == b.x)
				result = b.y;
			else if(result == b.y) result = b.x;
		}
		return result;
	}
	
}

Measured memory_bytes: 17188
#include <iostream>
#include <vector>

using namespace std;

vector<int> a;

void print_a() {
  for(int i = 0; i < a.size(); i++) {
    cout << a.at(i);
    if(i < a.size() - 1) {
      cout << " ";
    }
  }
  cout << endl;
}


int main() {
  int n;

  cin >> n;

  a.resize(n);
  for(int i = 0; i < n; i++) {
    cin >> a.at(i);
  }

  int cCnt = 0;
  for(int i = 0; i < a.size(); i++) {
    for(int j = a.size() - 1; j > i; j--) {
      if(a.at(j) < a.at(j-1)) {
	int t = a.at(j);
	a.at(j) = a.at(j-1);
	a.at(j-1) = t;
	cCnt++;
      }
    }
  }
  
  print_a();
  cout << cCnt << endl;
  return 0;
}



Measured memory_bytes: 3092
#pragma GCC optimize ("Ofast","unroll-loops")
#include <bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define MP make_pair
#define F first
#define S second
#define setpre(a) cout.precision(a),cout<<fixed;
#define ALL(a) a.begin(),a.end()
#define MEM(a,b) memset(a,b,sizeof a)
#define Tie ios::sync_with_stdio(0),cin.tie(0);
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const ll MOD=1e9+7;
ll n,k,a[10000],cnt,cnta,ans;

ll rev(ll a)
{
	ll b=MOD-2,re=1;
	while(b)
	{
		if(b&1)
			re=re*a%MOD;
		a=a*a%MOD,b>>=1;
	}
	return re;
}

int main()
{Tie
	cin>>n>>k;
	for(int i=0;i<n;i++)
		cin>>a[i];
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
		{
			if(i<j&&a[i]>a[j])
				cnt++;
			if(a[i]>a[j])
				cnta++;
		}
	ans=cnt*k%MOD;
	ans=(ans+(cnta+(cnta*(k-1)%MOD))*(k-1)%MOD*rev(2)%MOD)%MOD;
	cout<<ans<<'\n';
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define f(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
int main(void){
	int len, ans = 0;
	cin >> len;
//	char s[200010];
	string s;
	cin >> s;
//	memset(s, 0, sizeof(s));
//	for(int i = 0; i <= len; i++){
//		scanf("%c", &s[i]);
//	}
//	for(int i = 1; i <= len; i++){
//		printf("%c\n", s[i]);
//	}
	int i = 0, j = len-1;
	while(i < j){
		while(s[i] == 'R')i++;
		while(s[j] == 'W')j--;
//		cout << i << " " << j  << endl;
//		cout << s[i] << " " << s[j] << endl;
		if(s[i] == 'W' && s[j] == 'R'&& i < j)ans++;
		i++; j--;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3696
#include <bits/stdc++.h>
using namespace std;
int N;
int a[200001];

int main(){
    cin >> N;
    for(int i=1;i<N;i++) cin >> a[i];
    map<int,int> mp;
    for(int i=1;i<N+1;i++){
        mp[i] = 0;
    }
    for(int i=1;i<N;i++){
        mp[a[i]]++;
    } 
    for(auto itr = mp.begin(); itr != mp.end(); ++itr){
        cout << itr->second << endl;
    }
    return 0;
}


Measured memory_bytes: 13788
#include <bits/stdc++.h>
using namespace std;

int main() {
	int n;
	vector<string> w;
	cin >> n;
	for (int i = 0; i < n; i++) {
		string temp;
		cin >> temp;
		w.push_back(temp);
	}
	
	set<string> t;
	for (int i = 0; i < n; i++)
		t.insert(w[i]);
	if (w.size() != t.size()) {
		cout << "No" << endl;
		return 0;
	}
	for (int i = 0; i < n - 1; i++) {
		if (w[i].back() != w[i+1].front()) {
			cout << "No" << endl;
			return 0;
		}
	}
	
	cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

int main() {
	
	int n; cin >> n;
	vector<int> a(n), b(n), c(n); 
	for (int i = 0; i < n; i++) cin >> a[i];
	for (int i = 0; i < n; i++) cin >> b[i];
	for (int i = 0; i < n; i++) cin >> c[i];

	sort(a.begin(), a.end());
	sort(c.begin(), c.end());
	
	long long ans = 0;
	for (int i = 0; i < n; i++) {

		auto iter_a = lower_bound(a.begin(), a.end(), b[i]);
		auto iter_c = upper_bound(c.begin(), c.end(), b[i]);
				
		long long  a_cnt = iter_a - a.begin();
		long long  c_cnt = c.end() - iter_c;
				
		ans += a_cnt * c_cnt;

	}

	cout << ans << endl;
	return 0;

}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main(){
    ll n, k, q;
    cin>>n>>k>>q;
    vector<int> a(n, 0);
    rep(i, q){
        int temp;
        cin>>temp;
        a[temp-1]++;
    }
    rep(i, n){
        if (k-q+a[i] > 0) cout << "Yes"<<endl;
        else cout << "No" <<endl;
    }
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>

using namespace std;

#define f0r(a, b) for (long long a = 0; a < b; a++)
#define f1r(a, b, c) for (long long a = b; a < c; a++)
#define f0rd(a, b) for (long long a = b; a >= 0; a--)
#define f1rd(a, b, c) for (long long a = b; a >= c; a--)
#define ms(arr, v) memset(arr, v, sizeof(arr))
#define mp(a, b) make_pair(a, b)
#define pb push_back
#define f first
#define s second

#define ao(a, n) {for (int ele = 0; ele < n; ele++) { if (ele) cout << " "; cout << a[ele]; } cout << endl;}

typedef long long ll;
typedef double ld;
typedef long double lld;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;

const ll inf = 1e12;
const ll mod = 1e9 + 7;


int main() {
    ll n, x;

    cin >> n >> x;

    ll arr[n];

    f0r(i, n) cin >> arr[i];

    ll ret = 0;

    if (arr[0] > x) {
        ret += arr[0] - x;
        arr[0] = x;
    }

    if (arr[n-1] > x) {
        ret += arr[n-1] - x;
        arr[n-1] = x;
    }

    for (int i = 1; i < n; i++) {
        if (arr[i] + arr[i - 1] > x) {
            ret += ((arr[i] + arr[i-1]) - x);
            arr[i] -= ((arr[i] + arr[i-1]) - x);
        }
    }

    cout << ret << endl;
















}


Measured memory_bytes: 4404
import java.util.Scanner;
 
class Main{
  public static void main(String[] arg){
    int a, b, ans = 0;
    String op;
    Scanner in = new Scanner(System.in);

    while(true){
        a = in.nextInt();
        op = in.next();
        b = in.nextInt();

        if("?".equals(op)){
            return;
        }else if("+".equals(op)){
            ans = a + b;
            System.out.println(ans);
        }else if("-".equals(op)){
            ans = a - b;
            System.out.println(ans);
        }else if("*".equals(op)){
            ans = a * b;
            System.out.println(ans);
        }else if("/".equals(op)){
            ans = a / b;
            System.out.println(ans);
        }
    }

    
  }
}

Measured memory_bytes: 26092
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB emplace_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("[DEBUG] ");W(__VA_ARGS__);}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1<<20;

LL mypow(LL x,LL y){
    x%=MOD;
    LL res=1%MOD;
    while(y){
        if(y&1)res=res*x%MOD;
        y>>=1;
        x=x*x%MOD;
    }
    return res;
}
int N;
void solve() {
    LL an=mypow(10,N)-2*mypow(9,N)+mypow(8,N);
    ADD(an,0);
    W(an);
}
void input() {
   R(N); 
}
int main(){
#define MULTITEST 0
#if MULTITEST    
    CASET
#endif
    {
        input();
        solve();
    }
    return 0;
}


Measured memory_bytes: 3760
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

bool larger(string a, string b){
    if(a.length() == b.length()){
        return a < b;
    }
    return a.length() < b.length();
}
bool largerD(string a, string b){
    while((int)a.length()>0 && a[0]=='0') a.erase(a.begin());
    while((int)b.length()>0 && b[0]=='0') b.erase(b.begin());
    return larger(a,b);
}  

int main(){
    while(1){
        int w,h;
        cin >> w >> h;
        if(w==0) break;

        vector<vector<string> > mat(h+1, vector<string>(w+1, ""));
        for(int i=0; i<h; i++){
            for(int j=0; j<w; j++){
                char c;
                cin >> c;
                if('0'<=c && c<='9'){
                    mat[i][j] = string(1,c);
                }
            }
        }

        string largest = "";
        for(int i=h-1; i>=0; i--){
            for(int j=w-1; j>=0; j--){
                if(mat[i][j] == "") continue;
                if(larger(mat[i+1][j], mat[i][j+1])){
                    mat[i][j] += mat[i][j+1];
                }else{
                    mat[i][j] += mat[i+1][j];
                }
                if(largerD(largest, mat[i][j])){
                    largest = mat[i][j];
                }
            }
        }
        if(largest == "") largest = "0";
        cout << largest << endl;
    }
    return 0;
}

Measured memory_bytes: 3304
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll = long long;


void solve(long long H, long long W, long long A, long long B){
  rep(i,H-B) {
    rep(j,W-A) {
      std::cout << 1;
    }
    rep(j,A) {
      std::cout << 0;
    }
    std::cout << std::endl;
  }
  rep(i,B) {
    rep(j,W-A) std::cout << 0;
    rep(j,A) std::cout << 1;
    std::cout << std::endl;
  }
}

int main(){
    long long H;
    scanf("%lld",&H);
    long long W;
    scanf("%lld",&W);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(H, W, A, B);
    return 0;
}


Measured memory_bytes: 3744
#include <iostream>
#include <string.h>
#include <math.h>
#include <vector>
using namespace std;


int main() {
    int H1 = 0;
    int M1 = 0;
    int H2 = 0;
    int M2 = 0;
    int K = 0;

    cin >> H1 >> M1 >> H2 >> M2 >> K;
    cout << (60 * H2 + M2) - (60 * H1 + M1) - K;

    return 0;
}

Measured memory_bytes: 3200
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

int main() {
  int K;
  string S;
  cin >> K >> S;
  if(S.size() <= K) {
    cout << S << endl;
  } else {
    rep(i, K) {
      cout << S[i];
    }
    cout << "..." << endl;
  }
  return 0;
}

Measured memory_bytes: 3128
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    int s[n];
    for(int i=0;i<n;i++)cin >> s[i];
    int sum = 0;
    for(int i=0;i<n;i++)sum += s[i];
    if(sum % 10 == 0){
        sort(s,s+n);
        int i=0;
        while(s[i]%10==0)i++;
        if(i<n)sum -= s[i];
        else sum=0;
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
import sys
from collections import deque

n, m = map(int, sys.stdin.readline().split())
ab = map(int, sys.stdin.read().split())
ab = zip(*[ab] * 2)
graph = [set() for _ in range(n+1)]
for a, b in ab:
    graph[a].add(b)
    graph[b].add(a)

def main():
    que = set()
    for i in range(1, n+1):
        if len(graph[i]) == 1:
            que.add(i)
    res = len(que)
    while que:
        x = que.pop()
        y = graph[x].pop()
        graph[y] -= set([x])
        l = len(graph[y])
        if l == 0:
            que -= set([y])
            res -= 1
        elif l == 1:
            que.add(y)
            res += 1

    return res

if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 3316
#include<stdio.h>
#include<iostream>
#include<sstream>
#include<algorithm>
using namespace std;
int a[1005];
int cmp(int a,int b)
{
    return a>b;
}
int cha(int n)
{
    stringstream ss;
    ss<<n;
    string s;
    ss>>s;
    for(int i=1; s[i]; i++)
    {
        if(s[i]-1!=s[i-1])
            return 0;
    }
    return 1;
}
int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        for(int i=0; i<n; i++)
        {
            scanf("%d",&a[i]);
        }
        sort(a,a+n,cmp);
        int ans=-1;
        for(int i=0; i<n; i++)
        {
            for(int j=0; j<n; j++)
            {
                if(i==j)continue;
                if(cha(a[i]*a[j]))
                {
                    ans=a[i]*a[j];
                    break;
                }
            }
            if(ans!=-1)
                break;
        }
        printf("%d\n",ans);
    }
}

Measured memory_bytes: 3360
// C - Lining Up
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007

int main(){
	int N; cin>>N;

	vector<int> A(N);
	for(int i=0; i<N; i++){ int a; cin>>a; A[a]++; }

	int odd = N%2;
	int ans = odd? 1:2;

	if(A[!odd]!=ans){ cout<<'0'<<endl; return 0; }

	for(int i=3-odd; i<N; i+=2){
		if(A[i]!=2){ cout<< '0' <<endl; return 0; }
		ans = ans * 2 % MOD;
	}
	cout<< ans <<endl;
}

Measured memory_bytes: 640
#include <stdio.h>
	#include <iostream>
	#include <vector>
	#include <algorithm>
	using namespace std;
	typedef long long ll;
	typedef std::vector<ll> lls;
	#define MIN(a, b) ( ((a)<(b)) ? (a) : (b) )
	#define MAX(a, b) ( ((a)>(b)) ? (a) : (b) )

	void cinv(lls& llVec, ll n) {
		ll val;
		llVec.reserve((size_t)(n));
		for (ll i = 0; i < n; i++) {
			cin >> val;
			llVec.push_back(val);
		}
	}


	int main()
	{
		ll a;
		std::string s;

		cin >> a >> s;

		if (a >= 3200) cout << s;
		else cout << "red";

		return 0;
	}



Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

// 互除法で2正数x,yのgcdを返す関数
ll gcd (ll x, ll y) {
    ll p = x % y;
    while(p){
        x = y;
        y = p;
        p = x % y;
    }
    return y;
}

int main() {
    ll N, M;
    cin >> N >> M;
    vector<ll>a(N);
    for (int i = 0; i < N; ++i) {
        cin >> a[i];
    }
    ll k = a[0];
    for (int i = 0; i < N; ++i) {
        a[i] /= 2;
        k = gcd(k, a[i]);
    }

    ll kn = 0;
    while (k % 2 == 0) {
        k /= 2;
        kn++;
    }
    k = 1;
    for (int i = 0; i < kn; ++i) {
        k *= 2;
    }
    for (int i = 0; i < N; ++i) {
        a[i] /= k;
        if (a[i] % 2 == 0) {
            cout << 0 << "\n";
            return 0;
        }
    }

    ll lcm = 1;
    for (int i = 0; i < N; ++i) {
        lcm = lcm * a[i] / gcd(a[i], lcm);
    }
    
    lcm *= k;

    ll ans = M / lcm;
    ans = (ans + 1) / 2;
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>

using namespace std;

const int N=3e5+5;
int arr[N];
int main()
{
	int n, k;
	cin >> k >> n;
	if(k%2==0)
	{
		arr[0]=k/2;
		for(int i = 1; i < n; i++) arr[i]=k;
		for(int i = 0; i < n; i++) cout << arr[i] << " ";
		return 0;
	}
	for(int i = 0; i < n; i++) arr[i]=(k+1)/2;
	int tkdwn = n/2;
	int pos=n-1;
	while(tkdwn--)
	{
		while(arr[pos]==0)
		{
			pos--;
		}
		arr[pos]--;
		if(arr[pos]==0) continue;
		for(int i = pos+1; i < n; i++)
		{
			arr[i]=k;
		}
		pos=n-1;
	}
	for(int i = 0; i < n; i++)
	{
		if(arr[i]==0) break;
		cout << arr[i] << " ";
	}
}

Measured memory_bytes: 3456
N, X = [int(elem) for elem in input().split()]
total_distance = N
bigger, smaller = N - X, X
while bigger % smaller != 0:
    total_distance += 2 * (bigger // smaller) * smaller
    bigger, smaller = smaller, bigger % smaller

total_distance += 2 * (bigger // smaller) * smaller - smaller
print(total_distance)


Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		char s[] = new char[101];
		s = scan.next().toCharArray();

		for(int i = 0; i < s.length; i++) {
			if(i % 2 == 0) {
				// 偶数文字目がRでない
				if(s[i] == 'L') {
					System.out.println("No");
					return;
				}
			}else {
				// 奇数文字目がLでない
				if(s[i] == 'R') {
					System.out.println("No");
					return;
				}
			}
		}

		System.out.println("Yes");

	}
}

Measured memory_bytes: 23764
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main(){
	int n,m;
	while( cin >> n , n ){
		string s;
		cin >> m >> s;
		
		int dp[1000001] = {0};
		for(int i=2 ; i < s.size() ; i++ ){
			if( s[i-2] == 'I' && s[i-1] == 'O' && s[i] == 'I' ){
				dp[i] = dp[i-2] + 1;
			}
		}
		int ans = 0;
		for(int i=0 ; i < s.size() ; i++ ){
			if( dp[i] >= n ){
				ans++;
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 5944
import java.io.*;
import java.util.*;
import java.lang.Math;

public class Main {

    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner() {
            try {
                br = new BufferedReader(new InputStreamReader(System.in));
                st = new StringTokenizer(br.readLine());
            } catch (Exception e){e.printStackTrace();}
        }

        public String next() {
            if (st.hasMoreTokens()) return st.nextToken();
            try {st = new StringTokenizer(br.readLine());}
            catch (Exception e) {e.printStackTrace();}
            return st.nextToken();
        }

        public int nextInt() {return Integer.parseInt(next());}

        public long nextLong() {return Long.parseLong(next());}

        public double nextDouble() {return Double.parseDouble(next());}

        public String nextLine() {
            String line = "";
            if(st.hasMoreTokens()) line = st.nextToken();
            else try {return br.readLine();}catch(IOException e){e.printStackTrace();}
            while(st.hasMoreTokens()) line += " "+st.nextToken();
            return line;
        }
    }

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter pw = new PrintWriter(System.out);
        final int MOD = 1000000007;

        int k = sc.nextInt(), x = sc.nextInt();
        for(int i=x-k+1;i<x+k;i++) {
            pw.print(i + " ");
        }
        pw.close();
    }
}


Measured memory_bytes: 21204
#include <cstring>
#include <cstdio>
#include <algorithm>

using namespace std;
typedef long long ll;
const int MAXN = 2010;
const int MOD = 1e9+7;
int _w;

int C[MAXN][MAXN], sum[MAXN][MAXN], f[MAXN][MAXN];
void prelude() {
	for( int i = 0; i < MAXN; ++i ) {
		f[i][0] = sum[i][0] = C[i][0] = 1;
		for( int j = 1; j <= i; ++j )
			C[i][j] = (C[i-1][j] + C[i-1][j-1]) % MOD;
		for( int j = 1; j < MAXN; ++j )
			sum[i][j] = (sum[i][j-1] + C[i][j]) % MOD;
		for( int j = 1; j < MAXN; ++j )
			f[i][j] = (f[i][j-1] + sum[i][j]) % MOD;
	}
}

int solvet( int t, int b ) {
	int ans = 1; // i == 0
	for( int i = 1; i <= min(t-1, b); ++i )
		ans = int((ans + (ll)f[i-1][t-i-1] * C[b][i]) % MOD);
	return ans;
}

int main() {
	prelude();
	int a, b;
	_w = scanf( "%d%d", &a, &b );
	if( !a || !b ) return puts("1"), 0;
	int ans = 0;
	for( int t = 1; t <= a+1; ++t )
		ans = (ans + solvet(t, b-1)) % MOD;
	printf( "%d\n", ans );
	return 0;
}


Measured memory_bytes: 47488