akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#define YES "YES"
#define NO "NO"
#define Yes "Yes"
#define No "No"
#define ECHO OUT(solve())
#define YESNO OUT(three(solve(),YES,NO))
#define YesNo OUT(three(solve(),Yes,No))
#define three(A,B,C) ((A)?(B):(C))
#define FOR(i,a,b)  for(LL i=(a);i< (LL)(b);i++)
#define EFOR(i,a,b) for(LL i=(a);i<=(LL)(b);i++)
#define RFOR(i,a,b) for(LL i=(b);i>=(LL)(a);i--)
#define REP(i,b) FOR(i,zero,b)
#define rep REP
#define EREP(i,b) EFOR(i,zero,b)
#define RREP(i,b) RFOR(i,b,zero)
#define ALL(c) c.begin(),c.end()
#define UNIQUE(c) sort(ALL(c));c.erase(unique(ALL(c)),c.end())
#define MAX(c) (*max_element(ALL(c)))
#define MIN(c) (*min_element(ALL(c)))
#define MP make_pair
#define FI first
#define SE second
#define SI(x) (LL(x.size()))
#define PB push_back
#define DEBUG(a) OUT(a)
#define DEBUG2(a,b) OUT2(a,b)
#define cat cout << __LINE__ << endl
#define OUT(a) cout << (a) << endl
#define OUT2(a,b) cout << (a) <<" "<<(b) << endl
#define zero 0LL
#define all ALL
#define pb emplace_back
#define eb pb
#define int long long
using namespace std;
template<typename T> inline void maximize(T &a, T b) { a = max(a, b); }
template<typename T> inline void minimize(T &a, T b) { a = min(a, b); }
template<typename T> inline bool middle(T a, T b, T c) { return b <= a && a <= c; }
template<class T> inline bool MX(T &l, const T &r) { return l < r ? l = r, 1 : 0; }
template<class T> inline bool MN(T &l, const T &r) { return l > r ? l = r, 1 : 0; }
typedef int LL;
typedef double ld;
typedef int ut;
typedef vector<ut> VI;
typedef vector<VI> VII;
typedef pair<ut, ut> pr;
typedef pair<ut, pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef tuple<int, int, int, int> tapu;
typedef vector<tapu> Vtapu;
typedef priority_queue<tapu, Vtapu, greater<tapu> > PQ;
inline void outputVI(VI x) { REP(i, SI(x)) { cout << three(i, " ", "") << x[i]; }OUT(""); }
const int SIZE1 = 3e5 + 1000;
const int SIZE2 = 5010;
const int SIZE3 = 430;
const int SIZE = SIZE1;
const int MAPSIZE = 40;
const LL p = 7 + 1e9;
const LL INF = 1LL << 60;
const long double EPS = 1e-7;
typedef pair<ld, ut> pld;
LL BIT[SIZE];
void add(int x,int t){
  x++;
  while(x<=SIZE){
    BIT[x]+=t;
    x+=x&-x;
  }
}
LL sum(int x){
  x++;
  int ans=0;
  while(x>0){
    ans+=BIT[x];
    x-=x&-x;
  }
  return ans;
}
LL sum(int a,int b){
  return sum(b)-sum(a-1);
}
LL P[SIZE];
LL solve(){

 	LL N,K;
  cin >> N >> K;
  REP(i,N){
    cin >> P[i];
    add(i+1,1);
  }
  
  if(K==N){
    REP(i,N-1)
      if(P[i]%N!=(P[i+1]+N-1)%N) return 0;
    return 1;
  }
  if(K%2==0) return 1;
  LL ans=0;
  REP(i,N){
    ans+=sum(1,P[i]-1);
    add(P[i],-1);
  }
  if(ans%2) return 0;
  return 1;
}
signed main(){
  YesNo;
  return 0;
}



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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define show(x) cout << #x << " = " << x ln
#define dbg(x) cout<<#x"="<<x ln

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > mat;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int n, m;
string s[50], t[50];

int main() {
	cin >> n >> m;
	rep(i,n) cin >> s[i];
	rep(i,m) cin >> t[i];
	
	rept(ii,n-m) {
		rept(jj,n-m) {
			rep(i,m) {
				rep(j,m) {
					if (s[ii+i][jj+j]!=t[i][j]) goto br;
				}
			}
			cout << "Yes" << ln;
			return 0;
			br:;
		}
	}
	cout << "No" << ln;
}

Measured memory_bytes: 256
mod=10**9+7
n,k=map(int,input().split())
arr=list(map(int,input().split()))
arr=sorted(arr,reverse=True,key=lambda x:abs(x))
if k==n:
  ans=1
  for i in range(n):
    ans*=arr[i]
    ans%=mod
  print(ans)
else:
  if k%2==1 and max(arr)<0:
    ans=1
    for i in range(k):
      ans*=arr[n-1-i]
      ans%=mod
    print(ans)
  else:
    ans=1
    cnt=0
    for i in range(k):
      if arr[i]<0:
        cnt+=1
      ans*=arr[i]
      ans%=mod
    if cnt%2==0:
      print(ans)
    else:
      min_plus=-1
      min_minus=1
      for i in range(k):
        if arr[i]>=0:
          min_plus=arr[i]
        else:
          min_minus=arr[i]
      max_plus=-1
      max_minus=1
      for i in range(k,n):
        if arr[i]>=0 and max_plus==-1:
          max_plus=arr[i]
        if arr[i]<0 and max_minus==1:
          max_minus=arr[i]
      if min_plus==-1:        
        arr.remove(min_minus)
        ans=1
        for i in range(k-1):
          ans*=arr[i]
          ans%=mod
        ans*=max_plus
        ans%=mod
      elif min_minus==1:        
        arr.remove(min_plus)
        ans=1
        for i in range(k-1):
          ans*=arr[i]
          ans%=mod
        ans*=max_minus
        ans%=mod
      elif min_plus*max_plus>=min_minus*max_minus:
        arr.remove(min_minus)
        ans=1
        for i in range(k-1):
          ans*=arr[i]
          ans%=mod
        ans*=max_plus
        ans%=mod
      else:
        arr.remove(min_plus)
        ans=1
        for i in range(k-1):
          ans*=arr[i]
          ans%=mod
        ans*=max_minus
        ans%=mod
      print(ans)

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

