akhauriyash/Code-Regression huggingface dataset:
#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 FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }



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

  int n;
  cin >> n;
  multiset<int> s;
  rep(i, n) {
    int ai;
    cin >> ai;
    s.insert(ai);
  }

  int ans = 0;
  while (!s.empty()) {
    auto it = s.end();
    it--;
    int a = *it;
    s.erase(it);
    int res = 1;
    while (a >= res) res *= 2;
    res = res - a;
    auto it2 = s.find(res);
    if (it2 != s.end()) {
      ans++;
      s.erase(it2);
    }
  }
  cout << ans << '\n';




  
  return 0;
}

Measured memory_bytes: 9600
#include <cstdio>
#include <string>

using namespace std;

int main(void){
  int a,b;

  int nday[15] = {0,31,29,31,30,31,30,31,31,30,31,30,31};
  string ans[10] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};

  while(true){
    scanf("%d%d", &a,&b);
    if(a == 0 && b == 0)
      break;
    
    int sum = 3;
    for(int i = 1; i < a; i++)
      sum += nday[i];
    sum += b;

    printf("%s\n", ans[sum%7].c_str());

  }
  return 0;
}

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


int main(){
	
	string s; cin >> s;
	int n = s.size();
	
	for(int i = 0; i < n; i++){
	    if(s[i] == s[i+1]){
	    	cout << i+1 <<" " << i+2;
	    	return 0;
		}
		if(i < n-2 && s[i] == s[i+2]){
			cout << i+1 <<" " << i+3;
			return 0;
		}
	}
	cout << -1 <<" "<<-1;
	
    return 0;
}

Measured memory_bytes: 512
import sys
sys.setrecursionlimit(10 ** 7)
from collections import defaultdict as dd
input = sys.stdin.readline
N = int(input())
e = dd(list)
for i in range(N - 1):
  a, b = tuple(map(int, input().split()))
  e[a].append((b, i))
  e[b].append((a, i))
res = [0] * (N - 1)
vis = set()
def dfs(x):
  global vis
  global res
  viss = set()
  svis = set()
  t = 1
  for y, i in e[x]:
    if i in vis: viss.add(res[i])
  #print(x, viss)
  for y, i in e[x]:
    #print(x, y, t)
    while t in viss:
      t += 1
    if i in vis:
      continue
    #print(x, y, t)
    svis.add(y)
    vis.add(i)
    res[i] = t
    t += 1
    dfs(y)
  #print(res)
dfs(1)
print(max(res))
for r in res: print(r)

Measured memory_bytes: 137692
#include<iostream>
#include<algorithm>
#include<ctime>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<iomanip>
#include<numeric>
#include<queue>
#include<deque>
#include<cfloat>
#include<functional>
#include<tuple>
#include<math.h>
#include<bitset>
#include<stack>
#include<set>
#include<random>
#include<stdlib.h>
#define rip(i,n) for(int i=0;i<n;i++)
#define Rip(i,n) for(int i=1;i<=n;i++)
#define RIP(i,a,b) for(int i=a;i<b;i++)
#define all(V) V.begin(),V.end()
#define sec  setprecision;
#define _CRT_SECURE_NO_WARNINGS
#pragma target("avx")
#pragma optimize("O3")
#pragma optimize("unroll-loops");
constexpr double eps = 1e-9;
constexpr double pi = 3.141592653589793238462643383279;
using namespace std;
using ll = long long;
using ld = long double;
using Pa = pair<int, int>;
ll mod = 1000000007;
ll MOD = 998244353;
ll gcd(ll a, ll b)
{
	if (a % b == 0)	return(b);
	else return(gcd(b, a % b));
}
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
ll pow(ll x, ll n) {
	x %= mod;
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return (pow((x * x) % mod, n / 2) % mod);
	else
		return (x * pow(x, n - 1)) % mod;
}
int n; ld i = 1; ld tex = 1.08;
signed main() {
	 cin >> n;
	 while (floor(i * tex) != n) {
		 i++;
		 if (i * tex > n+1) {
			 cout << ":(" << endl;
			 return 0;
		 }
	 }
	 cout << i << endl;
}


Measured memory_bytes: 3792
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    vector<int> a;
    cin >> N;
    for(int i=0; i<N; i++){
        int x; cin >> x;
        a.push_back(x);
    }
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());
    int alice=0, bob=0;
    for(int i=0; i<N; i++){
        if(i%2==0){
            alice+=a[i];
        }else{
            bob+=a[i];
        }
    }

    printf("%d\n", alice-bob);
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e5 + 3;

void solve()
{
    int i = 0, j = 0, len = 0, ans = 0;
    string s; cin >> s;

    for(; j < s.size(); )
    {
        if(s[j] == 'R')
        {
            j++;
            len++;
        }
        else
        {
            ans = max(ans, len);
            j++;
            i = j;
            len = 0;
        }
    }
    cout << max(ans, len) << '\n';
}

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
    // freopen("input.txt", "r", stdin);

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

    return 0;
}

Measured memory_bytes: 3552
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define divup(a,b) ( ( (a) + ( (b) - 1u) ) / (b) ) // a/b の余り切り上げ
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int mod = 1000000007;

int main(){
    int a,p;
    cin>>a>>p;
    cout<< (a*3+p)/2 <<endl;
}


Measured memory_bytes: 256
// Sakhiya07 - Yagnik Sakhiya
 
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(),x.end()
#define pll pair<int,int>
 
#define mp make_pair
#define bp __builtin_popcountll
#define MOD  1000000007
const int N = 500005;

