akhauriyash/Code-Regression huggingface dataset:
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){
    int n; cin>>n; 
    string s; cin>>s;
    int dot=0,h=0,ans=1000001;
    for (int i=0;i<n;i++) 
        dot += (s[i] == '.'); 
    for (int i=0;i<n;i++){
        if (s[i]=='.') dot--;
        ans = min(ans,dot+h);
        if (s[i]=='#') h++;
    }
    cout << ans << endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}

/*
10 
#....###.# 


*/


Measured memory_bytes: 3748
#!/usr/bin/env python3
"""
Simple Version
Python TLE https://atcoder.jp/contests/dp/submissions/14906600
PyPy TLE https://atcoder.jp/contests/dp/submissions/14906630
"""
from collections import defaultdict
import sys

sys.setrecursionlimit(10**6)


def solve(N, M, edges):
    longest = [-1] * (N + 1)
    for i in range(N + 1):
        if not edges[i]:
            longest[i] = 0

    def get_longest(start):
        next = edges[start]
        for v in next:
            if longest[v] == -1:
                longest[v] = get_longest(v)

        ret = max(longest[v] for v in next) + 1
        return ret

    for i in range(N + 1):
        if longest[i] == -1:
            longest[i] = get_longest(i)

    return max(longest[v] for v in edges)


def main():
    N, M = map(int, input().split())
    edges = defaultdict(set)
    for i in range(M):
        v1, v2 = map(int, input().split())
        edges[v1].add(v2)

    print(solve(N, M, edges))


main()


Measured memory_bytes: 95632
#include <iostream>
#include <cstring>

using namespace std;

typedef long long ll;

#define MAXN 105
#define MAXVAL 1000

ll w[MAXN],v[MAXN];

ll dp[MAXN*MAXVAL];

int main(){

    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);cerr.tie(NULL);
    
    memset(dp,0x7f,sizeof dp);
    dp[0] = 0;
    ll n,we;cin>>n>>we;

    ll sum=0;

    for(int i=1;i<=n;i++){

        cin>>w[i]>>v[i];

        sum+=v[i];

    }

    for(int i=1;i<=n;i++){

        for(int j=sum-v[i];j>=0;j--){

            dp[j+v[i]] = min(dp[j+v[i]],dp[j]+w[i]);

        }

    }

    int ans=0;

    for(int i=1;i<=sum;i++){

        if(dp[i]<=we)
            ans = i;

    }
    
    cout<<ans<<endl;

}


Measured memory_bytes: 1024
T=[]
S=input()
Sr=list(reversed(S))
w1=list(reversed('dream'))
w2=list(reversed('dreamer'))
w3=list(reversed('erase'))
w4=list(reversed('eraser'))

while True:
    if Sr[:5]==w1:
        del(Sr[:5])
    elif Sr[:5]==w3:
        del(Sr[:5])
    elif Sr[:6]==w4:
        del(Sr[:6])
    elif Sr[:7]==w2:
        del(Sr[:7])
    else:
        break
if Sr==T:
    print('YES')
else:
    print('NO')

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

using ll = long long;


int main() {
	int h, n;
	cin >> h >> n;

	vector<int> spell(n);
	vector<int> cost(n);

	int a, b;
	for (int i = 0; i < n; i++) {
		cin >> a >> b;
		spell[i] = a;
		cost[i] = b;
	}

	vector<int> dp(h + 1, 1e9 + 5);

	dp[0] = 0;
	for (int i = 0; i <= h; i++) {
		for (int j = 0; j < n; j++) {
			if (i + spell[j] >= dp.size()) {
				dp[dp.size() - 1] = min(dp[i] + cost[j], dp[dp.size() - 1]);
				continue;
			}
			dp[i + spell[j]] = min(dp[i] + cost[j], dp[i + spell[j]]);
		}
	}

	cout << dp.back() << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#include <complex>
#include <map>
#include <climits>
using namespace std;

#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8
#define F first
#define S second

static const double PI=6*asin(0.5);
typedef long long ll;
typedef complex<double> CP;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vint;
static const int INF=1<<24;

int main(){
	//49+16=65
	int h,w;
	while(cin>>h>>w,h||w){
		int x=150,y=150;
		int dia=h*h+w*w;
		reep(i,1,151){
			//if(i==0) continue;
			reep(j,i+1,151){
				if(i==h&&j==w) continue;
				int dia1=x*x+y*y;
				int dia2=i*i+j*j;
				if(dia2>=dia){
					//cout<<"   "<<i<<" "<<j<<endl;
					if(dia==dia2&&i<h) continue;
					if(dia1>dia2){
						x=i;y=j;
						//cout<<"x = "<<x<<" y = "<<y<<endl;
					}
					else if(dia1==dia2&&i<x){
						x=i;y=j;
						//cout<<"x = "<<x<<" y = "<<y<<endl;
					}
				}
			}
		}
		cout<<x<<" "<<y<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
import java.util.*;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner (System.in);
		int N = sc.nextInt();
		char S[] = sc.next().toCharArray();
		int count = 0;
		
		int t=0;
		int ssss=0;
	    int data[] =new int[3];
		for(int i=0;i<N;i++) {
			       if(i<N-2) {
			           if(S[i]=='A' && S[i+1]=='B' && S[i+2]=='C'){
			           count++;
			          }
			       }
			    }
		System.out.println(count);

			}
		
		
		
	}

Measured memory_bytes: 21844
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		int a=stdIn.nextInt(),b;
		b = a + (int)Math.pow(a,2) + (int)Math.pow(a, 3);
		System.out.println(b);
		stdIn.close();
	}
}


Measured memory_bytes: 35644
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
  string s;
  cin >> s;
  ll ans=0;
  for(int i=0;i<s.size()-1;i++){
    s=s.substr(0,s.size()-1);
    if(s.size()%2==1){
      continue;
    }
    bool is=true;
    for(int j=0;j<s.size()/2;j++){
      if(s.at(j)!=s.at(j+s.size()/2)){
        is=false;
      }
    }
    if(is){
      ans=s.size();
      break;
    }
  }
  ll q=2;
  cout << max(ans,q);
}

Measured memory_bytes: 3612
#include<stdio.h>
#include<string.h>