int main(){
  string s;
  cin>>s;
  int p = s[0] == s[s.size() - 1];
  if(p == s.size() % 2) {
    cout<<"Second"<<endl;
  } else{
    cout<<"First"<<endl;
  }
  return 0;
}

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

using namespace std;

const string let = "FESTIVAL";

int adds[42];

int main() {
  long long k;
  cin >> k;
  long long x = 0;
  while (true) {
    x++;
    long long smallest = x * (x * (x * (x * (x * (x * (x * (x + 1) + 1) + 1) + 1) + 1) + 1) + 1) + 1;
    if (smallest > k) {
      x--;
      break;
    }
  }
  if (x == 0) {
    string res = let;
    for (int i = 0; i + 1 < k; i++) {
      res += "L";
    }
    cout << res << endl;
    return 0;
  }
  k -= x * (x * (x * (x * (x * (x * (x * (x + 1) + 1) + 1) + 1) + 1) + 1) + 1) + 1;
  for (int i = 7; i >= 0; i--) {
    adds[i] = 1;
    long long step = 1;
    for (int j = 0; j < i; j++) {
      step *= x;
    }
    while (k >= step) {
      k -= step;
      adds[i]++;
    }
  }
  string res = "";
  for (int i = 7; i >= 0; i--) {
    for (int it = 0; it < adds[i]; it++) {
      for (int j = (int) res.length() - 1; j >= (int) res.length() - (7 - i); j--) {
        res[j]--;
      }
      res += 'h';
    }
    for (int j = 0; j < x; j++) {
      res = (char) ('a' + i) + res;
    }
  }
  for (int i = 0; i < (int) res.length(); i++) {
    res[i] = let[res[i] - 'a'];
  }
  cout << res << endl;
  return 0;
}


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

using namespace std;

#define mp make_pair
#define mt make_tuple 
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define allarr(a) a , a + n
#define ll long long
#define ull unsigned long long 
#define pb push_back
#define fastio ios_base::sync_with_stdio(false) ; cin.tie(NULL); cout.tie(NULL)
typedef pair<int, int> pi;
typedef pair<ll,ll> pll; 
typedef pair<int,pi> trp ;
typedef vector<pi> vpi;
typedef vector<pll> vpll ;
ll _abs (ll x ) { return (x>0?x:-x); }
const int N = 2e5 + 5 ; 
int n , m , ans [N] ; 
int main(){
	fastio ; 
	cin >> n >> m ;
	memset(ans,-1,sizeof ans); 
	vector<tuple<int,int,int>> blocks ; 

	for(int i = 0 ; i < n ; i++ ){
		int l , r , x ;
		cin >> l >> r >> x ; 
		blocks.pb( mt (x , l , r ) ) ; 
	}
	sort(all(blocks)); 
	set<pi> ppl ; 
	for(int i = 0 ; i < m ; i++ ){
		int x ;
		cin >> x ;
		ppl.insert(mp(x,i)); 
	}


	for(int i = 0 ; i < n ; i++ ){
	tuple <int,int,int> b = blocks[i] ;
	cerr<<i<<" "<<get<0>(b)<<" "<<get<1>(b)<<" "<<get<2>(b)<<endl; 
	auto itl =ppl.lower_bound ({get<1>(b)-get<0>(b),-1e9-5}); 
	auto itr =ppl.lower_bound ({get<2>(b)-get<0>(b),-1e9-5}); 
		if( itl != ppl.end() ){
			
		for(auto it = itl ; it != itr ; it ++ ){
			ans[(*it).se] = get<0>(b) ;
			cerr<<"player : "<<(*it).fi<<" "<<(*it).se<<endl;  
		} 
		ppl.erase ( itl , itr ) ; 
		}
	}

	for(int i = 0 ; i < m ; i++ ) cout << ans[i] << endl ; 
}


Measured memory_bytes: 14704
len = int(input())
str = input()
flag = True

if len % 2 == 1:
  flag = False
