akhauriyash/Code-Regression huggingface dataset:
using System;

namespace _0103
{
    class Program
    {
        static void Main(string[] args)
        {
            int kaisuu = int.Parse(Console.ReadLine());
            string now;
            for (int i = 0; i < kaisuu; i++)
            {
                int OUT = 0;
                int point = 0;
                bool one = false;
                bool two = false;
                bool three = false;
                while (true)
                {
                    if (OUT == 3)
                    {
                        break;
                    }
                    now = Console.ReadLine();
                    if (now == "OUT")
                    {
                        OUT++;
                    }
                    else if (now == "HOMERUN")
                    {
                        point++;
                        if (one == true)
                        {
                            point++;
                        }
                        if (two == true)
                        {
                            point++;
                        }
                        if (three == true)
                        {
                            point++;
                        }
                        one = false;
                        two = false;
                        three = false;
                    }
                    else if (now=="HIT")
                    {
                        if (three == true)
                        {
                            three = false;
                            point++;
                        }
                        if (two == true)
                        {
                            two = false;
                            three = true;
                        }
                        if (one == true)
                        {
                            one = false;
                            two = true;
                        }
                        one = true;
                    }
                }
                Console.WriteLine(point);
            }
        }
    }
}

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

using namespace std;

int N, C;
int LightInfo[30];
int ButtonInfo[30];
int DpScore[31][(1 << 16)];

int popcnt(int u) {
	int ret;

	ret = 0;
	while (u) {
		u = (u & (u - 1));
		++ret;
	}

	return ret;
}

void solve() {
	int bits, total;

	fill_n(*DpScore, 31 * ((1 << 16)), -1);
	DpScore[0][0] = 0;
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < ((1 << 16)); ++j) {
			if (DpScore[i][j] == -1) {
				continue;
			}
			for (int k = 0; k < C; ++k) {
				bits = (LightInfo[i] | j) & (~ButtonInfo[k]);
				DpScore[i + 1][bits] = max(DpScore[i + 1][bits], DpScore[i][j] + popcnt((LightInfo[i] | j)&ButtonInfo[k]));
			}
		}
	}

	total = *max_element(DpScore[0], DpScore[0] + 31 * (1 << 16));
	cout << total << endl;
}

int main() {
	int num;

	while (cin >> N >> C, N) {
		memset(LightInfo, 0, sizeof(LightInfo));
		memset(ButtonInfo, 0, sizeof(ButtonInfo));
		for (int i = 0; i < N; ++i) {
			for (int j = 0; j < 16; ++j) {
				cin >> num;
				if (num == 1) {
					LightInfo[i] |= (1 << j);
				}
			}
		}
		for (int i = 0; i < C; ++i) {
			for (int j = 0; j < 16; ++j) {
				cin >> num;
				if (num == 1) {
					ButtonInfo[i] |= (1 << j);
				}
			}
		}

		solve();
	}

	return 0;
}