int main(void){
    char s[32];
    int len,i;
    scanf("%s",s);
    len = strlen(s);
    for(i = len-1;i >= 0;i--){
        printf("%c",s[i]);
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 524
def main():
    import sys
    readline = sys.stdin.buffer.readline
    sys.setrecursionlimit(10 ** 7)

    n = int(readline())
    x, y = divmod(n, 1000)
    if y == 0:
        print(0)
    else:
        print(1000 - y)


if __name__ == '__main__':
    main()


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

int tri(int a,int b,int c)
{
    int o;
    int flag=0;
    int arr[3]={0};
    arr[0]=a;
    arr[1]=b;
    arr[2]=c;
    int lmax=-1;
    int maxnum=0;
    for(o=0;o<3;o++)
    {
        if(arr[o]>lmax)
        {
            lmax=arr[o];
            maxnum=o;
        }
    }
    if(maxnum==0&&(a<(b+c)))flag=1;
    else if(maxnum==1&&(b<(a+c)))flag=1;
    else if(maxnum==2&&(c<(b+a)))flag=1;

    if(a==b||b==c||c==a)flag=0;
    //printf("%d %d %d -> %d\n",a,b,c,flag);
    return flag;
}

int main()
{
    int n;
    int ans=0;
    int l[110];
    int i,j,k;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&(l[i]));
    }
    for(i=0;i<n;i++)
    {
        for(j=i+1;j<n;j++)
        {
            for(k=j+1;k<n;k++)
            {
                ans+=(tri(l[i],l[j],l[k]));
                //if(tri(l[i],l[j],l[k]))
            }
        }
    }

	printf("%d",ans);
}


