akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define prtd(var, i) cout << fixed << setprecision(i) << var << endl;
#define ll long long
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    ll ans = 0;
    vector<int> cnt(100010);
    rep(i, n) {
        cin >> a[i];
        ans += a[i];
        cnt[a[i]]++;
    }
    vector<ll> ANS;
    int q;
    cin >> q;
    while(q--){
        int b, c;
        cin >> b >> c;
        if(cnt[b] == 0){
            ANS.push_back(ans);
            continue;
        }
        int count = cnt[b];
        cnt[b] = 0;
        cnt[c] += count;
        int sa = (c - b)*count;
        ans += sa;
        //cout << sa << endl;
        ANS.push_back(ans);
    }

    rep(i, ANS.size()) cout << ANS[i] << endl;

    return 0;

}

Measured memory_bytes: 5104
#include <bits/stdc++.h>
#define Tree int h,int l,int r,int L,int R
#define left 2*h,l,(l+r)/2,L,R
#define right 2*h+1,(l+r)/2+1,r,L,R
#define F first
#define S second
#define Pb push_back
using namespace std;
int n,m,f[100005];
pair < pair < int , int > , int > p[100005];
string ANS[100005] ;
main ()
{
	cin>>n>>m;
	
	for (int i=1; i<=m; i++)
	{
		cin>>p[i].F.S>>p[i].F.F;
		p[i].S=i;
	}
	
	sort(p+1,p+m+1);
	
	for (int i=1; i<=m; i++)
	{
		int x=++f[p[i].F.S];
		string s="";
	
		while (x)
		{
			s+=char('0'+x%10);
			x/=10;	
		}
		
		while (s.size()<6) s+='0';
		
		while (p[i].F.S)
		{
			s+=char('0'+p[i].F.S%10);
			p[i].F.S/=10;	
		}
		
		while (s.size()<12) s+='0';
		
		reverse(s.begin(),s.end());
					
		ANS[p[i].S]=s;
	}
	
	for (int i=1; i<=m; i++)
		cout<<ANS[i]<<endl;
}

Measured memory_bytes: 8576
#include<bits/stdc++.h>
typedef long long int lli;
using namespace std;
 
int main()
{
  lli a, b, ans;
  cin >> a >> b;
  if(b%2==0)
  {
    if(b>=a*2 and b<=a*4) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  else cout << "No" << endl;
  return 0;
}

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

int main() {
  int N, K, R, S, P;
  cin >> N >> K >> R >> S >> P;
  string T;
  cin >> T;
  int score = 0;
  for (int i = 0; i < N; i++){
    if (i < K || T[i] != T[i - K]){
      if (T[i] == 'r'){
        score += P;
      }
      else if (T[i] == 's'){
        score += R;
      }
      else{
        score += S;
      }
    }
    else{
      T[i] = 'a';
    }
  }
  cout << score << endl;
}


Measured memory_bytes: 512
// Author : Mohamed Sameh
#include <bits/stdc++.h>
typedef long long ll ;
#define pb push_back
#define f first
#define s second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SZ(a) (int)a.size()
#define Flush fflush(stdout);
using namespace std ;
const int N = 1e2+1, M = 1e5+1;
int n, k, a[N], can[M];
int main()
{
  cin >> n >> k ;
  for (int i = 0; i < n; i++)
    cin >> a[i];
  for (int i = 1; i <= k; i++)
    for (int j = 0; j < n && !can[i] && a[j] <= i; j++)
      if (!can[i - a[j]])
        can[i] = 1;
  cout << (can[k] ? "First\n" : "Second\n");
}


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

#define MAX 1e8

void add_candidate(vector<double> x, vector<double> &candidate)
{
    candidate.push_back(x[0] - x[1]);
    candidate.push_back(x[1] - x[2]);
    candidate.push_back((x[0] - x[2]) / 2);
}

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

    // [minus, const, plus]
    vector<double> xmin(3, MAX);
    vector<double> xmax(3, -MAX);
    vector<double> ymin(3, MAX);
    vector<double> ymax(3, -MAX);
    double x, y;
    char D;
    for (int i = 0; i < N; i++)
    {
        cin >> x >> y;
        cin >> D;

        if (D == 'L')
        {
            xmin[0] = min(xmin[0], x);
            xmax[0] = max(xmax[0], x);
        }
        else if (D == 'R')
        {
            xmin[2] = min(xmin[2], x);
            xmax[2] = max(xmax[2], x);
        }
        else
        {
            xmin[1] = min(xmin[1], x);
            xmax[1] = max(xmax[1], x);
        }

        if (D == 'D')
        {
            ymin[0] = min(ymin[0], y);
            ymax[0] = max(ymax[0], y);
        }
        else if (D == 'U')
        {
            ymin[2] = min(ymin[2], y);
            ymax[2] = max(ymax[2], y);
        }
        else
        {
            ymin[1] = min(ymin[1], y);
            ymax[1] = max(ymax[1], y);
        }
    }

    vector<double> candidate;
    add_candidate(xmin, candidate);
    add_candidate(xmax, candidate);
    add_candidate(ymin, candidate);
    add_candidate(ymax, candidate);
    candidate.push_back(0);

    double ans = 1e18;
    for (double c : candidate)
    {
        if (c >= 0)
        {
            x = max({xmax[0] - c, xmax[1], xmax[2] + c}) - min({xmin[0] - c, xmin[1], xmin[2] + c});
            y = max({ymax[0] - c, ymax[1], ymax[2] + c}) - min({ymin[0] - c, ymin[1], ymin[2] + c});
            ans = min(ans, x * y);
        }
    }
    cout << fixed << setprecision(2) << ans << endl;
}


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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define ALL(v) (v).begin(), (v).end()
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO  cout << "NO"  << endl
#define No  cout << "No"  << endl

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;


