akhauriyash/Code-Regression huggingface dataset:
// https://www.geeksforgeeks.org/longest-repeating-and-non-overlapping-substring/
// C++ program to find the longest repeated 
// non-overlapping substring 
#include<bits/stdc++.h> 
using namespace std; 

// Returns the longest repeating non-overlapping 
// substring in str 
string longestRepeatedSubstring(string str) 
{ 
   int n = str.length(); 
   int LCSRe[n+1][n+1]; 

   // Setting all to 0 
   memset(LCSRe, 0, sizeof(LCSRe)); 

   string res; // To store result 
   int res_length = 0; // To store length of result 

   // building table in bottom-up manner 
   int i, index = 0; 
   for (i=1; i<=n; i++) 
   { 
      for (int j=i+1; j<=n; j++) 
      { 
         // (j-i) > LCSRe[i-1][j-1] to remove 
         // overlapping 
         if (str[i-1] == str[j-1] && 
            LCSRe[i-1][j-1] < (j - i)) 
         { 
            LCSRe[i][j] = LCSRe[i-1][j-1] + 1; 

            // updating maximum length of the 
            // substring and updating the finishing 
            // index of the suffix 
            if (LCSRe[i][j] > res_length) 
            { 
               res_length = LCSRe[i][j]; 
               index = max(i, index); 
            } 
         } 
         else
            LCSRe[i][j] = 0; 
      } 
   } 

   // If we have non-empty result, then insert all 
   // characters from first character to last 
   // character of string 
   if (res_length > 0) 
      for (i = index - res_length + 1; i <= index; i++) 
         res.push_back(str[i-1]); 

   return res; 
} 

// Driver program to test the above function 
int main() 
{ 
   string str = "geeksforgeeks"; 
   int n;
   cin >> n;
   cin >> str;
   cout << longestRepeatedSubstring(str).size(); 
   return 0; 
} 


Measured memory_bytes: 97920
#include<bits/stdc++.h>
using namespace std;
int main(void) {
  long long int n, m;
  cin >> n >> m;
  long long int prod = n * m;
  long long ans = prod / 2;
  if(prod & 1) {
    ans++;
  }
  if(n == 1 || m == 1) {
    cout<<"1\n";
  } else {
  	cout << ans << "\n";
  }
}

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

int n, A[20];
bool flg[40002];

void rec(int idx, int sum){
  if(idx == n){
    flg[sum] = true;
    return;
  }

  rec(idx + 1, sum);
  rec(idx + 1, sum + A[idx]);
}

void makeFlg(){
  for(int i = 0; i < 40002; i++){
    flg[i] = false;
  }
  rec(0, 0);
}

int main(){
  while(cin >> n){
    for(int i = 0; i < n; i++){
      cin >> A[i];
    }

    makeFlg();

    int q;
    cin >> q;

    for(int i = 0; i < q; i++){
      int M;
      cin >> M;

      if(flg[M]){
        cout << "yes" << endl;
      }
      else{
        cout << "no" << endl;
      }
    }
  }
}

Measured memory_bytes: 1196
#include <stdio.h>

int main()
{
  int n, u, k, v, i, j, A[101][101];

  scanf("%d", &n);

  for (i = 1; i <= n; i++)
  {
    for (j = 1; j <= n; j++)
    {
      A[i][j] = 0;
    }
  }

  for (i = 1; i <= n; i++)
  {
    scanf("%d%d", &u, &k);

    for (j = 1; j <= k; j++)
    {
      scanf("%d", &v);
      A[u][v] = 1;
    }
  }
  for (i = 1; i <= n; i++)
  {
    for (j = 1; j < n; j++)
    {
      printf("%d ", A[i][j]);
    }
    printf("%d\n", A[i][j]);
  }
  return 0;
}



Measured memory_bytes: 2128
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
typedef long long ll;
const ll longinf=1LL<<60;
using namespace std;
int n,k;
int s[120000];
char c;
struct st
{
    int len, flag;
};

st bk[120000];
int t=0;

int main()
{
    cin>>n>>k;
    for (int i=1; i<=n; ++i)
    {
        scanf("%c",&c);
        while  (c!='0' && c!='1') 
            scanf("%c",&c);
        s[i]=c-'0';
        if (t==0 || s[i]!=s[i-1])
        {
            t+=1;
            bk[t].len=1;
            bk[t].flag=s[i];
        }else
        {
            bk[t].len++;
        }
    }
    int now_rev = 0;
    int start_pos = 0;
    int end_pos = 0;

    int ans = 0;
    int tans = 0;

    if (bk[1].flag == 0)
    {
        bk[0].flag=1;
        start_pos=0;
    }else
    {
        start_pos=1;
    }
    for (int i=1; i<=t; ++i)
    {
        if (bk[i].flag == 0 && now_rev<k)
        {
            tans += bk[i].len;
            now_rev+=1;
        }else if (bk[i].flag==0 && now_rev==k)
        {
            if (bk[start_pos].flag==0)
            {
                tans-=bk[start_pos].len;
                start_pos+=1;
            }else 
            {
                tans-=bk[start_pos].len;
                start_pos+=1;
                tans-=bk[start_pos].len;
                start_pos+=1;
            }
            tans += bk[i].len;
        }else if (bk[i].flag == 1)
        {
            tans += bk[i].len;
        }
        ans = max(ans,tans);
    }
    cout<<ans<<endl;



    return 0;
}



Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
const int INF = 1e15;