#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);srand(time(NULL));

void solve()
{
     ll k,n;
     cin >> k >> n;
     ll a[n];
     for(ll i=0;i<n;i++)   cin >> a[i];
     ll ans = a[n-1] - a[0];
     for(ll i=1;i<n;i++)
     {
          ll temp = k - a[i] + a[i-1];
          ans = min(ans,temp);
     }
     cout<<ans;
}

int main()
{
     FAST;
     int t = 1;
   //  cin >> t;
     while(t--)
     {
          solve();
     }
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>

using namespace std;

long long int Q, H, S, D;
long long int N;

int main(void) {

	cin >> Q >> H >> S >> D;
	cin >> N;

	long long int M2 = D;

	M2 = min(M2, S * 2);
	M2 = min(M2, H * 4);
	M2 = min(M2, Q * 8);

	long long int M1 = S;
	M1 = min(M1, H * 2);
	M1 = min(M1, Q * 4);

	long long int ans = 0;

	ans += (N /2)*M2;

	ans += (N % 2)*M1;

	ans = min(ans, N*M1);

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		int n;
		// TODO ?????????????????????????????????????????????
		Scanner scan = new Scanner(System.in);
		n=scan.nextInt();
		
		for(int i=1; ++i <= n;)
		{
			int x=i;
			if(x % 3 == 0) {
				System.out.print(" "+i);
				continue;
			}
		while(x>0) {
			if ( x % 10 == 3 ){
				System.out.print(" "+i);
				break;
			  }
			x/=10;
		}
		}
		System.out.println();
		
	}
	

}

Measured memory_bytes: 28852
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<map>
#include<cstdint>
#include<unordered_map>
#include<boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define F first
#define S second

namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

typedef pair<int, int> P;

bool pairsort1(const P& element1, const P& element2)
{//first昇順
	return element1.first < element2.first;
}
bool pairsort2(const P& element1, const P& element2)
{//first降順
	return element1.first > element2.first;
}
bool pairsort3(const P& element1, const P& element2)
{//second昇順
	return element1.second < element2.second;
}
bool pairsort4(const P& element1, const P& element2)
{//second降順
	return element1.second > element2.second;
}

int main() {
	int n;
	cin >> n;
	vector<pair<int,int>>x(n);
	rep(i, n) {
		cin >> x[i].F;
		x[i].second = i;
	}
	sort(all(x), pairsort1);
	int ans1 = x[n / 2 - 1].first;
	int ans = x[n / 2].first;
	rep(i, n) {
		if (x[i].second >= n / 2) {
			x[x[i].second].first = ans1;
		}
		else {
			x[x[i].second].first=ans;
		}
	}
	sort(all(x), pairsort3);
	rep(i, n) {
		cout << x[i].first << endl;
	}

}



Measured memory_bytes: 3712
/*input

*/


//assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
#include<bits/stdc++.h>
using namespace std;
#define ll          long long
#define pb          push_back
#define pii         pair<ll int,ll int>
#define vpii        vector< pii >
#define vi          vector<ll int>
#define vs			vector< string >
#define vvi         vector< vector< ll > >
#define inf			(ll)1e18
#define all(it,a)   for(auto it=(a).begin();it!=(a).end();it++) 
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define repr(i,a,b) for(ll int i=a;i>b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define whatis(x)   cout << #x << " is " << x << "\n";
#define graph(n)    adj(n,vector< ll > () )
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int solve()
{

	ll n;
	cin>>n;
	if(n==2)
	{
		cout<<1<<"\n";
		return 0;
	}
	set<ll> ft;

	for(ll i=1;i*i<=n;i++)
	{
		if(n%i==1 ) ft.insert(i),ft.insert(n/i);
		if(n%i==0)
		{
			ll lt = n;
			while( i>1 && (lt%i)==0 ) lt/=i;
			if(lt%i==1) ft.insert(i);

			lt = n;
			while((n/i)>1 && (lt%(n/i))==0) lt/=(n/i);
			if(lt%(n/i)==1) ft.insert(n/i);
		} 
	}

	ll ans = sz(ft)+1;

	// ll ans_temp=0;
	// rep(k,2,n+1)
	// {
	// 	ll dup = n;
	// 	while(dup%k==0) dup/=k;
	// 	while(dup>k && dup>1) dup-=k;
	// 	if(dup==1)
	// 	{
	// 		// whatis(k);
	// 		ans_temp++;
	// 	} 
	// }

	// cout<<ans_temp<<"\n";

	// all(it,ft) cout<<*it<<"\n";

	// assert(ans_temp==ans);

	cout<<ans<<"\n";
	return 0;
}

int main()
{
	auto start = chrono::high_resolution_clock::now();

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	ll test_cases=1;
	//cin>>test_cases;
	while(test_cases--)
		solve();

	auto stop = chrono::high_resolution_clock::now();
	auto duration = chrono::duration_cast<chrono::milliseconds>(stop-start);
	// cout<<"\nduration: "<<(double)duration.count()<<" milliseconds";
}

Measured memory_bytes: 256
#define DEB
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;


#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

template<class T> void chmin(T& a,const T& b) { if(a>b) a=b; }
template<class T> void chmax(T& a,const T& b) { if(a<b) a=b; }

typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}