Measured memory_bytes: 11020
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<map>
using namespace std;
#define ll long long
int main(){
	int N,K,d[10]={0};
	cin>>N>>K;
	for(int i=0;i<K;i++){
		int a;
		cin>>a;
		d[a]++;
	}
	for(int i=N;;i++){
		int vis=0,temp;
		temp=i;
		while(temp){
			int m;
			m=temp%10;
			if(d[m]==0)
				temp=temp/10;
			else{
				vis=1;
				break;
			}
		}
		if(vis==0){
			printf("%d\n",i);
			return 0;
		}
	}
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp3
{
    class Program
    {
        static void Main(string[] args)
        {
            int L = int.Parse(Console.ReadLine());
            var imp = Console.ReadLine().Split(' ');
            Array.Sort(imp);
            
            Console.Write(int.Parse(imp[L - 1]) - int.Parse(imp[0]));
            
            //System.Threading.Thread.Sleep(1000);
        }
    }
    
}


Measured memory_bytes: 13408
#include <bits/stdc++.h>
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ldb;
 
#define endl '\n'
#define loop(i, m, n) for (lli i = m; i < n; i++)
#define loope(i, m, n) for (lli i = m; i <= n; i++)
#define epool(i, m, n) for (lli i = m; i >= n; i--)
#define maxe *max_element
#define mine *min_element
#define mod 1000000007
#define mod2 998244353
#define vt vector<lli>
#define fi first
#define se second
#define pb push_back
#define umap unordered_map
#define mmap multimap
#define MP make_pair
#define empf emplace_front
#define empb emplace_back
#define ret(x) return cout << x, 0;
#define all(v) v.begin(),v.end()

#define fast_io                       \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
using namespace std;
const lli INF=1e18;

int32_t main(){
    fast_io
    lli i = 0,j = 0;
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    //cout << fixed << setprecision(22);

    lli t;
    t=1;
    //cin >> t;
    lli cno=0;
    while (t--){
        int n;
        cin >> n;
        n=n%10;

        if(n==2 || n==4 || n==5 || n==7 || n==9) cout << "hon";
        else if(n==3) cout << "bon";
        else cout << "pon";
        cout << endl;

    }
}


Measured memory_bytes: 3648
integer town(4)
integer a,b
town=0
do i=1,3
  read*,a,b
  town(a)=town(a)+1
  town(b)=town(b)+1
end do
if(maxval(town)==3 )then
  print"(A)","NO"
else
  print"(A)","YES"
endif
end

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//definition of function
int max(int a,int b,int c){
  int max=a;
  if(b>max){
    max=b;
  }
  if(c>max){
    max=c;
  }
  return max;
}

int main(){
  int A,B; cin>>A>>B;
  vector<int> C(3);
  C[0]=A+B;
  C[1]=A-B;
  C[2]=A*B;
  int max_C=max(C[0],C[1],C[2]);
  cout<<max_C<<endl;
  return 0;
}
  

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

int main() {
  int a, b;
  cin >> a >> b;
  if(a == 1 && b != 1){
  cout << "Alice" << endl;}
  else if(a != 1 && b == 1){
  cout << "Bob" << endl;} 
  else if(a < b && a != 1){
  cout << "Bob" << endl;}
  else if(a > b && b != 1){
  cout << "Alice" << endl;}
  else{
  cout << "Draw" << endl;}
}

Measured memory_bytes: 3472
#include <bits/stdc++.h>
#include <unistd.h>
#include <sys/time.h>
#include <stdlib.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P, ll> T;
 
long long int INF = 1e18;
const ll fact_table = 1200008;
double Pi = 3.1415926535897932384626;

priority_queue <ll> pql;
priority_queue <P> pqp;
priority_queue <P> bag;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop
 
ll dx[8]={1,0,-1,0,1,1,-1,-1};
ll dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//↓,→,↑,←
 
 
#define p(x) cout<<x<<"\n";
#define el cout<<endl;
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define CLEAR(a) a = decltype(a)(); 
#define pc(x) cout << x << ",";
 
// ll mod = 998244353ll;
// ll mod = 1000000007;
  
ll mypow(ll number1,ll number2, ll mod){
 
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = mypow(number1,number2 / 2, mod);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
/*
ll rui(ll number1,ll number2){
 
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
 
    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
*/
void YES(bool condition){
 
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
 
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}
 
/*
ll fact[fact_table + 5],rfact[fact_table + 5]; 
 
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=fact_table; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
    rfact[fact_table] = rui(fact[fact_table],mod - 2);
    for(ll i=fact_table; i>=1; i--){
       rfact[i-1] = rfact[i] * i;
       rfact[i-1] %= mod;
    }
    return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod ) * rfact[n-r]) % mod;}
*/
bool multicase = false;

ll n,m,num,sum,a,b,c,d,e,h,q;
ll w, k, l, r;
ll x[500005], y[500005], z[500005];
char s[500005], t[500005];

void solve(){
    cin >> a >> b >> c;
    swap(a, b);
    swap(a, c);
    pe(a);pe(b);p(c);
    return;
}

int main(){
    // init();
    // ios::sync_with_stdio(false);
    // cin.tie(nullptr);
    
    ll q;
    if(multicase){
        cin >> q;
    }else{
        q = 1;
    }
    while(q--){
        // pu("Case ");pu("#");pu(testcase);pu(": ");
        solve();
    }
    
    // while(solve());
    // solve();
    return 0;

}


















Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
using namespace std;
int c[11];
int main(){
  for(int i=0;i<10;i++){
    cin>>c[i];
  }
  sort(c,c+10,greater<int>());
  cout<<c[0]<<"\n"<<c[1]<<"\n"<<c[2]<<"\n";
}

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

int main(){
	char a[26] = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
	long long i,k,n,b[26],ans;
	string s;
	cin >> s;
	for(k=0;k<26;k++){
		b[k]=0;
	}
	
	 n = s.size();
	for(k=0;k<26;k++){
		for(i=0;i<n;i++){
			if(s[i]==a[k]){
				b[k]++;
			}
		}
	}
	ans = n*(n-1)/2;
	for(k=0;k<26;k++){
		ans -= b[k]*(b[k]-1)/2;
	}
	
	cout << ans+1 << endl;
}
	
			
	

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

#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define pll         pair<long,long>
#define vi          vector<int>
#define vll         vector<ll>
#define vii         vector<pii>
#define Mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define rall(a)      (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define mod        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define rem(i,a,b)  for(int i=a;i>b;i--)
#define mp(a,b)     make_pair(a,b)
#define vvi(a,b,name)    vector<vector<int>> name(a,vector<int>(b,-1))




void solve(){
    ll n;cin>>n;
    ll four=0,two=0,rest=0;
    ll temp;
    rep(i,0,n){
        cin>>temp;
        if(temp%4==0)four++;
        else if(temp%2==0)two++;
        else rest++;
    }
    if(rest<=four)cout<<"Yes";
    else if(two==0 && rest==four+1)cout<<"Yes";
    else cout<<"No";
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    long t=1;
    //cin>>t;

    while(t--){
        solve();
    }
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    for(int i = 0; i < n; i++)  a[i] = 20002*(i+1);
    for(int i = 0; i < n; i++)  b[i] = 20002*(n-i);
    vector<int> r(n);
    for(int i = 0; i < n; i++){
        int x;  cin >> x;
        r[x-1] = i+1;
    }
    for(int i = 0; i < n; i++)  cout << a[i] << " \n"[i+1==n];
    for(int i = 0; i < n; i++)  cout << b[i]+r[i] << " \n"[i+1==n];
    return 0;
}

Measured memory_bytes: 896
import java.util.*;
import java.math.*;

public class Main{

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long d = sc.nextLong();
    long a = sc.nextLong();
    long[][] num = new long[n][2];
    for(int i = 0; i < n; ++i) {
      num[i][0] = sc.nextLong();
      num[i][1] = sc.nextLong();
    }
    Arrays.sort(num, new Comparator<long[]>() {
      public int compare(long[] x, long[] y){
        if(x[0] > y[0]) return 1;
        else return -1;
      }
    });
    long tot = 0;
    long res = 0;
    List<long[]> list = new LinkedList<>();
    for(int i = 0; i < n; ++i) {
      while(!list.isEmpty() && num[i][0] > list.get(0)[0]) {
        tot -= list.remove(0)[1];
      }
      long cur = num[i][1] - tot;
      if(cur > 0) {
        long time = cur / a + ((cur % a == 0) ? 0 : 1);
        list.add(new long[]{num[i][0] + 2 * d, time * a});
        tot += time * a;
        res += time;
      } 
    }
    System.out.println(res);
  }
}

Measured memory_bytes: 128616
n = int(input())
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

if n % min(a, b, c, d, e) == 0:
    print(n // min(a, b, c, d, e)+4)
else:
    print(n // min(a, b, c, d, e)+1+4)

Measured memory_bytes: 3064
// Copyright © 2020 Diego Garcia Rodriguez del Campo. All rights reserved.
#include<bits/stdc++.h>
#define MAX 200005
#define optimiza_io cin.tie(0); ios_base::sync_with_stdio(0);
#define what_is(x) cerr << #x << " is " << x << endl;
using namespace std;
typedef long long ll;
 
int N, A, B, C;
string si[MAX];
vector < char > ans;
bool vis[MAX][5][5][5];
bool memo[MAX][5][5][5];

void solve( int x , int a , int b , int c ) {
    if( x > N ) 
        return;
    if( si[x] == "AB" )  {
        if( memo[x + 1][a - 1][b + 1][c] ) {
            cout << "B\n";
            solve( x + 1 , a - 1 , b + 1 , c );
        } else {
            cout << "A\n";
            solve( x + 1 , a + 1 , b - 1 , c );
        }
    }
    if( si[x] == "AC" )  {
        if( memo[x + 1][a - 1][b][c + 1] ) {
            cout << "C\n";
            solve( x + 1 , a - 1 , b , c + 1 );
        } else {
            cout << "A\n";
            solve( x + 1 , a + 1 , b , c - 1 );
        }
    }
    if( si[x] == "BC" )  {
        if( memo[x + 1][a][b - 1][c + 1] ) {
            cout << "C\n";
            solve( x + 1 , a , b - 1 , c + 1 );
        } else {
            cout << "B\n";
            solve( x + 1 , a , b + 1 , c - 1 );
        }
    }
}
 

bool dp( int x , int a , int b , int c ) {
    if( a < 0 or b < 0 or c < 0 )
        return false;
    if( x > N ) 
        return memo[x][a][b][c] = true;
    if( vis[x][a][b][c] )
        return memo[x][a][b][c];
        
    vis[x][a][b][c] = 1;
    
    if( si[x] == "AB" ) 
        return memo[x][a][b][c] = dp( x + 1 , a - 1 , b + 1 , c ) | dp( x + 1 , a + 1 , b - 1 , c );
    if( si[x] == "AC" ) 
        return memo[x][a][b][c] = dp( x + 1 , a - 1 , b , c + 1 ) | dp( x + 1 , a + 1 , b , c - 1 );
    if( si[x] == "BC" ) 
        return memo[x][a][b][c] = dp( x + 1 , a , b + 1 , c - 1 ) | dp( x + 1 , a , b - 1 , c + 1 ); 
}
 
int main()
{
    optimiza_io
    cin >> N >> A >> B >> C;
    for( int i = 1; i <= N; i ++ )
        cin >> si[i];
    
    if( A > 4 ) A = 4;
    if( B > 4 ) B = 4;
    if( C > 4 ) C = 4;
    if( ! dp( 1 , A , B , C ) ) {
        cout << "No\n";
        exit( 0 );
    }
    
    cout << "Yes\n";
    solve( 1 , A , B , C );
    return 0;
}
 
// CHECAR LIMITES 
 
/*
 
2 1 1 0
AB
BC
 
*/

Measured memory_bytes: 42128
#include <bits/stdc++.h>
//#include <mylib.h>
using namespace std;
//cin.sync_with_stdio(false);

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define FOR_RE(i,a,b) for(int i = (a); i > (b); --i)
#define rep(i,n) FOR(i,0,n)
//1個上から時計周り
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
//上右下左
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> Vector;
typedef vector<Vector>  DVector;
int n;

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

    string s;
    cin >> s;
    int l = s.size();
    int flag = 0;
    int check1;
    bool check2 = true;
    //cout << l << endl;
    
    if(s[0] == 'A') flag++;
    //cout << flag << endl;
    
    check1 = strncmp("a", &s[1], 1);
    //checkが負の値ならs[i]は小文字
    if(check1 <= 0)    flag++;
    //cout << flag << endl;
    
    int count = 0;
    FOR(i, 2, l-1){
        check1 = strncmp("a", &s[i], 1);
        if(s[i] == 'C') count++;
        else if(check1 > 0)  check2 = false;
    }
    if(count == 1 && check2)  flag++;
    //cout << flag << endl;
    
    check1 = strncmp("a", &s[l-1], 1);
    //checkが負の値ならs[i]は小文字
    if(check1 <= 0)    flag++;
    //cout << flag << endl;
    
    if(flag == 4)   cout << "AC" << endl;
    else    cout << "WA" << endl;
    
    return 0;
}

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

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

	int h, w;
	int judge = 0;
	cin >> h >> w;
	while(h != 0 || w != 0){
		for (int i = 0; i < h; i++){
			for (int j = 0; j < w; j++){
				if (i % 2 == 0){
					if (j % 2 == 0){
						cout << '#';
					}
					else{
						cout << '.';
					}
				}
				else if (j % 2 == 0){
					cout << '.';
				}
				else{
					cout << '#';
				}
			}
			cout << '\n';
		}
		cout << '\n';
		cin >> h >> w;
	} 

	return 0;
}


Measured memory_bytes: 3104
#include<stdio.h>
int main(void)
{
	int n,m,a,s,d,x=0,w,p=0,h=0;
	scanf("%d %d %d %d %d",&n,&m,&a,&s,&d);
	w=1;
	x=s;
	h=d;
	while(1){
		if(m<=s&&a<=d) break;
		s+=x;
		d+=h;
		w++;
		
	}
	n=n-w;
	printf("%d\n",n);
}	

Measured memory_bytes: 2688
#include<bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define PI 3.141592653589793238462643383279502884L
#define Sort(vec) sort(vec.begin(),vec.end())
#define tr1(i) cout<<i<<endl;
#define tr2(i,j) cout<<i<<" "<<j<<endl;
#define tr3(i,j,k) cout<<i<<" "<<j<<" "<<k<<endl;
#define all(st) st.begin(),st.end()
#define vpll vector<pair<lli,lli>>
#define vpii vector<pair<int,int>>
#define al vector<list<int>>
#define vs vector<string>
#define vi vector<int>
#define vb vector<bool>
#define vl vector<lli>
#define vc vector<char>
#define rep(i,l,r) for(int i=l;i<r;i++)
#define repit(st) for(auto it=st.begin();it!=st.end();it++)
#define ulli unsigned long long int
#define pb push_back
#define lli long long int
#define inf INT_MAX
#define minf INT_MIN
#define f first
#define se second
#define mod 1000000007
#define mx 200001
using namespace std;
void add_me(lli &a,lli b){
    a+=b;
    if(a>=mod) a-=mod;
}   
void sub_me(lli &a,lli b){
    a-=b;
    if(a<0) a+=mod;
}
struct disjointset{
    int parent[mx];
   	disjointset(){
        for(int i=1;i<mx;i++) parent[i]=i;
    }
    int find(int x){
      	int par=parent[x];
        if(par==x) return x;
        return find(parent[x]);
    }
    void union_(int x,int y){
   	    int par1=find(x);
     	int par2=find(y);
       	if(par1==par2) return;
       	parent[par2]=par1;
    }
};
lli mi(lli n,lli m){
	lli pw=n;
	lli ex=m-2;
	lli ans=1;
	while(ex){
		if(ex&1) ans = ans*pw%m;
		pw = pw*pw%m;
		ex>>=1;
	}
	return ans;
}
const int mxm = 200001;
bool is_prime[mxm];
void solve(){
	for(int i=2;i*i<=mxm;i++){
		if(is_prime[i]){
			for(int j=i*i;j<mxm;j+=i) is_prime[j]=false;
		}
	}
}
int main(){
	FIO;
	memset(is_prime,true,sizeof(is_prime));
	solve();
	lli x;cin>>x;
	while(!is_prime[x]){
		x++;
	}
	cout<<x<<endl;
	
	
	
	
}

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

#define ALL(a) begin(a), end(a)
#define TPL template
#define TNM typename

using ll = long long;
using ull = unsigned long long;

TPL<TNM T> using vec = vector<T>;
TPL<TNM T> using vec2 = vec<vec<T>>;
TPL<TNM T> using vec3 = vec<vec2<T>>;
TPL<TNM T> using vec4 = vec<vec3<T>>;
TPL<TNM T> using vec5 = vec<vec4<T>>;

TPL<TNM T> inline istream& operator >> (istream& is, vector<T>& vec) { for (T& x : vec) is >> x; return is; }
TPL<TNM V, TNM H> void resize(vector<V>& _v, const H _h) { _v.resize(_h); }
TPL<TNM V, TNM H, TNM ... T> void resize(vector<V>& _v, const H& _h, const T& ... _t) { _v.resize(_h); for (auto& __v : _v) resize(__v, _t ...); }
TPL<TNM V, TNM T> TNM enable_if<!is_class<V>::value>::type fill(vector<V>& _v, const T& _t) { std::fill(ALL(_v), _t); }
TPL<TNM V, TNM T> TNM enable_if<is_class<V>::value>::type fill(vector<V>& _v, const T& _t) { for (auto& _e : _v) fill(_e, _t); }
TPL<TNM T> inline void UNIQUE(vector<T>& _v) { sort(ALL(_v)); _v.erase(unique(ALL(_v)), _v.end()); }
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(6); } } pre__;

