akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <unordered_map>
#include <unordered_set>

using namespace std;

#define ll long long
#define pb push_back
#define debug1(x) cerr << #x << " = " << x << '\n';
#define debug2(x, y) cerr << #x << " = " << x << "   " << #y << " = " << y << "\n";
#define _ ios_base::sync_with_stdio(0);cin.tie(NULL);


void solve() {
    ll a, b;
    cin >> a >> b;
    ll c, d;
    cin >> c >> d;
    ll ans[4] = {};
    ans[0] = a * c;
    ans[1] = a * d;
    ans[2] = b * c;
    ans[3] = b * d;
    cout << *max_element(ans, ans+4);
}

int main() {_
    int t = 1;
//    cin >> t;
    for(int i = 1; i<=t; i++) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3636
#include <stdio.h>

int a[10000];

int t[100][100];

int main(void)
{
    int H, W, N;
    int i, j, g;
    int p[100];

    scanf("%d %d", &H, &W);
    scanf("%d", &N);

    for (i = 0; i < N; i++) {
        scanf("%d", &a[i]);
    }

    g = 0;
    for (i = 0; i < H; i++) {
        if (i % 2 == 0) {
            for (j = 0; j < W; j++) {
                t[i][j] = g;
                a[g]--;
                if (a[g] == 0) g++;
            }
        }
        else {
            for (j = W - 1; j > -1; j--) {
                t[i][j] = g;
                a[g]--;
                if (a[g] == 0) g++;
            }
        }
    }

    for (i = 0; i < H; i++) {
        for (j = 0; j < W; j++) {
            printf("%d ", t[i][j] + 1);
        }
        printf("\n");
    }
}

Measured memory_bytes: 256
a,b,c = map(int,input().split())

if a>=b and a>=c :
    print(int(str(a)+str(b))+int(c))
elif b>=a and b>=c :
    print(int(str(b)+str(a))+int(c))
elif c>=a and c>=b :
    print(int(str(c)+str(a))+int(b))
else:
    pass

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
 
template <class T>
inline void read(T &x) {
    x = 0;
    char c = getchar();
    bool f = 0;
    for (; !isdigit(c); c = getchar()) f ^= c == '-';
    for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48);
    x = f ? -x : x;
}
 
template <class T>
inline void write(T x) {
    if (x < 0) {
        putchar('-');
        x = -x;
    }
    T y = 1;
	int len = 1;
    for (; y <= x / 10; y *= 10) ++len;
    for (; len; --len, x %= y, y /= 10) putchar(x / y + 48);
}
 
const int MAXN = 1e5;
int n, firMax[2], secMax[2], firRes[2], secRes[2], tot[2][MAXN + 5];
 
int main() {
	read(n);
	for (int x, i = 1; i <= n; ++i) {
		read(x);
		++tot[i & 1][x];
	}
	for (int i = 1; i <= MAXN; ++i)
		for (int j = 0; j <= 1; ++j) {
			if (tot[j][i] > firMax[j]) {
				secMax[j] = firMax[j], secRes[j] = firRes[j];
				firMax[j] = tot[j][i], firRes[j] = i;
			} else if (tot[j][i] > secMax[j])
				secMax[j] = tot[j][i], secRes[j] = i;
		}
	if (firRes[0] != firRes[1]) write(n - firMax[0] - firMax[1]);
	else write(n - max(firMax[0] + secMax[1], secMax[0] + firMax[1]));
	putchar('\n');
	return 0;
}

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

//解答方針
//２で割り切れる回数を調べる　一つでも異なるものがあったらアウト
//x / (2**w)
//LCM(a_1,,,a_n)をとる
//1 <= x <= m''の中に, L=LCM(a_1,,,,a_n)の奇数倍のものは何個ある？
//切り上げ処理を行う
long long gcd(long long a, long long b){
    if (b == 0) return a;
    else return gcd(b, a%b);
}

long long lcm(long long a, long long b){
    return a / gcd(a, b) * b;
}

int countDivision(long long a){
    if (a % 2 == 1) return 0;
    int res = 0;
    while(a%2 == 0){
        a /= 2;
        res++;
    }
    return res;
    
}

int main(void){
    int n, m;
    cin >> n >> m;
    
    vector<long long> a(n);
    rep(i, n){
        cin >> a[i];
        a[i] /= 2;
    } 
    
    //２で割り切れる回数を調べる　一つでも異なるものがあったらアウト
    int comparison = countDivision(a[0]);
    
    rep(i, n){
        if (countDivision(a[i]) != comparison){
            cout << 0 << endl;
            return 0;
        }
        a[i] >>= comparison;
    }
    
    // / (2**w)
    m /= pow(2, comparison);
    
    //LCM(a_1,,,a_n)をとる
    
    long long l = 1;
    
    rep(i, n){
        l = lcm(l, a[i]);
        if(l > m){
            cout << 0 << endl;
            return 0;
        }
    }
    
    //1 <= x <= m''の中に, L=LCM(a_1,,,,a_n)の奇数倍のものは何個ある？
    //切り上げ処理を行う
    int ans = ((m / l) + 1) / 2;
    cout << ans << endl;
}




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

int main() {
  long N, A, B;
  cin >> N >> A >> B;
  vector<long> X(N);
  for (long i = 0; i < N; i++) cin >> X.at(i);
  long ans = 0;
  for (long i = 0; i + 1 < N; i++) {
    long tmp = X.at(i + 1) - X.at(i);
    tmp *= A;
    ans += min(tmp, B);
  }
  cout << ans << "\n";
}

