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

#define rep(i, a, n)  for(ll i=a; i<n; i++)
#define per(i, a, n)  for(ll i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define LONGMAX 1e18
#define intMAX 1000000000
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod = 1e9+7;
int n;
string s;

int main(){
	cin >> n;
	cin >> s;
	set<string>ans;
	for(int i = 0; i < 1000; i++){
		ostringstream sout;
		sout << fill0(3) << i;
		string temp = sout.str();
		// cout << temp <<endl;
		int flag = 0;
		for(int j = 0; j < n; j++){
			if(temp[flag] == s[j]){
				flag++;
			}
		}
		if(flag==3)ans.insert(temp);
	}
	cout << ans.size() << endl;
}


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

int main() {
  long int N,sum=1;cin >>N;
  vector<string> S(N);
  for (int j=0;j<N;j++) cin >> S.at(j);
  sort(S.begin(), S.end());
  long int t=0,i=0;
  while (i<N) {
   if (S.at(t) == S.at(i)) i++;
   else{sum++;t = i;i++;}
  }
  cout << sum << endl;
}


Measured memory_bytes: 9580
t, x, y = 0, 0, 0
for i in range(int(input())):
    next_t, next_x, next_y = map(int, input().split())
    diff = abs(x - next_x) + abs(y - next_y)
    if diff > (next_t - t) or (diff - (next_t - t)) % 2 == 1:
        print("No")
        exit(0)
    t, x, y, = next_t, next_x, next_y
print("Yes")

Measured memory_bytes: 8876
#include<bits/stdc++.h>
using namespace std;
#define clr(a,b) memset(a,b,sizeof(a))
int n;
int v,k,ttm;
vector<int> graph[105];
int dis[105];//到其他点的距离
int vis[105];//纪律顶点是否被访问
void bfs(int u)
{
    queue<int> qu;
    qu.push(u);
    dis[u]=0;
    vis[u]=1;
    while(!qu.empty())
    {
        int v=qu.front();qu.pop();
        for(int i:graph[v])
        {
            if(dis[i]||i==1){continue;}
            qu.push(i);
            dis[i]=dis[v]+1;
        }
    }
}
int main()
{
    clr(vis,0);
    cin>>n;
    for(int i=0;i<n;++i)
    {
        cin>>v>>k;
        while(k--)
        {
            cin>>ttm;
            graph[v].push_back(ttm);//连接的点
        }
    }
    bfs(1);
     cout<<1<<" "<<dis[1]<<endl;
    for(int i=2;i<=n;++i)
    {
         cout<<i<<" "<<(dis[i]?dis[i]:-1)<<endl;
    }
    return 0;
}



Measured memory_bytes: 3172
#include <vector>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <iostream>
#include <set>
using namespace std;