//const int INF=5e8;
char s[15];
int n;
int main(){
  cin>>s;
  n=strlen(s);
  lint res=0;
  REP(i,1<<(n-1)){
    vector<int> div;div.pb(0);
    REP(j,n-1) if(i>>j&1) div.pb(j+1);
    div.pb(n);
    REP(j,div.size()-1){
      int l=div[j],r=div[j+1];

      lint tmp=0;
      REPN(k,r,l) tmp=tmp*10+s[k]-'0';
      res+=tmp;
    }
  }
  cout<<res<<endl;
  return 0;
}





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

#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

const int N = 21;
const int M = (1LL<<N);

int a[N][N];
int pw[N+5];
int n;

vector<int> cur(M);
vector<int> go[N+1];

int cnt[M];
const int MOD = 1e9 + 7;

void solve()
{
    pw[0] = 1;
    for(int i=1;i<=N;i++) pw[i] = pw[i-1]<<1;
    
    cin >> n;
    f(i,n) f(j,n) cin >> a[i][j];
    
    f(i,n) if(a[0][i] == 1) cur[pw[i]] = 1;
        
    for(int i=1;i<n;i++)
    {    
        for(auto j : go[i])
        {
            for(int k=0;k<n;k++)
            {
                if(a[i][k] == 1 && ( (j&pw[k]) == 0))
                    cur[j|pw[k]] = (cur[j|pw[k]] + cur[j])%MOD;
            }
        }
    }
    
    cout << cur[pw[n]-1]; 
}

signed main()
{
    f(i,M) go[__builtin_popcount(i)].pb(i);
    
    fast;
    solve();
}

Measured memory_bytes: 19264
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef pair<int,int> P;
const int    INF=(int)1e9;
const int    MOD=(int)1e9+7;
const double EPS=(double)1e-10;
struct Accelerate_Cin{
    Accelerate_Cin(){
        cin.tie(0); ios::sync_with_stdio(0);cout<<fixed<<setprecision(20);
    };
};

int N;
int a[101],b[101],c[101],d[101];
bool check[201][201];
int mpb[201];

signed main(){
  cin>>N;
  for(int t=0;t<N;t++){
    cin>>a[t]>>b[t];
  }
  for(int t=0;t<N;t++){
    cin>>c[t]>>d[t];
    mpb[c[t]]=t;
  }

  sort(c,c+N);

  int ans=0;
  for(int x=0;x<N;x++){
    int X=c[x];
    int Y=d[mpb[X]];

    bool flag=false;
    for(int y=Y-1;0<=y;y--){
      for(int i=0;i<N;i++){
        if(a[i]<X&&b[i]==y&&!check[a[i]][b[i]]){
          check[a[i]][b[i]]=true;
          ans++;
          flag=true;
          break;
        }
      }
      if(flag)break;
    }

  }

  cout<<ans<<"\n";
  return 0;
}


Measured memory_bytes: 256
S = input()
N = len(S)
pre = "R"
R = 1
L = 1
Ans = [0]*N
from math import ceil,floor

for s,i in zip(S[1:],range(1,N)):
        if s == "R":
            R += 1
        if pre == "R" and s == "L":
            Ans[i-1] += ceil(R/2)
            Ans[i] += floor(R/2)
            R = 0
        pre = s

for s,i in zip(S[-2::-1],range(N-2,-1,-1)):
        if s == "L":
            L += 1
        if pre == "L" and s == "R":
            Ans[i+1] += ceil(L/2)
            Ans[i] += floor(L/2)
            L = 0
        pre = s
print(*Ans,sep = " ")


Measured memory_bytes: 6400
#include<bits/stdc++.h>
using namespace std;
namespace FAST_IO
{
	template<typename T> void read(T &a)
	{
		a=0;
		int f=1;
		char c=getchar();
		while(!isdigit(c))
		{
			if(c=='-')
			{
				f=-1;
			}
			c=getchar();
		}
		while(isdigit(c))
		{
			a=a*10+c-'0';
			c=getchar();
		}
		a=a*f;
	}
	template <typename T> void write(T a)
	{
		if(a<0)
		{
			a=-a;
			putchar('-');
		}
		if(a>9)
		{
			write(a/10);
		}
		putchar(a%10+'0');
	}
	template <typename T> void writeln(T a)
	{
		write(a);
		puts("");
	}
}
int main()
{
    int a,b;
    cin>>a>>b;
	cout<<(int)(log(a)/log(b))+1;
}

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 <deque>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

//typedef
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//conversion
inline LL toLong(string s) {LL v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//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) LL((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNTIL(p) while(!(p))

//constant
const double EPS = 1e-5;
const double PI  = acos(-1.0);

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

#define PUTS(x) cout << (x) << endl;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    REP(i,SZ(s))cout<<"x";
    PUTS("");
}

Measured memory_bytes: 256
import  java.io.*;
import  java.math.*;
import  java.util.*;


