akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define soort(v) sort(v.begin(),v.end())
#define foor(i,n) for(int i=0; i<n; i++)
//#define vecprint(v){for(int i=0; i<v.size(); i++)cout << v[i] << " ";}
int string_to_int(string s){stringstream x(s);double a=0; x>>a; return a;}
long long int gcd(long long int a, long long int b){if(a%b==0)return b;return gcd(b, a%b);}
long long int lcm(long long int a, long long int b){return (a*b)/gcd(a, b);}
int string_prod(string s){int b = 1;auto k =s.size();for(int j=0; j<k; j++){b *=(s[j]-48);}return b;}
//long long int factorial(long long int n){if (n == 0)return 1;return n * factorial(n - 1);}
#define ll long long
#define pb push_back

 
//int cnt =0;
//map<int,int>mp;
//
//void SieveOfEratosthenes(int n=2000000)
//{
//
//    vector <bool>prime(n+1,true);
//
//    for (int p=2; p*p<=n; p++)
//    {
//
//        if (prime[p] == true)
//        {
//
//            for (int i=p*p; i<=n; i += p)
//                prime[i] = false;
//        }
//    }
//
//
//    for (int p=2; p<=n; p++)
//       if (prime[p])
//          mp[p]++;
//}
//
 
//set <int>s;
//void primeFactors(long double n)
//{
//
//    while(fmod(n, 2)==0)
//    {
//        s.insert(2);
//        n /= 2;
//    }
//
//
//    for(int i=3; i<=sqrt(n); i+=2)
//    {
//
//        while(fmod(n, i)==0)
//        {
//            s.insert(i);
//            n /= i;
//        }
//
//    }
//
//    if(n>2){
//       s.insert(n);
//    }
//
//}
 
 
//int isprime(long long int N){
//    if(N<2 || (!(N&1) && N!=2))
//        return 0;
//    for(long long int i=3; i*i<=N; i+=2){
//        if(!(N%i))
//            return 0;
//    }
//    return 1;
//}
 
//int binary_ser(vector<int>&v,int target,int r,int l=0){
//
//    int mid;
//    mid = l+((r-l)/2);
//
//    if(l>r)return -1;
//
//    if(v[mid]==target)return mid;
//    else if(v[mid]>target){
//        r = mid-1;
//        return binary(v, target,r,l);
//    }
//    else{
//        l = mid+1;
//        return binary(v, target,r,l);
//    }
//
//    return -1;
//
//}
 
//int lcs(string s,string p){
//
//    vector<vector<int>>v(s.size()+1,vector<int>(p.size()+1));
//
//    for(int i=1; i<=s.size(); i++){
//        for(int j=1; j<=p.size(); j++){
//
//    if(s[i-1]==p[j-1]) v[i][j] = v[i-1][j-1]+1;
//
//    else v[i][j] = max(v[i-1][j], v[i][j-1]);
//
//  }
// }
//
//    return v[s.size()][p.size()];
//}



int main(){
    vector<int>v;
    map<int,int> mp;
    map<int,int> m;
    int a,b,c=0,n,cnt=100000000,cn=0;
    string s,p;
    
    cin >> n >> s;
    
    if(n%2){
        cout << "No" << endl;
        return 0;
    }
    
    for(int i=0; i<n/2; i++){
        if(s[i]!=s[n/2+i]){
            cout << "No" << endl;
            return 0;
        }
    }
    
    cout << "Yes" << endl;
    return 0;
    
    
}


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

int main(){
	int x, y, sum1 = 0;
	double sum2 = 0, ave = 0, cnt = 0;
	char c;
	while(cin >> x >> c >> y){
		cnt++;
		sum1 += x*y;
		sum2 += y;
	}
	ave = (int)((sum2 / cnt) + 0.5);
	cout << sum1 << endl << ave << endl;


}

Measured memory_bytes: 1232
/*
 * FileName:     D_model
 * CreatedDate:  2020-06-28 10:07:57 +0900
 * LastModified: 2020-06-28 10:11:29 +0900
 */


#include<stdio.h>
int main(){
	long long n;
	scanf("%lld\n",&n);
	int ans=0;
	for(long long i=2;i*i<=n;i++)if(n%i==0){
		int cnt=0;
		while(n%i==0){
                    n/=i,cnt++;
                }

		for(int j=1;j<=cnt;j++){
			cnt-=j;
			ans++;
		}
	}
	if(n!=1)ans++;
	printf("%d\n",ans);
}


Measured memory_bytes: 1704
#define _GLIBCXX_DEBUG//実行時、何も出なかったらこれを使う
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<numeric>
#include<climits>
#include<limits>//
#include <stdio.h>//

using namespace std;

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

typedef long long ll;

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

int dy[] = {1,0}; //次に行くところ
int dx[] = {0,1}; //上に同じ


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

  ll x,k,d;
  cin >> x >> k >> d;
  x = abs(x);
  if (x/d > k){
    cout << x - d * k << '\n';
    return 0;
  }
  k -= x/d;
  x %= d;
  if (k % 2 == 0){
    cout << x << '\n';
  }else
  {
    cout << abs(x-d) << '\n';
  }
  
  

  return 0;
} 

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int a, b;
  cin >> a >> b;
  if (((a != 1 && b != 1) && a > b) || (a == 1 && b != 1)) {
  	cout << "Alice" << "\n";
  }else if (a == b) {
  	cout << "Draw" << "\n";
  }else {
  	cout << "Bob" << "\n";
  }
}

Measured memory_bytes: 256
import scala.io.StdIn

