akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

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

    int odd = 0;
    odd += a % 2;
    odd += b % 2;
    odd += c % 2;

    cout << (2 <= odd ? "Hom" : "Tem") << endl;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second

using namespace std;

typedef pair<int, int> ii;

const int maxN = 305;
const int mod = 1e9 + 7;

int n,m;
vector<ii> adj[maxN];
int f[maxN][maxN][maxN], x[maxN][maxN][maxN];

void precalc(int r, int g, int b){
    int tmp = (r == 0) + (g == 0) + (b == 0);

    if(tmp < 2 && (r == g || g == b || r == b)){
        x[r][g][b] = 1;
        return;
    }

    int k = max({r,g,b});

    for(auto i : adj[k]){
        if((r >= i.fi) + (g >= i.fi) + (b >= i.fi) != i.se){
            x[r][g][b] = 1;
            return;
        }
    }
}


int32_t main()
{
    ios_base::sync_with_stdio(false); cin.tie(); cout.tie();
    cin >> n >> m;
    for(int i = 1; i <= m; ++i){
        int l,r,x;
        cin >> l >> r >> x;
        adj[r].push_back({l,x});
    }

    for(int r = 0; r <= n; ++r)
        for(int g = 0; g <= n; ++g)
            for(int b = 0; b <= n; ++b)
                precalc(r,g,b);

    f[0][0][0] = 1;

    int res = 0;
    for(int r = 0; r <= n; ++r)
        for(int g = 0; g <= n; ++g)
            for(int b = 0; b <= n; ++b){
                if(f[r][g][b]){
                    int tmp = max({r,g,b});
                    if(!x[tmp + 1][g][b])
                        f[tmp + 1][g][b] = (f[tmp + 1][g][b] + f[r][g][b]) % mod;
                    if(!x[r][tmp + 1][b])
                        f[r][tmp + 1][b] = (f[r][tmp + 1][b] + f[r][g][b]) % mod;
                    if(!x[r][g][tmp + 1])
                        f[r][g][tmp + 1] = (f[r][g][tmp + 1] + f[r][g][b]) % mod;
                    if(tmp == n)
                        res = (res + f[r][g][b]) % mod;
                }
            }

    cout << res % mod;

}



Measured memory_bytes: 222328
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;i++)


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

    sort(a.rbegin(),a.rend());
    cout<<a[1]+a[2]<<endl;
    
    return 0;
}

Measured memory_bytes: 256
IDENTIFICATION                   DIVISION.
PROGRAM-ID.                      ABC_078_A.
ENVIRONMENT                      DIVISION.
DATA                             DIVISION.
WORKING-STORAGE                  SECTION.
    01 INP    PIC X(3).
    01 X      PIC X(1).
    01 Y      PIC X(1).

PROCEDURE                        DIVISION.
MAIN.
    ACCEPT INP.

    UNSTRING INP
    DELIMITED BY SPACE
    INTO X Y.

    IF X < Y THEN
        DISPLAY '<'
    ELSE
        IF X = Y THEN
            DISPLAY '='
        ELSE
            DISPLAY '>'
        END-IF
    END-IF.

    STOP RUN.


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;

int max1, max2;

void checkmax(int a){
  if(a > max1){
    max2 = max1;
    max1 = a;
  }else if(a > max2){
    max2 = a;
  }
}

int main(){
  int N;cin>>N;
  vi A(N);
  int a;
  max1 = max2 = 0;
  for(int i=0; i<N; i++){
    cin>>a;
    checkmax(a);
    A[i] = a;
  }

  for(int i=0; i<N; i++){
    cout<<(A[i]==max1? max2: max1)<<endl;
  }
}

