akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define X first
#define Y second
#define REP(i,a) for(int i=0;i<a;++i)
#define REPP(i,a,b) for(int i=a;i<b;++i)
#define FILL(a,x) memset(a,x,sizeof(a))
#define foreach( gg,itit )  for( typeof(gg.begin()) itit=gg.begin();itit!=gg.end();itit++ )
#define mp make_pair
#define pb push_back
#define all(s) s.begin(),s.end()
#define present(c,x) ((c).find(x) != (c).end())
const double EPS = 1e-8;
const int mod = 1e9+7;
const int N = 1e6+10;
const ll INF = 1e18;

//#define DEBUG
ll power(ll x,ll y){
  ll t=1;
  while(y>0){
    if(y%2) y-=1,t=t*x%mod;
    else y/=2,x=x*x%mod;
  }
  return t;
}
#ifdef DEBUG
#define dprintf(fmt,...) fprintf(stderr,fmt,__VA_ARGS__)
#else
#define dprintf(fmt,...)
#endif

ll a[N],b[N];
int main(){
  int n; scanf("%d",&n);
  ll ans=0;
  REP(i,n) scanf("%lld%lld",&a[i],&b[i]);
  
  for(int i=n-1;i>=0;i--){
    ll k=(a[i]+ans+b[i]-1)/b[i];
    ans+=k*b[i]-(a[i]+ans);
  }
  printf("%lld\n",ans);

  return 0;
}

Measured memory_bytes: 1920
/*
*/
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <string>
#include <cmath>
#include <numeric>

int main()
{
    int p, q, r;
    std::cin >> p >> q >> r;
    int max = std::max(p, std::max(q, r));
    std::cout << p + q + r - max << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) begin(x), end(x)
using namespace std;
using ll = long long;
constexpr ll Mod = 998244353;
constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
const double PI = acos(-1);
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) {
    return a < b && (a = b, true);
}
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) {
    return a > b && (a = b, true);
}
/*-------------------------------------------*/

int D;
int c[26];
ll s[365][26];

int last[26];

set<int> st[26];
vector<int> ret;
vector<int> ans;

ll sum = 0, MAX;

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

    srand((unsigned)time(NULL));

    rep(i, 26) st[i].insert(-1);

    cin >> D;
    rep(i, 26) cin >> c[i];
    rep(i, D) rep(j, 26) cin >> s[i][j];

    rep(d, D) {
        ll a = -1, mx = -1;
        rep(i, 26) if(chmax(mx, (d - *st[i].rbegin()) * c[i] + s[d][i])) a = i;
        ans.push_back(a);
        st[a].insert(d);
        sum += s[d][a];
        rep(i, 26) sum -= c[i] * (d - *st[i].rbegin());
    }

    MAX = sum;
    ret = ans;

    rep(i, 26) st[i].insert(D);

    while(clock() < CLOCKS_PER_SEC * 1.9) {
        int x = rand() % D;
        ll a = -1, mx = -inf;
        rep(i, 26) if(i != ans[x]) {
            auto it1 = st[i].upper_bound(x);
            auto it2 = st[i].lower_bound(x);
            it2--;
            ll y = s[x][i] + (*it1 - *it2) * (*it1 - *it2 - 1) / 2 * c[i];
            y -= (*it1 - x) * (*it1 - x - 1) / 2 * c[i];
            y -= (x - *it2) * (x - *it2 - 1) / 2 * c[i];
            if(chmax(mx, y)) a = i;
        }
        auto it1 = st[ans[x]].upper_bound(x);
        auto it2 = st[ans[x]].lower_bound(x);
        it2--;
        ll y = s[x][ans[x]] + (*it1 - *it2) * (*it1 - *it2 - 1) / 2 * c[ans[x]];
        y -= (*it1 - x) * (*it1 - x - 1) / 2 * c[ans[x]];
        y -= (x - *it2) * (x - *it2 - 1) / 2 * c[ans[x]];
        if(mx >= y) {
            sum += mx - y;
            st[a].insert(x);
            st[ans[x]].erase(x);
            ans[x] = a;
            if(chmax(MAX, sum)) {
                ret = ans;
            }
        } else if(rand() % (y - mx + 1) == 0) {
            sum += mx - y;
            st[a].insert(x);
            st[ans[x]].erase(x);
            ans[x] = a;
        }
    }

    rep(i, D) cout << ret[i] + 1 << endl;

    return 0;

    cout << endl;

    sum = 0;
    rep(d, D) {
        int x = ret[d];
        last[x] = d + 1;
        sum += s[d][x];
        rep(i, 26) sum -= (d + 1 - last[i]) * (c[i]);
        cout << sum << "\n";
    }

    return 0;
}

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

int main(){
    ll N,M;
    string S;
    cin >> S;
    if(S[2] == S[3] && S[4]==S[5]){
        cout << "Yes"<<endl;
        return 0;
    }else{
        cout << "No" << endl;
    }
}


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

int main() {
  int N;
  cin >> N;
  vector<int> P(N);
  for(int i = 0; i < N; i++) {
    cin >> P.at(i);
  }
  int n = 0;
  for(int i = 0; i < N; i++) {
    if(P.at(i) != i + 1) {
      n++;
    }
  }
  if(n < 3) {
    cout << "YES" << endl;
  }
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
using namespace std;
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) gcd(b, a);
  if(b==0) return a;
  return gcd(b, a%b);
 }