int main() {
  string s;
  cin >> s;
  int n = (int)s.size();

  if (n < 26) {
    vector<bool> used(26, false);
    for (int i = 0; i < n; ++i) used[s[i] - 'a'] = true;
    for (int i = 0; i < 26; ++i) {
      if (!used[i]) {
	char add = i + 'a';
	s += add;
	break;
      }
    }
    cout << s << endl;
  } else {
    vector<bool> used(26, false);
    used[s.back() - 'a'] = true;
    int i;
    for (i = n - 1; i >= 0; --i) {
      if (s[i] < s[i + 1]) break;
      else used[s[i] - 'a'] = true;
    }
    if (i == -1) {
      puts("-1");
      return 0;
    }

    string t = "";
    for (int j = 0; j < i; ++j) t += s[j];
    for (int j = 0; j < 26; ++j) {
      if (used[j] && j > s[i] - 'a') {
	char add = j + 'a';
	t += add;
	break;
      }
    }
    cout << t << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**9)                    #再帰の深さブースト

n = int(input())
edge = [[] for i in range(n)]
ans = [0 for i in range(n)]
for i in range(n-1):
    u,v,w = map(int, input().split())
    edge[u-1].append([v-1,w%2])
    edge[v-1].append([u-1,w%2])

def bfsC(pre, now, nowc):
    for node, weight in edge[now]:
        if node != pre:
            if weight:
                ans[node] = 1-nowc
                bfsC(now, node, 1-nowc)
            else:
                ans[node] = nowc
                bfsC(now, node, nowc)
bfsC(-1, 0, 0)
for i in range(n):
    print(ans[i])

Measured memory_bytes: 157088
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author alireza_kaviani
 */

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef pair<ld, ld> pld;
typedef pair<string, string> pss;

#define all(x)                      (x).begin(),(x).end()
#define Sort(x)                     sort(all((x)))
#define X                           first
#define Y                           second
#define Mp                          make_pair
#define sep                         ' '
#define endl                        '\n'
#define debug(x)                    cerr << #x << " = " << x << endl
#define SZ(x)                       ll(x.size())
#define fast_io                     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_io                     freopen("in.txt" , "r" , stdin) ; freopen("out.txt" , "w" , stdout);
#define set_random                  mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

inline ll input() {
    ll n;
    cin >> n;
    return n;
}

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

set_random;

const ll MAXN = 1e6 + 10;
const ll INF = 8e18;
const ll MOD = 1e9 + 7; // 998244353; // 1e9 + 9;

string s;

int main() {
    fast_io;

    cin >> s;
    Sort(s);

    if(s[0] == s[1] && s[1] != s[2] && s[2] == s[3])    cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}
/*

*/


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define sp ' '
#define ret '\n'

int main(){
  int a,b,c,i;
  c=0;
  cin >> a;
  for(i=1;i<=a;i++){
    cin >> b;
    if(i!=b){
      c=c+1;
    }
  }
  if((c!=0)&&(c!=2)){
    cout << "NO";
  }
  else{
    cout << "YES";
  }
  return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())

s = input()
s = list(s)
if s[k-1] == 'A':
    s[k-1] = 'a'
elif s[k-1] == 'B':
    s[k-1] = 'b'
else:
    s[k-1] = 'c'

print(''.join(s))


Measured memory_bytes: 3060
<?php
  $n = trim(fgets(STDIN));
  $s = trim(fgets(STDIN));
  $max = 0;
  for($i=0; $i<$n-1; $i++){
      $x = "";
      $y = "";
      for($X=0; $X<=$i; $X++){
          $x .= $s[$X];
      }
      for($Y=$i+1; $Y<$n; $Y++){
          $y .= $s[$Y];
      }
    //   echo $x."\n";
    //   echo $y."\n";
      
      $kind = [];
      for($j=0; $j<strlen($x); $j++){
          for($k=0; $k<strlen($y); $k++){
              if($x[$j] == $y[$k]){
                  $kind[$x[$j]] = 1;
              }
          }
      }
      $max = max($max,count($kind));
  }
  echo $max;

Measured memory_bytes: 4604
#include <iostream>
using namespace std;
int main()
{
    int x;
    cin >> x;
    for(int a = -118; a <= 119; a++) {
        for(int b = -119; b <= 118; b++) {
            if(a*a*a*a*a - b*b*b*b*b == x) {
                cout << a << ' ' << b << endl;
                a = 120;
                b = 120;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3564
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
  int N;
  int A[1111111];
  int i;
  cin >> N;
  for(i=0;i<=N-1;i++)
    cin >> A[i];
  sort(A,A+N);
  int ans = 0;
  int count = 1;
  for(i=0;i<=N-2;i++){
    if(A[i]==A[i+1]){
      count++;
    }
    else{
      if(count%2==1) ans++;
      count = 1;
    }
  }
  int n = 0;
  int max = A[N-1];
  for(i=0;i<=N-1;i++)
    if(max == A[i]) n++;
  if(n%2 == 1) ans++;
  cout << ans << endl;
}

Measured memory_bytes: 2688
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cctype>
#include <string>

using namespace std;

int main(){
  string s;
  int h;

  while(1){
    cin >> s;
    if(s == "-"){
      break;
    }
    int m;
    cin >> m;
    
    for(int n = 0; n < m; n++){
      int h;
      cin >> h;
      
      string s_start = s.substr(0,h);
      string s_end = s.substr(h,-1);
      s = s_end + s_start;      
    }
    cout << s << endl;
  }
  return 0;
}  



Measured memory_bytes: 3172
import math

n = int(input())

if n * 100 % 108 == 0:
    print(n * 100 // 108)
else:
    price = math.floor((n * 100 // 108 + 1) * 1.08)
    if n == price:
        print(n * 100 // 108 + 1)
    else:
        print(":(")


Measured memory_bytes: 38384
#include <stdio.h>

#define LIMIT 1000000007

int main(){
   long ans,t;
   int i,n;

   scanf("%d",&n);
   ans=1;
   for (i=0;i<n;i++) ans=(ans*10)%LIMIT;
   t=2;
   for (i=0;i<n;i++) t=(t*9)%LIMIT;
   ans=(ans+LIMIT-t)%LIMIT;
   t=1;
   for (i=0;i<n;i++) t=(t*8)%LIMIT;
   ans=(ans+t)%LIMIT;
   printf("%ld\n",ans);
   return 0;
}


Measured memory_bytes: 1708
n = input()

def digitSum(n):
    s = str(n)
    array = list(map(int, list(s)))
    return array

b = digitSum(n)
a = 0
c = len(b)
for i in range(c):
    if b[i] == 1:
        a+=1
    else:
        a+=0

print(a)

Measured memory_bytes: 38256
// (Yes/No)
//   隣り合う２つの和が試行回数以上であることを満たせば
//   条件をクリアできるはず
// (パターン)
//   ０未満にならないように順に実行行を出力していけば良いはず
const lines = require('fs').readFileSync('/dev/stdin', 'utf8').split('\n');

const line1st = lines[0].split(' ');
const N = +line1st[0];
let A = +line1st[1];
let B = +line1st[2];
let C = +line1st[3];

// console.log(`N=${N} A=${A} B=${B} C=${C}`)

const s = [];
for (let i = 0; i < N; i++) {
    s.push(lines[i + 1]);
}

let isYes = true;
const ans = [];

for (let i = 0; i < N - 1; i++) {
    const v = s[i];
    const next = s[i + 1];
    if (v === 'AB') {
        // console.log(`AB: `)
        // console.log(`N=${N} A=${A} B=${B} C=${C}`)
        if (A === 0 && B === 0) {
            isYes = false;
            break;
        } else if (A === 0) {
            A ++;
            B --;
            ans.push('A');
        } else if (B === 0) {
            A --;
            B ++;
            ans.push('B');
        } else if (next === 'AC' && A === 1) {
            A ++;
            B --;
            ans.push('A');
        } else if (next === 'BC' && B === 1) {
            A --;
            B ++;
            ans.push('B');
        } else {
            A ++;
            B --;
            ans.push('A');
        }
    } else if (v === 'AC') {
        if (A === 0 && C === 0) {
            isYes = false;
            break;
        } else if (A === 0) {
            A ++;
            C --;
            ans.push('A');
        } else if (C === 0) {
            A --;
            C ++;
            ans.push('C');
        } else if (next === 'AB' && A === 1) {
            A ++;
            C --;
            ans.push('A');
        } else if (next === 'BC' && C === 1) {
            A --;
            C ++;
            ans.push('C');
        } else {
            A ++;
            C --;
            ans.push('A');
        }
    } else { // (v === 'BC')
        if (B === 0 && C === 0) {
            isYes = false;
            break;
        } else if (B === 0) {
            B ++;
            C --;
            ans.push('B');
        } else if (C === 0) {
            B --;
            C ++;
            ans.push('C');
        } else if (next === 'AB' && B === 1) {
            B ++;
            C --;
            ans.push('B');
        } else if (next === 'AC' && C === 1) {
            B --;
            C ++;
            ans.push('C');
        } else {
            B ++;
            C --;
            ans.push('B');
        }
    }
}

const final = s[N - 1];
if (final === 'AB') {
    if (A < B) {
        ans.push('A');
    } else if (A === B && A === 0) {
        console.log('No');
        return;
    } else {
        ans.push('B');
    }
} else if (final === 'BC') {
    if (C < B) {
        ans.push('C');
    } else if (C === B && C === 0) {
        console.log('No');
        return;
    } else {
        ans.push('B');
    }
} else { // (final === 'AC')
    if (C < A) {
        ans.push('C');
    } else if (C === A && C === 0) {
        console.log('No');
        return;
    } else {
        ans.push('A');
    }
}

if (!isYes) {
    console.log('No');
    return;
}
console.log('Yes');

ans.forEach(v => console.log(v));


Measured memory_bytes: 46836
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using ll = long long;
const int INF = 2147483647;
// const ll INF = 1000000000000000000LL;

int main() {
	string s;
	cin >> s;
	int r;
	int cnt_r=0;
	int cnt_l=0;

	vector<int> ans(s.size());
	for(int i=0;i<s.size();i++){
		if(s[i]=='R') cnt_r++;
		if(s[i]=='L'){
			r = i;
			while(r<s.size()){
				r++;
				if(s[r]=='R'){
					cnt_l++;
					break;
				}
				else
					cnt_l++;
			}
		}
		if(s[i-1]=='R'&&s[i]=='L'){
			cnt_r--;
			cnt_l--;
			ans[i-1] = cnt_r/2+(cnt_l+1)/2+1;
			ans[i] = (cnt_r+1)/2+cnt_l/2+1;
			cnt_r = 0;
			cnt_l = 0;
			i = r-1;
		}
	}
	rep(i,s.size()){
		cout << ans[i] << ' ';
	}
	cout << endl;
	return 0;
}



Measured memory_bytes: 3824
#include <algorithm>
#include <array>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <vector>

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

using namespace std;

int main() {
  std::cout << std::fixed << std::setprecision(10);
  int X;
  cin >> X;

  int n = X / 100;
  int m = X % 100;

  rep(i, n) {
    if (m >= 5) {
      m -= 5;
      continue;
    }
    if (m >= 4) {
      m -= 4;
      continue;
    }
    if (m >= 3) {
      m -= 3;
      continue;
    }
    if (m >= 2) {
      m -= 2;
      continue;
    }
    if (m >= 1) {
      m -= 1;
      continue;
    }
    if (m == 0) {
      break;
    }
  }

  if (m == 0)
    cout << 1 << endl;
  else
    cout << 0 << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
#include<algorithm>
#include<math.h>
#include<map>
#include<queue>

int main() {
	ll n;
	cin >> n;
	string a;
	cin >> a;
	ll cnt(0);
	ll cntw(0);
	rep(i, n) {
		if (a[i] == 'R') {
			++cnt;
		}
		else {
			++cntw;
		}
	}
	ll cntr(0);
	if (cntw == 0) {
		cout << 0;
		return 0;
	}
	rep(i, cnt) {
		if (a[i] == 'R') {
			cntr++;
		}
	}
	ll ans = cnt - cntr ;
	cout << ans;
	return 0;
}

Measured memory_bytes: 3752
n=int(input())
t=0
x=0
y=0
for i in range(n):
  t_,x_,y_=map(int,input().split())
  t=abs(t_-t)
  x=abs(x_-x)
  y=abs(y_-y)
  if x+y>t:
    print('No')
    exit()
  if t_%2!=(x_+y_)%2:
    print('No')
    exit()
  
print('Yes')

Measured memory_bytes: 9176
N = int(input())
A = list(map(int,input().split()))
B = [0]*N
for i in range(N):
     B[i] = A[i]-(i+1)

B.sort()
if N%2==1:
    W = B[N//2]
    out = 0
    for i in range(N):
        out += abs(B[i]-W)
else:
    X = B[N//2-1]
    Y = B[N//2]
    Z = X+Y
    if Z%2==0:
        W = Z//2
        out = 0
        for i in range(N):
            out += abs(B[i]-W)
    else:
        W1 = Z//2
        out1 = 0
        for i in range(N):
            out1 += abs(B[i]-W1)
        W2 = Z//2
        out2 = 0
        for i in range(N):
            out2 += abs(B[i]-W2)
        out = min(out1,out2)
print(out)

Measured memory_bytes: 88404
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.IO;

class Program
{
    static int Power(int N)
    {
        int ans = 1;
        for (int i = 0; i < N; ++i)
        {
            ans *= 2;
            ans %= 1000000007;
        }
        return ans;
    }
    static int Solve(int N, int[] A)
    {
        Array.Sort(A);
        if (N % 2 == 0)
        {
            for (int i = 0; i < N; ++i)
            {
                if (A[i] != ((i & ~1) + 1)) { return 0; }
            }
        }
        else
        {
            for (int i = 0; i < N; ++i)
            {
                if (A[i] != ((i + 1) & ~1)) { return 0; }
            }
        }
        return Power(N / 2);
    }
    static void Main(string[] args)
    {
        int N = int.Parse(Console.ReadLine());
        int[] A = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        Console.WriteLine(Solve(N, A));
    }
}


Measured memory_bytes: 9816
//raja1999
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16)a; cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 <<endl;prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false);
int main(){
	std::ios::sync_with_stdio(false);
	int n,a,b,i,fl=0;
	cin>>n;
	cin>>a>>b;
	if(a>b){
		swap(a,b);
		fl=1;
	}
	i=0;
	while(1){
		if(a==b-1){
			break;
		}
		if(fl){
			if(i%2==0){
				a--;
			}
			else{
				b++;
			}
		}
		else{
			if(i%2==0){
				a++;
			}
			else{
				b--;
			}
		}
		i++;

	}
	if(i%2==0){
		cout<<"Borys"<<endl;
	}
	else{
		cout<<"Alice"<<endl;
	}
} 


Measured memory_bytes: 256
//#pragma GCC optimize "trapv"
#include<bits/stdc++.h>
#define ll long long 
#define fab(a,b,i) for(int i=a;i<b;i++)
#define pb push_back
#define db double
#define mp make_pair
#define endl "\n"
#define f first
#define se second
#define all(x) x.begin(),x.end()
#define MOD 1000000007
#define quick ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;

int main()
{ quick;

	int n,k;
	cin>>n>>k;
	int h[n];
	fab(0,n,i)
	cin>>h[i];
	vector<int> dp(n);
	dp[n-1]=0;
	dp[n-2]=abs(h[n-1]-h[n-2]);

	for(int i=n-2;i>=0;i--)
	{
		int r=1e9;
		fab(i+1,i+k+1 and j<n,j)
		{
			r=min(r,dp[j]+abs(h[i]-h[j]));


		}
		dp[i]=r;
		//cout<<dp[i]<<" ";
	}
	//fab(0,n,i)
	//cout<<dp[i]<<" ";
	cout<<dp[0]<<endl;

	return 0;

	return 0;
}

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

#define fi first
#define se second
#define FO(x, n) for (int x = 0; x < n; ++x)
#define FOR(x, a, b) for (int x = a; x < b; ++x)
#define RFO(x, n) for (int x = n - 1; x >= 0; --x)
#define RFOR(x, a, b) for (int x = b - 1; x >= a; --x)
#define FOR_ITER(x, a) for(auto x = a.begin(); x != a.end(); ++x)

#define pb push_back
#define pf push_front
#define mp make_pair
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define VL vector<long long>
#define F first
#define S second

using namespace std;


typedef complex<double> P;
typedef unsigned char byte;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<string, string> pss;
typedef pair<ll, ll> pll;
inline bool feq(const double& a, const double& b) { return fabs(a - b) < 1e-10; }
inline int gcd(int a, int b) {
    if (b == 0) return a;
    return a < b? gcd(b, a) : gcd(b, a % b);
}
ll mo=1000000007;
const ll INF = 1e18;

int main(){
    string n;
    int k;
    cin >> n >> k;
    set<int> cs;

    FO(i, 10) {
        cs.insert(i);
    }

    FO(i, k) {
        int t;
        cin >> t;
        cs.erase(t);
    }

    vector<int> cv(All(cs));
    sort(All(cv));

    int minNum = cv.front();
    int maxNum = cv.back();
    if (minNum == 0) {
        minNum = cv.at(1);
    }

    int bitNum = SZ(n);

    string maxBitNum = "";
    FO(i, bitNum) {
        maxBitNum.pb('0' + maxNum);
    }

    int rs = minNum;
    FO(i, bitNum) {
        rs = rs * 10 + cv.front();
    }

    if (maxBitNum >= n) {
        FOR(i, stoi(n), rs) {
            string tmp = to_string(i);
            bool flag = true;
            FO (j, bitNum) {
                if (cs.count(tmp.at(j) - '0') == 0) {
                    flag = false;
                    break;
                }
            }
            if (flag) {
                cout << i << endl;
                break;
            }
        }
    } else {
        cout << rs << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include<algorithm>
#include <stdio.h>
#include <bitset>
#include<math.h>
#include<list>
using namespace std;
typedef long long ll;
int main() {
	int n, k, ans=0,h;
	cin >> n >> k;
	for (int i=0; i < n; i++) {
		cin >> h;
		if (h >= k) {
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
 
#define rep(i,n) for (int (i) = 0; (i) < (n); i++)
#define rep1(i,n) for (int (i) = 1; (i) <= (n); i++)
typedef long long int llint;
 
using namespace std;
 
const llint inf = 1 << 29 ;
 
int main(void) {
	int n, m;
	cin >> n >> m;
 
	vector<int> a(m);
	vector<int> keys;
	rep(i, m) {
	  int b;
		cin >> a[i] >> b;
 
	  int bs = 0;
		rep(j, b) {
		  int c;
			cin >> c;
			c--;
			bs |= 1 << c;
		}
		
		keys.push_back(bs);
	}
 
	vector<llint> dp(pow(2,n),inf);
	dp[0] = 0;
	rep(i, pow(2,n)) rep(j, m) {
 
	 if (dp[i] + a[j] < dp[i | keys[j]])  dp[i | keys[j]] = dp[i] + a[j];
	}
 
	llint ans;
	if ((ans = dp[pow(2, n) - 1]) == inf) cout << -1 << endl;
	else cout << dp[pow(2,n)-1] << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
int n,a[10001],b[10001],c[10001],x,i,z;
	scanf("%d",&n);
	while(n!=0){
	scanf("%d %d %d",&a[0],&b[0],&c[0]);
	z=b[0]+c[0];
	x=a[0];
	for(i=1;i<n;i++){
		scanf("%d %d %d",&a[i],&b[i],&c[i]);
		if(z<b[i]+c[i]){
			z=b[i]+c[i];
			x=a[i];
		}
	}
	printf("%d %d\n",x,z);
		scanf("%d",&n);
	}
	return 0 ;
}

Measured memory_bytes: 716
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <string>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <queue>
#include <climits>
#include <set>
#include <complex>
#include <cmath>
#include <cstring>
#include <map>
using namespace std;
using ll = long long;
#define MOD 1000000007
#define INF 1LL << 59
using ld = long double;

const int MAX = 510000;
//const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];
void COMinit()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
long long COM(int n, int k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
ll p[12], c[12];
int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    //cout << fixed << setprecision(5);

    ll D, G;
    cin >> D >> G;
    for (int i = 0; i < D; ++i)
        cin >> p[i] >> c[i];

    int ans = 1e9;
    for (int bit = 0; bit < (1 << D); ++bit)
    {
        int sum = 0;
        int t = 0;
        bool used[11];
        for (int i = 0; i < D; ++i)
        {
            used[i] = false;
        }
        for (int i = 0; i < D; ++i)
        {
            if (bit >> i & 1)
            {
                sum += p[i] * 100 * (i + 1) + c[i];
                t += p[i];
                used[i] = true;
            }
        }
        if (sum >= G)
        {
            ans = min(ans, t);
            continue;
        }

        int idx = 0;
        for (int i = D - 1; i >= 0; --i)
        {
            if (used[i] == false)
            {
                idx = i;
                break;
            }
        }

        for (int i = 1; i < p[idx]; ++i)
        {

            sum += (idx + 1) * 100;
            t++;
            if (sum >= G)
            {
                ans = min(ans, t);
                break;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int N = 999999;
		int[] P = new int[N+1];
		P[0] = 1; P[1] = 1;
		for (int i = 4 ; i < N+1 ; i+=2) P[i] = 1;
		for (int i = 3 ; i < N+1 ; i++) {
			if (P[i] == 0) {
				for (int j = i+i ; j < N+1 ; j+=i) P[j] = 1;
			}
		}
		int a = 0;
		for (int i = 0 ; i < N+1 ; i++) {
			if (P[i] == 0) a++;
			P[i] = a;
		}

		String line;
		while ((line = br.readLine()) != null) {
			int n = Integer.parseInt(line);
			System.out.println(P[n]);
		}

	}
}

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

using namespace std;

int n, h[100010];
long long dp[100010];

long long solve(int pos) {
    if (pos >= n - 1) return 0LL;
    if (dp[pos] != -1) return dp[pos];
    long long ret = LLONG_MAX;
    if (pos < n - 2) ret = min((long long) abs(h[pos] - h[pos + 1]) + solve(pos + 1), (long long) abs(h[pos] - h[pos + 2]) + solve(pos + 2));
    else ret = (long long) abs(h[pos] - h[pos + 1]) + solve(pos + 1);
    return dp[pos] = ret;
}

int main() {
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        scanf("%d", &h[i]);
        dp[i] = -1;
    }
    printf("%lld\n", solve(0));
    return 0;
}


Measured memory_bytes: 3712
process.stdin.resume();
process.stdin.setEncoding("utf8");

const reader = require("readline").createInterface({
  input: process.stdin,
  output: process.stdout,
});

const lines = [];

reader.on("line", (line) => {
  lines.push(line);
});

reader.on("close", () => {
  const n = Number(lines[0]);
  let minR = Number(lines[1]);
  let maxIncome = lines[2] - minR;
  for (let i = 2; i <= n; i++) {
    const r = Number(lines[i]);
    maxIncome = Math.max(maxIncome, r - minR);
    minR = Math.min(minR, r);
  }
  console.log(maxIncome);
});



Measured memory_bytes: 36192
#include <iostream>

using namespace std;

long long gcd( long long m, long long n ){

  if ( n == 0) return m;
  return gcd(n,m%n);
}//gcd

long long lcm( long long m, long long n ){
  // 引数に０がある場合は０を返す
  if ( ( 0 == m ) || ( 0 == n ) ) return 0;

  return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//lcm

int main(){
  int N;
  long long T,ans = 1;
  cin >> N;
  for(int i = 0; i < N; i++){
    cin >> T;
    ans = lcm(T,ans);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>

using namespace std;

typedef long long ll;

int main () {
	ll n, m;
	ll i, j;
    char s[101];
    std::map<std::string,int> salary;
	ll ret;
	
    cin >> n;
        
    for (i=0;i<n;i++){
        cin >> s;
        salary[s]++;
    }
    
    cout << salary.size()<< endl;
    

	return 0;
}

Measured memory_bytes: 19204
package main

import (
	"fmt"
	"strings"
)

func isACGT(s string) bool {
	var c int
	acgt := "ACGT"
	for i := range "ACGT" {
		c += strings.Count(s, string(acgt[i]))
	}
	return c == len(s)
}

func main() {
	var s string
	var ans int
	fmt.Scan(&s)
	for i := 0; i <= len(s)-1; i++ {
		for j := i + 1; j <= len(s); j++ {
			if isACGT(s[i:j]) && len(s[i:j]) > ans {
				ans = len(s[i:j])
			}
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 640
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[]args) {
        try {
        
         BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());

      HashSet<String> lottery = new HashSet<String>();
      for(int i = 0;i<n;i++) {
          String words = br.readLine();
          lottery.add(words);
      }
System.out.println(lottery.size());

        }catch(Exception e) {
        }
    }

    
}

Measured memory_bytes: 58900
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

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

template <class T> using ordered_set = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_mset;

#define FOR(i,a,b) for(int i = a; i < b; i++)
#define F0R(i,a) for(int i = 0; i < a; i++)
#define pb push_back
#define all(x) x.begin(), x.end()
#define sz(x) int((x).size())
#define newl '\n'


int N, P[10], Q[10], a[10], pa, qa;


int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	//ifstream cin("/Users/konwoo/input.txt");
	//ofstream cout("/Users/konwoo/output.txt");

	cin >> N;
	F0R(i,N) cin >> P[i+1];
	F0R(i,N) cin >> Q[i+1];
	F0R(i,N) a[i+1] = i+1;
	int cnt = 0;
	do{
		cnt++;
		bool works = 1;
		F0R(i,N){
			if (P[i+1] != a[i+1]) works =0;
		}
		bool works2 = 1;
		F0R(i,N){
			if (Q[i+1] != a[i+1]) works2 = 0;
		}
		if (works)pa = cnt;
		if (works2) qa = cnt;

	}while(next_permutation(a+1,a+N+1));
	cout << abs(pa-qa) << newl;



	










	return 0;
}


Measured memory_bytes: 256
ss = []
tt = []

n = gets.to_i
n.times { ss << gets.chomp }

m = gets.to_i
m.times { tt << gets.chomp }

ww = ss + tt
ww.uniq!

ret = 0
ww.each do |w|
  s_count = ss.select { |s| s == w }.size
  t_count = tt.select { |t| t == w }.size
  tmp = s_count - t_count
  ret = tmp if ret < tmp
end
puts ret


Measured memory_bytes: 1788
#include <iostream>
#include <fstream>
#include <sstream>
#include <random>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <queue>
#include <iostream>
#include <functional>
#include <stdio.h>
#include <string.h>
#include <unordered_map>
#include <set>
#include <iomanip>
#include <map>

#define ll long long
#define mod 1000000007
#define max_limit 1000005
using namespace std;
ll n;
ll arr[1000005];

long long add_mod (long long a, long long b) {
    return (a + b) % mod;
}

long long mul_mod (long long a, long long b) {
    return (a * b) % mod;
}

long long pow_mod (long long a, long long b) {
    long long res = 1, t = a;
    while (b) {
        if (b & 1)
            res = mul_mod(res, t);
        b >>= 1;
        t = mul_mod(t, t);
    }
    return res;
}

long long div_mod (long long a, long long b) {
    return mul_mod(a, pow_mod(b, mod - 2));
}

map < int, int > factors (int x) {
    map < int, int > res;
    for (int i = 2; i <= sqrt(x); ++i) {
        while (x % i == 0) {
            ++res[i];
            x /= i;
        }
    }
    if (x != 1)
        res[x] = 1;
    return res;
}

void cklcm (map < int, int > &a, map < int, int > &b) {
    for (auto &p: b)
        a[p.first] = max(a[p.first], p.second);
}

signed main () {
    int n;
    cin >> n;
    vector < int > a(n);
    map < int, int > g;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        map < int, int > x = factors(a[i]);
        cklcm(g, x);
    }
    long long t = 1;
    for (auto p: g)
        t = mul_mod(t, pow_mod(p.first, p.second));
    long long ans = 0;
    for (int i = 0; i < n; ++i)
        ans = add_mod(ans, div_mod(t, a[i]));
    cout << ans << '\n';
}

Measured memory_bytes: 768
#include <iostream>
#include <ctime>
#define ESP 1e-10
using namespace std;
int main() {
	for (int i = 0; i < 100000000; i++) {
		int j = i;
	}
	while (true) {
		int H, W; cin >> H >> W;
		if (H == 0 && W == 0) {
			break;
		}
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W;j++) {
				cout << "#";
			}
			cout << endl;
		}
		cout << endl;
	}


}

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int main()
{
    int a, b, x;
    cin >> a >> b >> x;
    if (x < a || a + b < x)
        OP("NO");
    else
        OP("YES");
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;
ll k;
//ld ;
string s;
 
int main() {
  cin >> k;
  cin >> s;
  string ans;
  if(k < s.length()){
    ans = s.substr(0,k) + "...";
  }else{
    ans = s;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3624
S = list(input())

cnt = 0
for i, s in enumerate(S):
    if i % 2 == 0 and s != "1":
        cnt += 1
    elif i % 2 == 1 and s != "0":
        cnt += 1

cnt1 = 0
for i, s in enumerate(S):
    if i % 2 == 0 and s != "0":
        cnt1 += 1
    elif i % 2 == 1 and s != "1":
        cnt1 += 1

print(min(cnt, cnt1))

Measured memory_bytes: 3956
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <climits>
#include <map>
#include <set>
const int mod = 1e9 + 7;
const int inf = 1 << 20;
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
using namespace std;


int main()
{
    string s;
    cin >> s;
    bool can = true;
    for(int i = 0; i < s.size(); i++){
        if((i+1) % 2 == 0){
            if(s[i] == 'R'){
                can = false;
            }
        }else{
            if(s[i] == 'L'){
                can = false;
            }
        }
    }
    if(can){
        cout << "Yes";
    }else{
        cout << "No";
    }
}

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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

template <typename T>
struct Edge {
  int from, to;
  T weight;
};

template <typename T>
class Graph {
 public:
  Graph(int n) : edges_(n) {}
  void AddEdge(int from, int to, T weight) {
    edges_[from].push_back({from, to, weight});
  }
  std::vector<Edge<T>>& Edges(int from) { return edges_[from]; }
  const std::vector<Edge<T>>& Edges(int from) const { return edges_[from]; }
  int NumVertices() const { return edges_.size(); }

 private:
  std::vector<std::vector<Edge<T>>> edges_;
};

template <typename T>
bool BellmanFord(const Graph<T>& graph, int start, std::vector<T>& dist) {
  std::size_t n = graph.NumVertices();

  dist.resize(n);
  T inf = std::numeric_limits<T>::max();
  fill(dist.begin(), dist.end(), inf);
  dist[start] = 0;

  for (std::size_t iter = 0; iter < n; ++iter) {
    for (std::size_t i = 0; i < n; ++i) {
      if (dist[i] == inf) continue;
      for (const Edge<T>& e : graph.Edges(i)) {
        if (T d = dist[i] + e.weight; dist[e.to] > d) {
          if (iter == n - 1) return false;
          dist[e.to] = d;
        }
      }
    }
  }
  return true;
}

int main() {
  in(ll, n, m, p);
  Graph<ll> g(n);
  Graph<ll> bg(n);
  rep(i, m) {
    in(int, a, b, c);
    --a, --b;
    g.AddEdge(a, b, p - c);
    bg.AddEdge(b, a, 0);
  }

  vector<ll> bgd;
  BellmanFord(bg, n - 1, bgd);
  rep(i, n) if (bgd[i] != 0) {
    g.Edges(i).clear();
  }

  vector<ll> d;
  if (BellmanFord(g, 0, d)) {
    out(max(-d[n - 1], 0LL));
  } else {
    out(-1);
  }
}


Measured memory_bytes: 4040
#include<bits/stdc++.h>
using namespace std;
int main()
{
    map<string,int>mp ;
    int n ; cin>>n ;
    while(n--)
    {
        string s ; cin>>s ;
        mp[s]++ ;
    }
    cout<<"AC x "<<mp["AC"]<<endl ;
    cout<<"WA x "<<mp["WA"]<<endl ;
    cout<<"TLE x "<<mp["TLE"]<<endl ;
    cout<<"RE x "<<mp["RE"]<<endl ;
}


Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		String s=String.valueOf(scanner.nextInt());
		
		String ans="";
		for(int i=0;i<3;i++) {
			char c=s.charAt(i);
			if(c=='1')ans+="9";
			else ans+="1";
		}
		
		System.out.println(Integer.parseInt(ans));
	}
}

Measured memory_bytes: 23380
#include <stdio.h>
int main(void){
    int a, b, d, r;
    double f;
    scanf("%d",&a);
    scanf("%d",&b);
    d=a/b;
    r=a%b;
    f=(double)a/(double)b;
    printf("%d %d %.7f\n",d,r,f);
     return 0;
}
    


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

using namespace std;

int main(){
	
  	string s;
  	int ans=0,m=0;
  	cin>>s;
  	for(int i=0;i<3;i++){
    	if(s[i]=='R'){
          	ans++;
        }
      	else{
        	if(ans>m) m=ans;
          	ans=0;
        }
    }
  	
  	cout<<max(m,ans)<<"\n";
  	return 0;
}

Measured memory_bytes: 3612
from collections import*
import sys
input=sys.stdin.readline

h,w=map(int,input().split())
grid=[["#"]*(w+2)]+[list("#"+input()+"#")for x in range(h)]+[["#"]*(w+2)]

stack=deque([])
for y in range(1,h+1):
    for x in range(1,w+1):
        if grid[y][x]=="#":
            grid[y][x]=0
            stack.append((y,x))

for i in range(h*w):
    tmp=deque([])
    while stack:
        my,mx=stack.pop()
        for y,x in ([0,1],[1,0],[-1,0],[0,-1]):
            if grid[my+y][mx+x]==".":
                grid[my+y][mx+x]=i+1
                tmp.append([my+y,mx+x])
    stack=tmp
    if len(tmp)==0:
        print(i)
        break

Measured memory_bytes: 164616
def resolve():
    '''
    code here
    '''
    S = input()

    ans1 = 0
    res1 = 0
    ans2 = 1
    res2 = 0
    for item in S:
        item = int(item)
        if ans1%2 != item:
            res1 += 1
        if ans2%2 != item:
            res2 += 1

        ans1 += 1
        ans2 += 1

    print(min(res2, res1)) 


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 9292
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;

string s,t;
int main()
{
	cin >> s >> t;
	for(int i = 0;i < s.size();i++){
		string x = "";
		for(int j = 0;j < s.size();j++){
			x += (s[(i + j)%s.size()]);
		}
		if(x == t){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

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

int main() {
  int n;
  string s;
  int xx=0;
  cin>>n;
  cin>>s;
  int ans=1000000;
  int now;
  int yy=0;
  int hh;
  for(int i=0;i<n;i++)if(s[i]=='W')xx++;
  for(int i=0;i<n;i++){
    if(s[i]=='W')yy++;
    if(s[i]=='W')hh=1;
    else hh=0;
    if(hh==1){
      now=yy-1+n-i-xx+yy;
    }
    else now=yy+n-i-xx+yy;
    ans=min(ans,now);
  }
  cout<<ans-1<<endl;
}


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

int main(){
  int n, k = 0;
  string s;
  cin >> n;
  rep(i, n){
    cin >> s;
    if (s == "Y")
      k++;
  }
  if(k == 0)
    cout << "Three" << endl;
  else
    cout << "Four" << endl;
}

Measured memory_bytes: 3568
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
#include<complex>

typedef complex<double> Point;
double dot(Point a, Point b){
  return real(conj(a) * b);
}
double cross(Point a, Point b){
  return imag(conj(a) * b);
}
int ccw(Point a, Point b, Point c){
  b -= a; c -= a;
  if(cross(b, c) > EPS) return 1;
  if(cross(b, c) < -EPS) return -1;
  if(dot(b, c) < 0) return +2;
  if(norm(b) < norm(c)) return -2;
  return 0;
}
enum{ OUT, ON, IN };
int contains(Point a, Point b, Point c, Point p){
  int A = ccw(a, b, p);
  int B = ccw(b, c, p);
  int C = ccw(c, a, p);
  if(A == B && B == C && abs(A) == 1) return IN;
  return OUT;
}

int main(){
  int N;
  cin >> N;
  while(N--){
    Point a[3];
    Point b[2];
    REP(i, 3) cin >> a[i].real() >> a[i].imag();
    REP(i, 2) cin >> b[i].real() >> b[i].imag();
    if(abs(ccw(a[0], a[1], a[2])) == 1 && contains(a[0], a[1], a[2], b[0]) != contains(a[0], a[1], a[2], b[1])){
      cout << "OK" << endl;
    }else{
      cout << "NG" << endl;
    }
  }
  return 0;
}

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

typedef vector<double> vec;
typedef vector<vec> mat;
const double EPS=1E-9;

vec gauss_jordan(const mat& A,const vec& b){
  int n=A.size();
  mat B(n,vec(n+1));
  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)B[i][j]=A[i][j];
  for(int i=0;i<n;i++)B[i][n]=b[i];
  for(int i=0;i<n;i++){
    int pivot=i;
    for(int j=i;j<n;j++)if(abs(B[j][i])>abs(B[pivot][i]))pivot=j;
    swap(B[i],B[pivot]);
    if(abs(B[i][i])<EPS)return vec();
    for(int j=i+1;j<=n;j++)B[i][j]/=B[i][i];
    for(int j=0;j<n;j++)if(i!=j)for(int k=i+1;k<=n;k++)B[j][k]-=B[j][i]*B[i][k];
  }
  vec x(n);
  for(int i=0;i<n;i++)x[i]=B[i][n];
  return x;
}

int main(){
  int n,s,t,q[100],a[100][100],d[100][100];
  while(cin>>n>>s>>t,n){
    vector<int> v[2][100];
    s--,t--;
    for(int i=0;i<n;i++)cin>>q[i];
    for(int i=0;i<n;i++)
      for(int j=0;j<n;j++){
	cin>>a[i][j];
	if(!a[i][j])a[i][j]=d[i][j]=1e9;
	else v[0][i].push_back(j),d[i][j]=a[i][j];
      }
    for(int i=0;i<n;i++)
      for(int j=0;j<n;j++)
	for(int k=0;k<n;k++)
	  d[j][k]=min(d[j][k],d[j][i]+d[i][k]);
    if(d[s][t]==1e9){cout<<"impossible"<<endl;return 0;}
    mat A(n,vec(n));
    vec b(n);
    for(int i=0;i<n;i++){
      if(d[i][t]==a[i][t])v[1][i].push_back(t);
      for(int j=0;j<n;j++)
	if(d[i][t]==a[i][j]+d[j][t])v[1][i].push_back(j);
      }
    for(int i=0;i<n;i++){
      int sz=v[q[i]][i].size();
      if(i==t){A[i][i]=1;continue;}
      double cnt=0;
      for(int j=0;j<sz;j++){
	int p=v[q[i]][i][j];
	A[i][p]=1.0/sz;
	cnt+=a[i][p];
      }
      A[i][i]-=1;
      b[i]-=cnt/sz;
    }
    vec res=gauss_jordan(A,b);
    printf("%.9lf\n",res[s]);
  }
  return 0;
}


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

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

	int cnt = 0;
	for (int i = 0; i < S.size(); i++) {
		if (S[i] != T[i]) {
			cnt++;
		}
	}
	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 3916
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> VI;
typedef vector<VI> VVI;//例: VVI dp(10, vector<int>(10, INF);
typedef priority_queue<int, vector<int>, less<int> > QUE_int;
const int INF = pow(10, 5) + 1;//+1しないとREになる(out of rangeになるんかな?? )

vector<int> dx = { -1, 0, 1, 0, -1, -1, 1, 1 };
vector<int> dy = { 0, -1, 0, 1, -1, 1, -1, 1 };

int main(void) {
	double H, A;
	cin >> H >> A;
	int ans = ceil(H / A);

	cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

void show(int arr[], int n){
	for(int i=0; i<n; i++)
		if(i<n-1)
			cout<<arr[i]<<' '<<flush;
		else
			cout<<arr[i]<<flush;
	cout<<endl;
}


void swap(int& a, int& b){
	int t=a;
	a=b;
	b=t;
}


int insertsort(int[], int);

int main()
{
	int n;
	cin>>n;
	int arr[100];

	for(int i=0; i<n; i++)
		cin>>arr[i];
	show(arr, n);

	insertsort(arr, n);

	


}

int insertsort(int arr[], int n)
{

	int counter=0;
	int compindex;
	int comp;
	int j;
	for( int i=1; i < n; i++ ){
		
		compindex=i;
		comp=arr[compindex];
		j=1;
		for( ; compindex-j > -1; j++ ) {

			if(comp < arr[compindex-j])
				arr[compindex - j + 1] = arr[compindex - j];
			else
				break;
			
			counter++;
		}
		arr[compindex - j + 1] = comp;
	
		show(arr, n);


	}

	return counter;


	
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
typedef long long ll;
#define ITR(v,c) for(auto v=begin(c);v!=end(c);v++)
#define FOR(v,a,n) for(int v=a;v<(int)(n);v++)
#define FORE(x,arr) for(auto &x:arr)
#define REP(v,n) FOR(v,0,n)
#define ALL(c) begin(c),end(c)
const int DX[4]={0,1,0,-1}, DY[4]={-1,0,1,0};
const int INF = 1e9;
template<class T,class U>ostream&operator<<(ostream &os,const pair<T,U> &p){
    os<<"("<<p.first<<","<<p.second<<")";return os;}
template<class T>ostream&operator<<(ostream &os,const vector<T> &v){
    ITR(i,v)os<<*i<<(i==end(v)-1?"":"\n");return os;}
//------------------------------------------------------------------------------

int main(int argc, char const *argv[]) {
    string s;
    cin>>s;
    if(s.size()==2) {
        if(s[0]==s[1]) cout<<"1 2"<<endl;
        else cout<<"-1 -1"<<endl;
        return 0;
    }
    REP(i,s.size()-2) {
        string t=s.substr(i,3);
        if(t[0]==t[1] || t[1]==t[2] || t[0]==t[2]) {
            cout<<i+1<<" "<<i+3<<endl;
            return 0;
        }
    }
    cout<<"-1 -1"<<endl;
    return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
#include<limits.h>
int main(void){
    long int l, r;
    scanf("%ld %ld", &l, &r);
    int k=r-l;
    if(r-l>2019){
        k=2019;
    }
    long int t=100000000, s;
    for(long int i=l; i<=l+k; i++){
        for(long int j=i+1; j<=l+k; j++){
            s=(i%2019)*(j%2019)%2019;
            // printf("%ld\n", s);
            if(t>s){
                t=s;
            }
            if(t==0){
                break;
            }
        
        if(t==0){
            break;
        }
        }
    }
    printf("%ld", t);
    return 0;


}

Measured memory_bytes: 128