else:
  for i in range(int(len//2)):
    if str[i] != str[i + int(len // 2)]:
      flag = False

if flag:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll ;
typedef pair <int,int> ii ;
typedef vector < ii > vii ;
typedef vector < vii > viii ;
#define rep(i,n)                   for( int i = 0 ; i < n ; i++)
#define repu(i,a,b)                for(int i = a ; i <= b ; i++) 
#define repd(i,b,a)                for(int i = b ; i >= a ; i--)
#define pb push_back
#define db double 
#define fi first
#define se second

int calc(int h[], int dp[],int i, int k, int n) {
	if(i>=n) return 0;
	int ans=INT_MAX;
	if(dp[i]!=-1) return dp[i];
	repu(j,1,k) {
		if(j+i<=n) 
		ans=min(ans, abs(h[i]-h[j+i])+calc(h,dp,j+i,k,n));
	}
	dp[i]=ans;
	return ans;
}

int main() {
   int n,k; cin>>n>>k;
   int h[n], dp[n];
   rep(i,n) cin>>h[i];
   memset(dp, -1, sizeof dp);
   cout<<calc(h,dp,0,k,n-1);
}

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

int main()
{
  int H,N;
  cin>>H>>N;
  int A[N];
  for(int i=0;i<N;i++)
    cin>>A[i];
  
  for(int j=0;H>0 && j<N;j++)
    H-=A[j];
  if(H<=0)
    cout<<"Yes";
  else
    cout<<"No";
}


Measured memory_bytes: 640
N = int(input())

A = 0
for i in range(1, N + 1):
    if i % 3 == 0 and i % 5 == 0:
        pass
    elif i % 3 == 0:
        pass
    elif i % 5 == 0:
        pass
    else:
        A += i

print(A)

Measured memory_bytes: 9080
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
#define llMAX 9223372036854775807
#define llMIN -9223372036854775808
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll n,k,x,y;

int main(){
  ll ans=0;
  double d;
  cin >> d ;
  d*=3.14159265358979323846*2.0;

  //小数点表記
  cout << setprecision(16) << d<<endl;
  return 0;
}

Measured memory_bytes: 3756
#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;

long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }

int main(){
    int n,xf; cin >> n >> xf;
    vector<int> x(n);

    rep(i,n){
        cin >> x[i];
        x[i] = abs(x[i] - xf);
    }

    int ans = x[0];

    rep(i,n){
        ans = GCD(ans,x[i]);
    }

    cout << ans << endl;

}

Measured memory_bytes: 640
using System;

class B
{
	static void Main()
	{
		Func<string, bool> month = x => x.CompareTo("00") > 0 && x.CompareTo("12") <= 0;
		var s = Console.ReadLine();
		var m1 = month(s.Substring(0, 2));
		var m2 = month(s.Substring(2));
		Console.WriteLine(m1 ? (m2 ? "AMBIGUOUS" : "MMYY") : (m2 ? "YYMM" : "NA"));
	}
}


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

int main(){
  int H,W;
  int ans=1;
  cin>>H>>W;
  char C[H][W];
  int S[H][W];
  string M;
  queue<pair<int,int>>que;
  for(int i=0;i<H;i++){
    cin>>M;
    for(int j=0;j<W;j++){
      C[i][j]=M.at(j);
      if(C[i][j]=='.'){
        S[i][j]=0;
      }
      else{
        S[i][j]=1;
        que.push(pair<int,int>(i,j));
      }
    }
  }
  while(que.size()){
      pair<int,int> p=que.front();que.pop(); 
      int nx=p.first,ny=p.second;
    
      if(nx-1>=0 && S[nx-1][ny]==0){
      S[nx-1][ny]=S[nx][ny]+1;
      que.push(pair<int,int>(nx-1,ny));
      }
      if(ny-1>=0 && S[nx][ny-1]==0){
        S[nx][ny-1]=S[nx][ny]+1;
        que.push(pair<int,int>(nx,ny-1));
      }   
      if(ny+1<W && S[nx][ny+1]==0){
        S[nx][ny+1]=S[nx][ny]+1;
        que.push(pair<int,int>(nx,ny+1));
      }
      if(nx+1<H && S[nx+1][ny]==0){
        S[nx+1][ny]=S[nx][ny]+1;
        que.push(pair<int,int>(nx+1,ny));
      }  
  }
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      //cout<<S[i][j];
      ans=max(ans,S[i][j]);
    }
    //cout<<endl;
  }
  
  cout<<ans-1<<endl;
  return 0;
}


Measured memory_bytes: 16268
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <bitset>
#include<vector>
#include<cstdlib>
#include<map>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
const ll MOD = 1e9 + 7;
#define rep(i,k) for(int i=0;i<k;i++)
ll n, m, i, j, k, o, p, l, z,q,x,y;
ll a[200010], ps[200010], inf = 1000000000000;
map <int, vector <int>> cnt;




int32_t main() {
	cin >> n >> k;
	cnt[0].push_back(0);
	ll ans = 0;
	for (ll i = 1; i <= n; i++) {
		cin >> a[i], a[i]--;
		ps[i] = (ps[i - 1] + a[i]) % k;
		ll x = upper_bound(cnt[ps[i]].begin(), cnt[ps[i]].end(), i - k) - cnt[ps[i]].begin();
		//cout << ps[i] << "\n";
		ans += (ll)cnt[ps[i]].size() - x;
		cnt[ps[i]].push_back(i);
	}
	cout << ans << "\n";

}

Measured memory_bytes: 25216
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
using P = pair<int, int>;

int main() {
    int n;
    while(cin >> n, n) {
        vector<int> xs, ys;
        vector<int> x1(4*n), x2(4*n), y1(4*n), y2(4*n);
        for(int i=0; i<n; ++i) {
            int l, t, r, b;
            cin >> l >> t >> r >> b;
            l *= 2; t *= 2; r *= 2; b *= 2;
            x1[i*4] = l, x2[i*4] = r, y1[i*4] = t, y2[i*4] = t;
            x1[i*4+1] = l, x2[i*4+1] = l, y1[i*4+1] = b, y2[i*4+1] = t;
            x1[i*4+2] = r, x2[i*4+2] = r, y1[i*4+2] = b, y2[i*4+2] = t;
            x1[i*4+3] = l, x2[i*4+3] = r, y1[i*4+3] = b, y2[i*4+3] = b;
            for(int j=-1; j<=1; ++j) {
                xs.push_back(l+j);
                xs.push_back(r+j);
                ys.push_back(t+j);
                ys.push_back(b+j);
            }
        }
        sort(xs.begin(), xs.end());
        sort(ys.begin(), ys.end());
        xs.erase(unique(xs.begin(), xs.end()), xs.end());
        ys.erase(unique(ys.begin(), ys.end()), ys.end());
        for(int i=0; i<4*n; ++i) {
            x1[i] = find(xs.begin(), xs.end(), x1[i]) - xs.begin();
            x2[i] = find(xs.begin(), xs.end(), x2[i]) - xs.begin();
            y1[i] = find(ys.begin(), ys.end(), y1[i]) - ys.begin();
            y2[i] = find(ys.begin(), ys.end(), y2[i]) - ys.begin();
        }
        int res = 0;
        vector<vector<bool>> fld(ys.size(), vector<bool>(xs.size(), false));
        for(int i=0; i<4*n; ++i) {
            for(int y=y1[i]; y<=y2[i]; ++y) {
                for(int x=x1[i]; x<=x2[i]; ++x) {
                    fld[y][x] = true;
                }
            }
        }
        for(int i=0; i<ys.size(); ++i) {
            for(int j=0; j<xs.size(); ++j) {
                if(fld[i][j]) {
                    continue;
                }
                fld[i][j] = true;
                res++;
                queue<P> que;
                que.push(make_pair(i, j));
                while(!que.empty()) {
                    P p = que.front(); que.pop();
                    int sy = p.first, sx = p.second;
                    int dy[4] = {0, -1, 0, 1},
                        dx[4] = {1, 0, -1, 0};
                    for(int k=0; k<4; ++k) {
                        int ty = sy + dy[k], tx = sx + dx[k];
                        if(ty < 0 || ys.size() <= ty || tx < 0 || xs.size() <= tx) {
                            continue;
                        }
                        if(fld[ty][tx]) {
                            continue;
                        }
                        que.push(make_pair(ty, tx));
                        fld[ty][tx] = true;
                    }
                }
            }
        }
        cout << res << endl;
    }
}


Measured memory_bytes: 3008
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <string>
#include <cmath>
#include <sstream>
#include <istream>
#include <iomanip>
#include <typeinfo>
#include <stack>
#include <map>

using namespace std;
typedef long long ll;
ll N;
ll M;
string s;
vector<ll > input1;  
vector<vector <ll > > input2;

int main(){
    
    ll N = 0;
    cin >> N;

    vector< pair<ll, ll > > work(N);

    ll maxWork = 0;
    for(ll i = 0; i < N; i++){
        ll A = 0;
        ll B = 0;
        cin >> A >> B;
        maxWork += A;
        work[i] = make_pair(B, A);
    }

    sort(work.begin(), work.end());
    //cout << work[N-1].first << endl;
    /*
    if(maxWork > work[N-1].first){
        cout << "No" << endl;
    }
    */
    
    /*else{
        cout << "Yes" << endl;
    }*/

    /*
    //vector<vector<ll> > dp(N+1, vector<ll >(work[N-1].first + 1, -1));
   */
   //vector<ll> dp(work[N-1].first + 1, -1);
    //初期化
    ll sum = 0;
    for(ll i = 0; i < N; i++){
        sum += work[i].second;
        //cout << sum << endl;
        if(sum > work[i].first){
            cout << "No" << endl;
            return 0;
        }

        
    }

    cout << "Yes" << endl;
} 

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long n,ans,t,a;
    double hei= 1000000;
    cin >> n;
    cin >> t >> a;
    for(int i = 0;i<n;i++){
        long long h;
        cin >> h;
        if(abs(a-(t-0.006f*h)) < hei){
            hei = abs(a-(t-0.006f*h));
            ans = i+1;
        }
    }


    cout << ans<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <iomanip>

using namespace std;

int main(){
    int N;
    cin >> N;
    int A[N];
    bool ok = true;
    for(int i =0; i<N;i++){
        cin >> A[i];
        if(A[i]%2==0){
            if(A[i]%3!=0 && A[i]%5!=0){
                ok = false;
            }

        }
    }
    if(ok) cout << "APPROVED"<<endl;
    else cout << "DENIED" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
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; }
struct io { io() { ios::sync_with_stdio(false); cin.tie(0); } };
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;


signed main(void) 
{
    ll n;
    cin >>n;
    string s;
    cin >>s;
    if (n >= 3200) {
        mes(s);
        re0;
    }
    mes("red");

    
    
    
    
    
    

}


Measured memory_bytes: 3580
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(0,-1),(1,0),(0,1),(-1,0)]
ddn = [(0,-1),(1,-1),(1,0),(1,1),(0,1),(-1,-1),(-1,0),(-1,1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    rr = []

    while True:
        n,M,A,B,C,T = LI()
        if n == 0:
            break
        a = tuple(LI())
        if T == 0:
            rr.append(' '.join(map(str, a)))
            continue
        m = [[0]*n for _ in range(n)]
        for i in range(n):
            m[i][i] = B
            if i > 0:
                m[i][i-1] = A
            if i < n-1:
                m[i][i+1] = C
        mod = M

        class Matrix():
            def __init__(self, A):
                self.A = A
                self.row = len(A)
                self.col = len(A[0])

            def __iter__(self):
                return self.A.__iter__()

            def __getitem__(self, i):
                return self.A.__getitem__(i)

            def __add__(self, B):
                aa = self.A
                bb = B.A
                return Matrix([[(aa[i][j] + bb[i][j]) for j in range(self.col)] for i in range(self.row)])

            def __sub__(self, B):
                aa = self.A
                bb = B.A
                return Matrix([[aa[i][j] - bb[i][j] for j in range(self.col)] for i in range(self.row)])

            def __mul__(self, B):
                bb = [[B.A[j][i] for j in range(B.row)] for i in range(B.col)]
                return Matrix([[sum([ak * bk for ak,bk in zip(ai,bj)]) % mod for bj in bb] for ai in self.A])

            def __truediv__(self, x):
                pass

            def pow(self, n):
                A = self
                r = Matrix([[0 if j != i else 1 for j in range(self.row)] for i in range(self.row)])
                while n > 0:
                    if n % 2 == 1:
                        r *= A
                    A *= A
                    n //= 2
                return r

            def __str__(self):
                return self.A.__str__()


        m = Matrix(m)
        mp = m.pow(T)
        r = mp * Matrix([[a[i]] for i in range(n)])
        rr.append(' '.join(map(lambda x: str(x[0]), r)))

    return '\n'.join(map(str,rr))


print(main())




Measured memory_bytes: 9608
#include<bits/stdc++.h>
using namespace std;
const int N=800005;

inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-') f=-1;ch=getchar();}
	while(isdigit(ch)){x=(x<<3)+(x<<1)+(ch&15);ch=getchar();}
	return x*f;
}

int n,k,tot,tmp,ans=0x7fffffff;
int ver[N],nex[N],head[N];
inline void add(int x,int y)
{ver[++tot]=y;nex[tot]=head[x];head[x]=tot;}

inline void dfs(int x,int fa,int dep)
{
	if(dep>k/2) tmp++;
	for(int i=head[x];i;i=nex[i])
	{
		int y=ver[i];
		if(y==fa) continue;
		dfs(y,x,dep+1);
	}
} 

int main()
{
	n=read(),k=read();
	for(int i=1;i<n;i++)
	{
		int x=read(),y=read();
		add(x,y);add(y,x); 
	} 
	if(k%2)
	{
		for(int x=1;x<=n;x++)
			for(int i=head[x];i;i=nex[i])
			{
				tmp=0;int y=ver[i];
				dfs(x,y,0);dfs(y,x,0);
				ans=min(ans,tmp);
			}
	}
	else
		for(int x=1;x<=n;x++)
			tmp=0,dfs(x,0,0),ans=min(ans,tmp);
	printf("%d\n",ans);
} 

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vb = vector<bool>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define LINF 1E18*5
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384

template<class S, class T>ostream& operator<<(ostream&os, pair<S, T>p) { os << "[" << p.first << ", " << p.second << "]"; return os; };
template<class S>auto&operator<<(ostream&os, vector<S>t) { bool a = 1; for (auto s : t) { os << (a ? "" : " ") << s; a = 0; } return os; }

//int dx[]={1,1,1,0,-1,-1,-1,0},dy[8]={1,0,-1,-1,-1,0,1,1,1};
//
constexpr ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }

class compare {
public:
	bool operator()(tuple<int, int> a, tuple<int, int> b) {
		return (get<1>(a) < get<1>(b));
	}

};

int main() {
	int n;
	cin >> n;
	vector<vvi> vvv(n, vvi(101, vi(101)));
	vi x(n), y(n), h(n);
	rep(i, n) {
		cin >> x[i] >> y[i] >> h[i];
	}
	rep(i, n) {
		rep(j, 101) {
			rep(k, 101) {
				vvv[i][j][k] = (abs(x[i] - j) + abs(y[i] - k) + h[i]);
			}
		}
	}
	rep(j, 101) {
		rep(k, 101) {
			bool b = true;
			int hei= -1 ;
			rep(i, n) {
				if (h[i] != 0) {
					hei = vvv[i][j][k];
					i += n;
				}
			}
			rep(i, n) {
				if (h[i] != 0) {
					if (hei != vvv[i][j][k])b = false;
				}
				else {
					if (hei > vvv[i][j][k]) b = false;
				}
			}
			if (b) {
				cout << j << " " << k << " " << hei << endl;
				return 0;
			}
		}
	}
}


Measured memory_bytes: 4608
#include <iostream>

int main(void){
    /* input */
    int beginNum  = 0;
    int endNum    = 0;
    int targetNum = 0;
    std::cin >> beginNum >> endNum >> targetNum;
    
    /* check */
    int divisorCount     = 0;
    for(int divideNum = beginNum; divideNum <= endNum; ++divideNum)
    {
        if((targetNum % divideNum) == 0)    /* 約数の場合 */
        {
            ++divisorCount;
        }
    }
    /* output */
    std::cout << divisorCount << std::endl;
    
    return 0;
}