public class Main {
    public static void main(String[] args) {
    	FastReader cin = new FastReader();
        int n = cin.nextInt();
        char s[] = cin.next().toCharArray();
        int a[] = new int[4010];
        int b[] = new int[4010];
        int c[] = new int[4010];
        
        if(s[0] == 'R') a[0] = 1;
        if(s[0] == 'G') b[0] = 1;
        if(s[0] == 'B') c[0] = 1;
        
        for(int i = 1; i < n; i++){
            if(s[i] == 'R'){
                a[i] = a[i-1]+1;
                b[i] = b[i-1];
                c[i] = c[i-1];
            }
            else if(s[i] == 'G'){
                b[i] = b[i-1]+1;
                a[i] = a[i-1];
                c[i] = c[i-1];
            }
            else if(s[i] == 'B'){
                c[i] = c[i-1]+1;
                a[i] = a[i-1];
                b[i] = b[i-1];
            }
        }
        long ans = 0;
        for(int i = 0; i < n; i++){
            int x = i;
            for(int j = i+1; j < n; j++){
                if(s[j] != s[i]){
                    x = j;
                    if(x == i|| x > n) continue;
                    
                    if((s[i]=='G'&&s[j]=='R')||(s[j]=='G'&&s[i]=='R')) ans += c[n-1]-c[x-1];
                    else if((s[i]=='B'&&s[j]=='R')||(s[j]=='B'&&s[i]=='R')) ans += b[n-1]-b[x-1];
                    else if((s[i]=='G'&&s[j]=='B')||(s[j]=='G'&&s[i]=='B')) ans+=a[n-1]-a[x-1];
                    
                    if((2*x-i)<n&&(s[2*j-i]!=s[j]&&s[2*j-i]!=s[i])) ans--;
                }
            }
        }
        System.out.println(ans);
    }
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;
 
        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }
 
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
 
        int nextInt() {
            return Integer.parseInt(next());
        }
 
        long nextLong() {
            return Long.parseLong(next());
        }
 
        double nextDouble() {
            return Double.parseDouble(next());
        }
 
        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}