void solve()
{
    string S; cin >> S;
    int N = S.length();
    ll ans = 0;

    for(int i = 0; i < 1 << N-1; i++)
    {
        ll s = 0;
        for(int j = 0; j < N; j++)
        {
            s = s*10+(S[j]-'0');
            if(1 << j & i)
            {
                ans += s;
                s = 0;
            }
        }
        ans += s;
    }
    cout << ans << endl;
}
    
int main() 
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>//头文件
using namespace std;
long long a;//其实应该用int的
int main(){
    cin>>a;//输入这个三位数
    if(a%10==(a-a%100)/100)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;//判断并输出
    //并没有写return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int s[100000];

int main(void)
{
	int i;
	int j;
	int n;
	int a1, a2;
	
	for (i = 0; i <= 100000; i++){
		s[i] = 1;
	}
	s[0] = s[1] = 0;
	for (i = 2; i * i <= 100000; i++){
		if (s[i] == 0) continue;
		for (j = i * i; j <= 100000; j += i){
			s[j] = 0;
		}
	}
	while (scanf("%d", &n) != EOF){
		i = 1;
		a1 = a2 = 0;
		while (a1 == 0 || a2 == 0){
			if (s[n - i] == 1 && a1 == 0){
				a1 = n - i;
			}
			if (s[n + i] == 1 && a2 == 0){
				a2 = n + i;
			}
			i++;
		}
		printf("%d %d\n", a1, a2);
	}
	return (0);
}

Measured memory_bytes: 1412
#include<bits/stdc++.h>
const int MOD=1000000007;
const int INF=1000000000;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
const double eps=1e-9;
const int inf=1e9;
typedef pair<int,int> P;
struct Point
{
  double x,y;
  Point(){x=0;y=0;}
  Point(double d_x,double d_y){x=d_x,y=d_y;}
  double operator*(Point obj){return obj.x*x+obj.y*y;}
  double operator%(Point obj){return obj.y*x-obj.x*y;}
  Point operator*(double b){Point tmp;tmp.x=x*b;tmp.y=y*b;return tmp;}
  Point operator/(double b){Point tmp;tmp.x=x/b;tmp.y=y/b;return tmp;}
  Point operator+(Point obj){Point tmp;tmp.x=x+obj.x;tmp.y=y+obj.y;return tmp;}
  Point operator-(){Point tmp;tmp.x=-x;tmp.y=-y;return tmp;}
  Point operator-(Point obj){Point tmp;tmp.x=x-obj.x;tmp.y=y-obj.y;return tmp;}
  Point operator-=(Point obj){x-=obj.x;y-=obj.y;return *this;}
  Point operator+=(Point obj){x+=obj.x;y+=obj.y;return *this;}
  Point operator/=(double b){x=x/b;y=y/b;return *this;}
  Point operator*=(double b){x=x*b;y=y*b;return *this;}
  double size(){return hypot(x,y);}
  Point unit(){return Point(x/size(),y/size());}
  Point normal(){return Point(y,-x);}
  double atan(){return atan2(y,x);}
};

bool operator<(Point a,Point b){return a.x!=b.x?a.x<b.x:a.y<b.y;}
bool operator>(Point a,Point b){return b<a;}
bool operator<=(Point a,Point b){return !(b<a);}
bool operator>=(Point a,Point b){return !(a<b);}
bool operator==(Point a,Point b){return (a-b).size()<eps;}
bool operator!=(Point a,Point b){return !(a==b);}

bool equal(double a,double b){return abs(a-b)<eps;}
double cross(Point a,Point b){return a%b;}
double dot(Point a,Point b){return a*b;}

int table[10][10];
int check(int a,int b,int c,int d,int e)
{
  for(int i=0;i<10;i++)
    {
      if(table[table[table[table[table[0][i]][b]][c]][d]][e]==0 && i!=a) return -1;
    }
  for(int i=0;i<10;i++)
    {
      if(table[table[table[table[table[0][a]][i]][c]][d]][e]==0 && i!=b) return -1;
    }
  for(int i=0;i<10;i++)
    {
      if(table[table[table[table[table[0][a]][b]][i]][d]][e]==0 && i!=c) return -1;
    }
  for(int i=0;i<10;i++)
    {
      if(table[table[table[table[table[0][a]][b]][c]][i]][e]==0 && i!=d) return -1;
    }
  for(int i=0;i<10;i++)
    {
      if(table[table[table[table[table[0][a]][b]][c]][d]][i]==0 && i!=e) return -1;
    }
  if(table[table[table[table[table[0][b]][a]][c]][d]][e] == 0 && a!=b) return -1;
  if(table[table[table[table[table[0][a]][c]][b]][d]][e] == 0 && b!=c) return -1;
  if(table[table[table[table[table[0][a]][b]][d]][c]][e] == 0 && c!=d) return -1;
  if(table[table[table[table[table[0][a]][b]][c]][e]][d] == 0 && d!=e) return -1;

  return 1;
}
int main(int argc,char const* argv[])
{
  for(int i=0;i<10;i++)
    {
      for(int j=0;j<10;j++)
	{
	  cin >> table[i][j];
	}
    }
  int ans=0;
  for(int a=0;a<10;a++)
    {
      for(int b=0;b<10;b++)
	{
	  for(int c=0;c<10;c++)
	    {
	      for(int d=0;d<10;d++)
		{
		  int e=table[table[table[table[0][a]][b]][c]][d];
		  if(check(a,b,c,d,e)==-1) ans++;
		}
	    }
	}
    }
  cout << ans << endl;
}



Measured memory_bytes: 3124
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define for1(i,n) for (ll i=0;i<(n);i++)
#define for2(i,m,n) for (ll i=(m);i<(n);i++)
#define for3(i,m,n,d) for (ll i=(m);i<(n);i+=(d))
#define DEBUG 0

string solve()
{
    string S;
    cin >> S;
    string ans;
    ans = S[0];
    ans += to_string(S.length() - 2);
    ans += S[S.length() - 1];

    return ans;
}

int main()
{
    do {
        cout << solve() << endl;
    } while (DEBUG);
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

bool ok(int H, int W, const vector<string> &s, int i, int j)
{
	if (s[i][j] != '#') {
		return true;
	}
	if (i >= 1 && s[i - 1][j] == '#') {
		return true;
	}
	if (j >= 1 && s[i][j - 1] == '#') {
		return true;
	}
	if (i + 1 < H && s[i + 1][j] == '#') {
		return true;
	}
	if (j + 1 < W && 1 && s[i][j + 1] == '#') {
		return true;
	}
	return false;
}

string solve(int H, int W, const vector<string> &s)
{
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			if (!ok(H, W, s, i, j)) {
				return "No";
			}
		}
	}
	return "Yes";
}

