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

int N;
int A[20];
int x[20][20];
int y[20][20];

int counter(int x) {
    if(x == 0) return 0;
    return counter(x >> 1) + (x & 1);
}

void solve() {
    cin >> N;
    for(int i = 1; i <= N; i++) {
        cin >> A[i];
        for(int j = 1; j <= A[i]; j++) {
            cin >> x[i][j] >> y[i][j];
        }
    }
    int ans = 0;
    for(int bits = 1; bits < (1 << N); bits++) {
        bool ok = true;
        for(int i = 1; i <= N; i++) {
            if(!( ( bits >> (i-1)) & 1)) continue;
            for(int j = 1; j <= A[i]; j++) {
                if(((bits >> (x[i][j]-1)) & 1) ^ y[i][j]) ok = false;
            }
        }
        if(ok) ans = max(ans, counter(bits));
    }
    cout << ans << endl;
    return;
}

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


Measured memory_bytes: 3576
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Scanner;

public class Main {

    void run() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] ar = new int[n + 10];
        for (int i = 0; i < n; i++) {
            ar[i] = sc.nextInt();
        }

        int[] ans = new int[n + 10];
        Arrays.fill(ans, -(1 << 30));
        ans[0] = ar[0];
        int len = 1;
        for (int i = 1; i < n; i++) {
            if (ans[len - 1] >= ar[i]) {
                ans[len] = ar[i];
                len++;
            } else {
                int idx = upperBound(ans, ar[i]);
                debug(i, idx);
                ans[idx] = ar[i];
            }
        }
        debug(ans);
        System.out.println(len);
    }

    public int upperBound(int[] array, int value) {
        int left = -1;
        int right = array.length;
        while (right - left > 1) {
            int middle = (right + left) / 2;
            if (array[middle] < value) {
                right = middle;
            } else {
                left = middle;
            }
        }
        return right;
    }


    void debug(Object...os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}


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