Measured memory_bytes: 1732
#include<iostream>
#include<math.h>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;

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

    int flag=0;//A=0,B=1,C=2
    while(true){
        if(flag==0){
            if(a[0] == 'a'){
                flag = 0;
            }
            else if(a[0] == 'b'){
                flag = 1;
            }
            else if(a[0] == 'c'){
                flag = 2;
            }
            else{
                cout<<'A';
                return 0;
            }
            a.erase(a.begin());
        }
        else if(flag==1){
            if(b[0] == 'a'){
                flag = 0;
            }
            else if(b[0] == 'b'){
                flag = 1;
            }
            else if(b[0] == 'c'){
                flag = 2;
            }
            else{
                cout<<'B';
                return 0;
            }
            b.erase(b.begin());
        }
        else{
            if(c[0] == 'a'){
                flag = 0;
            }
            else if(c[0] == 'b'){
                flag = 1;
            }
            else if(c[0] == 'c'){
                flag = 2;
            }
            else{
                cout<<'C';
                return 0;
            }
            c.erase(c.begin());
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <stdlib.h>

using namespace std;

int main() {
    string s,t;
    cin >> s;
    for(int i = 0; i < s.size(); i++) {
        if((i+1) % 2 == 1) {
            t += s[i];
        }
    }
    cout << t;
    return 0;
}



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

int main(){
	int n,ball,tp[2],con,bad;
	
	cin >> n;
	
	while(n--){
		
		tp[0] = tp[1] = 0;
		
		for(int i = 0; i < 10; i++){
			cin >> ball;
			
			if(tp[0] > tp[1]){
				con = 0;
			}else{
				con = 1;
			}
			
			if(ball > tp[con]){
				tp[con] = ball;
			}else if(ball > tp[!con]){
				tp[!con] = ball;
			}else{
				bad = 1;
			}
		}
		
		if(bad){
			cout << "NO" << endl;
			bad = 0;
		}else{
			cout << "YES" << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 0
lines = []
while line = gets
    lines << line.chomp.split(' ').map(&:to_i)
end

s = []
sum = 0
s = lines[1].sort{|a, b| a.to_i <=> b.to_i }
s = s[0..lines[0][1] - 1]

s.each do |n|
  sum += n
end

p sum


Measured memory_bytes: 14312
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007
#define mod2 1000000000
#define mod1 998244353
#define lol ios_base::sync_with_stdio(false);cin.tie(NULL);
#define all(x) (x).begin(), (x).end()
#define F(i, n) for (ll (i) = 0; (i) < (n); (i)++)
#define pb push_back
#define pf push_front
#define mp make_pair
#define f first
#define ss second

int main()
{
    ll a,b;cin >> a >> b;
    cout << a*b << endl;
}
    

Measured memory_bytes: 3636
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
//#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
//#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int mod = 1e9 + 7;
const int N = 505;
const int K = 20;
int mt[N], used[N], g[N][N], n, m;
pair < int, int > a[N][N];

bool try_kuhn(int v){
    if (used[v]) return 0;
    used[v] = 1;
    for (int i = 0; i <= n + n; i++){
        if (g[v][i] == 0) continue;
        if (mt[i] == -1 || try_kuhn(mt[i])){
            mt[i] = v;
            return 1;
        }
    }
    return 0;
}
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    cin >> n >> m;
    for (int i = 1; i <= n; i++){
        for (int j = 1; j <= m; j++){
            int x;
            cin >> x;
            x--;
            int y = x / m + 1;
            a[i][j] = {y, x};
        }
    }
    for (int i = 1; i <= m; i++){
        for (int j = 0; j <= n + n; j++){
            for (int l = 0; l <= n + n; l++){
                g[j][l] = 0;
                mt[l] = -1;
                used[l] = 0;
            }
        }
        for (int j = 1; j <= n; j++){
            for (int l = i; l <= m; l++){
                g[j - 1][a[j][l].F + n] = 1;
                g[a[j][l].F + n][j - 1] = 1;
            }
        }
        for (int j = 0; j < n; j++){
            for (int l = 0; l < n; l++) used[l] = 0;
            try_kuhn(j);
        }
        for (int j = n + 1; j <= n + n; j++){
            if (mt[j] != -1){
                int r = mt[j] + 1;
                for (int l = i; l <= m; l++){
                    if (a[r][l].F == j - n){
                        swap(a[r][l], a[r][i]);
                        break;
                    }
                }
            }
        }
    }
    for (int i = 1; i <= n; i++){
        for (int j = 1; j <= m; j++){
            cout << a[i][j].S + 1 << " ";
        }
        cout << endl;
    }
    for (int i = 1; i <= m; i++){
        vector < pair < int, int > > v;
        for (int j = 1; j <= n; j++){
            v.pb(a[j][i]);
        }
        sort(v.begin(), v.end());
        for (int j = 1; j <= n; j++){
            a[j][i] = v[j - 1];
        }
    }
    for (int i = 1; i <= n; i++){
        for (int j = 1; j <= m; j++){
            cout << a[i][j].S + 1 << " ";
        }
        cout << endl;
    }
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long n;
  bool did=false;
  while(cin >> n){
    if(n==0){
      return 0;
    }
    if(did){
      cout << endl;
    }
    string s[n];
    long long win[n],draw[n],lose[n];
    pair<int,int> p[n];
    for(int i=0;i<n;i++){
      cin >> s[i] >> win[i] >> lose[i] >> draw[i];
      p[i]=make_pair(win[i]*3+draw[i],i);
    }
    sort(p,p+n);
    reverse(p,p+n);
    for(int i=0;i<n;i++){
      bool f=true;
      for(int j=i;j<n;j++){
        if(p[j].first<p[i].first){
          for(int k=j-1;k>=i;k--){
            cout << s[p[k].second] << "," << p[k].first << endl;
          }
          f=false;
          i=j-1;
          break;
        }
      }
      if(f){
        for(int j=n-1;j>=i;j--){
          cout << s[p[j].second] << "," << p[j].first << endl;
        }
        break;
      }
    }
    did=true;
  }
  return 0;
}


Measured memory_bytes: 3208
#include <bits/stdc++.h>
using namespace std;
#define fo(x, n) for(int i = x; i <= n; i++)
#define all(x) x.begin(), x.end()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector <int> vi;
const int MOD = 1e9 + 7;

void solve(){
    int n;
    cin >> n;
    cout << n * (n + 1) / 2;
}
int main(){
    ios::sync_with_stdio(false); cin.tie(0);
	int T = 1;
    //cin >> T;
    fo(1, T){
        solve();
    }
}



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

int main(){

    int n;
    int sum=0,maxp=0;
    cin>>n;
    for(int i=0;i<n;i++){
        int p; cin>>p;
        sum+=p;
        maxp=max(maxp,p);
    }
    cout<<sum-maxp/2<<endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n, q, m; 
		int[] a;
		
		n = sc.nextInt();
		a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		q = sc.nextInt();
		for (int i = 0; i < q; i++) {
			m = sc.nextInt();
			if (checkpossible(a,m,n)) {
				System.out.println("yes");
			} else {
				System.out.println("no");
			}
		}
	}
	public static boolean checkpossible(int[] a, int m, int n){
		if (m==0) {
			return true;
		} else if (n == 0) {
			return false;
		} else {
			return (checkpossible(a,m,n-1) || checkpossible(a,m-a[n-1],n-1));
		}
	}
}


Measured memory_bytes: 26760
#include <iostream>
#include <vector>
#include <algorithm>

int main(int argc, char **argv)
{
    int N;
    std::cin >> N;
    
    std::vector<int> a(N);
    std::vector<int> aa(3*N);
    
    for(int i = 0; i < N; i++){
        int d;
        std::cin >> d;
        a.at(i) = d;
        aa.at(3*i+0) = d;
        aa.at(3*i+1) = d+1;
        aa.at(3*i+2) = d-1;
    }

    std::sort(aa.begin(), aa.end());
    
    int prev = aa.at(0);
    int count = 1;
    int ans = 0;
    for(int i = 1; i < 3*N; i++){
        if(prev == aa.at(i)){
            count++;
        }else{
            ans = std::max(ans, count);
            prev = aa.at(i);
            count = 1;
        }
    }
    ans = std::max(ans, count);
    std::cout << ans << std::endl;
}


Measured memory_bytes: 1792
from sys import stdin,setrecursionlimit
setrecursionlimit(10**6)
def S(): return stdin.readline().rstrip()
def LI(): return list(map(int,stdin.readline().rstrip().split()))

def BFS(table,s,step,next,w,h):
    if table[h-1][w-1] != -2:
        return
    dx = [1,0,-1,0]
    dy = [0,1,0,-1]
    nnext = []
    for rep in next:
        for j in range(4):
            nx = rep[0] + dx[j]
            ny = rep[1] + dy[j]
            if nx<0  or ny<0 or w<=nx or h<=ny:
                continue
            else:
                if s[ny][nx]=='#':
                    continue
                if table[ny][nx]==-2 or step+1<table[ny][nx]:
                    table[ny][nx] = step+1
                    nnext.append([nx,ny])
    if 0<len(nnext):
        BFS(table,s,step+1,nnext,w,h)

def main():
    tmp = LI()
    w,h = tmp.pop(),tmp.pop()
    s = [S() for _ in range(h)]
    table = [[-2]*w for _ in range(h)]
    BFS(table,s,0,[[0,0]],w,h)
    step = table[h-1][w-1]
    if step==-2:
        print(-1)
        exit()
    c = 0
    for rep in s:
        c += rep.count('#')
    ans = w*h-step-c-1
    print(ans)
    return

if __name__=='__main__':
    main()

Measured memory_bytes: 3316
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n)for(int i=0;i<(int)(n);i++)
//#define PI 3.141592653589793
//vector < vector<int>>a(0, vector<int>(0));二次元配列宣言


int main()
{
	int n;
	cin >> n;
	vector<int>a(n+1);
	int cnt=0;
	int i;
	for (i = 1; i <= n; i++)
	{
		cin >> a.at(i);
		if (a.at(i) % 2 == 1 && i % 2 == 1)
		{
			cnt++;
		}
	}
	cout << cnt << endl;
}
/**/
/*#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

#define PI 3.141592653589793

int main(void) {
	return 0;
}
*/

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

int main() 
{    
    string S,res;
    cin >> S;

    int H,L;

    int a[4];

    a[0] = S[0] - '0';
    a[1] = (int)S[1] - '0';
    a[2] = (int)S[2] - '0';
    a[3] = (int)S[3] - '0';


    H = a[0] * 10;
    H += a[1];
    L = a[2] * 10;
    L += a[3];


    if(1 <= H && H <= 12)
    {
        if(1<=L && L<=12)
        {
            res = "AMBIGUOUS";
        }
        else
        {
            res = "MMYY";
        }
    }
    else if(1<=L && L<=12)
    {
        res = "YYMM";
    }
    else
    {
        res = "NA";
    }

    cout << res << endl;

}

Measured memory_bytes: 256
/*
      author : Nishikawa
      created: 10.08.2020 13:21:07
*/

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


int main(){
    int n,m;
    cin >> n >> m;
    vector<ll> h(n);
    rep(i,n) cin >> h[i];
    vector<bool> top(n,true);
    rep(i,m){
        int a,b;
        cin >> a >> b;
        --a; --b;
        if(h[a] >= h[b]) top[b]=false;
        if(h[a] <= h[b]) top[a]=false;
    }
    int ans = 0;
    rep(i,n) if(top[i]) ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3984
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
#define REP(_i,_n) for(int _i=0;_i<_n;_i++)
int main() {
	string s;
	int a[128] = { 0 };
	char S[] = "abcdefghijklmnopqrstuvwxyz";
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		for (int j = 0; j < 27; j++) {
			if (s[i] == S[j]) a[s[i]]++;
			if (a[s[i]] > 1) {
				cout << "no" << endl;
				return 0;
			}
		}
	}
	cout << "yes" << endl;
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;

#define mt make_tuple
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sqr(x) ((ll)(x) * (x))

const int MAXN = 2e5;

int cnt[2020];

int main()
{
    string s;
    cin >> s;
    int n = (int)s.size();
    cnt[0]=1;

    int nestoLol = 1;
    int ostatak = 0;

    ll resenje = 0LL;

    for(int i = n-1; i >= 0; --i)
    {
        ostatak += (s[i]-'0') * nestoLol;
        ostatak %= 2019;
        nestoLol *= 10;
        nestoLol %= 2019;
        resenje += (ll)cnt[ostatak]++;
    }

    cout << resenje << '\n';

    return 0;
}


Measured memory_bytes: 3720
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
#include<set>

using namespace std;

const int V=100005;

vector<int> to[V*2];

vector<int> cnt;

vector<int> visited(V*2);

void dfs(int v)
{
	if(visited[v])return;
	visited[v]=true;
	cnt[v/V]++;
	for(auto u:to[v])
		dfs(u);


}

int main()
{
	int n;
	cin >> n;
	for(int i=0;i<n;i++)
	{
		int x,y;
		cin >> x >> y;
		y+=V;
		to[x].push_back(y);
		to[y].push_back(x);
	}


	long long ans=0;
	for(int i=0;i<V*2;i++)
	{
		if(visited[i])continue;
		cnt=vector<int>(2,0);
		dfs(i);
		ans+=(long long)cnt[0]*cnt[1];
	}

	ans-=n;
	
	cout << ans << endl;



}

Measured memory_bytes: 10752
#include<stdio.h>
#include<string.h>

int main(void){
  char buf1[10], buf2[300];
  char color[200];
  char *tp;
  int N, i, count;
  
  fgets(buf1, sizeof(buf1), stdin);
  sscanf(buf1,"%d",&N);  
  
  fgets(buf2, sizeof(buf2), stdin);
  //printf("%s\n", buf2); 
  
  tp = strtok(buf2, " \n");
 
  count = 0;
  while(tp!=NULL){
    color[count] = *tp;
    tp = strtok(NULL, " \n");
    //printf("%d %c\n", count, color[count]);
    count++;
  }
  
  count = 0;
  
  for(i=0; i<N; i++){
     if(color[i] == 'Y'){
       printf("Four\n");
       break;
     }else if(i == N-1){
      printf("Three");
    }
  }

return 0;
}
	

Measured memory_bytes: 128
let pi = 4. *. atan 1.

let to_radian degree = pi *. degree /. 180.

type point = { x : float; y : float }

let print_point e = Printf.printf "%f %f\n" e.x e.y

let rec koch n a b =
  if n <= 0 then ()
  else begin
    let s =
      let x = (2. *. a.x +. b.x) /. 3. in
      let y = (2. *. a.y +. b.y) /. 3. in
      { x; y } in
    let t =
      let x = (a.x +. 2. *. b.x) /. 3. in
      let y = (a.y +. 2. *. b.y) /. 3. in
      { x; y } in
    let u =
      let x = (t.x -. s.x) *. cos (to_radian 60.) -. (t.y -. s.y) *. sin (to_radian 60.) +. s.x in
      let y = (t.x -. s.x) *. sin (to_radian 60.) +. (t.y -. s.y) *. cos (to_radian 60.) +. s.y in
      { x; y } in
    koch (n - 1) a s;
    print_point s;
    koch (n - 1) s u;
    print_point u;
    koch (n - 1) u t;
    print_point t;
    koch (n - 1) t b
  end

let () =
  let n = read_int () in
  let p1 = { x = 0.; y = 0. } in
  let p2 = { x = 100.; y = 0. } in
  print_point p1;
  koch n p1 p2;
  print_point p2

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

int main(){
    long N;
    cin >> N;
    for(long h = 0; h < 3500; h++){
        for(long n = 0; n < 3500; n++){
            if(4 * h * n - N * (h + n) > 0){
                if((N * h * n) % (4 * h * n - N * (h + n)) == 0){
                    cout << h << " " << n << " " << (N * h * n) / (4 * h * n - N * (h + n)) << endl;
                    return 0;
                }
            }
        }
    }
}


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

#define endl '\n'

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int h, sum=0,n; cin >> h >> n;
    for (int i=0; i<n; i++){
        int x; cin >> x;
        sum += x;
    }
    if (sum < h) cout << "No\n";
    else cout << "Yes\n";

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int i,j,n;
	scanf("%d",&n);
	for(i=0;i<=n;i++)
	{
		for(j=0;j<=n;j++)
		{
			if(i*4+j*7>=n)
				break;
		}
		if(i*4+j*7==n)
		{
			printf("Yes");
			return 0;
		}
	} 
	printf("No");
	return 0;
}

Measured memory_bytes: 256
spades = [i for i in range(1, 14)]
hearts = [i for i in range(1, 14)]
clubs = [i for i in range(1, 14)]
diamonds = [i for i in range(1, 14)]


n = int(input())
for i in range(n):
    suits, ranks = (input()).split(' ')
    ranks = int(ranks)
    if suits == 'S':
        spades.remove(ranks)
    if suits == 'H':
        hearts.remove(ranks)
    if suits == 'C':
        clubs.remove(ranks)
    if suits == 'D':
        diamonds.remove(ranks)

for s in spades:
    print('S', s)
for h in hearts:
    print('H', h)
for c in clubs:
    print('C', c)
for d in diamonds:
    print('D', d)


Measured memory_bytes: 5612
#include <iostream>
#define N 100
#define INFINITY 200000000
using namespace std;
void prim();
int M[N][N],d[N],p[N],u,n,mincost,i,j;
string color[N];
int main(){
  cin >> n;
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      cin >> M[i][j];
    }
  }
  prim();
  return 0;
}
void prim(){
  for(i=0;i<n;i++) color[i]="WHITE",d[i]=INFINITY;
  d[0]=0;
  p[0]=-1;
  while(1){
    mincost=INFINITY;
    for(i=0;i<n;i++){
      if(color[i]!="BLACK"&&d[i]<mincost){
	mincost=d[i];
	u=i;
      }
    }
    if(mincost==INFINITY) break;
    color[u]="BLACK";
    for(i=0;i<n;i++){
      if(color[i]!="BLACK"&&M[u][i]!=-1){
	if(M[u][i]<d[i]){
	  d[i]=M[u][i];
	  p[i]=u;
	  color[i]="GLAY";
	}
      }
    }
  }
  int sum=0;
  for(i=0;i<n;i++) sum+=d[i];
  cout << sum << endl;
}