int main()
{
	int H, W;
	cin >> H >> W;
	vector<string> s(H);
	for (auto &x : s) {
		cin >> x;
	}
	cout << solve(H, W, s) << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int n,i,j,z = 0;
	long int a[100],x,s;
	scanf("%d",&n);
	scanf("%ld",&x);
	for(i = 0;i < n;i++){
	scanf("%ld",&a[i]);
	}
	for(i=0;i<n-1;i++){
		for(j=i+1;j<n;j++){
		if(a[i] > a[j]){
			s = a[i];
			a[i] = a[j];
			a[j] = s;
		}
		}
	}
	for(i=0;i<n;i++){
		if(x - a[i] >= 0){
			x -= a[i];
			z++;
			if(z == n && x > 0)z--;
		}
		else break;
	}
	printf("%d\n",z);
	return 0;
}

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

int main(){
  string S; cin >> S;
  string str;
  str.push_back(S[0]);
  for(int i=0; i<S.size()-1; i++){
    if(S[i]!=S[i+1]){
      str.push_back(S[i+1]);
    }
  }
  cout << str.size()-1 << endl;
}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main(){
    
    int a,b,c;
    cin>>a>>b>>c;
    
    if(a<b){
        if(b<c){
            cout<<"Yes"<<endl;
        }else{
            cout<<"No"<<endl;
        }
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3120
#include<cstdio>
int main()
{
    int a,b,ans,ci;
    scanf("%d",&ci);
    for(int i=0;i<ci;i++)
    {
        scanf("%d%d",&a,&b);
        ans+=b-a+1;
    }
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PLL = pair<ll, ll>;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repn(i,n) for(int i = 0; i <= (int)(n); i++)
#define srep(i,l,n) for(int i = l; i < (int)(n); i++)
#define srepn(i,l,n) for(int i = l; i <= (int)(n); i++)
#define drep(i,n) for(int i = (int)(n-1); i >= 0; i--)
#define drepn(i,n) for(int i = (int)(n); i >= 0; i--)
#define size(s) (int)s.size()
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<typename T> inline istream& operator>>(istream &i, vector<T> &v) {rep(j, size(v)) i >> v[j]; return i;}
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; }
template<class T> T gcd(T a, T b) {if(b==0)return a; else return gcd(b,a%b);}
template<class T> T lcm(T a, T b) {return a/gcd(a,b)*b;}
template<class T = int> using V = vector<T>;
template<class T = int> using VV = vector<V<T>>;
bool isIn(int i, int j, int h, int w) {return i >= 0 && i < h && j >= 0 && j < w;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void err() {cout << -1 << endl;}
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define ep emplace_back

const int MOD = 1000000007;
const int INF = 1e9;

#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b;
    string s;
    cin >> a >> b >> s;
    bool ok = true;
    for(int i = 0; i < a; i++) {
        if(!('0' <= s[i] && s[i] <= '9')) ok = false;
    }
    if(s[a] != '-') ok = false;
    for(int i = a + 1; i < a + b + 1; i++) {
        if(!('0' <= s[i] && s[i] <= '9')) ok = false;
    }
    if(ok) Yes(); else No();
}

Measured memory_bytes: 3612
# import sys
# sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]


def solve():
    n = II()

    i = 1
    ans = 1001001001001
    while i*i <= n:
        if n % i == 0:
            j = n // i
            step = i + j - 2
            # print(i, j, step)
            ans = min(step, ans)
        i += 1

    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 3064
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<typename T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef tuple<ll,ll,ll> tlll;
typedef tuple<int,int,int> tiii;
const ll mod=1e9+7;
const int inf=1<<30;

ll a[1000010];

int main(){
  ll k; cin >> k;
  a[0]=7%k;
  rep1(i,k){
    a[i]=(a[i-1]*10+7)%k;
  }
  rep(i,k){
    if(a[i]==0){
      cout << i+1 << endl;
      return 0;
    }
  }
  
  cout << -1 << endl;
}

Measured memory_bytes: 11372
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0LL)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;}
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);}
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;}
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int ctoi(char c){return c - '0';}

template<typename T>  
bool isOk(T key,T value){
  return key <= value;
}
template<typename T>
T binary_search(vector<T> a,T key){
  T ok = a.size();
  T ng = -1;

  while(abs(ok - ng) > 1){
    T mid = (ok + ng) / 2;
    if(isOk(key,a[mid]))ok = mid;
    else ng = mid;
  }

  return ok;
}