int main(){
	int N;
	cin >> N;
	int a[N+1];
	rep(i,N) cin >> a[i];
	a[N] = -1;
	sort(a,a+N);
	int now = 0;
	int cnt = 0;
	int ans = 0;
	rep(i,N+1) {
		if (now == a[i] ) cnt++;
		else {
			if (cnt >= now) ans += cnt - now;
			else ans += cnt;
			now = a[i];
			cnt = 1;
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 4032
from collections import Counter
from collections import defaultdict

S = list(map(str, input().rstrip()))

s = Counter(S)
d = defaultdict(int)

for i in ["a", "b", "c"]:
    d[i] = 0

for l, n in s.items():
    d[l] += n

d = list(d.values())

print("YES" if max(d) - min(d) <= 1 else "NO")

Measured memory_bytes: 4340
#include <bits//stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(obj) begin(obj), end(obj)
typedef long long int ll;
int main(void) {
    string s, t; cin >> s >> t; ll ans = 0,now = -1;
    vector<vector<int>> al(26);
    int n = s.size();
    rep(i, s.size()*2) al[s[i%n] - 'a'].push_back(i);
    rep(i, t.size()) {
        if (al[t[i] - 'a'].size() == 0) {
            cout << -1 << endl;
            return 0;
        }int ti = t[i] - 'a';
        auto it = upper_bound(ALL(al[ti]), now);// nowより大きい値
        ans += *it - now; now = *it % n;
    }cout << ans << endl;
}

Measured memory_bytes: 4628
from collections import Counter

n = int(input())
a = list(map(int,input().split()))
q = int(input())

count = Counter(a)
ans = sum(a)
for i in range(q):
    b,c = map(int,input().split())
    ans += count[b]*(c-b)
    print(ans)
    count[c] += count[b]
    count[b] = 0


Measured memory_bytes: 93864
#include <iostream>

using namespace std;

bool flag[50001];
int prime[50001];

int main()
{
  int n = 0;
  int i, j;

  flag[0] = flag[1] = true;
  for (i = 2; i * i <= 50000; i++){
    if(flag[i] != true){
      for(j = i * i; j <= 50000; j += i){
        flag[j] = true;
      }
    }
  }

  j = 0;
  
  for (i = 0; i <= 50000; i++){
    if (!flag[i]){
      prime[j++] = i;
    }
  }
  
  while(cin >> n, n){
    int cnt = 0;
    for(i = 0; prime[i] <= n / 2; i++){
      if (flag[n - prime[i]] == false){
        cnt++;
      }
    }
    cout << cnt << endl;
  }

  return (0);
}

Measured memory_bytes: 1232
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
//CONST
//------------------------------------------
#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
//-----------------------------------------
#define dcml(n) fixed<<setprecision(n)
using namespace std;
int main(void){
    ll A,P;cin>>A>>P;
    ll ans=(A*3+P)/2;
    cout<<ans<<"\n";
}

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

class Cube{
public:
	int f[6];
	Cube(){}
	void roll_z(){ roll(1,2,4,3);}
	void roll_y(){ roll(0,2,5,3);}
	void roll_x(){ roll(0,1,5,4);}
	void roll(int i,int j,int k,int l){
		int t = f[i]; f[i]= f[j]; f[j]=f[k]; f[k]=f[l]; f[l] = t; 
	}
};

bool eq( Cube c1, Cube c2){
	for(int i = 0; i < 6; i++)
		if(c1.f[i] != c2.f[i] )return false;
	return true;
}

bool equal( Cube c1, Cube c2){
	for(int i = 0; i < 6; i++){
		for(int j = 0; j < 4; j++){
			if( eq(c1, c2) ) return true;
			c1.roll_z();
		}
		if( i % 2 == 0)c1.roll_y();
		else c1.roll_x();
	}
	return false;
}

Cube C[100]; int n;

bool check(){
	for( int i = 0; i < n-1; i++)
		for(int j = i+1; j < n; j++)if(equal(C[i],C[j])) return false;
			return true;
}
int main(){
	cin >> n;
		for( int j = 0; j < n ; j++)
			for( int i = 0; i < 6; i++)cin >> C[j].f[i];

		if(check())cout << "Yes" << endl;
		else cout << "No" << endl;

		return 0;
}

Measured memory_bytes: 3096
//============================================================================
// Problem     : AOJ0203
// Title       : A New Plan of Aizu Ski Resort (会津山スキー場の新企画)
// Author      : mizo0203
// Status      : Accepted
// Date        : Wed May 30 15:25:20
// Copyright   : Your copyright free
// Description : 動的計画法
//============================================================================

#include <stdio.h>
#include <algorithm>

using namespace std;

int x, y;
int c[17][17];  // 最大15+2

int dp[17][17]; // 動的計画法の計算用

bool input() {
  int i, j;
  scanf("%d %d", &x, &y);
  if (!x && !y) return false; // x = 0 かつ y = 0 なら終了
  fill(c[0], c[0] + 17 * 17, 1); // 配列cを1(木)で初期化
  for (i = 1; i <= y; i++) {
    for (j = 1; j <= x; j++) {
      scanf("%d", &c[i][j]);
    }
  }

  return true;
}

void manage() {
  int i, j, output = 0;

  fill(dp[0], dp[0] + 17 * 17, 0); // 計算用配列を初期化
  for (i = 1; i <= x; i++) {
    if (c[1][i] != 1) dp[1][i] = 1;
  }

  for (i = 1; i < y; i++) {
    for (j = 1; j <= x; j++) {
      if (dp[i][j]) {
        if (c[i][j] == 0) {
          if (c[i + 1][j - 1] == 0) dp[i + 1][j - 1] += dp[i][j];
          if (c[i + 1][j    ] == 0) dp[i + 1][j    ] += dp[i][j];
          if (c[i + 1][j + 1] == 0) dp[i + 1][j + 1] += dp[i][j];
          if (c[i + 1][j    ] == 2) dp[i + 1][j    ] += dp[i][j];
        } else if (c[i][j] == 2) {
          if (c[i + 2][j] == 0) dp[i + 2][j] += dp[i][j];
          if (c[i + 2][j] == 2) dp[i + 2][j] += dp[i][j];
        }
      }
    }
  }
  /*
  printf("\n");
  for (i = 0; i < 17; i++) {
    for (j = 0; j < 17; j++) {
      printf("%d ", dp[i][j]);
    }
    printf("\n");
  }
  printf("\n");
  */
  for (i = 1; i <= x; i++) {
    if (c[y - 1][i] == 2) output += dp[y - 1][i];
    output += dp[y][i];
  }
  printf("%d\n", output);
}


int main() {

  while(input()) {
    manage();
  }

  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int H, W, N;
    cin >> H >> W >> N;
    int d = max(H, W);
    cout << (N + d - 1) / d << endl;
}

Measured memory_bytes: 256
fn read<T: std::str::FromStr>() -> T {
  let mut s = String::new();
  std::io::stdin().read_line(&mut s).ok();
  s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
  read::<String>().split_whitespace()
    .map(|e| e.parse().ok().unwrap()).collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
  (0..n).map(|_| read_vec()).collect()
}

fn main() {
  let (a1, a2, a3) = {
    let tmp: Vec<i8> = read_vec();
    (tmp[0], tmp[1], tmp[2])
  };

  let ans: &str = {
    if (a1+a2+a3) >= 22 {
      "bust"
    } else {
      "win"
    }
  };

  println!("{}", ans);
}

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

using namespace std;

using ll = long long;

int n, q;
string s;
vector<char> t, d;

bool judge(int idx, int dst) {
    int dst2 = (dst == -1 ? n : -1);
    for (int i = 0; i < q; i++) {
        if (s[idx] == t[i]) {
            if (d[i] == 'R') idx++;
            else idx--;
        }
        if (idx == dst) return true;
        if (idx == dst2) return false;
    }
    return false;
}

int solve(int tar) {
    int ok = tar, ng = (tar == -1 ? n : -1);
    while (abs(ng - ok) > 1) {
        int mid = (ok + ng) / 2;
        if (judge(mid, tar)) {
            ok = mid;
        } else {
            ng = mid;
        }
    }
    return ok;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> q;
    cin >> s;
    t.resize(q);
    d.resize(q);
    for (int i = 0; i < q; i++) {
        cin >> t[i] >> d[i];
    }
    int L = solve(-1), R = solve(n);

    vector<int> sum(n + 1, 0);
    sum[0]++;
    sum[L + 1]--;
    sum[R]++;
    sum[n]--;
    for (int i = 1; i < n; i++) sum[i] += sum[i - 1];
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (sum[i] == 0) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1812
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>


int main(){
  int D, N; cin >> D >> N;
  int p = 1;
  rep(i,D) p*=100;
  if (N==100) cout << 101*p << endl;
  else cout << N*p << endl;

  // cout << fixed << setprecision(6);
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

int main(){
  cin>>N; 
  vec a(N); 
  rep(i,N) cin>>a[i]; 
  sort(a.begin(), a.end()); 
  cout<<a[N-1]<<' ';
  ll id = lower_bound(a.begin(), a.end(), (a[N-1]+1)/2 ) - a.begin() ;
  if(id == N-1) --id; 
  ll ans = a[id]; 
  if(id != 0){ 
    if(abs(ans*2 - a[N-1]) > abs(a[id-1]*2 - a[N-1]) ) { 
      ans = a[id-1]; 
    }
  } 
  cout<<ans<<endl;
}


Measured memory_bytes: 1152
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
using namespace std;

#define MOD 1000000007

using ll = int;

int main(void) {
    
    string s;
    cin >> s;
    int a=0,b=0,c=0;
    for(int i=0;i<s.length();++i){
        if(s[i]=='a'){
            a++;
        }else if(s[i]=='b'){
            b++;
        }else{
            c++;
        }
    }
    if(max(max(abs(a-b),abs(b-c)),abs(c-a))<=1){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 512
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <bits/stdc++.h>
#include<queue>
#include <numeric>
#include<stdio.h>
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define fore(i,a) for(auto &i:a)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
 

LL gcd(LL a, LL b){
    if(b == 0) return a;
    return gcd(b,a%b);
}

LL lcm(LL a, LL b){
    LL g = gcd(a,b);
    return a/g *b;
}

int main(){
    int X,A;
    cin >> X >> A;
    if(X<A) cout << 0;
    else cout << 10;
    }

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
using namespace std;
set<int>::iterator it;
set<int>::iterator it2;
set<int>s[100005];
queue<pair<int,int> >q;
map<long long,int>mp;
int f[100005];
int getf(int x){return (f[x]==x)?x:(f[x]=getf(f[x]));}
int n;
int main()
{
	scanf("%d",&n);
	int i;
	for(i=1;i<=n-1;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		s[x].insert(y);
		s[y].insert(x);
	}
	for(i=1;i<=n-1;i++)
    {
    	int x,y;
    	scanf("%d%d",&x,&y);
		if(s[x].find(y)!=s[x].end()) 
		    q.push(make_pair(x,y));
		else
		{
			s[x].insert(y);
		    s[y].insert(x);
		}
	}
	for(i=1;i<=n;i++)
	    f[i]=i;
	for(i=1;i<n;i++)
    {
    	int x,y;
    	if(q.empty())
    	{
    		cout<<"NO";
    	    return 0;
		}
		x=q.front().first;
		y=q.front().second;
		q.pop();
		x=getf(x);
		y=getf(y);
		if(s[x].size()>s[y].size())
		    swap(x,y);
		f[x]=y;
	    s[x].erase(y);
	    s[y].erase(x);
	    for(it=s[x].begin();it!=s[x].end();it++)
	    {
	    	int num=*it;
	    	if(num==x)
			    continue;
	        s[num].erase(x);
	        if(s[y].find(num)!=s[y].end())
		        q.push(make_pair(y,num));
			else
			{
				s[num].insert(y);
			    s[y].insert(num);
			}
		}
		s[x].clear();
	}
	cout<<"YES";
}

Measured memory_bytes: 24064
a, b, c, x = map(int, [input() for i in range(4)])
count = 0
for i in range(min(x // 500, a) + 1):
    for j in range(min((x - i * 500) // 100, b) + 1):
        if x - i * 500 - j * 100 <= c * 50:
            count += 1
print(count)


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

int main(){
  int N, min_i = 101;
  float a[100], sum = 0, min_diff = 101, mean = 0;
  cin >> N;
  for (int i=0; i < N; i++) {
    cin >> a[i];
    sum += a[i];
  }
  mean = sum / N;
  for (int i=0; i < N; i++) {
    if (abs(a[i] - mean) < min_diff) {
      min_diff = abs(a[i] - mean);
      min_i = i;
    }
  }
  cout << min_i << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

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

	int n;
	cin >> n;
	vector<vector<int>> a(n, vector<int> (n));
	vector<int> cl(n);
	vector<int> rw(n);
	int cc = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			char c;
			cin >> c;
			a[i][j] = (c == '#');
			cl[j] += a[i][j];
			rw[i] += a[i][j];
			cc |= a[i][j];
		}
	}
	if (!cc) {
		cout << -1 << endl;
		return 0;
	}
	int add = 0;
	for (int j = 0; j < n; j++) {
		add += (cl[j] < n);
	}
	int ans = 3 * n;
	for (int i = 0; i < n; i++) {
		int cur = 0;
		int kek = 0;
		for (int j = 0; j < n; j++) {
			if (a[i][j]) continue;
			if (!cl[i]) kek = 1;
			cur++;
		}
		cur += kek;
		ans = min(ans, cur);
	}
	cout << add + ans << endl;
}


Measured memory_bytes: 1280
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := iScan()
	a := iSScan(n)
	x := make([]int, 9)
	for _, v := range a {
		x[smaller(v/400, 8)]++
	}
	for i := 0; i < 8; i++ {
		x[i] = smaller(1, x[i])
	}
	if sum(x[:8]) > 0 {
		fmt.Println(sum(x[:8]), sum(x[:8])+x[8])
	} else {
		fmt.Println(1, x[8])
	}
}


Measured memory_bytes: 1776
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  int A,B;
  cin >> A >> B;
  if (A+B >= 10) {
    cout << "error" << endl;
  } else {
    cout << A+B << endl;
  }
  return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#include <math.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const int mINF = -1001001001;


int main() {
string a;
cin >> a;
cout << "ABC" << a << endl;
return 0;
}


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

using namespace std;

#define int long long
#define PB push_back
#define PPB pop_back
typedef pair<int, int> pii;
typedef pair<int, pii> pip;
static const int INF = 1LL<<61;

static const int MAX_N = 5005;

struct S {
  int to, c, r;
  S(int p1, int p2, int p3) {
    to = p1;
    c = p2;
    r = p3;
  }
};

int C[MAX_N], R[MAX_N], d[MAX_N], n, k, visit[MAX_N];
vector<pii> G[MAX_N];
vector<int> tg[MAX_N];

void dijkstra() {
  fill(d, d + MAX_N, INF);
  d[1] = 0;
  priority_queue<pii, vector<pii>, greater<pii>> q;
  q.push(pii(0, 1));

  while (q.size()) {
    pii p = q.top();
    q.pop();
    int v = p.second;
    if (d[v] < p.first) continue;

    for (int i = 0; i < G[v].size(); ++i) {
      pii e = G[v][i];

      if (d[e.first] < e.second + p.first) continue;

      d[e.first] = e.second + p.first;
      q.push(pii(d[e.first], e.first));
    }
  }

  cout << d[n] << endl;
}

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

  cin >> n >> k;
  for (int i = 1; i <= n; ++i) {
    cin >> C[i] >> R[i];
  }

  for (int i = 0; i < k; ++i) {
    int a, b;
    cin >> a >> b;
    tg[a].PB(b);
    tg[b].PB(a);
  }

  for (int i = 1; i <= n; ++i) {
      memset(visit, 0, sizeof(visit));
      visit[i] = true;
      queue<S> q;
      for (int j = 0; j < tg[i].size(); ++j) {
        q.push(S(tg[i][j], C[i], R[i]));
      }

      while (q.size()) {
        S s = q.front();
        q.pop();
        int v = s.to;
        if (visit[v] || s.r == 0) continue;
        G[i].PB(pii(v, s.c));
        visit[v] = true;

        for (int j = 0; j < tg[v].size(); ++j) {
          q.push(S(tg[v][j], s.c, s.r - 1));
        }
      }
  }

  dijkstra();

  return 0;
}

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

using namespace std;

int main()
{
   int N;
   cin >> N;
   vector<int> p(N);
   vector<int> p_init(N);
   for(int i=0;i<N;++i) cin >> p[i];
   p_init=p;
   sort(p.begin(),p.end());
   int answer=0;
   for(int i=0;i<N;++i) if(p[i]!=p_init[i]) answer ++;
   if(answer==0||answer==2) cout << "YES" << endl;
   else cout << "NO" << endl;

   return 0;

}


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

int main(){
    int L,R,d;
    std::cin >> L >>  R >> d;
    int count = 0;
    for(int i = L;i <= R ;i++){
        if(i%d == 0){
            count++;
        }
    }
    std::cout<< count << std::endl;

    return 0;
}

Measured memory_bytes: 3588
# N人の子ども
# 1人目には1個, 2人目には2個...N人目にはN個
# 必要なキャンディーの個数の合計を出力

# 入力された値を数値に変換
N = int(input())

# 1〜Nまでの範囲の整数の和
print(N * (N+1) // 2)

Measured memory_bytes: 9088
import sys

def solve():
    input = sys.stdin.readline
    N, M = map(int, input().split())
    S = input().strip("\n")
    now = N
    ans = []
    while now > 0:
        for i in reversed(range(1, M+1)):
            if now - i < 0: continue
            elif S[now - i] == "0":
                ans.append(i)
                now -= i
                break
        else: 
            print(-1)
            break
    else: 
        A = [int(ans[-1 - i]) for i in range(len(ans))]
        print(" ".join(map(str, A)))

    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 11252
//rohitaas_15
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> o_set;
#define ll  long long
#define int ll
#define um(a,b) unordered_map<a,b>
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define all(v) v.begin(),v.end()
#define f(a,b) for(ll i=a;i<=b;i++)
#define pb push_back
#define mp make_pair
#define pii pair<ll,ll>
#define ff first
#define ss second
#define lb(v,x) lower_bound(v.begin(),v.end(),x)
#define ub(v,x) upper_bound(v.begin(),v.end(),x)
#define show(x) cout<<x<<"\n"
#define printvector(v,n) f(0,n-1){cout<<v[i]<<" ";}
#define input(v,n) f(0,n-1){cin>>v[i];}
#define vr vector<ll>
#define check() cout<<"hi"<<"\n"
#define MOD 1000000007
//#define endl "\n"
#define len() length()
#define maxv(v) *max_element(all(v));
#define minv(v) *min_element(all(v));
#define sumv(v) accumulate(all(v),0)
#define test() ll t;cin>>t;while(t--)
ll search(vr arr, ll l, ll r, ll x){if (r >= l) {ll mid = l + (r - l) / 2;if (arr[mid] == x)return mid;if (arr[mid] > x)return search(arr, l, mid - 1, x);return search(arr, mid + 1, r, x);} return -1;}
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll lcm(ll a , ll b){return (a*b)/ gcd(a,b);}
ll power(ll x, ll y, ll p){ll res = 1;x = x % p;while (y > 0){ if (y & 1) res = (res*x) % p; y = y>>1;x = (x*x) % p; } return res; }
ll modInverse(ll n, ll p){return power(n, p-2, p);}
ll CmP(ll n, ll r, ll p=MOD){if (r==0)return 1;ll fac[n+1];fac[0] = 1;for (ll i=1 ; i<=n; i++)fac[i] = fac[i-1]*i%p; return (fac[n]* modInverse(fac[r], p) % p *modInverse(fac[n-r], p) % p) % p; }
/*ll constructSTUtil(vr v,ll start,ll end,int *st,ll index)
{
	if(start==end)
	{
		st[index]=v[start];
		return st[index];
	}
	ll mid=(start+end)/2;
	st[index]=constructSTUtil(v,start,mid,st,2*index)+constructSTUtil(v,mid+1,end,st,2*index+1);
	return st[index];
}
ll *constructST(vr v,ll n)
{
	ll po=(ll)(ceil(log2(n)));
	ll msize=2*power(2,po)+1;
	vr st[msize];
	constructSTUtil(v,0,n-1,st,1);
	return st;
}*/
ll ask1(ll y)
{
	cout<<1<<" "<<y<<endl;
	ll x;
	cin>>x;
	return x;
}
bool compare(pair<ll,ll> &a,pair<ll,ll> &b)
{
	return a.second<b.second;
}
signed main()
{
	/*
	#ifndef ONLINE_JUDGE
	 freopen("input.txt","r",stdin);
	 freopen("output.txt","w",stdout);
	 #endif
	 //*/
	 /*ll t;
	 cin>>t;
	 ll cccc=t;
	 while(t--)
	 {
	 */
	 	ll a,b,k;

	 	cin>>k;
	 	cin>>a>>b;
	 	ll flag=0;
	 	f(a,b)
	 	{
	 		if(i%k==0)
	 		{
	 			show("OK");
	 			flag=1;
	 			break;
	 		}
	 	}
	 	if(!flag)
	 	{
	 		show("NG");
	 	}
	 //}
	/*cout<<"Case #"<<cccc-t<<": ";*/

}


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

using namespace std;

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

int main() {
  ll N;
  string A, B, C;
  cin >> N >> A >> B >> C;
  ll ans = 0;
  for (ll i = 0; i < N; i++) {
    ll j = 0;
    if (A[i] == B[i]) j++;
    if (B[i] == C[i]) j++;
    if (C[i] == A[i]) j++;
    if (j == 0) ans += 2;
    if (j == 1) ans += 1;
    if (j == 3) ans += 0;
  }

  cout << ans << endl;
}

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

using namespace std;

int main(){
  int n, m;
  cin >> n >> m;
  
  vector<pair<int, int>> a(m);
  vector<pair<int, int>> b(m);
  for(int i = 0; i < m; i++){
    int a_in, b_in;
    cin >> a_in >> b_in;
    a[i] = make_pair(a_in, i);
    b[i] = make_pair(b_in, i);
  }
  
  priority_queue<pair<int, int>> qa;
  priority_queue<pair<int, int>> qb;
  
  for(int i = 0; i < m; i++){
    qa.push(a[i]);
    qb.push(b[i]);
  }
  
  vector<bool> fin(m, false);
  int count = 0;
  while(!qa.empty()){
    pair<int, int> pa = qa.top();
    qa.pop();
    if(!fin[pa.second]){
      count++;
      while(!qb.empty() && pa.first < qb.top().first){
        fin[qb.top().second] = true;
        qb.pop();
      }
    }
  }
  
  cout << count << endl;
  
  return 0;
}

Measured memory_bytes: 3572
import java.util.*;

public class Main {
	//0127 cording
	//0148 cording end
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int m = sc.nextInt();
			HashMap<String, HashSet<Integer>> map = new HashMap<String, HashSet<Integer>>();
			for(int i  = 0 ;  i < m; i++){
				String c = sc.next();
				int first = sc.nextInt();
				int end = sc.nextInt();
				HashSet<Integer> set = new HashSet<Integer>();
				for(int j = first; j <= end; j++){
					set.add(j);
				}
				map.put(c, set);
			}
			
			int n = sc.nextInt();
			LinkedList<HashSet<Integer>> stack = new LinkedList<HashSet<Integer>>();
			String [] data = new String[n];
			boolean isC = true;
			for(int i = 0 ; i < n; i++){
				data[i] = sc.next();
			}
			for(int i = 0 ; i < n; i++){
				String s = data[i];
				if(Character.isDigit(s.charAt(0))){
					HashSet<Integer> se = new HashSet<Integer>();
					se.add(Integer.parseInt(s));
					stack.push(se);
				}
				else{
					char c = s.charAt(0);
					if(c =='+' || c == '-' || c =='/' || c=='*'){
						HashSet<Integer> b = stack.pop();
						HashSet<Integer> a = stack.pop();
						HashSet<Integer> r = new HashSet<Integer>();
						if(c == '+'){
							for(int vb: b){
								for(int va: a){
									int res = (vb + va) % 256;
									r.add(res);
								}
							}
						}
						else if(c == '-'){
							for(int vb: b){
								for(int va: a){
									int res = (va - vb + 256) % 256;
									r.add(res);
								}
							}
						}
						else if(c =='*'){
							for(int vb: b){
								for(int va: a){
									int res = (va * vb) % 256;
									r.add(res);
								}
							}
						}
						else{
							if(b.contains(0)){
								isC = false;
								break;
							}
							for(int vb: b){
								for(int va: a){
									int res = (va / vb) % 256;
									r.add(res);
								}
							}
						}
						stack.push(r);
					}
					else{
						stack.push(map.get(s));
					}
				}
			}
			if(isC){
				System.out.println("correct");
			}
			else{
				System.out.println("error");
				
			}
		}
	}
	
	public static void main(String [] args){
		new Main().doit();
	}
}

Measured memory_bytes: 13000
#include <bits/stdc++.h>
using namespace std;
bool mystery(string s){
string t=s;
  reverse(t.begin(),t.end());
  return s==t;
}
int main() {
  string s;
  cin>>s;
  int n=s.size();
  if(mystery(s)&& mystery(s.substr(0,(n-1)/2)) && mystery(s.substr(n+1/2)) ){
  cout<<"Yes"<<endl;
  }
  else{
  cout<<"No"<<endl;
  }
 
}

Measured memory_bytes: 3632
n=int(input())
a=list(map(int,input().split()))
check=[False]*8
count=0
for i in a:
    if i//400<8:
        check[i//400]=True
    else:
        count+=1
ans=0
for i in check:
    if i:
        ans+=1
print(max(1,ans),ans+count)

Measured memory_bytes: 3064
import sys
import math
def isLoop(n):
    if (n[0] != n[4] or n[1] != n[3]):
        return False
    else:
        return True
a, b = map(int, input().split())
cnt = 0
for i in range(a, b + 1):
    if (isLoop(str(i))):
        cnt += 1
print(cnt)

Measured memory_bytes: 3064
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

N=gets.to_i
t=array(N)
N.times do|i|
    t[i]=gets.to_i
end
puts t.inject(1){|res,x| res.lcm(x)}

Measured memory_bytes: 1788
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define pb push_back
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 100005;

int dx[] = {0, -1, 1, 0};
int dy[] = {-1, 0, 0, 1};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, d;
    cin >> n >> d;
    int res = n / ( d * 2 + 1 );
    if( n % ( d * 2 + 1) ) ++res;
    cout << res << endl;
    return 0;
}



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

void solve()
{
	ll n,k;
	cin>>n>>k;
	if(k>=n)
		cout<<min(k-n,(k-(k-n)))<<endl;
	else
	{
		ll l = (n-k)/k;
		l = n - l*k;
		ll mini = l;
		map<ll,ll> m;
		while(m[l]==0)
		{
			m[l] = 1;
			l = abs(l-k);
			mini = min(mini,l);
		}
		cout<<mini<<endl;
	}
}

int main()
{
	ll t = 1;
	// cin>>t;
	while(t--)
	{
		solve();
	}
}

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


using namespace std;


class disjoint_set {
    std::vector<long long> parent, rank;

    public:
        std::vector<long long> set_size;
        disjoint_set();
        disjoint_set(long long size);

        void make_set(long long x);
        long long find_set(long long x);
        void unite(long long x, long long y);
        void resize(long long size);
};


disjoint_set::disjoint_set(long long size)
{
    parent.resize(size);
    rank.resize(size);
    set_size.resize(size);

    for (long long i = 0; i < size; i++) {
        make_set(i);
    }
}


disjoint_set::disjoint_set()
    : disjoint_set(0)
{
}


void disjoint_set::resize(long long size)
{
    parent.resize(size);
    rank.resize(size);
    set_size.resize(size);

    for (long long i = 0; i < size; i++) {
        make_set(i);
    }
}


void disjoint_set::make_set(long long x)
{
    parent[x] = x;
    rank[x] = 0;
    set_size[x] = 1;
}


long long disjoint_set::find_set(long long x)
{
    if (x != parent[x]) {
        parent[x] = find_set(parent[x]);
    }
    return parent[x];
}


void disjoint_set::unite(long long x, long long y)
{
    long long rx, ry;
    rx = find_set(x);
    ry = find_set(y);
    if (rx == ry)
        return;
    if (rank[rx] == rank[ry]) {
        parent[rx] = ry;
        // when the rank (height) of the trees are the same
        // uniting trees will increase the rank.
        rank[ry]++;
        set_size[ry] += set_size[rx];
    } else if (rank[rx] < rank[ry]) {
        // uniting a shorter tree under a higher tree
        // won't change the rank (height) of the united tree.
        parent[rx] = ry;
        set_size[ry] += set_size[rx];
    } else {
        parent[ry] = rx;
        set_size[rx] += set_size[ry];
    }
}


using ll = long long;


int main() {
    ll N, M, K;
    cin >> N >> M >> K;
    disjoint_set ds(N);
    vector<ll> num_friends(N, 0);
    for (ll i = 0; i < M; i++) {
        ll A, B;
        cin >> A >> B;
        A--; B--;
        ds.unite(A, B);
        num_friends[A]++;
        num_friends[B]++;
    }

    vector<ll> blocking_candidate(N, 0);
    for (ll i = 0; i < K; i++) {
        ll C, D;
        cin >> C >> D;
        C--; D--;
        if (ds.find_set(C) == ds.find_set(D)) {
            blocking_candidate[C]++;
            blocking_candidate[D]++;
        }
    }

    for (ll i = 0; i < N; i++) {
        ll ans = ds.set_size[ds.find_set(i)] - num_friends[i] - blocking_candidate[i] - 1;
        cout << ans << " ";
    }
    cout << endl;
}


Measured memory_bytes: 7160
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dup(x,y) (((x)+(y)-1)/(y))
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const double EPS = 1e-10;
const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

int main() {
	ll n, x, m;
	cin >> n >> x >> m;
	map<ll, int> mp;
	vector<ll> v;
	ll a = x;
	int k = -1;
	for (int i = 0; i < m; i++) {
		if (mp[a]) {
			k = i;
			break;
		}
		mp[a] = i;
		v.push_back(a);
		a = (a * a) % m;
	}
	int s = mp[a];
	if (n <= s) {
		ll ans = 0;
		rep(i,n) {
			ans += v[i];
		}
		cout << ans << endl;
		return 0;
	}
	int t = k - mp[a];

	ll w = 0;
	ll y = 0;
	rep(i,(int)v.size()) {
		if (i < s) w += v[i];
		else y += v[i];
	}
	if (n <= s) {
		ll ans = 0;
		rep(i,n) {
			ans += v[i];
		}
		cout << ans << endl;
	} else {
		ll z = 0;
		for (int i = 0; i < (n - s) % t; i++) {
			z += v[i+s];
		}
		cout << w + (n - s) / t * y + z << endl;
	}
}

Measured memory_bytes: 6708
#include<iostream>
#include <complex>
#include <vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<list>
#include <iterator>
#include <utility>
#include <numeric>
using namespace std;

#define intt long long




int main() {
	int A, B, K;

	cin >> A >> B >> K;


	for (int i = K; i != 0; i--) {
		if (A % 2 == 1) {
			A -= 1;
		}

		A /= 2;
		B += A;

		i -= 1;
		if (i == 0) break;

		if (B % 2 == 1) {
			B -= 1;
		}

		B /= 2;
		A += B;

	
	}

	cout << A  << " "<< B << endl;

	return 0;

}

Measured memory_bytes: 256
using System;

namespace AizuOnLine
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] data = Console.ReadLine().Split(' ');
            double x1 = double.Parse(data[0]);
            double y1 = double.Parse(data[1]);
            double x2 = double.Parse(data[2]);
            double y2 = double.Parse(data[3]);

            double ans = Math.Sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));

            Console.WriteLine(ans.ToString("F8"));
        }
    }
}