int main(void) {
	int N;
	cin >> N;
	int cx = 0, cy = 0, ct = 0;
	for (int i = 0; i < N; ++i) {
		int t, x, y;
		cin >> t >> x >> y;
		int d = abs(cx - x) + abs(cy - y);
		if (d > t - ct) {
			cout << "No" << endl;
			return 0;
		}
		if ((t - d) % 2 != 0) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;

	return 0;
}

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

int main()
{
	int N, A[100100], B[100100];
	cin >> N;
	for (int i = 1; i < N+1; i++)
	{
		cin >> A[i];
	}
	for (int i = 1; i < N+1; i++)
	{
		B[A[i]] = i;
	}
	for (int i = 1; i < N; i++)
	{
		cout << B[i] << " " ;
	}
	cout << B[N] << endl;
	return 0;
}

Measured memory_bytes: 1664
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        int K = scan.nextInt();
        int S = scan.nextInt();
        if(N==K){
            for(int i=0;i<N;i++){
                System.out.print(S);
                System.out.print(" ");
            }
        }else if(S==1000000000){
            for(int i=0;i<K;i++){
                System.out.print(1000000000);
                System.out.print(" ");
            }
            for(int i=0;i<N-K;i++){
                System.out.print(999999999);
                System.out.print(" ");
            }
        }else{
            for(int i=0;i<K;i++){
                System.out.print(S);
                System.out.print(" ");
            }
            for(int i=0;i<N-K;i++){
                System.out.print(S+1);
                System.out.print(" ");
            }
        }
    }
}