int main(){
  int n,max=0,tmp;
  scanf("%d",&n);
  int l[n+2],r[n+2],a[n];
  for(int i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  l[0]=0;
  r[n-1]=0;

  for(int i=1;i<=n;i++){
    l[i]=gcd(l[i-1],a[i-1]);
  }
  for(int i=n-2;i>=0;i--){
    r[i]=gcd(r[i+1],a[i+1]);
  }
  for(int i=0;i<n;i++){
    tmp = gcd(l[i],r[i]);
    max = (max>tmp)?max:tmp;
  }
  printf("%d\n",max);

}


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

int main()
{
	string S;
	cin >> S;
	if (S == "SUN")
		cout << 7;
	else if (S == "MON")
		cout << 6;
	else if (S == "TUE")
		cout << 5;
	else if (S == "WED")
		cout << 4;
	else if (S == "THU")
		cout << 3;
	else if (S == "FRI")
		cout << 2;
	else if (S == "SAT")
		cout << 1;
	return 0;
}


Measured memory_bytes: 256
function Main(input) {
  if(input.includes('RRR')){
     console.log(3)
  }else if(input.includes('RR')){
  	 console.log(2)
  }else if(input.includes('R')){
     console.log(1)
  }else{
  	 console.log(0)
  }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

const int N = 1e5 + 10;

int n, m, x, y, d[N];

int main(){
	while(~scanf("%d %d", &n, &m)){
		for(int i=1; i<=n; i++)	d[i] = 0;
		while(m--){
			scanf("%d %d", &x, &y);
			d[x]++;
			d[y]++;
		}
		bool flag = 1;
		for(int i=1; i<=n; i++){
			if(d[i] & 1){
				flag = 0;
				break;
			}
		}
		puts(flag ? "YES":"NO");
	}
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
	//freopen("input.txt", "r", stdin);
	long long n;
	cin>>n;
	string s;
	s = to_string(n);
	long long sum = 0;
	for(int i=0;i<s.length();i++){
		   sum+=s[i]-'0';
	}
	if(n%sum==0)	cout<<"Yes";
	else			cout<<"No";
	return 0;
}

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

ll N;

int main(void) {
  cin >> N;

  ll ans = N + 1;
  if(N % 2 == 0) ans = 1;
  else {
    ll pow2 = 1;
    while(pow2 <= N) {
      if(((N - pow2 + 1) / pow2) % 2 == 0) {
        ans = pow2;
        break;
      }
      pow2 *= 2;
    }
  }
  cout << ans << endl;
}

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

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

    string s;
    cin >> s;
    
    long long b = 0, ans = 0;
    for(int i = 0; i < s.size(); i++){
        if(s[i] == 'B'){
            b++;
        }else{
            ans += b;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 720
/*????????????????§£?±??????????????????\??????????????????????????????????¨?3????????????????????????????????????
?????\???????????????????°´?????¢???????¨??????????????????????????????????????????§????????????????§?????????§?????????????????§???Debug Assertion Failed??¨????????????????????????
?????????????????????????????????????????\??????????????????????§£?±????????????§while???????????§????????¨????????????????????????AO??????presentation???error?????????????????????
?????????????????????????????\???????????????????????£?§£??§?????????
??£??´??????????????????????????????????????????????????????????????????????????????????????????????????§????????????????????????????§£?±?????????????????????¨??????????????????????????????
????????????????????????????????§????°??????????????????????????????????????????????????????????????????????????????´????????????????????§??????
*/
#include <iostream>
#include <stack>
#include <algorithm>
using namespace std;

int main()
{
	int sum = 0, i, x;
	stack<int>Pos;
	stack< pair<int, int> > S;
	char c;
	i = 0;
	while (cin >> c)
	{
		i++;
		sum = 0;
		if (c == '\\')
			Pos.push(i);
		else if (!Pos.empty() && c == '/')
		{
			x = Pos.top();
			Pos.pop();
			sum = i - x;
			while (!S.empty()&&S.top().first > x )
			{
				sum += S.top().second;
				S.pop();
			}
			S.push(make_pair(x, sum));
		}
	}
	sum = 0;
	int count = 0,Sum[20000];
	while (!S.empty())
	{
		Sum[count] = S.top().second;
		sum += S.top().second;
		count++;
		S.pop();
	} 
	cout << sum << endl<< count;
	for (i = count-1; i >= 0; i--)
	{
		cout << ' '<< Sum[i];
	}
	cout << endl;
}

Measured memory_bytes: 3232
#include <bits/stdc++.h>
using namespace std;
 
int main() 
{
  int w, a, b;
  cin >> w >> a >> b;
  
  int ans;
  
  if (a < b)
    ans = b - a - w;
  else if (a == b)
    ans = 0;
  else
    ans = a - b - w;   
    
  if (ans > 0)
    cout << ans;
  else
    cout << 0;
}

Measured memory_bytes: 3612
N=input()
M=int(N[0:2])
L=len(N[2:])*9
K=0
sum=0
for i in range(len(N)):
	sum+=int(N[i])
K=0
if L>0:
	D=M
else:
	D=M+1
for i in range(D):
	j=str(i)
	if len(j)==1:
		K=max(K,(int(j)))
	else:
		K=max(K,(int(j[0])+int(j[1])))
print(max(sum,K+L))

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


int main(){
    int N,K;
    int p[1001];
    cin >>N>>K;
    for(int i=0;i<N;i++){
        cin>>p[i];
    }
    sort(p,p+N);
    int ans=0;
    for(int i=0;i<K;i++){
        ans+=p[i];
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3644
import java.util.Scanner;

public class Main {
	private static Scanner sc;
	
	public static void main(String[] args) {
		sc =  new Scanner(System.in);
		int redA = Integer.parseInt(sc.next());
		int greenB = Integer.parseInt(sc.next());
		int blueC = Integer.parseInt(sc.next());
		int k = Integer.parseInt(sc.next());
		//case : 入力された文字列を取得するとき
//		String str = sc.next();
		for (int i=1; i<=k; i++) {
			if(redA<greenB) {
				if(greenB<blueC) {
					//do nothing
				} else {
					blueC = blueC*2; 
				}
			} else {
				greenB = greenB*2;
			}
		}
		//最終判定
		if(redA<greenB) {
			if(greenB<blueC) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 35616
#include<stdio.h>
#include<string.h>
#include<ctype.h>
 
 
int main(){
 
  char s[1000], c[10], r[1000];
  int q, i, j, a, b;
 
  scanf("%s", s);
  scanf("%d", &q);
  for(i=0;i<q;i++){
    scanf("%s", c);
    if(strcmp(c,"replace")==0){
      scanf("%d %d %s", &a, &b, r);
      for(j=a;j<=b;j++) s[j]=r[j-a];
    }else if(strcmp(c,"reverse")==0){
      scanf("%d %d", &a, &b);
      for(j=a;j<=b;j++) r[j-a]=s[j];
      for(j=0;j<b-a+1;j++) s[b-j]=r[j];
    }else if(strcmp(c, "print")==0){
      scanf("%d %d", &a, &b);
      for(j=a;j<=b;j++) printf("%c", s[j]);
      printf("\n");
    }
  }
 
  return 0;
}



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

using namespace std;

using ll = long long;
using ld = long double;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

int h, w;

vector<vector<int>> draw(const vector<vector<int>>& vec, int y, int x) {
	vector<vector<int>> bomView = vec;

	for (int i = -1; i <= 1; i++) {
		for (int j = -1; j <= 1; j++) {
			int ny = y + i;
			int nx = x + j;
			
			if (ny < 0 || ny >= h || nx < 0 || nx >= w) {
				continue;
			}

			bomView[ny][nx]++;
		}
	}

	return bomView;
}

void solve(const vector<string>& g) {
	vector<vector<int>> bomView(h, vector<int>(w));
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (g[i][j] == '.') {
				continue;
			}

			bomView = draw(bomView, i, j);
		}
	}

	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (g[i][j] == '#') {
				cout << "#";
			} else {
				cout << bomView[i][j];
			}
		}
		cout << endl;
	}
}

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

	cin >> h >> w;

	vector<string> g(h);
	for (auto& v : g) {
		cin >> v;
	}

	solve(g);
	return 0;
}


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

// TYPEDEF
// ----------------------------------------
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> Pair;
typedef vector<ll> vll;
typedef vector<vector<ll>> Graph;
typedef vector<string> vs;
typedef vector<pair<ll, ll>> Pll;
typedef queue<ll> qll;

// REPEAT
// ----------------------------------------
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REPA(i,a) for(ll i=0;i<(ll)(a.size());i++);
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define COUT(a) cout << (a) << endl;
#define ENDL(a) cout << endl;
#define COUTA(i,a) for(ll i=0;i<(ll)(a.size());i++) {cout << (a)[i] << " ";} cout << endl;

// UTIL
// ----------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define RSORT(a) sort((a).rbegin(), (a).rend())

// DEBUG
// ----------------------------------------
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif

template <typename T>
void debugV(const vector<T> v) {
#ifdef _DEBUG
  rep(i, v.size()) {
    cout << i << ":" << v[i] << " ";
  }
  cout << endl;
#else
  (void)v;
#endif
}

// BIT FLAG
// ----------------------------------------
const unsigned int BIT_FLAG_0 = (1 << 0); // 0000 0000 0000 0001
const unsigned int BIT_FLAG_1 = (1 << 1); // 0000 0000 0000 0010
const unsigned int BIT_FLAG_2 = (1 << 2); // 0000 0000 0000 0100
const unsigned int BIT_FLAG_3 = (1 << 3); // 0000 0000 0000 1000
const unsigned int BIT_FLAG_4 = (1 << 4); // 0000 0000 0001 0000
const unsigned int BIT_FLAG_5 = (1 << 5); // 0000 0000 0010 0000
const unsigned int BIT_FLAG_6 = (1 << 6); // 0000 0000 0100 0000
const unsigned int BIT_FLAG_7 = (1 << 7); // 0000 0000 1000 0000
const unsigned int BIT_FLAG_8 = (1 << 8); // 0000 0001 0000 0000
const unsigned int BIT_FLAG_9 = (1 << 9); // 0000 0010 0000 0000
const unsigned int BIT_FLAG_10 = (1 << 10); // 0000 0100 0000 0000
const unsigned int BIT_FLAG_11 = (1 << 11); // 0000 1000 0000 0000

// CONST
// ----------------------------------------
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI=3.14159265358979323846; // or M_PI
constexpr int MOD = 1000000007;


void Main() {
  string weather;
  cin >> weather;

  ll count = 0;
  ll max_count = 0;
  ll flag = 0;
  REP(i, 3) {
    if(weather[i] == 'R') {
      count++;
    }
    else {
      max_count = max(max_count, count);
      count = 0;
    }
  }
  max_count = max(max_count, count);
  COUT(max_count);
  
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}

/*
4 5
0 5
-2 4
3 4
4 -4
*/


Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <algorithm> 
#include <cstdlib>
#include <map>
#include <queue>
#include <vector>
#include <utility>
#include <climits>
#include <numeric>
#include <bitset>
#define ll long long
#define INF INT_MAX 
using namespace std;
int main(){
    string s;
    cin >> s;
    string divide[4] = {"dream","dreamer","erase","eraser"};
    string t;
    ll count=0;
    bool can2=true;
    reverse(s.begin(),s.end());
    for(int i=0;i<4;i++) reverse(divide[i].begin(),divide[i].end());

    for(int i=0;i<s.size();){
        bool can=false;
        for(int j=0;j<4;j++){
            string d = divide[j];
            if(d == s.substr(i,d.size())){
                i = i + d.size();
                can = true;
            }
        }
        if(!can){
            can2 = false;
            break;
        }
    }
    if(can2)cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 512
n,w=map(int,input().split())
a=[]
dp=[]
for i in range(n):
   a.append(list(map(int,input().split())))
for k in range(n+1):
  dp.append([])
  for l in range(w+1):
      dp[k].append(0)
for i in range(n):
   for j in range(w+1):
       if j<a[i][0]:
           dp[i+1][j]=dp[i][j]
       else:
           dp[i+1][j]=max(dp[i][j],dp[i][j-a[i][0]]+a[i][1])
print(dp[n][w])


Measured memory_bytes: 142668
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstdio>
#include <climits>
#include <set>
#include <map>
using namespace std;

#define rep(i, n) for(int i = 0; i < (n); ++i)

typedef long long ll;

bool isPrime(int a)
{
    if(a == 2) return true;
    int y = sqrt(a);

    for(int i = 2; i <= y; i++)
    {
        if((a % i) == 0)
        {
            return false;
        }
    }

    return true;
}

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

    for(int i = x; i <= 1000000; i++)
    {
        if(isPrime(i))
        {
            cout << i << endl;
            return 0;
        }
    }
    
    return 0;
}

Measured memory_bytes: 256
N,K=map(int,input().split())
D=[0]*K
A=[0]*K
for i in range(K):
    D[i]=int(input())
    A[i]=list(map(int,input().split()))
d={}
for i in range(1,N+1):
    d[i]=0

for i in range(K):
    for a in A[i]:
        d[a]+=1

ans=0
for i in range(1,N+1):
    if d[i] == 0:
        ans += 1

print(ans)

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

#define PUT 0
#define REMOVE 1
#define CHECK_PLANE 2

int cnt;
int m[10][10];
int ans[10][10];

bool is_origin[10][10];
bool make_rect(int now,int x,int y,int width,int height,int flag,
	       int r,int c){
  rep(i,height){
    rep(j,width){
      if ( flag == PUT )m[y+i][j+x]=now;
      else if ( flag == REMOVE && is_origin[y+i][x+j] == false){
	m[y+i][j+x]=0;
      }else if (flag == CHECK_PLANE){
	if ( m[y+i][j+x]!=0 && m[y+i][j+x]!=now)return false;
      }
    }
  }
  return true;
}

void solve(int num,int now,int *number,int *x,int *y,int *size,int r,int c){
  if ( now == num){
    cnt++;
    rep(i,r)rep(j,c)ans[i][j]=m[i][j];
    return;
  }

  if ( cnt > 1)return;
  
  int cur=number[now];
  REP(k,1,size[now]+1 && cnt <2){
    if ( size[now]%k != 0)continue;
    int h=k,w=size[now]/k;
    int hstart=max(0,y[now]-h+1),wstart=max(0,x[now]-w+1);
    REP(i,hstart,y[now]+1 && i+h <=r && cnt < 2){
      REP(j,wstart,x[now]+1 && j+w <=c && cnt < 2){
	if ( make_rect(cur,j,i,w,h,CHECK_PLANE,r,c) ){
	  make_rect(cur,j,i,w,h,PUT,r,c);
	  solve(num,now+1,number,x,y,size,r,c);
	  make_rect(cur,j,i,w,h,REMOVE,r,c);
	}
      }
    }
  }
}


main(){
  int c,r,n;
  while(cin>>c>>r>>n && c){
    pair<int,int> in[n];
    int x[n],y[n],size[n],tmp[100+1],num[100+1];
    rep(i,n)cin>>in[i].second>>in[i].first;
    sort(in,in+n,greater<pair<int,int> >());
    rep(i,n)tmp[in[i].second]=i,size[i]=in[i].first,num[i]=in[i].second;
    rep(i,r){
      rep(j,c){
	cin>>m[i][j];
	if ( m[i][j] != 0){
	  x[tmp[m[i][j]]]=j;
	  y[tmp[m[i][j]]]=i;
	  is_origin[i][j]=true;
	}
	is_origin[i][j]=false;
      }
    }
    cnt = 0;

    solve(n,0,num,x,y,size,r,c);
    if ( cnt == 1){
      rep(i,r){
	rep(j,c){
	  if ( j)cout << ' ';
	  cout <<ans[i][j];
	}
	cout << endl;
      }
    }else cout << "NA"<<endl;
  }
}

Measured memory_bytes: 868
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define SIZE 1000005

ll A[SIZE];
ll table[SIZE];
map<ll,ll> MAP;
bool is_prime[SIZE];

ll mod_pow(ll x,ll count, ll mod){

	if(count == 0)return 1;
	ll ret = mod_pow((x*x)%mod,count/2,mod);
	if(count%2 == 1){

		ret = (ret*x)%mod;
	}
	return ret;
}


ll extgcd(ll a,ll b,ll &x,ll &y){
	ll d = a;
	if(b != 0){
		d = extgcd(b,a%b,y,x);
		y -= (a/b)*x;
	}else{
		x = 1;
		y = 0;
	}
	return d;
}

ll mod_inverse(ll a,ll m){
    ll x,y;
    extgcd(a,m,x,y);
    return (m+x%m)%m;
}

int main(){

	for(int i = 0; i < SIZE; i++){

		is_prime[i] = true;
		table[i] = 0;
	}

	is_prime[0] = false;
	is_prime[1] = false;

	for(int i = 2; i < SIZE; i++){
		if(is_prime[i]){
			for(int k = 2*i;k < SIZE; k += i){
				is_prime[k] = false;
			}
		}
	}

	vector<ll> PRIME;
	for(int i = 2; i < SIZE; i++){
		if(is_prime[i]){
			MAP[i] = PRIME.size();
			PRIME.push_back(i);
		}
	}

	ll N;
	scanf("%lld",&N);

	for(int i = 0; i < N; i++){

		scanf("%lld",&A[i]);
		ll tmp = A[i];

		for(int k = 0; PRIME[k]*PRIME[k] <= A[i]; k++){

			if(tmp%PRIME[k] != 0)continue;

			ll count = 0;

			while(tmp > 0 && tmp%PRIME[k] == 0){
				count++;
				tmp /= PRIME[k];
			}
			table[k] = max(table[k],count);

		}
		if(is_prime[tmp]){

			table[MAP[tmp]] = max(table[MAP[tmp]],1LL);
		}
	}

	ll base = 1;
	for(int i = 0; i < PRIME.size(); i++){

		base *= mod_pow(PRIME[i],table[i],MOD);
		base %= MOD;
	}

	ll ans = 0;

	for(int i = 0; i < N; i++){

		ll tmp = base*mod_inverse(A[i],MOD);
		tmp %= MOD;

		ans += tmp;
		ans %= MOD;
	}

	printf("%lld\n",ans);

	return 0;
}


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



int main(){
  int X;
  cin>>X;
  int yor=0;
  if(X>=500){
    yor+=(X/500)*1000;
    X=X%500;
  }
  
  if(X>=5){
    yor+=(X/5)*5;
    X=X%5;


  }
  cout<<yor<<endl;
      
    
}

Measured memory_bytes: 256
def gcd(x,y):
    r=x%y
    if r==0:
        return y
    else:
        return gcd(y,r)
x,y=map(int, input().split())
if x>y:
    r=gcd(x,y)
if x==y:
    r=x
if x<y:
    r=gcd(y,x);
print(r)



Measured memory_bytes: 5596
#include <iostream>
#include <iomanip>
#include <math.h>
#include <string>
#include <algorithm>
#include <ctype.h>
#include <vector>
#include <numeric>
#include <map>
#include <queue>
#include <deque>
#include <bitset>
using namespace std;

#define ll long long int
#define rep(i, a, n) for (int i = a; i < n; i++)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vii vector<vector<int>>
#define vll vector<ll>
#define vllll vector<vector<ll>>
#define ALL(a) (a).begin(), (a).end()
#define sort_v(a) sort(a.begin(), a.end())
#define fi first
#define se second

void print(bool c)
{
    if (c)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

void Print(bool c)
{
    if (c)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}

ll gcdll(ll a, ll b)
{
    while (1)
    {
        if (a < b)
            swap(a, b);
        if (b == 0)
            break;
        a %= b;
    }
    return a;
}

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

bool cmp(const pii &a, const pii &b)
{
    if (a.second != b.second)
        return a.second < b.second;
    return a.first < b.first;
}

int n;
pair<double, double> xy[10];
bool pass[8];

double calc(int a, int b)
{
    return sqrt(pow((xy[a].fi - xy[b].fi), 2) + pow((xy[a].se - xy[b].se), 2));
}

int main()
{
    string s, t;
    cin >> s >> t;
    int cnt = 0;
    for (int i = 0; i < 3; i++)
    {
        if (s[i] == t[i])
            cnt++;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    if ((s[0] == s[1]) && (s[2] == s[3]) && (s[0]!= s[2])){
        cout << "Yes\n";
    }
    else{
        cout << "No\n";
    }
}


Measured memory_bytes: 256
n,k=map(int, input().split())
x,neg,pos=[],[],[]
for i in input().split():
	i = int(i)
	x.append(i)
	if i < 0:
		neg.append(i)
	else:
		pos.append(i)
neg.reverse()

ans=[]

if len(neg) >= k:
	ans.append(-neg[k-1])
if len(pos) >= k:
	ans.append(pos[k-1])

for i in range(1, k):
	j = k - i
	if i > len(neg) or j > len(pos):
		continue
	ans.append(pos[j-1] - neg[i-1] + min(pos[j-1], -neg[i-1]))

print(min(ans))


Measured memory_bytes: 16176
N,M=map(int,input().split())
P=[input().split() for i in range(M)]

WA=[]
AC=[]
for i in range(N):
    WA.append(0)
    AC.append(0)

for i in range(M):
    if P[i][1]=="WA" and  AC[int(P[i][0])-1]==0:
        WA[int(P[i][0])-1]+=1
    elif P[i][1]=="AC":
        AC[int(P[i][0])-1]=1
for i in range(N):
    if AC[i]==0:
        WA[i]=0

print(sum(AC),sum(WA))

Measured memory_bytes: 79448
#include <string>
#include <algorithm>
#include <vector> 
#include <math.h>
#include <iostream>
using namespace std;
long long mod = 1000000000 + 7;



int main()
{
	int n;
	cin >> n;
	vector<long long> a;
	int flag = 1;
	long long m = 9999999999;
	for (int i = 0; i < n; i++) {
		long long in;
		
		cin >> in;
		if (in < 0) {
			flag = flag * (-1);
			in = in * (-1);
			
		}
		m = min(m, in);
		a.push_back(in);
	}
	long long ans = 0;
	if (flag == 1) {
		for (int i = 0; i < n; i++) {
			ans += a[i];
		}
	}
	else {
		for (int i = 0; i < n; i++) {
			ans += a[i];
		}
		ans = ans - 2 * m;
	}

	cout << ans << endl;
	return 0;

}

Measured memory_bytes: 1400
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <utility>
#include <numeric>
#include <deque>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <limits>
#include <cassert>
#include <bitset>
#include <list>
#include <iomanip>
#include <cctype>

#define for0(i, N)    for (long long i = 0  ; i <  (N); ++i)
#define for1n(i, N)   for (long long i = 1  ; i <= (N); ++i)
#define for1(i, N)    for (long long i = 1  ; i <  (N); ++i)
#define forn(i, N)    for (long long i = 0  ; i <= (N); ++i)
#define forx(i, N, x) for (long long i = (x); i <  (N); ++i)
#define forl(i, N, x, a) for (long long i = (x), a = 0; a < (N);    \
                              i = (i + 1) % (N), ++a)
#define int long long

template<size_t i>
std::bitset<i> operator++(std::bitset<i> b, signed){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    return b = (unsigned long long)b + 1;
}

template<size_t i>
std::bitset<i> operator++(std::bitset<i> b){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    auto temp = b;
    b++;
    return temp;
}

template<size_t i>
std::bitset<i> operator--(std::bitset<i> b, signed){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    return b = (unsigned long long)b - 1;
}

template<size_t i>
std::bitset<i> operator--(std::bitset<i> b){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    auto temp = b;
    b--;
    return temp;
}

long long constexpr inf = std::numeric_limits<long long>::max();

using namespace std;

typedef long long ll;
typedef long double ld;
typedef priority_queue<ll> pq;
typedef priority_queue<ll,vector<ll>, greater<ll>> pql;
typedef stack<ll> stk;
typedef queue<ll> qu;
typedef pair<ll, ll> pll;
typedef map<ll, ll> mll;
typedef unordered_map<ll, ll> umll;
typedef set<ll> sll;
typedef unordered_set<ll> usll;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<vector<ll>> vvll;


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

    string s;
    cin >> s;

    cout << (s[2] == s[3] && s[4] == s[5] ? "Yes" : "No") << "\n";

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int MOD = 1000 * 1000 * 1000 + 7;
const int C = 26;
int mod(int n) {
    return (n % MOD + MOD) % MOD;
}   
int cnt[C];
signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif
    int n;
    cin >> n;
    string s;
    cin >> s;
    for (char c : s) ++cnt[c - 'a'];
    int ans = 1;
    for (int i = 0; i < C; ++i) ans = mod(ans * (cnt[i] + 1));
    cout << mod(ans - 1) << '\n';
}   

Measured memory_bytes: 512
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<cstdlib>
#include<cmath>

using namespace std;

#define MAX_V 100001
#define INF (1e9 + 1)
#define REP(i,n) for(long long int (i)=0;(i) < (n);(i)++)
#define REV(i,n) for(long long int (i)=(n-1);(i) > -1;(i)--)

int N,M;
int a[1001];

void solve(){
  int mx = -1;
  REP(i,N){
    for(int j=i+1;j<N;j++){
      if(a[i]+a[j]<=M && a[i]+a[j]>mx) mx = a[i]+a[j];
    }
  }
  if(mx==-1) cout << "NONE" << endl;
  else cout << mx << endl;
}

int main(){
  while(true){
    scanf("%d %d",&N,&M);
    if(N==0&&M==0)break;
    REP(i,N) cin >> a[i];
    solve();
  }

  return 0;
}


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

struct str {
    int n, m;
    vector<vector<int> > a, s;

    str(int _n, int _m, vector<vector<int> > _a) {
        a = _a;
        n = _n;
        m = _m;
        s.assign(n + 1, vector<int>(m + 1, 0));
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= m; j++) {
                s[i][j] = s[i - 1][j] + s[i][j - 1] - s[i - 1][j - 1] + a[i - 1][j - 1];
            }
        }
    }

    int sum(int i1, int i2, int j1, int j2) {
        int ans = 0;
        ans += s[i2 + 1][j2 + 1];
        ans -= s[i1][j2 + 1];
        ans -= s[i2 + 1][j1];
        ans += s[i1][j1];
        return ans;
    }
};

int main() {
#ifdef HOME
    assert(freopen("in", "r", stdin));
#endif


    int n, m, q;
    while (scanf("%d%d%d", &n, &m, &q) == 3) {
        vector<vector<int> > a(n, vector<int>(m));
        for (int i = 0; i < n; i++) {
            scanf("\n");
            for (int j = 0; j < m; j++) {
                char c;
                scanf("%c", &c);
                a[i][j] = c - '0';
            }
        }

        vector<vector<int> > hor(n, vector<int>(m - 1));
        vector<vector<int> > ver(n - 1, vector<int>(m));
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                if (i + 1 < n) ver[i][j] = a[i][j] + a[i + 1][j] == 2;
                if (j + 1 < m) hor[i][j] = a[i][j] + a[i][j + 1] == 2;
            }
        }
        str shor(n, m - 1, hor), sver(n - 1, m, ver), sall(n, m, a);
        for (int i = 0; i < q; i++) {
            int i1, j1, i2, j2;
            scanf("%d%d%d%d", &i1, &j1, &i2, &j2);
            i1--; j1--; i2--; j2--;
            printf("%d\n", sall.sum(i1, i2, j1, j2) - shor.sum(i1, i2, j1, j2 - 1) - sver.sum(i1, i2 - 1, j1, j2));
        }
    }


#ifdef HOME
    cerr << "time: " << clock() * 1.0 / CLOCKS_PER_SEC << endl;
#endif
    return 0;
}