Measured memory_bytes: 9296
#include <iostream>
using namespace std;
int main(){
    int ans=0;
    char a[5];
    for(int i=0;i<3;i++){
        cin >> a[i];
    }
    for(int i=0;i<3;i++){
        if(a[i]=='o'){
            ans = ans + 100;
        }
    }
    cout << 700+ans << endl;
}

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

#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (ll i = m; i < (n); i++)

using ll = long long;
using pii = pair<int, int>;
using Vi = vector<int>;

int main() {
  int x,y;
  cin >> x >> y;
  if(x%y==0){
    cout << -1 << endl;
  }
  else{
    cout << x << endl;
  }
} 

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>

using namespace std;

#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL); 
#define endl "\n"

typedef long long int  ll;
typedef unsigned long long int ull;


int main()
{
	FAST;
	int a,b,k;
	cin >> a >> b >> k;
	
	set<int> s;

	for(int i=a ; i<=min(a+k-1,b) ; i++)
		s.insert(i);

	for(int i=max(a,b-k+1) ; i<=b ; i++)
	    s.insert(i);
	    
	for(auto x : s)
	    cout << x << "\n";
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
    public static void Main()
    {
        string[] input = Console.ReadLine().Split();
        double H = double.Parse(input[0]);
        double A = double.Parse(input[1]);
        double ans = 0;
        ans = Math.Ceiling(H / A);
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>

using namespace std;

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

#define INF 1001001001
#define LLINF 1001001001001001001LL

typedef pair<int,int> P;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//------------------HEAD---------------------

int H,W;
char field[1002][1002];
P start;
P goal;

int d[1000][1000];

int bfs(){
    queue<P> que;
    
    rep(i,H)rep(j,W)d[i][j]=INF;
    que.push(start);
    d[start.first][start.second]=0;
    
    while(!que.empty()){
        P p=que.front();que.pop();
        //cerr<<"l:40 "<<p.first<<" "<<p.second<<endl;
        
        if(p==goal)break;
        
        rep(i,4){
            int nx=p.first+dx[i];
            int ny=p.second+dy[i];
            //if(nx==0&&ny==3)cerr<<"l:49 "<<(0<=nx&&nx<H)<<(0<=ny&&ny<W)<<(field[nx][ny]!='X')<<(d[nx][ny]==INF)<<endl;
            if(0<=nx&&nx<H&&0<=ny&&ny<W&&field[nx][ny]!='X'&&d[nx][ny]==INF){
                
                que.push(P(nx,ny));
                d[nx][ny]=d[p.first][p.second]+1;
            }
        }
        
    }
    return d[goal.first][goal.second];
}

int main(void){
    int N;
    cin>>H>>W>>N;
    rep(i,H)cin>>field[i];
    P cheeses[10];
    rep(i,H)rep(j,W){
        if(field[i][j]=='S')start=P(i,j);
        int t=int(field[i][j]-'1');
        if(0<=t&&t<=8)cheeses[t]=P(i,j);
    }
    int ans=0;
    rep(i,N){
        goal=cheeses[i];
        int t=bfs();
        ans+=t;
        //cerr<<t<<endl;
        start=cheeses[i];
    }
    cout<<ans<<endl;
    // Here your code !
    
}


Measured memory_bytes: 7968
#include <stdio.h>
#include <string.h>
struct dice{
    int d[6], tmp[6];
};

struct dice dice1;

void init(int n[6]){
    for(int i = 0; i < 6; i++){
        dice1.d[i] = n[i];
    }
}

void throwdice(char c){
    for(int i = 0; i < 6; i++){
        dice1.tmp[i] = dice1.d[i];
    }
    
    if(c == 'N'){
        dice1.d[0] = dice1.tmp[1];
        dice1.d[1] = dice1.tmp[5];
        dice1.d[2] = dice1.tmp[2];
        dice1.d[3] = dice1.tmp[3];
        dice1.d[4] = dice1.tmp[0];
        dice1.d[5] = dice1.tmp[4];
    }else if(c == 'E'){
        dice1.d[0] = dice1.tmp[3];
        dice1.d[1] = dice1.tmp[1];
        dice1.d[2] = dice1.tmp[0];
        dice1.d[3] = dice1.tmp[5];
        dice1.d[4] = dice1.tmp[4];
        dice1.d[5] = dice1.tmp[2];
    }else if(c == 'W'){
        dice1.d[0] = dice1.tmp[2];
        dice1.d[1] = dice1.tmp[1];
        dice1.d[2] = dice1.tmp[5];
        dice1.d[3] = dice1.tmp[0];
        dice1.d[4] = dice1.tmp[4];
        dice1.d[5] = dice1.tmp[3];
        
    }else if(c == 'S'){
        dice1.d[0] = dice1.tmp[4];
        dice1.d[1] = dice1.tmp[0];
        dice1.d[2] = dice1.tmp[2];
        dice1.d[3] = dice1.tmp[3];
        dice1.d[4] = dice1.tmp[5];
        dice1.d[5] = dice1.tmp[1];
    }
}
int main(void){
    int n[6];
    char t[110];
    int ts;
    
    for(int i = 0; i < 6; i++){
        scanf("%d",&n[i]);
    }
    init(n);
    scanf("%s",t);
    ts=strlen(t);
    for(int i = 0; i < ts; i++){
        throwdice(t[i]);
    }
    printf("%d\n",dice1.d[0]);
    
}



Measured memory_bytes: 2104
n=int(input())
s=[]
for i in range(int(n/2)):
  a=str(i+1)
  b=str(n-int(a))
  s_a=0
  s_b=0
  for j in range(len(a)):
    s_a+=int(a[j])
  for k in range(len(b)):
    s_b+=int(b[k])
  s.append(s_a+s_b)
print(min(s))

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

inline void solve(){
    int k,t; cin>>k>>t; 
    int a[t],sum=0;
    for (int &i: a) cin>>i;
    sort(a,a+t);
	for (int i=0;i<t-1;i++) sum += a[i]; 
	cout << max(0LL,a[t-1]-sum-1) << endl; 
}

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

*/


Measured memory_bytes: 3612
/*
[ ( ^ _ ^ ) ]
*/

import java.io.*;
import java.util.*;


public class Main {
    int INF = (int)1e9;
    long MOD = 1000000007;


    void solve(InputReader in, PrintWriter out) throws IOException {
        int k = in.nextInt();
        int n = in.nextInt();
        Integer[] a = new Integer[n];
        for(int i=0; i<n; i++) {
            a[i] = in.nextInt();
        }
        Arrays.sort(a);
        int rs = k;
        for(int i=0; i<n-1; i++) {
            rs = Math.min(rs, k - (a[i+1]-a[i]));
        }
        rs = Math.min(rs, k - (a[0]+k-a[n-1]));
        out.println(rs);
    }
    

    public static void main(String[] args) throws IOException {
        if(args.length>0 && args[0].equalsIgnoreCase("d")) {
            DEBUG_FLAG = true;
        }
        InputReader in = new InputReader();
        PrintWriter out = new PrintWriter(System.out);
        int t = 1;//in.nextInt();
        long start = System.nanoTime();
        while(t-- >0) {
            new Main().solve(in, out);
        }
        long end = System.nanoTime();
        debug("\nTime: " + (end-start)/1e6 + " \n\n");
        out.close();
    }
    
    static boolean DEBUG_FLAG = false;
    static void debug(String s) {
        if(DEBUG_FLAG) System.out.print(s);
    }
    
    public static void show(Object... o) {
        System.out.println(Arrays.deepToString(o));
    }
    
    static class InputReader {
        static BufferedReader br;
        static StringTokenizer st;
    
        public InputReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        
        String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        
        int nextInt() {
            return Integer.parseInt(next());
        }
        
        long nextLong() {
            return Long.parseLong(next());
        }
        
        double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}

Measured memory_bytes: 49748
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#include<bitset>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define brep(index,num) for(int index=num-1;index>=0;index--)
#define brep1(index,num) for(int index=num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int R;
	scan(R);
	prin(setprecision(12)<<2*R*M_PI);
	return 0;
}


Measured memory_bytes: 3772
def main():
    N = int(input())
    A = [[int(a) for a in input().split()] for _ in range(N)]
    B = [[A[i][j] for j in range(N)] for i in range(N)]
    C = [[A[i][j] for j in range(N)] for i in range(N)]
    for k in range(N):
        for i in range(N):
            for j in range(N):
                t = B[i][k] + B[k][j]
                if t < B[i][j]:
                    return -1
                if B[i][k] and B[k][j] and t == B[i][j]:
                    C[i][j] = 0
    return sum([sum([C[i][j] for j in range(i)]) for i in range(N)])
print(main())

Measured memory_bytes: 44636
s = input()
t = input()

# t0=time()

n = len(s)
k = len(t)


maxn = 0
if s==t:
    maxn=k
for i in range(n-k+1):
    # print(s[i:i+k], t)
    neq = 0
    for c1, c2 in zip(s[i:i+k], t):
        neq += int(c1==c2)
    # print('n symbols equal:',neq)
    if neq > maxn:
        maxn=neq
        # print('max_eq', maxn)
print(k-maxn)

Measured memory_bytes: 9052