object Main {
  def isInvalid(R1: Int, R2: Int):Boolean = {
    if(R1 < 0 || R1 >= 10000 || R2 < 0 || R2 >= 10000){
      return true
    }
    return false
  }

  def printResult(R1: Int, R2: Int){
    if(isInvalid(R1,R2)){
      println("E")
    }
    else{
      println(R1)
    }
  }
  def solve(line: String){
    val digit = """(\d+)""".r
    var R1 = 0
    var R2 = 0
    var R3 = "+"
    val tokens = line.split("").toArray
    for(i <- 0 to tokens.length - 1){
      val x = tokens(i).toString
      x match {
        case digit(x) => {
          R2 = 10 * R2 + x.toInt
        }
        case "+"|"-"|"*" => {
          R3 match {
            case "+" => {
              R1 = R1 + R2
            }
            case "-" => {
              R1 = R1 - R2
            }
            case "*" => {
              R1 = R1 * R2
            }
          }
          if(isInvalid(R1,R2)){
            println("E")
            return
          }
          R2 = 0
          R3 = x
        }
        case "=" => {
          R3 match {
            case "+" => {
              R1 = R1 + R2
              R2 = 0
            }
            case "-" => {
              R1 = R1 - R2
              R2 = 0
            }
            case "*" => {
              R1 = R1 * R2
              R2 = 0
            }
          }
          printResult(R1,R2)
          return
        }
      }
    }
  }

  def main(args: Array[String]){
    StdIn.readLine match {
      case line: String => {
        solve(line)
        main(args)
      }
      case _ => {
        return
      }
    }
  }
}

Measured memory_bytes: 63516
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t,a,b,n,i,j,k,sum;
    string s;
    cin>>s;
    sort(s.begin(),s.end());
    if(s[0]==s[1]&&s[2]==s[3]&&s[0]!=s[2])
        cout<<"Yes";
    else
        cout<<"No";
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using ll = unsigned long long;
using namespace std;

int main(void) {

    int n;
    cin >> n;
    int *v, *c;
    v = new int[n];
    c = new int[n];

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

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

    int total_v=0, total_c=0;

    for(int i = 0; i < n; ++i) {
        if (v[i] - c[i] > 0) {
            total_v += v[i];
            total_c += c[i];
        }
    }

    cout << total_v - total_c << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
int N ;
long long Y;
cin >> N ;
cin >> Y; 
bool b = false;
int x = -1;
int y = -1;
int z = -1;
for(int i = 0; i <=N; i++){
  for(int j = 0; i+j <=N; j++){
    if(1000*(N-i-j) == Y - 5000*j - 10000*i){
      x = i;
      y = j;
      z = N -i-j;
    }
  }
}
  cout << x << " " << y << " " << z << endl;

}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mp make_pair
#define fi first
#define se second
#define VAL 100000
#define ll long long
#define INF 10000000000000000LL
#define pll pair<long long , long long>
const int MAX=1e4+10;
const int MOD=1e9+7;
const int TOT_PRIMES=19;
const int MAX_A=70;
using namespace std;
vector<int>adj[MAX];

int p ,n;
int val[MAX];

int vis[(1<<16)][16][16];
int  mx;
ll arr[MAX];
int prime[10]={2, 3, 5, 7, 11, 13, 17, 19};
int coun(int x){
	return __builtin_popcount(x);
}

int main() 
{ 
	//ios_base::sync_with_stdio(false);
  //  cin.tie(NULL);	
//	#ifndef ONLINE_JUDGE
//	freopen("inp.txt" ,"r", stdin );
//	freopen("out.txt", "w", stdout);
//	#endif
	
	cin>>n;
	long long sum=0;
	for(long long i=1;i<=n;i++){
		if((i%3!=0)&&(i%5!=0))
			sum=sum+i;
	}
	cout<<sum;

}


Measured memory_bytes: 3868
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define forn(i,a,b) for(int i =a;i<b;i++)
#define fi first
#define se second
#define fast ios_base::sync_with_stdio(false);
using namespace std;

//for debugging 
/*
g++ -D_GLIBCXX_ASSERTIONS -DDEBUG -ggdb3 -std=c++14 
*/
int recur_depth = 0;
#ifdef DEBUG
#define dbg(x) {++recur_depth; auto x_=x; --recur_depth; cerr<<string(recur_depth, '\t')<<"\e[91m"<<__func__<<":"<<__LINE__<<"\t"<<#x<<" = "<<x_<<"\e[39m"<<endl;}
#else
#define dbg(x)
#endif
template<typename Ostream, typename Cont>
typename enable_if<is_same<Ostream,ostream>::value, Ostream&>::type operator<<(Ostream& os,  const Cont& v){
	os<<"[";
	for(auto& x:v){os<<x<<", ";}
	return os<<"]";
}
template<typename Ostream, typename ...Ts>
Ostream& operator<<(Ostream& os,  const pair<Ts...>& p){
	return os<<"{"<<p.first<<", "<<p.second<<"}";
}
// debugging ends here

typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
const int mxn  = 3e3+1;
// const int len = 1e7;
ll dp[mxn][mxn][3];
ll vals[mxn][mxn]; 
int r,c;

ll find(int x, int y, int xl){
	if(x<0 || x >= r ) return 0ll;
	if(y<0 || y>=c) return 0ll;
	ll &ans = dp[x][y][xl];
	if(ans!=-1){
		return ans;
	}
	ans = 0;
	if(vals[x][y]!=0){
		ans = max(ans, vals[x][y] + find(x+1,y,3));
	}
	if(xl>1 && vals[x][y]!=0){
		ans = max(ans,vals[x][y] + find(x,y+1,xl-1));
	}
	ans = max(ans, max(find(x+1,y,3), find(x,y+1,xl)));
	// cout << x << ' ' << y << " " << xl << " " << " " << ans << endl;
	return ans;

}