Measured memory_bytes: 3976
import java.util.Scanner
import scala.collection.Searching._

import scala.annotation.tailrec

class IUnionFind(val size: Int) {

  private case class Node(var parent: Option[Int], var treeSize: Int)

  private val nodes = Array.fill[Node](size)(new Node(None, 1))

  def union(t1: Int, t2: Int): IUnionFind = {
    if (t1 == t2) return this

    val root1 = root(t1)
    val root2 = root(t2)
    if (root1 == root2) return this

    val node1 = nodes(root1)
    val node2 = nodes(root2)

    if (node1.treeSize < node2.treeSize) {
      node1.parent = Some(t2)
      node2.treeSize += node1.treeSize
    } else {
      node2.parent = Some(t1)
      node1.treeSize += node2.treeSize
    }
    this
  }

  def connected(t1: Int, t2: Int): Boolean = t1 == t2 || root(t1) == root(t2)

  @tailrec
  private def root(t: Int): Int = nodes(t).parent match {
    case None => t
    case Some(p) => root(p)
  }
}


object Main {
  def solve(sc: => Scanner): Unit = {
    println(sc.nextInt match {
      case 0 => 1
      case 1 => 2
      case 2 => 1
      case _ => 0
    })
  }

  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)

    solve(sc)
  }
}

Measured memory_bytes: 45160
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	static final long MOD = 998244353L;
	
	Main() {
		FastScanner scanner = new FastScanner();
		int N = scanner.nextInt();
		int S = scanner.nextInt();
		
		int[] A = new int[N];
		for (int i = 0; i < N; i++) {
			A[i] = scanner.nextInt();
		}
		
		long[][] DP = new long[N+1][S+1];
		DP[0][0] = 1;
		for (int i = 0; i <  N; i++) {
			
			//遷移先の合計値
			for (int s = 0; s <= S; s++) {
				DP[i+1][s] = (DP[i+1][s] + DP[i][s] * 2L % MOD) % MOD;
				
				if (s-A[i] >= 0) {
					DP[i+1][s] = (DP[i+1][s] + DP[i][s-A[i]]) % MOD;
				}
				
			}
		}
		
		System.out.println(DP[N][S]);
	}
	
	public static void main(String[] args) {
		new Main();
	}
	
	long[] fac, finv, inv;
	
	void init(int max) {
		max += 1;
		fac = new long[max];
		finv = new long[max];
		inv = new long[max];
		
		fac[0] = fac[1] = 1;
		finv[0] = finv[1] = 1;
		inv[1] = 1;
		for (int i = 2; i < max; i++) {
			fac[i] = fac[i - 1] * i % MOD;
			inv[i] = MOD - inv[(int) (MOD % i)] * (MOD / i) % MOD;
			finv[i] = finv[i - 1] * inv[i] % MOD;
		}
	}
	
	long combination(int n, int k) {
		if (n < k) return 0;
		if (n < 0 || k < 0) return 0;
		return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	
	private int readByte() {
		if (hasNextByte()) return buffer[ptr++];
		else return -1;
	}
	
	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}
	
	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
		return hasNextByte();
	}
	
	public String next() {
		if (!hasNext()) throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	
	public long nextLong() {
		if (!hasNext()) throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
	
	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) nl;
	}
	
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}



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