bool isPrime(ll n) {
	for (int i = 2; n >= i * i; ++i) {
		if(!(n % i))return false;
	}
  return true;
}
vector<ll> primes(ll n){
  vector<ll> v;
  for (ll i = 2; i*i <= n; ++i) {
    while(n%i==0){
      n/=i;
      v.pb(i);
    }
  }
  if(n != 1)v.pb(n);
  return v;
}

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

int main() { 
  //cin.tie(0); ios::sync_with_stdio(0);
  ll l,r;cin>>l>>r;
  ll ans = INF;
  if(abs(r-l) >= 2019ll)ans = 0;
  for(ll i = l;i <= r;++i){
    for(ll j = i+1;j <= r;++j){
      ans = min(ans,(i*j)%2019ll);
      if(ans == 0)break;
    } 
    if(ans == 0)break;
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 17
using namespace std;
int a,b,n,x,y,dp[N][N];

int main(){
  while(1){
    cin>>a>>b;
    if(!a&&!b)break;
    memset(dp,0,sizeof(dp));
    cin>>n;
    for(int i=0;i<n;i++)
      cin>>x>>y,dp[x-1][y-1]=-1;
    dp[0][0]=1;
    for(int i=0;i<a;i++)
      for(int j=0;j<b;j++){
	if(dp[i][j]<0)continue;
	if(dp[i+1][j]>=0)dp[i+1][j]+=dp[i][j];
	if(dp[i][j+1]>=0)dp[i][j+1]+=dp[i][j];
      }
    cout<<dp[a][b-1]<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
n, m = map(int, input().split())
if m == 1:
    print(1, n)
    exit()
if n % 2 == 1:
    for i in range(m):
        print(i+1, n-i-1)
else:
    j = 1
    for i in range((m-1)//2+1):
        print(j, n - i)
        j += 1
    j += 1
    for i in range((m-1) // 2+1, m):
        print(j, n - i)
        j += 1


Measured memory_bytes: 9200
#include<bits/stdc++.h>
using namespace std;   //author: madmin2619/mintu_agarwal
     
#define nfs() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define endl "\n"
#define pb push_back
#define pf push_front
#define forin(i, n) for(int i=0;i<n;i++)
#define tr(c, it) for(auto it=c.begin();it!=c.end();it++)
#define sz(c) c.size()
#define all(c) c.begin(),c.end()
#define ff first
#define ss second
#define m_p(x, y) make_pair(x, y)
     
const int M = 1e9 + 7;
     
int32_t main(){
    nfs()
    int t, n, i, j, k, W;
    cin >> n >> W;
    vector<int> w(n), v(n);
    forin(i, n)	cin >> w[i] >> v[i];
    int dp[n+1][W+1];
    forin(i, n+1){
    	forin(j, W+1)
    		dp[i][j]=0;
    }
    for(i=1;i<n+1;i++){
    	for(j=1;j<W+1;j++){
    		if(j-w[i-1]>=0)
    			dp[i][j]=max(dp[i-1][j], dp[i-1][j-w[i-1]]+v[i-1]);
    		else
    			dp[i][j]=dp[i-1][j];
    	}
    }
    cout << dp[n][W] << "\n";
    return 0;
}

Measured memory_bytes: 79232
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
 
//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};
 
int main()
{
	map<int, bool> m;
	
	FOR(i, 1, 29){
		int tmp;
		cin >> tmp;
		m[tmp] = 1;
	}

	FOR(i, 1, 31){
		if (m[i] == 0){
			cout << i << endl;
		}
	}

}



Measured memory_bytes: 3104
import java.awt.Robot;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.InputStream;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.math.BigDecimal;
import java.math.MathContext;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Deque;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Random;
import java.util.Scanner;
import java.util.Set;
import java.util.Stack;
import java.util.TreeMap;
import java.util.TreeSet;

import static java.util.Comparator.*;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        Solver solver = new Solver(System.in, out);
        solver.solve();
        out.close();
    }
}
class Solver {
	Scanner sc;
	PrintWriter out;
    public Solver(InputStream in, PrintWriter out) {
    	sc = new Scanner(in);
    	this.out = out;
    }
    // ======================================================================
    double[] KT = new double[1001];
    public void solve() {
    	int N = ni();
    	int K = ni();
    	double sum;
    	for (int i = 1; i <= 1000; i++) {
    		sum = 0;
			for (int j = 1; j <= i; j++) {
				sum = sum + (double)j / i;
			}
			KT[i] = sum;
//			out.println("KT[" + i + "] = " + KT[i]);
		}
    	int[] P = ndi(N);
    	double ans = 0, wk = 0;
    	int right = 0;
    	for (int left = 0; left < N - K + 1; left++) {
//    		out.println("start   wk = " + wk + "  left = " + left + "  right = " + right);
    		while(right < left + K) {
    			wk += KT[ P[right] ];
    			right++;
//    			out.println("   wk = " + wk + "  right = " + right);
    		}
    		ans = Math.max(ans, wk);
    		wk -= KT[ P[left] ];
		}
    	out.println(ans);
    }
    // ------------------------------------------
    // 入力
    // ------------------------------------------
    public int ni() {
    	return sc.nextInt();
    }
    public long nl() {
    	return sc.nextLong();
    }
    public String ns() {
    	return sc.next();
    }
    public char[] nc() {
    	return sc.next().toCharArray();
    }
    public int[] ndi(int N) {
    	int[] ans = new int[N];
    	for (int i = 0; i < N; i++) {
			ans[i] = ni();
		}
    	return ans;
    }
    public long[] ndl(int N) {
    	long[] ans = new long[N];
    	for (int i = 0; i < N; i++) {
			ans[i] = nl();
		}
    	return ans;
    }
    public String[] nds(int N) {
    	String[] ans = new String[N];
    	for (int i = 0; i < N; i++) {
			ans[i] = ns();
		}
    	return ans;
    }
    public char[][] ndc(int N) {
    	char[][] ans = new char[N][];
    	for (int i = 0; i < N; i++) {
			ans[i] = nc();
		}
    	return ans;
    }
    public int[][] nddi(int N, int S) {
    	int[][] ans = new int[N][S];
    	for (int i = 0; i < N; i++) {
			for (int j = 0; j < S; j++) {
				ans[i][j] = ni();
			}
		}
    	return ans;
    }
}


Measured memory_bytes: 72656
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll ;
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
 const ll inf=1e9+7;
string a,b,c;


 void test_cases()
{

ll a,b,c,d;
cin>>a>>b>>c>>d;

a=a*b;
c=c*d;
cout<<max(a,c);
}


int main()
{
    fast;
  ll t;
 // cin>>t;
 t=1;
  while(t--)
  test_cases();

  	
}

		
	
	
	
	


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

int main() 
{
  int n, x;
  cin >> n >> x;
  vector<int> data(n);
  for(int i = 0; i < n; i++)
  {
    cin >> data.at(i);
  }
  sort(begin(data), end(data));
  int answer = 0;
  for(int i = 0; i < n; i++)
  {
    if(x - data.at(i) >= 0)
    {
      if(i == n - 1) //最後まで配り切った場合
      {
        if(x == data.at(i))
        {
          answer++;
          continue;
        }
        else
        {
          continue;
        }
      }
      answer++;
      x -= data.at(i);
    }
    else
    {
      break;
    }
    
  }
  cout << answer << endl;
}


Measured memory_bytes: 256
import math
def main():

    N  = int(input())

    xyz = []
    for x in range(1, int(math.sqrt(N))+1):
        for y in range(1, int(math.sqrt(N))+1):
            for z in range(1, int(math.sqrt(N))+1):
                xyz.append([x, y, z])

    d = dict()
    for x, y, z in xyz:
        v = x*x + y*y + z*z + x*y + y*z + z*x
        d[v] = d.get(v, 0) + 1

    for n in range(1, N+1):
        if n in d:
            print(d[n])
        else:
            print(0)


if __name__ == '__main__':
    main()


Measured memory_bytes: 198068
S = input()
ans = [0] * len(S)
lr = "r"
for i in range(len(S)):
    if (i == 0 or lr == "l") and S[i] == "R":
        c = 0
        lr ="r"
        while S[i+c] == "R":
            c += 1    
        ans[i+c] += c//2
        ans[i+c-1] += (c+1)//2
    elif lr == "r" and S[i] == "L":
        c = 0
        lr = "l"
        while i+c < len(S) and S[i+c] == "L":
            c += 1
        ans[i] += (c+1)//2
        ans[i-1] += c//2
print(*ans)

Measured memory_bytes: 10788
#include <bits/stdc++.h>
using namespace std;
string s; int q, n, t, f; char c;
deque<char> x;
int main (){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> s;
for (int i=0; i<s.size(); i++){
	x.push_back(s[i]);
}
cin >> q;
while (q--){
	cin >> t;
	if (t==1){
		n++;
	}
	else{
		cin >> f >> c;
		if ((f+n)%2) x.push_front(c);
		else x.push_back(c);
	}
}
if (n%2)
	for (int i=x.size()-1; i>=0; i--)
		cout << x[i];
else
	for (int i=0; i<x.size(); i++)
		cout << x[i];
return 0;
}

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

int X;

int main()
{
    cin >> X;
    for (int i = 0; 100 * i <= X; i++) {
        int lft = X - 100 * i;
        int tk = lft / 5 + bool(lft % 5 > 0);
        if (tk <= i) { printf("1\n"); return 0; }
    }
    printf("0\n");
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        Integer[] a = new Integer[n];
        Arrays.setAll(a, i -> Integer.parseInt(sc.next()));
        sc.close();

        // 主処理
        int min = Arrays.stream(a).mapToInt(i -> i).min().getAsInt();
        int max = Arrays.stream(a).mapToInt(i -> i).max().getAsInt();
        int result = max - min;

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 26964
#include "bits/stdc++.h" 
using namespace std;
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define rerep(i,a,n) for(ll i=n;i>=a;i--)
#define elif else if
#define all(s) s.begin(),s.end()
typedef long long ll;
int main(){
    ll n,m;
    cin>>n>>m;
    ll a[n];
    ll sum=0;
    rep(i,0,n){
        cin>>a[i];
        sum+=a[i];
    }
    ll cut=4*m;
    ll cnt=0;
    rep(i,0,n){
        ll ex;
        if(sum%a[i]==0)ex=sum/a[i];
        else ex=sum/a[i]+1;
        if(cut>=ex)cnt++;
        if(cnt==m){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
}

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

int main() {
    vector<vector<int>> vec(3, vector<int>(3));
    rep(i, 3) {
        rep(j, 3) {
            cin >> vec.at(i).at(j);
        }
    }
    int n;
    cin >> n;
    vector<int> b(n);
    rep(i, n) cin >> b[i];
    rep(i, 3) {
        rep(j, 3) {
            rep(k, n) {
                if (vec[i][j] == b[k]) {
                    vec[i][j] = 0;
                    break;
                } 
            }
        }
    }
    bool flag = false;
    rep(i, 3) {
        if (vec[i][0] == 0 && vec[i][1] == 0 && vec[i][2] == 0) {
            flag = true;
            break;
        }
    }
    rep(i, 3) {
        if (flag) break;
        if (vec[0][i] == 0 && vec[1][i] == 0 && vec[2][i] == 0) {
            flag = true;
            break;
        }
    }
    if (vec[0][0] == 0 && vec[1][1] == 0 && vec[2][2] == 0) flag = true;
    if (vec[0][2] == 0 && vec[1][1] == 0 && vec[2][0] == 0) flag = true;
    if (flag) {
        cout << "Yes" << endl;
    }else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)

using namespace std;

int main()
{
    int n, K;
    cin >> n >> K;
    rep(i,n){
        int a;
        cin >> a;
    }
    if(n == K){
        cout << "1\n";
    }else{
        cout << (n-K-1)/(K-1) + 1 + 1 << "\n";
    }
}

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

using ll = long long;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

int main() {
	int N;
	std::cin >> N;
	std::vector <ll> T(N);
	for (auto& p : T)
		std::cin >> p;

	long long ans = T[0];
	for (auto& p : T) {
		ans = lcm(std::min(ans, p), std::max(ans, p));
	}

	std::cout << ans << std::endl;

	return 0;
}

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

int main(){
  for(int i=0;i<4;i++){
    int a,b;
    cin>>a>>b;
    if(a==1){
      b*=6000;
    }
    if(a==2) b*=4000;
    if(a==3) b*=3000;
    if(a==4) b*=2000;
    cout<<b<<endl;
  }
  return 0;
}



Measured memory_bytes: 3100
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long N = sc.nextLong();

    long ans = N-1;
    for (long i = 2; i*i <= N ; i++) {
      if(N%i==0){
        ans = Math.min(ans,i-1+N/i-1);
      }
    }

    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;

int main(){
    string N; cin >> N;
    int cnt=0;
    rep(i,N.size()) cnt+=N[i]-'0';
    
    if(stoi(N)%cnt==0) cout << "Yes";
    else cout << "No";
    
}

Measured memory_bytes: 256
# encoding:utf-8
import copy
import numpy as np
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import math


N,K = map(int,input().split())
S = str(input())

now,cnt = 1,0
Nums = []
for i in range(N):
    if S[i] == str(now):
        cnt += 1
    else:
        Nums.append(cnt)
        cnt = 1
        now = 1 - now

if cnt!=0:
    Nums.append(cnt)

if len(Nums)%2==0:
    Nums.append(0)

#累積和
"""
Sums = [0]
tmp = 0
for i in range(len(Nums)):
    tmp += Nums[i]
    Sums.append(tmp)

ans = 0
Add = 2*K+1
for i in range(len(Sums)):
    if i%2==0:
        left = i
        right = min(i+Add,len(Sums)-1)
        tmp = Sums[right]-Sums[left]
        ans = max(tmp,ans)
"""
# 尺取り法
ans = 0
add = 2*K+1
left = 0
right = min(0+add,len(Nums))
pre = sum(Nums[left:right])
ans = pre
for i in range(len(Nums)-add):
    if i%2==0:
        left = i
        right = min(i+add,len(Nums)-1)
        pre += sum(Nums[right:right+2])-sum(Nums[left:left+2])
        ans = max(pre,ans)

print(ans)


Measured memory_bytes: 14776
/*
AuThOr GaRyMr
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int main(){
	fastio;
	LL a,b,c;
	cin>>a>>b>>c;
	if(c-a-b<=0){
		cout<<"No";
		return 0;
	}
	if(4ll*a*b<(c-a-b)*(c-a-b)){
		cout<<"Yes";
	}
	else cout<<"No";
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

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

        sc.nextInt();
        String s = sc.next();
        int k = sc.nextInt();

        char target = s.charAt(k - 1);

        for (char c : s.toCharArray())
        {
            if (c == target)
                System.out.print(c);
            else
                System.out.print("*");
        }
        System.out.println();
    }
}


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

static const int N = 100;

signed main() {
  int n, p[N+1], m[N+1][N+1];
  cin >> n;
  for(int i = 1; i <= n; i++) cin >> p[i-1] >> p[i];

  for(int i = 1; i <= n; i++) m[i][i] = 0;
  for(int l = 2; l <= n; l++) {
      for(int i = 1; i <= n-l+1; i++) {
          int j = i+l-1;
          m[i][j] = (1 << 21);
          for(int k = i; k <= j-1; k++) {
              m[i][j] = min(m[i][j], m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j]);
          }
      }
  }
  cout << m[1][n] << endl;
  return 0;
}



Measured memory_bytes: 3152
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
int main()
{
	int n;
	cin >> n;
	cout << n * n;
	return 0;
 } 

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] t = new int[N+1];
        int[] x = new int[N+1];
        int[] y = new int[N+1];

        for (int i = 1; i <= N; i++) {
            t[i] = sc.nextInt();
            x[i] = sc.nextInt();
            y[i] = sc.nextInt();
        }
        sc.close();

        for (int i = 1; i <= N; i++) {
            int load = Math.abs(x[i] - x[i - 1]) + Math.abs(y[i] - y[i - 1]);
            int time = t[i] - t[i - 1];
            if (time < load || load % 2 != time % 2) {
                System.out.println("No");
                return;
            }
        }

        System.out.println("Yes");
    }
}

Measured memory_bytes: 91312
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
const array<pair<int,int>,4> fd{make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 
//ll

int n,k;
int main(){
  cin>>n>>k;
  int h[100000];rep(i,n)cin>>h[i];
  sort(h,h+n);
  int ans = INF;
  rep(i,n-k+1){
    ans = min(ans,h[i+k-1]-h[i]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 640
#include<stdio.h>
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int MAX(int a,int b){return a<b?b:a;}
int main(){
  int n,d[100010],a[100010],b[100010],m,i;
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&d[i]);
  a[0]=d[0];
  for(i=1;i<n;i++)a[i]=gcd(a[i-1],d[i]);
  b[n-1]=d[n-1];
  for(i=n-1;i--;)b[i]=gcd(b[i+1],d[i]);
  //for(i=0;i<n;i++)printf("%d %d\n",a[i],b[i]);
  m=MAX(a[n-2],b[1]);
  for(i=1;i<n-1;i++)m=MAX(m,gcd(a[i-1],b[i+1]));
  printf("%d\n",m);
  return 0;
}
			  


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

// @@ !! LIM()

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

  ll N, M; cin >> N >> M;
  vector<ll> a(N), b(N), c(M), d(M);
  for (ll i = 0; i < N; i++) cin >> a.at(i) >> b.at(i);
  for (ll j = 0; j < M; j++) cin >> c.at(j) >> d.at(j);
  for (ll i = 0; i < N; i++) {
    ll dist = LLONG_MAX;
    ll pt = -1;
    for (ll j = 0; j < M; j++) {
      ll x = abs(c.at(j) - a.at(i)) + abs(d.at(j) - b.at(i));
      if (x < dist) {
	dist = x;
	pt = j;
      }
    }
    cout << pt + 1 << "\n";
  }

  return 0;
}



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

int main()
{
    int H, W;
    cin >> H >> W;
    vector<vector<int>> A(H, vector<int>(W));
    for (vector<int> &a : A)
    {
        for (int &x : a)
        {
            cin >> x;
        }
    }
    vector<vector<int>> B(H, vector<int>(W));
    for (vector<int> &b : B)
    {
        for (int &x : b)
        {
            cin >> x;
        }
    }

    vector<vector<int>> D(H, vector<int>(W));
    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            D[i][j] = abs(A[i][j] - B[i][j]);
        }
    }

    vector<vector<vector<bool>>> dp(H, vector<vector<bool>>(W, vector<bool>(80 * 80 + 1, false)));
    dp[0][0][D[0][0]] = true;
    queue<pair<int, int>> index;
    queue<int> value;
    index.push(make_pair(0, 0));
    value.push(D[0][0]);
    vector<int> diffh{0, 1};
    vector<int> diffw{1, 0};
    vector<int> coefprev{1, -1};
    vector<int> coefnew{1, 1};
    while (!index.empty() && !value.empty())
    {
        int h = index.front().first;
        int w = index.front().second;
        int v = value.front();
        index.pop();
        value.pop();

        for (int i = 0; i < 2; i++)
        {
            int newh = h + diffh[i];
            int neww = w + diffw[i];
            if (newh >= H)
            {
                continue;
            }
            if (neww >= W)
            {
                continue;
            }
            for (int j = 0; j < 2; j++)
            {
                int newv = abs(coefprev[j] * v + coefnew[j] * D[newh][neww]);
                if (newv > 80 * 80 + 1)
                {
                    continue;
                }
                if (dp[newh][neww][newv])
                {
                    continue;
                }
                index.push(make_pair(newh, neww));
                value.push(newv);
                dp[newh][neww][newv] = true;
            }
        }
    }
    int ans = 80 * 80 + 1;
    for (int i = 0; i < 80 * 80 + 1; i++)
    {
        if (dp.back().back()[i])
        {
            ans = min(ans, i);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 8704
import sys

def IL():
	return list(map(int, sys.stdin.readline().rstrip().split()))

A, B, C, K = IL()
maxim = 0
if A >= K:
	maxim = K
else:
	maxim = A
	K = K - A
	if B >= K:
		pass
	else:
		K = K - B
		maxim = maxim - K

print(maxim)

Measured memory_bytes: 9196
#include <iostream>
#include <vector>
#include <functional>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;

int main(){
  int n,m;
  while(1){
    cin >> n >> m;
    if(n==0&&m==0)break;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    sort(a.begin(),a.end(),greater<int>());
    int maxi = 0;
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
        if(i==j)continue;
        if(a[i]+a[j]<=m){
          maxi = max(maxi,a[i]+a[j]);
        }
      }
    }
    if(maxi==0) cout << "NONE" << endl;
    else cout << maxi << endl;
  }
  return 0;
}



Measured memory_bytes: 3100
import java.awt.geom.Line2D;
import java.awt.geom.Point2D;
import java.awt.geom.Point2D.Double;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.TreeSet;
import java.lang.Object;
 
public class Main {
    Scanner sc = new Scanner(System.in);
   
    public static void main(String[] args) {
        new Main(); 
    }
   
    public Main() {
        new aoj1230().doIt();
    }
    class aoj1230{	
    	void doIt(){
    		while(true){
    			int n = sc.nextInt();
    			if(n ==0)break;
    			int max = sc.nextInt();
    			int p[] = new int[2*n];
    			for(int i = 0;i < 2*n;i++)p[i] = sc.nextInt();
    			boolean[][]dp = new boolean[2*n][max+1];
    			for(int i = 2;i <= max;i++){
    				for(int j = 0;j < 2*n;j++){
    					for(int k = 1;k <= p[j];k++){
    						if(i-k <= 0)break;
    						if(!dp[(j+1)%(2*n)][i-k])dp[j][i] = true;
    					}
    				}
    			}
    			System.out.println(dp[0][max] ? 1:0);
    		}
    	}
    }
}

Measured memory_bytes: 28308
#include <iostream>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <string>
#include <cmath>
#include <math.h>
using namespace std;

class Dice{
public:
	int face[6];
	Dice(){}
	void north(){
		int t=face[0];
		face[0]=face[1];
		face[1]=face[5];
		face[5]=face[4];
		face[4]=t;
	}
	void south(){
		int t=face[0];
		face[0]=face[4];
		face[4]=face[5];
		face[5]=face[1];
		face[1]=t;
	}
	void east(){
		int t=face[0];
		face[0]=face[3];
		face[3]=face[5];
		face[5]=face[2];
		face[2]=t;
	}
	void west(){
		int t=face[0];
		face[0]=face[2];
		face[2]=face[5];
		face[5]=face[3];
		face[3]=t;
	}
	void spin(){
		int t=face[1];
		face[1]=face[2];
		face[2]=face[4];
		face[4]=face[3];
		face[3]=t;
	}
};

bool equal(Dice d1, Dice d2){
	for(int i=0; i<6; i++){
		for(int j=0; j<4; j++){
			if(d1.face[0]==d2.face[0] 
			&& d1.face[1]==d2.face[1] 
			&& d1.face[2]==d2.face[2] 
			&& d1.face[3]==d2.face[3] 
			&& d1.face[4]==d2.face[4] 
			&& d1.face[5]==d2.face[5]) return true;
			d1.spin();
		}
		if(i%2==0) d1.north();
		else d1.east();
	}
	return false;
}

int getRight(Dice d, int top, int front){
	for(int i=0; i<6; i++){
		for(int j=0; j<4; j++){
			if(d.face[0]==top && d.face[1]==front) return d.face[2];
			d.spin();
		}
		if(i%2==0) d.north();
		else d.east();
	}
	return -1;
}

int main(){
	int num;
	cin >> num;
	Dice dices[num]; 
	for(int i=0; i<num; i++){
		Dice dice = Dice();
		for(int i=0; i<6; i++){
			cin >> dice.face[i];
		}
		dices[i] = dice;
	}
	for(int i=0; i<num-1;i++){
		for(int j=i+1; j<num; j++){
			if(equal(dices[i],dices[j])){
				cout << "No" <<endl;
				return 0;
			}
		}
	}
	cout << "Yes" <<endl;
	//printf("%d\n",getRight(dice,t,f));
	return 0;
}


Measured memory_bytes: 3116
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		java.util.Scanner sin = new java.util.Scanner(System.in);
		int i = 1;
		int a;
		while(true){
			a = sin.nextInt();
			if(a == 0) break;
			System.out.println("Case " + i++ + ": " + a);	
		}
	}
}


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

int main() {
  int N,K;
  cin >> N >> K;  
  vector<int> V(N);
  int count = 0;
  for (int i = 0; i < N; i++) {
    cin >> V.at(i);
    if (V.at(i) >= K)
      count++;
  }
  
  cout << count << endl;
  
}


Measured memory_bytes: 3784
class Stack<T> {
    val values = emptyList<T>().toMutableList()

    fun push(value: T) = values.add(value)

    fun pop() = values.removeAt(values.size - 1)

    override fun toString() = values.toString()
}
class Queue<T> {
    val values = emptyList<T>().toMutableList()

    fun enqueue(value: T) = values.add(value)

    fun dequeue() = values.removeAt(0)

    override fun toString() = values.toString()
}

fun <T> List<T>.get1Origin(index: Int) = this[index - 1]
fun <T> List<T>.subList1Origin(fromIndex: Int, toIndex: Int) = this.subList(fromIndex - 1, toIndex - 1)
fun <T> MutableList<T>.set1Origin(index: Int, element: T) = this.set(index - 1, element)
fun <T> MutableList<T>.removeAt1Origin(index: Int) = this.removeAt(index - 1)

fun String.splitToString() = this.split(" ")
fun String.splitToInt() = this.split(" ").map { it.toInt() }
fun String.splitToLong() = this.split(" ").map { it.toLong() }

fun main(args: Array<String>) {
    val (N, M) = readLine()!!.splitToInt()
    println(if (N == M) "Yes" else "No")
}

Measured memory_bytes: 37896
// 基本テンプレート

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

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

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

signed main() {
    int R, G; cin >> R >> G;
    cout << 2*G - R << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    int n, m, x, y; cin >> n >> m >> x >> y;
    vector<int> xx(n+1); rep(i,n) cin >> xx[i];
    vector<int> yy(m+1); rep(i,m) cin >> yy[i];
    xx[n] = x; yy[m] = y;

    sort(all(xx));
    sort(all(yy));

    if(xx[n] < yy[0]) cout << "No War" << endl;
    else cout << "War" << endl;
}


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

struct RAQ {
    int sz;
    vector<int> dat;
    inline RAQ(int n) {
        sz = 1;
        while(sz < n)
            sz <<= 1;
        dat.assign(sz << 1, 0);
    }
    inline void add(int l, int r, int x) {
        for(l += sz, r += sz; l < r; l >>= 1, r >>= 1) {
            if(l & 1) dat[l++] += x;
            if(r & 1) dat[--r] += x;
        }
    }
    inline int get(int k) {
        int rtn = 0;
        for(k += sz; k; k >>= 1)
            rtn += dat[k];
        return rtn;
    }
};

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

    int N, Q;
    cin >> N >> Q;

    RAQ seg(N);

    int c, x, y, z;
    while(Q--) {
        cin >> c;
        if(c) {
            cin >> x;
            cout << seg.get(x - 1) << "\n";
        } else {
            cin >> x >> y >> z;
            seg.add(x - 1, y, z);
        }
    }
}


Measured memory_bytes: 3784