Measured memory_bytes: 3240
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;

typedef long long ll;

int main(void) {
  int n, m;
  scanf("%d%d", &n, &m);
  int lb = 0;
  int ub = n+10;
  REP(i, m) {
    int l, r;
    scanf("%d%d", &l, &r);
    lb = max(lb, l);
    ub = min(ub, r);
  }
  
  cout << max(0, ub - lb + 1) << endl;
    
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
using ll = long long;
using ld = long double;
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
using pll = pair<long long,long long>;
#define cY cout<<"Yes"<<endl
#define cN cout<<"No"<<endl
const long long INF = 1LL << 60;
const long long MOD = 1000000007;
const long double pi = (acos(-1));
#define pb push_back
#define vs vector<string>

//最大最小の入れ替え
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

//約数列挙
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}
//コンビネーション
ll nCr(ll n, ll r) {
    ll ans = 1;
    for (ll i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (ll i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}
//素因数分解
map< ll, ll > prime_factor(ll n) {
  map< ll, ll > ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

//切り上げの割り算は(a + b - 1) / bでできる

//ここから
int main(){
    ll N;
    cin>>N;
    map<ll,ll> m;
    ll M=998244353;
    ll max=-1;
    rep(i,N){
        ll a;
        cin>>a;
        if(i==0&&a!=0){
            cout<<0<<endl;
            return 0;
        }
        chmax(max,a);
        m[a]++;
    }
    ll Ans=1;
    if(m[0]!=1){
        cout<<0<<endl;
        return 0;
    }
    rep2(i,1,max+1){
        if(m[i]==0){
            cout<<0<<endl;
            return 0;
        }
        rep(j,m[i]){
            Ans*=m[i-1];
            Ans%=M;
        }
    }
    cout<<Ans%M<<endl;
}


Measured memory_bytes: 6528
#include "bits/stdc++.h"
using namespace std;
#define repr(i,a,b) for(long long i=(long long)(a);i<(long long)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define MOD 998244353
#define PI 3.1415926535
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<Pll> vPll;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<double>> vvd;
typedef vector<vector<Pi>> vvPi;
typedef priority_queue<int, vector<int>, greater<int>> pqli;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi>> pqlP;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }
int main(void)
{
	ll n, ans=0;

	cin>>n;

	vll a(n);

	vll count(100000, 0);

	rep(i, n){
		cin>>a[i];
		count[a[i]-1]++;
	}

	rep(i, 100000){
		if(count[i]){
			ans++; count[i]--;
		}
	}

	ll re=0;
	rep(i, 100000){
		if(count[i]<=0) continue;
		re=abs(re-count[i]);
	}

	re++;
	while(re>2){
		re=(re/3)+re%3;
	}
	re--;
	cout<<ans-re<<endl;
	
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define sqr(x) ((x)*(x))
#define mp make_pair
#define uint unsigned
#define PI pair<int,int>
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline int read(){
	int x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(int a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(int a){
    if(a<0){
    	a=-a; putchar('-');
	}
	write(a); puts("");
}
inline int rnd(int x){
	return rand()%x;
}
inline ull rnd(){
	return ((ull)rand()<<30^rand())<<4|rand()%4;
}
const int M=20,N=1<<M,inf=1e9+3e5;
int n,v,gao,f[1<<M],g[1<<M],x[N],lst[M][N],nxt[M][N],tong[N];
int main(){
	n=read(); v=read(); x[0]=-inf; x[n+1]=inf;
	for(int i=1;i<=n;i++)x[i]=read();
	for(int i=0;;i++){
		int dali=v>>i; gao=i; nxt[i][n+1]=n; lst[i][0]=1;
		for(int j=1;j<=n;j++)if(x[j]-x[j-1]<=dali)lst[i][j]=lst[i][j-1]; else lst[i][j]=j;
		for(int j=n;j;j--)if(x[j+1]-x[j]<=dali)nxt[i][j]=nxt[i][j+1]; else nxt[i][j]=j;
		if((v>>i)==0)break;
	}
	f[0]=0; g[0]=n+1; 
	for(int i=1;i<(1<<gao);i++){
		f[i]=0; g[i]=n+1;
		for(int j=0;j<gao;j++)if(i>>j&1)f[i]=max(f[i],nxt[j+1][f[i^(1<<j)]+1]);
		for(int j=0;j<gao;j++)if(i>>j&1)g[i]=min(g[i],lst[j+1][g[i^(1<<j)]-1]);
	}
	for(int i=0;i<=n+1;i++)tong[i]=-1;
	for(int i=0;i<(1<<gao);i++){
		int l=f[i],r=g[((1<<gao)-1)^i];
		tong[r]=max(tong[r],l);
	}
	for(int i=1;i<=n;i++)tong[i]=max(tong[i],tong[i-1]);
	for(int i=1;i<=n;i++){
		int l=lst[0][i],r=nxt[0][i];
		puts(tong[r+1]>=l-1?"Possible":"Impossible");
	}
}

Measured memory_bytes: 87168
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=(a);i<=(b);i++)
#define END(x) do{cout<<(x)<<endl;exit(0);}while(0)
#define bug(x) do{cerr<<#x<<": "<<x<<"\n";}while(0)
#define bugv(x) do{cerr<#x<<': "';\
for(auto&e: x)cerr<<e<<" ";cerr<<"\n";}while(0)

using namespace std;
using ll=long long;

int main() {
  ios_base::sync_with_stdio(false); cin.tie(nullptr);
  int n,k; cin>>n>>k;
  vector<ll> T(n+1, 0);
  vector<ll> M(n+1, 1);
  ll MM = n * (1LL<<20);
  bug(MM);

  rep(i, 1, min(k-1,n)) {
    ll need = (k+(i-1)) / i;
    bug(need);
    ll f = 1;
    while(f < need) f = f << 1;
    bug(f);
    M[i] = n * f;
    T[i] = 1;
    while(M[i] != MM) { M[i]*=2; T[i]*=2;}
  }
  rep(i, k, n) T[i] = (1LL<<20);
  ll tt = 0;
  rep(i, 1, n) tt+= T[i];
  cout << setprecision(28) << (long double)(tt) / MM << endl;

  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 2147483647;
const ll LINF = 9223372036854775807;
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main() {
	int a, b; cin >> a >> b;
	if (a > b)
		swap(a, b);
	REP(i, b)
		cout << a;
}

Measured memory_bytes: 256
#include "iostream"
using namespace std;
int main(int argc, char const *argv[])
{
	int mtain[10];

	for (int i = 0; i < 10; ++i)
	{
		cin >> mtain[i];
	}

	for (int i = 0; i < 10; ++i)
	{
		for (int j = i + 1; j < 10; ++j)
		{
			int work = 0;

			if(mtain[i] < mtain[j]){
				work = mtain[i];
				mtain[i] = mtain[j];
				mtain[j] = work;	
			} 
		}
	}

	cout << mtain[0] << endl;
	cout << mtain[1] << endl;
	cout << mtain[2] << endl;

	return 0;
}

Measured memory_bytes: 1160
n,k = map(int,input().split())
ai = [int(i) for i in input().split()]

li = [-10]*(n)
tmp = ai[0]

st = -1

for i in range(n+1):
    #tmp = ai[i]
    if li[tmp-1] != -10:
        prd = i - li[tmp-1]
        st = li[tmp-1]+1
        break
    li[tmp-1] = i
    tmp = ai[tmp-1]
    #print(tmp)
    
#print(li,prd,tmp)
pat = 0
if ai[tmp-1] == tmp:
    pat = 1

#print(prd,li,st,pat)
#exit()

#if pat == 1:
#    print(tmp)
#    exit()
if k <= st:
    for i in range(n):
        if li[i] == k-1:
            print(i+1)
            exit()
else:
    idx = (k-st) % prd
    #print(idx,idx,idx)
    for i in range(n):
        if li[i] == st-1+idx:
            print(i+1)
            exit()


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

namespace AOJ
{
	class Program
	{
		static void Main(string[] args)
		{
			var s = "";
			while ((s = Console.ReadLine()) != "0 0")
			{
				var HW = s.Split(' ').Select(i => int.Parse(i)).ToArray();
				int r = 0;
				var k = new int[HW[0] + 2][];
				k[0] = k[k.Length - 1] = new int[HW[1] + 2];
				for (int i = 1; i <= HW[0]; i++)
				{
					k[i] = string.Format("_{0}_", Console.ReadLine())
						.Select(c => c == '@' ? 1 : c == '#' ? 2 : c == '*' ? 3 : 0).ToArray();
				}
				for (int i = 0; i < HW[0] + 2; i++)
				{
					for (int j = 0; j < HW[1] + 2; j++)
					{
						if (k[i][j] != 0)
						{
							g(k, i, j, k[i][j]);
							r++;
						}
					}
				}
				Console.WriteLine(r);
			}
		}

		static void g(int[][] k, int x, int y, int c)
		{
			if (k[x][y] != c) return;
			k[x][y] = 0;
			g(k, x - 1, y, c);
			g(k, x, y - 1, c);
			g(k, x + 1, y, c);
			g(k, x, y + 1, c);
		}
	}
}

Measured memory_bytes: 6692
let lcs (x, y) =
  let s = String.length x in
  let t = String.length y in
  let dp = Array.make_matrix (s+1) (t+1) 0 in
  for i = 1 to s do
    for j = 1 to t do
      dp.(i).(j) <-
        if x.[i-1] = y.[j-1] then dp.(i-1).(j-1) + 1
        else max dp.(i-1).(j) dp.(i).(j-1)
    done
  done;
  dp.(s).(t)

let () =
  let n = read_int () in
  for _ = 0 to n - 1 do
    Scanf.scanf "%s %s\n" (fun x y -> (x, y))
    |> lcs
    |> Printf.printf "%d\n"
  done

Measured memory_bytes: 18600
#include<bits/stdc++.h>
#define ll long long 
#define hell 1000000007 
#define F first
#define re 15000000
#define S second
#define pb push_back
#define all(a)  (a).begin(),(a).end()
#define rep(i,a,b) for(ll int i = a;i<b;i++)
#define pi 3.1415926536
#define Mod 998244353
using namespace std;
bool comp(pair<string,int> X,pair<string,int> Y){
	if(X.F!=Y.F)
		return X.F < Y.F;
	else
		return X.S  > Y.S;
}
int main()
{
	int n;
	cin>>n;
	vector<pair<string,int>   >v;
	map<int,int> m;
	for(int i = 0;i<n;i++)
	{
		string s;
		cin>>s;
		int x;
		cin>>x;
		v.pb({s,x});
		m[x] = i+1;
	}
	sort(all(v),comp);
	for(int i = 0;i<v.size();i++)
		cout<<m[v[i].S]<<endl;
}

Measured memory_bytes: 256
N, M, K = map(int, input().split())

def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 10 ** 9 + 7
mod = 10 ** 9 + 7
n = 3 * 10 ** 5  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用
 
for i in range(2, n + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)
#一つの配置でK C 2本の線
#配置はMN C K 通り
#よって、MNCK * KC2 / MNC2 = (MN - 2)C(K - 2)回
#各2頂点間のコストは足される。
#答えは全ての2頂点間のコストの和 * (MN - 2)C(K - 2)

#全ての2頂点間のコストの和を求める
#距離 i 離れた二点の個数は (1 + 2 + ... N - i) * N
#つまり、N * (N - i + 1) * (N - i) / 2
#縦横あるので、 それぞれ足す
ans1 = 0
for i in range(1, M):
  ans1 += i * (M - i) % mod
  #print(ans1)
ans1 = (ans1 * N * N) % mod

ans2 = 0
for i in range(1, N):
  ans2 += i * (N - i) % mod
ans2 = (ans2 * M * M) % mod

#print(ans1, ans2)

ans = ans1 + ans2
print(ans * cmb(M * N - 2, K - 2, p) % mod)



Measured memory_bytes: 44588
#include<cstdio>
#include<deque>
#include<stack>
#include<algorithm>
#include<cstring>
#include<cctype>
using namespace std;
int T(char*s)
{
	char*p,a[2]="@",c;
	stack<char> o;
	deque<char> d;
	for(p=s;*p;++p)
	{
		a[0]=*p;
		if(isdigit(*p))
		{
			d.push_back(*p);
			while(o.size()&&o.top()=='-')o.pop(),d.push_back('-');
		}
		if(strpbrk(a,"(+*-"))o.push(*p);
		if(*p==')')
		{
			while(c=o.top(),o.pop(),c-'(')d.push_back(c);
			while(o.size()&&o.top()=='-')o.pop(),d.push_back('-');
		}
	}
	while(o.size())d.push_back(o.top()),o.pop();
	for(int i=1;i<d.size();)
	{
		if(d[i]=='-')d[i-1]=-(d[i-1]-'1')+'1',d.erase(d.begin()+i);
		else if(d[i]=='*')d[i-2]=min(d[i-2],d[i-1]),d.erase(d.begin()+i-1,d.begin()+i+1),--i;
		else if(d[i]=='+')d[i-2]=max(d[i-2],d[i-1]),d.erase(d.begin()+i-1,d.begin()+i+1),--i;
		else ++i;
	}
	return d[0]=='2';
}
int main()
{
	char s[84],t[84],*p,i[3];
	while(scanf("%s",s),s[0]-'.')
	{
		int r=0;
		for(i[0]='0';i[0]<'3';++i[0])for(i[1]='0';i[1]<'3';++i[1])for(i[2]='0';i[2]<'3';++i[2])
		{
			strcpy(t,s);
			while(p=strpbrk(t,"PQR"))*p=i[*p-'P'];
			r+=T(t);
		}
		printf("%d\n",r);
	}
	return 0;
}

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

#define int long long
#define endl "\n"
#define pb push_back
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define IN freopen("input.txt","r",stdin);
#define OUT freopen("output.txt","w",stdout);

const int N = 2e5 + 5;
const double pi = 3.141592653589793238;

int32_t main()
{
    IOS;
    string a,b;
    cin >> a;
    cin >> b;
    int cnt=0;
    for(int i=0;i<a.size();i++){
        if(a[i]!=b[i])
            cnt++;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 3796
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>

using namespace std;
using namespace boost::adaptors;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

constexpr ll MOD = 998244353;

// a^-1 mod p
ll inv(ll a,ll p){
  return ( a == 1 ? 1 : (1 - p*inv(p%a,a)) / a + p );
}

int main() {
  ll n;
  cin>>n;
  vecll a(n);
  for(auto&& e:a)cin>>e;
  vecll coeff(1000001, 0);
  vecll sumcoeff(1000001, 0);
  for(ll i = 1; i <= 1000000; ++i) {
    ll need = inv(i, MOD);
    coeff[i] = need + (MOD - sumcoeff[i]);
    coeff[i] %= MOD;
    for(ll j = 2*i; j <= 1000000; j += i) {
      sumcoeff[j] += coeff[i];
      sumcoeff[j] %= MOD;
    }
  }
  vecll hist(1000001);
  for(auto&& e:a) ++hist[e];
  ll ans = 0;
  ll inv2 = inv(2, MOD);
  for(ll i = 1; i <= 1000000; ++i) {
    ll sum = 0;
    ll sqsum = 0;
    for (ll j = i; j <= 1000000; j += i) {
      sum += j * hist[j] % MOD;
      sum %= MOD;
      sqsum += j * j % MOD * hist[j] % MOD;
      sqsum %= MOD;
    }
    ll mul = sum * sum % MOD + (MOD - sqsum);
    mul %= MOD;
    mul *= inv2;
    mul %= MOD;
    ans += coeff[i] * mul % MOD;
    ans %= MOD;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 26112
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream &operator << (ostream& out,const pair<S,T>& o){
    out << "(" << o.first << "," << o.second << ")"; return out;
}
/*
 Atcoder 100~200点代
 アな問題が多いので,まとめる
*/
// https://abc042.contest.atcoder.jp/tasks/abc042_a
//void solve(){ ll A,B,C; cin >> A >> B >> C; if(A == 5 && B == 5 && C == 7){ cout << "YES" << endl; return;} if(A == 5 && B == 7 && C == 5){ cout << "YES" << endl; return;} if(A == 7 && B == 5 && C == 5){ cout << "YES" << endl; return;} cout << "NO" << endl; return ; }
// https://abc043.contest.atcoder.jp/tasks/abc043_a
//void solve(){ ll N; cin >> N; cout << N*(N+1)/2 << endl; }
// https://abc044.contest.atcoder.jp/tasks/abc044_a
//void solve(){ll N,K,X,Y;cin>>N>>K>>X>>Y; cout<<X*min(N,K)+Y*max(0LL,N-K)<<endl;}
// https://abc045.contest.atcoder.jp/tasks/abc045_a
//void solve(){ll a,b,h;cin>>a>>b>>h;cout<<(a+b)*h/2<<endl;}
// https://abc046.contest.atcoder.jp/tasks/abc046_a
//void solve(){ ll a,b,c; cin >> a >> b >> c; set<ll> s; s.insert(a); s.insert(b); s.insert(c); cout << s.size() << endl; }
// https://abc047.contest.atcoder.jp/tasks/abc047_a
void solve(){ll a,b,c;cin>>a>>b>>c;if(a==b+c||b==a+c||c==a+b)cout<<"Yes"<<endl;else cout<<"No"<<endl;}
// https://abc048.contest.atcoder.jp/tasks/abc048_a
//void solve(){string s1,s2,s3;cin>>s1>>s2>>s3;cout<<"A"<<s2[0]<<"C"<<endl;}
// https://abc049.contest.atcoder.jp/tasks/abc049_a
//void solve(){}
// https://abc050.contest.atcoder.jp/tasks/abc050_a
//void solve(){}
// https://abc051.contest.atcoder.jp/tasks/abc051_a
//void solve(){}
// https://abc052.contest.atcoder.jp/tasks/abc052_a
//void solve(){}
// https://abc053.contest.atcoder.jp/tasks/abc053_a
//void solve(){}
// https://abc054.contest.atcoder.jp/tasks/abc054_a
//void solve(){}

// Main function
int main(void) {cin.tie(0); ios::sync_with_stdio(false); solve(); return 0; }


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int i=0,j,fir[3000]={},sec[3000]={},n1,n2;
	do{
		scanf("%d %d",&n1,&n2);
		if(n1!=0 || n2!=0){
			fir[i] = n1;
			sec[i] = n2;
			i++;
		}
	}while(n1!=0 || n2!=0);
	
	for(j=0;j<i;j++){
		if(fir[j]<sec[j])
			printf("%d %d\n",fir[j],sec[j]);
		else
			printf("%d %d\n",sec[j],fir[j]);
	}
	return 0;
}

Measured memory_bytes: 632
#include <bits/stdc++.h>
//#include <ext/numeric>


using namespace std;
//using namespace __gnu_cxx;

const int MAXN = 300005;
int n, l;
int arr[MAXN];
vector<int> adjList[MAXN];

void build() {
    int j = n - 1;
    for (int i = n - 1; ~i; --i) {
        while (arr[j] - arr[i] > l)
            --j;
        adjList[j].push_back(i);
    }
}

int timer;
vector<int> tin, tout;
vector<vector<int>> up;
void dfs(int v, int p) {
    tin[v] = ++timer;
    up[v][0] = p;
    for (int i = 1; i <= l; ++i)
        up[v][i] = up[up[v][i - 1]][i - 1];

    for (int u : adjList[v]) {
        if (u != p)
            dfs(u, v);
    }

    tout[v] = ++timer;
}

void preprocess(int root) {
    tin.resize(n);
    tout.resize(n);
    timer = 0;
    l = ceil(log2(n));
    up.assign(n, vector<int>(l + 1));
    dfs(root, root);
}


int ans(int u, int v) {
    int ret = 0;
    for (int i = l; i >= 0; --i) {
        if (up[u][i] < v) {
            ret += (1 << i);
            u = up[u][i];
        }
    }
    return ret + 1;
}

int main() {
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("fence.out", "w", stdout);
#endif

    cin >> n;
    for (int i = 0; i < n; ++i)
        cin >> arr[i];
    cin >> l;
    build();
    preprocess(n - 1);
    int q;
    cin >> q;
    while(q--) {
//        cout << 1 << endl;
        int u, v;
        cin >> u >> v;
        if (u > v)
            swap(u, v);
        --u;
        --v;
        cout << ans(u, v) << '\n';
    }


    return 0;
}

Measured memory_bytes: 29352
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintStream;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	static private int sample = 0;
	static private InputStream in;
	static private PrintStream out;
	static private Scanner sc;
	static {
		if(sample == 0) {
			in = System.in;
			out = System.out;
		}else {
			try {
				in = new FileInputStream(new File("sample"+sample));
				out = new PrintStream("result"+sample);
			} catch (Exception e) {
				e.printStackTrace();
				System.exit(1);
			}
		}
		sc = new Scanner(in);
	}
	static public boolean fileCompare2(String fileA, String fileB) {
		boolean bRet = false;
		try {
			bRet = Arrays.equals(Files.readAllBytes(Paths.get(fileA)), Files.readAllBytes(Paths.get(fileB)));
		} catch (IOException e) {
		}
		return bRet;
	}
	static public void exit() {
		if(sample!=0) {
			out.close();
			String sam = "sample"+sample;
			String ans = "answer"+sample;
			String res = "result"+sample;
			if(fileCompare2(ans, res)) {
				System.out.println("AC");
			}else {
				System.out.println("WA");
				try {
					System.out.println(new String(Files.readAllBytes(Paths.get(ans))));
					System.out.println(new String(Files.readAllBytes(Paths.get(res))));
					System.out.println(new String(Files.readAllBytes(Paths.get(sam))));
				} catch (IOException e) {
				}
			}
		}
		sc.close();
	}
	static public void main(String ...strings ) {
		try {
			final int N = sc.nextInt();
			final int A[] = new int[N];
			int m1 = 0;
			int m2 = 0;
			for(int i=0;i<N;i++) {
				A[i] = sc.nextInt();
				if(m1 <= A[i]) {
					m2 = m1;
					m1 = A[i];
				}else if(m2 < A[i]){
					m2 = A[i];
				}
			}
			for(int i=0;i<N;i++) {
				if(A[i] == m1) {
					out.println(m2);
				}else {
					out.println(m1);
				}
			}
		} finally {
			exit();
		}
	}
}


Measured memory_bytes: 103596
from collections import Counter

n = int(input())
S = []
for _ in range(n):
    S.append(input())  # S += [input()] とも書ける

# 要素数チェック
counter = Counter(S)
# 要素数最大の要素を全て取得する->リスト
mostnum = 0
ans = []
for c in counter.most_common():
    if mostnum <= c[1]:
        mostnum = c[1]
        ans.append(c[0])
    else:
        break
# リストを辞書順に並び替える
ans.sort()
# リストを改行で出力
for a in ans:
    print(a)

Measured memory_bytes: 45040
program ABC162_C
  integer::G,A,H,I,J,K,L
  read(5,*)K
  A=0
  do I=1,K
     do J=1,K
        do L=1,K
           call gcd(J,L,G)
           call gcd(I,G,H)
           A=A+H
        end do
     end do
  end do
  write(6,*)A
end program ABC162_C

  subroutine gcd(A,B,G)
    integer::A,B,C,G,M
    if(A<B) then
       D=B
       E=A
    else
       D=A
       E=B
    end if
    do while(E/=0)
       M=mod(D,E)
       D=E
       E=M
    end do
    G=D
  end subroutine gcd

Measured memory_bytes: 2764
#include <iostream>

using namespace std;
int ans[1006][1006]={0};
long long mod=1e9+7;
int main()
{
int h,w;
cin >> h >>w;
char grid[h][w];
ans[0][0]=1;
for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
        cin >>  grid[i][j];
        if(i){
            ans[i][j]=(ans[i-1][j]+ans[i][j])%mod;
        }
        if(j){
            ans[i][j]=(ans[i][j-1]+ans[i][j])%mod;
        }
        if(grid[i][j]=='#'){
            ans[i][j]=0;
        }
    }
}
cout << ans[h-1][w-1];

    return 0;
}


Measured memory_bytes: 5120
#include <iostream>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <unordered_map>
#include <random>
#include <queue>
#include <iomanip>

#define BIG 1000000007
#define LLMAX 9223372036854775807
#define LLMIN (-9223372036854775808)
#define long long long

using namespace std;

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

    cout << (a < b ? 0 : 10)<< endl;
}




Measured memory_bytes: 888