void solve(){
	int k;
	cin >> r >> c >> k;
	memset(dp,-1,sizeof(dp));
	for(int i =0;i<k;i++){
		int x,y,val;
		cin >> x >> y;
		--x,--y;
		cin >> vals[x][y]; 
	}

	ll ans = find(0,0,3);

	cout << ans << endl;
}

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

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


Measured memory_bytes: 285676
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		while (true) {
			if (IsPrime(x)) {
				System.out.println(x);
				return;
			}
			x++;
		}
	}

	static boolean IsPrime(int n) {
		if (n < 2)
			return false;
		else if (n == 2)
			return true;
		else if (n % 2 == 0)
			return false;
		double sqrtNum = Math.sqrt(n);
		for (int i = 3; i <= sqrtNum; i += 2) {
			if (n % i == 0) {
				return false;
			}
		}
		return true;
	}

}

Measured memory_bytes: 23636
#include<bits/stdc++.h>
using namespace std;
#define TRACE
#define M 1000000007
#define oo 1000000000000000007
#define F first
#define S second
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pll;
#define pb push_back
#define M6 1000009
#define M5 500009
#define pi 3.14159265
#define epsilon 1e-6

#ifdef TRACE
    #define trace1(x)                cerr << #x << ": " << x << endl;
    #define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
    #define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
    #define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
    #define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
    #define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;
 
#else
 
    #define trace1(x)
    #define trace2(x, y)
    #define trace3(x, y, z)
    #define trace4(a, b, c, d)
    #define trace5(a, b, c, d, e)
    #define trace6(a, b, c, d, e, f)
 
#endif
ll power(ll x,ll n,ll m){
    ll res=1;
    while(n>0){
        if(n&1) res=(res*x)%m;
        n/=2;
        x=(x*x)%m;
    }
    return res;
}