Measured memory_bytes: 159360
#include <stdio.h>
#include <string.h>
int main()
{
    char s[10001];
    char alfa[26];

    int i,j;   
    int n;

    scanf("%d %s",&n,s);

    int len = strlen(s);
    for (i = 0; i < len; i++)
    {
        printf("%c",(s[i] - 'A' + n) % 26 + 'A');
    }
    
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;

int main() {
    vector<vector<int>> C(3, vector<int> (3));
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> C.at(i).at(j);
        }
    }
    for (int i = 0; i < 2; i++) {
        for (int j = i + 1; j < 3; j++) {
            for (int k = 0; k < 2; k++) {
                for (int l = k + 1; l < 3; l++) {
                    if (C.at(i).at(k) - C.at(j).at(k) != C.at(i).at(l) - C.at(j).at(l)) {
                        cout << "No" << endl;
                        return 0;
                    }
                }
            }
        }
    } 
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
var input = ""
process.stdin.resume();
process.stdin.setEncoding('utf-8');
process.stdin.on('data', function(chunk) {
  input += chunk;
});
 
process.stdin.on('end', function() {
  input = input.split("\n");

  var i = 0;
  while (input[i] != 0) {
    i++;
    s = input[i++].split(" ")
    
    var sum = 0;
    for (j = 0; j < s.length; j++) {
      sum += parseInt(s[j], 10);
    }
    average = sum / s.length;

    var x = 0;
    for (j = 0; j < s.length; j++) {
      x += Math.pow((s[j] - average), 2);
    }
    console.log(Math.sqrt(x / s.length));
  }
});

