akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long int lli;
#define optimize ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define forn(i,n) for(int i = 0; i<n; i++)
#define forab(i,a,b) for(int i = a; i<b; i++)
#define forll(i,a,b) for(lli i = a; i<b; i++)
#define mp make_pair
#define pb emplace_back
#define sortv(v) sort(v.begin(), v.end())
#define debug(x) cout<<#x<<" : "<<x<<endl
#define all(x) x.begin(),x.end()
#define printv(v) for(auto it : v) cout<<it<<" ";cout<<endl;
const int mod1 = 1000000007;
const int mod2 = 998244353;

bool possible(vector<int>a, int mid, int k)
{
	int s = 0;
	for(int x : a)
	{
		s += (x+mid-1)/mid-1;
	}
	return s<=k;
}


int main()
{
	optimize

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

	int mn = 1, mx = (int)1e9+1;

	while(mn < mx)
	{
		int md = (mn+mx)/2;
		if(possible(a, md, k))
		{
			mx = md;
		}
		else
			mn = md+1;
	}
	cout<<mn<<endl;

	
	return 0;
}

Measured memory_bytes: 4664
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <stack>
#include <cmath>
#include <queue>
#include <numeric>


int main()
{
	int a;

	std::cin >> a;

	std::cout << "ABC" << a << std::endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF 1e9
#define dump(x) cerr<<#x<<"="<<x<<endl
#define int long long

using ll = long long;
const ll mod = LLONG_MAX;

signed main(){
  string s;
  cin>>s;
  cout<<s[0];
  cout<<s.size()-2;
  cout<<s[s.size()-1]<<endl;
}


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

using namespace std;

int main() {

  int n, m = -1;

  cin >> n;

  for (int x, i = 0; i< n; ++i) {
    cin >> x;
    int c = 0;
    for (; x % 2 == 0; x /= 2, ++c)
      ;
    if (m == -1 || c < m)
      m = c;
  }
  
  cout << m << endl;

  return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int main()
  {
      int sx, sy, tx, ty;
      int i;
scanf("%d %d %d %d",&sx,&sy,&tx,&ty);
      for(i=1;i<=ty-sy;i++)
      {
         printf("U");
     }
     for(i=1;i<=tx-sx;i++)
     {
         printf("R");
     }
     for(i=1;i<=ty-sy;i++)
     {
         printf("D");
     }
     for(i=0;i<=tx-sx;i++)
     {
         printf("L");
   }
     for(i=0;i<=ty-sy;i++)
    {
         printf("U");
     }
    for(i=0;i<=tx-sx;i++)
     {
         printf("R");
     }
    printf("D");
    printf("R");
     for(i=0;i<=ty-sy;i++)
     {
         printf("D");
     }

     for(i=0;i<=tx-sx;i++)
     {
         printf("L");
     }
    printf("U\n");
    return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
typedef unsigned long long int ull;
typedef long long lint;

int main(void){
    string S,T;
    cin >> S >> T;
    cout << T << S << endl;
}

Measured memory_bytes: 256
/*
        Author: Prokash
                CSE48, JU
*/

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n,in,t;
    cin>>t;
    vector<ll>v;
    ll sum=0;
    for(ll i=0;i<t;i++)
    {
        cin>>in;
        sum+=in;
        v.push_back(in);
    }
    ll s,d=0;
    ll ans=INT_MAX;
    for(ll i=0;i+1<t;i++)
    {
        d+=v[i];
        s=abs(sum-2*d);
        ans=min(ans,s);
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

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

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(pi c, pi d){
	return c.S < d.S;
}


int check(string& s, int N, int middle){
	string a = s.substr(0, middle);
	string b = s.substr(middle, N-middle);
	
	set<char> sa;
	set<char> sb;
	
	for(char c: a) sa.insert(c);
	for(char c: b) sb.insert(c);
	auto it = sa.begin();
	int ans = 0;
	while(it != sa.end()){
		auto it2 = sb.find(*it);
		if(it2 != sb.end()) ++ans;
		++it;
	}
	return ans;
	
}

int main() {
	int N, ans=0;
	string S;
	cin >> N >> S;
	REP(i, 1, N){
		ans = max(ans, check(S, N, i));
	}
	cout << ans;
		

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N; cin >> N;
  for(int i = 1; i < 10; i++){
    for(int j = 1; j <= i; j++){
      if(i * j == N){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,i,j,ans;
  cin>> n;
  ans=0;
  vector<int> val(n),cost(n);
  for(i=0;i<n;i++)
  {
    cin >> val.at(i);
  }
   for(i=0;i<n;i++)
  {
    cin >> cost.at(i);
  }
  for(i=0;i<n;i++)
  {
    if(val.at(i)-cost.at(i)>0)
      ans+=val.at(i)-cost.at(i);
  }
  cout << ans <<endl;
}

Measured memory_bytes: 256
def p(u):
 if u+1:print(s,u,end=s);p(T[u]);p(T[u+N])
def i(u):
 if u+1:i(T[u]);print(s,u,end=s);i(T[u+N])
def o(u):
 if u+1:o(T[u]);o(T[u+N]);print(s,u,end=s)
s=''
N=int(input())
T=[0,0]*N
for _ in[0]*N:
 a,b,c=map(int,input().split())
 T[a],T[a+N]=b,c
r=(set(range(N))-set(T)).pop()
print('Preorder');p(r)
print('\nInorder');i(r)
print('\nPostorder');o(r)
print()


Measured memory_bytes: 5628
// practice with Dukkha
#include <algorithm>
#include <iostream>

using namespace std;

const int N = 100000, A = 26;

int dd[N + 1][A];

int main() {
	string s, t; cin >> s >> t;
	int n = s.length(), m = t.length();
	int inf = n * 2;
	fill(dd[n], dd[n] + A, inf);
	for (int i = n - 1; i >= 0; i--) {
		int a = s[i] - 'a';
		dd[n][a] = i;
	}
	for (int i = n - 1; i >= 0; i--) {
		for (int a = 0; a < A; a++)
			dd[i][a] = 1 + dd[i + 1][a];
		int a = s[i] - 'a';
		dd[i][a] = 0;
	}
	long long i = 0;
	for (int j = 0; j < m; j++) {
		int a = t[j] - 'a';
		int d = dd[i % n][a];
		if (d >= inf) {
			cout << "-1\n";
			return 0;
		}
		i += d + 1;
	}
	cout << i << '\n';
	return 0;
}


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

using namespace std;

int main(int argc, char const *argv[]) {
  int abc[3];
  cin >> abc[0] >> abc[1] >> abc[2];
  sort(abc, abc+3);
  cout << abc[2]*10 + abc[1] + abc[0] << endl;

  return 0;
}


Measured memory_bytes: 768
def main():
    k = int(input())
    
    tmp = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

    print(tmp[k-1])

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include <iostream>
#include <string.h>
using namespace std;
 
static const int MAX_LENGTH = 1200;
 
int main(void) {
    char* inputLine = new char[MAX_LENGTH];
    cin.getline(inputLine, MAX_LENGTH);
 
    for(int i=0; i <= strlen(inputLine); i++) {
        if(i == strlen(inputLine)) {
            cout << endl;
            break;
        }

        if(0 <= inputLine[i] - 'a' && inputLine[i] - 'a' <= 25) {
            cout << (char)(inputLine[i] - ('a'-'A'));
            continue;
        }
        if(0 <= inputLine[i] - 'A' && inputLine[i] - 'A' <= 25) {
            cout << (char)(inputLine[i] + ('a'-'A'));
            continue;
        }
        cout << inputLine[i];
    }
 
    return 0;
}

Measured memory_bytes: 3008
use std::io::Read;

fn main() {
    let mut buf = String::new();

    std::io::stdin().read_to_string(&mut buf).unwrap();

    let mut iter = buf.split_whitespace();
    let h: usize = iter.next().unwrap().parse().unwrap();    
    let w: usize = iter.next().unwrap().parse().unwrap();    
    let a: Vec<Vec<char>> = (0..h).map(|_| iter.next().unwrap().chars().collect()).collect();
    let mut rows = vec![false; h];
    let mut cols = vec![false; w];
    for i in 0..h {
        for j in 0..w {
            if a[i][j] == '#' {
                rows[i] = true;
                cols[j] = true;
            }
        }
    }
    for i in 0..h {
        if !rows[i] { continue; }
        for j in 0..w {            
            if !cols[j] { continue; }
            print!("{}", a[i][j]);
        }
        println!();
    }
}



Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
const long INF=1000000000000;

//関数
long flooN(long X,long N){//XinZ,NinN;
    return X/N-(X<0 && X%10!=0);
}

int main() {
    
    
    //入力
    long N;
    cin>>N;
    vector<long > A(N);
    for(int i=0;i<N;i++){
        cin>>A.at(i);
        A.at(i)-=(i+1);
    }
    
    
    //計算
    sort(A.begin(),A.end());
    long ans=0;
    for(int i=0;i<N;i++){
        ans+=abs(A.at(i)-A.at((N-1)/2));
    }
    
    //出力
    cout<<ans<<endl;
}

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

using namespace std;

long long a[100];

int main(){
  int i,N,Si=0;
  long long x,S=0;
  cin >> N >> x;
  for (i=0;i<N;i++) {
    cin >> a[i];
  }
  sort(a, a+N);
  for (i=0;i<N;i++) {
    S+=a[i];
    if (S<=x) {
      if (i==N-1 && S!=x) {
        break;
      }
      Si+=1;
    } else {
      break;
    }
  }
  cout << Si << endl;
  return 0;
}


Measured memory_bytes: 256
from scipy.sparse import*;N=int(input());Z=[[i]+list(map(int,input().split()))for i in range(N)];P=set()
for j in[1,2]:
 Z.sort(key=lambda a:a[j])
 for i in range(1,N):a,b,c=Z[i-1];d,e,f=Z[i];P.add((min(abs(e-b),abs(f-c)),a,d))
d,i,j=zip(*P);print(int(csgraph.minimum_spanning_tree(csr_matrix((d,(i,j)),(N,N))).sum()))

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

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

    // 0: lose, 1: win
    vector<vector<int>> dp(k + 1, vector<int>(2, -1));
    function<int(int, int)> rec = [&] (int st, int turn) {
        if(dp[st][turn] != -1) return dp[st][turn];
        int& res = dp[st][turn] = 0;
        for(int i = 0; i < n; ++i) {
            if(st - a[i] < 0) continue;
            res |= !rec(st - a[i], !turn);
        }
        return res;
    };

    cout << (rec(k, 0) ? "First" : "Second") << endl;
}


Measured memory_bytes: 13568
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		System.out.println(S.charAt(0)+""+(S.length()-2)+""+S.charAt(S.length()-1));
	}

}


Measured memory_bytes: 23636
# -*- coding:utf-8 -*-


def ID():
    N, M = [int(n) for n in input().split()]
    lst = [[n for n in input().split()] for _ in range(M)]
    sorted_lst = sorted(lst, key=lambda x: int(x[1]))
    memo = {}
    result = {}
    for p, x in sorted_lst:
        if p not in memo:
            memo[p] = 1
        else:
            memo[p] += 1
        higher = p.zfill(6)
        lower = "{0:06d}".format(memo[p])
        result[p + x] = higher + lower

    for p, x in lst:
        print(result[p+x])


if __name__ == '__main__':
    ID()

Measured memory_bytes: 53936
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <queue>
using namespace std;
typedef long long LL;
const int inf = 1 << 30;
const LL INF = 1LL << 60;
const int MaxN = 100005;

int N, C;
int s[MaxN + 5], t[MaxN + 5], c[MaxN + 5];
int tt[2 * MaxN + 5], sum[2 * MaxN + 5];

int  main()
{
	while(scanf("%d %d", &N, &C) != EOF)
	{
		for(int i = 0; i < N; i++)
			scanf("%d %d %d", &s[i], &t[i], &c[i]);
		for(int i = 1; i <= C; i++)
		{
			for(int j = 0; j < 200002; j++) tt[j] = 0;
			for(int j = 0; j < N; j++) {
				if(c[j] == i) {
					tt[s[j] * 2 - 1]++;
					tt[t[j] * 2]--;
				}
			}
			for(int j = 1;j < 200002; j++) tt[j] += tt[j-1];
			for(int j = 0;j < 200002; j++)
				if(tt[j] > 0) sum[j]++;
		}
		int ans = 0;
		for(int i = 0; i < 200002; i++)
			ans = max(ans, sum[i]);
		printf("%d\n", ans);
		memset(tt, 0, sizeof(tt));
		memset(sum, 0, sizeof(sum));
	}
	return 0;
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


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

  int h,w;
  cin >> h >> w;
  int a[h][w],b[h][w];
  rep(i,h) rep(j,w) cin >> a[i][j];
  rep(i,h) rep(j,w) cin >> b[i][j];
  const int si=80*160;
  const int dpsi=si*2+10;
  bool make[h][w][dpsi];
  rep(hi,h)rep(wi,w) rep(i,dpsi) make[hi][wi][i]=false;  
  make[0][0][si + a[0][0]-b[0][0]]=true;
  make[0][0][si - a[0][0]+b[0][0]]=true;
  queue<pair<int,int>> que;
  que.push(mp(0,0));
  bool st[h][w];
  rep(i,h) rep(j,w) st[i][j]=false;
  while(!que.empty()){
    auto cor=que.front();que.pop();
    int hi=cor.first;
    int wi=cor.second;
    if(st[hi][wi])  continue;
    st[hi][wi]=true;
    if(hi+1>=h){}
    else{
      int df=a[hi+1][wi] - b[hi+1][wi];
      df=abs(df);
      rep(i,dpsi){
	if(i+df<dpsi) make[hi+1][wi][i+df] |= make[hi][wi][i];
	if(i-df>=0) make[hi+1][wi][i-df] |= make[hi][wi][i];
      }
      que.push(mp(hi+1,wi));
    }
    if(wi+1>=w){}
    else{
      int df=a[hi][wi+1] - b[hi][wi+1];
      df=abs(df);
      rep(i,dpsi){
        if(i+df<dpsi) make[hi][wi+1][i+df] |= make[hi][wi][i];
        if(i-df>=0) make[hi][wi+1][i-df] |= make[hi][wi][i];
      } 
      que.push(mp(hi,wi+1));
    }
  }
  int ans=INT_MAX;
  rep(i,dpsi){
    if(make[h-1][w-1][i]){
      //      cout << ""<< endl;
      ans = min(ans, abs(si-i));
    }
  }
  cout << ans << endl;

  //  cout << endl << endl;
  //  cout << static_cast<double>(clock()) / CLOCKS_PER_SEC << "s"<<endl;
  return 0;
    

}


Measured memory_bytes: 160384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

int main(){
    int N, M;
    cin >> N >> M;
    int c[M];
    rep(i, M) cin >> c[i];
    int dp[N+1];
    fill(dp, dp+N+1, inf);
    dp[0] = 0;
    rep2(i, 1, N){
        rep(j, M){
            if(i < c[j]) continue;
            chmin(dp[i], dp[i-c[j]]+1);
        }
    }
    cout << dp[N] << endl;
}


Measured memory_bytes: 3300
#include<bits/stdc++.h>
#define mes(a, b)  memset(a, b, sizeof a)
#define pb push_back
typedef unsigned long long int ull;
typedef long long int ll;
const int    maxn = 1e5 + 20;
const int    maxm = 1e5 + 10;
const ll     mod  = 1e9 + 7;
const ll     INF  = 1e18 + 100;
const int    inf  = 0x3f3f3f3f;
const double pi   = acos(-1.0);
const double eps  = 1e-8;
using namespace std;
int main(){
	int n;cin >> n;
	printf("%.9f\n",2 * n * pi );
}

Measured memory_bytes: 3724
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>

using namespace std;
typedef long long int ll;

struct state{
	int maxLen = 0; int x = -1; int y = -1;
};

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

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

	vector<vector<state>> dp(n + 1, vector<state>(m + 1, state()));


	for(int i = 1; i <= n; i++) {
		for(int j = 1; j <= m; j++) {
			int x = i - 1, y = j - 1;
			if(s[x] == t[y]) {
				state s;
				s.maxLen = dp[i - 1][j - 1].maxLen + 1;
				s.x = i - 1; s.y = j - 1;
				dp[i][j] = s;
			} else {
				state s;
				if(dp[i][j - 1].maxLen >= dp[i - 1][j].maxLen) {
					s.maxLen = dp[i][j - 1].maxLen;
					s.x = i; s.y = j - 1;
				} else {
					s.maxLen = dp[i - 1][j].maxLen;
					s.x = i - 1; s.y = j;
				}
				dp[i][j] = s;
			}
		}
	}

	string lcs;

	int x = n, y = m;
	while(x > 0 && y > 0) {
		int a = dp[x][y].x, b = dp[x][y].y;
		if(x - a > 0 && y - b > 0) {
			lcs = lcs + s[x - 1];
		}
		x = a; y = b;
	}

	// cout << dp[n][m].maxLen << endl;
	reverse(lcs.begin(), lcs.end());
	cout << lcs << endl;

}

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

vector<vector<int>>memo(14,vector<int>(1<<13,-1));
int solve(bitset<12>v, int now, const vector<int>&nums) {
	if (memo[now][v.to_ulong()] != -1)return memo[now][v.to_ulong()];

	if (now == 13) {
		vector<int>times(24);
		for (int i = 0; i <= 12; ++i) {
			if (i == 0) {
				times[i] = true;
			}
			else if (i == 12) {
				if (nums[i])times[i] = true;
			}
			else {
				if (nums[i] == 2) {
					times[i] = true;
					times[24 - i] = true;
				}
				else if (nums[i] == 1) {
					if (v[i]) {
						times[i] = true;
					}
					else {
						times[24 - i] = true;
					}
				}
				else if (nums[i] >= 3)assert(false);
			}
		}
		int ans = 24;
		for (int i = 0; i < 24; ++i) {
			for (int j = i+1; j < 24; ++j) {
				if (times[i] && times[j]) {
					ans = min(ans, min(abs(i - j), 24 - abs(i - j)));
				}
			}
		}
		return memo[now][v.to_ulong()] = ans;
	}
	else if (now == 12) {
		if (nums[now] > 1) {
			return memo[now][v.to_ulong()] = 1;
		}
		else {
			return memo[now][v.to_ulong()] = solve(v, now + 1, nums);
		}
	}
	else {
		int ans = 0;
		if (nums[now] == 1) {
			v[now] = 0;
			ans = max(ans, solve(v, now + 1, nums));
			v[now] = 1;
			ans = max(ans, solve(v, now + 1, nums));
			v[now] = 0;
		}
		else if (nums[now] > 2) {
			return memo[now][v.to_ulong()] = 0;
		}
		else {
			ans = solve(v, now + 1, nums);
		}
		return memo[now][v.to_ulong()] = ans;
	}
	
}
int main() { 

	int N; cin >> N;
	vector<int>nums(13);
	for (int i = 0; i < N; ++i) {
		int a; cin >> a;
		nums[a]++;
	}
	int ans = 0;
	if (nums[0] >= 1) {
		ans = 0;
	}
	else {
		bitset<12>bs;
		ans = solve(bs, 1, nums);
	}
	cout << ans << endl;
	return 0;
}

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

#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define ll long long
#define ld long double
#define pb push_back
#define MOD 1000000007
#define LLMN LONG_LONG_MIN
#define LLMX LONG_LONG_MAX
#define LDMX LDBL_MAX
#define LDMN LDBL_MIN
#define MAX 1000000

ll mulmod(ll, ll);
ll fastpower(ll, ll);
void getprime(vector<ll>&);
void getfact(vector<ll>&, vector<ll>&);
ll ncr(ll, ll, vector<ll>&, vector<ll>&);

void solve()
{
    ll n, x, k;
    cin>>x>>n;
    vector<ll>a(n);
    ll res = LLMX, mn = LLMX;
    if(n == 0)
        res = x;
    else
    {
        for(ll i=0;i<n;i++) cin>>a[i];
        sort(a.begin(), a.end());
        for(ll i=0;i<=101;i++)
        {
            if(binary_search(all(a), i) == false)
            {
                if(abs(i - x) < mn)
                {
                    mn = abs(i - x);
                    res = i;
                }
                else if(abs(i - x) == mn)
                {
                    res = min(i, res);
                }
            }
        }
    }
    cout<<res;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll t = 1;
    //cin>>t;
    while(t--)
    {
        solve();        
    }
    return 0;
}

ll mulmod(ll a, ll b)
{
    ll res = 0; 
    a = a % MOD;
    while(b > 0)
    {
        if (b % 2 == 1)
            res = (res + a) % MOD;
 
        a = (a * 2) % MOD; 
        b /= 2;
    } 
    return res % MOD; 
}

ll  fastpower(ll a, ll n)
{
    ll res = 1;
    while(n > 0)
    {
        if(n % 2 != 0)
        {
            res = (res * a) % MOD;
        }
        n /= 2;
        a = (a * a) % MOD;
    }
    return res;
}

void getprime(vector<bool>&prime)
{
    prime[0] = false;
    prime[1] = false;
    
    for(ll i = 2;i <= MAX; i++)
    {
        if(prime[i])
        {
            for(ll j = i*i; j <= MAX; j += i)
                prime[j] = false;
        }
    }
}

void getfact(vector<ll> &fact, vector<ll> &ifact)
{
    fact[0] = 1;
    ifact[0] = 1;
    
    for(ll i = 1; i <= MAX; i++)
    {
        fact[i] = (fact[i-1] * i)%MOD;
        ifact[i] = (ifact[i-1] * fastpower(i, MOD -2) )%MOD;
    }
}

ll ncr(ll n, ll r, vector<ll>&fact, vector<ll>&ifact)
{
    ll res;
    res = (((fact[n] * ifact[r]) % MOD) * ifact[n-r]) % MOD;
    return res;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define bitrep(X,N) for(ll X = 0; X < (1 << (N)); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end() 


using namespace std;

int main(){
  
  	int k;
  	cin >> k;
  
  	int even = k / 2;
  	int odd = k - even;
  
 	cout << even * odd << endl;

    return 0;
}

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


int main(int argc, char *argv[]) { ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);

  int n;cin>>n;
  vector<int> P(n),Q(n);
  for(int i=0;i<n;i++)cin>>P[i];
  for(int i=0;i<n;i++)cin>>Q[i];
  vector<int> arr(n);
  for(int i=0;i<n;i++)arr[i]=i+1;

  int a=0,b=0,cnt=1;

  do{
    if(P==arr)a=cnt;
    if(Q==arr)b=cnt;
    cnt++;
  } while(next_permutation(arr.begin(), arr.end()));

  cout<<abs(a-b)<<endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < (ll)(n); ++i)
#define FOR(i, a, b) for(ll i=(a); i < (ll)(b); ++i)
template<class T> inline bool chmax(T& a, T b) { if(a < b){ a=b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if(a > b){ a=b; return 1; } return 0;}

int main(){
	ll a,b,c,d;
	cin >> a >> b >> c >> d;
	
	cout << max(max(a*c,a*d), max(b*c,b*d)) << endl;
	
	return 0;
}

Measured memory_bytes: 3632
def main():
	N = int(input()) 
	p = [int(f) for f in input().split()]
	
	A = [f for f, i in zip(p, range(1, N+1)) if not f-i == 0]

	if len(A) == 0 or len(A) == 2:
		print("YES")
	else:
		print("NO")


if __name__ == "__main__":
	main()

Measured memory_bytes: 2940
import sys
# input = sys.stdin.buffer.readline
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getlist():
    return list(map(int, input().split()))
import math
import heapq
import fractions
from collections import defaultdict, Counter, deque
MOD = 10**9 + 7
INF = 10**15

def getyaku(n):
    res = []
    for i in range(1, int(math.sqrt(n)) + 1):
        if n % i == 0:
            res.append(i)
            res.append(n // i)

    return(sorted(list(set(res))))

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

def main():
    n,m, k = getlist()
    for i in range(n+1):
        tmp = m*i
        for j in range(m + 1):
            ttmp = tmp + n * j
            ttmp -= i*j*2
            if ttmp == k:
                # print(i, j)
                print("Yes")
                return
    print("No")
    return

if __name__ == '__main__':
    main()

"""
9999
3

2916
"""

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

int main() {
    int n, ans = 0;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int curmin = 1e9;
    rep(i, n) {
        curmin = min(curmin, a[i]);
        if (a[i] == curmin) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4048
N = int(input())
xy = [map(int, input().split()) for _ in range(N)]
x, y = [list(i) for i in zip(*xy)]
dis1 = [0] * N
dis2 = [0] * N
for i in range(N):
        dis1[i] = x[i] + y[i]
        dis2[i] = x[i] - y[i]
max_dis1 = max(dis1)
min_dis1 = min(dis1)
max_dis2 = max(dis2)
min_dis2 = min(dis2)
max_dis = max([max_dis1 - min_dis1,-min_dis2 + max_dis2])
print(max_dis)

Measured memory_bytes: 127948
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<ll,ll> P;
#define M 998244353
#define F first
#define S second
#define PB push_back
#define INF 100000000000000000
ll pw(ll x,ll y){
	ll res=1;
	while(y){
		if(y&1)res=res*x%M;
		y>>=1;
		x=x*x%M;
	}
	return res;
}
ll n,a[305],dp[305][90005],s,ans,dpp[305][180005];
int main(void){
    cin>>n;
    for(int i=0;i<n;i++){
		cin>>a[i];
		s+=a[i];
	}
	dp[0][0]=1;
	dpp[0][s]=1;
	for(int i=0;i<n;i++){
		for(int j=0;j<=s;j++){
			if(dp[i][j]==0)continue;
			dp[i+1][j]=(dp[i+1][j]+dp[i][j]*2LL%M)%M;
			dp[i+1][j+a[i]]=(dp[i+1][j+a[i]]+dp[i][j])%M;
		}
		for(int j=0;j<=s*2;j++){
			if(dpp[i][j]==0)continue;
			dpp[i+1][j-a[i]]=(dpp[i+1][j-a[i]]+dpp[i][j])%M;
			dpp[i+1][j+a[i]]=(dpp[i+1][j+a[i]]+dpp[i][j])%M;
		}
	}
	ans=1LL;
	for(int i=0;i<n;i++)ans=ans*3LL%M;
	for(int i=0;i<=s;i++){
		if(i*2==s){
			ans=(ans+dpp[n][s]*3LL%M)%M;
		}
		if(i*2>=s){
			ans=(ans+M-dp[n][i]*3LL%M)%M;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 635136
#include <bits/stdc++.h>
 
#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
#define dumpi(x1) fprintf(stderr, "#%s.%d (%s) = (%d)\n", __func__, __LINE__, #x1, x1);
#define dumpii(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%d, %d)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumpiii(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%d, %d, %d)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
 
struct S002 {
  int n;
  S002& operator > (long& x) {
    n = x;
    return *this;
  }
  S002& operator > (long&& x) {
    n = x;
    return *this;
  }
  S002& operator >= (long& x) {
    if( scanf("%ld", &x) <= 0 ) exit(0);
    return *this;
  }
  S002& operator >= (double& x) {
    if( scanf("%lf", &x) <= 0 ) exit(0);
    return *this;
  }
  S002& operator >= (std::string& s) {
    if( not (std::cin >> s) ) exit(0);
    return *this;
  }
  template<typename a>
  S002& operator >= (std::vector<a>& v) {
    v.resize(n);
    for(long i = 0; i < n; ++i) {
      *this >= v[i];
    }
    return *this;
  }
  template<typename a, std::size_t s>
  S002& operator >= (std::array<a, s>& x) {
    for(long i = 0; i < (long)s; ++i) {
      *this >= x[i];
    }
    return *this;
  }
};

struct Solver {
  std::string s;
  Solver() {
    S002 r;
    r >= s;
  }
  void solve() {
    long l = std::find(s.begin(), s.end(), 'A') - s.begin();
    std::reverse(s.begin(), s.end());
    long r = (long)s.size() - 1 - (std::find(s.begin(), s.end(), 'Z') - s.begin());
    printf("%ld\n", r - l + 1);
  }
};
 
int main() {
  for(;;) std::unique_ptr<Solver>(new Solver())->solve();
  return 0;
}

Measured memory_bytes: 640
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type Abbreviation ---------- */
using ll = long long;

/* ---------- Constants  */
const ll MOD = 1e9 + 7;
// const int INF = 1 << 25;
// const ll INF = 1LL << 50;
// const double PI = acos(-1);
// const double EPS = 1e-10;
// mt19937 mert(LL(time(0)));

/* ---------- Short Functions ---------- */
template <typename T>
T gcd(T a, T b) {
    if (a > b) return gcd(b, a);
    return a == 0 ? b : gcd(b % a, a);
}

template <typename T, typename U>
T mypow(T b, U n) {
    if (n == 0) return 1;
    if (n == 1) return b /* % MOD */;
    if (n % 2 == 0) {
        return mypow(b * b /* % MOD */, n / 2);
    } else {
        return mypow(b, n - 1) * b /* % MOD */;
    }
}

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */

int main() {
    int N, K;
    cin >> N >> K;

    ll sum[N+1];
    sum[0] = 0;
    for (int i = 1; i <= N; i++) {
        int a;
        cin >> a;
        sum[i] = sum[i-1] + a;
    }

    vector<ll> B;

    for (int l = 1; l <= N; l++) {
        for (int r = l; r <= N; r++) {
            ll b = sum[r] - sum[l-1];
            B.push_back(b);
        }
    }

    ll ret = 0LL;

    for (int shift = 40; shift >= 0; shift--) {
        vector<ll> one;

        for (ll b : B) {
            if ((b >> shift) & 1LL == 1LL) one.push_back(b);
        }

        if (one.size() >= K) {
            B = one;
            ret |= (1LL << shift);
        }
    }

    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 6256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for (int i = (a); i <= (b); ++i)
#define REPD(i,a,b) for (int i = (a); i >= (b); --i)
#define FORI(i,n) REP(i,1,n)
#define FOR(i,n) REP(i,0,int(n)-1)
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define SZ(x) int((x).size())
#define DBG(v) cerr << #v << " = " << (v) << endl;
#define FOREACH(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++)
#define fi first
#define se second

const int N = 200200;

int n;
int p[N], pos[N];

int main() {
	scanf("%d", &n);
	FORI(i,n) {
		scanf("%d", &p[i]);
		pos[p[i]] = i;
	}
	int len = 1, res = 1;
	pos[n+1] = -1;
	FORI(i,n) {
		if (pos[i] < pos[i+1]) {
			len++;
		} else {
			res = max(res, len);
			len = 1;
		}
	}
	printf("%d\n", n-res);
	return 0;
}


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

enum
{
    MAX_V = 300 + 10, MAX_Z = 2000 + 50
};

const long long INF = 1000000000000;
long long dp[MAX_Z][MAX_V];
long long SG[MAX_V][MAX_V], LG[MAX_V][MAX_V];
int rt[MAX_Z], rtl;
int n, m;

void floyd()
{
    for(int k = 1; k <= n; k++)
        for(int i = 1; i <= n; i++)
            for(int j = 1; j <= n; j++)
                SG[i][j] = min(SG[i][j], SG[i][k] + SG[k][j]);
    for(int k = 1; k <= n; k++)
        for(int i = 1; i <= n; i++)
            for(int j = 1; j <= n; j++)
                LG[i][j] = min(LG[i][j], LG[i][k] + LG[k][j]);
    for(int i = 1; i <= n; i++)
        LG[i][i] = SG[i][i] = 0;
}

int main()
{
    while(~scanf("%d%d", &n, &m), n+m)
    {
        for(int i = 1; i <= n; i++)
            for(int j = 1; j <= n; j++)
                SG[i][j] = LG[i][j] = INF;
        for(int i = 0; i < m; i++)
        {
            int x, y;
            long long cs;
            char tp;
            scanf("%d %d %lld %c", &x, &y, &cs, &tp);
            if(tp == 'S')
            {
                SG[x][y] = min(SG[x][y], cs);
                SG[y][x] = min(SG[y][x], cs);
            }
            else
            {
                LG[x][y] = min(LG[x][y], cs);
                LG[y][x] = min(LG[y][x], cs);
            }
        }
        scanf("%d", &rtl);
        for(int i = 1; i <= rtl; i++)
            scanf("%d", &rt[i]);

        floyd();
        for(int i = 1; i <= rtl; i++)
            for(int j = 1; j <= n; j++)
                dp[i][j] = INF;

        dp[1][rt[1]] = 0;
        for(int i = 2; i <= rtl; i++)
            for(int j = 1; j <= n; j++)
                for(int k = 1; k <= n; k++)
                {
                    if(j != k)
                        dp[i][j] = min(dp[i][j], dp[i - 1][k] + LG[k][rt[i - 1]] + SG[k][j] + LG[j][rt[i]]);
                    else
                        dp[i][j] = min(dp[i][j], dp[i - 1][k] + LG[rt[i-1]][rt[i]]);
                }

        long long ans = *min_element(dp[rtl] + 1, dp[rtl] + n + 1);
        if(ans == INF);
        else printf("%lld\n", ans);
    }
    return 0;
}

Measured memory_bytes: 4748
#include<cmath>
#include<cstdio>
#include<vector>

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

using namespace std;

const int N_MAX=10;
bool Gauss_Jordan(int n,const double A[N_MAX][N_MAX],const double *b,double *x){
	static double B[N_MAX][N_MAX+1];
	rep(i,n){
		rep(j,n) B[i][j]=A[i][j];
		B[i][n]=b[i];
	}

	rep(i,n){
		int piv=i;
		for(int j=i;j<n;j++) if(abs(B[j][i])>abs(B[piv][i])) piv=j;
		rep(j,n+1) swap(B[i][j],B[piv][j]);

		// if(abs(B[i][i])<EPS) return false;

		for(int j=i+1;j<=n;j++) B[i][j]/=B[i][i];
		rep(j,n) if(i!=j) for(int k=i+1;k<=n;k++) B[j][k]-=B[j][i]*B[i][k];
	}

	rep(i,n) x[i]=B[i][n];
	return true;
}

int main(){
	int n,m; scanf("%d%d",&n,&m);
	bool G[10][10]={};
	int deg[10]={};
	rep(i,m){
		int u,v; scanf("%d%d",&u,&v); u--; v--;
		G[u][v]=G[v][u]=true;
		deg[u]++;
		deg[v]++;
	}

	vector<int> V; // 訪問済みの頂点集合としてありえるもの全体
	rep(S,1<<n){
		if((S&1)==0) continue;

		bool vis[10]={true};
		int Q[10],head=0,tail=0;
		Q[tail++]=0;
		while(head<tail){
			int u=Q[head++];
			rep(v,n) if(G[u][v] && !vis[v] && (S>>v)&1) {
				vis[v]=true;
				Q[tail++]=v;
			}
		}

		bool ok=true;
		rep(u,n) if(((S>>u)&1)!=vis[u]) ok=false;
		if(ok) V.push_back(S);
	}

	int k=0;
	vector< pair<int,int> > T; // ありうる状態の全体 ( 訪問済みの頂点集合と今いる頂点のペア )
	int id[1<<10][10]; // T の逆写像
	rep(i,V.size()) rep(u,n) if((V[i]>>u)&1) {
		T.push_back(make_pair(V[i],u));
		id[V[i]][u]=k++;
	}

	// dp[i] := 状態 i からスタートして全頂点を巡り終える時刻の期待値
	double dp[3000]={};
	rep(u,n) dp[id[(1<<n)-1][u]]=0; // S=(1<<n)-1 のとき ( DP の基底状態 )
	for(int S=(1<<n)-2;S>0;S--){
		int m=0,idx[3000];
		rep(u,n) if(S>>u&1) idx[id[S][u]]=m++;

		// S のみを訪問することがありえるかどうか
		bool ok=false;
		rep(i,k) if(T[i].first==S) ok=true;
		if(!ok) continue;

		double A[N_MAX][N_MAX]={},b[N_MAX]={},x[N_MAX];
		rep(u,n) if(S>>u&1) {
			// A, b を計算
			int i=id[S][u];
			rep(v,n) if(G[u][v]) {
				int S2=S;
				if(((S>>v)&1)==0) S2|=1<<v;
				if(S==S2){
					int j=id[S2][v];
					A[idx[i]][idx[j]]=-1.0/deg[u];
				}
				else{
					b[idx[i]]+=dp[id[S2][v]]/deg[u];
				}
			}
			A[idx[i]][idx[i]]=1;
			b[idx[i]]+=1;
		}

		Gauss_Jordan(m,A,b,x);

		rep(u,n) if(S>>u&1) dp[id[S][u]]=x[idx[id[S][u]]];
	}

	printf("%.9f\n",dp[0]);

	return 0;
}

Measured memory_bytes: 1228
using System;
using System.Collections.Generic;
using System.Linq;
public class Hello
{
    public static void Main()
    {
        var S = Console.ReadLine();
        var T = Console.ReadLine();
        var ans = 0;
        for (var chaCnt = 0; chaCnt < S.Length; chaCnt++)
        {
            if (S[chaCnt] != T[chaCnt])
            {
                ans++;
            }
        }Console.WriteLine(ans);
    }
}


Measured memory_bytes: 27364
solveImpl :: Int -> [String]
solveImpl 0 = []
solveImpl h = (cycle "#.") : (map (drop 1) $ solveImpl (h - 1))

solve :: [Int] -> [String]
solve [h,w] = map (take w) $ solveImpl h

main :: IO ()
main  = getContents
    >>= return . map (map read) . map words . lines
    >>= return . takeWhile (/= [0,0])
    >>= return . map solve
    >>= mapM_ (\ x -> mapM_ putStrLn x >> putStrLn "")

Measured memory_bytes: 4908
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <map>
#include <stack>
#include <bitset>
#include <numeric> //lcm
#include <iomanip> //double精度 setprecision

using namespace std;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = n-1; i >= 0; --i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)
#define rrep1(i,n) for(int i = (n); i >= 1; --i)
#define REP(i,n,m) for(int i = (n); i < (m); ++i)
#define all(vec) (vec).begin(),(vec).end()

#define debug(vec) for(auto v : vec) cerr << v << " "; cerr << endl;
#define debug2D(vec2D) for(auto vec : vec2D) { for (auto v : vec) cerr << v << " "; cerr << endl; } 
#define debugP(vec) for(auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl;
#define debug2DP(vec2D) for(auto vec : vec2D) { for (auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl; } 

typedef long long ll;

constexpr ll INF = 1000000000; //10^10
//const ll MOD = 998244353;
constexpr ll MOD = 1000000007;

template<class T> inline bool chmax(T& a, T b) { if (a <= b) { a = b; return true; } else return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } else return false; }


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

	ll n,x; cin >> n >> x;
	vector<ll> a(n);
	rep(i,n) cin >> a[i];

	ll ans = 0;
	rep(i, n-1) {
		if (a[i] + a[i+1] <= x) continue;

		ans += a[i] + a[i + 1] - x;
	  a[i+1] =  max(0LL, x - a[i]);
	}

	cout << ans << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <climits>
#include <algorithm>
#include <cstdlib>  // abs() for integer
#include <vector>
#include <tuple>

using namespace std;

long long N, X[1009], Y[1009], H[1009];
vector <tuple<long long, long long, long long>>vec;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
//    ダメだったやつ
//    int n;
//    cin >> n;
//    int x_c[n], y_c[n], height[n];
//
//    for(int i=0; i<n; i++){
//        cin >> x_c[i] >> y_c[i] >> height[i];
//    }
//
//    int c_x, c_y, trueheight = 100000;
//    bool flag = true;
//    for(int x=0; x<=100; x++){
//        for(int y=0; y<=100; y++){
//            int tmp_1;
//            int tmp_2;
//            for(int i=0; i<n-1; i++){
//                tmp_1 = height[i] + abs(x_c[i] - x) + abs(y_c[i] - y);
//                tmp_2 = height[i+1] + abs(x_c[i+1] - x) + abs(y_c[i+1] - y);
//                if(tmp_1 != tmp_2) {
//                    break;
//                }
//            }
//            if(trueheight > tmp_1){
//                c_x = x;
//                c_y = y;
//                trueheight = tmp_1;
//            }
//        }
//    }
//    cout << c_x << ' ' << c_y << ' ' << trueheight << '\n';

    cin >> N;
    tuple<long long, long long, long long>G = make_tuple(-1, -1, -1);

    for (int i=1; i<=N; i++){
        cin >> X[i] >> Y[i] >> H[i];
        if(H[i] >= 1) G = make_tuple(X[i], Y[i], H[i]);
    }
    for(int i=0; i<=100; i++){
        for(int j=0; j<=100; j++) {
            long long V = get<2>(G) + abs(get<0>(G) - i) + abs(get<1>(G) - j);
            V = max(V, 0LL);
            bool flag = true;
            for (int k = 1; k <= N; k++) {
                long long VV = V - abs(X[k] - i) - abs(Y[k] - j);
                VV = max(VV, 0LL);
                if (H[k] != VV) flag = false;
            }
            if(flag == true)
            vec.push_back(make_tuple(i, j, V));
        }
    }
    if(vec.size() == 1){
        cout << get<0>(vec[0]) << " " << get<1>(vec[0]) << " " << get<2>(vec[0]) << endl;
    }
    return 0;
}

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

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = null;
		for (int i = 1; (line = br.readLine()) != null; i++) {
			if ("0".equals(line)) break;
			System.out.println("Case " + i + ": " + line);
		}
	}
}

Measured memory_bytes: 27896
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#define f first
#define s second
using namespace std;
typedef long long ll;
const ll limit=1e6+2;
const ll maxN=1e9+2;
string s,st,st1;
bool f[limit];
long long t,n,x,test,d=0,tp=0,mp=0,temp=2,l,r,m,res=0,k;
long long b[limit],mi[limit],a[limit];

int main()
{
    for(ll i=1;i<=200;i++)
    {
        b[i]=0;
    }
    cin>>n>>k;
    for(ll i=1;i<=k;i++)
    {
        cin>>d;
        for(ll j=1;j<=d;j++)
        {
            cin>>a[j];
            b[a[j]]=1;
        }
    }
    for(ll i=1;i<=n;i++)
    {
        if(b[i]==0) res++;
    }
    cout<<res;
}


Measured memory_bytes: 3652
#include "bits/stdc++.h"
using namespace std;
int main(){
    string S,T;
    cin >> S >> T;
    int n = T.size();
    int i,j,k,a,b;
    char c;
    vector< vector<int> > s(26),t(26);
    for(i = 0;i<n;i++){
        c = S.at(i);
        s.at(c-'a').push_back(i);
        c = T.at(i);
        t.at(c-'a').push_back(i);
    }
    for(i=0;i<26;i++){
        a = s.at(i).size();
        if(a){
            for(j=0;j<26;j++){
                b = t.at(j).size();
                if(b){
                    if(t.at(j).at(0)!=s.at(i).at(0)) continue;
                    if(a != b){
                        cout << "No" << endl;
                        return 0;
                    }
                    for(k=0;k<b;k++){
                        if(s.at(i).at(k)!=t.at(j).at(k)){
                            cout << "No" << endl;
                            return 0;
                        }
                    }
                    break;
                }
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3080
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
using namespace std;
using ll = long long;
using ld = long double;

constexpr int MOD=1000000007;
//constexpr int MOD=998244353;
class modint{
public:
  long long x;
  constexpr modint(long long x=0):x((x%MOD+MOD)%MOD){}
  constexpr modint operator-() const{return modint(-x);}
  constexpr modint& operator+=(const modint& a){
    if((x+=a.x)>=MOD) x-=MOD;
    return *this;
  }
  constexpr modint& operator-=(const modint& a){
    if((x+=MOD-a.x)>=MOD) x-=MOD;
    return *this;
  }
  constexpr modint& operator*=(const modint& a){
    (x*=a.x)%=MOD;
    return *this;
  }
  constexpr modint operator+(const modint& a) const{return modint(*this)+=a;}
  constexpr modint operator-(const modint& a) const{return modint(*this)-=a;}
  constexpr modint operator*(const modint& a) const{return modint(*this)*=a;}
  constexpr bool operator==(const modint& a) const{return this->x==a.x;}
  constexpr bool operator!=(const modint& a) const{return this->x!=a.x;}
  constexpr modint pow(long long expo) const{
    if(expo==0)  return 1;
    modint a=pow(expo>>1);
    a*=a;
    if(expo&1)  a*=(*this);
    return a;
  }
  //for prime MOD
  constexpr modint inv() const{return pow(MOD-2);}
  constexpr modint& operator/=(const modint& a){return (*this)*=a.inv();}
  constexpr modint operator/(const modint& a) const{return modint(*this)/=a;}
};
istream& operator>>(istream& is,const modint& a){return is >> a.x;}
ostream& operator<<(ostream& os,const modint& a){return os << a.x;}

int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  int N;
  cin >> N;
  vector<vector<int>> a(N,vector<int>(N));
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      cin >> a.at(i).at(j);
    }
  }

  vector<modint> dp((1<<(N)),0);
  dp.at(0)=1;
  for(int bit=0;bit<(1<<(N));bit++){
    bitset<25> s(bit);
    for(int i=0;i<N;i++){
      if(s.test(i))  continue;
      if(a.at(s.count()).at(i)==1) dp.at(bit|(1<<i))+=dp.at(bit);
    }
  }
  cout << dp.at((1<<(N))-1) << endl;
  //for(int bit=0;bit<(1<<(N));bit++) cout << bit << " " << dp.at(bit) << endl;

  return 0;
}

Measured memory_bytes: 16768
from collections import deque

def main():
    n=int(input())
    a=[tuple(map(int,input().split())) for _ in range(2)]
    dp=[[0]*n for _ in range(2)]
    dp[0][0] = a[0][0]
    q = deque([(0,0)])
    while len(q) > 0:
        cur = q.popleft()
        #print("cur", cur)
        for s in nextstep(cur, n):
            #print(s, end="")
            dp[s[0]][s[1]] = max(dp[s[0]][s[1]], dp[cur[0]][cur[1]]+a[s[0]][s[1]])
            q.append(s)
            #print(dp)
    print(dp[-1][-1])

def nextstep(cur, m):
    if cur[0] == 0:
        yield (1, cur[1])
    if cur[1] < m-1:
        yield (cur[0], cur[1] + 1)

if __name__ == "__main__":
    main()

Measured memory_bytes: 9412
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<n; ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
typedef long long ll;

int main(){
    int n,m;cin>>n>>m;
    set<int> a;rep(i,m){int tmp; cin>>tmp; a.insert(tmp);}
    vector<int> stairs(n+1,0);
    stairs[0] = 1; if(a.count(1) == 0)stairs[1] = 1;
    for(int i = 2; i<=n; i++){
        if(a.count(i)==0){
            stairs[i] = (stairs[i-1]+stairs[i-2])%MOD;
        }
    }
    cout<<stairs[n]<<endl;return 0;
}


Measured memory_bytes: 5376
//package Atcoder;

import java.util.*;
import java.io.*;
public class Main
{
	static final int mod=(int)1e9+7;
	static final int inf=(int)1e9;
	static final long INF=(long)1e18;
	public static void main(String[] args)
	{
		FastScanner fs=new FastScanner();
		int n=fs.nextInt();
		long s=0;
		for(int i=1;i<=n;i++)
		{
			if(i%3!=0 && i%5!=0)
			{
				s+=i;
			}
		}
		System.out.println(s);
	}
}
class FastScanner 
{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");
		public String next() 
		{
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
			
		}
		
		long pow(long x,long n)
		{
			long res=1;
			while(n>0)
			{
			   	if(n%2!=0)
			   	{
			   		res=(res*x);n--;
			   	}
			   	else
			   	{
			   		x=(x*x);n/=2;
			   	}
			}
			return res;
		}
		int gcd(int a,int b)
		{
			if(b==0)
			{
				return a;
			}
			return gcd(b,a%b);
		}
		long longgcd(long a,long b)
		{
			if(b==0)
			{
				return a;
			}
			return longgcd(b,a%b);
		}
		int[] sort(int arr[])
		{
			ArrayList<Integer> list = new ArrayList<Integer>();
			for(int i:arr)list.add(i);
			Collections.sort(list);
			for(int i=0;i<arr.length;i++)
			{
				arr[i]=list.get(i);
			}
			return arr;
		}
		char[] charsort(char arr[])
	        {
	    	ArrayList<Character> list = new ArrayList<>();
	    	for(char c:arr)list.add(c);
	    	Collections.sort(list);
	    	for(int i=0;i<list.size();i++)
	    	{
	    		arr[i]=list.get(i);
	    	}
	    	return arr;
	        }
		long[] longsort(long arr[])
		{
			ArrayList<Long> list = new ArrayList<Long>();
			for(long i:arr)list.add(i);
			Collections.sort(list);
			for(int i=0;i<arr.length;i++)
			{
				arr[i]=list.get(i);
			}
			return arr;
		}
		public int nextInt() 
		{
			return Integer.parseInt(next());
		}
		public int[] readArray(int n)
		{
			int[] arr=new int[n];
			for (int i=0; i<n; i++) arr[i]=nextInt();
			return arr;
		}	
		public long nextLong()
		{
			return Long.parseLong(next());
		}
		public long[] longreadArray(int n) 
		{
			long[] a=new long[n];
			for (int i=0; i<n; i++) a[i]=nextLong();
			return a;
		}
}

Measured memory_bytes: 32732