Measured memory_bytes: 43460
n = int(input())
a_list = list(map(int, input().split()))
b_list = []
for i in range(n):
	b_list.append(0)

for i in range(n):
	b_list[a_list[i]-1] = i+1
	
b_list =[str(z) for z in b_list]
b_list=' '.join(b_list)
print(b_list)

Measured memory_bytes: 17736
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
const int MOD = 1E9 + 7;
const int INF = 1 << 29;

int main() {
  int N, M;
  cin >> N >> M;
  int left = 1, right = M + 1;
  while (left < right) {
    cout << left << ' ' << right << endl;
    left++;
    right--;
  }
  left = M + 2, right = 2 * M + 1;
  while (left < right) {
    cout << left << ' ' << right << endl;
    left++;
    right--;
  }
}

Measured memory_bytes: 3600
import sys
import math
import collections
import heapq

def set_debug(debug_mode=False):
    if debug_mode:
        fin = open('input.txt', 'r')
        sys.stdin = fin


def int_input():
    return list(map(int, input().split()))


if __name__ == '__main__':
    # set_debug(True)

    # t = int(input())
    t = 1

    for ti in range(1, t + 1):
        a, b, c = int_input()

        if (a == b == 5 and c == 7) or (a == c == 5 and b == 7) or (b == c ==5 and a == 7):
            print('YES')
        else:
            print('NO')



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

using namespace std;