Measured memory_bytes: 17116
import numpy as np
A  = []
for i in range(3):
    A.append(list(map(int, input().split())))
A = np.array(A)

N = int(input())
B = []
for j in range(N):
    B.append(int(input()))

res = np.array([int(i in B) for i in A.ravel()]).reshape(3, 3)
diag_sum = res[0, 0] + res[1, 1] + res[2, 2]
diag_sum2 = res[0, 2] + res[1, 1] + res[2, 0]
if (res.sum(axis=0) == 3).any() or (res.sum(axis=1) == 3).any() or diag_sum == 3 or diag_sum2 == 3:
    print('Yes')
else:
    print('No')




Measured memory_bytes: 12492
/*
    -ensure correct output format
    -ensure printing required output
    -reread the problem statement
  */

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define F first
#define S second
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>
#define pb push_back
#define eb emplace_back
#define ischar(x)  (('a' <= x && x <= 'z') || ('A' <= x && x <= 'Z'))
#define isvowel(ch) ((ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')||(ch=='A'|| ch=='E' || ch=='I'|| ch=='O'|| ch=='U'))
#define bug cout<<"BUG"<<endl;
const int Max = 2e6 + 10;
const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;
bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
       return (a.first > b.first);
}
ll lcm(ll a,ll b)
{
    if(a==0 || b==0)return 0;

    return a/__gcd(a,b)*b;
}

