akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

const ll mod = 1000000007;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

struct combination {
  std::vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

ll X, Y;
combination comb( 1000010 );

int main()
{
  std::cin >> X >> Y;

  if( (X+Y) % 3 )
  {
    std::cout << 0 << std::endl;

    return 0;
  }

  ll N = (X+Y)/3;

  std::cout << comb( N, Y-N ).x << std::endl;

  return 0;
}

Measured memory_bytes: 15872
from collections import deque
S=input()
d=deque(S)
rev=False
Q=int(input())
for i in range(Q):
    Que=input().split()
    if(Que[0]=='1'):
        rev=not rev
    else:
        if(Que[1]=='1'):
            if(not rev):
                d.appendleft(Que[2])
            else:
                d.append(Que[2])
        else:
            if(not rev):
                d.append(Que[2])
            else:
                d.appendleft(Que[2])
d=d if not rev else reversed(d)
print(*d,sep='')


Measured memory_bytes: 12272
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdlib>
using namespace std;
 
//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//infinity
#define INTINF 2000000000
#define LONGINF 20000000000
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

long long POW(int a, int b){
	long long ret = 1;
	REP(i, b)ret *= a;
	return ret;
}

int main(){
	long long n; cin >> n;
	if(n == 0){
		cout << 0 << endl;
		return 0;
	}
	
	long long sum = n;
	long long pt = 0;
	while(true){
		if(sum == 0)break;
		if(sum > 0){
			long long t = 0;
			int i = 0;
			for(;;i+=2){
				t += POW(-2, i);
				if(t >= sum) {
					sum -= POW(-2, i);
					REP(j, pt - i - 1)
						cout << 0;
					pt = i;
					cout << 1;
					break;
				}
			}
		}else{
			long long t = 0;
			int i = 1;
			for(;;i+=2){
				t += POW(-2, i);
				if(t <= sum) {
					sum -= POW(-2, i);
					REP(j, pt - i - 1)
						cout << 0;
					pt = i;
					cout << 1;
					break;
				}
			}
			if(i > pt)continue;
			REP(j, pt - i)
				cout << 0;
		}
	}
	REP(j, pt)
		cout << 0;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>  
using namespace std;  
int main() { 	
	char a,b,c;
	int d=700;
	scanf("%c%c%c", &a, &b, &c);
	if(a=='o'){
		d+=100;
	}
	else{
		d+=0;
	}
	if(b=='o'){
		d+=100;
	}
	else{
		d+=0;
	}
	if(c=='o'){
		d+=100;
	}
	else{
		d+=0;
	}
	printf("%d", d);

}






Measured memory_bytes: 128
#include <stdio.h>

int main(void){

  int x,y,s,f,i,j,a,b;

  for(;;){
    
    scanf("%d %d %d",&x,&y,&s);
    if(x==0&&y==0&&s==0)break;
    int max=0;
    for(i=1;i<=s/2;i++){
      for(j=i;j<=s;j++){
        a=i*(100+x)/100;
        b=j*(100+x)/100;
        f = i*(100+y)/100 + j*(100+y)/100;
        if(a+b==s&&max<f)
          max=f;
      }
    }

    printf("%d\n",max);

  }

  return 0;
}

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

int main(){
    map<string, ll, std::less<>> mp;
    ll q, c, x;
    string s, l;
    cin >> q;
    rep(i, q){
        cin >> c >> s;
        auto t = mp.find(s);
        switch(c){
            case 0:
                cin >> x;
                if(t == mp.end()){
                    mp.insert(make_pair(s, x));
                }else{
                    t->second = x;
                }
                break;
            case 1:
                cout << (t == mp.end() ? 0 : t->second) << endl;
                break;
            case 2:
                if(t != mp.end()){
                    mp.erase(t);
                }
                break;
            case 3:
                cin >> l;
                for(auto i = mp.lower_bound(s); i!= mp.upper_bound(l); i++){
                    cout << i->first << " " << i->second << endl;
                }
                break;
        }
    }
    return 0;
}


Measured memory_bytes: 27708
#include <algorithm>
#include <functional>
#include <cmath>
#include <vector>
#include <set>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cstring>
#include <map>
#include <queue>
using namespace std;


int main()
{
	int n;
	cin >> n;
	cout << 1LL * n*(n + 1) / 2 - n;

}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <map>
#include <numeric>
#include <algorithm>

const int N = 200000 + 10;

int n, a[N], b[N];
int sorted[N], tot;

int anc[N];

int find(int x) { return anc[x] == x ? x : (anc[x] = find(anc[x])); }

bool init() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]), a[0] ^= a[i];
  for (int i = 1; i <= n; ++i) scanf("%d", &b[i]), b[0] ^= b[i];
  std::map<int, int> cnt;
  for (int i = 0; i <= n; ++i) ++cnt[a[i]], --cnt[b[i]];
  for (auto it : cnt) if (it.second) return false;
  tot = 0;
  for (int i = 1; i <= n; ++i) if (a[i] != b[i]) sorted[++tot] = a[i], sorted[++tot] = b[i];
  std::sort(sorted + 1, sorted + tot + 1);
  tot = std::unique(sorted + 1, sorted + tot + 1) - sorted - 1;
  auto f = [&] (int x) { return std::lower_bound(sorted + 1, sorted + tot + 1, x) - sorted; };
  for (int i = 1; i <= n; ++i) if (a[i] != b[i]) a[i] = f(a[i]), b[i] = f(b[i]);
  return true;
}