Measured memory_bytes: 33460
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

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

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(v) (v).begin(), (v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

vector< int > A;
bool rec(int now,int sum){
  if(!sum) return true;
  else if(now == A.size() || sum < 0) return false;
  return rec( now + 1, sum - A[now]) || rec( now + 1, sum);
}
int main(){
  int n;
  cin >> n;
  A.resize(n);
  for(int i = 0 ; i < n ; i++ ) cin >> A[i];
  int q;
  cin >> q;
  for(int i = 0 ; i < q ; i++ ){
    int M;
    cin >> M;
    cout << ( rec(0,M) ? "yes" : "no" ) << endl;
  }
}



Measured memory_bytes: 3116
#include <iostream>
#include <cstdio>
using namespace std;
int k;
long long ans;
int gcd(int a, int b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int main() {
	cin >> k;
	for (int a = 1; a <= k; a++) {
		for (int b = 1; b <= k; b++) {
			int d = gcd(a, b), e;
			for (int c = 1; c <= k; c++) {
				e = gcd(d, c);
				ans += e;
			}
		}
	}
	cout << ans;
	return 0;
}

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

int main(){
    int N, M;
    cin >> N >> M;
    vector<string> A(N);
    vector<string> B(M);
    for (int i = 0; i < N; i++) cin >> A[i];
    for (int i = 0; i < M; i++) cin >> B[i];
    
    for (int i = 0; i < N-M+1; i++) {
        for (int j = 0; j < N-M+1; j++) {
            bool check = true;
            for (int k = 0; k < M; k++) {
                for (int l = 0; l < M; l++) {
                    if (A[i+k][j+l] != B[k][l]) {
                        check = false;
                        break;
                    }
                }
                if (!check) break;
            }
            if (check) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

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

#define vi vector<int>
#define vl vector<long>
#define vvi vector<vector<int>>
#define vvl vector<vector<long>>
#define pint pair<int, int>
#define plong pair<long, long>

int main() {
    long N, A, B, C, D;
    cin>>N >> A >> B >> C >> D;
    string ans = "NO";
    REP(i, 0, N){
        long j = N-1-i;
        long min_R = -D*j + C*i;
        long max_R = -C*j + D*i;
        if(min_R <= B-A && B-A <= max_R) ans = "YES";
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/
 
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x
 
using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;
 
const ll MODBASE = 1000000007LL;
const int MAXN = 110;
const int MAXM = 1000;
const int MAXK = 16;
const int MAXQ = 200010;

int n, a[MAXN], b[MAXN], c[MAXN];

bool check(int *a, int *b) {
    FOR(i,1,n)
        if (a[i] != b[i]) return false;
    return true;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n;
    FOR(i,1,n) cin >> a[i];
    FOR(i,1,n) cin >> b[i];
    FOR(i,1,n) c[i] = i;
    int cnt = 0, A = 0, B = 0;
    do {
        cnt++;
        if (check(a, c)) A = cnt;
        if (check(b, c)) B = cnt;
    } while (next_permutation(c+1, c+n+1));
    cout << abs(A - B);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
/*
void chmin(ll a, ll b){if (a>b){a = b; return true;}return false;}
void chmax(ll a, ll b){if (a<b){a = b; return true;}return false;}
*/

const ll MOD = 1000000007;
const ll INF = 9999999999;

int main() {
  int N; ll W; cin >>N >>W;
  vector<ll> weight(N),value(N);
  rep (i,N) cin >>weight.at(i) >>value.at(i);

  vector<vector<ll>> dp(N+2, vector<ll>(100100, 0));
  // dp[i][j]...i-1番目までの品物から重さがj以下となるように選んだ時の勝ちの総和の
  // 最大値
  for (int i=0; i<N; i++){
    for (int j=0; j<=W; j++){
      if (j >= weight[i]) chmax(dp[i+1][j], dp[i][j-weight[i]] + value[i]);
      chmax(dp[i+1][j], dp[i][j]);
    }
  }
  cout <<dp[N][W] <<endl;
  
}


Measured memory_bytes: 81024
#include <stdio.h>
#include <string.h>

int main()
{
	int inputN, printOutput;

	scanf("%d", &inputN);

	if (inputN % 2 != 0)
	{
		printOutput = inputN / 2 + 1;
	}
	else
	{
		printOutput = inputN / 2;
	}

	printf("%d \n", printOutput);
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main(){
int a,b,c,d,i,j;
scanf("%d %d %d",&a,&b,&c);
if(a>b){
d=a;
a=b;
b=d;
}
for(i=1;i<=a;i++){
if(a%i==0 && b%i==0){
j=i;
}
}
a=a/j;
b=b/j;
printf("%d\n",a*b*c);
return 0;
}


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

int main(){
    ll n,count=0,max=0;
    cin>>n;
    vector<string> s(n);
    rep(i,n){
        cin>>s[i];
    }
    sort(s.begin(),s.end());
    rep(i,n-1){
        if(s[i]==s[i+1]){
            count++;
            if(max<count){
                max=count;
            }
        }else{
                count=0;
        }
    }
  count=0;
    rep(i,n-1){
        if(s[i]==s[i+1]){
            count++;
            
        }else{
                count=0;
        }
      if(max==count){
                cout<<s[i]<<endl;
            }
    }
  if(count==0&&max==0){
    cout<<s[n-1]<<endl;
  }
}

Measured memory_bytes: 9600
import sys
input = lambda: sys.stdin.readline().rstrip()
from math import floor,ceil,sqrt,factorial,log
from heapq import heapify, heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from decimal import Decimal
inf = float('inf')
mod = 1000000007

k = int(input())
s = input()

if len(s) <= k:
    print(s)
else:
    print(s[:k] + '...')

Measured memory_bytes: 71000
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef vector<int> v;
typedef vector<ll> vll;
typedef pair<int, int> P;
using Graph = vector<vector<int>>;
const int INF = 1001001001;
const int mINF = -1001001001;
const int mod = 1000000007;
// << fixed << setprecision(0) <<
// sort(ALL(),greater<int>());


int main() {
  ll n,k;
  cin >> n >> k;
  while(k<=2*n) {
    if(n>=k) {
      n%=k;
    } else {
      n=abs(k-n);
    }
  }
  cout << n << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector< ll > vi;
typedef vector< vi > vvi;
#define pb push_back

int main(void)
{
    ll a,b,c;
	cin >> a >> b >> c;
	c = c%b;
	bool flag = false;
	for(int i = 1;i<=b;i++)
	{
		if((i*a%b)%b == c)
		{
			flag = true;
			break;
		}
	}
	if(flag)
		cout << "YES"<< endl;
	else
	{
		cout << "NO" << endl;
	}
	
   	return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    if (n % sumKeta(n) == 0){
        println("Yes")
    }else{
        println("No")
    }
}

fun sumKeta(num: Int): Int {
    val str = num.toString()
    var sum = 0
    str.forEach { sum += it.toString().toInt() }
    return sum
}

Measured memory_bytes: 31844
n=input()
t=[]
for i in range(len(n)):
    t.append(n[i])
t.insert(0,"0")
#print(t)
s=int(t[-1])
#print(s)
if s==3:
    print("bon")
elif s==0 or s==1 or s==6 or s==8:
    print("pon")
else:
    print("hon")

Measured memory_bytes: 9184
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;

int main() {
	int N, A, B;
	cin >> N >> A >> B;

	int ans = 0;
	for (int i = 1; i <= N; i++) {
		int s = 0;
		int n = i;
		while (n) {
			s += n % 10;
			n /= 10;
		}

		if ((s >= A) && (s <= B)) ans += i;
	}

	cout << ans << endl;
}

Measured memory_bytes: 3556
import java.io.BufferedReader;
import java.io.InputStreamReader;


public class Main {

	public static void main(String[] args) {
		try {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            String str;
            while ((str = br.readLine()) != null) {
                String[] num = str.split(" ");
                int X = Integer.parseInt(num[0]);
                int A = Integer.parseInt(num[1]);
                int B = Integer.parseInt(num[2]);
                int C = Integer.parseInt(num[3]);
                int D = Integer.parseInt(num[4]);
                int PriceA, PriceB;
                if (X % A == 0) {
                	PriceA = B * (X / A);
                } else {
                	PriceA = B * ((X / A) + 1);
                }
                if (X % C == 0) {
                	PriceB = D * (X / C);
                } else {
                	PriceB = D * ((X / C) + 1);
                }
                System.out.println(Math.min(PriceA, PriceB));
                }
            } catch (Exception e) {
                System.out.println(e);
            }
	}

}



Measured memory_bytes: 24356
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <math.h>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int k; cin >> k;
	ll res=0;
	for(int i=1;i<=k;i++){
		for(int j=1;j<=k;j++){
			for(int l=1;l<=k;l++){
				int g=__gcd(i,j);
				g=__gcd(g,l);
				res+=g;
			}
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 3608
#!/usr/bin/env python3
import sys


def solve(A: int, B: int, C: int):
    mx = max(A, B, C)
    tmp = 0
    tmp += mx - A
    tmp += mx - B
    tmp += mx - C
    if tmp % 2 == 0:
        ret = tmp // 2
    else:
        ret = (tmp + 3) // 2
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    solve(A, B, C)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
/*input
*/

// #include<bits/stdc++.h>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <cstdint>
#include <tuple>
#endif
 
using namespace std;
long long mod=1e9+7;
long long INF=1e7;
double EPS = 1e-12;
const long long lim = 2e5+10;
typedef long long int lld;
typedef long long ll;

#define rep(i,a,n) for(long long int i = (a); i <= (n); ++i)
#define mset(a, v) memset(a, v, sizeof(a))
#define Error(x...) { cout << "(" << #x << ")" << " = ( "; printIt(x); }
template <typename T1> void printIt(T1 t1) { cout << t1 << " )" << endl; }
template <typename T1, typename... T2>
void printIt(T1 t1, T2... t2) { cout << t1 << " , "; printIt(t2...); }


#define popcount __builtin_popcountll

ll powP(ll x, ll y) {
    ll ans = 1, po = x % mod;
    while(y > 0) {
        if(y & 1) ans = ans * po % mod;
        y >>= 1; po = po * po % mod;
    }
    return ans;
}


ll Array[lim],BArray[lim],dp[lim];

int main(){

    ios::sync_with_stdio(0);
    cin.tie(0);
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt 
    freopen("output.txt", "w", stdout);
    #endif

    lld T,i,p,j,l,e,r,b,c,k,q,a,d,w,x,y,u,v,z,t,curr,prev,sum=0,val,countA=0,indicator=0,pos,h,minA,maxA,type,n,m,ans=0,left,right;
    string A,B;
    cin>>n;
    if(n%1000==0) cout<<0<<endl;
    else cout<<1000-n%1000<<endl;
    return 0;
}





Measured memory_bytes: 3640
import java.util.Scanner;
import java.util.Arrays;

public class Main {
    public static void main(String args[]){
        Scanner stdIn = new Scanner(System.in);
        
        int n = stdIn.nextInt();
        //int k = stdIn.nextInt();
        //int b = stdIn.nextInt();
        //int num[] = new int[3];
        //String s = stdIn.next();
        //char c[] = s.toCharArray();
        //boolean flag = true;
        
        if(n % 2 == 0){
            System.out.println(n);
        }else{
            System.out.println(n * 2);
        }
        
        
        
        //System.out.println();
        //System.out.print();
    }
}


Measured memory_bytes: 21844
#include<stdio.h>
int main(){
  int x,y;
  int i;

  for(i=1;i<=3000;i++){
    scanf("%d%d",&x,&y);
    if(x==0 && y==0) break;
    else if(0>x || y>10000){
      i--;
      continue;
    }
    else{
      if(x<=y) printf("%d %d\n",x,y);
      else printf("%d %d\n",y,x);
    }
  }
  return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll MOD = 1000000007;

const int MAX_V = 200002;
int a[22];
int N;
double memo[22][MAX_V];
bool visited[22][MAX_V];

double dfs(int pos, int prev){
    if(pos == N) return 0;
    if(visited[pos][prev]) return memo[pos][prev];
    double ret = 1e18;
    for(int i=1;prev*i<MAX_V;i++){
        int next = i * prev;
        ret = min(ret, max(abs(a[pos]-next) / double(a[pos]), dfs(pos+1, next)));
    }
    visited[pos][prev] = true;
    memo[pos][prev] = ret;
    return ret;
}

int main(){
    cin >> N;

    for(int i=0;i<N;i++){
        cin >> a[i];
    }
    printf("%.10f\n", dfs(0, 1));

    return 0;
}

Measured memory_bytes: 36532
#include <iostream>
 
int gcd2(int a, int b){
  if(a%b == 0){
    return b;
  }else{
    return gcd2(b, a%b);
  }
}
 
int gcd3(int a, int b, int c){
  int d = gcd2(a,b);
  int e = gcd2(c,d);
  return e;
}
 
int main(){
  
  int K = 0;
  std::cin >> K;
  
  long sum = 0;
  for(int i=1; i<=K; i++){
    for(int j=1; j<=K; j++){
      for(int k=1; k<=K; k++){
        sum += gcd3(i, j, k);
      }
    }
  }
  
  std::cout << sum << std::endl;
  
  return 0;
}

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

#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)

#define INF (int)1e9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define endl "\n"

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<string, string> pss;
typedef map<int, int> mii;

void solve(ll test_case)
{
  int n;
  cin>>n;
  ll sum = 0;
  vi a(n);
  int temp;
  //vi
  vl array(100000,0);
  for(int i=1;i<n+1;i++){
    cin>>temp;
    sum+=temp;

    array[temp]++;

  }
  int k;
  cin>>k;
  while(k--){
    int pos,val;
    int pro=0,after=0;
    cin>>pos>>val;
    if(array[pos] != 0){
        pro = pos * array[pos];
        after = array[pos] * val;
        array[val]+=array[pos];
        array[pos]=0;
    }
    sum+= (after - pro);
    cout<<sum<<endl;
  }
}

int main()
{

//#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
//#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t=1, t1 = 0;
    //cin >> t;
    while (t1 < t)
    {
        solve(t1 + 1);
        t1++;
    }
 return 0;
}


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

class Main{
	public static void main(String[] args){
		Solve s = new Solve();
		s.solve();
	}	
}

class Solve{
	Solve(){}
	
	Scanner in = new Scanner(System.in);

	void solve(){
		int n = in.nextInt(), m = in. nextInt();
		int ans = m;
		boolean f = true;
		for(int i = 0; i < n; i++){
			int a = in.nextInt(), b = in.nextInt();
			m += a; m -= b;
			if(m < 0) f = false;
			ans = Math.max(ans, m);
		}
		if(f) System.out.println(ans);
		else System.out.println(0);
	}
	
}

// while(in.hasNext()){
		// 	int n = in.nextInt();
		// 	if(n == 0) return;
			
		// }

Measured memory_bytes: 47368
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
signed main(){
  int a;
  int c=0;
  int d=0;
  int e=0;
  int f=0;
  int g=0;
  int h=0;
  int j=0;
  int k=0;
  int l=0;
  int m=0;
  cin>>a;
  vector<int> b(a);
  rep(i,a)
  cin>>b.at(i);
  rep(i,b.size()){
    if(b.at(i)<400){
        d++;
      if(d==1)
        c++;
        }
  if(400<=b.at(i)&&b.at(i)<800){
        m++;
      if(m==1)
        c++;
        }
  if(800<=b.at(i)&&b.at(i)<1200){
        f++;
      if(f==1)
        c++;
        }
  if(1200<=b.at(i)&&b.at(i)<1600){
        g++;
      if(g==1)
        c++;
        }
  if(1600<=b.at(i)&&b.at(i)<2000){
        h++;
      if(h==1)
        c++;
        }
  if(2000<=b.at(i)&&b.at(i)<2400){
        j++;
      if(j==1)
        c++;
        }
  if(2400<=b.at(i)&&b.at(i)<2800){
        k++;
      if(k==1)
        c++;
        }
  if(2800<=b.at(i)&&b.at(i)<3200){
        l++;
      if(l==1)
        c++;
        }
    if(3200<=b.at(i))
      e++;
    }
  if(d==0&&m==0&&f==0&&g==0&&h==0&&j==0&&k==0&&l==0)
    cout<<1<<' '<<e;
    else
      cout<<c<<' '<<c+e;
    }


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);
		String inputN = scanner.nextLine();
		
		String inputP = scanner.nextLine();
		String[] pStr = inputP.split(" ", 0);
		
		int n = Integer.parseInt(inputN);
		int pInt[] = new int[n];
		for(int i=0;i<n;i++){
			pInt[i] = Integer.parseInt(pStr[i]);
		}
		
		for(int i=1;i<n;i++){
			if(pInt[i] > pInt[i-1]){
				pInt[i]--;
			}
		}
		
		boolean isStair = true;
		
		for(int i=1;i<n;i++){
			if(pInt[i] < pInt[i-1]){
				isStair = false;
			}
		}
		
		String show = isStair ? "Yes" : "No";
		System.out.println(show);
	}
}

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

int main(){
	string a;
	cin >> a;
	for (int b = 0; b < 4; b++) {
		cout << a[b];
	}
	cout << " ";
	for (int c = 4; c < 12; c++) {
		cout << a[c];
	}
	cout << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <queue>
#include <string>
#include <algorithm>
#include <cstdio>
#include <stack>
#include <vector>
#include <map>
#include <ctime>
#include <cmath>
#include <string.h>
#define inf 0x7fffffff
using namespace std;
struct I
{
    int x,y;
};


int a,b,c,k,n,m,i,e,d,o[11010],l[1000][212],dx[20]={1,0,-1,0},dy[20]={0,1,0,-1},dz[20]={1,-1};
long long x,y,z[110];
//map <string,int> m;
int j[1060];

stack<int> s;
//char r[55];
//deque<int> d;
struct P
{
    int x,y;
    /*bool operator<(const P &a)const
    {

        return max(x,-x)<=max(a.x,-a.x);
    }*/
};
double u;
//P u[500000];
vector <int> v[211010];
queue<P> q;
string r,r1[100];
map<string,int > p;
//A==65
//Z==90

//a==97

int f(int t)
{
    if(b<0||c<0||d<0) return 0;
    if(b==0&&c==0&&d==0) return 1;
    if(t%2)
    {
        d--;
        return f(4);
    }
    if(t%4==2)
    {
        c--;
        return f(2);
    }
    int k=0;
    if(b>0)
    {
    b--;
    return f(1);
    }
    //b++;
    if(c>0)
    {
    c--;
    k=max(k,f(2));
    }
    //c++;
    d--;
    k=max(k,f(4));
    return k;
}

int main()
{
    scanf("%d %d %d",&a,&b,&c);
    for(int t=1;t<=c;t++)
        scanf("%d",&o[t]);
        int u=0;
    for(int h=1,t=1,w=1;h<=c;)
    {
        if(o[h]==0)
        {
            h++;
            goto asdf;
        }
        l[t][w]=h;
        o[h]--;
        if(l[t+dx[u]][w+dy[u]]!=0||t+dx[u]>a||w+dy[u]>b||t+dx[u]<1||w+dy[u]<1)
            u=(u+1)%4;
        t+=dx[u];
        w+=dy[u];
        asdf:;
    }
    for(int t=1;t<=a;t++,puts(""))
        for(int w=1;w<=b;w++)
        printf("%d ",l[t][w]);
}


Measured memory_bytes: 5376
#include<stdio.h>

int main(){
  int n,m[4],flag=0,i;
  scanf("%d",&n);
  if(n>=1000&&n<=9999){
    m[0]=n%10;
    for(i=1;i<4;i++){
      n/=10;
      m[i]=n%10;
      if(m[i]==m[i-1])
        flag++;
    }
    if(flag>=2&&m[1]==m[2])
     printf("Yes\n");
    else
      printf("No\n");
  }
  return 0;
}  

Measured memory_bytes: 128
N = int(input())
ng = ["agc", "aagc", "acgc", "aggc", "atgc", "agac", "agcc", "aggc", "agtc", "acg", "gac"]
c = 0

x = {"a": 1, "g": 1, "c": 1, "t": 1}
for _ in range(N - 1):
    y = {}
    for k, v in x.items():
        n = k[-3:]
        for s in ["a", "c", "g", "t"]:
            if n + s in ng or (n + s)[-3:] in ng:
                continue
            if n + s in y.keys():
                y[n + s] += v
            else:
                y[n + s] = v
    x = y

print(sum(x.values()) % 1000000007)







Measured memory_bytes: 3064
// D.cpp
#include <bits/stdc++.h>

using namespace std;

const int MAX_N = 2020, base = MAX_N;

int n, mod, dp[MAX_N * 3][MAX_N * 4];

int main()
{
    scanf("%d%d", &n, &mod), dp[0][base] = 1;
    for (int i = 0; i < 3 * n; i++)
        for (int j = -n; j <= 3 * n; j++)
        {
            dp[i + 1][j + 1 + base] = (0LL + dp[i + 1][j + 1 + base] + dp[i][j + base]) % mod;
            dp[i + 2][j - 1 + base] = (0LL + dp[i + 2][j - 1 + base] + 1LL * dp[i][j + base] * (i + 1) % mod) % mod;
            dp[i + 3][j + base] = (0LL + dp[i + 3][j + base] + 1LL * dp[i][j + base] * (i + 2) % mod * (i + 1) % mod) % mod;
        }
    int ans = 0;
    for (int i = 0; i <= 3 * n; i++)
        ans = (0LL + ans + dp[3 * n][i + base]) % mod;
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 193176
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x) x
#define rep(...) MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<"\n"
using namespace std; typedef long long ll;
typedef vector<int> vi; typedef vector<ll> vll; template<class T>using vv = vector<vector<T>>;
template<class T>vv<T> vvec(size_t n, size_t m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T>bool chmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
template<class T>bool chmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 28, MOD = int(1e9) + 7; constexpr ll LINF = 1ll << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); }; }aaaa;

int main() {
    int N, M;
    cin >> N >> M;
    vi A(N);
    rep(i, N) cin >> A[i];

    ll sum = 0;
    map<int, int> m;
    m[sum]++;
    ll ans = 0;
    rep(i, 0, N) {
        sum += A[i];
        ans += m[sum % M];
        m[sum % M]++;
    }

    write(ans);
}

Measured memory_bytes: 3584
#include <stdio.h>
int main()
{
  double a,b,c,sum,i,n;
  scanf("%lf",&n);
  for(i=0;i<n;i++){
    scanf("%lf %lf %lf",&a,&b,&c);
    a=a*a;
    b=b*b;
    c=c*c;
    sum=a+b+c;
    //printf("%d %d %d %d",a,b,c,sum);//
    if(a==1&&b==1&&c==1){
      printf("NO\n");
    }else if(sum/2==a||sum/2==b||sum/2==c){
      printf("YES\n");
    }else printf("NO\n");
  }
  return 0;
}

Measured memory_bytes: 1036
#include <iostream>
#include <string>
#include<algorithm>
#include <vector>
#include<stack>
#include<queue>
#include<list>
#include<set>
#include<map>
#include<numeric>
#include<regex>
using namespace std;

typedef long long ll;
#define modulo 1000000007 // 10^9 + 7
#define MAX 1000000000 // 10^9


int main() {
	int N, H, W;
	cin >> N >> H >> W;
	int ans = 0;

	for (int i = 0; i < N; i++) {
		int a, b;
		cin >> a >> b;
		if(H <= a && W <= b) ans++;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<long long, long long> P;
#define int long long
#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
#ifdef DEBUG
std::ostream& dout = cout;
#else
stringstream dout;
#endif
template<typename T, typename U>
istream& operator>>(istream& in, pair<T, U>& p) {
    in >> p.first >> p.second;
    return in;
}
signed main(signed argc, char* argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    const int MOD = 1000000007;
    string s;
    cin>>s;
    if(s[2]==s[3]&&s[4]==s[5])cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

void solve() {
    ll N, M;
    cin >> N >> M;
    using Tup = tuple<ll, ll, ll>;
    vector<Tup> cs(M);
    for (ll i = 0; i < M; i++) {
        ll p, y;
        cin >> p >> y;
        --p;
        cs[i] = {y, p, i};
    }
    sort(cs.begin(), cs.end());
    Vl num(N);
    vector<Pll> ans(M);
    for (ll i = 0; i < M; i++) {
        auto [y, p, idx] = cs[i];
        ++num[p];
        ans[idx] = {p, num[p]};
    }
    cout << setfill('0');
    for (ll i = 0; i < M; i++) {
        cout << setw(6) << ans[i].first + 1;
        cout << setw(6) << ans[i].second;
        cout << "\n";
    }
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    solve();
    cout << flush;
    return 0;
}

Measured memory_bytes: 7952
#include<iostream>
#include<string>
#include<sstream>

using namespace std;
int main() {
	string s; cin >> s;
	int a, b;
	stringstream ss;
	ss << s.substr(0, 2); ss >> a;
	ss.clear();
	ss << s.substr(2, 2); ss >> b;

	if (a == 0)a = 13;
	if (b == 0)b = 13;
	if (a <= 12 && b <= 12)cout << "AMBIGUOUS";
	else if (a <= 12 && b > 12)cout << "MMYY";
	else if (a > 12 && b <= 12)cout << "YYMM";
	else cout << "NA";
	cout << endl;
	
	return 0;
}

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

int main() {
    string s;
    string head, tail;
    string new_string;
    int length;
    
    cin >> s;
    length = s.length();
    head = s[0];
    tail = s[length-1];
    
    cout << head << length-2 << tail << endl;
    return 0;
}


Measured memory_bytes: 256