void input(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)cin>>ara[i];
}
void print(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)
        cout<<ara[i]<<" ";
    cout<<endl;
}


int main()
{

   fastread();

   ll i,j,n,m,p,a,sum=0,k,t,b,c,d,cnt=0,q,l,r,ans=0;

      bool flag=false;

      string str;


      cin>>a>>b>>c>>d;

      sum=a*c;

      sum=max(sum,a*d);

      sum=max(sum,b*c);

      sum=max(sum,b*d);

      cout<<sum<<endl;














}



Measured memory_bytes: 3652
dx = [1, 0, -1, 0, 1, -1, -1, 1]
dy = [0, 1, 0, -1, 1, 1, -1, -1]

# 入力
H, W = map(int, input().split())
S = [input() for _ in range(H)]

# 各マス (i, j) について順に処理
for i in range(H):
    for j in range(W):
        if S[i][j] != '.':
            continue
        counter = 0
        for d in range(8):
            ni = i + dx[d]
            nj = j + dy[d]
            if ni < 0 or ni >= H or nj < 0 or nj >= W:
                continue
            if S[ni][nj] == '#':
                counter += 1
        S[i] = S[i].replace('.', str(counter), 1)

for row in S:
    print(row)

Measured memory_bytes: 9236
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
using namespace std;
const ll mod = 1000000007;
int main(){
    int N,K; cin >> N >> K;
    ll com[2006][2006];
    memset(com, 0, sizeof(com));
    com[0][0] = 1;
    for(int i = 1; i<2006; i++){
        com[i][0] = 1;
        for(int j = 1; j<2006; j++){
            com[i][j] = com[i-1][j-1] + com[i-1][j];
            com[i][j] %= mod;
        }
    }

    for(int i = 1; i<=K; i++) {
        ll ans = com[N-K+1][i]*com[K-1][i-1];
        ans %= mod;
        cout << ans <<endl;
    }
}