Measured memory_bytes: 3104
#include <iostream>
using namespace std;
int main(){
    int n,m,k;
    cin >> n >> m >> k;
    bool flag=false;
   // int t=m>n?n-1:m-1;
   /* if(k<=t || (k>=n*m-t || k<n*m)){
        flag =false;
    }else if((n%2==0 && m%2==0)&&k%2==1){
        flag=false;
    }*/

    for(int i=0;i<=n;i++){
        for(int j=0;j<=m;j++){
            int t=(n-i)*j+(m-j)*i;
            if(t==k) flag=true;
        }
    }
    if(flag)
        printf("Yes\n");
    else
        printf("No\n");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long
const int INF = 1LL << 60;

signed main(){

  int n, m, x; cin >> n >> m >> x;
  vector<int> c(n);
  vector<vector<int>> a(n, vector<int>(m));
  for(int i = 0; i < n; i++){
    cin >> c[i];
    for(int j = 0; j < m; j++){
      cin >> a[i][j];
    }
  }

  int ans = INF;
  for(int i = 0; i < 1 << n; i++){
    vector<int> v(m, 0);
    int cost = 0;
    for(int j = 0; j < n; j++){
      if(i >> j & 1){
        for(int k = 0; k < m; k++){
          v[k] += a[j][k];
        }
        cost += c[j];
      }
    }
    bool judge = true;
    for(int j = 0; j < m; j++){
      if(v[j] < x) judge = false;
    }
    if(judge) ans = min(ans, cost);
  }
  if(ans == INF) ans = -1;
  cout << ans << endl;

  return 0;
}


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    ll H, W;
    cin >> H >> W;
    mat C(10, vec(10));
    REP(i,0,10) {
        REP(j,0,10) cin >> C[i][j];
    }
    mat A(H, vec(W));
    REP(i,0,H) {
        REP(j,0,W) cin >> A[i][j];
    }

    REP(k,0,10) {
        REP(i,0,10) {
            REP(j,0,10) {
                if(C[i][j] > C[i][k] + C[k][j]) {
                    C[i][j] = C[i][k] + C[k][j];
                }
            }
        }
    }

    ll sum = 0;
    REP(i,0,H) {
        REP(j,0,W) {
            if(A[i][j] >= 0) sum += C[A[i][j]][1];
        }
    }
    PR(sum);

    return 0;
}