const int N = 101700;
int wa[N], wb[N], wv[N], Ws[N];
int Rank[N]; //名次数组
int height[N]; //排名相邻的两个后缀的最长公共前缀
char str[N];
int s[N], sa[N]; //sa为后缀数组,n个后缀从小到大进行排序之后把排好序的后缀的开头位置

int Max(int a, int b) {
    return a > b ? a : b;
}

int Min(int a, int b) {
    return a < b ? a : b;
}

int cmp(int *r, int a, int b, int l) {
    return r[a] == r[b] && r[a + l] == r[b + l];
}

//get_sa函数的参数n代表字符串中字符的个数，这里的n里面是包括人为在字符串末尾添加的那个0的
//get_sa函数的参数m代表字符串中字符的取值范围，是基数排序的一个参数，
//如果原序列都是字母可以直接取128，
//如果原序列本身都是整数的话，则m可以取比最大的整数大1的值。
void get_sa(int *r, int *sa, int n, int m) //倍增算法
{
    int i, j, p, *x = wa, *y = wb, *t;
    for (i = 0; i < m; i++) Ws[i] = 0;
    for (i = 0; i < n; i++) Ws[x[i] = r[i]]++;
    for (i = 1; i < m; i++) Ws[i] += Ws[i - 1];
    for (i = n - 1; i >= 0; i--) sa[--Ws[x[i]]] = i; //对长度为1的字符串排序
    for (p = 1, j = 1; p < n; j *= 2, m = p) {
        for (p = 0, i = n - j; i < n; i++) y[p++] = i;
        for (i = 0; i < n; i++) if (sa[i] >= j) y[p++] = sa[i] - j; //第二关键字排序结果

        for (i = 0; i < n; i++) wv[i] = x[y[i]];
        for (i = 0; i < m; i++) Ws[i] = 0;
        for (i = 0; i < n; i++) Ws[wv[i]]++;
        for (i = 1; i < m; i++) Ws[i] += Ws[i - 1];
        for (i = n - 1; i >= 0; i--) sa[--Ws[wv[i]]] = y[i]; //第一关键字排序

        for (t = x, x = y, y = t, p = 1, x[sa[0]] = 0, i = 1; i < n; i++)
            x[sa[i]] = cmp(y, sa[i - 1], sa[i], j) ? p - 1 : p++; //更新rank数组
    }
    return;
}

void get_height(int *r, int *sa, int n) //求height数组
{
    int i, j, k = 0;
    for (i = 1; i <= n; i++) Rank[sa[i]] = i;
    for (i = 0; i < n; height[Rank[i++]] = k)
        for (k ? k-- : 0, j = sa[Rank[i] - 1]; r[i + k] == r[j + k]; k++);
    return;
}