int main(){
	int a,b,x;
	cin>>a>>b>>x;
	
	if(a>x) cout<<"NO"<<endl;
	else{
		if(x-a<=b) cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author parsa bahrami
 */

#pragma GCC optimize("O2")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;
typedef pair<string, string> pss;

template<class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define sz(x)                       (ll) x.size()
#define jjoin(x)                    for (auto i : x) cout << i << endl;
#define all(x)                      (x).begin(),(x).end()
#define F                           first
#define S                           second
#define Mp                          make_pair
#define sep                         ' '
#define error(x)                    cerr << #x << " = " << x << endl
#define fast_io                     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define set_random                  mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
#define kill(x)                     return cout << x << endl , 0;
#define Hkill(x)                    cout << x << endl; exit(0);
#define endl                        '\n'

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

const ll MAXN = 2e5 + 10;
const ll MAXA = 101;
const ll INF = 8e18;
const ll MOD = 1e9 + 7; //998244353
const ld PI = 4 * atan((ld) 1);
ll n, k, fact[MAXN + 1], INV[MAXN + 1], ans = 1;
vector<ll> adj[MAXN];

ll C(ll i, ll j) {
    if (j < i) return 0;
    if (i == j) return 1;
    return ((((fact[j] * INV[i]) % MOD) * INV[j - i]) % MOD);
}


void dfs(ll v, ll p = -1) {
    ll deg = 0;
    for (ll u : adj[v]) {
        if (u == p) continue;
        deg++;
        dfs(u, v);
    }
    if (p == -1) {
        ans = (ans * C(deg, k - 1) % MOD * fact[deg]) % MOD;
        //cout << 1 << " " << C(deg, k - 1) << endl;
    } else {
        ans = ((ans * C(deg, k - 2) % MOD) * fact[deg]) % MOD;
    }
}

int main() {
    fast_io;
    set_random;
    cin >> n >> k;
    for (ll i = 1; i <= n - 1; i++) {
        ll u, v;
        cin >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    fact[0] = 1;
    for (ll i = 1; i <= MAXN; i++)
        fact[i] = (fact[i - 1] * i) % MOD;
    INV[MAXN] = poww(fact[MAXN], MOD - 2, MOD);
    for (ll i = MAXN - 1; i >= 0; i--)
        INV[i] = ((INV[i + 1] * (i + 1)) % MOD);
    ans = k;
    dfs(1);
    //ans = k;
    cout << ans << endl;
    //error(C(2, 10));
    return 0;
}



Measured memory_bytes: 14720
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int maxn=4e5+10;
int last[30];
int f[2*maxn][30];
char a[maxn],b[maxn];
signed main(){
	int i,j;
	scanf("%s%s",a+1,b+1);
	int n=strlen(a+1),m=strlen(b+1);
	for(i=n+1;i<=2*n;i++)a[i]=a[i-n];
	for(i=2*n;i>=1;i--){
		//last[c-'a']=i
		for(j=0;j<26;j++){
			f[i][j]=last[j];
		}
		last[a[i]-'a']=i;
	}
	int s=0,pos=0;
	for(i=1;i<=n;i++){
		if(a[i]==b[1]){
			pos=i;
			break;
		}
	}
	if(!pos){
		printf("-1\n");
		return 0;
	}
	s=pos;
	for(i=2;i<=m;i++){
		s+=f[pos][b[i]-'a']-pos;
		pos=f[pos][b[i]-'a'];
		if(!pos){
			printf("-1\n");
			return 0;
		}
		if(pos>n){
			pos-=n;
		}
		//printf("pos=%d\n",pos);
	}
	printf("%lld\n",s);
	return 0;
}


Measured memory_bytes: 48896
// by adiforluls
#pragma GCC optimize ("-O2")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define FAST         ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ll           long long
#define ld           long double
#define pb           push_back
#define mp           make_pair
#define pii          pair<int,int>
#define mii          map<int,int>
#define vi           vector<int>
#define vll          vector<long long>
#define all(a)       (a).begin(),(a).end()
#define clz(a)       __builtin_clz(a) // count leading zeroes
#define ctz(a)       __builtin_ctz(a) // count trailing zeroes
#define popc(a)      __builtin_popcount(a) // count set bits (for ints only diff for ll)
#define lul          1000000007
#define rep(i,a,b)   for(int i=a;i<b;i++)
#define rfor(i,a,b)  for(int i=a; i>=b; i--)
#define SIZE         1000005
#define F            first
#define S            second
#define mod          998244353

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " = " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " = " << arg1<<" |";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define endl         '\n'
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key(k)
// find_by_order(k)
const ld PI = acos(-1.0);
const int INF = 0x3f3f3f3f;

bool cmp(pii &x, pii &y)
{
    return x.F+x.S<y.F+y.S;
}
void solve()
{
    int n; cin>>n;
    vector<pii> v(n);
    rep(i,0,n) cin>>v[i].F>>v[i].S;
    sort(all(v),cmp);
    vector<vector<ll>> dp(n+1,vector<ll>(n+1,1LL<<60));
    dp[0][0]=0;
    rep(i,0,n)
    {
        rep(j,0,i+1)
        {
            if(dp[i][j]<=v[i].F)
            {
                dp[i+1][j+1] = min(dp[i+1][j+1],dp[i][j]+v[i].S);
            }
            dp[i+1][j] = min(dp[i+1][j],dp[i][j]);
        }
    }
    rfor(i,n,1)
    {
        if(dp[n][i]<(1LL<<60)) {cout<<i; return;}
    }
    cout<<0; 
}
int main()
{   
    FAST;
   //  #ifndef ONLINE_JUDGE
     // freopen("input.txt", "r", stdin);
     // freopen("output.txt", "w", stdout);
   //  #endif
    int t; t=1;
    while(t--){
       solve();
    }
    return 0;
}

Measured memory_bytes: 195840
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD 1000000007

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

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

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

signed main() {
    int H1, M1, H2, M2, K;
    cin >> H1 >> M1 >> H2 >> M2 >> K;

    int len = (H2 - H1) * 60;
    len += M2 - M1;

    cout << len - K << endl;

    return 0;
}


Measured memory_bytes: 3624
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
long long int a[1000060];
long long int b[1000060];
int main()
{
    long long int i,j,ci=0;
    for(i=2;i<=1000050;i++)
    {
        if(a[i]==0)
        {
            for(j=i+i;j<=1000050;j=j+i)
            {
                a[j]=1;
            }
            b[ci]=i;
            ci++;
        }
    }
    long long int x,y,z,t;
    scanf("%lld%lld",&x,&y);
    z=min(x,y);
    t=max(x,y);
    ci=1;
    for(i=0;b[i]*b[i]<=z;i++)
    {
        if(z%b[i]==0)
        {
            if(t%b[i]==0)
                ci++;
            while(z%b[i]==0)
            {
                z=z/b[i];
            }
        }
    }
    if(z!=1)
        if(t%z==0)
        ci++;
    printf("%lld\n",ci);
    return 0;
}


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

using namespace std;

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> inline T sqr(T x) {return x*x;}

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

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

int pos[22];
int dir[22];
int last[22];
bool pri[22];

int main(void){
	int n,l;
	while(cin >> n >> l){
		if(n==0)
			break;

		for(int i=1;i<=n;++i){
			char d;
			cin >> d >> pos[i];
			dir[i]=(d=='R')?1:-1;
		}

		for(int t=1;;++t){
			for(int i=1;i<=n;++i)
				pos[i]+=dir[i];

			for(int i=1;i<=n;++i){
				if(pos[i]==0||l==pos[i]){
					if(pos[i]==0)
						pri[i]=true;
					else
						pri[i]=false;
					last[i]=t,pos[i]=-1,dir[i]=0;
				}
			}

			for(int i=1;i<=n;++i)
				for(int j=i+1;j<=n;++j)
					if(pos[i]==pos[j])
						swap(dir[i],dir[j]);

			bool finished=true;
			for(int i=1;i<=n;++i)
				if(pos[i]!=-1)
					finished=false;

			if(finished)
				break;

		}
		int cmax=0,ans=0;
		for(int i=1;i<=n;++i){
			if(last[i]>cmax||(cmax==last[i]&&pri[i]))
				cmax=last[i],ans=i;
		}
		cout << cmax << " " << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define INF 1e9;
using namespace std;
typedef long long ll;
int main() {
  string S;
  cin >> S;
  ll K;
  cin >> K;
  ll N = S.length();

  REP(i, min(N, K)) {
    if (S[i] != '1') {
      cout << S[i];
      return 0;
    }
  }
  cout << 1;
  return 0;

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h> 
#include<stdlib.h>

int main()
{
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);
	if(a < b && b < c)
    {
		printf("Yes\n");
    }   
	else 
    {
    	printf("No\n");
	}	

		
	return 0;
}


Measured memory_bytes: 2144
#include <cstdio>
#include <algorithm>

#define MAX 500000

int main()
{
	int N, L[MAX], ans=0;
	scanf("%d", &N);
	for(int i=0; i<N; i++){
		scanf("%d", &L[i]);
	}
	//ans = N*(N-1)*(N-2)/6;
	std::sort(L, L+N);
	for(int i=0; i<N; i++){
		for(int j=i+1; j<N; j++){
			for(int k=j+1; k<N; k++){
				if(L[i] >= L[j]+L[k]){
					k=N;
					continue;
				}
				else if(L[j] >= L[i]+L[k]){
					k=N;
					continue;
				}
				else if(L[k] >= L[j]+L[i]){
					k=N;
					continue;
				
				}
				ans ++;
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}

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

const int N = 3589;

ll a[N], dp[N][N];

int main() {
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    for (int i=1; i<=n; i++) {
        cin >> a[i];
    }
    for (int len=1; len<=n; len++) {
        for (int i=1, j=i+len-1; j<=n; i++, j++) {
            dp[i][j] = max(a[i]-dp[i+1][j], a[j]-dp[i][j-1]);
        }
    }
    cout << dp[1][n] << '\n';
}


Measured memory_bytes: 86272
import java.util.*;

public class Main {
	
    public static int gcd(int p, int q) {
        if (q == 0) return p;
        else return gcd(q, p % q);
    }

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		int X = scanner.nextInt();
		int[] x = new int[N];
		
		for(int i=0; i<N; i++) {
			x[i] = scanner.nextInt();
		}
		
		int D = Math.abs(x[0] - X);
		
		for(int i=1; i<N; i++) {
			D = gcd(D, Math.abs(x[i] - X));
		}
		
		System.out.println(D);
		

	}

}


Measured memory_bytes: 50356
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>

using namespace std;


void solve() {
    int X, Y; cin >> X >> Y;
    for (int i = 0; i <= X; i++) {
        if (i * 2 + (X - i) * 4 == Y) {
            cout << "Yes" << endl;
            return;
        }
    }
    cout << "No" << endl;
}


int main() {
    solve();
    return 0;
}

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

int main() {
    int n, x;
    cin >> n >> x;
    int now = 0;
    int cnt = 0;
    while (now <= x) {
        int l; cin >> l;
        now += l;
        cnt++;
        if (cnt == n && now <= x) {
            cnt++;
            break;
        }
    }
    cout << cnt << endl;
}

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

const int mod = 1000000007;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  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;
  }
};

int main() {
  int n;
  cin >> n;
  vector<int> c(n);
  rep(i, n) cin >> c[i];
  sort(c.begin(), c.end());
  vector<mint> two(n + 1);
  two[0] = 1;
  rep(i, n) two[i + 1] = two[i] * 2;

  mint ans;
  rep(i, n) {
    int l = i, r = n - 1 - i;
    mint now = two[r];
    if (r != 0) now += two[r - 1] * r;
    now *= two[l];
    now *= c[i];
    ans += now;
  }
  
  ans *= two[n];

  cout << ans.x << endl;
  return 0;
}


Measured memory_bytes: 2560
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n:i32,
        m: i32,
    }

    let res = n * (n - 1) / 2 + m * (m - 1) / 2;
    println!("{}", res);
}


Measured memory_bytes: 4352
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N,C = map(int,input().split())
time = [0]*(100009*2)
channel = [[0]*(100009*2) for _ in range(C)]
#(方針)チャンネル関係なしに
#同じチャンネルの連続だと録画開始時間に0.5秒のロスがない
# 同チャンネルで 1-7 7-8 → [0.5,8) → 録画機1つ(0.5~7.99) 
# 違うチャンネルで 1-7 7-8 → [0.5,7) 0.5~6.99 , [6.5,8) 6.5~7.99 → 録画機2つ

#前処理:　同チャンネル#0.5が扱いずらいので,sを2s-1,tを2tに対応させる
#ex: 1-3 → 0.5-3 → 1-6
#ex: 3-5 → 2.5-5 → 5-10
#ex: 1-3,3-5 → 1-6,5-10 → 2個必要の区間をつなげる(ex. 1-7 7-8 → 1-8）
max_num = 0
for i in range(N):
 s,t,c = map(int,input().split())
 s,t = 2*s-1,2*t 
 if(channel[c-1][s-1] == 1): channel[c-1][s-1] = 0
 else: channel[c-1][s] = 1
 channel[c-1][t] = 1
 max_num = max(max_num,t)

#imos法
#0.5が扱いずらいので,sを2s-1,tを2tに対応させる
#ex: 1-3 → 0.5-3 → 1-6
#ex: 3-5 → 2.5-5 → 5-10
#ex: 1-3,3-5 → 1-6,5-10 → 2個必要
#A = []
tmp = 0
for i in range(C):
 for j in range(max_num+10):
  if((tmp == 0)and(channel[i][j] == 1)):
    tmp = 1
    a = j
  elif((tmp == 1)and(channel[i][j] == 1)):
    tmp = 0
    b = j
    #A.append([a,b])
    time[a] += 1
    time[b+1] -= 1
#print(A)
    
ans = 0
for i in range(max_num+10):
  if(i != 0): time[i] += time[i-1]
  ans = max(ans,time[i])
print(ans)
#print(time)

Measured memory_bytes: 51700
import java.util.Scanner;

public class Main{

    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        
        // input
        long x = scan.nextLong();
        long y = scan.nextLong();

        // search
        int count = 0;
        while(x <= y){
            x *= 2;
            count++;
        }

        // answer
        System.out.println(count);
    }
}

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

int main() {
	string S;
	cin >> S;
	int ans = 0;
	for (int i = 0; i < S.size(); ++i) {
		for (int j = 0; j < S.size() - i; ++j) {
			int k;
			for (k = j; k < i + j + 1; ++k) {
				if (S[k] != 'A' && S[k] != 'C' && S[k] != 'G' && S[k] != 'T') break;
			}
			if (i + j == k - 1) ans = i + 1;
		}
	}
	cout << ans;
}

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

ll pow(ll n, ll k, ll m) {
	ll r = 1;
	for (; k > 0; k >>= 1) {
		if (k & 1) r = (r*n) % m;
		n = (n*n) % m; 
	}
	return r;
}

int main() {
	ll n; cin >> n;
	ll ans = 0;
	vector<ll> res(1000001, 0);
	vector<ll> c(1000001, 0);
	for (ll i = 0; i < n; ++i) {
		ll a; cin >> a;
		c[a]++;
	}
	for (ll i = 1000000; i > 0; --i) {
		ll sum_of_sq = 0; ll sq_of_sum = 0;
		for (ll j = 1; j*i < 1000001; ++j) {
			sum_of_sq += pow(j*i, 2, MOD) * c[j*i];
			sum_of_sq %= MOD;
			sq_of_sum += j*i * c[j*i];
			sq_of_sum %= MOD;
		}
		sq_of_sum = pow(sq_of_sum, 2, MOD);
		ll dif = (sq_of_sum - sum_of_sq + MOD) % MOD;
		res[i] = dif * pow(2*i, MOD-2, MOD);
		res[i] %= MOD;
		for (ll j = 2; j*i < 1000001; ++j) {
			res[i] += (MOD - res[j*i]) * j;
			res[i] %= MOD;
		}
		ans += res[i];
		ans %= MOD;

	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 16000
from fractions import gcd
N,X = map(int, input().split())
x = list(map(int, input().split()))

x.append(X)
x = list(set(x))
x.sort()
y = [x[i+1]-x[i] for i in range(len(x)-1)]

if len(x) == 1:
  print(0)
  exit()
elif len(x) == 2:
  print(abs(x[1]-x[0]))
  exit()
else:
  ans = y[0]
  for i in range(len(y)):
    ans = gcd(ans,y[i])
print(ans)

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

int N;
int A[100010];

int main()
{
    scanf("%d",&N);
    for(int i = 0; i < N; i++)scanf("%d",A + i);
    sort(A,A + N);
    int ans = 0;
    for(int i = 0; i < N - 1; i++)
    {
        if(A[i] != A[i + 1])ans++;
    }

    printf("%d\n",ans + 1);
    return 0;
}


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

#define REP(i, n) for(int i = 0; i < (int) (n); i++)
#define ALL(v) (v).begin(), (v).end()
#define INF 1e9

using namespace std;

struct team{
  int id;
  array<int, 10> penalty;
  int correct;
  int score;
  team(int i) : id(i), penalty({0}), correct(0), score(0) {}
  bool operator<(const team &x)const{
    if(correct < x.correct) return true;
    if(correct > x.correct) return false;
    if(score > x.score) return true;
    if(score < x.score) return false;
    if(id < x.id) return true;
    return false;
  }
  bool operator==(const team &x)const{
    if(correct == x.correct and score == x.score) return true;
    return false;
  }
};

int main(){
  int m, t, r, p;
  while(cin >> m >> t >> p >> r and m + t + p + r){
    vector<team> teams;
    REP(i, t) teams.emplace_back(i+1);
    REP(i, r){
      int mk, tk, pk, jk;
      cin >> mk >> tk >> pk >> jk;
      tk--; pk--;
      if(jk) teams[tk].penalty[pk]++;
      if(!jk) { teams[tk].correct++; teams[tk].score += teams[tk].penalty[pk] * 20 + mk; }
    }
    sort(ALL(teams));
    reverse(ALL(teams));
    REP(i, teams.size()){
      cout << teams[i].id;
      if(i < teams.size()-1) cout << (teams[i] == teams[i+1] ? "=" : ",");
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 3088
#include <iostream>
#include <vector>
#include <ios>
using namespace std;
struct Node
{
	Node() : leftId(-1), rightId(-1), depth(0), height(0) {}
	int leftId;
	int rightId;
	int depth;
	int height;
	int getDegree() const
	{
		int d = 0;
		if (-1 != leftId) ++d;
		if (-1 != rightId) ++d;
		return d;
	}
};
Node* getNode(int id, vector<Node>& vNode)
{
	if (id < 0 || vNode.size() <= id)
		return 0;
	return &vNode[id];
}
int getSiblingId(int id, vector<int>& vPID, vector<Node>& vNode)
{
	int pid = vPID[id];
	if (-1 == pid)
		return -1;
	Node& pNode = vNode[pid];
	if (pNode.leftId == id)
		return pNode.rightId;
	if (pNode.rightId == id)
		return pNode.leftId;
	return -1;
}
int SetNodeDepthHeight(Node& node, vector<Node>& vNode)
{
	Node* lNode = getNode(node.leftId, vNode);
	Node* rNode = getNode(node.rightId, vNode);
	if (!lNode && !rNode)
		return 0;

	int lheight = -1, rheight = -1;
	if (lNode){
		lNode->depth = node.depth + 1;
		lheight = SetNodeDepthHeight(*lNode, vNode);
	}
	if (rNode){
		rNode->depth = node.depth + 1;
		rheight = SetNodeDepthHeight(*rNode, vNode);
	}
	node.height = (lheight > rheight ? lheight : rheight) + 1;
	return node.height;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, id, l, r;
	cin >> n;
	vector<int> vPID(n, -1);
	vector<Node> vNode(n);
	for (int i = 0; i < n; ++i)
	{
		cin >> id >> l >> r;
		vNode[id].leftId = l;
		vNode[id].rightId = r;
		if (-1 != l)	vPID[l] = id;
		if (-1 != r)	vPID[r] = id;
	}
	vector<int> vRoot;
	vRoot.reserve(n);
	for (int i = 0; i < n; ++i){
		if (vPID[i] == -1)
			vRoot.push_back(i);
	}
	for (int i = 0; i < vRoot.size(); ++i)
		SetNodeDepthHeight(vNode[vRoot[i]], vNode);
	for (int i = 0; i < n; ++i){
		Node& node = vNode[i];
		cout << "node " << i
			<< ": parent = " << vPID[i]
			<< ", sibling = " << getSiblingId(i, vPID, vNode)
			<< ", degree = " << node.getDegree()
			<< ", depth = " << node.depth
			<< ", height = " << node.height
			<< ", ";
		if (vPID[i] == -1) cout << "root\n";
		else if (0 == node.height) cout << "leaf\n";
		else cout << "internal node\n";
	}
	return 0;
}

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

#define rep(i, m, n) for(int(i) = (int)(m); i < (int)(n); ++i)
#define rep2(i, m, n) for(int(i) = (int)(n)-1; i >= (int)(m); --i)
#define REP(i, n) rep(i, 0, n)
#define REP2(i, n) rep2(i, 0, n)
#define all(hoge) (hoge).begin(), (hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T>
using vec = vector<T>;
template <class T>
using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll)1e9 + 7;
//constexpr long long MOD = 998244353LL;
using ld = long double;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;

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

struct Edge {
    ll to, rev;
    long double cap;
    Edge(ll _to, long double _cap, ll _rev) {
        to = _to;
        cap = _cap;
        rev = _rev;
    }
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph &G, ll from, ll to, long double cap, bool revFlag,
              long double revCap) {
    G[from].push_back(Edge(to, cap, (ll)G[to].size()));
    if(revFlag)
        G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void solve() {
    ll a[4];
    REP(i, 4) {
        cin >> a[i];
    }
    sort(a, a + 4);
    if(a[0] == 1 and a[1] == 4 and a[2] == 7 and a[3] == 9) {
        cout << "YES" << en;
    } else {
        cout << "NO" << en;
    }
}

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

    solve();
    /*
    ll t;
    cin >> t;
    REP(i, t)
    solve();
    */

    return 0;
}


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

//conversion
//------------------------------------------
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();}

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<VC> VVC;
typedef vector<VB> VVB;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef pair<LL,LL> PLL;
typedef vector<PII> VPII;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define LB lower_bound
#define UB upper_bound
#define SORTR(c) sort((c).begin(), (c).end(), greater<int>())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define FORR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REPR(i,n) RFOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL INF = INT_MAX;
const LL LINF = LLONG_MAX;
const LL MOD = 1e9+7;

//other
//-------------------------------------------
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define FI first
#define SE second

//memo
// setprecision()

VI dx = {1,0,-1,0};
VI dy = {0,1,0,-1};

LL Gcd(LL a, LL b) {
  return __gcd(a,b);
}

LL Lcm(LL a, LL b) {
  LL abd = Gcd(a,b);
  LL x = a / abd, y = b / abd;
  
  return x*y*abd;
}


LL RepSqu(LL N, LL P, LL M) {
  if(P == 0) {
    return 1;
  }
  if(P%2 == 0) {
    LL t = RepSqu(N, P/2, M);
    return t*t % M;
  }
  return (N * RepSqu(N, P-1, M)) % M;
}


int main() {
  
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string X;
  cin >> X;
  int N = SZ(X);
  int cou=0,ans=0;
  
  REP(i,N){
    if(X.at(i)=='S')cou++;
    else if(cou > 0)cou--;
    else ans++;
  }
  
  cout << ans+cou << endl;
  
  return 0;
}

Measured memory_bytes: 720
#include<stdio.h>
#include<math.h>
int main(void){
    int minv,maxv,i,n,R[200000];

    maxv=-1.0E9;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&R[i]);
    }

    minv=R[0];
    for(i=1;i<n;i++){
        if(maxv<R[i]-minv){
            maxv=R[i]-minv;
        }
        if(R[i]<minv){
            minv=R[i];
        }
    }

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

}


Measured memory_bytes: 2620
# coding: utf-8
"""this is python work script"""
def solve(s):
    """solve problem"""
    if s == 'ABC':
        ans = 'ARC'
    else:
        ans = 'ABC'
    return ans

def main():
    """main function"""
    S = input().rstrip()
    answer = solve(S)
    print(answer)

if __name__ == '__main__':
    main()


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

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

	set<int> s;
	for (int i = 1; i <= n; ++i) {
		s.insert(i);
	}

	for (int i = 0; i < k; ++i) {
		int d;
		cin >> d;
		for (int j = 0; j < d; ++j) {
			int a;
			cin >> a;
			s.erase(a);
		}
	}

	cout << s.size();
	
	return 0;
}
	

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int maxcost(int matrix[][3],int calc[][3],int n,int task)
{
  if(n==0)
  {
    if(task==0)
      return max(matrix[0][1],matrix[0][2]);
    else if(task==1)
      return max(matrix[0][0],matrix[0][2]);
    else
      return max(matrix[0][0],matrix[0][1]);
  }
  if(calc[n][task]!=-1)
    return calc[n][task];
  if(task==0)
    return calc[n][task]=matrix[n][task]+max(maxcost(matrix,calc,n-1,1),maxcost(matrix,calc,n-1,2));
  else if(task==1)
    return calc[n][task]=matrix[n][task]+max(maxcost(matrix,calc,n-1,0),maxcost(matrix,calc,n-1,2));
  else if(task==2)
    return calc[n][task]=matrix[n][task]+max(maxcost(matrix,calc,n-1,0),maxcost(matrix,calc,n-1,1));
}
  
int main()
{
  int days;
  cin >> days;
  int matrix[days][3];
  int calc[days][3];
 
  for(int i=0;i<days;i++)
  {
    for(int j=0;j<3;j++)
    {
      cin >> matrix[i][j];
      calc[i][j]=-1;
      
    }
  }
  cout << max( maxcost(matrix,calc,days-1,0),max(maxcost(matrix,calc,days-1,1),maxcost(matrix,calc,days-1,2)));
  return 0;
}

Measured memory_bytes: 12120
#include<stdio.h>
#include<string.h>
int main()
{
    char str[100],l;
    scanf("%s",&str);
    l=strlen(str);
    if(l==3)
    {
        if(str[0]=='7'||str[1]=='7'||str[2]=='7')
        {
            printf("Yes\n");
        }
        else
        {
            printf("No\n");
        }

    }
    return 0;
}


Measured memory_bytes: 1616
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>

using namespace std;
using lint = long long;

int main() {
    while (true) {
        int N, M;
        cin >> N >> M;
        if (N == 0 && M == 0) break;
        vector<int> P(N);
        for (int i = 0; i < N; i++) {
            cin >> P[i];
        }
        P.emplace_back(0);
        ++N;
        vector<int> P2(N*N);
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++) {
                P2[i*N+j] = P[i] + P[j];
            }
        }
        sort(P2.begin(), P2.end());
        int ans = 0;
        for (int i = 0; i < N*N; i++) {
            const int index = upper_bound(P2.begin(), P2.end(), M - P2[i]) - P2.begin();
            if (index == 0) continue;
            ans = max(ans, P2[i] + P2[index-1]);
        }
        cout << ans << endl;
    }
    return 0;
}


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

