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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h,w; cin>>h>>w;
    vector<vi> c(10,vi(10));
    rep(i,10)rep(j,10){
        cin>>c[i][j];
    }
    rep(k,10)rep(i,10)rep(j,10)
        chmin(c[i][j],c[i][k]+c[k][j]);
    ll ans=0;
    rep(i,h)rep(j,w){
        int a; cin>>a;
        if (a==-1) continue;
        ans+=c[a][1];
    }
    cout<<ans<<endl;
    return 0;
}


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

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

	if (X == 2)
	{
		cout << 2 << endl;
		return 0;
	}

	bool divided = false;
	int ans;

	if (X % 2 == 0)
	{
		for (int i = X + 1; i <= 100003; i += 2)
		{
			divided = false;
			for (int j = 3; j < i; j += 2)
			{
				if (i % j == 0)
				{
					divided = true;
					break;
				}
			}
			if (divided == false)
			{
				ans = i;
				break;
			}
		}
	}

	if (X % 2 == 1)
	{
		for (int i = X; i <= 100003; i += 2)
		{
			divided = false;
			for (int j = 3; j < i; j += 2)
			{
				if (i % j == 0)
				{
					divided = true;
					break;
				}
			}
			if (divided == false)
			{
				ans = i;
				break;
			}
		}

	}

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

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

int main() {
	long long N, b=0, c=0, d=0;
	cin >> N;
	for(int a=0; a<N; a++)
	{
		if(N ==1)
		{
			b = 1;
			break;
		}
		if(a == 0)
		{
			d = 2;
		}
		else if(a == 1)
		{
			d = 1;
		}
		b = c + d;
		c = d;
		d = b;
	}
	cout << b << endl;
	
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
const int N = 1e6 +5;
int a[N];
long long ans;
int main(){
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++){
		if(i % 3 == 0 && i % 5 == 0) a[i] = 0;
		else if (i % 3 == 0) a[i] = 0;
		else if (i % 5 == 0) a[i] = 0;
		else a[i] = i;
	}
	for(int i = 1; i <= n; i++)
		ans += a[i];
		cout << ans << endl;
}


Measured memory_bytes: 7472
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

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

const int MAX_A = 1000000;
const int INF = INT_MAX / 2;

vector<int> memo[MAX_A + 1];

int f(const int x) {
    if (x % 2 == 0) {
        return x / 2;
    } else {
        return x * 3 + 1;
    }
}

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

    memo[s].push_back(1);

    int prev = s;
    for (int i = 2; i <= MAX_A; i++) {
        int v = f(prev);
        memo[v].push_back(i);
        prev = v;
    }

    int ans = INF;
    for (int i = 1; i <= MAX_A; i++) {
        if ((int) memo[i].size() < 2) continue;
        chmin(ans, memo[i][1]);
    }

    cout << ans << endl;

    return 0;
}


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

using namespace std;

bool solve(int n){
  int cnt=0;
  while(n){
   int rem = n%10;
    cnt++;
    n = n/10;
  }

  if(cnt%2 == 1)
     return true;

  return false;
}


int main(){

int n,cnt=0;
 cin>>n;

 for(int i=1;i<=n;i++){
    if(solve(i) == true){
        //cout<<i<<endl;
        cnt += 1;

    }
 }

 cout<<cnt<<endl;


return 0;
}


Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ll n,m;
    cin >> n >> m;
    vector<pair<ll,ll>> ab(n,pair<ll,ll>());
    int a,b;
    for(int i = 0;i < n;i++){
        cin >> a >> b;
        ab[i].first = a;
        ab[i].second = b;        
    }
    sort(ab.begin(),ab.end());
    int j = 0;
    ll ans = 0;
    priority_queue<ll> baito;
    for(int i = m;i >= 0;i--){
        baito.push(0);
        while(m-ab[j].first == i){
            baito.push(ab[j].second);
            j++;
        }
        ans += baito.top();
        baito.pop();
    }
    cout << ans << endl;
}


Measured memory_bytes: 2936
N = gets.chomp.to_i
A = gets.chomp.split(" ").map(&:to_i)
MOD = 1000000007

ans = 1
cnt = [0, 0, 0]
A.each do |a|
  c = cnt.count { |v| v == a }
  i = cnt.index { |v| v == a }
  ans = ans * c % MOD
  if i.nil?
    puts 0
    exit
  end
  cnt[i] += 1
end
puts ans


Measured memory_bytes: 8708
#include <iostream>
#include <algorithm>
#include <string>
#include  <queue>
#include <vector>
#include  <cstdio>
#include <cstring>
//#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define I(a) scanf("%d",&a)
#define I2(a,b) scanf("%d%d",&a,&b)
#define I3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define L(a) scanf("%lld",&a)
#define L2(a,b) scanf("%lld%lld",&a,&b)
#define L3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define PI(a) printf("%d",a)
#define PL(a) printf("%lld",a)
#define PT(t) printf("Case %d: ",t)
#define PB push_back
#define x first
#define y second
#define xx first.first
#define xy first.second
#define yx second.first
#define yy second.second
#define SC scanf
#define PC printf
#define NL printf("\n")
#define SET(a) memset(a,0,sizeof a)
#define SETR(a) memset(a,-1,sizeof a)
#define SZ(a) ((int)a.size())-1
#define f(i,a,b) for(int i=a;i<=b; i++)
#define fr(i,a,b) for(int i=a;i<=b; i++)
#define frr(i,a,b) for(int i=a;i>=b; i--)
#define frv(i,a)  for(int i=0;i<a.size();i++)
#define pi 2.0*acos(0.0)
#define R(a) freopen(a, "r", stdin);
#define W(a) freopen(a, "w", stdout);
#define CB(x) __builtin_popcount(x)
#define STN(a) stringtonumber<ll>(a)
#define lol printf("BUG\n")
#define Endl "\n"
#define mk make_pair
using namespace std;
template <class T> inline T BM(T p, T e, T M)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    }
    return (T)ret;
}
template <class T> inline T mul(T p, T e, T M)
{
    ll ret = 0;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret + p) ;
        p = (p + p) ;
        if(ret>=M)ret-=M;
        if(p>=M)p-=M;
    }
    return (T)ret;
}
template <class T> inline T gcd(T a, T b)
{
    if(b == 0)return a;
    return gcd(b, a % b);
}
template <class T> inline T mdINV(T a, T M)
{
    return BM(a, M - 2, M);
}
template <class T> inline T PW(T p, T e)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p);
        p = (p * p);
    }
    return (T)ret;
}
 
 
template <class T>bool ISLEFT(T a, T b, T c)
{
    if(((a.xx - b.xx) * (b.yy - c.yy) - (b.xx - c.xx) * (a.yy - b.yy)) < 0.0)return 1;  //Uporer dike //A,b,c, x okkher ordera sorted
    else return 0;
}
 