Measured memory_bytes: 31744
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
	int n,m; cin>>n>>m;
	VL x(n),y(n),z(n); rep(i,n) cin>>x[i]>>y[i]>>z[i];
	ll ans=0L;
	rep(i,1<<3){
		ll tmp = 0;
		VL score(n,0);
		rep(j,n){
			int bit=i;
			score[j]+=x[j]*pow(-1,bit%2);
			bit/=2;
			score[j]+=y[j]*pow(-1,bit%2);
			bit/=2;
			score[j]+=z[j]*pow(-1,bit%2);
		}
		sort(RALL(score));
		rep(j,m) tmp+=score[j];
		chmax(ans,tmp);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll n=5,k,i;
    ll arr[n];
    for(i=0;i<n;i++)
        cin>>arr[i];
    sort(arr,arr+n);
    cin>>k;
    if((arr[4]-arr[0])>k)
        cout<<":("<<endl;
    else
        cout<<"Yay!"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <climits>
//#include "h.h"
using namespace std;

#define MOD1097 1000000007

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mp make_pair
#define pm(first, second) pb(mp(first, second))
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(X) (X).begin(), (X).end()

int main(){

	int W, H, x, y;
	cin >> W >> H >> x >> y;
	printf("%0.12lf ", (double)W * (double)H / 2.0);
	if(W == x * 2 && H == y * 2)printf("1\n");
	else printf("0\n");

//"Hiroakimm0415"

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
 
using namespace std;
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }



int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(10);
	cout << fixed;
  
	int n;
	cin >> n;
	vector<int> v;
	for(int i = 0; i < n; i++)v.push_back(i);
	for(int i = 0; i < (1 << n); i++){
		vector<int> now;
		for(int j = 0; j < n; j++){
			if(i & (1 << j))now.push_back(v[j]);
		}
		cout << i << ':';
		for(auto j:now)cout << ' ' << j;
		cout << '\n';
	}
    return 0;
}