int main() {
    int zz;
    cin >> zz;
    scanf("%s", str);
    int len = strlen(str);
    for (int i = 0; i < len; i++)
        s[i] = str[i] - 'a' + 1;
    s[len] = 0;//这个赋值为0是关键所在
    get_sa(s, sa, len + 1, 27);
    get_height(s, sa, len);
    //for(int i=0;i<len+1;i++) printf("%d %d\n",i,sa[i]);
    int ans = 0;
    int mm = 0;
    for (int i = 1; i <= (len + 1) / 2; i++) {
        //查一半就好了，长度大于（len+1）/2的子串不可能重复俩次啦
        //长度为i的重复子串
        int minn = N;
        int maxn = -1;
        for (int j = 1; j <= len; j++) {
            if (height[j] >= i)//连续
            {
                minn = Min(minn, Min(sa[j - 1], sa[j]));
                maxn = Max(maxn, Max(sa[j - 1], sa[j]));
            } else//若height的值不是连续大于i的
            {
                if (minn + i <= maxn)
                    ans++, mm = max(i, mm);
                minn = N, maxn = -1;
            }
        }
        if (minn + i <= maxn)
            ans++,mm=max(i,mm);
    }
    printf("%d\n",mm);
//    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a.at(i);
  sort(a.rbegin(), a.rend());
  ll ans = 0;
  if(n % 2 == 0){
    rep(i, n/2){
      if(i == 0) ans += a.at(i);
      else ans += (ll)a.at(i)*2;
    }
  }else{
    rep(i, n/2+1){
      if(i == 0 || i == n/2) ans += a.at(i);
      else ans += (ll)a.at(i)*2;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4044
import numpy as np

N, M, X = map(int, input().split())
I = [list(map(int,input().split())) for x in range(N)]
I2 = [I[y].pop(0) for y in range(N)]
total = np.array([0]*len(I[0]))
ans = []
def check(n,total,cost):
    if n > N-1:
        if min(total) >= X:
            ans.append(cost)
            return
        return
    else:
        array = np.array(I[n])
        check(n+1, total + array, cost + I2[n])
        check(n+1, total, cost)
check(0, total, 0)
if not ans:
    print(-1)
else:
    print(min(ans))

Measured memory_bytes: 27276
import java.util.*;
class Main {
    static int A,B,C;
    static int[] array;
    static int N;
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	N = Integer.parseInt(sc.next());
	A = Integer.parseInt(sc.next());
	B = Integer.parseInt(sc.next());
	C = Integer.parseInt(sc.next());
	array = new int[N];
	for(int i = 0; i<N; i++) {
	    array[i] = Integer.parseInt(sc.next());
	}

	System.out.println(dfs(0,0,0,0,0));
    }

    public static int dfs(int depth, int za, int zb, int zc, int cost) {
	if(depth == N) {
	    if(za>0 && zb>0 && zc>0) return (int)Math.abs(za-A) + (int)Math.abs(zb-B) + (int)Math.abs(zc-C) + cost;
	    else return Integer.MAX_VALUE;
	}
	int notadd = dfs(depth+1, za, zb, zc, cost+0);
	int adda, addb,addc = 0;
	if(za == 0) {
	    adda = dfs(depth+1, za + array[depth], zb, zc, cost+0);
	} else {
	    adda = dfs(depth+1, za + array[depth], zb, zc, cost+10);
	}

	if(zb == 0) {
	    addb = dfs(depth+1, za, zb + array[depth], zc, cost);
	} else {
            addb = dfs(depth+1, za, zb + array[depth], zc, cost+10);
	}

	if(zc == 0) {
            addc = dfs(depth+1, za, zb, zc + array[depth], cost);
	} else {
            addc = dfs(depth+1, za, zb, zc + array[depth], cost+10);
        }

	int min = Math.min(notadd, adda);
	min = Math.min(min, addb);
	min = Math.min(min, addc);
	return min;
    }

}

Measured memory_bytes: 22996
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807

int main(){

    int A,B,K;
    cin >> A >> B >> K;

    for(int i=0; i<K; i++){
        if(i % 2 == 0){
            A = A / 2;
            B += A;
        }
        if(i % 2 == 1){
            B = B / 2;
            A += B;
        }
    }
    cout << A << " " << B << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<math.h>
#include<utility>

#define lli long long
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define rep0(i,j) for(int i=0;i<j;i++)
#define rep1(i,j) for(int i=1;i<=j;i++)
#define rep0d(i,j) for(int i=j-1;i>=0;i--)
#define MAX 1000000007
int a[2001][2001];
using namespace std;


int main() {
	lli l,r,min=MAX;
	cin >> l >> r;
	
	if(l%2019>r%2019||l+2019<=r)cout << 0;
	else{
	for(int i=l%2019; i<r%2019;i++){
		for(int j=i+1;j<=r%2019;j++){
			if((i*j)%2019<min)min=(i*j)%2019;	
		}	
		
	}
	cout << min;

	}
}


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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)

typedef long long LL;
typedef pair<int, int> pii;

const int INTINF = 1e9;
const LL LLINF = 1e18;

int C[501];
int S[501];
int F[501];

void solve()
{
    int N;
    cin >> N;

    REP0(i, N - 1)
    {
        cin >> C[i] >> S[i] >> F[i];
    }

    REP0(i, N - 1)
    {
        // i 駅目から出るのにかかる時間. 以下、経過時間として扱う
        int t = S[i] + C[i];
        FOR(j, i + 1, N - 1)
        {
            if (S[j] < t)
            {
                t += (F[j] - (t - S[j]) % F[j]) % F[j] + C[j];
            }
            else
            {
                t += S[j] - t + C[j];
            }
        }
        cout << t << endl;
    }

    cout << 0 << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(10);
    solve();
    return 0;
}

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

int main() {
  int N;
  int sum=0;
  cin >> N;
  
  vector<int> math(N);
 
  for (int i = 0; i < N; i++) {
    cin >> math.at(i);
  }
  
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
    if(i!=j) sum+=math.at(i)*math.at(j);
    }
  }
  cout << sum/2 << endl;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define m 1000000007
using namespace std;
int h,w;
vector<vector<char>> g(1000,vector<char>(1000));
vector<vector<long long>> dp(1000,vector<long long>(1000,-1));
long long grid(int i,int j){
    if(i<0 or j<0)return 0;
    if(i==0 &&j==0)return 1;
    if(g[i][j]=='#')return 0;
    if(dp[i][j]!=-1)return dp[i][j];
    dp[i][j] = grid(i-1,j)+grid(i,j-1);
    return dp[i][j]%m;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>h>>w;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>g[i][j];
        }
    }
    cout<<grid(h-1,w-1)<<"\n";
    return 0;
}

Measured memory_bytes: 9216
N, M = map(int, input().split())
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]
for i in range (N-M+1):
    for j in range(N-M+1):
        for k in range(M):
            if A[k+i][j:j+M] != B[k]:
                break
        else:
            print("Yes")
            exit()
print("No")
        

Measured memory_bytes: 3060
package main

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

func main() {
	N, W := ReadInt(), ReadInt()

	ws := make([]int, N+1)
	vs := make([]int, N+1)

	for i := 1; i <= N; i++ {
		ws[i], vs[i] = ReadInt(), ReadInt()
	}

	dp := [101][1e5 + 1]int{}
	for i := 1; i <= N; i++ {
		for w := 1; w <= W; w++ {
			dp[i][w] = dp[i-1][w]
			if w-ws[i] >= 0 {
				dp[i][w] = Max(dp[i][w], dp[i-1][w-ws[i]]+vs[i])
			}
		}
	}
	fmt.Println(dp[N][W])
}

func Max(xs ...int) int {
	max := xs[0]
	for _, x := range xs[1:] {
		if max < x {
			max = x
		}
	}
	return max
}

var sc = bufio.NewScanner(os.Stdin)

func init()        { sc.Buffer(make([]byte, 256), 1e9); sc.Split(bufio.ScanWords) }
func Read() string { sc.Scan(); return sc.Text() }

func ReadInt() int {
	v, e := strconv.Atoi(Read())
	if e != nil {
		panic(e.Error())
	}
	return v
}


Measured memory_bytes: 82516
#include <iostream>

//ABC42

int main()
{
	int a[3];
	std::cin >> a[0] >> a[1] >> a[2];
	if (a[0] * a[1] * a[2] == 175) std::cout << "YES" << std::endl;
	else std::cout << "NO" << std::endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}
int dx[4]={0,1,-1,0};
int dy[4]={1,0,0,-1};



signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    ll n;
    cin>>n;
    ll a[n],b[n];
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i];
        ll x = a[i] + b[i], y = a[i] - b[i];
        a[i] = x, b[i] = y;
    }
    ll ans = 0;
    sort(a,a+n);
    sort(b,b+n);
    ans = max(a[n-1]-a[0], b[n-1]-b[0]);
    cout << ans << endl;
}

Measured memory_bytes: 6776
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;

int A, B;

int main() {
	cin >> A >> B;
	if (A <= 5) cout << "0" << endl;
	else if (A <= 12) cout << B / 2 << endl;
	else cout << B << endl;
	return 0;
}