/*



*/

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

int main(){
  char c;
  cin>>c;
  if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u'){
    cout<<"vowel"<<endl;
  }else{
    cout<<"consonant"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
n,m =map(int,input().split())

a = 1
b = m - 1
c = m
d = [i for i in range(n + 1)]

for i in range(m):
    if m % 2 == 0 and i < m / 2:
        print(d[a], d[a+b])
        print(d[-a-c],d[-a])
        a = a + 1
        b = b - 2
        c = c - 2

    elif m % 2 != 0 and i < m / 2:
        print(d[-a-c],d[-a])
        if i == (m + 1) / 2 - 1:
            break
        print(d[a], d[a+b])
        a = a + 1
        b = b - 2
        c = c - 2  

Measured memory_bytes: 15888
/*
        BISMILLAHIR RAHMANIR RAHIM
        MD Rasheduzzaman (CUET)
		mdrasheduzzamanakash@gmail.com
*/
#include <bits/stdc++.h>

#define FileIn(file) freopen(file".inp", "r", stdin)
#define FileOut(file) freopen(file".out", "w", stdout)
#define E_FOR(i, a, b) for (long long i=a; i<=b; i++)
#define FOR(i, n) for (long long i=0; i<n; i++)
#define Fill(ar, val) memset(ar, val, sizeof(ar))
#define PI 3.1415926535897932385
#define ll64 unsigned long long
#define ll long long
#define all(ar) ar.begin(), ar.end()
#define all_u(ar,val) ar.begin(), ar.end(),val
#define get_ind_lo(ar,val) long long(lower_bound(all_u(ar,val)) - ar.begin());
#define get_ind_up(ar,val) long long(upper_bound(all_u(ar,val)) - ar.begin());
#define pb push_back
#define pf push_front
#define INF 500000000
#define maxN 10000001
using namespace std;

//sieve

bool bs[maxN];
vector<long long>primes;
void sieve(){
    Fill(bs,true);
    bs[0] = bs[1] = false;
    for(long long i = 4;i < maxN; i += 2) bs[i] = false;
    for(long long i = 3;i*i < maxN;i += 2){
        if(bs[i])
            for(long long j = i*i;j < maxN;j += i+i)  bs[j] = false;
    }
    primes.pb(2);
    for(long long i = 3;i < maxN;i += 2) if(bs[i])    primes.pb(i);
}



int main(){
    long long a,b,cnt=1;
    cin >> a >> b;
    sieve();
    a = __gcd(a,b);
    // cout << a <<endl;
    // for(long long i = 0;i < 10;i++)cout << primes[i] << " ";
    for(long long i : primes){
        if(a%i == 0)++cnt;
        while(a%i == 0)a/=i;
    }
    if(a != 1)++cnt;
    cout << cnt << endl;
}

Measured memory_bytes: 20332
import random
from itertools import accumulate
N = int(input())
As = [int(i) for i in input().split(' ')]

#N = pow(10, 4)
#As = [random.randint(0,1000) for r in range(N)] 
As = list(accumulate(As))


def bsearch(L, l, r, ls, rs):
    if r - l == 0:
        l_temp = L[l-1] if l!=0 else 0
        lsum = l_temp - ls
        return [max(lsum, rs - L[l]), min(lsum, rs - L[l]) + L[l] - l_temp]
    n = int((r-l)/2)
    lsum = L[l+n] - ls
    rsum = rs - L[l+n]
    if lsum > rsum:
        return bsearch(L, l, l+n, ls, rs)
    else:
        return bsearch(L, l+n+1, r, ls, rs)

for i in range(N-3):
    cs = bsearch(As, 0, i+1, 0, As[i+1]) + bsearch(As ,i+2, N-1, As[i+1], As[-1])
    if i == 0:
        result = max(cs) - min(cs)
    else:
        if max(cs) - min(cs) < result:
            result = max(cs) - min(cs)
print(result)


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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;
const int INF = 2147483647;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//myfuncs
//素数判定
template<class T> inline T isPrime(T x) {
	bool ret = true;
	if (x < 2) {
		ret = false;
	}
	for (LL i = 2; i <= sqrt(x); i++) {
		if (x%i == 0) {
			ret = false;
		}
	}
	return ret;
}

//Union FInd
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

//main code

int main(int argc, char const* argv[])
{
    int n;
    cin >> n;
    VVI a(2,VI(n,0));
    for (int i = 0; i < 2; i++) {
        for (int j = 0; j < n; j++) {
            cin >> a[i][j];
        }
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
        int count = 0;
        for (int j = 0; j < n; j++) {
            if (i > j) {
                count += a[0][j];
            }
            else if (i == j) {
                count += a[0][j] + a[1][j];
            }
            else {
                count += a[1][j];
            }
        }
        ans = max(ans,count);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int min(int x, int y) {
	return x < y ? x : y;
}
int main() {
	int n;
	char s[10001][11];
	int ac = 0, bc = 0, abc = 0;
	int ans = 0;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%s", s[i]);
		int l = strlen(s[i]);
		if (s[i][l - 1] == 'A' && s[i][0] == 'B') {
			abc++;
		} else if (s[i][l - 1] == 'A') {
			ac++;
		} else if (s[i][0] == 'B') {
			bc++;
		}
		for (int j = 0; j < l - 1; j++) {
			if (s[i][j] == 'A' && s[i][j + 1] == 'B')
				ans++;
		}
	}
	if (abc == 0) {
		ans += min(ac, bc);
	} else {
		if (ac == 0 && bc == 0) {
			ans += abc - 1;
		} else {
			ans += abc + min(ac, bc);
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int f[100][100],dp[100][100];
int main()
{
	int n=0;
	for(int i = 0; i < 100; ++i)
	{
		for(int j = 0; j < 100; ++j)
		{
			f[i][j]=0;
		}
	}	
	string in;
	int x=1,y=1;
	while(getline(cin,in))
	{
		n++;
		x=1;
		for(int i = 0; i < in.size(); ++i)
		{
			while(i<in.size()&&in[i]!=',')
			{
				f[y][x]*=10;
				f[y][x]+=in[i]-'0';
				i++;
			}
			x++;
		}
		f[y][x]=-1;
		y++;
	}
	n=y-1;
	/*for(int i = 0; i < n+1; ++i)
	{
		for(int j = 0; j < n+1; ++j)
		{
			cout<<f[i][j];
		}
		cout<<endl;
	}*/
	dp[1][1]=f[1][1];
	for(int i = 2; i <= n ; ++i)
	{
		x=1;
		while(f[i][x]!=-1)
		{
			if(i<=y/2)
				dp[i][x]=max(dp[i-1][x-1],dp[i-1][x])+f[i][x];
			else
				dp[i][x]=max(dp[i-1][x],dp[i-1][x+1])+f[i][x];
			x++;
		}
	}
	/*for(int i = 0; i < n+1; ++i)
	{
		for(int j = 0; j < n+1; ++j)
		{
			cout<<" "<<dp[i][j];
		}
		cout<<endl;
	}*/
	cout<<dp[n][1]<<endl;
  return 0;
}

Measured memory_bytes: 1252
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)) {
			while(true) {
				int n = sc.nextInt();
				if(n == 0)break;
				int cnt = 0;
				for(int i=1; i<n; i++) {
					int sum = 0;
					for(int j=i; j<n; j++) {
						sum += j;
						if(sum == n) {
							cnt++;
						}
					}
				}
				System.out.println(cnt);
			}

			
			
	
		}
	}
}





Measured memory_bytes: 26884
#include<iostream>
//#include<cstring>
//#include<cmath>
//#include<cstdio>
//#include<algorithm>
using namespace std;

long long a,b,c,x;
long long sum;
int ans;

int main(){ 
    cin>>a>>b>>c>>x;
    for(int i=0; i<=a; i++){
    	for(int j=0; j<=b; j++){
    		for(int y=0; y<=c; y++){
    			sum=i*500+j*100+y*50;
    			if(sum==x){
    				ans++;
				}
				if(sum>x){
					break;
				}
			}
		}
	}
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
class Dice:
    def __init__(self, labels):
        self._top = labels[0]
        self._front = labels[1]
        self._right = labels[2]
        self._left = labels[3]
        self._back = labels[4]
        self._bottom = labels[5]
    
    def top(self):
        return self._top
    
    def front(self):
        return self._front
    
    def right(self):
        return self._right
    
    def left(self):
        return self._left
    
    def back(self):
        return self._back
    
    def bottom(self):
        return self._bottom
    
    def role(self, directions):
        for d in directions:
            self._role1(d)
    
    def _role1(self, d):
        if d == "N":
            self._top, self._front, self._bottom, self._back = \
            self._front, self._bottom, self._back, self._top
        elif d == "E":
            self._top, self._left, self._bottom, self._right = \
            self._left, self._bottom, self._right, self._top
        elif d == "S":
            self._top, self._back, self._bottom, self._front = \
            self._back, self._bottom, self._front, self._top
        else:
            self._top, self._right, self._bottom, self._left = \
            self._right, self._bottom, self._left, self._top


xs = list(map(int, input().split()))
directions = input()

dice = Dice(xs)
dice.role(directions)

print(dice.top())


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

typedef long long ll;

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

    int k, n;
    cin >> k >> n;
    int arr[n];
    for (int i = 0; i < n; ++i) {
        cin >> arr[i];
    }
    int m = arr[0] + k - arr[n - 1];
    for (int i = 1; i < n; ++i) {
        m = max(m, arr[i] - arr[i - 1]);
    }
    cout << k - m << endl;

    return 0;
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
const unsigned long long MOD=1e9+7;
int dp[2][100005];
int sum[100005];
int a[100005];
int add(int l,int r){
	int res=sum[r]-((l>0)?sum[l-1]:0);
	if(res<0) res+=MOD;
	return res;
}
int main(){
	int n,k;
	cin>>n>>k;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	dp[1][0]=1;
	int ii=0;
	for(int i=0;i<n;i++,ii^=1){
		sum[0]=dp[ii^1][0];
		for(int j=1;j<=k;j++) 
		{
			sum[j]=sum[j-1]+dp[ii^1][j];
			if(sum[j]>=MOD) sum[j]-=MOD;
		}
		for(int j=0;j<=k;j++){
			dp[ii][j]=add(j-a[i],j);
			if(dp[ii][j]>=MOD) dp[ii][j]-=MOD;
		}
		
	}
	cout<<dp[ii^1][k];
}

Measured memory_bytes: 1408
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{
	int i;
	char *buf = calloc(1, 1000000);
	
	scanf("%s", buf);

	for (i = 0; buf[i]; i++) {
		if (i % 2 == 0) {
			putc(buf[i], stdout);
		}
	}
	return 0;
}

Measured memory_bytes: 1152
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in).useDelimiter("\\D");
		int ax, by, i;
		int w = sc.nextInt();
		int n = sc.nextInt();
		int[] tate = new int[w];
		for (i = 0; i < w; i++) {
			tate[i] = i + 1;
		}
		for (i = 0; i < n; i++) {
			ax = sc.nextInt();
			by = sc.nextInt();
			int sub = tate[ax - 1];
			tate[ax - 1] = tate[by - 1];
			tate[by - 1] = sub;
		}
		for (i = 0; i < w; i++) {
			System.out.println(tate[i]);
		}
	}
}