signed main(){
    int n;
    cin >> n;
    if(n % 2) cout << n * 2 << endl;
    else cout << n << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

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

const ll INF = 1LL << 60;

int dp[101][4][4][4];//dp[n][i][j][k]: .....ijk で表される長さ n の文字列の個数

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

  // A->0 G->1 C->2 T->3
  //?012 ?102 ?021 0?12 01?2 はダメ
  dp[0][3][3][3] = 1;// 初期条件
  rep(len, n) rep(i, 4) rep(j, 4) rep(k, 4){
    // 文字列.....ijk ->......ijka とするイメージ
    rep(a, 4){
      if(j == 0 && k == 1 && a == 2) continue;
      if(j == 1 && k == 0 && a == 2) continue;
      if(j == 0 && k == 2 && a == 1) continue;
      if(i == 0 && k == 1 && a == 2) continue;
      if(i == 0 && j == 1 && a == 2) continue;
      dp[len+1][j][k][a] += dp[len][i][j][k];
      dp[len+1][j][k][a] %= MOD;
    }
  }

  int ans = 0;
  rep(i, 4) rep(j, 4) rep(k, 4){
    ans += dp[n][i][j][k];
    ans %= MOD;
  }
  std::cout << ans << '\n';
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
struct node{
	int a, b;
	int tot;
};
node peo[500005];
int cmp(node x, node y){
	if (x.tot>y.tot)
		return true;
	return false;
}
int main()
{
	int n;
	cin >> n;
	for (int i=1;i<=n;i++){
		cin >> peo[i].a >> peo[i].b;
		peo[i].tot=peo[i].a+peo[i].b;
	}	
	sort(peo+1,peo+n+1,cmp);
	long long ans=0;
	for (int i=1;i<=n;i++){
		if (i%2==1) ans+=peo[i].a;
		else ans-=peo[i].b;
	}
	cout << ans;
	return 0;
} 

Measured memory_bytes: 1408
import sys
readline = sys.stdin.readline

N = int(readline())
A = list(map(int,readline().split()))

# Rが答えだとすると、
# R[0] + R[1] + ... R[N] = A[0] + A[1] + ... A[N] (雨の総量は一定のため)
# A[1] = (R[1] + R[2]) / 2
# R[1] + R[2] = A[1] * 2
# R[i] + R[i + 1] = A[i] * 2
# Nが奇数なので、
# R[0] + R[1] + R[2] + R[3] + R[4] + ... + R[N-1] + R[N] = sum(A)
# R[0] + (R[1] + R[2]) + (R[3] + R[4]) + ... + (R[N - 1] + R[N]) = sum(A)
# R[0] + A[1] * 2 + A[3] * 2 + ... + R[N - 1] * 2 = sum(A)
# R[0] = sum(A) - (A[1] * 2 + A[3] * 2 + ... + R[N - 1] * 2)

R = [0] * N
R[0] = sum(A)
for i in range(1, len(A), 2):
  R[0] -= A[i] * 2

# R[i]が求められれば、R[i + 1]は
# R[i + 1] = A[i] * 2 - R[i]
# で求めることが出来る

for i in range(len(A)-1):
  R[i + 1] = A[i] * 2 - R[i]
  
print(*R)

Measured memory_bytes: 14124
# include <bits/stdc++.h>
# define int long long
# define endl "\n"
using namespace std;

void solve() {

	int n, d, x, y, count = 0;
	cin >> n >> d;
	while (n--) {
		cin >> x >> y;
		if (x * x + y * y <= d * d) {
			count++;
		}
	}
	cout << count << endl;
}
signed main() {

	ios_base::sync_with_stdio(0);
	cin.tie(0);

# ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
# endif

	// int t;
	// cin >> t;
	// while (t--)
	solve();

	return 0;
}

Measured memory_bytes: 3648
#include <stdio.h>
#include <stdlib.h>

int main()
{
    long long n,i,q,j,b,c,input;
    long long out = 0;
    scanf("%lld",&n);
    int a[200000]={0};
    for(i=0;i<n;i++){
        scanf("%lld",&input);
        a[input]++;
        out = out+input;
    }
    scanf("%lld",&q);
    for(i=0;i<q;i++){
        scanf("%lld %lld",&b,&c);
        if(a[b]==0) out = out;
        else{
            out = out+(c-b)*a[b];
            a[c] = a[c]+a[b];
            a[b] = 0;
        }
        printf("%lld\n",out);
    }
    return 0;
}


Measured memory_bytes: 2480
/*
   Created by Rahul Goel.
*/
/*******************************************************************************/
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
/*******************************************************************************/
using namespace std;
using ll = long long;
using ld = long double;
ll mod = 1000000007;
const int INF = 1e9;
const ll LINF = 1e18;
/*******************************************************************************/
/*
.-.. . -. -.- .- / .. ... / .-.. --- ...- . -.-.--
 */
/* For PBDS */
/*Two new methods X.order_of_key() and X.find_by_order()*/
/*
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/

/*******************************************************************************/
ll mod_sum() { return 0LL; }
template<typename T, typename... Args>
T mod_sum(T a, Args... args) { return ((a + mod_sum(args...))%mod + mod)%mod; }

ll mod_prod() { return 1LL; }
template<typename T, typename... Args>
T mod_prod(T a, Args... args) { return (a*mod_prod(args...))%mod; }
/*******************************************************************************/
using pii = pair < ll, ll >;
using vi = vector < ll >;
using vb = vector < bool >;
using vvi = vector < vector < ll > >;
using vvb = vector < vector < bool > >;
using vpii = vector < pii >;
using vvpii = vector < vector < pii > >;
#ifdef ONLINE_JUDGE
#define endl '\n'
#endif
#define fastio          ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define all(c)          (c).begin(), (c).end()
#define present(c,x)    ((c).find(x) != (c).end())
#define cpresent(c,x)   (find(all(c),x) != (c).end())
#define uniq(c)         (c).resize(distance((c).begin(), unique(all(c))))
#define min_pq(t)       priority_queue < t, vector < t >, greater < t > >
#define max_pq(t)       priority_queue < t >
#define pb              push_back
#define ff              first
#define ss              second
/*******************************************************************************/

/*
    Code begins after this.
*/


ll solve(){
    ll n;
    cin >> n;
    vi a, b;
    a = b = vi(n);
    for(ll i=0; i<n; i++)
        cin >> a[i] >> b[i];
    sort(all(a));
    sort(all(b));
    if(n&1){
        ll x = a[n/2];
        ll y = b[n/2];
        cout << y - x + 1 << endl;
    }
    else{
        ll x = a[n/2] + a[n/2 - 1];
        ll y = b[n/2] + b[n/2 - 1];
        cout << y - x + 1 << endl;
    }
    return 0;
}


signed main(){
    fastio;

    ll t = 1;
    while(t--)
        solve();

    return 0;
}

/*******************************************************************************/
// Remeber - In a custom comparator cmp(a, b) a==b must always return to false.


Measured memory_bytes: 6376
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<string>
#include<unordered_map>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j,k
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define sort(a) sort(a.begin(),a.end())
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define sizeoof(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
double ans=0;llfor;///////////////////////////////////////////////////////////
int main(){
 ll n,m;sc(n);sc(m);
 ans=double(n)/double(m);
 printf("%.9lf\n",ans);
return 0;}

Measured memory_bytes: 3760
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    ll N, K; cin >> N >> K;
    vector<ll> A(N);
    rep(i,N) cin >> A.at(i);
    int i = 0;
    int j = i + K;
    rep(k, N-K) {
        if (A[i] < A[j]) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
        i++, j++;
    }
}


Measured memory_bytes: 4840
import heapq

n, m = map(int, input().split())
a = [-int(i) for i in input().split()]
heapq.heapify(a)

for i in range(m):
    k = heapq.heappop(a)
    heapq.heappush(a, -int(-(k / 2) // 1))
print(-sum(a))

Measured memory_bytes: 16200
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int N;
    cin >> N;
    string S;
    cin >> S;

    int r = 0;
    rep(i, N) {
        if (S[i] == 'R') r++;
    }

    int w = 0;
    rep(i, r) {
        if (S[i] == 'W') w++;
    }

    cout << w << endl;
    return 0;
}

Measured memory_bytes: 3720
#include<cstdio>
#include<algorithm>
using namespace std;
char s[5];
int tot;
bool f[3];
int main()
{
	scanf("%s",s);
	for(int i=0;i<3;i++)
		f[s[i]-'a']=1;
	for(int i=0;i<3;i++)
		tot+=f[i];
	printf("%s",tot==3?"Yes":"No");
}

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

int main(){
    int N,R,G,B;

    cin >> R >> G >> B >> N;
 
    int ans = 0;

    for(int i = 0; i <= N/R; i++) {
        if(N - R*i < 0)break;
        for (int j = 0; j <= N/G; j++){
            if(N - R*i - G*j < 0)break;
            if((N - R*i - G*j) % B == 0)ans++;
        }
        
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <map> 
#include <unordered_map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL H,W;
LL Ch,Cw;
LL Dh,Dw;
string S[1000];

LL ans = 0;

//上下左右の順
int dh[4] = {-1,1,0,0};
int dw[4] = {0,0,-1,1};
bool chk_external(int h,int w){
	return (h>=0 && h<H && w>=0 && w<W);
}

void solve(){
	//tuple<(h,w)に行くのに必要な魔法使用回数,h,w>
	priority_queue<tuple<LL,LL,LL>,vector<tuple<LL,LL,LL>>,greater<tuple<LL,LL,LL>>> pq;
	pq.push(tuple<LL,LL,LL>(0,Ch,Cw));
	//(h,w)に行くのに必要な魔法使用回数をmagic[h][w]とおく
	vector<vector<LL>> magic(H,vector<LL>(W,INF));
	magic[Ch][Cw] = 0;
	while(!pq.empty()){
		LL now_magic_counter = get<0>(pq.top());
		LL now_h = get<1>(pq.top());
		LL now_w = get<2>(pq.top());
		pq.pop();
		//歩きで移動
		for(int i=0;i<4;i++){
			LL next_h = now_h + dh[i];
			LL next_w = now_w + dw[i];
			if(!chk_external(next_h,next_w)) continue;
			if(S[next_h][next_w]=='#') continue;
			if(magic[next_h][next_w]>now_magic_counter){
				magic[next_h][next_w] = now_magic_counter;
				pq.push(tuple<LL,LL,LL>(now_magic_counter,next_h,next_w));
			}
		}
		//魔法で移動
		for(int mh=-2;mh<=2;mh++){
			for(int mw=-2;mw<=2;mw++){
				LL next_h = now_h + mh;
				LL next_w = now_w + mw;
				LL next_magic_counter = now_magic_counter + 1;
				if(!chk_external(next_h,next_w)) continue;
				if(S[next_h][next_w]=='#') continue;
				if(magic[next_h][next_w]>next_magic_counter){
					magic[next_h][next_w] = next_magic_counter;
					pq.push(tuple<LL,LL,LL>(next_magic_counter,next_h,next_w));
				}
			}
		}
	}
	ans = magic[Dh][Dw];
	if(ans==INF) ans = -1;
}

int main(){
    cin >> H >> W;
    cin >> Ch >> Cw;
    cin >> Dh >> Dw;
    Ch--;Cw--;Dh--;Dw--;
    for(int h=0;h<H;h++) cin >> S[h];

    solve();

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 12768
#include <stdio.h>
#include <stdlib.h>
int count=0;
int dequeue(void);
void enqueue(int);
void visit(int u, int *jude, int *d, int *f, int size);
int d[101], f[101],jude[101], Q[101];
int matrix[101][101];
int head=0,tail = 0;
int max(int size,int *degree);
int main(int argc, char** argv) {
    int size;
    scanf("%d", &size);
    int degree[size];
    for(int i=0;i<size;i++)
    {
        jude[i]=0; 
        for(int j=0;j<size;j++)
        {
            matrix[i][j]=0;
        }
    }
    
    
    int temp, a;
    for(int i=0;i<size;i++)
    {
        scanf("%d %d",&temp, &degree[i]);
        for(int j=0;j<degree[i];j++)
        {
            scanf("%d", &a);
            matrix[temp-1][a-1]=1;
        }
    }
    for(int i=0;i<size;i++)
    {
        if(matrix[0][i]==1)
            jude[i]=0;
    }
    jude[0]=1;
    int distant[size];
    distant[0]=0;
    enqueue(0);
    
    int tempu;
    while(head!=tail)
    {
        tempu=dequeue();
        for(int i=0;i<size;i++){
        if(matrix[tempu][i]==1 && jude[i]==0){
	jude[i]=1;
	distant[i]=distant[tempu]+1;
	enqueue(i);
      }
      jude[tempu]=2;
    }
  }
    
    /*for(int i=0;i<size;i++)
    {
        if(jude[i]==0)
            visit(i,jude,d,f, size);
    }*/
    
    
    for(int i=0;i<size;i++)
    {
        if(jude[i]==2)
            printf("%d %d\n", i+1, distant[i]);
        else
            printf("%d -1\n", i+1);
    }
  
    return (EXIT_SUCCESS);
}

/*void visit(int u, int *jude, int *d, int *f, int size)
{
  int i;
  jude[u]=1;
  d[u]=++count;
  for(i=0;i<size;i++){
    if(matrix[u][i]==1)
    {
      if(jude[i]==0)
          visit(i, jude, d, f, size);
    }
  }
  jude[u]=2;
  f[u]=++count;
}*/

int max(int size,int *degree)
{
    int max=0;
    for(int i=0;i<size;i++)
    {
        if(degree[i] > max)
            max = degree[i];
    }
    return max;
}
int dequeue()
{
  int x;
  x=Q[head];
  if(head+1==100)head=0;
  else head=head+1;
  return x;
}

void enqueue(int x)
{
  Q[tail]=x;
  if(tail+1==100)tail=0;
  else tail=tail+1;
}


Measured memory_bytes: 2060
#include <iostream>
using namespace std;
int main(void){
    
    //変数：生徒の人数 「 n 」と置く
    int n;
    //変数：数学の点数「 mathematical 」、英語の点数「 english 」、国語の点数「 national 」と置く
    int mathematical, english, national;

    while(cin >> n, n){
        
        //繰返し：生徒数分、繰返しする
        for(int i = 0; i < n; i++){
        //条件：クラス分けの判断は問題見て
        cin >> mathematical >> english >> national;
            if( mathematical == 100 || english == 100 || national == 100 ) cout << "A" << endl;
            else if( 90 <= (mathematical + english) / 2 ) cout << "A" << endl;
            else if( 80 <= (mathematical + english + national) / 3 ) cout << "A" << endl;
            else if( 70 <= (mathematical + english + national) / 3 ) cout << "B" << endl;
            else if( 50 <= (mathematical + english + national) / 3 && 80 <= mathematical || 80 <= english ) cout << "B" << endl;
            else cout << "C" << endl;
        }
    }
    
    
}



Measured memory_bytes: 3084
using System;
using System.IO;

namespace CA {
	class Prg {
		static void Main() {
			using (var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }) {
				while (true) {
					var str = Console.ReadLine().Split(' ');
					var h = int.Parse(str[0]);
					var w = int.Parse(str[1]);

					if (h == 0 && w == 0) break;
					for (var i = 1; i <= h; i++) {
						for (var j = 1; j <= w; j++) {
							sw.Write((i + j) % 2 == 0 ? '#' : '.');
						}
						sw.WriteLine();
					}
					sw.WriteLine();
				}
			}
        }
	}
}

Measured memory_bytes: 8832
from functools import reduce
n  = int(input())
data = [int(input()) for x in range(n)]




def gcd(a, b):
    """Return greatest common divisor using Euclid's Algorithm."""
    while b:      
        a, b = b, a % b
    return a

def lcm(a, b):
    """Return lowest common multiple."""
    return a * b // gcd(a, b)

def lcmm(*args):
    """Return lcm of args."""   
    return reduce(lcm, args)

print(lcmm(*data))

Measured memory_bytes: 3700
#!/usr/bin/env python3
import sys


def solve(X: int):
    print(X//500 * 1000 + (X%500) // 5 * 5)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    solve(X)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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

int main() {
    ll N, M;
    ll MOD = 1e9 + 7;
    cin >> N >> M;
    ll ans = 0;
    for(ll i = M; i <= N + 1; i++){
        ll tmp = (N * i - i * (i - 1) + 1) % MOD;
        ans = (ans + tmp) % MOD;
    }

    cout << ans << endl;
    return 0;
}


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


int main(){
		
	int n,W;
	cin>>n>>W;
	vector<long long int> dp(W+1,0);
	for(int i=0;i<n;i++){
		int w,v;
		cin>>w>>v;
		for(int j=W;j>=0;j--){
			if(j>=w){
				dp[j]=max(dp[j-w]+v,dp[j]);
			}
		}
	}
	cout<<dp[W]<<endl;
	
	
	/*
	int n,W;
	cin>>n>>W;
	vector<vector<long long int> > dp(n+1,vector<long long int>(W+1,0));
	vector<int> w(n),v(n);
	for(int i=0;i<n;i++){
		cin>>w[i]>>v[i];
	}
	for(int i=1;i<=n;i++){
		for(int j=0;j<(W+1);j++){
			if(w[i-1]>j){
				dp[i][j]=dp[i-1][j];
			}
			else{
				dp[i][j]=max(v[i-1]+dp[i-1][j-w[i-1]],dp[i-1][j]);
			}
		}
	}
	cout<<dp[n][W]<<endl;*/
	return 0;
}

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

int h[110];

int main() {
    int N, max_h = 0;
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> h[i];
        max_h = max(max_h, h[i]);
    }
    int ans = 0;
    for (int i = 0; i < max_h; i++) {
        bool prev_zero = true;
        for (int j = 0; j < N; j++) {
            if (h[j] > 0) {
                h[j]--;
                if (prev_zero) {
                    ans++;
                    prev_zero = false;
                }
            }
            else {
                prev_zero = true;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define all(sdk) sdk.begin(),sdk.end()
#define mll map<int, int>
#define pb push_back
#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 mp make_pair
#define hell 1000000007
#define endl '\n'
#define vvll vector<vector<int> >
#define vll vector<int>
#define mint map<int,int> 
#define sz(x) (int)x.size()
#define sll set<int>
#define pll pair<int,int>
#define F first
#define S second

int n;
int arr[405];
int dp[405][405];
int prefsum[405];

int find(int l, int r){
	if(l>r)
		return 0;
	if(dp[l][r]!=-1)
		return dp[l][r];

	if(l==r)
		return 0;

	int ans=1e18;
	rep(i,l,r){
		ans=min(ans,find(l,i) + find(i+1,r) + prefsum[r+1] - prefsum[l]);
	}
	return dp[l][r]=ans;
}

void solve(){
	
	cin>>n;
	rep(i,0,n)
		cin>>arr[i];

	memset(dp, -1, sizeof dp);
	prefsum[0]=0;
	prefsum[1] = arr[0];
	rep(i,1,n){
		prefsum[i+1] = prefsum[i] + arr[i];
	}
	cout<<find(0,n-1)<<endl;
	
}
signed main(){
    //freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    srand (static_cast <unsigned> (time(0)));
    int t=1;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
int main(){
  string a;
  cin >> a;
  vector<int> english(200);
  for(int i = 0;i<a.size();i++){
    int b = a.at(i);
    english.at(b)++;
  }
  int flag = 0;
  for(int i = 0;i<200;i++){
    if(english.at(i)%2 == 1)
      flag = 1;
  }
  if(flag == 1)
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <list>
#include <math.h>
#include <vector>
#include <algorithm>
#include<iomanip>
#include <unordered_map> 
#include <queue>
#include <tuple>

using namespace std;
typedef long long ll;
typedef pair<int, int> pp;

#define MOD 1000000007


int main() {

  int N;

  unordered_map<int, vector<int>> mp;
  map<tuple<int,int>, int> color;

  int A[100001];
  int B[100001];

  cin >> N;
  for (int i=1; i < N; i++) {
    int a, b;
    cin >> a >> b;
    A[i] = a;
    B[i] = b;
    mp[a].push_back( b );
    mp[b].push_back( a );
    if(b < a) {
      int tmp = a;
      a = b;
      b = tmp;
    }
    color[make_tuple(a,b)] = 0;
  }

  queue<pair<int,int>> que;
  que.push(make_pair(1,0));

  int max = 0;

  while(!que.empty()) {
    int a = que.front().first;
    int color_ = que.front().second;
    que.pop();
    //cout << a << endl;

    int tmp_color[100001] = { 0 };
    int k = 1;
    for(int i = 0; i < mp[a].size(); i++) {
      int b = mp[a][i];
      int a_ = a;
      int b_ = b;
      if(b < a) {
        a_ = b;
        b_ = a;
      }
      if(color[make_tuple(a_,b_)]!=0){
        continue;
      }
      if(k == color_) k++;
      color[make_tuple(a_,b_)] = k;
      tmp_color[k] = 1;

      if(max <= k) {
        max = k;
      }
      que.push(make_pair( b, k ));
      k++;
    }
  }

  cout << max << endl;

  for (int i = 1; i < N; i++) {
    int a = A[i];
    int b = B[i];
    if(B[i] < A[i]) {
      b = A[i];
      a = B[i];
    }
    cout << color[make_tuple(A[i],B[i])] << endl;
  }

  //for float, double precision
  //cout << std::fixed << setprecision(15);
  return 0;

}


Measured memory_bytes: 16548
#include <iostream>
#include <cmath>
#include <algorithm>
#include <set>
#include <vector>
using namespace std;
int main() {
    int N; cin >> N;
    set<char> S;
    for (int i = 0; i < N; ++i) {
        char c; cin >> c; S.insert(c);
    }
    if (S.size() == 3) printf("%s\n", "Three");
    else printf("%s\n", "Four");
}


Measured memory_bytes: 3560
#include <bits/stdc++.h>
#define sanyes ios_base::sync_with_stdio(0), cout.tie(0); cin.tie(0);
#define llong long long int
#define pb push_back
#define bpc __builtin_popcount
#define f first
#define s second

const llong mxn = 1e5 + 7;
const llong mod = 1e9 + 7;
const llong inf = 1e18 + 9;

using namespace std;

llong n, ans = 0, l;
string s, t;

int main(){
    cin >> n;
    cin >> s >> t;
    ans = 2 * n;
    for (int i = 0; i < n; i ++){
        if(s.substr(i, n - i) == t.substr(0, n - i)){
            l = (n - i);
            break;
        }
    }cout << ans - l;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <string>
#define range(i, n) for (int i = 0; i<n; i++)
using namespace std;
using ll = long long;
int main(){
    string S, T;
    cin >> S;
    cin >> T;
    int count = 0;
    for (int i = 0; i < S.length(); i++){
        if (S[i] == T[i]){
            count ++;
        }
    }
    cout << S.length() - count;
    return 0;
}

Measured memory_bytes: 3896
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  string s,t;
  cin>>s>>t;
  int dp[2][t.size()+1];
  memset(dp,0,sizeof(dp));
  for(int x=0;x<2;x++){
    queue<int> q[26];
    for(int i=0;i<(int)s.size();i++)
      q[s[i]-'a'].push(i);
    int p=0,f=0;
    for(int i=0;i<(int)t.size();i++){
      int c=t[i]-'a';
      while(!q[c].empty()&&q[c].front()<p) q[c].pop();
      if(q[c].empty()){
	f=1;
	break;
      }
      p=q[c].front();q[c].pop();
      dp[x][i]=p;
    }
    if(f){
      cout<<"no"<<endl;
      return 0;
    }
    if(x) break;
    reverse(s.begin(),s.end());
    reverse(t.begin(),t.end());
  }
  int f=1;
  for(int i=0;i<(int)t.size();i++){
    //cout<<dp[1][i]+1<<" "<<(s.size()-dp[0][t.size()-(i+1)])<<endl;
    f&=(dp[1][i]+1)==(s.size()-dp[0][t.size()-(i+1)]);
  }
  cout<<(f?"yes":"no")<<endl;
  return 0;
}

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

template <typename T>
struct Heap {
	Heap *l, *r;
	T val;
	Heap() {}
	Heap(T v) : l(nullptr), r(nullptr), val(v) {}
	void Init(int v) {
		l = nullptr; r = nullptr; val = v;
	}
};
Heap<int> pool[2000000];
int it;

class Priority_Queue {
	Heap<int>* root;
	Heap<int>* meld(Heap<int>* a, Heap<int>* b) {
		if (a == nullptr) return b;
		if (b == nullptr) return a;
		if (a->val < b->val) swap(a, b);
		a->r = meld(a->r, b);
		swap(a->l, a->r);
		return a;
	}
	Heap<int>* pop_(Heap<int>* a) {
		return meld(a->l, a->r);
	}
public:
	Priority_Queue() : root(nullptr) {}
	void push(int val) {
		pool[it].Init(val);
		root = meld(root, &pool[it++]);
	}
	int top() {
		return root->val;
	}
	void pop() {
		root = pop_(root);
	}
	void meld(Heap<int>* a) {
		root = meld(root, a);
	}
};

int main()
{
	int val;
	string S;
	Priority_Queue pq;

	while (cin >> S, S != "end") {
		if (S == "extract") {
			printf("%d\n", pq.top());
			pq.pop();
		}
		else {
			cin >> val;
			pq.push(val);
		}
	}
	return 0;
}

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


int main(){   
    int a ,b; cin >> a >> b;
    for(int n=1;n<=10000;n++){
        int taxa = n*8/100;
        int taxb = n*10/100;
        if(taxa == a && taxb == b){
            cout << n << endl;
            return 0;
        }
    
    }
    cout << -1 << endl;
    return 0;
}


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

int main(){
  double A,B,H,M,pi=3.14159265358979,ax,ay,bx,by;
  cin >> A >> B >> H >> M;
  ax=A*sin(2*pi*(60*H+M)/720);
  ay=A*cos(2*pi*(60*H+M)/720);
  bx=B*sin(2*pi*M/60);
  by=B*cos(2*pi*M/60);
  cout << fixed << setprecision(15) << sqrt((ax-bx)*(ax-bx)+(ay-by)*(ay-by)) << endl;
}
    

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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

// n回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii;  // 2次元配列
typedef vector<ll> vll;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;
template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

const ld Pi = std::acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;

vii dp;
/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    // cout << fixed << setprecision(15);

    int h,w; cin >> h >> w;
    vec<string> grid(h);
    rep(i,h) cin >> grid[i];
    dp.resize(h+1, vi(w+1));
    dp[0][0] = 1;

    rep(i,h) {
        rep(j,w) {
            if(i+1<h && grid[i+1][j] == '.'){
                dp[i+1][j] += dp[i][j];
                dp[i+1][j] %= mod;
            }
            if(j+1<w && grid[i][j+1] == '.') {
                dp[i][j+1] += dp[i][j];
                dp[i][j+1] %= mod; 
            }
        }
    }
    cout << dp[h-1][w-1] << '\n';
}

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

int main()
{
	int n;
	int A[1000];
	
	while (1) {
		cin >> n;

		if (n == 0)break;

		for (int i = 0; i < n; i++) cin >> A[i];
		int sum = 0;
		for (int i = 0; i < n; i++) sum += A[i];
		double avg =1.0* sum / n;
		double dist = 0.0;
		for (int i = 0; i < n; i++)dist += (A[i] - avg)*(A[i] - avg);
		double a = sqrt(dist / n);
		printf("%lf\n", a);
	}
}

Measured memory_bytes: 3212
#include<iostream>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<cstdio>
#include<map>
using namespace std;
const int N=1e4+50;
const long long INF=0x3f3f3f3f3f3f3f3f;
typedef long long ll;
long double length[N][N];
long double d[N];
bool vis[N];
int n;
struct circular
{
   long double x,y;
   long double r=0;
}c[N];
void dijkstra(int s)
{
    for(int i=0;i<=n+1;i++)
        d[i]=INF;
    d[s]=0;
    while(1)
    {
        int v=-1;
        for(int i=0;i<=n+1;i++)
        {
            if(!vis[i]&&(v==-1||d[i]<d[v]))
                v=i;
        }
        if(v==-1)
         break;
        vis[v]=1;
        for(int i=0;i<=n+1;i++)
        d[i]=min(d[i],d[v]+length[v][i]);
    }
}
int main()
{
    long double x1,y1;
    scanf("%llf%llf%llf%llf",&c[0].x,&c[0].y,&x1,&y1);
    scanf("%d",&n);
    c[n+1].x=x1;
    c[n+1].y=y1;
    for(int i=1;i<=n;i++)
    {
        scanf("%llf%llf%llf",&c[i].x,&c[i].y,&c[i].r);
    }
    for(int i=0;i<=n+1;i++)
    {
        for(int j=i+1;j<=n+1;j++)
        {
           length[i][j]=(long double)sqrt((long double)(c[i].x-c[j].x)*(c[i].x-c[j].x)+(long double)(c[i].y-c[j].y)*(c[i].y-c[j].y));
            length[i][j]-=c[i].r+c[j].r;
            if(length[i][j]<0)
             length[i][j]=0;
            length[j][i]=length[i][j];
        }
    }
    dijkstra(0);
    printf("%.9Lf\n",d[n+1]);
    return 0;
}


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

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

class Sol{
	public void Solve(){
		
		if(K % 2 == 0){
			int[] ans = new int[N];
			ans[0] = K / 2;
			for(int i=1;i<N;i++) ans[i] = K;
			Console.WriteLine(String.Join(" ",ans));
		} else {
			
			int[] ans = new int[N];
			for(int i=0;i<N;i++) ans[i] = (K + 1) / 2;
			
			int nn = (N - 1 + 1) / 2;
			int b = N - 1;
			
			for(int i=0;i<nn;i++){
				while(ans[b] == 0) b--;
				ans[b]--;
				if(ans[b] > 0){
					b++;
					for(;b<N;b++) ans[b] = K;
					b = N - 1;
				}
			}
			
			List<int> a = ans.ToList();
			while(a[a.Count - 1] == 0) a.RemoveAt(a.Count - 1);
			Console.WriteLine(String.Join(" ",a));
		}
	}
	int K, N;
	public Sol(){
		var d = ria();
		K = d[0]; N = d[1];
	}

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


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

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

    if (D == 25) {
        cout << "Christmas" << endl;
    }
    else if (D == 24) {
        cout << "Christmas Eve" << endl;
    }
    else if (D == 23) {
        cout << "Christmas Eve Eve" << endl;
    }
    else {
        cout << "Christmas Eve Eve Eve" << endl;
    }
}

Measured memory_bytes: 256
use proconio::input;
use std::collections::HashSet;

fn main() {
    input! {
        a: usize,
        b: usize,
        c: usize,
        d: usize,
        e: usize,
        f: usize,
    }


    let mut waters = HashSet::new();

    for i in 0..=f/100 {
        for j in 0..=f/100 {
            let water = 100 * a * i + 100 * b * j;
            if 0 < water && water <= f {
                waters.insert(water);
            }
        }
    }

    let mut sugars = HashSet::new();
    for i in 0..=f {
        for j in 0..=f {
            let sugar = c * i + d * j;
            if 0 < sugar && sugar <= f {
                sugars.insert(sugar);
            }
        }
    }

    let mut ans = (100*a, 0);

    for &water in &waters {
        for &sugar in &sugars {
            if water + sugar > f {
                continue;
            }
            if water * e < sugar * 100 {
                continue;
            }
            if (ans.0 + ans.1) * sugar >= (water + sugar) * ans.1 {
                ans = (water, sugar)
            }

        }
    }

    println!("{} {}", ans.0 + ans.1, ans.1);
}


Measured memory_bytes: 2236
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
     
#define fast { ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); }
#define pb push_back
#define ll long long
#define ld long double
     
#define vi vector<int>
#define vl vector<long>
#define vll vector<long long>
     
#define infi INT_MAX
#define infl LONG_LONG_MAX
#define infd LDBL_MAX
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fi(i,a,b) for(ll i=(b-1);i>=a;i--)
#define F first
#define S second
#define G(a,b) get<a>(b)
#define MP make_pair
#define MT make_tuple
#define pll pair<ll,ll> 
#define endl "\n"
#define ALL(v) v.begin(),v.end()
#define nl cout<<"\n";
#define pr(x) cout<<x;
#define pr1(x) cout<<x<<" ";
#define pr2(x,y) cout<<x<<" "<<y;
#define deb printf("***************************************************************************************\n");
#define moshi printf("moshi moshi ! \n");
#define hi printf("hi ! \n");
#define bye printf("bye bye ! \n");
#define o_set(ll) tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define number_of_set_bits  __builtin_popcountll  
const ld PI=3.1415926535897932384626433; 

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }     
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

void func()
{ 
  ll x,n;
  cin>>x>>n;
  ll arr[n+1];
  bool is_present[105]={};
  f(i,1,n+1) cin>>arr[i],is_present[arr[i]]=1;
  
  

  f(l,0,105)
  {
    ll a=x-l,b=x+l;
    if(!is_present[a])
    {
      cout<<a<<endl;
      return;
    }

    if(!is_present[b])
    {
      cout<<b<<endl;
      return;
    }
  }
}   

     
     
int main() 
{
    fast

    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif // ONLINE_JUDGE
        
     
    ll ntc=1;
    //cin>>ntc;
     
    f(i,1,ntc+1)
    {
      //cout<<"Case #"<<i<<": ";
      func();
    }     
    return 0;
}

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

/**
       return NO_PAIN ? NO_GAIN : GAIN;
*/

using namespace std;

#define all(v)   v.begin(), v.end()
#define sz(x)    (int) x.size()
#define Unique(x) x.erase(unique(all(x)), x.end())
#define endl "\n"
#define pb push_back
#define START cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
#define isOdd(n)    (n&1)
#define pow(n, m) (ll)powl(n, m)
#define numOfDigits(n)  ((n)? (ll)(log10(n))+1 : 1)
#define clr(x, val)    memset(x, val, sizeof(x)) //be careful of value and TLE
#define MOD 1000000007
#define EPS 1e-7
#define LSOne(x)  (x & (-x))   //least significant 1
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int N = 1e5 + 1;
vector<vi> adj(N);
bool vis[N];
int dp[N];
void dfs(int u){
    vis[u] = 1;
    for(int i = 0; i<sz(adj[u]); i++){
        int v = adj[u][i];
        if(!vis[v])
            dfs(v);
        dp[u] = max(dp[u], dp[v] + 1);
    }
}
int main()
{
    START
    //freopen("test cases\\in.txt", "r", stdin) ;
    //freopen("test cases\\in.txt", "w", stdout);
    int n, m; cin>>n>>m;

    for(int i = 0; i<m; i++){
        int u, v; cin>>u>>v;
        adj[u].pb(v);
    }
    int mx = 0;
    for(int i = 1; i<=n; i++)
        if(!vis[i] && sz(adj[i]))
            dfs(i);

    cout<<*max_element(dp, dp+N);
	return 0;
}


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

#define nax 100009
#define FOR(i,n,m) for(int i =(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)

typedef long long ll;
typedef vector<ll> vi;

int main(){
	ll dp[109][nax];
	ll n,k, mod = 1000000007LL;
	cin>>n>>k;
	vi a(n);
	REP(i,n) cin>>a[i];

	memset(dp,0LL,sizeof dp);
	REP(i,n) dp[i][0] = 1;
	REP(i,a[0]+1) dp[0][i] = 1;

	FOR(i,1,n){
		FOR(j,1,nax){
			dp[i][j] = (dp[i][j-1]%mod + dp[i-1][j]%mod)%mod;
			if(j-a[i]-1>=0) dp[i][j] = ((dp[i][j] - dp[i-1][j-a[i]-1])%mod+mod)%mod;
		}
	}

	cout<<dp[n-1][k]<<endl;

	return 0;
}

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

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

       if(a>b){
	      t=a; a=b; b=t;
       }

       if(b>c){
	      t=b; b=c; c=t;
       }

       if(c==a+b) cout<<"Yes"<<endl;
       else cout<<"No"<<endl;

       return 0;
}


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

using namespace std;
typedef long long LL;
const double pi = acos(-1.0);
const double eps = 1e-7;
const LL N = 110;

LL T,n,m,i,j,k,c[10010],a[N][N],h,w,t,ans=0,cnt=1;

int main()
{
    scanf("%lld%lld%lld",&h,&w,&n);
    for(i=1;i<=n;i++)scanf("%lld",&c[i]);
    for(i=0;i<h;i++){
        if(i%2){
            for(j=0;j<w;j++){
                if(c[cnt]){
                    c[cnt]--;
                    a[i][j]=cnt;
                }else{
                    cnt++;
                    c[cnt]--;
                    a[i][j]=cnt;
                }
            }
        }else{
            for(j=w-1;j>=0;j--){
                if(c[cnt]){
                    c[cnt]--;
                    a[i][j]=cnt;
                }else{
                    cnt++;
                    c[cnt]--;
                    a[i][j]=cnt;
                }
            }
        }
    }
    for(i=0;i<h;i++){
        printf("%lld",a[i][0]);
        for(j=1;j<w;j++){
            printf(" %lld",a[i][j]);
        }
        printf("\n");
    }
    //system("pause");
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define INF 999999999
#define rep(i, n) for(int i = 0;i < n;i++)
#define pb(n) push_back(n)
#define sort(n) sort(n.begin(), n.end());
#define Ivec vector<int>
#define Svec vector<string> 
int main() {
  lli A,B,C,D=0;
  cin >> A;
  cin >> B >> C;
  rep(i,A+1){
    lli E=0;
    lli F=i;
    for(;;){
    E+=F%10;
    if(F-10<0)break;
    F/=10;
    }
    if(E>=B&&C>=E)D+=i;
  }
  cout << D << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		 Dice3 di3 = new Dice3();		//Dice3のインスタンス

		int n = scan.nextInt();		//回数n

		int[] dice1 = new int[6];		//dice1作成
		for(int i=0; i<6; i++) {
			dice1[i] = scan.nextInt();
		}

		int[] answer2 = new int[6]; 	//確認した後の配列
		boolean flag = false;			//最終判定

		int[] dice2 = new int[6];		//dice2作成

		//n-1回サイコロを作成し確認
		for(int i=0; i<n-1; i++) {

			for(int j=0; j<6; j++) {
				dice2[j] = scan.nextInt();
			}


			answer2 = di3.check(dice1, dice2);		//総当たりで確認


			if(Arrays.equals(dice1, answer2)) {
				flag = true;
				break;
			}
		}

		if(flag) {		//既に算出済み
			System.out.println("No");
		}else
			System.out.println("Yes");
	}
}



class Dice3{
	static int top = 0;
	static int side1 = 0;
	
	static int[] answer = new int[6]; //動かすサイコロの形

	//command（特定の文字が入力された際、その方向に転がす）
	int[] command(int[] dice, char com) {
	    	top = dice[0];	//dice[0]を覚えておく
	    	side1 = dice[1];	//dice[1]を覚えておく

	    	switch (com) {

	    	case 'N':
	    		dice[0] = dice[1];
	    		dice[1] = dice[5];
	    		dice[5] = dice[4];
	    		dice[4] = top;
	    		break;

	    	case 'W':
	    		dice[0] = dice[2];
	    		dice[2] = dice[5];
	    		dice[5] = dice[3];
	    		dice[3] = top;
	    		break;


	    	case 'R':
	    		dice[1] = dice[3];
	    		dice[3] = dice[4];
	    		dice[4] = dice[2];
	    		dice[2] = side1;
	    		break;
	    	}
		return dice; 		//配列を返す
	 }


	//check（全ての面で配列d2を横回転させ配列d１と比較）
	int[] check(int[] d1 ,int[] d2) {

		//N方向回転
		for(int k=0; k<4; k++) {

			if(Arrays.equals(d1, answer)) {		//配列の比較はArraysから
				break;
			}
			answer = command(d2, 'N');

			//横回転
			for(int l=0; l<4; l++) {

				if(Arrays.equals(d1, answer)) {
					break;
				}
				answer = command(d2, 'R');
			}
		}

		//W方向回転
		for(int k=0; k<4; k++) {

			if(Arrays.equals(d1, answer)){
				break;
			}
			answer = command(d2, 'W');

			//横回転
			for(int l=0; l<4; l++) {

				if(Arrays.equals(d1, answer)) {
					break;
				}
				answer = command(d2, 'R');
			}
		}
		return answer;
	}
}


Measured memory_bytes: 28324
K = int(input())
N = K - 1
count = 0
for i in range(K):
    I = i + 1
    for j in range(N):
        J = j + 1
        if I % 2 != 0 & J % 2 == 0:
            count += 1
        elif I % 2 == 0 & J % 2 != 0:
            count += 1
    N -= 1
print(count)


Measured memory_bytes: 2940
import math
L = 10**6 + 1

N = int(input())
A = list(map(int, input().split()))
memo = [0] * L
flag = 0 # 0をpairwise coprime

for a in A:
    memo[a] += 1

for i in range(2, L):
    if sum(memo[i::i]) > 1:
        flag = 1
        break

g = 0
for i in range(N):
    g = math.gcd(g, A[i])

if flag == 0:
    answer = 'pairwise coprime'
elif flag == 1 and g == 1:
    answer = 'setwise coprime'
else:
    answer = 'not coprime'

print(answer)

Measured memory_bytes: 127624
#include<iostream>
#include<iomanip>
#include<string>
#include<set>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<functional>
using namespace std;
#define LL unsigned long long
#define MOD 1000000007
#define inf 1999999999

LL N, K, _K, sum = 0, ans = 0, A[2002], froll[2002] = {}, roll[2002] = {};

int main() {
	cin >> N >> K;
	_K = K * (K - 1) / 2;
	_K %= MOD;
	for (int i = 0; i < N; i++)cin >> A[i];
	for (int i = N; i >= 0; i--) {
		for (int j = i + 1; j < N; j++) if (A[i] > A[j]) froll[i]++;
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			if (A[i] > A[j]) roll[i]++;
		}
		roll[i] = roll[i] * _K + froll[i] * K;
		roll[i] %= MOD;
		ans += roll[i];
	}
	cout << ans % MOD << endl;
	return 0;
}


Measured memory_bytes: 256