Measured memory_bytes: 3608
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.nextLine();
    for(char i='a';i<='z';i++){
      if(s.indexOf(i) == -1){
        System.out.println(i);
        break;
      }else if(i == 'z'){
        System.out.println("None");
      }
    }
  }
}

Measured memory_bytes: 26300
#include<cstdio>
#include<stdint.h>
#define int long long
int T,a,b,L,R,x,l,r,ans;
inline bool check(int c){
	int aa=a-(c/(x+1)*x+c%(x+1)),bb=b-c/(x+1);
	return aa*x>=bb;
}
int32_t main(){
	for(scanf("%lld",&T);T--;){
		scanf("%lld%lld%lld%lld",&a,&b,&L,&R);
		x=((a>b?a:b)-1)/((a<b?a:b)+1)+1,l=1,r=(a+b)/(x+1),ans=0;
		while(l<=r){
			const int mid=l+r>>1;
			if(check(mid*(x+1)))l=(ans=mid)+1;else r=mid-1;
		}
		ans*=x+1;
		int aa=a-(ans/(x+1)*x+ans%(x+1)),bb=b-ans/(x+1);
		int exta=aa-bb/x,extb=bb%x;
		for(int i=L;i<=R;++i)
		if(i<=ans)putchar(i%(x+1)?'A':'B');else
		if(i<=ans+exta)putchar('A');else
		if(i<=ans+exta+extb)putchar('B');else
		putchar((i-ans-exta-extb)%(x+1)==1?'A':'B');
		putchar('\n');
	}
	return 0;
}

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