//#define int long long
//struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;
//const int MOD = 1e9 + 7;
using intpair = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) ((int)((a) + (b) - 1)/(int)(b))

int dp[100];
signed main() {
    dp[0] = dp[1] = 1;
    int n; cin >> n;
    
    reps(i,2,n){
        dp[i] = dp[i-1] + dp[i-2];
    }
    
    cout << dp[n] << endl;
}


Measured memory_bytes: 3088
H,W = map(int,input().split())
if H == 1:
    print(1)
elif W == 1:
    print(1)
elif H % 2 == 0:
    print((H // 2) * W)
else:
    if W % 2 == 0:
        print(H * (W // 2))
    else:
        print(H * (W // 2) + (H // 2 + 1))

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

typedef long long ll;

ll pow_mod(ll a, ll n, ll p)
{
    if(n == 1){
        return a%p;
    }else if(n%2 == 1){
        return a*pow_mod(a,n-1,p)%p;
    }else{
        ll t = pow_mod(a,n/2,p);
        return t*t%p;
    }
}

int main()
{
    ll n,a,b;
    int i,k;
    cin >> n >> a >> b;
    int MOD = 1e9 + 7;
    ll ans = pow_mod(2,n,MOD) - 1;
    ll max_number = n;
    k = max(a,b);
    vector<ll> inv(k+1,1);
    vector<ll> nCk(k+1,1);
    for(i = 2;i <= k;++i){
        inv.at(i) = MOD - inv.at(MOD%i)*(MOD/i)%MOD;
    }
    for(i = 1;i <= k;++i){
        nCk.at(i) = nCk.at(i-1)*(max_number-i+1)%MOD;
        nCk.at(i) = nCk.at(i)*inv.at(i)%MOD;
    }
    
    ans += (MOD - nCk.at(a)) + (MOD - nCk.at(b));
    ans %= MOD;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long a,b,c;
	cin>>a>>b>>c;
	if(a%2!=0&&b%2!=0&&c%2!=0){
		cout<<min({a*b,a*c,b*c})<<endl;
	}
	else cout<<0<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

int main(){
    Init();
    ll n, m, d;
    cin >> n >> m >> d;

    // d=0の場合
    if(d == 0){
        // 隣り合う2項がd=0となるのは数値が同じ場合の時のみ。
        // (1,1),(2,2),...,(n,n)であり、かつ組み合わせはn^2通り存在する。
        // ∴n/(n^2) = 1/n, これがm-1個のペア存在するため乗算する。
        cout << 1.0/n*(m-1) << endl;
    }
    // d>=1の場合
    else{
        // 隣り合う2項の差がdとなるのは、
        // (1,d+1),(2,d+2),...,(n-d,n) -> n-d+1-1 = n-d通り
        // (n,n-d),...,(d+1,1) -> n-d-1+1 = n-d通り
        // ∴2*(n-d), これがm-1個のペア存在するため乗算する。
        cout << (long double)2.0*(n-d)/n*(m-1)/n << endl;
    }
}

Measured memory_bytes: 3812
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... U> void assign(V<T>& v, int n, const U&... u) { v.resize(n); for (auto&& i : v) assign(i, u...); }

int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  int n; cin >> n;
  V< pair<int, int> > x(n);
  for (int i = 0; i < n; i++) {
    int xt; cin >> xt, xt--;
    x[i] = {xt, i};
  }
  sort(x.begin(), x.end());
  V<> a(n * n);
  for (int i = 0; i < n; i++) a[x[i].first] = x[i].second + 1;
  int p = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < x[i].second; j++) {
      while (a[p]) p++;
      a[p] = x[i].second + 1;
    }
  }
  p = n * n - 1;
  for (int i = n - 1; i >= 0; i--) {
    for (int j = 0; j < n - 1 - x[i].second; j++) {
      while (a[p]) p--;
      a[p] = x[i].second + 1;
    }
  }
  V<> b(n * n), c(n + 1);
  for (int i = 0; i < n * n; i++) b[i] = c[a[i]]++;
  for (int i = 0; i < n; i++) if (b[x[i].first] != x[i].second) return cout << "No" << '\n', 0;
  cout << "Yes" << '\n';
  for (int i = 0; i < n * n; i++) cout << a[i] << (i != n * n - 1 ? ' ' : '\n');
}

Measured memory_bytes: 3200
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long N = sc.nextInt();
		long M = sc.nextInt();
		long num = 0;
		if(M==1 && N==1)num = 1;
		else if(M>=3 && N==1)num = M-2;
		else if(M==1 && N>=3)num = N-2;
		else if(M==2 || N==2)num = 0;
		else num = N*M - 2*(N+M-2);
		System.out.println(num); 		
	}
}
	

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int main() {
    int c[3][3];
    for (int i = 0; i < 3; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            cin >> c[i][j];
        }
    }

    int a[3], b[3];
    a[0] = 0;
    for(int i = 0; i < 3; i++) b[i] = c[0][i];
    a[1] = c[1][0] - b[0], a[2] = c[2][0] - b[0];

    for (int i = 0; i < 3; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            if(c[i][j] != a[i] + b[j]) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 256
#include<vector>
#include<list>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int i,j;
  int h,b;
  string r,a;
  while(cin>>r>>a&&r!="0"&&a!="0"){
    h=b=0;
    for(i=0;i<4;i++){
      for(j=0;j<4;j++){
	if(r[i]==a[j])
	  b++;
      }
    }	  
    for(i=0;i<4;i++){
      if(r[i]==a[i]){
	h++;
	b--;
      }
    }
    cout<<h<<" "<<b<<endl;
  }
  return 0;
}

Measured memory_bytes: 912
//  s.at(0) = toupper(s.at(0));//小文字なら大文字へ//大文字の場合はそのまま
//  s.at(i) = tolower(s.at(i));//大文字なら小文字へ//小文字の場合はそのまま
//  string s;
//  cin >> s;
//  cout << s.at(0) <<endl;
//  cout << s.at(0)-'0' <<endl;
//  Aが16？
//  cout << char(i+48) << endl;//なぜかaは47と得る時がある。+48で出力もaにできる。
//  cout << char(97) << endl;//アスキーコードでaを出力
// sort(b.begin(), b.end());//bという配列を小さい方からソート
// reverse(b.begin(), b.end());//bという配列をリターン
// 10桁でdouble出力するパターン１ 
// printf("%.10f\n", ma);
// 10桁でdouble出力するパターン２
//cout << fixed << setprecision(10);
//  cout << ma << endl;

/*01 02 03 12 13 23　と６回見ていくパターン 
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    }
  }
*///vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#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() {
  int n;
  cin >> n;
  vector<int>a(n);
  rep(i,n) cin >> a.at(i);
  int sum = 0;
  rep(i,n) sum += a.at(i);
  if(sum%10!=0){
    cout << sum << endl;
    return 0;
  }
  else {
    int flag = 0;
    sort(a.begin(),a.end());
    rep(i,n){
      if(a.at(i)%10!=0){
        sum -= a.at(i);
        flag = 1;
        break;
      }
    }
    if(flag==1)	cout<<sum<<endl;
    else  		cout<< 0 <<endl;
  }
}

Measured memory_bytes: 3636
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector< vector<int> > Mat;
typedef tuple<int, int, int, int> T;

const int MOD = (int)1e9+7;
const int INF = (int)1e9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

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

    int N;
    cin >> N;
    vector<int> L(N);
    rep(i, N) cin >> L[i];

    sort(L.begin(), L.end());

    int total = 0;
    rep(i, N-1){
        total += L[i];
    }
    if(L[N-1] < total) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256