int main() {
  if (!init()) {
    puts("-1");
    return 0;
  }
  std::iota(anc, anc + tot + 1, 0);
  int ans = tot;
  for (int i = 1; i <= n; ++i) if (a[i] != b[i] && find(a[i]) != find(b[i])) anc[find(a[i])] = find(b[i]), --ans;
  for (int i = 1; i <= n; ++i) ans += (a[i] != b[i]);
  int p = std::lower_bound(sorted + 1, sorted + tot + 1, a[0]) - sorted;
  ans -= (0 < p && p <= tot && sorted[p] == a[0]);
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 8448
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

const int infI=1e9+5;
const long long infL=1e16;
const int MOD=1e9+7;
const int MAX=1e7+5;

#define mp make_pair
#define in &
#define pb push_back
#define ii pair<int,int>
#define iii pair<ii,int>
#define ll long long
#define pll pair<ll,ll>
#define vvl vector<vector<ll> >
#define vi vector<int>
#define vvi vector<vector<int> >
#define vl vector<ll>
#define eb emplace_back
#define forn(i,a,b) for(ll i=a;i<b;i++)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define endl '\n'
#define popb pop_back()
#define se second
#define fi first
#define test(t) int t;cin>>t;while(t--)
#define debug(x) cerr<<"=>"<<#x<<" = "<<x<<endl

ll power(ll a,ll b){
    if(b==0){
        return 1;
    }
    if(b==1){
        return a;
    }
    ll temp=power(a,b/2);
    temp=(temp*temp)%MOD;
    if(b%2){
        temp=(temp*a)%MOD;
    }
    return temp;
}

//only use if mod is prime
ll mod_inv(ll a,ll mod){
    a%=mod;
    return power(a,mod-2);
}

void extended_gcd(ll a,ll b,ll &x,ll &y){
    if(b==0){
        x=1;
        y=0;
        return;
    }
    ll x1,y1;
    extended_gcd(b,a%b,x1,y1);
    x=y1;
    y=x1-((a/b)*y1);
    return;
}

//TLE can also occur if vectors are not passed by reference
//priority_queue implements max heap by default

int f[MAX];

void init(){
    for(ll i = 2;i<MAX;i++){
        for(ll j = i;j<MAX;j+=i){
            ++f[j];
        }
    }
}

int main(){
    fastio;
    // think about edge cases like n=1,n=MAX etc.
    int n;
    cin>>n;
    init();
    ll ans = 0;
    forn(i,1,n+1){
        ans += (i*(f[i]+1));
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 42720
#include<iostream>
using namespace std;
int main(){
  int a[100];
int n,m;
  cin>>n>>m;
for(int i=0;i<n;i++){
	a[i]=0;
}
  for(int i=0;i<m;i++){
   int d;cin>>d;
    for(int k=0;k<d;k++){
    	int o;cin>>o;o--;
      a[o]++;
    }
  }
 int ans=0;
  for(int i=0;i<n;i++){
	if(a[i]==0){ans++;}
}
  cout<<ans<<endl;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

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

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

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

    ll N;
    cin >> N;
    vector<ll> a(N);
    REP(i, N) cin >> a[i];

    ll jud = 0;
    REP(i, N) jud ^= a[i];
    cout << (jud == 0 ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#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, n, m) for (int i = m; i < n; i++)
#define MM(i, n, m) for (int i = m; i <= n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

typedef long long ll;

/**
 * C問以降は ll を使う.
 * double型にするのを忘れない.
 * nC2の求め方 (1/2)*n*(n-1)
 * vector<型> 変数名(要素数, 初期値)
 * pair<型, 型> 変数名
 * map<型, 型> 変数名  // 連想配列
 * priority_queue<型> 変数名  // 最大値から出てくるヒープ
*/
int main()
{
    int a, b, x;
    cin >> a >> b >> x;
    if(a > x) {
        cout << "NO" << endl;
    } else if(a+b < x) {
        cout << "NO" << endl;
    } else {
        cout << "YES" << endl;
    }
    return 0;
}

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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

void solve() {
  int a, b; scanf("%d%d", &a, &b);
  printf("%d", a*b);
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 3824
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

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 a[6], b[6];
int cnt[6];

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

  int n;
  REP(i, 3){
    cin >> a[i] >> b[i];
    cnt[a[i]]++;
    cnt[b[i]]++;
  }

  bool f = false;
  FOR(i, 1, 5){
    if(cnt[i] == 3) f = true;
  }
  if(f) cout << "NO" << endl;
  else cout << "YES" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
 
int main(){
    int N,T,x,y;
    scanf("%d%d",&N,&T);
    vector<int>v(T+1);
    for(;N--;){
        scanf("%d%d",&x,&y);
        v[x+1]++,v[y+1]--;
    }
    for(x=y=0;x<T;x++)y=max(y,v[x+1]+=v[x]);
    printf("%d\n",y);
}


Measured memory_bytes: 2744
#include<stdio.h>
int main()
{
    int c[3][3];
    int d;
    int i, j;
    for (i = 0; i < 3; i++)
    {
        for (j = 0; j < 3; j++)
            scanf("%d", &c[i][j]);
    }
    for (i = 0; i < 2; i++)
    {
        d = c[i][0] - c[i + 1][0];
        for (j = 1; j < 3; j++)
        {
            if ((c[i][j] - c[i + 1][j]) != d)
            {
                printf("No\n");
                return 0;
            }
        }
    }
    for (j = 0; j < 2; j++)
    {
        d = c[0][j] - c[0][j + 1];
        for (i = 1; i < 3; i++)
        {
            if ((c[i][j] - c[i][j + 1]) != d)
            {
                printf("No\n");
                return 0;
            }
        }
    }
    printf("Yes\n");
    return 0;

}

Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import static java.lang.Integer.parseInt;

/**
 * A Way to Invite Friends
 */
public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] words;

		int N = parseInt(br.readLine());
		int[] friends = new int[100_003];

		for (int i = 0; i < N; i++) {
			line = br.readLine();
			int a, b;
			a = parseInt(line.substring(0, line.indexOf(' ')));
			b = parseInt(line.substring(line.indexOf(' ') + 1));
			friends[a]++;
			friends[b + 1]--;
		}

		int max = 0;
		for (int i = 1; i <= N + 1; i++) {
			friends[i] += friends[i - 1];
			if (i <= friends[i] + 1 && friends[i] <= N + 1) {
				max = i;
			}
		}
		System.out.println(max - 1);
	}
}

Measured memory_bytes: 47928
N,A,B = map(int,input().split())
S = list(input())
ans = []
nums = [0,0]
for s in S:
    if s == 'a':
        if nums[0] < A+B:
            ans.append('Yes')
            nums[0] += 1
        else:
            ans.append('No')
    elif s == 'b':
        if nums[0] < A+B and nums[1] < B:
            ans.append('Yes')
            nums[0] += 1
            nums[1] += 1
        else:
            ans.append('No')
    else:
        ans.append('No')

print('\n'.join(ans))


Measured memory_bytes: 5928
//
//  main.cpp
//  zero
//
//  Created by 叶金炜 on 2019/4/2.
//  Copyright © 2019 okstal. All rights reserved.
//

#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#define pi acos(-1)
using namespace std;
int main() {
    int n,i;
    cin>>n;
    i=1;
    while (i<=n) {
        int x=i;
        if(x%3==0)cout << " " << i;
        else while(x)
        {
            if(x%10==3){cout << " " << i;break;}
            x/=10;
        }
        i++;
    }
    cout<<endl;
    return 0;
}



Measured memory_bytes: 3080
s=['','Man','Oku','Cho','Kei','Gai','Jo','Jou','Ko','Kan','Sei','Sai','Gok','Ggs','Asg','Nyt','Fks','Mts']
while 1:
    m,n=map(int,input().split())
    if m==0:break
    a=''
    for i in range(0,len(str(m**n)),4):
        b=m**n//(10**i)%10000
        if b:a=str(b)+s[i//4]+a
    print(a)

Measured memory_bytes: 7704
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoderBeginnerContest055
{
    class ProgramC

    {
        static void Main(string[] args)
        {
            string szLine = Console.ReadLine();
            string[] szArr = szLine.Split(' ');
            long s = long.Parse(szArr[0]);
            long c = long.Parse(szArr[1]);

            long max = 0;
            if (2 * s >= c)
            {
                max = c / 2;
            }
            else
            {
                // c多すぎ
                max = s;
                // いったんn 個作成
                c = c - 2 * s;


                // c*4 個あれば Sccになる
                max += c / 4;

            }
            Console.WriteLine(max);
        }
        
    }
}


Measured memory_bytes: 11092
#include <iostream>

using namespace std;

int GetDigit(int num){
    int digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}

int main()
{
	int n;
	cin >> n;
	int count = 0;
	for (int i = 1; i < n + 1; i++)
	{
		if(GetDigit(i) % 2 != 0) count++;
	}
	cout << count << endl;
}

Measured memory_bytes: 256
from sys import stdin


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    S, W = list(map(int,_in[0].split(' ')))  # type:list(int)
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    TF = 'unsafe' if W>=S else 'safe'
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(TF)



Measured memory_bytes: 61652
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <set>
#include <queue>
#include <map>
#include <numeric>
#include <functional>
#include <math.h>

using namespace std;

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

#define INF ((int)1e9)
#define INFLL ((ll)1e18)
#define MOD (1000000007LL)

class mod {
public:
    mod() {m_n = 0;}
    mod(ll n) {if (n >= 0) m_n = n % MOD; else m_n = n % MOD + MOD;}
    friend bool operator== (const mod& a, const mod& b) {return a.m_n == b.m_n;}
    friend bool operator!= (const mod& a, const mod& b) {return !(a == b);}
    friend mod operator+ (const mod& a, const mod& b) {return (a.m_n + b.m_n) % MOD;}
    friend mod& operator+= (mod& a, const mod& b) {return a = a + b;}
    friend mod operator- (const mod& a) {return -a.m_n;}
    friend mod operator- (const mod& a, const mod& b) {return (a.m_n + (-b.m_n)) % MOD;}
    friend mod& operator-= (mod& a, const mod& b) {return a = a - b;}
    friend mod operator* (const mod& a, const mod& b) {return (a.m_n * b.m_n) % MOD;}
    friend mod& operator*= (mod& a, const mod& b) {return a = a * b;}
    friend mod mod_pow(const mod& n, ll r) {
        if (r == 0) {
            return 1;
        } else if (r < 0) {
            return mod_pow(n, (MOD - 2) * (-r));
        } else if (r % 2 == 0) {
            mod tmp = mod_pow(n, r / 2);
            return tmp * tmp;
        } else {
            return n * mod_pow(n, r - 1);
        }
    }
    friend mod operator/ (const mod& a, const mod& b) {return a * mod_pow(b, -1);}
    friend mod& operator/= (mod& a, const mod& b) {return a = a / b;}
    friend ostream& operator<< (ostream& os, const mod& n) {os << n.m_n; return os;}
    friend istream& operator>> (istream& is, mod& n) {ll tmp; is >> tmp; n = mod(tmp); return is;}
private:
    ll m_n;
};

#define FACT_MAX 1000000
mod fact[FACT_MAX], fact_inv[FACT_MAX];
void prep_fact(int N)
{
    fact[0] = 1;
    for (int n = 1; n <= N; ++n) {
        fact[n] = n * fact[n-1];
    }
}
void prep_fact_inv(int N)
{
    for (int n = 0; n <= N; ++n) {
        fact_inv[n] = mod_pow(fact[n], -1);
    }
}
void prep(int N)
{
    prep_fact(N);
    prep_fact_inv(N);
}
mod comb(int n, int k) {if (n < 0 || k < 0 || k > n) return 0; else return fact[n] * fact_inv[n-k] * fact_inv[k];}
mod multi_choose(int n, int k) {return comb(n + k - 1, k);}

int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    prep(2*N);
    for (int i = 1; i <= K; ++i) {
        if (N-K < i-1) {
            cout << 0 << endl;
        } else  {
            mod b = multi_choose(i, K-i);
            mod r = multi_choose(i+1, N-K-i+1);
            cout << b * r << endl;
        }
    }

    return 0;
}


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

const int mod = (int)1e9+7;

template<typename T> struct combination {
    int MAX;
    vector<T> f;
    vector<vector<T>> dp;
    combination(int _n) {
        MAX = _n;
        f.resize(MAX + 1, 0);
        for (int i = 0; i <= MAX; i++) {
            if (i == 0) f[i] = 1;
            else f[i] = i * f[i-1] % mod;
        }
        dp.resize(MAX + 1, vector<T>(MAX + 1, 0));
    }
    T power(int m, int n) { // m^n
        if (n == 0) return 1;
        if (n % 2 == 1) return m * power(m, n-1) % mod;
        T r = power(m, n/2);
        return r * r % mod;
    }
    T inv(int a, int b) { // a / b % mod
        return a * power(b, mod-2) % mod;
    }
    T fact(int n) { // n!
        return f[n];
    }
    T perm(int n, int r) { // nPr
        if (n < r) return 0;
        return inv(fact(n), fact(n-r));
    }
    T comb(int n, int r) { // nCr
        if (n < r) return 0;
        return inv(perm(n, r), fact(r));
    }
    T pie(int n, int k) { // 包除原理
        T s = 0;
        for (int i = 0; i < k; i++) {
            s += power(-1, i) * comb(k, i) * power(k-i, n);
            s %= mod;
            if (s < 0) s += mod;
        }
        return s;
    }
    T part(int n, int k) { // 分割数
        if (n < 0) return 0;
        if (n == 0 || k == 1) return dp[n][k] = 1;
        if (dp[n][k] != 0) return dp[n][k];
        return dp[n][k] = (part(n, k-1) + part(n-k, k)) % mod;
    }
    T stir(int n, int k) { // スターリング数
        if (n < k || (n > 0 && k == 0)) return 0;
        if (n == k || k == 1) return dp[n][k] = 1;
        if (dp[n][k] != 0) return dp[n][k];
        return dp[n][k] = (stir(n-1, k-1) + k * stir(n-1, k)) % mod;
    }
    T bell(int n, int k) { // ベル数
        T s = 0;
        for (int i = 0; i <= k; i++) {
            s += stir(n, i);
            s %= mod;
        }
        return s;
    }
};

int main() {
    ll n;
    cin >> n;
    combination<ll> c(0);
    ll r = c.power(10, n) - 2LL * c.power(9, n) + c.power(8, n);
    r %= mod;
    if (r < 0) r += mod;
    cout << r << endl;
}

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

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

using ll = long long;

int main(){
	string s;
	cin>>s;
	s = 'A'+s;
	int ans = 0;
	reep(i,1,s.size()){
		if(s[i-1]>=s[i]) ans++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3164
#include<bits/stdc++.h>
using namespace std;
int cnt=0;
int x[200][200]={1};
int main()
{
	int a,b;
	cin>>a>>b;
	int c,d;
	cin>>c>>d;
	for(int i=0;i<c;i++)
	{
		for(int j=0;j<b;j++)
		{
			x[i][j]=2;
		}
	}
	for(int i=0;i<d;i++)
	{
		for(int j=0;j<a;j++)
		{
			x[j][i]=2;
		}
	}
	for(int i=0;i<a;i++)
	{
		for(int j=0;j<b;j++)
		{
			if(x[i][j]==0)cnt++;
		}
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stack>
#include <queue>
#include <cstdio>
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n0,n) for(int i=n0;i<n;i++)
#define Com(i,j,n) for(int i=0;i<n-1;i++)for(int j=i+1;j<n;j++)
const int INF =100100100;
const int MOD = (int)1e9+7;
const double EPS = 1e-9;
typedef long long ll;
typedef long li;
#define pb push_back 
#define mp make_pair

signed main (){	
	ll NN,mcount=0,ans=0,tmp=0,min=1000000000;
	cin >> NN ;
	rep(i,NN) {
		cin >> tmp;
        if(tmp < 0) { 
          mcount ++; 
          tmp = (-1) * tmp;
        }
		min = tmp > min ? min : tmp;
        ans += tmp;
	}
	if(mcount%2 == 1) ans = ans - 2 * min;
	cout << ans << endl;
	return 0;
}


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

//立っているbitの数を数える関数
int pcnt(int x) {
  return __builtin_popcount(x);
}

//f(x)を求める関数
int f(int x) {
  if (x == 0) return 0;
  return f(x%pcnt(x))+1;
}

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  vector<int> x(n);
  rep(i,n) x[i] = s[i]-'0';//配列xに、一要素に一桁ずつsを格納

  int pc = 0;//最初のxのポップカウント
  rep(i,n) pc += x[i];

  vector<int> ans(n);

  rep(b,2) {//ポップカウントが1増える場合と1減る場合について
    int npc = pc;
    if (b == 0) npc++; else npc--;
    if (npc <= 0) continue;

    int r0 = 0;//元の、割った余りを求める。2進数から受信数に直して余りを取っている（余りを取ることでオーバーフロー回避）
    rep(i,n) {
      r0 = (r0*2)%npc;
      r0 += x[i];
    }
    //i桁目をフリップした時の数の、割った余り(r)を求め
    //その時の答えを計算する
    int k = 1;
    for (int i = n-1; i >= 0; --i) {
      if (x[i] == b) {//xのビット1/0 が bと等しい時
        int r = r0;
        if (b == 0) r = (r+k)%npc;
        else r = (r-k+npc)%npc;//負の数の割り算に注意
        ans[i] = f(r)+1;
      }
      k = (k*2)%npc;
    }
  }

  rep(i,n) cout << ans[i] << endl;
  return 0;
}


Measured memory_bytes: 5252
import java.util.*;

public class Main{
    public static void main(String[] args){
        int h;
        int w;
        int i = 0;
        int j = 0;
        String n = System.getProperty("line.separator");
        Scanner scanner = new Scanner(System.in);
        while(true){
            h = scanner.nextInt();
            w = scanner.nextInt();
            if(h == 0 && w == 0) break;
            else{
                while(i < h){
                    while(j < w){
                        if(i == 0 || i == h-1 || j == 0 || j == w-1){
                            System.out.print("#");
                        }
                        else{
                            System.out.print(".");
                        }
                        j++;
                    }
                    j = 0;
                    System.out.print(n);
                    i++;
                }
                i = 0;
                System.out.print(n);
            }
        }
        scanner.close();
    }
}


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

#define REP(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 1
#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR
#endif


//改造
typedef long long int ll;
using namespace std;


//ここから編集する

int main() {
    int sx,sy,tx,ty;
    cin >> sx >> sy >> tx >> ty;
    int dx = tx - sx;
    int dy = ty - sy;
    REP(i,0,dx){
        cout << "R";
    }
    REP(i,0,dy){
        cout << "U";
    }
    REP(i,0,dx){
        cout << "L";
    }
    REP(i,0,dy){
        cout << "D";
    }
    REP(i,0,1){
        cout << "D";
    }

    REP(i,0,dx + 1){
        cout << "R";
    }
    REP(i,0,dy + 1){
        cout << "U";
    }
    REP(i,0,1){
        cout << "L";
    }
    REP(i,0,1){
        cout << "U";
    }
    REP(i,0,dx + 1){
        cout << "L";
    }
    REP(i,0,dy + 1){
        cout << "D";
    }
    REP(i,0,1){
        cout << "R";
    }
    return 0;
}


Measured memory_bytes: 256
// clang-format off

#include <bits/stdc++.h>

#define int long long int
#define main signed main()
#define bye return 0
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define each(p, v) for (auto p = (v).begin(); p != (v).end(); p++)
#define all(v) (v).begin(), (v).end()
#define prec(n) fixed << setprecision(n)
#define dump(x) cerr << "(L" << __LINE__ << ") " << #x << " = " << (x) << endl
#define clr(x, a) memset(x, a, sizeof(x))

#define sum(v) accumulate(all(v), 0)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define odd(n) ((n) % 2)
#define even(n) (!odd(n))

#define INF 1000000000
#define MOD 1000000007
#define PI acos(-1)

#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define vi vector<int>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>

using namespace std;

// clang-format on

main {
  int n, k;
  cin >> n >> k;
  rep(i, k) {
    int x, y;
    cin >> x >> y;
    cout << (x + y <= n ? min(x, y) + 2 : n - max(x, y)) % 3 + 1 << endl;
  }
  bye;
}

Measured memory_bytes: 3100
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

H, W, D = MAP()
A = [LIST() for _ in range(H)]

Q = INT()
LR = [LIST() for _ in range(Q)]

dic = [[] for _ in range(D)]

for i in range(H):
	for j in range(W):
		dic[A[i][j]%D].append([A[i][j], i, j])

for lis in dic:
	lis.sort(key=lambda x:x[0])

for lis in dic:
	lis[0][0] = 0
	for i in range(len(lis)):
		if i == len(lis)-1:
			break
		point = (lis[i][1], lis[i][2])
		dist_point = (lis[i+1][1], lis[i+1][2])
		lis[i+1][0] = lis[i][0] + abs(point[0]-dist_point[0]) + abs(point[1]-dist_point[1])

for L, R in LR:
	print(dic[R%D][ceil(R/D)-1][0]-dic[R%D][ceil(L/D)-1][0])


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

int main() {
  int X; cin >> X;
  int G = __gcd(360,X);
  cout << 360/G << endl;
}

Measured memory_bytes: 3652
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	
	static int n, m;
	static int[] h, w;
	
	private static int check(int sx, int sy)
	{
		int x = sx;
		int y = sy;
		int count = 0;
		int width = w[sx];
		int height = h[sy];
		
		while(true)
		{
			if(width == height)
			{
				count++;
				x++;
				if(x >= m) return count;
				width += w[x];
			}
			else if(width < height)
			{
				x++;
				if(x >= m) return count;
				width += w[x];
			}
			else
			{
				y++;
				if(y >= n) return count;
				height += h[y];
			}
		}
	}
	
	public static void main(String[] args)
	{
		
		Scanner sca = new Scanner(System.in);
		
		while(true)
		{
			n = sca.nextInt();
			m = sca.nextInt();
			if(n == 0) break;
			
			int i, j, k;
			
			h = new int[n];
			for(i = 0;i < n;i++) h[i] = sca.nextInt();
			
			w = new int[m];
			for(i = 0;i < m;i++) w[i] = sca.nextInt();
			
			int count = 0;
			int x, y;
			for(y = 0;y < n;y++)
			{
				for(x = 0;x < m;x++)
				{
					count += check(x, y);
				}
			}
			
			System.out.println(count);
		}
	}
}

Measured memory_bytes: 57432
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) REP(i, 0, n)
#define REP(i, s, e) for(int i = (int)(s); i < (int)(e); ++i)
#define repr(i, n) REP(i, n, 0)
#define REPR(i, s, e) for(int i = (int)(s-1); i >= (int)(e); --i)
#define all(X) (X).begin(), (X).end()
#define pb push_back

bool calc(vector<int>& v, int i, int n) {
  REP(j, 1, n+1) {
    v[(i+j)%n] -= j;
    if(v[(i+j)%n] < 0) return false;
  }
  return true;
}

// TLE version
int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  rep(i, n) cin >> v[i];
  ll sum = v[0];
  vector<int> d(n-1);
  rep(i, n-1) {
    d[i] = v[i+1]-v[i];
    sum += v[i+1];
  }
  ll m = (ll)n * (n+1) / 2LL;
  if(sum % m != 0) {
    cout << "NO" << endl;
    return 0;
  }
  ll k = sum / m;
  rep(i, n-1) {
    d[i] -= k;
    if(d[i] >0 || ((-d[i])%n)) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}


Measured memory_bytes: 1152
N, L = map(int, input().split())

# 途中で符号が変わる
tot = N * L + N * (N - 1) // 2
if (L + N - 1) * L <= 0:
    print(tot)
# ずっと負
elif L * N - 1 < 0:
    print(tot - (L + N - 1))
# ずっと正
else:
    print(tot - L)

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

int main(void) {
  ios::sync_with_stdio(false);
  int64_t N, K;
  cin >> N >> K;
  vector<int64_t> H(N);
  rep(i, N) { cin >> H[i]; }
  sort(H.begin(), H.end());
  int64_t answer = 0;
  for (int i = 0; i < N - K; ++i) {
    answer += H[i];
  }
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 1792
use proconio::input;

use rand::Rng;

struct State {
    c: Vec<i32>,
    s: Vec<Vec<i32>>,
    cur_seq: Vec<usize>,
    sat: i32,
}

impl State {
    fn init(&mut self) {
        let mut last = vec![0; 26];
        self.sat = 0;

        for i in 0..self.cur_seq.len() {
            self.sat += self.s[i][self.cur_seq[i]];
            last[self.cur_seq[i]] = (i + 1) as i32;

            for j in 0..26 {
                self.sat -= self.c[j] * ((i + 1 - last[j] as usize) as i32);
            }
        }
    }

    fn change(&mut self, d: usize, q: usize) {
        self.sat -= self.s[d][self.cur_seq[d]];
        self.sat += self.s[d][q];

        let mut last = vec![0; 26];
        for i in 0..self.cur_seq.len() {
            last[self.cur_seq[i]] = (i + 1) as i32;
            let j = self.cur_seq[d];
            self.sat += self.c[j] * ((i + 1 - last[j] as usize) as i32);
            self.sat += self.c[q] * ((i + 1 - last[q] as usize) as i32);
        }

        last = vec![0; 26];
        let p = self.cur_seq[d];
        self.cur_seq[d] = q;
        for i in 0..self.cur_seq.len() {
            last[self.cur_seq[i]] = (i + 1) as i32;

            self.sat -= self.c[p] * ((i + 1 - last[p] as usize) as i32);
            self.sat -= self.c[q] * ((i + 1 - last[q] as usize) as i32);
        }
    }
}

fn main() {
    input! {
        d: usize,
        c: [i32;26],
        s: [[i32;26]; d],
    }

    let mut state = State {
        c: c.to_owned(),
        s,
        cur_seq: vec![0; d],
        sat: 0,
    };

    let mut sorted_c: Vec<(usize, &i32)> = c.iter().enumerate().collect();
    sorted_c.sort_by_key(|k| -k.1);

    let mut rng = rand::thread_rng();
    for j in 0..d {
        state.cur_seq[j] = sorted_c[j % 13].0;
    }
    state.init();
    let mut cur_sat = state.sat;
    let mut cur_ans = state.cur_seq.to_owned();

    for _ in 0..500000 {
        let d = rng.gen_range(0, d);
        let q = rng.gen_range(0, 26);
        if state.cur_seq[d] == q {
            continue;
        }
        state.change(d, q);
        if state.sat > cur_sat {
            dbg!(state.sat, cur_sat);
            cur_sat = state.sat;
            cur_ans = state.cur_seq.to_owned();
        }
    }

    dbg!(cur_sat);

    for i in cur_ans {
        println!("{}", i + 1);
    }
}


Measured memory_bytes: 2732
#include <iostream>
#include <cstdio>
#include <vector>
#include <stack>
#include <math.h>

using namespace std;

typedef long long int ll;
typedef long double ld;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define vsort(a) sort(a.begin(), a.end())
#define rev(a) reverse(a.begin(), a.end())

const int MOD = 1000000007;
const int INF = INT_MAX;



int main(){

    

    ld w, h, x, y;
    cin >> w >> h >> x >> y;

    ld gx = w/2.0;
    ld gy = h/2.0;
    ld X = x + (w-2*x) * y / (h-2*y);
    ld Y = y + (h-2*y) * x / (w-2*x);


    printf("%.12Lf ", w*h/2.0);
    if (x == gx && y == gy) cout << 1 << endl;
    else cout << 0 << endl;

}





//              g++ -std=c++1z


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;

int main(){
    long long n, m, k;
    cin >> n >> m >> k;

    vector<long long> a(n);
    vector<long long> b(m);
    vector<long long> a_sum(n+1, 0);
    vector<long long> b_sum(m+1, 0);

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

    for(long long i = 0; i < m; i++){
        cin >> b[i];
    }

    for(long long i = 0; i < n; i++){
        a_sum[i+1] = a_sum[i] + a[i]; 
    }

    for(long long i = 0; i < m; i++){
        b_sum[i+1] = b_sum[i] + b[i]; 
    }

    long long j = m;
    long long ans = 0;
    for(long long i = 0; i <= n; i++){
        if(a_sum[i] > k) break;

        while(a_sum[i] + b_sum[j] > k){
            j -= 1;
        }
        ans = max(ans, i+j);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 9600
n,k = map(int,input().split())
cnt = [0]*n
ans = 0
for i in range(k):
    d = int(input())
    a = [int(i)-1 for i in input().split()]
    for j in a:
        cnt[j] += 1
for i in range(n):
    if cnt[i] == 0: ans += 1
print(ans)



Measured memory_bytes: 9184
#include <stdio.h>
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <bitset>
#include <map>
#include <set>
#include <tuple>
#include <string.h>
#include <math.h>
#include <random>
#include <functional>
#include <assert.h>
#include <math.h>
#include <sstream>
#include <iterator>

using namespace std;

using i64 = long long int;
using ii = pair<int, int>;
using ii64 = pair<i64, i64>;

int main()
{
    int n;
    scanf("%d", &n);
    string s;
    cin >> s;

    vector<int> l(n + 2), r(n + 2);

    for (int i = 1; i <= n; i++)
    {
        if (s[i - 1] == 'W')
            l[i] = 1;
        else
            r[i] = 1;
    }

    for (int i = 1; i <= n; i++)
        l[i] += l[i - 1];

    for (int i = n; i >= 1; i--)
        r[i] += r[i + 1];

    int ans = l[0] + r[2];

    for (int i = 1; i <= n; i++)
        ans = min(ans, l[i - 1] + r[i + 1]);

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

    return 0;
}

Measured memory_bytes: 2948
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>

using namespace std;

int main() {
    string N;
    cin >> N;
    if(N[0] == '7' || N[1] == '7' || N[2] == '7') {
        cout << "Yes" << endl;    
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3628
// package app;

import java.util.Arrays;
import java.util.Objects;
import java.util.Scanner;
import java.util.stream.Stream;

public class Main {

    public static void main(final String[] args) throws Exception {
        final Scanner sc = new Scanner(System.in);

        // final String a = sc.next();
        // final String b = sc.next();

        final int A = sc.nextInt();
        final int B = sc.nextInt();
        final int C = sc.nextInt();
        final int D = sc.nextInt();
        // final int b = sc.nextInt();
        // final int D = sc.nextInt();
        // System.out.println();

        System.out.println(Math.max((A * B), (C * D)));

        // System.out.println(A <= X && A + B >= X ? "YES" : "NO");

    }
}

Measured memory_bytes: 21972
#include <stdio.h>

int main(void)
{
	int a, b, c, n, max, i;
	
	scanf("%d", &n);
	
	for (i = 0; i < n; i++){
		scanf("%d %d %d", &a, &b, &c);
		
		max = a;
		
		if (max < b || max < c){
			if (b < c){
				max = c;
				if (max * max == a * a + b * b){
					puts("YES");
				}
				else {
					puts("NO");
				}
			}
			else {
				max = b;
				if (max * max == a * a + c * c){
					puts("YES");
				}
				else {
					puts("NO");
				}
			}
		}
		else {
			if (max * max == b * b + c * c){
					puts("YES");
				}
			else {
				puts("NO");
			}
		}
	}
	
	return (0);
}

Measured memory_bytes: 580
#include<stdio.h>
int dp[17][17];
int main(void)
{
	int i,j,x,y,kouzix,kouziy,n;
	while(1){
		scanf("%d %d",&x,&y);
		if(x==0&&y==0) break;
		scanf("%d",&n);
		for(i=1;i<=y;i++){
			for(j=1;j<=x;j++) dp[i][j]=0;
		}
		for(i=0;i<n;i++){
			scanf("%d %d",&kouzix,&kouziy);
			dp[kouziy][kouzix]=-1;
		}
		dp[1][1]=1;
		for(i=1;i<=y;i++){
			for(j=1;j<=x;j++){
				if(dp[i][j]!=-1){
					if(dp[i+1][j]!=-1&&i<=y) dp[i+1][j]+=dp[i][j];
					if(dp[i][j+1]!=-1&&j<=x) dp[i][j+1]+=dp[i][j];
				}
			}
		}
	/*	for(i=1;i<=y;i++){
			for(j=1;j<=x;j++){
				printf("%d ",dp[i][j]);
			}
				printf("\n");
		}*/
		printf("%d\n",dp[y][x]);
	}
	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <vector>
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
int main(){
    int X,a=0;
    cin >> X;
    while(X>=5){
        if(X>=500){
            X-=500;
            a+=1000;
        }else if(X>=5){
            X-=5;
            a+=5;
        }else{
            break;
        }
    }
    cout << a;
}

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

int main()
{
    int N;
    cin >> N ;
    vector<int> vec(N);
    for (int i = 0; i < N; i++)
    {
        cin >> vec.at(i);
    }
    sort(vec.begin(), vec.end());
    reverse(vec.begin(), vec.end());
    int alice = 0;
    int bob = 0;
    for (int i = 0; i < vec.size(); i++)
    {
        if (i % 2 == 0)
        {
            alice += vec.at(i);
        }
        else
        {
            bob += vec.at(i);
        }
    }
    cout << alice - bob << endl;
}

Measured memory_bytes: 3616
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MMOD 998244353
#define MAX 2010101
using namespace std;
using Edge=pair<ll,ll>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

ll R,C,N;
vector<pair<ll,ll>> L;

ll Number(ll x,ll y){
  if(x==0)	return y;
  if(y==C)	return C+x;
  if(x==R)	return C+R+(C-y);
  if(y==0)	return C+R+C+(R-x);
  return -1;
}

int main(){
  cin>>R>>C>>N;
  REP(i,N){
    ll X,Y,XX,YY;
    cin>>X>>Y>>XX>>YY;
    ll x=Number(X,Y);
    ll y=Number(XX,YY);
    if(x==-1 || y==-1) continue;
    L.PB(MP(x,i));
    L.PB(MP(y,i));
  }
  SORT(L);
  
  vector<ll> A;
  FORE(v,L){
    if(A.size() && A.back()==v.second) A.pop_back();
    else A.PB(v.second);
  }
  
  if(A.size()) CONO;
  else COYE;
  return 0;
}

Measured memory_bytes: 7988
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    int a,b,c;
    cin>>a>>b>>c;
    int d=a+b;
    d=min(d,a+c);
    d=min(d,b+c);
    cout<<d<<endl;

    return 0;
}


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

int main ()
{
	// ios::sync_with_stdio(0);
 //    cin.tie(0);
 //    cout.tie(0);
	ll t,n,m,k,i,a,b,j;
	ll h[104]={0};
	cin >> m >> n;
	for(i=0;i<n;i++)
	{
		cin >> a;
		h[a]++;
	}
	k=m;
	a=0;
	for(i=1;i<102;i++)
	{
		if(!h[i] && k>abs(m-i))
		{
			a=i;
			k=abs(m-i);
		}
	}
	cout << a << "\n"; 
	return 0;
}

Measured memory_bytes: 3632
n=int(input())
a,b,c=input(),input(),input()
ans=0
for i in range(n):
    if a[i]==b[i]==c[i]:
        continue
    if a[i]==b[i] or b[i]==c[i] or c[i]==a[i]:
        ans+=1
    else:
        ans+=2
print(ans)

Measured memory_bytes: 3060
#include<stdio.h>
int main(void)
{ 
  int n[100];
  int i,a,b,count=0;

  scanf("%d",&a);
  
  for(i=0;i<a;i++){
    scanf("%d",&b);
    n[i]=b;
  }
  for(i=0;i<a;i++){
    if(n[i]%2==0){
      if(n[i]%3==0||n[i]%5==0){
      }
      else {
        count+=1;
      }
    }
  }
   if(count>0){
     printf("DENIED");
   }
  else {
    printf("APPROVED");
  }
  
  return 0;
}

Measured memory_bytes: 1700
S = input()
a = int(S[0])
b = int(S[1])
c = int(S[2])
d = int(S[3])

if a*10 + b == 0:
    if c*10 + d == 0:
        print("NA")
    elif c*10 + d <= 12:
        print("YYMM")
    else:
        print("NA")
elif a*10 + b <= 12:
    if c*10 + d == 0:
        print("MMYY")
    elif c*10 + d <= 12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if c*10 + d == 0:
        print("NA")
    elif c*10 + d <= 12:
        print("YYMM")
    else:
        print("NA")

Measured memory_bytes: 3064