int main(){
  int n,i,j,ans=0;
  cin >> n;
  double sum,ave,eps=0.0001,min=100.0;
  vector<double> a(n);
  for(i=0; i<n; i++){
    cin >> a[i];
    sum+=a[i];
  }
  sum/=n;
  for(i=0; i<n; i++){
    a[i]-=sum;
    if(abs(a[i])<abs(a[ans])-eps){
      ans=i;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
A,B,C,X,Y=map(int,input().split())
ans=0
if X>Y:
  A,B=B,A
  X,Y=Y,X
if A+B<C*2:
  ans+=(A+B)*X
else:
  ans+=C*X*2

Y-=X
tmp=B*Y
for y in range(Y):
  tmp2=B*y+C*(Y-y)*2
  if tmp > tmp2:
    tmp=tmp2
print(ans+tmp)

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

int main()
{

	int n,k;
	while(cin>>n){
	k=0;
	for(int i=0;i<10;i++){
		for(int j=0;j<=(n-i)&&j<10;j++){
			for(int h=0;h<=(n-(i+j))&&h<10;h++){
				for(int g=0;g<=(n-(i+(j+h)))&&g<10;g++){
					if((i+j+h+g)==n){
						k++;
					}
				}
			}
		}
	}

	cout<<k<<endl;
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#ifdef __DEBUG__
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const deque<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const set<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int H,W,K;
vector<string> pond;
int sx,sy,tx,ty;
void input(){
    fast_io();
    cin >> H >> W >> K;
    cin >> sx >> sy >> tx >> ty;
    sx--,sy--;
    tx--,ty--;
    for (int i = 0; i < H; i++)
    {
        string s; cin >> s;
        pond.push_back(s);
    }
}

#define x first
#define y second

int solve(){
    queue<pair<int,pii> > q;
    q.emplace(0,make_pair(sx,sy));
    vector<vector<int>> dist(H,vector<int>(W,INT_INF));
    dist[sx][sy] = 0;
    map<pii,pii> pref;
    while (!q.empty())
    {
        int d = q.front().first;
        pii cur = q.front().second;
        q.pop();
        if(dist[cur.x][cur.y]<d) continue;
        for (int k = 0; k < 4; k++)
        {
            for (int t = 1; t <= K; t++)
            {
                pii next = cur;
                next.x += t*dx[k];
                next.y += t*dy[k];
                if(next.x<0 || next.x>=H) break;
                if(next.y<0 || next.y>=W) break;
                if(pond[next.x][next.y]=='@') break;
                if(dist[next.x][next.y]<=dist[cur.x][cur.y]) break;
                if(dist[next.x][next.y]<=d+1) continue;
                dist[next.x][next.y]=d+1;
                pref[next] = cur;
                if(next.x==tx && next.y==ty) break;
                q.emplace(d+1,next);
            }
        }
    }
    if(dist[tx][ty]==INT_INF) {cout << -1 << endl; return 0;}
    else cout << dist[tx][ty] << endl;      
    return 0;
}   

#undef x
#undef y

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

Measured memory_bytes: 56204
X, N = map(int, input().split())
P = set(map(int, input().split()))

if N == 0:
    print(X)
    exit()
ans = None
plus = 0
while True:
    if X - plus not in P:
        ans = X-plus
        break
    elif X + plus not in P:
        ans = X + plus
        break
    plus += 1

print(ans)

Measured memory_bytes: 9192
import sys
import numpy as np


def input():
    return sys.stdin.readline().strip()


sys.setrecursionlimit(10 ** 9)


def main():
    N = int(input())
    A = np.array(list(map(int, input().split())))
    B = np.array(list(map(int, input().split())))
    diff = A - B
    lack = -diff[diff < 0]
    enough = diff[diff > 0]
    x = lack.sum()
    enough.sort()
    enough = reversed(enough)
    s = 0
    ans = 0
    for e in enough:
        if s < x:
            s += e
            ans += 1
        else:
            break
    if s < x:
        print(-1)
    else:
        print(len(lack) + ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 23920
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <stack>
#include <queue>
#include <cctype>
#include <complex>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <cassert>
#include <iomanip>

typedef long long ll;
using namespace std;


const int MAX = 25*3600;

bool solve(){
	
	int n;
	cin>> n;
	if(!n) return false;
	
	vector<int> v(MAX,0);
	for(int k=0;k<n;k++){
		int in[2] = {0};
		for(int i=0;i<2;i++){
			int h,m,s;
			char c[2];
			cin>> h>> c[0]>> m>> c[1]>> s;
			in[i] = 3600 * h + 60 * m + s;
		}
		for(int i=in[0]; i<in[1]; i++) v[i]++;
	}
	
	cout<< *max_element(v.begin(), v.end()) << endl;

	return true;
}

int main(){
	cout.setf(ios::fixed);
	cout.precision(10);
	
	while(solve());

	return 0;
}

 

Measured memory_bytes: 1544
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin>>S;
  int ans=0,count=0;
  for(int i=0;i<S.size();i++){
    if(S.at(i)=='A'||S.at(i)=='C'||S.at(i)=='G'||S.at(i)=='T'){
      count++;
      }
    else{
      ans=max(ans,count);
      count=0;
      }
    }
  ans=max(ans,count);
  cout<<ans;
  }

Measured memory_bytes: 256
import Control.Monad (replicateM)
main :: IO ()
main = do
    n <- readLn
    ws <- replicateM n getLine
    case nodup ws of
        True -> putStrLn "Yes"
        False -> putStrLn "No"

nodup [] = True
nodup (a:[]) = True
nodup (a:b:c) = (last a) == (head b) && (notElem a (b:c)) && nodup (b:c)

Measured memory_bytes: 636
#pragma GCC optimize("Ofast")  
#pragma GCC target("avx,avx2,fma") 
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define ALL(x) x.begin(),x.end()
#define PB push_back
#define EB emplace_back
#define F first
#define S second
#define ll long long
#define MP make_pair
// #define int long long
// #define MAX LONG_LONG_MAX
// #define MIN LONG_LONG_MIN
#ifdef LOCAL // setting up print debugging (yes lol)
template<class K, class V>ostream& operator<<(ostream&s,const pair<K,V>&p){s<<'<'<<p.x<<','<<p.y<<'>';return s;}
template<class T, class=typename T::value_type, class=typename enable_if<!is_same<T,string>::value>::type>
ostream& operator<<(ostream&s,const T&v){s<<'[';for(auto&x:v){s<<x<<", ";}if(!v.empty()){s<<"\b\b";}s<<']';return s;}
void __prnt(){cerr<<endl;} template<class T, class...Ts>void __prnt(T&&a,Ts&&...etc){cerr<<a<<' ';__prnt(etc...);}
#define print(...) __prnt(__VA_ARGS__)
#else
#define print(...)
#endif
using namespace std;

const size_t MAXN = 1e5 +7;
const ll MOD = 1e9+7;

void check(){
	ll dp[10007] = {0} ,n;
	dp[0] = 1;
	cin >> n;
	for(ll i = 0; i < n ;i++){
		for(ll j = i+3; j <= n ;j++){
			dp[j] = (dp[j]+dp[i])%MOD;
		}
	}
	cout << dp[n];
}

int32_t main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); 
	cin.exceptions(cin.failbit);
	int t = 1;	
	// cin >> t;
	for(int i = 1 ; i <= t ;i++){
		// cout << "Case "<< i << ":\n";
		check();
	}
	return 0;
}


Measured memory_bytes: 3744
#include <bits/stdc++.h>
using namespace std;
int func(int a, int b) {
  int res = 0;
  while(a > 0) {
    res += a % b;
    a /= b;
  }
  return res;
}

int main() {
  int n;
  cin >> n;
  int res = n;
  for (int i = 0; i <= n; i++) {
    int c = func(i, 6) + func(n - i, 9);
    res = min(res, c);
  }
  cout << res << endl;
}

Measured memory_bytes: 256
import Foundation
let main: () = {
    let (N, M) = *listOfInt()
    var s = Array(N + 1) { $0 }
    s.insert(0, at: 0)
    for n in 1 ... N + 1 { s[n] += s[n - 1] }
    var ans = 0
    for n in M ... N + 1 {
        let min = s[n] - s.first!
        let max = s.last! - s[N - n + 1]
        ans += max - min + 1
        ans %= 1000000007
    }
    print(ans)
}()

@inlinable func next() -> String { readLine()! }
@inlinable func nextInt() -> Int { Int(next())! }
@inlinable func listOfString() -> [String] { next().split(separator: " ").map(String.init) }
@inlinable func listOfInt() -> [Int] { listOfString().map { Int($0)! } }
extension Array {
    init(_ size: Int, _ initValue: ((Int) -> Element)) {
        self = [Element]()
        for index in 0 ..< size {
            let value = initValue(index)
            self.append(value)
        }
    }
}

prefix operator *
prefix func * <T> (a: [T]) -> (T, T) { (a[0], a[1]) }


Measured memory_bytes: 14416
#include <stdio.h>

int main(void)
{
	int a, b;		//Value a, b.

	scanf("%d %d", &a, &b);
	printf("a ");
	if(a < b)
		printf("< ");
	if(a > b)
		printf("> ");
	if(a == b)
		printf("== ");
	printf("b\n");

	return (0);
}



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

int main(){
    string s;
    cin >> s;

    int count0 = 0;
    int count1 = 0;
    for(int i=0; i<s.size(); i++){
        if(s[i] == '1') count1 += 1;
        if(s[i] == '0') count0 += 1;
    }
    cout << 2 * min(count1, count0) << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n , t, a ;
  cin >> n >> t >> a;
  a = a *1000;
  int ans ;
  int sa = 1<<30;
  for(int i = 0;i<n;i++){
    int h;
    cin >> h;
    int d = 1000*t - 6*h;
    int D = max(a,d) - min(a,d);
    if( sa > D){
      sa = D;
      ans = i+1;
    }
  }
  cout << ans;
 

}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String ans = "yes";
		for(int i = 0; i < s.length()-1; i++) {
			for(int j = i+1; j < s.length(); j++) {
				if(s.charAt(i)==s.charAt(j)) {
					ans = "no";
				}
			}
		}
		System.out.println(ans);
	}
}

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

int main(){
  string s;
  int k;
  cin >>k >>s;
  if(k<s.size()) cout << s.substr(0,k) << "..." << endl;
  else cout << s << endl;
  return 0;
}

Measured memory_bytes: 3528