ll n,m,A[M5];
int  main()
{   //ios_base::sync_with_stdio (0), cin.tie (0);
    //sieve();
    //init();
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ll tc=1,t=0,i,j,k,a,b,c,d,l,r;
    //cin>>tc;
    while(t++<tc){
        //cout<<"Case #"<<t<<": ";
        cin>>n;
        double aa=0;
        for(i=1;i<=n;i++) {cin>>A[i]; aa+=1.00/A[i];}
        cout<<fixed<<setprecision(15)<<(1.00/aa);
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#define INF 100001
 
using namespace std;
 
int main(){
  int n;
  cin >> n;
  int dp[n+1][n+1],p[n+1];
  cin >> p[0] >> p[1];
  for(int i=2;i<=n;i++){
    int t; cin >> t;
    cin >> p[i];
  }
  for(int i=1;i<=n;i++) dp[i][i]=0;
  for(int l=2;l<=n;l++){
    for(int i=1;i<=n-l+1;i++){
      int j=i+l-1;
      dp[i][j]=INF;
      for(int k=i;k<=j-1;k++)
        dp[i][j]=min(dp[i][j], dp[i][k]+dp[k+1][j]+p[i-1]*p[k]*p[j]);
    }
  }
  cout << dp[1][n] << endl;
}

Measured memory_bytes: 3092
#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 ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
 
#define FS              ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll              unsigned int
#define ld              long double
#define pb              push_back
#define bp              __builtin_popcount
#define sz              size()
#define ff              first
#define ss              second
#define vll             vector<ll>
#define vbool           vector<bool>
#define vpll            vector<pair<ll,ll>>
#define pll             pair<ll,ll>
#define vllv            vector<vector<ll>>
#define setpri(x)       cout<<setprecision(x)<<fixed;
#define all(v)          v.begin(),v.end()
#define allr(v)         v.rbegin(),v.rend()
#define yesr {cout<<"YES"<<endl;return;}
#define nor {cout<<"NO"<<endl;return;}
// getline (std::cin,name);
ll MOD=1e9+7;
ll ceil1(ll n,ll x);
ll gcd(ll a,ll b){return __gcd(a,b);}
ll lcm(ll a,ll b){return (max(a,b)/gcd(a,b))*min(a,b);}
ll pow1(ll n,ll m,ll mod);
ll pow2(ll n,ll k);
ll modinv(ll n,ll mod){  return pow1(n,mod-2,mod);}
bool func(pair<ll,ll> &a,pair<ll,ll> &b ){
        if(a.ff != b.ff)return a.ff < b.ff;
        return a.ss > b.ss;
}
void solve(){
        ll i,j,k,l,n,m,y,z,r;
        
        map<ll,string> mp;
        mp[2]=mp[4]=mp[5]=mp[7]=mp[9]="hon";
        mp[0]=mp[1]=mp[6]=mp[8]="pon";
        mp[3]="bon";
        
        cin>>n;
        n%=10;
        while(n>=10){
                n/=10;
        }
        cout<<mp[n]<<endl;
        
        
        
}
int main(){
        FS;
        ll i,j,k,n,m,x,y,z,q;
        q=1;
        // cin>>q;
        while(q--){
                solve();
        }
        return 0;
}
ll ceil1(ll n,ll x){
        return (n-1)/x+(n>0);
}
ll pow1(ll n,ll m,ll mod){
        if(m==0)return 1;
        
        if(m%2==0)return pow1((n*n)%mod,m/2,mod);
    	
    	return (pow1((n*n)%mod,m/2,mod)*n)%mod;
}
ll pow2(ll n,ll k){
        ll ans=1;
            while(k>0){
                if(k%2==1)ans=ans*n;
                n=n*n;
                k/=2;
            }
            return ans;
}

Measured memory_bytes: 3660
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    static final long MODULO =  (long)1e9 + 7;
    public static void main(String[] args) {
        FastReader fastReader = new FastReader();
        int N = fastReader.nextInt();
        int[] nums = new int[N];
        for(int i = 0; i < N; i++) {
            nums[i] = fastReader.nextInt();
        }
        int j = nums.length - 1;
        while(j >= 0 && nums[j] == 0) j--;
        if(j <= 0) {
            System.out.println(0);
            return;
        }
        long sum = nums[j];
        long res = 0;
        for(int i = j - 1; i >= 0; i--) {
            if(nums[i] == 0) {
                continue;
            }

            res = (res + sum*nums[i] % MODULO) % MODULO;
            sum = (sum + nums[i]) % MODULO;
        }

        System.out.println(res);
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

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

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

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

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


Measured memory_bytes: 55076
#include<iostream>
#include<cstdio>

using namespace std;

int main(){
	
	long num[10010];
	long kosuu;
	long max, min;
	long sum = 0;
	
	cin >> kosuu ;
		
	for(long i = 0; i < kosuu ;i++){
		cin >> num[i];
	
	}
	
	max = num[0];
	min = num[0];
	
	for(long i = 0; i < kosuu ;i++){
		if(max < num[i]){
		max = num[i];
		}
	}
	for(long i = 0; i < kosuu ;i++){
		if(min > num[i]){
		min = num[i];
		}
	}	
		
	for(long i = 0; i < kosuu ;i++){
		sum +=num[i];
		
	}
	
	cout << min << " " << max << " " << sum << endl;
		
		
		
	
return 0;
}

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

int main(void){

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


   
   int a,b,c;
   cin>>a>>b>>c;
   swap(a,b);
   swap(a,c);
   cout<<a<< " "<<b<<  " "<<c<<endl;


  return 0;
}

Measured memory_bytes: 256
/*dismint|jjc*/
#include <bits/stdc++.h>
using namespace std;
#define forl(V, S, E) for(int V = S; V < E; V++)
#define ford(V, S, E) for(int V = S; V >= E; V--)
#define fore(E, X) for(auto &E:X)
#define println(X) cout << X << endl
#define printe(X) for(auto &E:X) cout << E << " "; cout << endl
typedef unordered_map<int, unordered_set<int>> graph;
typedef long long ll;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	ll a, b, c, k; cin >> a >> b >> c >> k;
	ll ans = 0;
	if(k) {
		if(k >= a) {
			k -= a;
			ans += a;
		}
		else {
			ans += k;
			k = 0;
		}
	}
	if(k) {
		if(k >= b) {
			k -= b;
		}
		else {
			k = 0;
		}
	}
	if(k) {
		ans -= k;
	}
	println(ans);
}


Measured memory_bytes: 3612
#include <iostream>

using namespace std;

int a[100010];
int b[100010];

int main() {
	int N;
	scanf("%i",&N);
	for(int i=1;i<=N;++i){
		scanf("%i",&a[i]);
	}
	for(int i=1;i<=N;++i){
		b[a[i]]=i;
	}
	for(int i=1;i<=N;++i){
		printf("%i ",b[i]);
	}
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef long double lb;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define repr(i,j,n) for(ll i = j; i >= (n); i--)
#define each(i,mp) for(auto& i:mp)
#define all(x) (x).begin(),(x).end()
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
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; }
typedef pair<ll,ll>P;
const lb pi=acos(-1);
const ll mod=1e9+7;
const ll INF = 1LL<<60;
const ll m=1LL<<32;

int main(){

  ll x,n;cin>>x>>n;
  // ll p[n];
  map<ll,bool>mp;
  rep(i,0,n){
    // cin>>p[i];
    ll p;cin>>p;
    mp[p]=true;
  }

  ll mi=INF;
  ll ans=x;
  rep(i,-100,105){
    if(mi>abs(x-i)&&!mp[i]){
      // out(i<<":"<<abs(x-i));
      mi=abs(x-i);
      ans=i;
    }
  }
  out(ans);

  return 0;
}


Measured memory_bytes: 3648
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <iomanip>
#include <cmath>
#include <queue>
#include <bitset>
#include <numeric>
#include <array>
#include <cstring>
#include <random>
#include <chrono>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())
typedef long long ll;
typedef long double ld;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const ll mod = 1e9 + 7;
int main() {

  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

  ll n = 0;

  cin >> n;

  if(n == 1) { cout << 0; return 0; }

  ll tot = 1, sub = 1, add = 1;

  for(int i = 1; i <= n; i++) {
    tot = (tot * 10) % mod;
    sub = (sub * 9) % mod;
    add = (add * 8) % mod;
  }

  cout << ((((tot - sub - sub + add) % mod) + mod) % mod);

  return 0;
}
/*

*/


Measured memory_bytes: 3664
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
int y;

int main(void){
	scanf("%d%d",&n,&y);
	y/=1000;
	for(int i=0;i<=n;i++){
		for(int j=0;i+j<=n;j++){
			int k=n-i-j;
			if(k*10+j*5+i==y){
				printf("%d %d %d\n",k,j,i);
				return 0;
			}
		}
	}
	printf("-1 -1 -1\n");
	return 0;
}

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

main()
{
  int data[10];
  int mpos;

  for ( int i = 0; i < 10; i++) {
    cin >> data[i];
  }
  
  for ( int i = 0; i < 3; i++) {
    mpos = 0;
    for ( int j = 0; j < 10; j++) {
      if ( data[mpos] < data[j] ){
	mpos = j;
      }
    }
    cout << data[mpos] << endl;
    data[mpos] = -1;
  }

  return (0);
}



Measured memory_bytes: 3068
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class C
{
	public static void Main() => (new Solver()).Solve();
}


public class Solver
{
	public void Solve()
	{
		int N = GetInt();
		int[] A = GetInts(N);

		int[] from = new int[N];
		for(int i = 0; i < N; i++)
		{
			from[i] = i - A[i];
			if(from[i] < 0 || from[i] > i)
			{
				Console.WriteLine(-1);
				return;
			}
		}

		long ans = 0;
		int prev = int.MaxValue / 2;
		for(int i = N - 1; i >= 0; i--)
		{
			if(from[i] > prev)
			{
				Console.WriteLine(-1);
				return;
			}
			else if(from[i] < prev)
			{
				ans += (long)(i - from[i]);
				prev = from[i];
			}
		}

		Console.WriteLine(ans);
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(int N) => Enumerable.Range(0, N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(int N) => Enumerable.Range(0, N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(int N) => Enumerable.Range(0, N).Select(_ => GetDouble()).ToArray();
	public static string[] GetStrings(int N) => Enumerable.Range(0, N).Select(_ => GetString()).ToArray();
}


Measured memory_bytes: 20544
N, K = map(int, input().split())
P = [int(x) for x in input().split()]
for i, p in enumerate(P):
  P[i] = (p + 1) / 2
ans = 0
E = 0
for i, p in enumerate(P):
  E += p
  if K <= i:
    E -= P[i - K]
  ans = max(E, ans)
print(ans)

Measured memory_bytes: 24676
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <climits>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
//typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
#define chmin(x, y) x = min(x, y);
#define chmax(x, y) x = max(x, y);

//const ll INFL = LLONG_MAX;//10^18 = 2^60
const ll INFL = 1LL<<60;
//const int INF = INT_MAX;
const ll INF = 1 << 30;//10^9
ll MOD = 1000000007;
//ll MOD = 998244353;

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

void pres(double A, ll x = 10){cout << fixed << setprecision(x) << A << endl;}
void BinarySay(ll x, ll y = 60){rep(i, y) cout << (x>>(y-1-i) & 1); cout << endl;}
ll cnt_bit(ll x){return __builtin_popcountll(x);}

ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x; k /= 2;
  }
  return res;
}

ll pow_mod(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

ll inverse(ll x){return pow_mod(x, MOD - 2);};

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

ll lcm(ll x, ll y){
  ll res = x / gcd(x, y);
  res *= y;
  return res;
};

//コンビネーション
const int MAXcomb = 200010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
ll comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}

const int MAXkai = 200010;
ll kai_memo[MAXkai];
ll kai(ll N){
  if(kai_memo[N] != 0) return kai_memo[N];
  if(N <= 1) return 1;
  return kai_memo[N] = N * kai(N-1) % MOD;
}


void solve(){
  int N;
  cin >> N;
  map<string, int> mp;
  vector<string> S;
  rep(i, N){
    string s;
    cin >> s;
    mp[s]++;
    S.pb(s);
  }
  int M = 0;
  rep(i, N){
    M = max(M, mp[S[i]]);
  }
  vector<string> ans;
  rep(i, N){
    if(mp[S[i]] == M) ans.pb(S[i]);
  }
  sort(ans.begin(), ans.end());
  ans.erase(unique(ans.begin(), ans.end()), ans.end());
  rep(i, ans.size()){
    cout << ans[i] << endl;
  }
}


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


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


int dfs(int,int,int , int);

int tag();
void change(int *, int *);

int xarr[4]={-1,0,1,0},yarr[4]={0,-1,0,1};
int array[3][3],sum;
int main(){
  int i,j,zerox,zeroy;
  for(i=0;i<3;i++){
    for(j=0;j<3;j++){
      scanf("%d",&array[i][j]);
      if(array[i][j]==0){
	
	zerox=j;
	zeroy=i;	
      }
    }
  }
  
  for(sum=0;sum<32;sum++){
    if(dfs(0,10,zerox,zeroy)==1) break;
  }
  printf("%d\n",sum);  /*output*/
  return 0;
}
int  dfs(int dep, int prev, int zerox, int zeroy){
  int i,xx,yy,ta;
  ta=tag();
  if(ta==0) return 1;
  if(dep+ta>sum) return -1;
  
    for(i=0;i<4;i++){
      if(i-prev==-2 || i-prev==2) continue;
      xx=zerox+xarr[i];
      yy=zeroy+yarr[i];
      if(xx<0 || yy<0 || xx>=3 || yy>=3) continue;
      change(&array[zeroy][zerox],&array[yy][xx]);
      
      if(dfs(dep+1,i,xx,yy)==1) return 1;
      change(&array[zeroy][zerox],&array[yy][xx]);
      
    }
    return -1;
    
}



int tag(){
  int i,j,num=0;
  for(i=0;i<3;i++){
    for(j=0;j<3;j++){
      if(array[i][j]==0) continue;
      num+=abs((array[i][j]-1)/3-i)+abs((array[i][j]-1)%3-j);
      
 
    }
  }
  return num;
}

/*exchange array[zeroy][zerox] and array[yy][xx]*/
void change(int * num1, int *num2){  
  int ch;
  ch=*num1;
  *num1=*num2;
  *num2=ch;
}



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

int main(){
  int A, B, K;
  cin >> A >> B >> K;
  int tmp;
  for(int i=0;i<K;i++){
    if(A+i<=B) cout << A+i << endl;
    tmp = A+i;
  }
  for(int i=K;i>0;i--){
    if(B-i+1>=A && B-i+1 > tmp) cout << B-i+1 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
	int money=0,m=0, num=0,n=0;
	int res, i=0;
	while((res=scanf("%d,%d", &m, &n))!=EOF)
	{
		if(res != 2)break;
		money += m*n;
		num   += n;
		i++;
	}
	if(i>0)
		printf("%d\n%d\n", money, (int)((double)num/i+0.5) );
	return 0;
}

Measured memory_bytes: 592
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>

using namespace std;

int main(){
    long long int K,N= 0;
    cin >> K >> N ;
    vector<long long int> v(N+1);
    for(int i =0;i<N;i++){
        cin>>v[i];
    }
    v.at(N) = v[0] + K;
    long max = 0;
    for(int i = 0; i < N; i++){
       long tmp = v[i+1] - v[i];
       if(max < tmp) max=tmp;
    }
    cout << K - max << endl;
    return 0;
}

Measured memory_bytes: 1920
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#define ll long long int
using namespace std;
ll n,a1,a2;
ll ans1=0,ans2=0;
int main(){
    scanf("%lld",&n);
    if(n%2==0){
        a1=a2=n/2;
    }
    else
    {
        a2=n/2;
        a1=(n/2)+1;
    }
    ans1=a1;
    ans2=a2;
    printf("%lld",ans1*ans2);
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder.Abc
{
    public class QuestionA
    {
        public static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            if ((N % 1000) == 0) {
                Console.WriteLine(0);
            } 
            else {
                Console.WriteLine(((N / 1000) + 1) * 1000 - N);
            }
            
        }
    }
}


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

int ara[101] ;

int main()
{
    //freopen("tex.in" , "r" ,stdin) ;
    //freopen("tex.out" , "w" ,stdout) ;

    int i , j , item ;
    int n ;
    scanf("%d" ,&n) ;
    for(i = 0 ; i < n ; i++){
        scanf("%d" ,&ara[i]) ;
    }
    
    for(i = 0 ; i < n ; i++){

        item = ara[i] ;       
        j = i - 1 ;

        while(j >= 0 && ara[j] > item){
            ara[j+1] = ara[j] ;
            j--; 
        }

        ara[j+1] = item ;
        
        for(int k = 0 ; k < n ; k++){
            if(k > 0) printf(" ") ;
            printf("%d" ,ara[k]) ;
        } 
        printf("\n") ;
    }
        
    return 0 ;
}


Measured memory_bytes: 3200
#include <stdio.h>

int main(){
	char s[10];
	int num=0;
	scanf("%s",s);
	for (int i = 0; i < 4; i++){
		switch (s[i]){
		case '+':num++; break;
		case '-':num--; break;
		}
	}
	printf("%d",num);
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#define llint long long

using namespace std;

llint k, a, b;

int main(void)
{
	cin >> k >> a >> b;
	
	if(b <= a+2){
		cout << k+1 << endl;
		return 0;
	}
	
	if(k <= a-1){
		cout << k+1 << endl;
		return 0;
	}
	
	llint rem = k - (a-1);
	cout << a + rem/2*(b-a) + rem%2;
	return 0;
}

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

public class Main {

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

  public void run() {

    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(br.readLine());
      int[][] graph = new int[n][n];
      String[] vInfo;
      int degree;

      for(int i=0; i<n; i++) {
        vInfo = br.readLine().split(" ");
        degree = Integer.parseInt(vInfo[1]);
        for(int j=0,k=2,v=0; j<degree; j++) {
          v = Integer.parseInt(vInfo[k++]);
          graph[i][v-1] = 1;
        }
      }

      StringBuilder buf = new StringBuilder();
      for (int[] i : graph) {
        for (int v : i) {
          buf.append(v).append(" ");
        }
        buf.setLength(buf.length()-1);
        buf.append("\n");
      }

      System.out.print(buf);
    }
    catch (IOException e) {
      System.out.println("IOException!");
    }
  }
}


Measured memory_bytes: 25368
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end());

typedef long long ll;

const ll INF = ll(pow(10,18))+1;

int main(){
  int n;
  ll k;
  cin >> n >> k;
  vector<ll> A(n);
  rep(i,n) cin >> A[i];
  sort(A);
  ll l = -INF, r = INF;
  while(l+1 < r) {
    ll x = (l+r)/2;
    bool ok = [&]{
      ll tot = 0;
      rep(i,n){
        if(A[i] < 0){
          int l = -1;
          int r = n;
          while(l+1<r){
            int c = (l+r)/2;
            if(A[c]*A[i] < x) r = c;
            else l = c;
          }
          tot += n-r;
        }
        else{
          int l = -1;
          int r = n;
          while(l+1<r){
            int c = (l+r)/2;
            if(A[c]*A[i] < x) l = c;
            else r = c;
          }
          tot += r;
        }
        if (A[i]*A[i] < x) tot --;
      }
      tot /= 2;
      return tot < k;
    }();
    if (ok) l = x;
    else r = x;
  }
  cout << l << endl;
}


Measured memory_bytes: 1792
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;

vector<pair<ll, ll>> sequence(ll x, ll A) {
  vector<pair<ll, ll>> seq;
  if (x < A) {
    seq.emplace_back(1, x);
  } else {
    if (A > 1) {
      seq.emplace_back(1, A - 1);
    }
    seq.emplace_back(A + 1, x + 1);
  }
  return seq;
}

ll maximumProduct(const ll len, const ll as, const ll bs) {
  ll L = 0, R = len - 1;
  while (R - L > 10) {
    ll m = (R - L) / 3;
    ll l = L + m, r = R - m;
    if ((as + l) * (bs - l) < (as + r) * (bs - r)) {
      L = l;
    } else {
      R = r;
    }
  }
  ll mx = 0;
  for (ll x = max(0ll, L - 10); x <= min(len - 1, R + 10); x++) {
    mx = max(mx, (as + x) * (bs - x));
  }
  return mx;
}

ll maximumProduct(const vector<pair<ll, ll>>& seqA,
                  const vector<pair<ll, ll>>& seqB) {
  vector<ll> indA(seqA.size() + 1, 0), indB(seqB.size() + 1, 0);
  for (int i = 1; i <= seqA.size(); i++)
    indA[i] = indA[i - 1] + (seqA[i - 1].second - seqA[i - 1].first + 1);
  for (int i = 1; i <= seqB.size(); i++)
    indB[i] = indB[i - 1] + (seqB[i - 1].first - seqB[i - 1].second + 1);
  ll mx = 0;
  for (int i = 0; i < seqA.size(); i++) {
    for (int j = 0; j < seqB.size(); j++) {
      ll s = max(indA[i], indB[j]), t = min(indA[i + 1], indB[j + 1]);
      if (s < t) {
        ll as = seqA[i].first + (s - indA[i]),
           bs = seqB[j].first - (s - indB[j]);
        mx = max(mx, maximumProduct(t - s, as, bs));
      }
    }
  }
  return mx;
}

int main() {
  int Q;
  while (cin >> Q) {
    for (int q = 0; q < Q; q++) {
      ll A, B;
      cin >> A >> B;
      ll C = A * B;
      ll ok = 0, ng = C + 100;
      while (ng - ok > 1) {
        ll x = (ok + ng) / 2;
        assert(x > 0);
        auto seqA = sequence(x, A);
        auto seqB = sequence(x, B);
        reverse(seqB.begin(), seqB.end());
        for (auto& b : seqB) {
          swap(b.first, b.second);
        }
        if (maximumProduct(seqA, seqB) < C) {
          ok = x;
        } else {
          ng = x;
        }
      }
      cout << ok << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;

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;
}
using namespace std;

void solve(){
	int n;
	cin>>n;
	vector<ll>p;
	ll sum=0;
	rep(i,n){
		ll a,b;
		cin>>a>>b;
		sum-=b;
		p.eb(a+b);
	}
	sort(p.rbegin(),p.rend());
	for(int i=0;i<n;i+=2){
		sum+=p[i];
	}
	cout<<sum<<"\n";
}

signed main(){
	std::ios::sync_with_stdio(false);
    std::cin.tie(0);
	solve();
	return 0;
}


Measured memory_bytes: 1400
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text.RegularExpressions;
using System.Diagnostics;
using static System.Math;
using static System.Array;

//var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
namespace AtCoderSolve
{

    class Solve
    {
        const int mod = 1000000007;
        const int INF = 2147483647;
        const long SINF = 9223372036854775807;

        static int W, H, N;
        static int[] x, y, a;
        

        public static void Input()
        {
            var cin = new Scanner();
            var input = cin.SplitReader();
            W = input[0];
            H = input[1];
            N = input[2];
            x = new int[N];
            y = new int[N];
            a = new int[N];
            for(var i = 0; i < N; i++)
            {
                var p = cin.SplitReader();
                x[i] = p[0];
                y[i] = p[1];
                a[i] = p[2];
            }
        }

        static void Main(string[] args)
        {
            Input();

            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);

            int minx = 0;
            int miny = 0;
            int maxx = W;
            int maxy = H;
            for(var i = 0; i < N; i++)
            {
                if (a[i] == 1) { minx = Max(minx, x[i]); }
                if (a[i] == 2) { maxx = Min(maxx, x[i]); }
                if (a[i] == 3) { miny = Max(miny, y[i]); }
                if (a[i] == 4) { maxy = Min(maxy, y[i]); }
            }
            int dx = maxx - minx;
            int dy = maxy - miny;


            Console.WriteLine(dx < 0 || dy < 0 ? 0 : dx * dy);

            //Console.Out.Flush();

        }





    }

    public class Scanner
    {
        public int[] SplitReader()
        {
            int[] array = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return array;
        }
        public long[] SplitReaderL()
        {
            long[] array = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return array;
        }

    }

    public class Graph
    {
        
    }
}

    



Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
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;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1 << 30)
#define LLINF (1LL << 60)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll x, y;
    cin >> x >> y;
    cout << (llabs(x - y) <= 1 ? "Brown" : "Alice") << endl;
}

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

template <class T>
inline void read(T &x) {
    x = 0;
    char c = getchar();
    bool f = 0;
    for (; !isdigit(c); c = getchar()) f ^= c == '-';
    for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48);
    x = f ? -x : x;
}

inline void readChar(char &c) {
	for (c = getchar(); c != '.' && c != '#'; c = getchar());
}

template <class T>
inline void write(T x) {
    if (x < 0) {
        putchar('-');
        x = -x;
    }
    T y = 1;
	int len = 1;
    for (; y <= x / 10; y *= 10) ++len;
    for (; len; --len, x %= y, y /= 10) putchar(x / y + 48);
}

const int MAXN = 2e5;
int n, a, b, c, d, cnt, lastRock;
char s[MAXN + 5];

int main() {
	read(n), read(a), read(b), read(c), read(d);
	if (d < c) swap(a, b), swap(c, d);//确保 d > c 
	for (int i = 1; i <= n; ++i) readChar(s[i]);
	if (s[c] == '#' || s[d] == '#') {
		puts("No");
		return 0;
	}
	for (int i = a; i <= c; ++i)
		if (s[i] == '#' && s[i - 1] == '#') {
			puts("No");
			return 0;
		}
	for (int i = b; i <= d; ++i)
		if (s[i] == '#' && s[i - 1] == '#') {
			puts("No");
			return 0;
		}
	if (a < b) {//b 先到 d，a 再到 b 
		puts("Yes");
		return 0;
	}
	for (int i = b; i <= d; ++i)//让 a 到一个合适的位置，使 b 能够到达 d
		if (s[i] == '#') {
			if (lastRock && ((i >= a + 2 && i <= c) || (lastRock >= a && lastRock <= c - 2) || 
			(lastRock < a && i > c)) && i - lastRock > 3) {
				puts("Yes");
				return 0;
			}
			lastRock = i;
			++cnt;
		}
	if (!cnt) {
		puts("Yes");
		return 0;
	}
	if (cnt == 1 && max(abs(a - lastRock), abs(c - lastRock)) > 3) {
		puts("Yes");
		return 0;
	}
	puts("No");
	return 0;
}

Measured memory_bytes: 384
#import time

def main():
    N, K = map(int, input().split())
    matrix = [list(map(int, input().split())) for i in range(2*K)]
    sunuke = [0]*(N+1)
    for i in range(K):
        for j in matrix[2*i+1]:
            sunuke[j] += 1
    ans = sunuke.count(0) -1

    return ans

if __name__ == '__main__':
    #start = time.time()
    print(main())
    #elapsed_time = time.time() - start
    #print("経過時間:{}".format(elapsed_time * 1000) + "[msec]")

Measured memory_bytes: 9068
#include<stdio.h>

int main(void){
    int n,i=1,x;

    scanf("%d",&n);

    while(i<n+1){
        x=i;
        if(x%3==0 || x%10==3) printf(" %d",i);
        else{
            while(x!=0){
                x/=10;
                if(x==3 || x%10==3){
                    printf(" %d",i);
                    break;
                }
            }
        }
        i++;
    }
    printf("\n");

    return 0;
}


Measured memory_bytes: 2104
/*input
11 5 5
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}

int a[maxn];

int main()
{
	//IOS;
	REP(i,3) cin>>a[i];
	sort(a,a+3);
	cout<<a[2]-a[0];
	return 0;
}


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

using ll=long long;
int main(){
    int n,q;
    cin>>n>>q;
    vector<ll> a(n);
    for(int i=0;i<n;i++) cin>>a[i],a[i]*=2;
    vector<ll> x(q);
    for(int i=0;i<q;i++) cin>>x[i],x[i]*=2;
    map<ll,pair<int,int>> mp;
    for(int i=1;i<=n;i++){
        int r=n-i;
        int l=n-i-i;
        if(l>=0){
            mp[(a[r]+a[l])/2]={i,0};
        }
        l--,r--;
        if(l>=0){
            mp[(a[r]+a[l])/2]={i,1};
        }
    }
    vector<ll> sum(n+1);
    vector<ll> even(n+1);
    
    partial_sum(a.begin(),a.end(),sum.begin()+1);
    for(int i=0;i<n;i++){
        if(i%2==0) even[i+1]=even[i]+a[i];
        else even[i+1]=even[i];
    }
    
    for(int i=0;i<q;i++){
        if(n==2 || (a[n-2]+a[n-3])/2<x[i]){
            if(n%2==1) cout<<even[n]/2<<endl;
            else cout<<(sum[n]-even[n])/2<<endl;
        }
        else if(x[i]<=(a[0]+a[n/2])/2){
            cout<<(sum[n]-sum[n/2])/2<<endl;
        }
        else{
            pair<int,int> tmp=(*mp.lower_bound(x[i])).second;
            int m=tmp.first;
            if(tmp.second==1){
                ll res=0;
                res+=sum[n]-sum[n-m-1];
                if(n%2==0) res+=sum[n-m-1-m]-even[n-m-1-m];
                else res+=even[n-m-1-m];
                cout<<res/2<<endl;
            }
            else{
                ll res=0;
                res+=sum[n]-sum[n-m];
                if(n%2==0) res+=sum[n-m-m]-even[n-m-m];
                else res+=even[n-m-m];
                cout<<res/2<<endl;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 11136
t = 1
while 1:
    N = int(input())
    if N == 0:
        break
    print("Case %d:" % t); t += 1
    M = [[0]*N for i in range(N)]
    c = 1
    for i in range(2*N-1):
        for j in range(max(i-N+1, 0), min(N, i+1)):
            if i % 2 == 0:
                M[i-j][j] = "%3d" % c
            else:
                M[j][i-j] = "%3d" % c
            c += 1
    for l in M:
        print(*l,sep='')


Measured memory_bytes: 5604
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    n = int(input())
    vx = []
    vy = []
    vh = []
    for i in range(n):
        x,y,h = readInts()
        vx.append(x)
        vy.append(y)
        vh.append(h)
        if h > 0:
            si = i
    # 基準となる座標はどこでもいい
    # けど、h = 0 のところはだめやねん
    #
    resx,resy,resh = -1,-1,-1
    for x in range(101):
        for y in range(101):
            h = vh[si] + abs(x - vx[si]) + abs(y - vy[si])
            ok = True
            for i in range(n):
                if vh[i] > 0 and h - vh[i] != abs(x - vx[i]) + abs(y - vy[i]):
                    ok = False
                if vh[i] == 0 and h > abs(x - vx[i]) + abs(y - vy[i]):
                    ok = False
            if ok:
                resx = x
                resy = y
                resh = h
    print(resx,resy,resh)
if __name__ == '__main__':
  main()


Measured memory_bytes: 5148