Measured memory_bytes: 3160
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    string s;
    cin >> s;
    ll n = s.size();

    vector<char> v;
    rep(i, n) {
        if(i < n-1 && s[i] == 'B' && s[i+1] == 'C') {
            v.pb('D');
            i++;
        }
        else {
            v.pb(s[i]);
        }
    }

    ll ans = 0;
    ll cnt = 0;
    for(auto c : v) {
        if(c == 'A') {
            cnt++;
        }
        else if(c == 'D') {
            ans += cnt;
        }
        else {
            cnt = 0;
        }
    }

    out(ans);
    re0;
}

Measured memory_bytes: 772
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define UNIQUE(v) { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); }
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) (q ? "Yes" : "No")
#define YES(q) (q ? "YES" : "NO")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) { cerr << "[DEBUG] " #q ": ["; REP(dumpall_i, (q).size()) { cerr << q[dumpall_i] << (dumpall_i == (q).size() - 1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; }
template<class T> T gcd(const T &a, const T &b) { return a < b ? gcd(b, a) : b ? gcd(b, a % b) : a; }
template<class T> T lcm(const T &a, const T &b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
using  ll = long long;
using ull = unsigned long long;
using  ld = long double;
using namespace std;

// モジュール


// 処理内容
int main() {

    constexpr ll p = 1000000007;
    
    ll n, m; cin >> n >> m;
    vector<ll> s(n), t(m);
    REP(i, n) cin >> s[i];
    REP(i, m) cin >> t[i];

    vector<vector<ll>> dp(n+1, vector<ll>(m+1, 0));
    // dp[0][0] = 1;
    REP(i, n+1) dp[i][0] = 1;
    REP(i, m+1) dp[0][i] = 1;
    RANGE(i, 1, n) RANGE(j, 1, m) {
        dp[i][j] = (dp[i][j-1] + dp[i-1][j] % p + (p - dp[i-1][j-1])) % p;
        if (s[i-1] == t[j-1]) {
            dp[i][j] += dp[i-1][j-1];
            dp[i][j] %= p;
        }
    }
    cout << dp[n][m] << endl;
    
}

Measured memory_bytes: 31616
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m); (i) > (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define R cin>>
#define i64 unsigned long long
#define repr(i, n) REPR(i, n, 0)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define in(a) insert(a)
#define P(p) cout<<(p)<<endl;
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SORT(a) sort((a).begin(), (a).end())
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long int> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll mod = 1e9+7;
//const ll MOD = 998244353;
const ld PI = acos(-1);
const ld EPS = 1e-11;
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
template<typename T> void co(T e){cout << e << "\n";}
template<typename T> void co(const vector<T>& v){for(const auto& e : v)
    { cout << e << " "; } cout << "\n";}
ll gcd(ll a, ll b) {
    if (a < b)swap(a, b);
    if (b == 0) return a;
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}
ll lcm(ll a, ll b) {
    ll g = gcd(a, b);
    return a * b / g;
}
bool prime(ll n) {
    for (ll i = 2; i <= sqrt(n); i++) {
        if (n%i == 0)return false;
    }
    return n != 1;
}


int pow(ll x, ll y, ll mod){
    ll ret=1;
    for(;y;y>>=1,x=1ll*x*x%mod){
        if(y&1) ret=1ll*ret*x%mod;
    }
    return ret;
}
void kill()
{
    cout << -1 << endl;
    exit(0);
}

int main() {
    sonic();
    int n;
    int next, prev, total, i, t;
    R n;
    i64 ans = 0;
    priority_queue<pii> q;
    vi A(n), B(n);
    rep(i, n)R A[i];
    rep(i, n){
        R B[i];
        q.push(make_pair(B[i], i));
    }
    while(0<q.size()) {
        i = q.top().second;
        q.pop();
        if(B[i]==A[i])continue;
        if(B[i]<A[i])kill();
        next = (i + 1 + n) % n;
        prev = (n + i - 1) % n;
        total = B[next] + B[prev];
        t = (B[i] - A[i]) / total;
        if(t==0)kill();
        ans += t;
        B[i] -= t * total;
        q.push(make_pair(B[i], i));
    }
    cout << ans << endl;
}


Measured memory_bytes: 6880
#include <bits/stdc++.h>
using namespace std;
int n,t,sol;
int main()
{
    ios::sync_with_stdio(false);
    cin>>n>>t;
    sol=n/(t+t+1);
    if(sol*(t+t+1)!=n) ++sol;
    cout<<sol;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int fib(int);

int main()
{
  int n;
  scanf("%d",&n);
  
  printf("%d\n",fib(n));
}

int fib(int n)
{
  int F[45],i;
  for(i=0;i<45;i++)
    {
      if(i==0 || i==1)F[i]=1;
      else F[i]=F[i-1]+F[i-2];
      if(i==n)break;
    }
  return F[n];
}



Measured memory_bytes: 2112
N = gets.to_i
Ws = Array.new(N) { gets.chomp }
hash = {}
flag = "Yes"
first = Ws.slice!(0)
hash[first] = true
tmp = first[first.length - 1]
Ws.each {|c|
    if (hash[c] != true) && (c[0] == tmp)
        hash[c] = true
        tmp = c[c.length - 1]
    else
        flag = "No"
        break;
    end
}

puts flag


Measured memory_bytes: 1788
// https://atcoder.jp/contests/

#include <bits/stdc++.h>
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for (int(i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for (int(i) = (m); (i) < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

string s, r, c[] = {"maerd", "remaerd", "esare", "resare"};
int l[] = {5, 7, 5, 6};

bool cut(string &s)
{
  bool r = false;
  REP(i, 4)
  {
    if (s.substr(0, l[i]) == c[i])
    {
      s = s.substr(l[i]);
      r = true;
    }
  }
  return r;
}

int main()
{
  cin >> s;
  reverse(ALL(s));

  while (0 < s.length())
    if (!cut(s))
      break;

  r = s.length() == 0 ? "YES" : "NO";

  cout << r << '\n';

  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define INF 1000000007
int u[1100000];
vector<int> y;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b,c,d=0,e=0,f=0,g=0;
  cin >>a;
  if(a<1200) cout <<"ABC\n";
  else{
    if(a<2800) cout <<"ARC\n";
    else cout <<"AGC\n";
  }
  return (0);
}


Measured memory_bytes: 256