Measured memory_bytes: 2432
#include<cstdio>
char s[200001]={};
int main(){
    scanf("%s",s);
    int cnt=1,last_len=1,itr=1;
    while(s[itr]!='\0'){
        if(last_len==2){
            last_len=1;
            ++itr;
        }else if(s[itr]==s[itr-1]){
            if(s[itr+1]=='\0')break;
            last_len=2;
            itr+=2;
        }else{
            ++itr;
        }
        ++cnt;
    }
    printf("%d\n",cnt);
    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>

int main(void)
{
	int a,b;
	char op;
	do{
		scanf("%d %c %d",&a,&op,&b);
		if(op=='+'){
			printf("%d\n",a+b);
		}else if(op=='-'){
			printf("%d\n",a-b);
		}else if(op=='*'){
			printf("%d\n",a*b);
	}else if(op=='/'){
			printf("%d\n",a/b);
	}
	}while(op=='+' || op=='-' || op=='*' || op=='/');
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define pii pair <int, int>
#define fi first
#define sc second
#define ALL(x) x.begin(), x.end()
#define RALL(X) x.begin(), x.end()
#define FOR(i, n, k) for(i=0; i<n; i+=k)
#define FO(i, n, k) for(i=1; i<=n; i+=k)
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define N 100005
#define mid ((l+r)/2)
#define dbg(x) (cerr << #x << " : " << x << endl)
#define endl "\n"
#define MOD 100000009

using namespace std;

typedef long long int lli;

bool even(int x){
	int bsmk = 0;
	while(x){
		int digit = x%10;
		x -= digit;
		x /= 10;
		bsmk++;
	}
	return bsmk % 2;
}

int main(){
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	int res=0;
	for(int i=0; i<=n; i++){
		if(even(i)) res++;
	}
	cout << res;
	return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ll long long
#define db double
#define el "\n"
#define ld long double
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n;i>=0;i--)
#define rep_a(i,a,n) for(int i=a;i<n;i++)
#define tr(ds, it) for(auto it=ds.begin(); it!=ds.end(); it++)
#define rtr(ds, it) for(auto it=ds.rbegin(); it!=ds.rend(); it--)
#define all(ds) ds.begin(), ds.end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
typedef priority_queue <int> pq;
typedef vector< long long > vi;
typedef pair<long long, long long> ii;
#define o_set tree<ii, null_type,less<ii>, rb_tree_tag,tree_order_statistics_node_update>
#define Mod 1000000007
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

struct graph {
	
	int V;
	vector<int> *adj;
	
	graph(int x) {
		V = x;
		adj = new vector<int>[x];
	}
	
	void AddEdge (int a, int b) {
		
		adj[a].pb(b);
		adj[b].pb(a);
	}
};

int main()
{
    fastio;
//	#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r" , stdin);
//    freopen("output.txt", "w" , stdout);
//    #endif
    
	int n, m, x, y;
	cin >> n >> m;
	
	int value[n];
	rep(i, n)
		cin >> value[i];
		
	graph g(n);
	
	rep(i, m) {
		
		cin >> x >> y;
		x--;
		y--;
		g.AddEdge(x, y);
	}	
	
	int count = 0;
	
	rep(i, n) {
		
		bool flag = true;
		
		for (auto it = g.adj[i].begin(); it != g.adj[i].end(); it++){
			
			if (*it != i && value[*it] >= value[i]) {
				flag = false;
				break;
			}
		}
		if (flag)
			count++;
	}
	
	cout << count << "\n";
	
	//code
	return 0;
}


Measured memory_bytes: 9172
n=int(input())
s=[]
number=[0,0,0,0,0] #MARCH

for i in range(n):
    s.append(input())
for i in range(n):
    if s[i][0]=="M": 
        number[0]+=1
    elif s[i][0]=="A":
        number[1]+=1
    elif s[i][0]=="R":
        number[2]+=1
    elif s[i][0]=="C":
        number[3]+=1
    elif s[i][0]=="H":
        number[4]+=1


k=[]
k.append(number[0]*number[1]*number[2])
k.append(number[0]*number[1]*number[3])
k.append(number[0]*number[1]*number[4])
k.append(number[0]*number[2]*number[3])
k.append(number[0]*number[2]*number[4])
k.append(number[0]*number[3]*number[4])

k.append(number[1]*number[2]*number[3])
k.append(number[1]*number[2]*number[4])
k.append(number[1]*number[3]*number[4])
k.append(number[2]*number[3]*number[4])

print(sum(k))

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

#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long
 
const int N=3e5+5,MAX=3e7,MOD=1e9+7;
 
using namespace std;


int n;
int main()
{
   	
 

    	string a,b;
	cin>>a>>b;

	int ans = 0;
	for(int i=0;i<3;i++)ans+=(a[i]==b[i]);

	cout<<ans<<endl;



}	


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//s[i]-'0'でchar文字→int数に;
//string s = to_string(int数);
//int n = stoi(string文字列)
//実行時間制約2秒では２×10^8回くらいまで計算できる


int main() {
  int n;
  cin >> n;
  
  vector<ll> p(n);
  ll ans=0;
  rep(i,n){
  cin>>p[i];
    ans+=p[i]-1;
  }
    
  
  cout << ans << endl;
}


Measured memory_bytes: 256
// Using fgets(3) and strtol(3) to obtain integers. 
// It may be faster than scanf(3) version sometimes. 
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>

int64_t solve(char *begin, char *end);

int main(int argc, char const* argv[])
{
  char *next;
  int64_t N, Q;
  char buf[32];
  fgets(buf, sizeof(buf), stdin);
  N = strtol(buf, &next, 10);
  Q = strtol(next + 1, NULL, 10);
  // fprintf(stderr, "N = %ld, Q = %ld\n", N, Q);
  
  char *S = malloc((size_t)N + 1);
  fgets(S, N + 1, stdin);
  getchar();

  int64_t R[N];
  memset(R, 0, 8 * N);
  for (int i = 0; i < N - 1; i++) {
    R[i + 1] = R[i] + (((S[i] == 'A') && (S[i + 1] == 'C')) ? 1 : 0);
  }

  int64_t l, r, res;

  for (int i = 0; i < Q; i++) {
    memset(buf, 0, sizeof(buf));
    fgets(buf, sizeof(buf), stdin);
    l = strtol(buf, &next, 10);
    r = strtol(next + 1, NULL, 10);
    res = R[r - 1] - R[l - 1];
    printf("%lu\n", res);
  }

  free(S);
  return 0;
}





Measured memory_bytes: 1664
#include <stdio.h>
int H,W;
char map[101][101];
int dx[4]={1,0,-1,0};
int dy[4]={0,-1,0,1};
void print(){
  int i,j;
  for(i=0;i<H;i++){
    for(j=0;j<W;j++){
      printf("%c",map[i][j]);
    }
    printf("\n");
  }
  printf("\n");
}
void dfs(int y,int x,char c){
  int nx,ny;
  int i,j;
  int ans;
  //print();
  map[y][x]='.';
  for(i=0;i<4;i++){
    nx=x+dx[i];
    ny=y+dy[i];
    if(map[ny][nx]==c && 0<=nx && nx<W && 0<=ny && ny<H){
    
      dfs(ny,nx,c);
    }
  }
}
void init(){
  int i,j;
  for(i=0;i<H;i++){
    for(j=0;j<W;j++){
      map[i][j]='.';
    }
  }
}
int main(){
  int i,j;
  int ans=0;
  while(1){
    ans=0;
    scanf("%d %d",&H,&W);
    if(H==0 && W==0)break;
    init();
    for(i=0;i<H;i++){
      scanf("%s",&map[i]);
    }
    for(i=0;i<H;i++){
      for(j=0;j<W;j++){
	if(map[i][j]!='.'){
	  dfs(i,j,map[i][j]);
	  ans++;
	}
      }
    }
    printf("%d\n",ans);
  }
  return 0;
}

Measured memory_bytes: 1080
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<iomanip>
#include<cstring>
#define initdp(a,b) for(int i=0;i<=a;i++)for(int j=0;j<=b;j++)dp[i][j]=-1;
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0;i<n;i++)
#define repd(i,n) for(int i=n-1;i>=0;i--)
#define waste ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define inf 1e9+1
#define inf1 1e18+1
#define mod 1000000007
#define pie 3.14159265358979323846
#define N 100005
#define mid(l,r) l+(r-l)/2
using namespace std;
ll gcd(ll a,ll b){ if(a>b)swap(a,b);if(!a)return b;return gcd(b%a,a);}
int n,k,q;
int tin[N],tout[N],tim,num,sum;
int up[N][20],ls[N*20],rs[N*20],Root[N],mark,cnt[N*20],tot[N*20];
struct edge{
	ll int u,v,c,w;
	edge(){}
	edge(int a,int b,int c,int d){u=a;v=b;this->c=c;w=d;}
};
vector<int>ed[N];
int dis[N];
edge edg[N];
void addnode(int &i,int pa,int l,int r,int c,int w){
	i=++mark;
	cnt[i]=cnt[pa]+1;
	tot[i]=tot[pa]+w;
	ls[i]=ls[pa];
	rs[i]=rs[pa];
	if(l==r)return;
	if(c<=mid(l,r))addnode(ls[i],ls[pa],l,mid(l,r),c,w);
	else addnode(rs[i],rs[pa],mid(l,r)+1,r,c,w);
}
void qry(int i,int l,int r,int c){
	//if(c>r||c<l)return;
	if(l==r){
		num=cnt[i];
		sum=tot[i];
		return;
	}
	if(c<=mid(l,r))qry(ls[i],l,mid(l,r),c);
	else qry(rs[i],mid(l,r)+1,r,c);
}
void dfs(int i,int p,ll ww){
	tin[i]=++tim;
	dis[i]=dis[p]+ww;
	up[i][0]=p;
	for(int j=1;j<=k;j++)up[i][j]=up[up[i][j-1]][j-1];
	for(int j:ed[i]){
		int v=edg[j].u+edg[j].v-i;
		if(v==p)continue;
		addnode(Root[v],Root[i],0,n-1,edg[j].c,edg[j].w);
		dfs(v,i,edg[j].w);
	}
	tout[i]=++tim;
}
bool isan(int i,int j){
	return tin[i]<=tin[j]&&tout[i]>=tout[j];
}
int lca(int i,int j){
	if(isan(i,j))return i;
	if(isan(j,i))return j;
	for(int k1=k;k1>=0;k1--){
		if(!isan(up[i][k1],j))i=up[i][k1];
	}
	return up[i][0];
}
void solve(){
	cin>>n>>q;
	k=log2(n)+1;
	for(int i=0;i<n-1;i++){
		ll int u,v,c,w;
		cin>>u>>v>>c>>w;
		edg[i]=edge(u,v,c,w);
		ed[u].pb(i);
		ed[v].pb(i);
	}
	tin[0]=++tim;
	dfs(1,0,0);
	tout[0]=++tim;
	while(q--){
		ll u,v,c,w;
		cin>>c>>w>>u>>v;
		int l=lca(u,v);
		qry(Root[u],0,n-1,c);
		int a1=num,b1=sum;
		qry(Root[v],0,n-1,c);
		int a2=num,b2=sum;
		qry(Root[l],0,n-1,c);
		int a3=a1+a2-2*num,b3=b1+b2-2*sum;
		cout<<dis[u]+dis[v]-2*dis[l]-b3+a3*w<<"\n";
	}
}
int main()
{
	waste;
	int t;
	//cin>>t;
	t=1;
	while(t--){
		solve();
	}
}

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

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using mii = map<int, int>;
using msi = map<string, int>;
using pii = pair<int, int>;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::fixed << std::setprecision(10);
    
    int n; cin >> n;
    string s; cin >> s;
    int ans = 0; char cur = 'A';
    REP(i, n) {
        if(cur != s[i]) ans++;
        cur = s[i];
    }
    cout << ans << endl;
    

    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <string>
#include <vector>
/* 変数i を n回繰り返すマクロ */
#define rep(i,n) for (int i = 0;i < (n);i++)
using namespace std;
int main()
{
    cout << fixed << setprecision(10);//小数点以下10桁出力
    int n;
    cin >> n;
    vector<int> a(n);
    bool flag = false;
    rep(i,n){
        int in;
        cin >> in;
        if(in % 2 == 0){
            if(in % 3 == 0 || in % 5 == 0){

            }else{
                flag = true;
            }
        }
    }

    if(flag == true){
        cout << "DENIED" << endl;
    }else{
        cout << "APPROVED" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
N, M = list(map(int, input().split(' ')))
a = []
b = []
for i in range(M):
    ai, bi = list(map(int, input().split(' ')))
    a.append(ai-1)
    b.append(bi-1)


class UnionFind:
    def __init__(self, n):
        self.p = {}
        self.r = {}
        self.s = {}
        for i in range(n):
            self.p[i] = i
            self.r[i] = 1
            self.s[i] = 1


    def find(self, n):
        path = []
        while n != self.p[n]:
            path.append(n)
            n = self.p[n]
        for m in path:
            self.p[m] = n
        return n


    def union(self, a, b):
        ap = self.find(a)
        bp = self.find(b)
        if self.r[ap] > self.r[bp]:
            self.p[bp] = ap
            size = self.s[bp] + self.s[ap]
            self.s[ap] = size
        elif self.r[ap] < self.r[bp]:
            self.p[ap] = bp
            size = self.s[bp] + self.s[ap]
            self.s[bp] = size
        elif ap != bp:
            self.p[ap] = bp
            self.r[bp] += 1
            size = self.s[bp] + self.s[ap]
            self.s[bp] = size

    def size(self, n):
        np = self.find(n)
        return self.s[np]


s = UnionFind(N)

ans = (N*(N-1)) // 2
anss = [ans]
for i in range(M):
    j = M-i-1
    if s.find(a[j]) != s.find(b[j]):
        ans -= s.size(a[j]) * s.size(b[j])
        s.union(a[j], b[j])
    if i != M-1:
        anss.append(ans)

for i in range(len(anss)):
    j = len(anss)-1-i
    print(anss[j])

Measured memory_bytes: 37804
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
#define bra(first,second) '(' << first << ',' << second << ')'
ll MOD = 1000000007;
//ll INF = 21474836470000000;
ll INF = 1001001001001001001;
long double EPS = 1e-11;
long double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<ll>>;

ll ceil(ll a,ll b){
   return (a+b-1)/b;
}

ll K,Q;
ll D[5010];

int main(){
   cin >> K >> Q;
   rep(i,K) cin >> D[i];
   rep(i,Q){
      ll n,x,m;
      cin >> n >> x >> m;
      ll sum = x,eq = 0;
      rep(j,K){
         ll num = ceil(n - 1 - j,K);
         sum += (D[j] % m) * num;
         if(D[j] % m == 0) eq += num;
      }
      cout << (n - 1) - (sum / m - x / m) - eq << endl;
   }
}


Measured memory_bytes: 384
k,n = list(map(int,input().split()))
a = list(map(int,input().split()))

last = a[0] + k - a[-1]

ans = 0
for i in range(n-1):
    ans = max(ans,a[i + 1] - a[i])
ans = max(ans,last)
print(k - ans)

Measured memory_bytes: 78540
using System;
using System.Linq;

class Program
{
	static void Main(string[] args)
	{
		// 入力
        var n = int.Parse(Console.ReadLine());
		string[] input = Console.ReadLine().Split(' ');
        int count1 = 1;
        int count2 = 0;
        bool flag = false;
        for (int i = 0; i < n; i++)
        {
            if (int.Parse(input[i]) == count1)
            {
                count1++;
                count2++;
                flag = true;
            }
        }

        if (!flag)
        {
            Console.WriteLine(-1); 
        }
        else 
        {
            Console.WriteLine(n- count2); 
        }
	}
}

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> d(n);
  vector<vector<int>> a(n, vector<int>());
  rep(i, n) {
    cin >> d.at(i);
    a.at(i).resize(d.at(i));
    rep(j, d.at(i)) cin >> a.at(i).at(j);
  }
  int ans = 0;
  rep(i, n) {
    bool have = false;
    rep(j, n) {
      rep(k, d.at(j)) {
        if(i + 1 == a.at(j).at(k)) have = true;
      }
    }
    if(have == false) ans++;
  }
  cout << ans << endl;
} 

Measured memory_bytes: 3672
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <math.h>
 
#define MOD 1000000007
#define INF INT_MAX
#define NINF INT_MIN
#define LLINF LLONG_MAX
using ll = long long;
using namespace std;
 
 
int main() {
    int a, b, c, d, e, t = 0, k = 10;
    cin >> a >> b >> c >> d >> e;
    t += (a + 9) / 10 * 10;
    t += (b + 9) / 10 * 10;
    t += (c + 9) / 10 * 10;
    t += (d + 9) / 10 * 10;
    t += (e + 9) / 10 * 10;
    if (a % 10 != 0) {
        k = min(k, a % 10);
    }
    if (b % 10 != 0) {
        k = min(k, b % 10);
    }
    if (c % 10 != 0) {
        k = min(k, c % 10);
    }
    if (d % 10 != 0) {
        k = min(k, d % 10);
    }
    if (e % 10 != 0) {
        k = min(k, e % 10);
    }
    if (k != 10) {
        t += k - 10;
    }
    cout << t << endl;
    getchar(); getchar();
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	int S ,h ,m ,s ,temp;
	scanf("%d",&S);
	temp=S/60;
	h=temp/60;
	m=temp%60;
	s=S%60;
	printf("%d:%d:%d\n",h,m,s);
	return 0;
}

Measured memory_bytes: 592
n= int(input())
a = list(map(int,input().split()))

ls = []
ls.append(a[0])

for i in range(1,n):
    ls.append(a[i]+ls[i-1])

Sum = ls[-1]
ans = 10**20
for i in range(0,n-1):
    ans = min(abs(Sum-2*ls[i]),ans)

print(ans)

Measured memory_bytes: 86864
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	int N, x; cin >> N >> x;
	vector<int> a(N);
	rep(i, N) cin >> a[i];
	vector<vector<int> > dp(N + 1, vector<int>(256));
	dp[0][0] = 1;
	rep(i, N) {
		vector<vector<int> > _dp = dp;
		rep(k, N) rep(x, 256)
			_dp[k + 1][x ^ a[i]] = (_dp[k + 1][x ^ a[i]] + dp[k][x]) % MOD;
		dp = _dp;
	}
	int ans = 0;
	rep(k, N + 1) {
		ll z = dp[k][x];
		for (int i = 1; i <= k; i++)
			z = z * i % MOD;
		ans = (ans + z) % MOD;
	}
	cout << ans << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define pb push_back
#define int long long
#define mp make_pair
#define inf 1000000007
#define LINF 10000000000000007LL
#define ll long long
using namespace std;
int dis[309][309];
int sait[309][309];
signed main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			cin>>dis[i][j];
		}
	}
	for(int i=1;i<=n;i++){
		if(dis[i][i] != 0){
			cout<<-1<<endl;
			return 0;
		}
	}
	for(int k=1;k<=n;k++){
		for(int i=1;i<=n;i++){
			for(int j=1;j<=n;j++){
				if( i != k && j != k){
					if( dis[i][j] > dis[i][k] + dis[k][j]){
						cout<<-1<<endl;
						return 0;
					}
					else if( dis[i][j] == dis[i][k] + dis[k][j]){
						sait[i][j] = -1;
					}
				}
			}
		}
	}
	int ans = 0;
	for(int i=1;i<=n;i++){
		for(int j=i+1;j<=n;j++){
			if(sait[i][j] == 0)ans += dis[i][j];
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1664
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <iostream>
#include <limits>
#include <climits>
#include <functional>
#include <numeric>

using namespace std;

#define alloc(type,n) (type*)calloc(sizeof(type),(n));
typedef long long lli;

lli n;
vector<pair<lli,lli> > a;
vector<lli> ans;
lli max_n;
vector<pair<lli,lli> >::iterator itr;
lli now_i = 100001;
lli wide_length;

int main(){
	cin >> n;
	a = vector<pair<lli,lli> >(n+1);
	ans = vector<lli>(n+1);
	for(int i = 0;i < n;i++){
		int x;
		cin >> x;
		a[i] = make_pair(x,i);
	}
	sort(a.begin(),a.end());
	max_n = a.back().first;
	while (true) {
		itr = lower_bound(a.begin(),a.end(),make_pair(max_n,(lli)0));
		now_i = min(now_i,itr->second);
		wide_length = (lli) (a.end() - itr);
		if(itr == a.begin()) break;
		itr--;
		lli nex_max = itr->first;
		ans[now_i] += (max_n - nex_max) * wide_length;
		max_n = nex_max;
	}
	ans[now_i] += (max_n - 0) * wide_length;
	for(int i = 0;i < n;i++){
		cout << ans[i] << endl;
	}

	return 0;
}


Measured memory_bytes: 3456
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <string>
#include <sstream>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <stack>
#include <cstdio>
#include <climits>
#include <tuple>
#include <ctime>
#include <cstring>
#include <numeric>
#define FOR(i,a,n) for (int i = a; i < n; i++)
#define IFOR(i,n,a) for (int i = n; i >= a; i--)
#define mp make_pair
#define full(a) a.begin(), a.end()
#define sz(x) ((int)(x).size())
#define pii pair<int, int>
#define trav(a,x) for (auto& a : x)
using ull = unsigned long long;
using ll = long long;
using ld = long double;
using namespace std;
const ll mod = 1e9 + 7;
const int N = 5005;


void solve()
{
    string s, t; cin >> s >> t;
    int n1 = sz(s), n2 = sz(t);
    int mn = 2e9;
    FOR(i, 0, n1 - n2 + 1)
    {
        int c = 0;
        int tmp = i;
        FOR(j, 0, n2)
        {
            if (s[tmp] != t[j])
            {
                c++;
            }
            tmp++;
        }
        mn = min(mn, c);
    }
    cout << mn;
}

int main()
{
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    /*int tc;  cin >> tc;
    while (tc--)*/
        solve();
    return 0;
}







Measured memory_bytes: 3192
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    public static bool f = false, t = true;
    static void Main(string[] args)
    {
        int n = Read.Int();
        int K = Read.Int();
        int[] a = Read.ints();
        long ans = 0;
        for(int i = 0; i < a.Length; i++)
        {
            ans += 2 * (Math.Min(a[i],K-a[i]));
        }Console.WriteLine(ans);
        Console.ReadLine();
    }

    public static long gcd(long a, long b)
    {
        while (true)
        {
            if (a == 0) { return b; }
            if (b == 0) { return a; }
            if (a > b) { a -= b; }
            else { b -= a; }
        }
    }
    public static long lcm(long a, long b)
    {
        return a / gcd(a, b) * b;
    }
    public static bool IsPrime(long n)
    {
        if (n < 2) return false;
        if (n == 2) return true;

        for (long i = 2; i < n; i++)
        {
            if (n % i == 0) return false;
        }
        return true;
    }

}
public static class Read
{
    public static void outl(string n = "") { Console.WriteLine(n); return; }
    public static long Long()
    {
        return long.Parse(Console.ReadLine());
    }
    public static long[] longs()
    {
        return Console.ReadLine().Split().Select(long.Parse).ToArray();
    }
    public static int Int()
    {
        return int.Parse(Console.ReadLine());
    }
    public static int[] ints()
    {
        return Console.ReadLine().Split().Select(int.Parse).ToArray();
    }
    public static string Str() { return Console.ReadLine(); }
    public static string[] Strs() { return Console.ReadLine().Split(); }
}

Measured memory_bytes: 13396
#include "bits/stdc++.h"
using namespace std;

int main() {
	int N;
	cin >> N;
	vector<long long> A(N), B(N);
	vector<pair<long long, pair<int, int> > > V;
	for (int i = 0; i < N; i++) {
		cin >> A[i] >> B[i];
		V.push_back({ A[i], {i, 0} });
		V.push_back({ B[i], {i, 1} });
	}
	sort(V.begin(), V.end());
	vector<vector<bool> > Use(N, vector<bool>(2, false));
	long long COUNT = 0;
	for (int i = 0; i < N; i++) {
		COUNT += V[i].first;
		Use[V[i].second.first][V[i].second.second] = true;
	}
	bool check = false;
	bool check2 = true;
	for (int i = 0; i < N; i++) {
		if (Use[i][1]) check2 = false;
	}
	if (check2) check = true;
	check2 = true;
	for (int i = 0; i < N; i++) {
		if (Use[i][0]) check2 = false;
	}
	if (check2) check = true;
	check2 = false;
	for (int i = 0; i < N; i++) {
		if (Use[i][0] && Use[i][1]) check2 = true;
	}
	if (check2) check = true;
	if (check) {
		cout << COUNT << endl;
		return 0;
	}
	long long ANS = 1000000000000000;
	vector<long long> L(N + 1, 0), R(N + 1, 0);
	for (int i = 0; i < N; i++) {
		L[i + 1] = max(L[i], min(A[i], B[i]));
	}
	for (int i = N - 1; i >= 0; i--) {
		R[i] = max(R[i + 1], min(A[i], B[i]));
	}
	for (int i = 0; i < N; i++) {
		ANS = min(ANS, COUNT - max(L[i], R[i + 1]) + max(A[i], B[i]));
	}
	cout << ANS << endl;
}

Measured memory_bytes: 14316
#include <stdio.h>
#include <math.h>

int main(){
    int a,b;
    for(a=1;a<=9;a+=1){
        for(b=1;b<=9;b+=1){
             printf("%dx%d=%d\n",a,b,a*b);
        }
    }
    return 0;
}

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

#ifdef LOCAL
#define DEBUG(...) cerr << #__VA_ARGS__ << ": ", debug(__VA_ARGS__);
#else
#define DEBUG(...)
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator << (ostream &os, const vector<T> &v) {os << "["; for (int i=0; i<(int)v.size(); i++) {if (i) os << ", "; os << v[i];} return os << "]";}
void debug() {cerr << "\n";} template<typename T, typename... Args> void debug(T x, Args... args) {cerr << x << "; "; debug(args...);}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int k;
    cin >> k;

    queue<long long> q;
    for (int i=1; i<10; i++)
        q.push(i);
    while (--k) {
        long long x = q.front();
        q.pop();

        int rm = x % 10;
        if (rm != 0)
            q.push(10 * x + rm - 1);
        q.push(10 * x + rm);
        if (rm != 9)
            q.push(10 * x + rm + 1);
    }

    cout << q.front() << "\n";

    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf ll(10e15)
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    ll t;
    t=1;
    while(t--)
    {
        ll n,m;
        cin>>n>>m;
        vector<ll> vec(n);
        for(ll &x:vec)
            cin>>x;
        sort(vec.rbegin(),vec.rend());
        ll sum=0;
        for(auto x:vec)sum+=x;

        ll count=0;
        for(auto x:vec)
        {
            if(x*4*m>=sum)
            ++count;
            else break;
        }
        if(count>=m)
        cout<<"Yes"<<endl;
        else cout<<"No";
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
typedef long long ll;
int X,Y,Z;
int N;
const int MN = 300000;
ll a[MN],b[MN],c[MN];
typedef pair<ll,ll> P;
int main(){
	cin>>X>>Y>>Z;
	int N = X+Y+Z;
	rep(i,N) cin>>a[i]>>b[i]>>c[i];

	ll offa = 0;
	rep(i,N) offa += a[i];

	vector<P> vp;
	rep(i,N) vp.pb(P(b[i]-a[i], c[i]-a[i]));
	sort(all(vp),greater<P>());
	rep(i,N) b[i] = vp[i].fs, c[i] = vp[i].sc;


	vector<ll> bsm(Z+1,0);
	vector<ll> ups(Z+1,0);
	{
		priority_queue<ll> que;
		ll upk = 0;
		ll dif = 0;

		rep(i,N){
			dif += b[i];
			que.push(c[i]-b[i]);

			int n = i+1;
			if(n>Y){
				ll d = que.top();que.pop();
				upk += d;
			}
			int k = n-Y;
			if(0<=k && k<=Z){
				bsm[k] = dif;
				ups[k] = upk;
			}

		}
	}

	vector<ll> csm(Z+1,0);
	{
		priority_queue<ll> que;
		ll dif = 0;
		for(int i = N-1; i>=0; i--){
			que.push(c[i]);
			int n = N-i;
			if(n>X){
				ll d = que.top();que.pop();
				dif += d;
			}
			if(X<=n&&n<=X+Z){
				csm[n-X] = dif;
			}
		}
	}

	ll mx = -1e18;
	rep(k,Z+1){
		ll tmp = bsm[k] + ups[k] + csm[Z-k];
		chmax(mx,tmp);
	}

	ll ans = offa + mx;
	cout<<ans<<endl;

}


Measured memory_bytes: 8816
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr long long MOD = 1000000000 + 7;
constexpr long long INF = std::numeric_limits<long long>::max();
const double PI = acos(-1);
#define fir first
#define sec second
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Mfor(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, k, s, t, q, ans, sum, last, cnt = 25000, a[100000],dp[60][10000];
Pll b[100000];
struct Edge { LL to,cost; };
vector<Edge>vec[100000];
string str[3];
bool f;
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
struct Seg {
	LL n;
	vector<LL>node;
	/*Seg(vector<LL>v) {
		n = 1; while (n < v.size())n *= 2;
		node.resize(n * 2 - 1);
		rep(i, n)node[n + i - 1] = v[i];
		Mfor(i, n - 2)node[i] = min(node[i * 2 + 1], node[i * 2 + 2]);
	}*/
	Seg(LL n_) {
		n = 1; while (n < n_)n *= 2;
		node.resize(n * 2 - 1);
		rep(i, n)node[n + i - 1] = ((LL)1 << 31) - 1;
		Mfor(i, n - 1)node[i] = min(node[i * 2 + 1], node[i * 2 + 2]);
	}
	void update(LL i, LL x) {
		i = i + n - 1;
		node[i] = x;
		while (i > 0) {
			i = (i - 1) / 2;
			node[i] = min(node[i * 2 + 1], node[i * 2 + 2]);
		}
	}
	LL find(LL i, LL a, LL b, LL l, LL r) {
		if (b< l || r < a)return INF;
		if (l <= a&&b <= r)return node[i];
		return min(find(i * 2 + 1, a, (a + b) / 2, l, r), find(i * 2 + 2, (a + b + 1) / 2, b, l, r));
	}
};
int main() {
	cin >> n >> q;
	Seg seg(n);
	rep(i, q) {
		LL x, y, z;
		cin >> x >> y >> z;
		if (x == 0)seg.update(y, z);
		else cout << seg.find(0, 0, seg.n-1, y, z) << endl;
	}
	return 0;
}



Measured memory_bytes: 7340
program scoring
    implicit none
    integer(8)::t1,t2,t_rate,t_max,diff!実行時間の計測関連
    integer(8)::D,C(26),last(26,365),last_sim(26,365),i,j,k,vmax,tbest,torigin
    integer(8)::drand,qrand!局所探索法の書き換え関連
    integer(8)::contests=26
    integer(8)::steps=0!ベンチマーク用
    integer(8),allocatable::S(:,:),T(:),V(:),Vorigin(:)
    !時間計測開始
    call system_clock(t1)

    !入力
    read*,D,C
    allocate(S(26,D))
    allocate(T(D))
    allocate(V(D))
    allocate(Vorigin(D))
    read*,S
    T=0
    V=0
    last=0
    last_sim=0

    !貪欲法による初期解の生成
    do i=1,D
        do j=1,26
            !得点の初期化
            if(i==1)V(i)=0
            if(i>1)V(i)=V(i-1)

            !lastの初期化
            if(i==1)last(:,i)=0
            if(i>1)last(:,i)=last(:,i-1)

            last(j,i)=i
            V(i)=V(i)+S(j,i)
            
            do k=1,26
                V(i)=V(i)-C(k)*(i-last(k,i))
            end do

            if(j==1)then
                vmax=V(i)
                tbest=j
            else if(V(i)>=vmax)then
                vmax=V(i)
                tbest=j
            end if
        end do
        if(i==1)last(:,i)=0
        if(i>1)last(:,i)=last(:,i-1)
        T(i)=tbest
        last(tbest,i)=i
    end do
    vmax=V(D)
    call system_clock(t2,t_rate,t_max)
    diff=t2-t1

    do
        if(diff>19900000)exit

        !乱数の生成
        drand=rnd_int(D)
        qrand=rnd_int(contests)

        last_sim(:,:)=last(:,:)
        Vorigin(:)=V(:)
        !drand日目に行うコンテストをqrandに変更する
        !last_simの書き換え
        torigin=T(drand)
        if(drand==1)then
            last_sim(T(drand),1)=0
            last_sim(qrand,1)=1
        else
            last_sim(T(drand),drand)=last(T(drand),drand-1)
            last_sim(qrand,drand)=drand
        end if
        !日付に対応するコンテストタイプの書き換え
        T(drand)=qrand

        !drand日目の得点の再計算
        if(drand==1)then
            V(drand)=0
        else
            V(drand)=V(drand-1)
        end if
        V(drand)=V(drand)+S(T(drand),drand)
        do i=1,26
            V(drand)=V(drand)-C(i)*(drand-last(i,drand))
        end do

        !drand+1日目以降の得点の再計算
        do i=drand+1,D
            last_sim(:,i)=last(:,i-1)
            V(i)=V(i-1)
            V(i)=V(i)+S(T(i),i)
            last(T(i),i)=i
            do j=1,26
                V(i)=V(i)-C(j)*(i-last(j,i))
            end do
        end do

        if(V(D)>vmax)then
            vmax=V(D)
            last(:,:)=last_sim
            Vorigin(:)=V
        else
            T(drand)=torigin
        end if
        !時間計測
        call system_clock(t2,t_rate,t_max)
        diff=t2-t1
    end do

    !答えの出力
    do i=1,D
        print'(i0)',T(i)
    end do
contains
function rnd_int(rnd_max)
    integer(8),intent(in)::rnd_max
    integer(8)::rnd_int
    real::rnd_real
    call random_number(rnd_real)
    rnd_int=mod(int(rnd_real*100000000),rnd_max)+1
    return
end function
end program scoring

Measured memory_bytes: 3228
#include <bits/stdc++.h>
#define F first
#define S second
#define endl '\n'
#define rep(i , a , n) for (int i=a; i<(int)(n); i++)
#define re(i , n)     for (int i=0; i<(int)(n); i++)
#define pb push_back
#define em emplace_back
#define IOS ios_base::sync_with_stdio(false);cin.tie(0); cout.tie(0)
#define trace(a) cerr << #a << " = " << a << endl

using namespace std;

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

const int mod=7+1e9;
const int inf=1e9+5;
const ll  INF=1e18+5;
const int N=2e5+5;

int main()
{
    IOS;
    int n,m,L;
    cin>>n>>m>>L;
    vector<vector<ll>> dis(n,vector<ll>(n,INF));
    re(i,n)dis[i][i]=0;
    re(i,m)
    {
    	int u,v,w;
    	cin>>u>>v>>w;
    	--u,--v;
    	dis[u][v]=min(dis[u][v],(ll)w);
    	swap(u,v);
    	dis[u][v]=min(dis[u][v],(ll)w);
    }
    //vector<vector<ll>> v(n,vector<ll>(n,INF));
    re(k,n)
      re(u,n)
         re(v,n)
         {
         	dis[u][v]=min(dis[u][v] , dis[u][k]+dis[k][v]);
         }
    vector<vector<ll>> dis2(n,vector<ll>(n));
    re(u,n)
       re(v,n)
       {
       	dis2[u][v]=( dis[u][v]<=L?1:INF );
       }
    re(k,n)
      re(u,n)
         re(v,n)
         {
         	dis2[u][v]=min(dis2[u][v] , dis2[u][k]+dis2[k][v]);
         }  

    int q;
    cin>>q;
    while(q--)
    {
    	int u,v;
    	cin>>u>>v;
    	--u,--v;
    	if(dis2[u][v]==INF)cout<<"-1\n";
    	else cout<<dis2[u][v]-1<<endl;
    }
    return 0;
}

Measured memory_bytes: 2048
from collections import defaultdict
n = int(input())
a = list(map(int, input().split()))
s = [0] * n
s[0] = a[0]
dic = defaultdict(int)
for i in range(1, n):
    s[i] = s[i - 1] + a[i]

for i in range(n):
    dic[s[i]] += 1

num = 0
for k in dic.keys():
    if k == 0:
        num += dic[k] * (dic[k] - 1) // 2
        num += dic[k]
    else:
        num += dic[k] * (dic[k] - 1) // 2

print(num)


Measured memory_bytes: 41696
// B - Postal Code
#include <bits/stdc++.h>
#define lli long long int
#define uli unsigned long long int
#define rep(i, m, n) for (lli i = m; i < (n); i++)
#define repe(i, m, n) for (lli i = m; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((lli)(x).size())
#define MAX(x) *max_element(ALL(x))
const lli INF = 2147483647;
const lli MINF = -2147483648;
const lli LINF = 9223372036854775807;
const lli MOD = 1000000007; //10^9+7
const long double PI = acos(-1);
#define SORT(n) sort(n.begin(), n.end())
#define SORTR(n) sort(n.begin(), n.end(), greater<int>())
#define REV(n) reverse(n.begin(), n.end())
#define Vec(K, L, N, S) vector<L> K(N, S)
#define rt sqrt
#define pb push_back
#define eb emplace_back
#pragma GCC optimize("Ofast")
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vlli = vector<lli>;
using P = pair<lli, lli>;
// vector<P> vp;
// vp.emplace_back(a[i], b[i]);
using vs = vector<string>;
using ll = long long;
// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : "");
  }
  // os << '}';
  return os;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli a, b, c, h, k, n, w, ans = 0, count = 0;
  string s, t;
  cin >> a >> b;
  cin >> s;
  rep(i, 0, a)
  {
    if (!('0' <= s[i] && s[i] <= '9'))
    {
      cout << "No"
           << "\n";
      return 0;
    }
  }
  rep(i, a + 1, a + b + 1)
  {
    if (!('0' <= s[i] && s[i] <= '9'))
    {
      cout << "No"
           << "\n";
      return 0;
    }
  }
  if (s[a] == '-')
  {
    cout << "Yes"
         << "\n";
  }
  else
  {
    cout << "No"
         << "\n";
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static int count(int x, int y, int S, int T, int[][] map) {
        int c = 0;
        for (int i = x; i < S+x; i++) {
            for (int j = y; j < T+y; j++) {
                c += map[j][i];
            }
        }

        return c;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n, W, H, S, T, c;
        int[][] treeMap;

        while (true) {
            n = Integer.parseInt(sc.next());
            c = 0;
            if (n == 0)
                break;

            W = Integer.parseInt(sc.next());
            H = Integer.parseInt(sc.next());

            treeMap = new int[H][W];

            for (int i = 0; i < n; i++) {
                int x = Integer.parseInt(sc.next());
                int y = Integer.parseInt(sc.next());
                treeMap[y-1][x-1] = 1;
            }
            S = Integer.parseInt(sc.next());
            T = Integer.parseInt(sc.next());

            int max = 0;
            for (int x = 0; x <= W-S; x++) {
                for (int y = 0; y <= H-T; y++) {
                    if (count(x, y, S, T, treeMap) > max)
//                        System.out.println(x + "," + y + " ");
                        max = count(x, y, S, T, treeMap);
                }
            }

//            System.out.println(Arrays.deepToString(treeMap));
            System.out.println(max);
        }
    }
}

Measured memory_bytes: 41040
A, B, AB, X, Y = map(int, input().split())

ans1 = A*X + B*Y
ans2 = 0
ans3 = 0
if X >= Y:
  ans2 = A*(X-Y) + AB*Y*2
  ans3 = AB*X*2
else:
  ans2 = B*(Y-X) + AB*X*2
  ans3 = AB*Y*2
print(min(ans1, ans2, ans3))


Measured memory_bytes: 3060
#include <cstdio>
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
	int n, m;
	int veg[1024];
	int sum;

	while (1){
		sum = 0;
		scanf("%d%d", &n, &m);

		if (n == 0 && m == 0){
			break;
		}

		for (int i = 0; i < n; i++){
			scanf("%d", &veg[i]);
		}

		sort(veg, veg + n);
		reverse(veg, veg + n);

		for (int i = 0; i < n; i++){
			if ((i + 1) % m != 0){
				sum += veg[i];
			}
		}

		cout << sum << endl;
	}

	return (0);
}

Measured memory_bytes: 1224
#include <cstdio>
#include <algorithm>
using namespace std;

int main() {
	int n;
	while(scanf("%d", &n) != EOF) {
		int ans = 0;
		for(int a = 0; a < 10; a++) {
			for(int b = 0; b < 10; b++) {
				for(int c = 0; c < 10; c++) {
					for(int d = 0; d < 10; d++) {
						if(a + b + c + d == n)
							ans++;
					}
				}
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;

vector<int> G[MAX_N];
bool ok;

int dfs(int u, int p)
{
    if(u == 0){
        if(len(G[u]) == 1){
            int res = dfs(G[u][0], u);
            if(ok) return 0;
            ok = (res^1);
            return 0;
        }else{
            int cnt = 0;
            each(v, G[u]){
                cnt += dfs(v, u);
                if(ok) return 0;
                if(cnt > 1){
                    ok = true;
                    return 0;
                }
            }
            ok = (cnt^1);
            return 0;
        }
    }else{
        if(len(G[u]) == 1){
            return 1;
        }else if(len(G[u]) == 2){
            each(v, G[u]){
                if(v != p){
                    int res = dfs(v, u);
                    if(ok) return 0;
                    return res^1;
                }
            }
        }else{
            int cnt = 0;
            each(v, G[u]){
                if(v != p){
                    cnt += dfs(v, u);
                    if(ok) return 0;
                    if(cnt > 1){
                        ok = true;
                        return 0;
                    }
                }
            }
            return cnt^1;
        }
    }
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    rep(i,n-1){
        int a, b;
        cin >> a >> b;
        --a, --b;
        G[a].pb(b), G[b].pb(a);
    }
    dfs(0, -1);
    if(ok){
        cout << "First\n";
    }else{
        cout << "Second\n";
    }
    return 0;
}


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

int s(int c){
  int d=0;
  while(c>0){
    d+=c%10;
    c/=10;
  }
  return d;
}

int main(){
  int n,a,b,sum=0;
  cin>>n>>a>>b;
  for(int i=0;i<=n;i++){
    if(a<=s(i)&&s(i)<=b)
      sum+=i;
  }
  cout<<sum<<endl;
}

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

const int N = 1000000;
bool sosu[N + 1];

int eras(int n) {
  sosu[0] = sosu[1] = false;
  sosu[2] = true;
  for (int i = 3; i <= n; i += 2) sosu[i] = true;
  for (int i = 3; i <= sqrt(n); i += 2) {
    if (sosu[i]) {
      for (int j = i * i; j <= n; j += i * 2) {
		   sosu[j] = false;
      }
    }
  } 

  return 0;
}

signed main(){
  eras(N);

  int a,d,n;
  while(cin>>a>>d>>n,a | d | n){
    int cnt = 0;
    while (true) {
      if (sosu[a]) cnt++;
      if (cnt == n) break;
      a += d;
    }
    cout << a << endl;
  }

}


Measured memory_bytes: 3944
#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
#include<algorithm>
#include<cctype>
#define LL long long
#define mk make_pair
#define fi first
#define se second
#define pii pair<int,int>
using namespace std;
const int N = 1e5 + 3;
int a[N],b[N],x[N],y[N],c[N];
int A,B,M;
int main(){
	scanf("%d%d%d",&A,&B,&M);
	for(int i = 1;i <= A;++i) scanf("%d",&a[i]);
	for(int i = 1;i <= B;++i) scanf("%d",&b[i]);
	for(int i = 1;i <= M;++i) scanf("%d%d%d",&x[i],&y[i],&c[i]);
	int ans = 0x3f3f3f3f;
	for(int i = 1;i <= M;++i) ans = min(ans,a[x[i]] + b[y[i]] - c[i]);
	sort(a + 1,a + A + 1);sort(b + 1,b + B + 1);
	printf("%d\n",min(ans,a[1] + b[1]));
	return 0;
}



Measured memory_bytes: 2176
#include<stdio.h>

int main(){
	int a;
	int b;
	while(1){
		scanf("%d",&a);
		if(a==0)return 0;
		for(int i=0;i<9;i++){
			scanf("%d",&b);
			a-=b;
		}
		printf("%d\n",a);
	}
}

Measured memory_bytes: 0
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  int x1, y1, x2, y2;
  readf("%s %s %s %s\n", &x1, &y1, &x2, &y2);
  auto x3 = x2 - (y2 - y1);
  auto y3 = y2 + x2 - x1;
  auto x4 = x1 - (y2 - y1);
  auto y4 = y1 + x2 - x1;

  writefln("%s %s %s %s", x3, y3, x4, y4);
}


Measured memory_bytes: 256