#define  mx 200004
#define base 193ll
 
typedef pair<int,int >P;
//////////////////////////
////////////////////////
#define F(i,a,b) for(int i=a;i<b; i++)
#define LL long long
#define MX  200007
#define md 998244353ll
///////////////////////////
///////////////////////////
///

int main(){
	int k;
	I(k);
	ll res = 0;

	int dp[202][202];

	for(int i = 1;i<=200;i++){
		for(int j = 1;j<=200;j++){
			dp[i][j] = gcd(i,j);
		}
	}
	for(int i = 1;i<=k;i++){
		for(int j = 1;j<=k;j++){
			for(int l = 1;l<=k;l++){
				res += dp[dp[i][j]][l];
			}
		}
	}

	cout<<res<<endl;

	return 0;
}

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

int main() {
    int ans = 0;
    string W, T;
    cin >> W;
    while (true) {
        cin >> T;
        if (T == "END_OF_TEXT") {
            break;
        }
        if (W.size() != T.size()) {
            continue;
        }
        bool yes = true;
        for (int i = 0; i < T.size(); ++i) {
            int dif = W[i] - T[i];
            if (dif != 0 && dif != 0x20 && dif != -0x20) {
                yes = false;
                break;
            }
        }
        if (yes) {
            ++ans;
        }
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 3140
using System;

namespace tes
{
    class Program
    {
        static void Main(string[] args)
        {

            int[] a = new int[100000];
            int[] b = new int[100000];
            string[] op = new string[100000];
            int i =0;
            
            int x = 0;
            while (x < 20)
            {
                var line1 = Console.ReadLine().Split();
                a[i] = int.Parse(line1[0]);
                op[i] = line1[1];
                b[i] = int.Parse(line1[2]);
                
                if(op[i]== "?")
                {
                    break;
                }    
                i++;
            }

            for (int z = 0; z < i; z++)
            {
                if(op[z]=="+")
                {
                Console.WriteLine(a[z]+b[z]);
                }
                if (op[z] == "%")
                {
                    Console.WriteLine(a[z]%b[z]);
                }
                if (op[z] == "/")
                {
                    Console.WriteLine(a[z]/b[z]);
                }
                if (op[z] == "-")
                {
                    Console.WriteLine(a[z]-b[z]);
                }
                if (op[z] == "*")
                {
                    Console.WriteLine(a[z]*b[z]);
                }

            }



        }
    }
}

Measured memory_bytes: 10740
N,K = map(int,input().split())
A = list(map(int,input().split()))
F = list(map(int,input().split()))
A.sort()
F.sort(reverse = True)
r = 1e12+1
l = -1
def ok(c):
  s = 0
  for i in range(N):
    s += max(0,A[i]-c//F[i])
  return bool(s<=K)

while l+1 < r:
  c = (l+r) // 2 
  a = ok(c)
  if a == True:
    r = c
  else:
    l = c
print(int(r))
    


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

ll INF = 1LL<<60;

const int n = 26;
int main(){
	ll d;
	cin >> d;
	vector<vector<ll>> s(d+1, vector<ll>(n+1,0));
	vector<ll> c(n+1); //満足度低下
	REP(i,n) cin >> c[i];
	REP(i,d){
		REP(j,n){
			cin >> s[i][j];
		}
	}
	vector<ll> schedule(d+1);
	vector<ll> score(d+1);
	vector<ll> last(n+1,0);
	ll total_score = 0;
	REP(i,d){
		ll d_score = -INF;
		ll temp = 0;
		REP(j,n){
			temp += s[i][j];
			REP(k,n){
				temp -= c[k]*(i - last[k]);
			}
			if(d_score < temp){
				d_score = temp;
				schedule[i] = j;
			}
		}
		total_score += d_score;
		last[schedule[i]] = i;
	}
	REP(i,d){
		cout << schedule[i] << endl;
	}
    return 0;
}



Measured memory_bytes: 3724
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
a, b = map(int, raw_input().split())
# 文字列の入力
s = raw_input()
list = [ ]
list = s.split ( '-' )
if ( len(list[0]) == a and len(list[1]) == b):
    print "Yes"
    exit()
print "No"


Measured memory_bytes: 2568
def bubble_sort(C, N):
    flag = 1
    while flag:
        flag = 0
        for j in range(1, N):
            if list(C[j])[1] < list(C[j-1])[1]:
                C[j], C[j-1] = C[j-1], C[j]
                flag = 1
        N -= 1
    return C

def selction_sort(C, N):
    for i in range(N):
        minj = i
        for j in range(i, N):
            if list(C[j])[1] < list(C[minj])[1]:
                minj = j
        C[i], C[minj] = C[minj], C[i]
    return C

N = int(input())
C = input().split()

st = [''] * 9
bubble_st = [''] * 9
selection_st = [''] * 9
bubble_c = bubble_sort(C[:], N)
selection_c = selction_sort(C[:], N)
for i in range(N):
    st[int(list(C[i])[1])-1] += list(C[i])[0]
    bubble_st[int(list(bubble_c[i])[1])-1] += list(bubble_c[i])[0]
    selection_st[int(list(selection_c[i])[1])-1] += list(selection_c[i])[0]
print(' '.join(bubble_c))
if st == bubble_st:
    print('Stable')
else:
    print('Not stable')
print(' '.join(selection_c))
if st == selection_st:
    print('Stable')
else:
    print('Not stable')



Measured memory_bytes: 5612
#include <algorithm>
#include <bitset>
#include <iomanip>
#include <ios>
#include <iostream>
#include <numeric>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;
const long long INF = 1LL << 60;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef tuple<int, int, int> ti3;

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

int main(int argc, char const* argv[])
{
    const int SIZE = 1e5 + 200;

    int N, K;
    ll h[SIZE];
    ll dp[SIZE];

    cin >> N >> K;
    for (int i = 0; i < N; i++) {
        int x;
        cin >> h[i];
    }
    for (int i = 0; i < SIZE; i++) {
        dp[i] = INF;
    }
    dp[0] = 0;

    for (int i = 0; i < N; i++) {
        for (int j = 1; j <= K; j++) {
            chmin(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
        }
    }
    cout << dp[N - 1] << "\n";
    return 0;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

int main(){
  long long n,a,b;
  cin>>n>>a>>b;
  long long h[n];
  long long temp[n];
  REP(i,n){
    cin>>h[i];
  }
  long long l=0,r=1000000001;
  long long mid;
  long long as=0;
  while(r-l>0){
    mid = (l+r)/2;
    REP(i,n){
      temp[i]=h[i]-mid*b;
      if(temp[i]>0){
        as += (temp[i]+a-b-1)/(a-b);
      }
    }
    if(as<=mid){
      r = mid;
    }else{
      l = mid+1;
    }
    as = 0;
  }
  cout<<l<<endl;
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
ll a[100004];
ll ans,num[100004];
int main(){
	cin>>n;
	for(int i=0;i<=n;i++)cin>>a[i];
	for(int i=n;i>=0;i--)num[i]=num[i+1]+a[i];
	ll res=0,now=1;
	for(int i=0;i<=n;i++){
		res+=now;
		now-=a[i];
		if(now<0||now>num[i+1]){
			puts("-1");return 0;
		}
		now=min(now*2,num[i+1]);
	}
	cout<<res;
}

Measured memory_bytes: 5192
#include <iostream>
#include <vector>
using ll = long long;
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n-1; i >= 0; i--)
using namespace std;

class UnionFind {
public:
  vector<ll> par;
  vector<ll> siz;
  
  UnionFind(ll sz_) : par(sz_), siz(sz_, 1) {
    for(int i = 0; i < sz_; i++) par[i] = i;
  }
  
  void init(ll sz_){
    par.resize(sz_);
    siz.assign(sz_, 1);
    for (ll i = 0; i < sz_; ++i) par[i] = i;
  }
  
  ll root(ll x){
    if (par[x] == x) return x;
    return par[x] = root(par[x]);
  }
  
  bool unite(ll x, ll y){
    x = root(x);
    y = root(y);
    if (x == y) return false;
    if (siz[x] < siz[y]) swap(x, y);
    siz[x] += siz[y];
    par[y] = x;
    return true;
  }
  
  bool same(ll x, ll y){
    return root(x) == root(y);
  }
    
  ll size(ll x){
    return siz[root(x)];
  }
};

int main(){
  ll n, m;
  cin >> n >> m;
  vector<ll> a(m), b(m);
  rep(i, m){
    cin >> a[i] >> b[i];
    a[i]--, b[i]--;
  }
  vector<ll> ans(m+1);
  ans[m] = n*(n-1)/2;
  UnionFind tree(n);
  repr(i, m){
    ans[i] = ans[i+1];
    if (!tree.same(a[i], b[i])) ans[i] -= tree.size(a[i]) * tree.size(b[i]);
    tree.unite(a[i], b[i]);
  }
  rep(i, m) cout << ans[i+1] << endl;
  
  return 0;
}

Measured memory_bytes: 5248
A,B,K = map(int,input().split())
X = set()
for i in range(A,min(A+K,B+1)):
    X.add(i)
for i in range(max(B-K+1,A),B+1):
    X.add(i)
X = list(X)
X.sort()
for i in X:
    print(i)

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


int main(){
    int n, x;
    cin >> n >> x;
    int l[100];
    for(int i = 1; i<= n;i++){
        cin >> l[i];
    }
    int d, i, f, ans;
    ans = 0;
    f = 0;
    for(i = 2; i <= n+1; i++){
        d = f + l[i-1];
        if(x >= d){
            f = d;
            ans++;
        }else{
            break;
        } 
    }
    ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll read(){
	ll a=0,b=getchar(),c=1;
	while(!isdigit(b))c=b=='-'?-1:1,b=getchar();
	while(isdigit(b))a=a*10+b-'0',b=getchar();
	return a*c;
}
const int N=200005;
ll n,f,ans,b[N],m[N];
char s[N];
vector<int> a[N];
int add(int x,int y){
	while(x<=n)b[x]+=y,x+=x&-x;
}
int sum(int x){
	int res=0;
	while(x)res+=b[x],x-=x&-x;
	return res;
}
int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	for(int i=1;i<=n;i++)
		a[s[i]-'a'].push_back(i),add(i,1);
	for(int i=0;i<26;i++)
		if(a[i].size()&1)f++;
	if(f>1)return puts("-1"),0;
	for(int i=0;i<26;i++)
		for(int j=0;j<a[i].size();j++)
			m[a[i][j]]=a[i][a[i].size()-j-1];
	for(int i=1;i<=n;i++)
		ans+=(sum(n)-sum(m[i])),add(m[i],-1);
	printf("%lld",ans/2);
	return 0;
}

Measured memory_bytes: 9336
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> VI;
typedef vector<VI> VVI;//例: VVI dp(10, vector<int>(10, INF);
typedef priority_queue<int, vector<int>, less<int> > QUE_int;
const int INF = 2 * pow(10, 9) + 1;//+1しないとREになるかも(out of rangeになるんかな?? )

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

ll max(ll a, ll b) {
	if (a > b) return a;
	return b;
}

int main(void) {
	int N, W;
	cin >> N >> W;
	vector<ll> w(N+1), v(N+1);
	w[0] = 0; v[0] = 0;
	for (int i = 1; i <= N; i++) cin >> w[i] >> v[i];


	//dp[i][j]: 0～i番目の品物があるとき，重さw以下で最大価値
	vector<vector<ll>> dp(N + 1, vector<ll>(W + 1, -1));
	for (int j = 0; j <= W; j++) {
		dp[0][j] = 0;
	}
	for (int i = 1; i <= N; i++) {
		for (int j = 0; j <= W; j++) {
			if (j - w[i] < 0) dp[i][j] = dp[i - 1][j];//i番目のモノは入らない．
			else dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w[i]] + v[i]);
		}
	}

	/*for (int i = 0; i <= N; i++) {
		for (int j = 0; j <= W; j++) {
			cout << dp[i][j] << " ";
		}
		cout << endl;
	}*/
	
	cout << dp[N][W] << endl;
}


Measured memory_bytes: 80256
#include<bits/stdc++.h>
using namespace std;
using ll  = long long;
using vl  = vector<ll>;
using vi  = vector<int>;
#define _GLIBCXX_DEBUG
#define IO_STREAM cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define rep(i,sta,end) for(int i=sta;i<end;++i)
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
const ll INF = 1000000000000000;
const ll MOD = 1000000007;
const double PI = acos(-1);
//||
#define DBG(a,b,c,d) cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<endl
//DBG("","","","");

signed main(){
	IO_STREAM;
	int X;
	cin>>X;
	int least=lcm(360,X);
	int ans=least/X;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3608
n, t = map(int,input().split())
cList = []
for i in range(n):
  cList.append(list(map(int,input().split())))

result = 1001
for i in cList:
  if i[1] <= t:
    if result > i[0]:
      result = i[0]

if result == 1001:
  print("TLE")
else:
  print(result)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
#define era(t) t.erase(unique(be(t)),t.end())
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
typedef long long ll;
using namespace std;
const ll mod=1000000007,mod9=1000000009;
template <class T>inline T lcm(T a,T b){return (a*b/__gcd(a,b));}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c;
    cin>>a>>b>>c;
    if((a>c && c>b)|| (a<c && c<b)){
        cout << "Yes"<<endl;

    }
    else{
        cout <<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
package main

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

const mod = 1000000007

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	N, M := nextInt(), nextInt()
	dp := make([]int, N+1)
	for i := 0; i < M; i++ {
		m := nextInt()
		dp[m] = -1
	}
	dp[0] = 1
	if dp[1] == -1 {
		dp[1] = 0
	} else {
		dp[1] = 1
	}

	for i := 2; i < N+1; i++ {
		if dp[i] == -1 {
			dp[i] = 0
		} else {
			dp[i] = (dp[i-1] + dp[i-2]) % mod
		}
	}
	fmt.Println(dp[N])
}


Measured memory_bytes: 1920
import numpy as np
N = int(input())
A = [int(input()) for _ in range(N)]
A.sort()
if N % 2 == 0:
  up = [-1,1]
  down = [-1,1]
else:
  up = [-1,-1]
  down = [1,1]
for i in range(1,N-1):
  if i % 2 == 0:
    up.append(-2)
    down.append(2)
  else:
    up.append(2)
    down.append(-2)
up.sort()
down.sort()
up = np.array(up)
down = np.array(down)
print(max(np.sum(up * A),np.sum(down * A)))

Measured memory_bytes: 25504
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
using namespace std;
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    string s;
    cin>>s;
    int flag=1,ch=0;
    if(s[0]!='A'){flag=0;}
    for(int i=0;i<s.length();++i)
    {
        if(i>=2&&i<s.length()-1)
        {
            if(s[i]=='C'){++ch;}
        }
        if(s[i]!='A'&&s[i]!='C'&&isupper(s[i]))
        {
            flag=0;
        }
    }
    if(ch!=1)
    {
        flag=0;
    }
    if(!flag)
    {
        cout<<"WA";
    }
    else
    {
        cout<<"AC";
    }

return(0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.1415926535897932
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
  
  int N,D,X;
  cin>>N>>D>>X;
  
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin>>A[i];
  }
  
  vector<int> sum(N);
  
  
  for(int i=0;i<N;i++){
    int day=1;
    while(day<=D){
      sum[i]++;
      day+=A[i];
    }
  }
  
  int ans=0;
  for(int i=0;i<N;i++){
    ans+=sum[i];
  }
  
  cout<<X+ans<<endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    int N;
    cin >> N;
    vector<int> a(N);
    int sum = 0;
    rep(i, 0, N)
    {
        cin >> a[i];
        sum += a[i];
    }
    int ans = 0;
    int minDiff = INT_MAX;
    rep(i, 0, N)
    {
        const int diff = abs(a[i] * N - sum);
        if (chmin(minDiff, diff))
        {
            ans = i;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

N = int(readline())
A = np.array(read().split(),np.int32)

answer = 0
for _ in range(32):
    A = A[A%2 == 0]
    answer += len(A)
    A >>= 1
print(answer)


Measured memory_bytes: 12668
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define rrep(i,n) for(int i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define pr(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
#define yes "Yes"
#define no "No"
using ll = long long;
using namespace std;
typedef pair<int,int> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int N;
int main(){
    cin >> N;
    pr(N/3);
}

Measured memory_bytes: 256
import sys
from bisect import *
from collections import *
from copy import deepcopy
from heapq import *
from itertools import *
from math import *
from operator import *
from pprint import *

sys.setrecursionlimit(10**8)

input = sys.stdin.readline

def factorize(n):
    res = []
    for i in range(2,int(n**0.5)+1):
        if n%i == 0:
            cnt = 0
            while n%i==0:
                n //= i
                cnt += 1
            res.append((i,cnt))
    if n > 1:
        res.append((n,1))
    return res

def gcd(a,b):
    while b:
        a,b = b,a%b
    return a

def main():
    """ main """
    A,B = map(int, input().split())
    print(len(factorize(gcd(A,B)))+1)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3700
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=200010,M=1e9+7;
struct kk{
	ll a,b;
	bool operator<(const kk &x)const{
		if(a!=x.a) return a<x.a;
		else return b<x.b;
	}
};
struct KK{
	ll pos,neg;
};
map<kk,KK> m;
set<kk> s;
set<kk>::iterator iter;
ll n;
ll oa,ob,o,ans;
ll gcd(ll a,ll b){
	if(b>a) swap(a,b);
	if(b==0) return a;
	return gcd(b,a%b);
}
ll ex(ll b,ll e,ll m){
	if(e==0) return 1;
	ll tmp=ex(b,e>>1,m);
	if(e&1) return tmp*tmp%m*b%m;
	else return tmp*tmp%m;
}
template<class T> inline T ab(T x){
	if(x<0) return -x;
	else return x;
}
int main()
{
	//freopen("in.txt","r",stdin);
	scanf("%lld",&n);
	//printf("%lld\n",n);
	for(ll i=1,a,b;i<=n;++i){
		scanf("%lld %lld",&a,&b);
		//printf("%lld %lld\n",a,b);
		if(a==0&&b==0) ++o;
		else if(a==0) ++ob;
		else if(b==0) ++oa;
		else{
			ll e=gcd(ab(a),ab(b));
			a/=e,b/=e;
			if(a<0) a=-a,b=-b;
			if(b>0){
				++m[(kk){a,b}].pos;
				s.insert((kk){a,b});
			}
			else{
				++m[(kk){-b,a}].neg;
				s.insert((kk){-b,a});
			}
		}
	}
	ans=ex(2,oa,M)+ex(2,ob,M)-1;ans%=M;
	for(iter=s.begin();iter!=s.end();++iter){
		kk tmp=*iter;
		ll cho;
		cho=ex(2,m[tmp].pos,M)+ex(2,m[tmp].neg,M)-1;
		//printf("cho=%lld,a=%lld,b=%lld,pos=%lld,neg=%lld\n",cho,tmp.a,tmp.b,m[tmp].pos,m[tmp].neg);
		cho%=M;
		ans*=cho;
		ans%=M;
	}
	if(o) ans+=o;
	ans%=M;
	if(ans)printf("%lld\n",ans-1);
	else printf("%lld\n",M-1);
}

Measured memory_bytes: 31700
order = []
amari = []
show = []
sum = 0
for i in range(5):
  order.append(int(input()))
  s = order[i] % 10
  if(s == 0):
    s = 10
  t = order[i] - s + 10
  amari.append(s)
  sum += t
ans = sum - 10 + min(amari)
print(ans)

Measured memory_bytes: 3064
ary = Array.new
while line = $stdin.gets
ary << line.chomp.split
end
kosu=ary[0][0].to_i
ary.delete_at(0)
moji = ary[0][0].split("")
ary.delete_at(0)
matome = [0]
k=0
kosu.times{|t|
if moji[t]=="A" and moji[t+1]=="C" then
    k +=1
  matome.push(k)
else
  matome.push(k)
end
}
ary.each{|item|
  a=item[0].to_i-1
  b=item[1].to_i-1
  puts matome[b]-matome[a]
  }

Measured memory_bytes: 27260
#include<bits/stdc++.h>
using namespace std;
using ll  = long long;
using vl  = vector<ll>;
using vi  = vector<int>;
#define _GLIBCXX_DEBUG
#define IO_STREAM cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define rep(i,sta,end) for(ll i=sta;i<end;++i)
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
#define INF 1000000000000000LL
const ll MOD = 1000000007;
const double PI = acos(-1);
//||
#define DBG(a,b,c,d) //cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<endl
//DBG("","","","");

signed main(){
	IO_STREAM;
	string S;
	int Q;
	cin>>S>>Q;
	string front,rear;
	int cnt=0;
	rep(i,0,Q){
		int T,F;
		string C;
		cin>>T;
		if(T==1){
			cnt++;
		}
		else{
			cin>>F>>C;
			if(cnt%2){
				if(F==1){
					rear+=C;
				}
				else{
					front=C+front;
				}
			}
			else{
				if(F==1){
					front=C+front;
				}
				else{
					rear+=C;
				}
			}
		}
	}
	if(cnt%2){
		reverse(all(S));
		reverse(all(front));
		reverse(all(rear));
		S=rear+S+front;
	}
	else{
		S=front+S+rear;
	}
	cout<<S<<endl;
	return 0;
}


Measured memory_bytes: 1316
while True:
    n, x = map(int, input().split())
    if n == 0 and x == 0:
        break
    ans = 0
    for a in range(1, n+1):
        for b in range(1, n+1):
            if b <= a:
                continue
            c = x-(a+b)
            if c > b and c <= n:
                ans +=1
    print('{}'.format(ans))


Measured memory_bytes: 5596
#include<iostream>
#include<string.h>
#include<cstdio>

using namespace std;

int main()
{
    char text[1001];
    char End[100]="END_OF_TEXT";
    char sub[11];
    int cnt=0;

    cin>>sub;

    int lenth1=strlen(sub);

    for(int i=0;i<lenth1;i++)
    {
        sub[i]=tolower(sub[i]);
    }

    while(cin.getline(text,1001,'\n')&&strcmp(text,End))
    {
        int lenth2=strlen(text);

        char *s;

        s=strchr(text,' ');

        while(s!=NULL)
        {
            *s='\0';

            for(int i=0;i<strlen(text);i++)
            {
                text[i]=tolower(text[i]);
            }

            if(strcmp(sub,text)==0)
            {
                cnt++;
            }

            strcpy(text,s+1);
            s=strchr(text,' ');
        }
        for(int i=0;i<strlen(text);i++)
            {
                text[i]=tolower(text[i]);
            }

            if(strcmp(sub,text)==0)
            {
                cnt++;
            }

    }

    cout<<cnt<<endl;


    return 0;
}



Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;using ll=long long;using vi=vector<int>;using vvi=vector<vi>;using vl=vector<ll>;using vvl=vector<vl>;using P=pair<int,int>;using PL=pair<ll,ll>;using vp=vector<P>;using vpl=vector<PL>;
template<typename T>constexpr auto inf=numeric_limits<T>::max()/2;constexpr int INF=inf<int>,MOD=1000000007;constexpr ll LINF=inf<ll>;
#define _ol3(_1,_2,_3,name,...)name
#define _rep(i,n)_repi(i,0,n)
#define _repi(i,a,b)for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...)_ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n)for(int i=n-1;i>=0;--i)
#define REPA(i,v)REP(i,v.size())
#define all(v)(v).begin(),(v).end()
#define bit(n)(1ll<<(n))
#define uniq(v)sort(all(v));v.erase(unique(all(v)),v.end())
#define F first
#define S second
#define endl '\n'
#define cho(n,a,b)cout<<((n)?a:b)<<endl
void YES(int n){cho(n,"YES","NO");}void Yes(int n){cho(n,"Yes","No");}void Poss(int n){cho(n,"Possible","Impossible");}
void _print(ostream&s){}template<class T,class...U>void _print(ostream&s,T&&t,U&&...u){s<<t<<(sizeof...(u)?' ':'\n');_print(s,u...);}
template<class...T>void print(T&&...t){_print(cout,t...);}
#ifndef LOCAL
struct osd{template<class T>osd&operator<<(const T&t){return*this;}};osd cer_;
#define dprint(...)
#define cerr cer_
#else
template<class...T>void dprint(T&&...t){_print(cerr,t...);}
#endif
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>ostream&operator<<(ostream&o,const vector<T>&v){for(auto&&i:v)o<<i<<' ';return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(T&j:v)i>>j;return i;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){return o<<p.F<<' '<<p.S;}
template<class T,class U>istream&operator>>(istream&i,pair<T,U>&p){return i>>p.F>>p.S;}
template<class T>ostream&operator<<(ostream&o,const set<T>&v){for(auto&&i:v)o<<i<<' ';return o;}
template<class T>ostream&operator<<(ostream&o,const multiset<T>&v){for(auto&&i:v)o<<i<<' ';return o;}
template<class T>vector<T>&operator<<(vector<T>&v,const T&t){v.push_back(t);return v;}
template<class T>set<T>&operator<<(set<T>&v,const T&t){v.insert(t);return v;}
template<class T>multiset<T>&operator<<(multiset<T>&v,const T&t){v.insert(t);return v;}

int main(){
    cin.tie(0);ios::sync_with_stdio(0);
    int n;
    cin>>n;
    vl v(n);
    cin>>v;
    sort(all(v));
    ll a=v[0];
    ll k=0;
    REP(i,1,n){
        a+=v[i]<<k;
        k++;
    }
    cout<<a/(double)(1ll<<k)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define pb push_back
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 55;
const int K = 105;

int n, a[N], k;
int dp[N][N][K];

int solve(int l, int r, int op){
   if(op < 0){
      return -inf;
   }

   if(op == 0 or l > r){
      return 0;
   }

   int &ans = dp[l][r][op];
   if(~ans)
      return ans;
   ans = 0;
   int A = solve(l+1, r, op-1) + a[l];
   int B = solve(l, r-1, op-1) + a[r];
   int C = solve(l+1, r, op-2);
   int D = solve(l, r-1, op-2);
   ans = max({ans, A, B, C, D});
   return ans;
}

int32_t main(){_

   cin>>n>>k;

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

   memset(dp, -1, sizeof dp);
   cout<<solve(0, n-1, k);

   return 0;
}

// Common sense: do smth instead of nothing
// Even a single second counts...
// If other's can do it, even I can do it. It wouldn't be that tough. Let me give it a try.
// Mistakes made in past
// -Ques. ask for max-min => think binary_search, DP, greedy
// -not reading question properly / skipping to read & understand all samples properly & wasting time in wrong direction.
// -Using wrong indexing in nested loops something like a[i], when it is supposed to be a[j](WA)
// -value of const int N is not correct (WA/RTE).
// -Did you memset dp to -1 ?
// -check for small edges cases and work on small test cases manually if WA
// -not deallocating memory to pointers can lead to MLE. Use delete :))
// -not reading problem statements of harder problems E,..., thinking it couldn't be solved, but it isn't the case.
// -Avoid using #define int long long as much as possible when it's dp problem and requires high memory say, O(N^2, N=5000) (MLE)
// -Check Bitwise Operator Precedence 
// -Use pragmas to optimize (by constant factor) when necessary..
// -Think before coding & starting to debug. Have patience to look inside code and actually see how it works

Measured memory_bytes: 2688
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector> 
#include <cstring>
#include <queue>
#include <stack>
#include <ctime>
#include <set>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
  
  
namespace io{
    const int L = (1 << 20) + 1;
     
    char buf[L], *S , *T, c;
      
    char getchar() {
        if(S == T) {
            T = (S = buf) + fread(buf, 1, L, stdin);
            return (S == T ? EOF : *S++);
        }
        return *S++;
    }
     
    int inp() {
        int x = 0, f = 1; char ch;
        for(ch = getchar(); !isdigit(ch); ch = getchar())
            if(ch == '-') f = -1;
        for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
        return x * f;
    }
     
    ll inp_ll() {
        ll x = 0; int f = 1; char ch;
        for(ch = getchar(); !isdigit(ch); ch = getchar())
            if(ch == '-') f = -1;
        for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
        return x * f;
    }
     
    char B[25], *outs=B+20, *outr=B+20;
    template<class T>
    inline void print(register T a,register char x=0){
        if(x) *--outs = x, x = 0;
         
        if(!a)*--outs = '0';
        else
            while(a)
                *--outs = (a % 10) + 48, a /= 10;
         
        if(x)
            *--outs = x;
         
        fwrite(outs, outr - outs , 1, stdout);
        outs = outr;
    }
};
  
using io :: print;
using io :: inp;
using io :: inp_ll;
const int maxM = 300010;
const int maxN = 10010;
int n,m;
struct node
{
	node *son[2];
	int val,pry;	
};
node box[maxM];
node *nil = box;
int tot;

int main()
{
	scanf("%d %d",&n,&m);
	for(int i=1;i<=3;i++)
	{
		if((n*m*i)%2 == 1)
		{
			puts("Yes");
			return 0;	
		}	
	} 
	puts("No");
    return 0;
}

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

int main(void) {
    int n;
    cin >> n;
    vector<ll> a(n);
    for (int i=0; i<n; i++) cin >> a[i];
    
    ll ans = 0;
    for (int i=1; i<a.size(); i++) {
        if (a[i] < a[i-1]) {
            ans += a[i-1] - a[i];
            a[i] = a[i-1];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4776
using System;
using System.Collections.Generic;
public class Hello{
    public static void Main(){
     　
     　int[,] n=new int[3,3];
     　bool[,] check=new bool[3,3];
     　int N;
            // = int.Parse(Console.ReadLine()); //標準入力
            string[] str1 = Console.ReadLine().Split(' ');
            string[] str2 = Console.ReadLine().Split(' ');
            string[] str3 = Console.ReadLine().Split(' ');
            string[] num = Console.ReadLine().Split(' ');
            
            n[0,0]=int.Parse(str1[0]);
            n[1,0]=int.Parse(str1[1]);
            n[2,0]=int.Parse(str1[2]);
            n[0,1]=int.Parse(str2[0]);
            n[1,1]=int.Parse(str2[1]);
            n[2,1]=int.Parse(str2[2]);
            n[0,2]=int.Parse(str3[0]);
            n[1,2]=int.Parse(str3[1]);
            n[2,2]=int.Parse(str3[2]);
            
            N=int.Parse(num[0]);
            for(int i=0;i<N;i++){
            string[] b = Console.ReadLine().Split(' ');
            int bn=int.Parse(b[0]);
                for(int k=0;k<3;k++){
                    for(int l=0;l<3;l++){
                        if(bn==n[k,l]){
                            check[k,l]=true;
                        }
                    }
                }
            }
            bool bing=false;
            for(int i=0;i<3;i++){
                if(check[i,0]&&check[i,1]&&check[i,2])bing=true;
                if(check[0,i]&&check[1,i]&&check[2,i])bing=true;
            }
            if(check[0,0]&&check[1,1]&&check[2,2])bing=true;
            if(check[2,0]&&check[1,1]&&check[0,2])bing=true;
           
           Console.WriteLine(bing?"Yes":"No");//改行付き出力
    }
}


Measured memory_bytes: 11092
k, n = map(int, input().split())
arr = list(map(int, input().split()))
ans = 0
for i in range(n):
    if i + 1 <= n - 1:
        if arr[i + 1] - arr[i] > ans:
            ans = arr[i + 1] - arr[i]
    else:
        if k - (arr[i] - arr[0]) > ans:
            ans = k - (arr[i] - arr[0])
print(k - ans)

Measured memory_bytes: 25452
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long k = sc.nextLong();
		long[] num = new long[100010];
		for(int i = 0 ; i < n ; i++) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			num[a] += b;
		}
		for(int i = 0 ; i < 100010 ; i++) {
			k -= num[i];
			if(k <= 0) {
				System.out.println(i);
				return;
			}
		}
	}
}


Measured memory_bytes: 74796
#include<iostream>
#include<string>
#include<algorithm>
#include<set>

using namespace std;

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

 int n = 0;
 cin >> n;

 set<string> dic;

 for(int i = 0; i < n; i++){
  string buf1,buf2;
  cin >> buf1 >>buf2;
  if(buf1 == "insert"){
    dic.insert(buf2);
  }else{
   if(dic.find(buf2) != dic.end()){
    cout << "yes" << endl;
   }else{
    cout << "no" << endl;
   }
  }
 }
 return 0;
}

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

const ll infll=9223372036854775806;
const int inf=2147483646;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	int a[5],ans=0,t=10,i,m;
	cin>>a[0]>>a[1]>>a[2]>>a[3]>>a[4];
	for (i=0;i<5;i++){
		if (a[i]%10<t&&a[i]%10>0){
			t=a[i]%10;
			m=i;
		}
	}
	ans=a[m];
	for (i=0;i<5;i++){
		if (i!=m){
			if (a[i]%10==0){
				ans+=a[i];
			}
			else {
				ans+=((a[i]/10)+1)*10;
			}
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<set>
#include<vector>
#include<iomanip>
#include<numeric>
using namespace std;

int main(){
  int N;cin>>N;
  int A[110],B[110];
  for(int i=0;i<N;i++)cin>>A[i];
  for(int i=0;i<N;i++)cin>>B[i];
  int ans=0;
  for(int i=0;i<N;i++){
    int sum=0;
    for(int j=0;j<i+1;j++)sum+=A[j];
    for(int j=i;j<N;j++)sum+=B[j];
    ans=max(ans,sum);
  }

  cout<<ans<<endl;
  
  return 0;
}
//行の合計値から考える
//上が勝てなくなるところを考える

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc081/tasks/abc081_a

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String s = sc.next();

        int count = 0;
        for(char ch : s.toCharArray()) {
           if (ch == '1') count++;
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
#define ar array
#define pb push_back


int main()
{
	// #ifndef ONLINE_JUDGE
	// 	freopen("input.txt","r",stdin);
	// 	freopen("outputc.txt","w",stdout);
	// #endif
	
	//int t;
	//cin>>t;
	//while(t--)
	{
		int n,k;
		cin>>n>>k;
		ll a[n];
		for(auto &x:a)
		{
			cin>>x;
		}
		ll dp[n];
		memset(dp,0x3f,sizeof(dp));
		dp[0]=0;
		for(int i=1;i<n;i++)
		{
			for(int j=1;j<=k;j++)
			{
				if(i-j>=0)
				{
					dp[i]=min(dp[i],dp[i-j]+abs(a[i]-a[i-j]));
				}
			}
		}
		cout<<dp[n-1];
	}
		
}


Measured memory_bytes: 5168
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL<<60;
#define all(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0; i<(n);++i)
#define FOR(i,k,n) for(int i=(k);i<(n);++i)

typedef pair<ll,int> P;

vector<ll> d(100005);
vector<vector<P> > G(100005);

void dijkstra(int V){
    REP(i,V)d[i]=INF;
    priority_queue<P,vector<P>,greater<P>> que;
    d[0]=0;
    que.push(P(0,0));
    while(!que.empty()){
        P p=que.top();que.pop();
        int v = p.second;
        ll cost = p.first;
        if(d[v]<cost)continue;
        for(auto e:G[v]){
            if(d[e.second]>d[v]+e.first){
                d[e.second]=d[v]+e.first;
                que.push(P(d[e.second],e.second));
            }
        }
    }
}

int main(){
    int N;cin>>N;
    ll A,B;cin>>A>>B;
    vector<ll> X(N);
    REP(i,N)cin>>X[i];
    REP(i,N-1){
        G[i].push_back(P(min(A*(X[i+1]-X[i]),B),i+1));
    }
    dijkstra(N);
    cout<<d[N-1]<<endl;
    return 0;
}

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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {


    char S[5];

    Scs(S);

    int a[12312] = {};

    Rep(i,4) a[S[i]]++;

    int as = 0;

    Rep(i,4444) as += ( a[i] == 2 );


    YesNo(as == 2 );

    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
int main(){
int a,b,k,i,e;
scanf("%d%d%d",&a,&b,&k);
int count;
count=0;

for(i=100; i>=1; i--){
if(a%i==0 && b%i==0){count++; e=i;}
if(count==k){printf("%d",e);
return 0;
}
}
}


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

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

    int n;
    cin >> n;
    map<int, int> D;
    REP(i, n){
        int d;
        cin >> d;
        D[d]++;
    }
    int m;
    cin >> m;
    bool f = true;
    REP(i, m){
        int t;
        cin >> t;
        D[t]--;
        if(D[t] < 0) f = false;
    }

    if(n < m){
        cout << "NO" << endl;
        return 0;
    }

    if(f) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 9600
//header{{{
#include<bits/stdc++.h>
  
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define setout(n,x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10)
#define int long long
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod = 1e9+7; 
 
int gcd(int a,int b){ return b ? gcd(b,a % b) : a;}
int lcm(int a,int b){ return a / gcd(a,b) * b;}
//}}}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> a(n);
	bool zero = false;
	int cnt = 0,sum = 0;
	rep(i,n){
		cin >> a[i];
		cnt += (a[i] < 0);
		zero |= (a[i] == 0);
		sum += abs(a[i]);
	}
	if(cnt % 2 == 0 || zero){
		cout << sum << '\n';
	}
	else {
		int minv = INF;
		rep(i,n){
			minv = min(minv,abs(a[i]));
		}
		cout << sum - 2 * minv << '\n';
	}
	return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef pair<string,string> Pstring;
typedef pair<double,double> Pdouble;


#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define Precision13 cout << fixed << setprecision(13)
const double PI=3.14159265358979323846;
const int MAX = 510000;
const int MOD = 1000000007;
const int INF = 1<<29;
using Graph = vector<vector<int>>;


int main()
{
  ll a,b,c,k;
  cin >> a >> b >> c >> k;
  if(a>=k){
    cout << k << endl;
  }else if(a+b >=k){
    cout << a << endl;
  }else{
    cout << a-(k-(a+b)) << endl;
  }
}

Measured memory_bytes: 3624