Measured memory_bytes: 17220
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<bitset>
#define endl "\n"
using namespace std;

int main() 
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  
  string a, b, c;

  cin >> a >> b >> c;
  if (a.back() == b.front() && b.back() == c.front())
  {
      cout << "YES" << endl;
  }
  else
  {
      cout << "NO" << endl;
  }
  return 0;
}




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

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

    if (n == 0) {
      break;
    }
    
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
      cin >> a[i];
    }
  
    sort(a.begin(), a.end());

    int mind = 1000001;
    for (int i = 1; i < n; i++) {
      int d = a[i] - a[i - 1];
      if (d < mind) {
	mind = d;
      }
    }

    cout << mind << endl;
  }
}

Measured memory_bytes: 3080
#include<stdio.h>
int gcd(int,int);

int main(){

  int x,y;

  scanf("%d%d",&x,&y);

  printf("%d\n",gcd(x,y));

  return 0;
}
  int gcd(int x, int y) {
    int t;
    while (y != 0) {
      t = x % y;
      x = y;
      y = t;
    }
    return x;
  }
  
  

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;
using PLL = pair<ll, ll>;

using Graph = vector<vector<int>>;

const int MAX_V = 50;
const int MAX_S = MAX_V * 50 + 5;//必要な銀貨の最大
const ll INF = 1e18;

