akhauriyash/Code-Regression huggingface dataset:
#include<iostream>

using namespace std;

int main(void){
  int n, num, before, sum = 1;
  cin >> n >> before;
  char now = 'n';	//p(lus), m(inus), n(ull)
  
  for(int i = 1; i < n; i++){
    cin >> num;
    if(now == 'n'){
      if(before < num)
        now = 'p';
      else if(num < before)
        now = 'm';
    }
    else if(now == 'p'){
      if(num < before){
        sum++;
        now = 'n';
      }
    }
    else{	//m
      if(before < num){
        sum++;
        now = 'n';
      }
    }
    before = num;
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
a, b = map(int, input().split())
num = []
for i in range(1, 999+1):
    num.append(i)
    
diff = b-a
index = [i for i in range(len(num)) if num[i]==diff][0]
true_b = sum(num[:index+1])
true_a = sum(num[:index])
print(true_a- a)

Measured memory_bytes: 3064
n = int(input())
alist = list(map(int,input().split()))
binlist = [0]*60
mod_number = 10**9+7

def dec2bin(target):
    amari = []
    while target != 0:
        amari.append(target%2)
        target = target//2
    amari.reverse()
    return amari

for a in alist:
    a_bin = dec2bin(int(a))
    for i in range(len(a_bin)):
        if int(a_bin[-(i+1)])==1:
            binlist[-(i+1)] += 1
            #print(a,a_bin,i,binlist)
ans = 0
for i in range(60):
    ans = (ans + binlist[-(i+1)]*(n-binlist[-(i+1)])*pow(2,i))%mod_number
    
print(ans)

Measured memory_bytes: 125624
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
#include <list>
#include <utility>
#include <memory>
#include <cstring>
#include <fstream>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <ios> 
#include <bits/stdc++.h>
using namespace std;
long long l,r,low,hig;
int main(){
	cin>>l>>r;
	if (r-l<2019){
		long long p=l%2019;
		if (2019-p<=r-l){
			low=0;
			hig=2018;
		}else{
			low=p;
			hig=p+r-l;
		}
	}else{
		low=0;
		hig=2018;
	}
	long long ans=2018;
	for (long long i=low;i<=hig;i++) for (long long j=i+1;j<=hig;j++)
		ans=min(i*j%2019,ans);
	cout<<ans;
}

Measured memory_bytes: 256
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}
void readA(T)(size_t n,ref T[]t){t=new T[](n);auto r=rdsp;foreach(ref v;t)pick(r,v);}

void main()
{
  int n; readV(n);
  int[] a; readA(n, a);

  a.sort();
  writeln(a[$-1]-a[0]);
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, K; cin >> N >> K;
  int x = 1;
  FOR(i,0,N) {
    if(x + K <= 2 * x) x += K;
    else x *= 2;
  }
  cout << x << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>   // popen, pclose, fgets
#include <cstdlib> 
using namespace std;
#define rep0(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vvvi = vector<vvi>;
using ll = long long; //long longをllだけにした
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll =vector<vvll>;
const double PI=3.14159265358979323846;
//小数点以下を指定したい時　　→→→→  cout << fixed << setprecision();
//int→string
//string→int   int num = atoi(numStr.c_str());

int main() {
    int x,y;cin>>x>>y;
    string ans="No";
    if(y%2==0){
        if(4*x>=y&&y>=2*x){
            ans="Yes";
        }
    }
    cout<<ans<<endl;
}

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

f=[]
f.append(0)
f.append(abs(a[1]-a[0])) 
for i in range(2,n) :
    f.append(min(f[i-1]+abs(a[i]-a[i-1]),f[i-2]+abs(a[i]-a[i-2])))
print(f[-1])


Measured memory_bytes: 55112
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
## dp ##
def DD2(d1,d2,init=0): return [[init]*d2 for _ in range(d1)]
def DD3(d1,d2,d3,init=0): return [DD2(d2,d3,init) for _ in range(d1)]
## math ##
def to_bin(x: int) -> str: return format(x, 'b') # rev => int(res, 2)
def to_oct(x: int) -> str: return format(x, 'o') # rev => int(res, 8)
def to_hex(x: int) -> str: return format(x, 'x') # rev => int(res, 16)
MOD=10**9+7
def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def enumerate_divs(n):
    """Return a tuple list of divisor of n"""
    return [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]
def get_primes(MAX_NUM=10**3):
    """Return a list of prime numbers n or less"""
    is_prime = [True]*(MAX_NUM+1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, int(MAX_NUM**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i*2, MAX_NUM+1, i): is_prime[j] = False
    return [i for i in range(MAX_NUM+1) if is_prime[i]]
def prime_factor(n):
    """Return a list of prime factorization numbers of n"""
    res = []
    for i in range(2,int(n**0.5)+1):
        while n%i==0: res.append(i); n //= i
    if n != 1: res.append(n)
    return res
## libs ##
from itertools import accumulate as acc, combinations as combi, product, combinations_with_replacement as combi_dup
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left
#======================================================#

def main():
    n = II()
    print(int(n**(1/2))**2)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3444
#155_C
from collections import Counter
n = int(input())
s = [input() for _ in range(n)]
s = Counter(s).most_common()

x0 = s[0][1]
ans = []
for t, x in s:
    if x == x0:
        ans.append(t)
ans.sort()
print('\n'.join(ans))

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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if (a + b > c + d) {
    cout << "Left" << endl;
  } else if (a + b == c + d) {
    cout << "Balanced" << endl;
  } else {
    cout << "Right" << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;


int main(){
    ll n , k;
    cin>>n>>k;
    ll r,ss,p;
    cin>>r>>ss>>p;
    string s;
    cin>>s;
    ll res = 0;
    for(ll i=0;i<n;i++){
	if( i>=k && s[i] == s[i-k] ){
	    s[i] = '.';
	    continue;
	}
	if( s[i] == 'r' ){
	    res += p;
	}else if( s[i] == 's' ){
	    res += r;
	}else{
	    res += ss;
	}
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <bitset>
#include <climits>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define RFOR(i,a,b) for (int i=(a)-1;i>=(b);i--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int INF = 1e9;
const ll LL_INF = 1e18;
const int MOD = 1e9 + 7;

using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  int K;
  cin >> K;

  map<string, int> mp;
  REP(i,28){

    for(int j = 0; j < s.size(); j++){
      if(s[j] != 'a' + i) continue;
      string a;
      for(int k = j; k < min(j + 5, (int)s.size()); k++){
        a += s[k];
        mp[a] = 1;
      }
    }
    if(mp.size() >= 5) break;
  }
  int ct = 0;
  for(auto m : mp){
    if(++ct == K){
      cout << m.first << endl;
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 384
s = input()

if s=='SUN':
    print(7)
elif s=='MON':
    print(6)
elif s=='TUE':
    print(5)
elif s=='WED':
    print(4)
elif s=='THU':
    print(3)
elif s=='FRI':
    print(2)
else:
    print(1)

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

#define pb push_back
#define fi first
#define se second
typedef long long ll;

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

	int n, k;
	map<char, int> M;
	string s;
	
	cin >> n >> k;
	cin >> M['s'] >> M['p'] >> M['r'];
	cin >> s;

	int ans = 0;
	for (int i = 0; i < k; ++i) {
		int cnt = 0, last;
		for (int j = i; j < n; j += k) {
			if (j == i || s[j] != last) {
				cnt += M[s[j]];
				last = s[j];
			} else if (s[j] == last && j + k < n) {
				last = 'x';
			}
		}
		ans += cnt;
	}
	cout << ans << '\n';
}


Measured memory_bytes: 512
//https://atcoder.jp/contests/abc123/tasks/abc123_c
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;
int main()
{
    int S;
    cin >> S;

    int right = 0;
    int left = 0;

    right = S / 100;
    left = S % 100;

    if(1 <= right && right <= 12){
        if(1 <= left && left <= 12){
            cout << "AMBIGUOUS" << endl;
        }else{
            cout << "MMYY" << endl;
        }
    }else{
        if(1 <= left && left <= 12){
            cout << "YYMM" << endl;
        }else{
            cout << "NA" << endl;
        }
    }



}


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

int main(){
				int A,B;
				cin >> A >> B;
				char S[A + B + 1];
				for(int i = 0; i < A + B + 1; i++) cin >> S[i];
				for(int i = 0; i < A; i++) if(S[i] == '-'){
							 	cout << "No" << endl;
								return 0;
				}
				if(S[A] != '-'){
							 cout << "No" << endl;	
							 return 0;
				}
				for(int i = A + 1; i < A + B; i++) if(S[i] == '-'){
								cout << "No" << endl;
								return 0;
				}
				cout << "Yes" << endl;
				return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 30;
const int MOD = 1e9 + 7;

const int N = 1e5 + 10;
int a[N];

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
  }
  int maxa = a[n - 1];
  int best = 0, cnt = 0;
  for (int i = n - 2; i >= 0; --i) {
    if (maxa - a[i] > best) {
      best = maxa - a[i];
      cnt = 1;
    } else if (maxa - a[i] == best) {
      ++cnt;
    }
    maxa = max(maxa, a[i]);
  }
  printf("%d\n", cnt);
  return 0;
}


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

int main(){
	int n, i, d1, d4;
	cin >> n;
	int x[n], y;
	double d2, d3;
	d1 = 0;
	d2 = 0;
	d3 = 0;
	d4 = 0;
	for (i = 0; i < n; ++i){
		cin >> x[i];
	}
	for (i = 0; i < n; ++i){
		cin >> y;
		d1 += abs(x[i]-y);
		d2 += (x[i]-y)*(x[i]-y);
		d3 += abs((x[i]-y)*(x[i]-y)*(x[i]-y));
		d4 = max(d4,abs(x[i]-y));
	}
	d2 = sqrt(d2);
	d3 = cbrt(d3);
	printf("%d\n%.8lf\n%.8lf\n%d\n", d1, d2, d3, d4);
	return 0;
}


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

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		if(N == 2){
			if(K == 0){
				Console.WriteLine(1);
				Console.WriteLine("1 2");
			} else {
				Console.WriteLine(-1);
			}
			return;
		}
		if(K > (N - 1) * (N - 2) / 2){
			Console.WriteLine(-1);
			return;
		}
		
		bool[][] a = new bool[N][];
		for(int i=0;i<N;i++){
			a[i] = new bool[N];
		}
		
		for(int i=1;i<N;i++){
			a[0][i] = true;
		}
		int tot = (N - 1) * (N - 2) / 2;
		List<int> L = new List<int>();
		List<int> R = new List<int>();
		bool fin = false;
		for(int i=N-1;i>=1;i--){
			if(fin) break;
			for(int j=N-1;j>i;j--){
				if(fin) break;
				if(tot > K){
					tot--;
					a[i][j] = true;
					continue;
				}
				fin = true;
				break;
				
			}
		}
		for(int ii=0;ii<N;ii++){
			for(int jj=0;jj<N;jj++){
				if(a[ii][jj]){
					L.Add(ii + 1);
					R.Add(jj + 1);
				}
			}
		}
		
		Console.WriteLine(L.Count);
		for(int i=0;i<L.Count;i++){
			Console.WriteLine("{0} {1}",L[i], R[i]);
		}
		
		
	}
	int N,K;
	public Sol(){
		var d = ria();
		N = d[0]; K = d[1];
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 13268
import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

int calc2(char c, int k, string s) {
    int n = cast(int)s.length;
    int[] ss;
    int[] t;
    for (int i = 0; i < n; i++) {
        if (s[i] == c) {
            if (i == 0) t ~= 0;
            if (i == n - 1) t ~= 0;
            if (i > 0 && s[i-1] != c) t ~= 1;
            if (i+1 < n && s[i+1] != c) t ~= 1;

            if (t.length == 2) {
                ss ~= t.sum;
                t = [];
            }
        }
    }

    ss.sort();
    ss.reverse();
    return ss.take(k).sum;
}

int calc(int k, string s) {
    int n = cast(int)s.length;
    int x = 0;
    for (int i = 0; i < s.length; i++) {
        final switch (s[i]) {
        case 'L':
            if (i > 0 && s[i-1] == 'L') x++;
            break;
        case 'R':
            if (i+1 < n && s[i+1] == 'R') x++;
            break;
        }
    }
    return x + max(calc2('L', k, s.dup), calc2('R', k, s.dup));
}

void main() {
    int n, k; scan(n, k);
    string s = read!string;
    writeln(calc(k, s));
}


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

Measured memory_bytes: 128
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
int main(void){
    int n,ans = 0,mx = 0;
    string s;
    cin >> n >> s;
    for(int i = 0;i < n;i++){
        if(s[i] == 'I') ans++;
        else ans--;
        mx = max(mx,ans);
    }
    cout << mx << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.*;

public class Main{
	public static void main(String[] args){
		BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
		String s;
		double a;
		double ans;
		try{
			while((s=reader.readLine()) !=null){
				a=Double.parseDouble(s);
				ans=(1899*a)/243;
				System.out.println(ans);
			}
		}catch(IOException e){
			System.out.println(e);
		}
	}
}

Measured memory_bytes: 17020
//thanks God For Every Thing!
//contest link:
#include<bits/stdc++.h>
#include<stdio.h>
#include<math.h>
#define pi                      acose(-1)
#define rep(i,x)                for(int i=0; i<(x); i++)
#define rep1(i,x)               for(int i=1; i<=(x); i++)

typedef long long int           ll;
typedef double                  dl;
using namespace std;
//const int MX= 2e3+5;
//int arr[MX];

//void bobule_sort(int list[MX]);

int main()
{
    int t;
    char ch[4];
    int ac=0, tl=0, re=0, wa=0;
    cin>>t;
    while(t--){
        scanf("%s", ch);
        if(strcmp(ch,"AC")==0) ac++;
        else if(strcmp(ch,"WA")==0) wa++;
        else if(strcmp(ch,"TLE")==0) tl++;
        else if(strcmp(ch,"RE")==0) re++;
    }
    printf("AC x %d\n", ac);
    printf("WA x %d\n", wa);
    printf("TLE x %d\n", tl);
    printf("RE x %d\n", re);

    return 0;
}
/*void bobule_sort(int list[MX])
{
    int i, j, temp, cnt=0;
    for(i=0; i<n; i++)
    {
        for(j=0; j<n-i-1; j++)
        {
            if(list[j]>list[j+1])
            {
                temp      = list[j];
                list[j]   = list[j+1];
                list[j+1] = temp;
            }
        }
    }
}*/



Measured memory_bytes: 3832
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<deque>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<int, int>pii;
typedef pair<int, pii>pi3;
ll mod = 1000000007;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };
int x[100000], y[100000];
int ans[100000];
int main()
{
	int mx, my, d;
	scanf("%d%d%d", &mx, &my, &d);
	for (int i = 0; i < mx; i++)
	{
		for (int j = 0; j < my; j++)
		{
			int z;
			scanf("%d", &z);
			x[z] = i, y[z] = j;
		}
	}
	for (int i = 1; i <= d; i++)
	{
		int nx = 0, ny = 0, sum = 0;
		for (int j = i; j <= mx*my; j += d)
		{
			sum += abs(nx - x[j]) + abs(ny - y[j]);
			ans[j] = sum;
			nx = x[j], ny = y[j];
		}
	}
	int query;
	scanf("%d", &query);
	for (int i = 0; i < query; i++)
	{
		int za, zb;
		scanf("%d%d", &za, &zb);
		printf("%d\n", ans[zb] - ans[za]);
	}
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define drep(i,cc,n) for(int i=(cc);i<=(n);++i)
#define rep(i,n) drep(i,0,(n)-1)
#define drrep(i,cc,n) for(int i=(cc);i>=(n);--i)
#define rrep(i,n) drrep(i,0,(n)-1)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,v.size())if(i==0)cout << v[i];else cout << " " << v[i]; cout << endl;
#define arrprint(v,n) rep(i,n)if(i==0)cout << v[i];else cout << " " << v[i]; cout << endl;
#define matprint(v,n,m) rep(i,n){rep(j,m){cout << v[i][j] << " ";}cout << endl;}
#define SORT(v) sort(v.begin(), v.end())
#define REV(v) reverse(v.begin(), v.end())
using namespace std;
const int mod=1000000007;
const int INF=1001001001;
using ll = long long;
using P = pair<int,int>;
template<typename T>
using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>; //小さいものから取り出す

int main(){
    int x;
    cin >> x;
    int ans;
    if(x<600)ans = 8;
    else if(x<800)ans = 7;
    else if(x<1000)ans = 6;
    else if(x<1200)ans = 5;
    else if(x<1400)ans = 4;
    else if(x<1600)ans = 3;
    else if(x<1800)ans = 2;
    else if(x<2000)ans = 1;

    cout << ans << endl;
//  printf("%.10f\n",ans);

    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <cstring>
using namespace std;

const int MAXN = 10001;
const int weight[10] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
struct Stat {
	short int cnt[10];
	int len;
	void push(int key) {
		cnt[key]++;
		len++;
	}
	Stat (int num=0){
		memset(cnt, 0, sizeof(cnt));
		len = 0;
		if (num)
			push(num);
	}
	Stat& operator=(const Stat &rhs) {
		len = rhs.len;
		memcpy(cnt, rhs.cnt, sizeof(cnt));
		return *this;
	}
	bool operator<(const Stat &rhs) const {

		if (len == rhs.len) {
			int pleft = 9, pright = 9;
			do {
				while(pleft && !cnt[pleft])
					pleft--;
				while(pright && !rhs.cnt[pright])
					pright--;
				if (pleft == pright) {
					if (cnt[pleft] != rhs.cnt[pright])
						return cnt[pleft] < rhs.cnt[pright];
				}else
					return pleft < pright;
			}while (pleft-- && pright--);
		}
		return len < rhs.len;
	}
}dp[MAXN];

int main() {
	int n, m;
	cin>>n>>m;
	for (int i=0; i<m; i++) {
		int num;
		cin>>num;
		Stat init(num);
		if (dp[weight[num]] < init)
			dp[weight[num]] = init;
		for (int i=1; i+weight[num]<=n; i++)
			if (dp[i].len) {
				Stat nextstat = dp[i];
				nextstat.push(num);
				if (dp[i+weight[num]] < nextstat)
					dp[i+weight[num]] = nextstat;
			}
	}
	// cout<<"Finish dp[n].len "<<dp[n].len<<endl;
	string ans="";
	for (int i=9; i>0; i--)
		while(dp[n].cnt[i]--)
			ans += to_string(i);
	cout<<ans<<endl;
	return 0;
}


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

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

			String in = br.readLine();
			String chr[] = in.split(" ");
			int a = Integer.parseInt(chr[0]);
			int b = Integer.parseInt(chr[1]);
			int c = Integer.parseInt(chr[2]);
			int ans = (a-b);
			 System.out.println(ans>=c?0:c-ans);
		}
	}
}

Measured memory_bytes: 25408
import java.util.*;
 
public class Main {
	public static void main (String[] args) {
		Scanner in = new Scanner(System.in);
		
		int A = in.nextInt();
		int B = in.nextInt();
		
		if(A > B){
		    System.out.println("safe");
		}else{
		    System.out.println("unsafe");
		}

	}
}

Measured memory_bytes: 35828
# https://atcoder.jp/contests/dp/tasks/dp_a

n = int(input())
h = list(map(int, input().split()))

dp = [0 for i in range(n)]
dp[0] = 0
dp[1] = abs(h[1] - h[0])

for i in range(2, n):
    dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2])) 

print(dp[-1])



Measured memory_bytes: 52856
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0;i < n;i++)
#define REP(i,n,k) for(int i = n;i < k;i++)
#define P(p) cout << (p) << endl;
#define sP(p) cout << setprecision(15) << fixed << p << endl;
#define vi vector<int>
#define printv(v) for(int i = 0;i < v.size();i++)P(v[i]);
#define printt(a,b) cout << a << " " << b << endl; 
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int dx[] = { 1, -1 , 0 , 0};
int dy[] = { 0,  0,  1, -1};
int MOD = 1e9 + 7;

void solve() {
    int a,b;
    cin >> a >> b;
    if(a >= 13){
        P(b);
    }else if(a >= 6 && a <= 12 ){
        P(b/2);
    }else{
        P(0);
    }
}

int main() {
    solve();
    return 0;
}


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

int main() {
    string s, t;
    cin >> s >> t;
    int n = s.length(), m = t.length();

    sort(s.begin(), s.end());
    sort(t.begin(), t.end(), greater<char>());

    string ans;
    if (n < m) {
        for (int i = 0; i < n; i++) {
            if (s[i] < t[i]) {
                ans = "Yes";
                break;
            }
            else if (s[i] == t[i]) {
                ans = "Yes";
                continue;
            }
            else {
                ans = "No";
                break;
            } 
        }
    }
    else { // n >= m
        int i = 0;
        while(s[i] == t[i] && i < m) {
            i++;
        }
        if (i >= m || s[i] > t[i]) ans = "No";
        else ans = "Yes";
    }
    cout << ans << endl;
}

Measured memory_bytes: 3604
try:
    from math import gcd
except:
    from fractions import gcd
import operator
from collections import deque


class Segtree:
    """
    st = Segtree(4, f=operator.add, e=0)
    st[1:] = [4, 9, 16]
    st[0] = -99
    assert st[-1] == 16
    assert st[:] == [-99, 4, 9, 16]
    assert st.grasp(1, 3) == 13
    """

    def __init__(self, n, f=operator.add, e=0):
        """all(f(v, e) == f(e, v) == v for v in data)"""
        self.r = range(n)
        self.size = 2 ** ((n - 1).bit_length())
        self.tree = [e] * (2 * self.size)
        self.f = f
        self.iden = e

    def __len__(self):
        return len(self.r)

    def __list__(self):
        return self.tree[self.size-1:self.size-1+len(self.r)]

    def __repr__(self):
        return repr(list(self))

    def grasp(self, i=0, j=None):
        """reduce(f, data[i:j], e)"""
        if j is None:
            j = len(self)
        i = self.size - 1 + max(i, 0)
        j = self.size - 1 + min(j, len(self))
        ans = self.iden
        while j - i > 0:
            if i & 1 is 0:
                ans = self.f(self.tree[i], ans)
            if j & 1 is 0:
                ans = self.f(ans, self.tree[j-1])
            i = i >> 1
            j = (j - 1) >> 1
        return ans

    def __getitem__(self, i):
        r = self.r[i]
        if isinstance(r, int):
            return self.tree[self.size - 1 + r]
        else:
            return [self.tree[self.size - 1 + ri] for ri in r]

    def __setitem__(self, i, v):
        """Extra elements will be ignored when i is a slice."""
        r = self.r[i]
        if isinstance(r, int):
            r = [r]
            v = [v]
        q = deque()
        s = set()

        def addnext(j):
            k = (j - 1) // 2
            if k >= 0 and k not in s:
                q.append(k)
                s.add(k)

        for ri, vi in zip(r, v):
            j = self.size - 1 + ri
            self.tree[j] = vi
            addnext(j)
        while len(q):
            j = q.popleft()
            # s.remove(j)
            vl = self.tree[2 * j + 1]
            vr = self.tree[2 * j + 2]
            self.tree[j] = self.f(vl, vr)
            addnext(j)


N = int(input())
A = [int(s) for s in input().split()]
st = Segtree(N, f=gcd, e=0)
st[:] = A
ans = max([gcd(st.grasp(0, i), st.grasp(i+1)) for i in range(N)])
print(ans)


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

class Program
{
	static void Main(string[] args)
	{
        var N = int.Parse(Console.ReadLine());

        //[誰が,誰に] = 何を
        int[,] x = new int[N,N];

        //一度すべて-1で埋める
        for (int i = 0; i < N; i++)
        {
            for (int j = 0; j < N; j++)
            {
                x[i,j] = -1;
            }
        }

        //各人の発言内容を格納
        bool skip = true;
        for (int i = 0; i < N; i++)
        {
            var A = int.Parse(Console.ReadLine());
            for (int j = 0; j < A; j++)
            {
                string[] input = (Console.ReadLine().Split(' '));
                x[i,int.Parse(input[0])-1] = int.Parse(input[1]);
            }
        }

        // bit全探索でN人の状態を探索する
        var ans = 0;
        for (int i = 0; i < Math.Pow(2, N); i++)
        {
            // N人の状態をbool[]にする
            var katei = new bool[N];
            for (int j = 0; j < N; j++)
            {
                var a = (i >> j) & 1;
                if (a == 1) katei[j] = true;
            }
            var ok = true;
            for (int j = 0; j < N; j++)
            {
                if (katei[j])
                {
                    for (int k = 0; k < N; k++)
                    {

                        if (x[j,k] != -1)
                        {
                            var a = k;
                            var b = Convert.ToBoolean(x[j,k]);
                            if (katei[a] != b)
                            {
                                ok = false;
                            }
                        }
                        
                    }
                }
            }
            if (ok)
            {
                ans = Math.Max(ans, katei.Count(f => f));
            }
        }

        //出力
        Console.WriteLine(ans);
        
	}
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int N;
  cin>>N;
     vector<int> p(N);
   for (int i = 0; i < N; i++) {
    cin >> p.at(i);
  }
  int count;
for (int i = 0; i < N; i++) {
 if(p[i] != i+1){count++;}
}
  if(count==2||count==0){
    cout << "YES"<<endl;
  }
  else{cout << "NO"<<endl;}
 
 
 
 
}

Measured memory_bytes: 256
//Code by Anshuman Das Gupta

#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define MOD 1000000007
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define loop(I,N) for(int i=I;i<N;i++)
#define sortvec(V) sort(V.begin(),V.end())
#define vec vector<int>
#define endl "\n"
using namespace std;
int fast_power(int base, int power) {
    int result = 1;
    while (power > 0) {

        if (power & 1) {
            result = (result * base) % MOD;
        }
        base = (base * base) % MOD;
        power = power >> 1;
    }
    return result % MOD;
}

bool isPrime(int x) {
    for (int i = 2; i <= sqrt(x); i++) {
        if (x % i == 0)
            return false;
    }
    if (x == 1)
        return false;
    return true;
}

int binsearch(int a[], int f, int r, int x) {
    while (f <= r) {
        int mid = (f + r) / 2;
        if (a[mid] == x)
            return mid;
        else if (a[mid] > x) {
            r = mid - 1;
        }
        else {
            f = mid + 1;
        }
    }
    return -1;
}
void sieve(int a[], int n) {
    a[0] = 0;
    a[1] = 0;
    for (int i = 2; i <= n; i++) {
        if (a[i] == 1) {
            for (int j = i + i; j <= n; j += i) {
                a[j] = 0;
            }
        }
    }
}
int32_t main() {
#ifndef ONLINE_JUDGE
    //for getting input from input.txt
    freopen("input.txt", "r", stdin);
    //for writing output to output.txt
    freopen("out.txt", "w", stdout);
#endif
    int t = 1;
    //cin >> t;
    while (t--) {
        int n, k;
        cin >> n >> k;
        vector<vector<int> > v(n + 1);
        int h[n + 1];
        loop(1, n + 1) {
            cin >> h[i];
        }
        loop(0, k) {
            int x, y;
            cin >> x >> y;
            v[x].pb(y);
            v[y].pb(x);
        }
        int ans = 0;
        loop(1, n + 1) {
            int ma = INT_MIN;
            for (auto it : v[i]) {
                ma = max(ma, h[it]);
            }
            if (h[i] > ma) {
                ans++;
            }
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 9868
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef long long ll;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
int main(){
    fastio
    int n ; 
    cin >> n ; 
    vector<int> v(n) ; 
    for(int i = 0; i < n; i++){
        int x ; 
        cin >> x ; 
        x--;
        v[x] = i + 1 ;
    }
    for(int &c : v){
        cout << c << ' ' ; 
    }
    cout << endl;
    return 0 ;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
using namespace std;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    string s, t;
    cin >> N >> s >> t;
    int idx = -1;
    for(int i=N;i>=0;i--){
        if(s.substr(N-i,i) == t.substr(0,i)){
            cout << 2 * N - i << endl;
            return 0;
        }
    }
    cout << 2 * N << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

using ll = long long;
using ld = long double;

#define for_(i,a,b) for(int i = (a);i < (b);i++)
#define rfor_(i,a,b) for(int i = (b)-1;i >= (a);i--)
#define rep(i,n) for_(i,0,(n))
#define rrep(i,n) rfor_(i,0,(n))

int n;

ld s[1001];

ld m, sg;

int main(){
	cin.tie(0);
	
	while(cin>>n,n) {
	    rep(i, n)cin>>s[i];
	    
	    m = 0;
    	rep(i, n)m += s[i];
	    m /= n;
	    
	    sg = 0;
    	rep(i, n)sg += s[i]*s[i];
	    sg /= n;
	
    	sg -= m*m;
	
	    cout<<sqrt(sg)<<endl;
	}
	
	return 0;
}



Measured memory_bytes: 3300
from collections import deque


class MaxFlow:
    class Edge:
        def __init__(self, to, cap, rev):
            self.to, self.cap, self.rev = to, cap, rev

    def __init__(self, node_size, inf):
        self._node = node_size
        self._inf = inf
        self._level = [-1] * self._node
        self._iter = [0] * self._node
        self._graph = [[] for _ in range(self._node)]

    def add_edge(self, from_, to, cap):
        self._graph[from_].append(self.Edge(to, cap, len(self._graph[to])))
        self._graph[to].append(self.Edge(from_, 0, len(self._graph[from_]) - 1))

    def bfs(self, start):
        self._level = [-1] * self._node
        que = deque()
        self._level[start] = 0
        que.append(start)
        while que:
            cur_vertex = que.popleft()
            for e in self._graph[cur_vertex]:
                if self._level[e.to] < 0 < e.cap:
                    self._level[e.to] = self._level[cur_vertex] + 1
                    que.append(e.to)

    def dfs(self, cur_vertex, end_vertex, flow):
        if cur_vertex == end_vertex:
            return flow
        while self._iter[cur_vertex] < len(self._graph[cur_vertex]):
            e = self._graph[cur_vertex][self._iter[cur_vertex]]
            if e.cap > 0 and self._level[cur_vertex] < self._level[e.to]:
                flowed = self.dfs(e.to, end_vertex, min(flow, e.cap))
                if flowed > 0:
                    e.cap -= flowed
                    self._graph[e.to][e.rev].cap += flowed
                    return flowed
            self._iter[cur_vertex] += 1
        return 0

    def solve(self, source, sink):
        flow = 0
        while True:
            self.bfs(source)
            if self._level[sink] < 0:
                return flow
            self._iter = [0] * self._node
            while True:
                f = self.dfs(source, sink, self._inf)
                if f == 0:
                    break
                flow += f


class BipartiteMatching:
    def __init__(self, size1, size2):
        self._u_size, self._v_size = size1, size2
        self.mf = MaxFlow(self._u_size + self._v_size + 2, min(self._u_size, self._v_size))
        for i in range(self._u_size):
            self.mf.add_edge(0, i + 1, 1)
        for i in range(self._v_size):
            self.mf.add_edge(self._u_size + i + 1, self._u_size + self._v_size + 1, 1)

    def add_edge(self, from_, to):
        self.mf.add_edge(from_ + 1, to + self._u_size + 1, 1)

    def solve(self):
        return self.mf.solve(0, self._u_size + self._v_size + 1)

#####################################################################################

N = int(input())

X = []
Y = []
for i in range(N):
    X.append([int(i) for i in input().split()])

for i in range(N):
    Y.append([int(i) for i in input().split()])

dinic = BipartiteMatching(len(X), len(Y))

for i in range(len(X)):
    for j in range(N):
        if X[i][0] < Y[j][0] and X[i][1] < Y[j][1]:
            dinic.add_edge(i,j)


print(dinic.solve())

Measured memory_bytes: 74912
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

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

    while(--n >= 0){
        string order, s;
        cin >> order >> s;

        int m = s.size();
        for(int i=order.size()-1; i>=0; --i){
            if(order[i] == 'J'){
                rotate(s.begin(), s.end()-1, s.end());
            }else if(order[i] == 'C'){
                rotate(s.begin(), s.begin()+1, s.end());
            }else if(order[i] == 'E'){
                string s1, s2, s3;
                s1 = s.substr(0, m/2);
                s3 = s.substr((m+1)/2);
                if(m % 2 == 1)
                    s2 = s[m/2];
                s = s3 + s2 + s1;
            }else if(order[i] == 'A'){
                reverse(s.begin(), s.end());
            }else if(order[i] == 'P'){
                for(int j=0; j<m; ++j){
                    if('1' <= s[j] && s[j] <= '9')
                        -- s[j];
                    else if(s[j] == '0')
                        s[j] = '9';
                }
            }else{
                for(int j=0; j<m; ++j){
                    if('0' <= s[j] && s[j] <= '8')
                        ++ s[j];
                    else if(s[j] == '9')
                        s[j] = '0';
                }
            }
        }

        cout << s << endl;
    }

    return 0;
}

Measured memory_bytes: 0
a, b, ab, x, y = (int(x) for x in input().split())
if x>y:
    tmp = x
    x = y
    y = tmp
    tmp = a
    a = b
    b = tmp

if a+b < 2*ab:
    print(a*x+b*y)
elif b < 2*ab:
    print(b*(y-x)+ab*2*x)
else:
    print(2*ab*y)



Measured memory_bytes: 3060
// head{{{
/* vim: set foldmethod=marker ft=cpp: */
#include <iostream>
#include <list>
#pragma GCC optimize("O3")
using namespace std;
// }}}
 
int main() {
    //optimize{{{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    //---------}}}

    // f(X) = X1stdigit + X2nddigit +...(all digits) = Xsum
    // if X % Xsum == 0 -> harshad number-> cout Yes otherwise no??

    int N=0; // init
    cin >> N; // only input N 
    int Nsum=0;
    int Nextract=N;
    while (Nextract>0) {
        int Ntmp = Nextract%10;
        Nextract/=10;
        Nsum+=Ntmp;
    }
    if (N % Nsum == 0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

}



Measured memory_bytes: 3636
#include<iostream>
#include<cstring>
#include<vector>
using namespace std;
const int maxn = 1e5 + 10;
int w[maxn];
int v[maxn];
long long dp[maxn];
int main(){
	int n, m;
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n;i++)
		scanf("%d%d", &w[i], &v[i]);
	for (int i = 1; i <= n;i++){
		for (int j = m; j >= w[i];j--){
			dp[j] = max(dp[j], dp[j - w[i]] + v[i]);
		}
	}
	printf("%lld", dp[m]);
	return 0;
}


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

a = [s]*n

ans = ""

for i in range(n-k):
    if s == 1:
        a[i] = 2
    elif s == 1000000000:
        a[i] = 1000000000-1
    else:
        a[i] = s+1

for i in range(n):
    ans += " " + str(a[i])

print(ans)

Measured memory_bytes: 9876
import java.util.*;
import java.io.*;
import java.text.*;
//Solution Credits: Taranpreet Singh
public class Main{
    //SOLUTION BEGIN
    void pre() throws Exception{}
    void solve(int TC) throws Exception{
        int n = ni(), W = ni(), mx = (int)1e5;
        long[] dp = new long[1+mx];
        Arrays.fill(dp, IINF);
        dp[0] = 0;
        for(int i = 0; i< n; i++){
            int w = ni(), v = ni();
            for(int j = mx-v; j>= 0; j--)dp[j+v] = Math.min(dp[j+v], dp[j]+w);
        }
        long ans = 0;
        for(int i = 0; i<= mx; i++)if(dp[i]<=W)ans = i;
        pn(ans);
    }
    //SOLUTION END
    void hold()throws Exception{throw new Exception("Hold right there, Sparky!");}
    long mod = (long)1e9+7, IINF = (long)4e18;
    final int INF = (int)2e9, MX = (int)1e6+1;
    DecimalFormat df = new DecimalFormat("0.000000000000000");
    double PI = 3.1415926535897932384626433832792884197169399375105820974944, eps = 1e-8;
    static boolean multipleTC = false, memory = false;
    FastReader in;PrintWriter out;
    void run() throws Exception{
        in = new FastReader();
        out = new PrintWriter(System.out);
        int T = (multipleTC)?ni():1;
        //Solution Credits: Taranpreet Singh
        pre();for(int i = 1; i<= T; i++)solve(i);
        out.flush();
        out.close();
    }
    public static void main(String[] args) throws Exception{
        if(memory)new Thread(null, new Runnable() {public void run(){try{new Main().run();}catch(Exception e){e.printStackTrace();}}}, "1", 1 << 28).start();
        else new Main().run();
    }
    long gcd(long a, long b){return (b==0)?a:gcd(b,a%b);}
    int gcd(int a, int b){return (b==0)?a:gcd(b,a%b);}
    int bit(long n){return (n==0)?0:(1+bit(n&(n-1)));}
    void p(Object o){out.print(o);}
    void pn(Object o){out.println(o);}
    void pni(Object o){out.println(o);out.flush();}
    String n(){return in.next();}
    String nln(){return in.nextLine();}
    int ni(){return Integer.parseInt(in.next());}
    long nl(){return Long.parseLong(in.next());}
    double nd(){return Double.parseDouble(in.next());}

    class FastReader{
        BufferedReader br;
        StringTokenizer st;
        public FastReader(){
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public FastReader(String s) throws Exception{
            br = new BufferedReader(new FileReader(s));
        }

        String next(){
            while (st == null || !st.hasMoreElements()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (IOException  e){
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        String nextLine(){
            String str = "";
            try{   
                str = br.readLine();
            }catch (IOException e){
                e.printStackTrace();
            }  
            return str;
        }
    }
}    

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

using namespace std;
int main() {
    string pickles, ickles;
    int count = 0;
    cin >> pickles;
    transform(pickles.begin(), pickles.end(), pickles.begin(), ::tolower);
    while(cin >> ickles) {
        if (ickles == "END_OF_TEXT") {
            break;
        }
        transform(ickles.begin(), ickles.end(), ickles.begin(), ::tolower);
        if (ickles == pickles) {
            count++;
        }
    }
    cout<< count << endl;
    return 0;
}


Measured memory_bytes: 3176
//
//AtCoder Beginner Contest 171
//E - Red Scarf
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <functional>
#include <cassert>

using namespace std;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) (int)(x).size()
#define SIZEL(x) (ll)(x).size()
#define MSG(a) cout << #a << " " << a << endl;

using ll = long long;
using ld = long double;

const double PI = 3.14159265358979323846;

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }            //最小公倍数

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

    vector<int> a(n);
    REP(i, n) cin >> a[i];

    int sum=0;
    REP(i, n) sum^=a[i];
    REP(i, n) a[i]^=sum;
    REP(i, n) cout << a[i] << " ";
    cout << endl;

    return 0;
}


Measured memory_bytes: 4048
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

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

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

    // input
    ll N;
    cin >> N;

    vector<ll> T(N+1);
    int t_sum = 0;
    FOR(i, 1, N+1){
        int t;
        cin >> t;

        T[i] = t;
        t_sum += t;
    }

    ll M;
    cin >> M;

    FOR(i, 0, M){
        int p, x;
        cin >> p >> x;

        p(t_sum - T[p] + x);
    }
    
    return 0;
}

Measured memory_bytes: 256
N,C = map(int,input().split())
Color = []
for _ in range(C):
    Color.append(list(map(int,input().split()))) 
Data = []
for _ in range(N):
    Data.append(list(map(int,input().split()))) 

Data2 = [{},{},{}]

for h in range(N):
    for w in range(N):
        c = Data[h][w]
        m = (h + w) % 3
        if not c in Data2[m]:
            Data2[m][c] = 0 
        Data2[m][c]+=1

ans = 10**20
for c1 in range(C):
    for c2 in range(C):
        if c1 == c2:
            continue
        for c3 in range(C):
            if c1 == c3 or c2 == c3:
                continue

            tmp = 0
            for k,v in Data2[0].items():
                tmp += (Color[k-1][c1-1]*v)
            for k,v in Data2[1].items():
                tmp += (Color[k-1][c2-1]*v)
            for k,v in Data2[2].items():
                tmp += (Color[k-1][c3-1]*v)
            ans = min(ans,tmp)

print(ans)


Measured memory_bytes: 5620
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

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

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

    // input
    string s;
    cin >> s;

    map<char, int> mp;
    FOR(i, 0, 26){
        char c = 'a' + i;
        mp[c] = -100;
    }

    FOR(i, 0, s.size()){
        char c = s[i];
        int index_diff = i - mp[c];
        if(index_diff <= 2){
            // 見つけた
            p2(mp[c]+1, i+1);
            return 0;
        }
        else{
            mp[c] = i;
        }
    }

    p2(-1, -1);

    return 0;
}

Measured memory_bytes: 512