struct Edge{
    int to, a, b;
    Edge(int to, int a, int b):to(to), a(a), b(b){}//コンストラクタ
};


vector<Edge> g[MAX_V];
ll dp[MAX_V][MAX_S + 5];//頂点vで所持金sを持っている時の時間の最小値

int main(){
    int n, m, S; 
    cin >> n >> m >> S;
    rep(i,m){
        int u, v, a, b;
        cin >> u >> v >> a >> b;
        --u, --v;
        g[u].emplace_back(v,a,b);
        g[v].emplace_back(u,a,b);
    } 
    vector<int> c(n), d(n);
    rep(i,n) cin >> c[i] >> d[i];
    rep(i,n)rep(j,MAX_S+5) dp[i][j] = INF;
    S = min(S, MAX_S);
    priority_queue<pair<ll, P>, vector<pair<ll,P>>, greater<pair<ll, P>>> que;//timeが小さい物から取り出す。(dijkstra)
    dp[0][S] = 0;
    que.push(make_pair(0, P(0, S)));
    while(!que.empty()){
        auto p = que.top();
        que.pop();
        ll time = p.first;
        int v = p.second.first;
        int s = p.second.second;
        if(time > dp[v][s]) continue;
        {
            int ns = s + c[v];
            ns = min(ns, MAX_S);
            ll nt = time + d[v];
            if(nt < dp[v][ns]){
                dp[v][ns] = nt;
                que.push(make_pair(nt, P(v, ns)));//頂点は移動しない
            }
        }
        for(auto e : g[v]){
            if(s < e.a) continue;
            int nv = e.to;
            int ns = s - e.a;
            ll  nt = time + e.b;
            if(dp[nv][ns] > nt){
                dp[nv][ns] = nt;
                que.push(make_pair(nt, P(nv, ns)));
            }  
        }
    }
    for(int i = 1; i < n; i++){
        ll res = INF;
        for(int s = 0; s <= MAX_S; s++){
            res = min(res, dp[i][s]);
        }
        cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 6092
use std::collections::{BTreeMap, BTreeSet};
const MOD: usize = 1e9 as usize + 7;
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n: i64 = sc.read();
    let mut memo = BTreeMap::new();
    println!("{}", solve(n, n, &mut memo));
}

fn naive(n: i64) -> usize {
    let mut set = BTreeSet::new();

    for a in 0..(n + 1) {
        for b in 0..(n + 1) {
            let u = a ^ b;
            let v = a + b;
            if u <= n && v <= n {
                set.insert((u, v));
            }
        }
    }
    println!("{:?}", set);
    set.len()
}

fn solve(sum: i64, xor: i64, memo: &mut BTreeMap<(i64, i64), usize>) -> usize {
    match memo.get(&(sum, xor)) {
        Some(&ans) => ans,
        None => {
            if sum == 0 {
                return 1;
            }
            let mut result = 0;

            // odd & odd
            if sum >= 2 {
                result += solve((sum - 2) >> 1, xor >> 1, memo);
            }

            // odd & even
            result += solve((sum - 1) >> 1, xor >> 1, memo);

            // even & even
            result += solve(sum >> 1, xor >> 1, memo);

            result %= MOD;
            memo.insert((sum, xor), result);
            result
        }
    }
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 4352