akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine();
        String[] num = line.split(" ");
        long n = Long.parseLong(num[0]);
        long x = Long.parseLong(num[1]);
        long result = n; //真横にx、反射してn-xまでは確定なので、合計値のnを初期値とする。
        long divisor;
        long divided;
        if(n-x > x){
            divided = n-x;
            divisor = x;
        } else {
            divided = x;
            divisor = n-x;
        }
        long a;
        while(true){
            result = result + 2 * divisor * (divided / divisor);
            if(divided % divisor == 0){
                result = result - divisor;
                break;
            }
            a = divided;
            divided = divisor;
            divisor = a % divisor;
        }
        System.out.println(result);
    }
}


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

int main(){
    string s;
    cin >> s;

    if(((s[0]==s[1]) && (s[0]==s[2])) ||  ((s[1]==s[2]) && (s[2]==s[3]))) 
    {
        cout << "Yes" << endl;
    }
    else
    cout << "No" << endl;
}


Measured memory_bytes: 3612
//  SMOKE SHISHA PLAY FIFA  // 
#include<bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef long double ld;

#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pll pair<ll,ll>
#define MP make_pair
#define ff first
#define ss second
#define PB push_back
#define mod 1000000007
#define lp(i,start,end) for(ll i=start;i<=end;i++) 
#define deb1(a) cout<<#a<<" = "<<(a)<<endl;
#define deb2(a,b) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<endl;
#define deb3(a,b,c) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;


ll modu(ll a, ll b)
{
	ll ans =1;
	while(b>0)
	{
		if(b&1)
		ans = (ans*a)%mod;
		b/=2;
		a = (a*a)%mod;
	}
	return ans;
}

int main()
{
	fastio
	ll h,w;
	cin>>h>>w;
	ll dp[h+1][w+1]={0};
	dp[1][1]=1;
	char grid[h+1][w+1];
	lp(i,1,h)
		lp(j,1,w){
			cin>>grid[i][j];
		}
	lp(i,1,h)
		lp(j,1,w){
			if(grid[i][j]=='.'){
				if(i>1)
					dp[i][j]+=dp[i-1][j];
				if(j>1)
					dp[i][j]+=dp[i][j-1];
				dp[i][j]=dp[i][j]%mod;
				}	
		}
	cout<<dp[h][w]<<endl;

	return 0;	
}


Measured memory_bytes: 12440
def num2alpha(num):
    if num <= 26:
        return chr(64 + num)
    elif num % 26 == 0:
        return num2alpha(num // 26 - 1) + chr(90)
    else:
        return num2alpha(num // 26) + chr(64 + num % 26)


# input
N = int(input())

# check
print(num2alpha(N).lower())

Measured memory_bytes: 9172
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef double dd;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef pair<ll , ll> lli;
typedef vector<ii> vii;
typedef vector<il> vil;
typedef vector<li> vli;
typedef vector<lli> vlli;
 
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define in insert
#define f0(b) for(int i=0;i<(b);i++)
#define f00(b) for(int j=0;j<(b);j++)
#define f1(b) for(int i=1;i<=(b);i++)
#define f11(b) for(int j=1;j<=(b);j++)
#define f2(a,b) for(int i=(a);i<=(b);i++)
#define f22(a,b) for(int j=(a);j<=(b);j++)
#define sf(a) scanf("%lld",&a)
#define sff(a,b) scanf("%lld %lld", &a , &b)
#define pf(a) printf("%lld\n",a)
#define pff(a,b) printf("%lld %lld\n", a , b)
#define PI 3.14159265359
#define bug printf("**!\n")
#define mem(a , b) memset(a, b ,sizeof(a))
#define front_zero(n) __builtin_clzll(n)
#define back_zero(n) __builtin_ctzll(n)
#define total_one(n) __builtin_popcountll(n)

const ll mod = (ll)100000007;
const ll maxn = (ll)1005;
const int nnn = 1048590;
const int inf = numeric_limits<int>::max()-1;
//const ll INF = numeric_limits<ll>::max()-1;
const ll INF = 1e18;

ll dx[]={0,1,0,-1};
ll dy[]={1,0,-1,0};
ll dxx[]={0,1,0,-1,1,1,-1,-1};
ll dyy[]={1,0,-1,0,1,-1,1,-1};

ll a,b,c,d,fun,last;
map < ll , ll > m;
bool amt(ll pro){
	if(last >= pro) return 1;
	else return 0;
}
ll dp(ll n, ll p){
	if(n == 0) return 0;
    if(m[n] != 0) return m[n];
    ll ans = INF;
    for(ll i = n-5; i <= n+5; i++){
    	if(i < 0) continue;
    	ll diff = abs(i-n);
    	if(i == 0){
    		ans = min(ans , diff*d);
    		continue;
		}
		if(i == p) continue; 
		if(i%2 == 0){
			if(i/2 == n) continue;
			ll kt = i/2;
			ll h = a;
			if(amt(kt)) h = (kt)*d; 
			ans = min(ans , ((diff*d) + min( a , h  ) ) + dp(i/2 , n));
		}
		if(i%3 == 0){
			if(i/3 == n) continue;
			ll kt = 2*(i/3);
			ll h = b;
			if(amt(kt)) h = (kt)*d; 
			ans = min(ans , ((diff*d) + min( b ,h)  ) + dp(i/3 , n) );
		}
		if(i%5 == 0){
			if(i/5 == n) continue;
			ll kt = 4*(i/5);
			ll h = c;
			if(amt(kt)) h = (kt)*d; 
			ans = min(ans , ((diff*d) + min( c , h ) )  + dp(i/5 , n));
		}
	} 
	//cout << n << ' ' << ans << '\n';
	return m[n] = ans;
}

void solve(){ 
    cin >> fun >> a >> b >> c >> d;
    m.clear();
    m[1] = d;
    m[2] = min((d+a) , 2*d);
    m[3] = min( m[2]+d , min(3*d , d + b));
    m[4] = min( min(4*d , d+2*a) , m[3]+d);
    m[5] = min( min(5*d , 2*(d+a)) , min(d+c , 3*d + b));
    last = (fun/d)+1;
    cout << dp(fun, -1) << '\n';
	return;
}


int main() {
   
    //ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
    ll T;
    T=1;
    cin >> T;
    //scanf("%lld",&T);
    //ll CT = 0;
    //work();
    while(T--){
    	//cout << "Case " << ++CT <<": " ;
    	//printf("Case %lld: ",++CT);
		solve();
    	
    	
	}
    
    return 0;
}



Measured memory_bytes: 7100
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <iomanip>
#include <cmath>
#include <queue>
#include <deque>
#include <stack>
#include <stdio.h>
#include <cstring>
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2")
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
typedef long double ld;
typedef long long ll;
typedef double db;
#define endl '\n'
#define pb push_back
#define pii pair<ll, ll>
#define ff first
#define ss second
#define sz(x) (ll)(x).size()
#define optimize1() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#pragma warning(disable:4996)

using namespace std;
const int MX = 2e5 + 1e3;

int a[MX], sp[MX];
int n;

bool check(int x)
{
	int i;
	map<int, int>mp;

	for (i = 1; i <= n; i++)
	{
		if (a[i] <= a[i - 1])
		{
			while (!mp.empty())
			{
				int t = mp.rbegin()->first;
				if (t > a[i])
					mp.erase(t);
				else
					break;
			}
			int j = a[i];
			while (mp[j] + 1 == x) {
				mp.erase(j);
				j--;
			}

			if (j == 0)
				return 0;
			mp[j]++;
		}
	}
	return 1;
}

signed main() {
    optimize1();

	cin >> n;
	bool ppp = 0;
	for (int i = 1; i <= n; i++)
	{
		cin >> a[i];
		if (a[i] <= a[i - 1])ppp = 1;
	}

	if (ppp == 0) {
		cout << 1 << endl;
		return 0;
	}

	int l = 2, r = n;
	while (l < r)
	{
		int m = (l + r) / 2;
		if (check(m))
			r = m;
		else 
			l = m + 1;
	}
	cout << l << endl;
	return 0;
}

Measured memory_bytes: 4432
from heapq import *

an, bn, cn, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)

ans = []
hp = [[-(a[0] + b[0] + c[0]), 0, 0, 0]]
heapify(hp)
sumi = {(0, 0, 0)}
for _ in range(k):
    hpk = heappop(hp)
    mx = hpk[0]
    ai = hpk[1]
    bi = hpk[2]
    ci = hpk[3]
    if ai + 1 < an and (ai + 1, bi, ci) not in sumi:
        heappush(hp, [mx + a[ai] - a[ai + 1], ai + 1, bi, ci])
        sumi.add((ai + 1, bi, ci))
    if bi + 1 < bn and (ai, bi + 1, ci) not in sumi:
        heappush(hp, [mx + b[bi] - b[bi + 1], ai, bi + 1, ci])
        sumi.add((ai, bi + 1, ci))
    if ci + 1 < cn and (ai, bi, ci + 1) not in sumi:
        heappush(hp, [mx + c[ci] - c[ci + 1], ai, bi, ci + 1])
        sumi.add((ai, bi, ci + 1))
    ans += [-mx]
print(*ans, sep="\n")


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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

const int MAX_P = 1000000+1;
bool isprime[MAX_P];

void make_prime(){
	fill(isprime,isprime+MAX_P, true);
	isprime[0] = isprime[1] = false;
	for(int i=2;i<MAX_P;i++){
		while(!isprime[i]) i++;
		for(int j=i*2;j<MAX_P;j+=i) isprime[j] = false;
	}

}

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}


int main() {
	int n;
	cin >> n;
	ll a[n];
	for(int i=0;i<n;i++) cin >> a[i];

	ll mod = 1e9+7;
	static map<int, int> lcm;
	
	make_prime();
  	
	for(int p=2;p*p<=MAX_P;p++){
		while(!isprime[p]) p++;
		lcm[p] = 0;
	}
	
	for(int i=0;i<n;i++){
		ll tmp = a[i];
		for(int p=2;p*p<=MAX_P;p++){
			while(!isprime[p]) p++;
			int m = 0;
			while(tmp%p == 0){
				tmp/=p;
				m++;
			}
			lcm[p] = max(lcm[p], m);
		}
		if(isprime[tmp]){
			lcm[tmp] = 1;
		}
	}

	ll lcm2 = 1;
	for(int p=2;p<=MAX_P;p++){
		while(!isprime[p]) p++;
		lcm2 *= pow(p, lcm[p]);
		lcm2 %= mod;
	}

	ll ans = 0;
	for(int i=0;i<n;i++){
		ll b = lcm2 * modinv(a[i], mod);
		b %= mod;
		ans += b;
		ans %= mod;
	}
	cout << ans << endl;
	
	return 0;
}

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

typedef long long ll;

struct tree_distance{
    int n;
    vector<vector<int>> g;
    vector<int> d;
    int s;
    tree_distance(int _n,int _s){
        n = _n;
        g.resize(n);
        d.resize(n);
        for (int i = 0; i < n; ++i)
        {
            d[i] = -1;
        }
        s = _s;
    }
    void add(int a,int b){
        g[a].push_back(b);
    }
    void init(){
        dfs(s,0);
    }
    void dfs(int x,int dis){
        d[x] = dis;
        for(int i : g[x]){
            if(d[i] < 0){
                dfs(i,dis+1);
            }
        }
    }
};

int main(int argc, char const *argv[])
{
    int n;cin >> n;
    tree_distance A(n,0),B(n,n-1);
    for (int i = 0; i < n-1; ++i)
    {
        int a,b;cin >> a >> b;
        a--,b--;
        A.add(a,b);A.add(b,a);
        B.add(a,b);B.add(b,a);
    }
    A.init();B.init();
    int cnt = 0;
    for (int i = 0; i < n; ++i)
    {
        if(A.d[i] <= B.d[i])cnt++;
    }

    if(cnt > n - cnt){
        cout << "Fennec" << endl;
    }else{
        cout << "Snuke" << endl;
    }
    return 0;
}

Measured memory_bytes: 14208
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
using namespace std;

int main() {
  int cnt=0;
  int A, B, K;
  int memo=0;
  int Kcnt=1;
  int ans =0;

  cin >> A >> B >> K;

  //Aを割り切れる数の探索->Amに格納
  vector<int> Am(A);
  for(int i = 1; i <= A; i++){
    if(A%i == 0){
      Am[cnt] = i;
      cnt++;
    }
  }

  //Bを割り切れる数の探索
  //見つけたらAmの数と比較->同じのがあればKcnt++
  //K == Kcntなら終了
  int lpflg =0;
  vector<int> kcnt(A+B);
  for(int i = 1; i <= B; i++){
    if(B%i == 0){
      for(int j = 0; j < cnt; j++){
        if(i == Am[j]){
          kcnt[Kcnt] = i;
          Kcnt++;
        }
      }
    }
  }
  
  cout << kcnt[Kcnt-K] << endl;

}


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

long long max(long long A,long long B){
    return A>B?A:B;
}

long long min(long long A,long long B){
    return A<B?A:B;
}

int main(void){
    long long n,m;
    scanf("%lld%lld",&n,&m);
    long long l,r,A=n+1,B=-1;
    for (int i=0; i<m; i++){
        scanf("%lld%lld",&l,&r);
        if (l>A || r<B){
            printf("0\n");
            return 0;
        }
        
        A=min(A,r);
        B=max(B,l);
    }
    printf("%lld\n",A-B+1);
    return 0 ;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
using namespace std;
using ll = long long;
int main(){
    while(1){
        ll n,ans=-10000000000;
        cin >> n;
        if(n==0)    break;
        vector<ll> a(n);
        for(ll i=0;i<n;i++) cin >> a[i];
        for(ll i=0;i<n;i++){
            ll sum=0;
            for(ll j=i;j<n;j++){
                sum+=a[j];
                ans = max(sum,ans);   
            }
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3036
import sys
import math
def get_array(): return list(map(int, sys.stdin.readline().strip().split()))
def get_ints(): return map(int, sys.stdin.readline().strip().split())
def input(): return sys.stdin.readline().strip()
n=int(input())
a=get_array()
arr=a[0]
ans=0
for i in range(n-1):
    if a[i+1]<arr:
        ans+=(arr-a[i+1])
    else:
        arr=a[i+1]
print(ans)

Measured memory_bytes: 94032
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstdio>
using namespace std;

#define loop(i, n) for (int i = 0; i < n; i++)
#define INF 1010001000

typedef long long int ll;

ll tr(string a);
bool cl(string a);
int c3(ll a);
int solve(string st);

int main()
{
    string input;
    cin >> input;
    while (input[0] != '0') {
        int ans = solve(input);
        if (ans != INF) {
            cout << ans << endl;
        } else {
            cout << "NA" << endl;
        }
        cin >> input;
    }
    return 0;
}

int solve(string st)
{
    int ans = 0;
    vector<bool> check(1048576, false);
    queue<string> a, b, c;
    if ( cl(st) ) {
        return ans;
    }
    a.push(st);
    while (!a.empty()) {
        while (!a.empty()) {
            st = a.front();
            a.pop();
            if (check[c3(tr(st))]) {
                continue;
            } else {
                check[c3(tr(st))] = true;
                //cout << c3(tr(st)) << endl;
            }
            if (cl(st)) {
                return ans;
            }
            for (int i = 1; i < st.size(); i++) {
                if (st[i-1] != st[i]) {
                    string nw(st);
                    if (st[i-1] != 'r' && st[i] != 'r') {
                        nw[i-1] = 'r';
                        nw[i] = 'r';
                    } else if (st[i-1] != 'g' && st[i] != 'g') {
                        nw[i-1] = 'g';
                        nw[i] = 'g';
                    } else if (st[i-1] != 'b' && st[i] != 'b') {
                        nw[i-1] = 'b';
                        nw[i] = 'b';
                    }
                    b.push(nw);
                }
            }
        }
        a = b;
        b = c;
        ans++;
    }
    return INF;
}

ll tr(string a)
{
    ll ret = 0;
    for (int i = 0; i < a.size(); i++) {
        ret *= 10;
        if (a[i] == 'r') {
            ret += 1;
        } else if (a[i] == 'g') {
            ret += 2;
        } else {
            ret += 3;
        }
    }
    return ret;
}

bool cl(string a)
{
    for (int i = 1; i < a.size(); i++) {
        if (a[i-1] != a[i]) {
            return false;
        }
    }
    return true;
}

int c3(ll a)
{
    int ret = 0;
    if (a) {
        ret = c3(a / 10);
        ret *= 4;
        ret += a % 10;
    }
    return ret;
}

Measured memory_bytes: 4084
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
#define pb push_back
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
const double PI=acos(-1);
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

void solve(){
    ll n; cin >> n;
    vector<ll> a(n);
    REP(i, n) cin >> a[i];
 
    ll res = 1000000000;

    for(int i=-100; i<=100; i++){
        ll sum = 0;
        REP(j, n){
            
            sum += (a[j] - i)*(a[j] - i);
        
        }
        res = min(res, sum);
    }
    cout << res << endl;
}

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

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

#include <bits/stdc++.h>

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

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

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

// モジュール


// 処理内容
int main() {
    
    ll n, k; cin >> n >> k;
    ld ans = 0;

    vector<ld> dp(k+1, 0);
    RANGE(i, 1, n) {
        ll tn = 0;
        ll t = i;
        ld prob = 1.L / n;
        while (t < k) {
            t *= 2;
            tn++;
            prob /= 2;
        }
        ans += prob;
    }
    cout << setprecision(20) << ans << endl;
    
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ull = uint64_t;
using ll = int64_t;
using ld = long double;

const int N = 400228;
ll a[N];
ll s[N];

ll ans = 0;

void gbest(int lg, int len, int rg, ll pos) {
    int lp = lg + len;
    int rp = rg - len;

    ll sl = 0, sr = 0;
    ll dr = a[rg - 1] - pos;
    ll dl = pos - a[lg];

    if (dr > dl) {
        sl += dl;
    } else {
        sr -= dr;
    }

    ll cl = s[lp] - s[lg];
    ll cr = s[rg] - s[rp];
    sl += cl * 2;
    sr += cr * 2;

    ans = max(ans, sr - sl);
}

ll eval(int lg, int rg, ll pos) {
    int md = lower_bound(a + lg, a + rg, pos) - a;

    if (md == lg) {
        return a[rg - 1] - pos;
    }

    if (md == rg) {
        return pos - a[lg];
    }

    int lp = md, rp = md;
    ll sl = 0, sr = 0;

    gbest(lg, min(md - lg, rg - md), rg, pos);

    if (md - lg == rg - md) {
        return 0;
    }
    
    if (md - lg > rg - md) {
        lp = lg + (rg - md) + 1;
        sr += pos;
        sl -= a[lg];
    } else {
        rp = rg - (md - lg) - 1;
        sl += pos;
        sr -= a[rg - 1];
    }

    ll cl = s[lp] - s[lg];
    ll cr = s[rg] - s[rp];
    sl += cl * 2;
    sr += cr * 2;
    return sr - sl;
}

void tr(int lg, int rg, ll pos) {
    ans = max(ans, eval(lg, rg, pos));
}

int main() {
#ifdef BZ
    freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cout.setf(ios::fixed); cout.precision(20);
    ll l;
    int n;
    cin >> l >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        a[n + i] = l + a[i];
    }

    s[0] = 0;
    for (int i = 0; i < 2 * n;++i) {
        s[i + 1] = s[i] + a[i];
    }

    tr(0, n, 0);

    for (int i = 0; i < n; ++i) {
        tr(i, i + n, l);
    }

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



Measured memory_bytes: 6528
using System;

namespace _0003
{
    class Program
    {
        static void Main(string[] args)
        {
            var dataCount = int.Parse(Console.ReadLine());

            for (int i = 0; i < dataCount; i++)
            {
                var input = Console.ReadLine();

                if (input != null)
                {
                    string[] parts = input.Split(' ');
                    int[] sides = new int[3];
                    sides[0] = int.Parse(parts[0]);
                    sides[1] = int.Parse(parts[1]);
                    sides[2] = int.Parse(parts[2]);

                    Array.Sort(sides);

                    if ((sides[2] * sides[2]) == (sides[1] * sides[1] + sides[0] * sides[0]))
                    {
                        Console.Write("YES\n");
                    }
                    else
                    {
                        Console.Write("NO\n");
                    }
                }
            }
        }
    }
}

Measured memory_bytes: 5556
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<bits/stdc++.h>
#include<stack>
#include<queue>
#include<list>
#include<vector>
#include<bitset>
#include<unordered_map> 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
// #include "boost/algorithm/string.hpp"
#define fio ios_base::sync_with_stdio(false)
#define mod 1000000007
#define mod1 mod
#define mod2 100000009
#define li long long int
#define ll li
#define readi(x) scanf("%d",&x)
#define  reads(x)  scanf("%s", x)
#define readl(x) scanf("%I64d",&x)
#define rep(i,n) for(i=0;i<n;i++)
#define revp(i,n) for(i=(n-1);i>=0;i--)
#define myrep1(i,a,b) for(i=a;i<=b;i++)
#define myrep2(i,a,b) for(i=b;i>=a;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define MAXN 1000000000000000000
#define MINN -1000000000000000000
#define INTMAX 1000001000
#define pii pair<ll,ll> 
#define pdd pair<double,double>
#define pic pair<int,char>
#define N 2000010
#define lgn 20
#define ddouble long double
#define minus minu
#define PI 3.1415926535
#define lgn 20
 
 
// #define INTMAX 200000000 
 
// using namespace boost;
// #define si short int
 
using namespace std;
using namespace __gnu_pbds;             
typedef priority_queue<pii, vector<pii> ,greater < pii > > min_pq;
// typedef priority_queue<pii, vector<pii> , greater<pii >  > min_pq;
ll toint(const string &s) {stringstream ss; ss << s; ll x; ss >> x; return x;}
string tostring ( ll number ){stringstream ss; ss<< number; return ss.str();}
 
// using namespace __gnu_pbds;         
// typedef priority_queue<pair<ll,char> , vector<pair<ll , char> > > max_pq;
// typedef priority_queue<pii , vector<pii > ,greater<pii > > min_pq;
typedef tree<pii , null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> OST;
// typedef priority_queue<pair < ll , pair < pii , ll > >  , vector<pair < ll , pair < pii , ll > >  > ,greater<pair < ll , pair < pii , ll > >  > > min_pq;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << std::endl;
        //use cerr if u want to display at the bottom
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif
#define nn 2000005
ll n;
ll ar[ N ];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    // #endif
    ll k;
    cin >> n >> k;
    ll sum = 0;
    for ( ll i = 1; i <= n; i ++)
        cin >> ar[i], sum += ar[i];
    sort(ar+1,ar+n+1);
    if ( sum == k )
    {
        cout << n;
        return 0;
    }
    if ( sum < k )
    {
        cout << n-1;
        return 0;
    }
    sum = 0;
    ll cnt = 0;
    for ( ll i = 1; i <= n; i ++)
        if ( (sum+ar[i])<= k )
            sum += ar[i],cnt++;
    cout << cnt;
}

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  string S;
  cin >> S;

  while(SZ(S) > 3){
	string tmp;
	vector<bool> use(3);
	for(int i=0;i<SZ(S);){
	  if(i+3 <= SZ(S) && S.substr(i,3) == "ABC"){
		i += 3;
		tmp += "!";
	  }
	  else{
		use[S[i]-'A'] = true;
		tmp += S[i];
		++i;
	  }
	}
	if(count(ALL(use),true) != 2)
	  break;
	int ix;
	REP(i,3) if(!use[i]) ix = i;
	S = "";
	REP(i,SZ(tmp))
	  if(tmp[i] == '!')
		S += 'A' + ix;
	  else
		S += tmp[i];
  }
  cout << (S=="ABC"? "Yes": "No") << endl;

  return 0;
}

Measured memory_bytes: 3232
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define req(i,n) for(long long i=n-1; i>=0; i--)
#define range(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define onBoard(y,x) (y>=0 && y<h && x>=0 && x<w)
#define vint vector<int>
#define pri_que priority_queue
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a/gcd(a,b)*b;}
const long long dx[8]={1,0,-1,0,1,-1,-1,1};
const long long dy[8]={0,1,0,-1,1,1,-1,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    int h,w; cin >> h>> w;
    vector<vector<char>> s(h+2,vector<char>(w+2,'.'));
    range(i,1,h+1){
        range(j,1,w+1){
            cin >> s[i][j];
        }
    }

    int i=1,j=1;
    while(true){
            if(i==h && j==w && s[i][j]=='#'){
                rep(k,4){
                    if(s[i+dy[k]][j+dx[k]]=='#'){
                        cout<<"Impossible"<<endl;
                    return 0;
                    }
                }
                cout<<"Possible"<<endl;
                return 0;
            }
            bool l=false,r=false,u=false,d=false;
            if(s[i][j+1]=='#') r=true;
            if(s[i][j-1]=='#') l=true;
            if(s[i+1][j]=='#') d=true;
            if(s[i-1][j]=='#') u=true;

            if(l==1 || u==1 || (r==1&&d==1)){
                cout<<"Impossible"<<endl;
                return 0;
            }
            s[i][j]='.';
            if(r==1) j++;
            if(d==1) i++;
        
    }
}

Measured memory_bytes: 3620
#include <iostream>
#include <vector>

using namespace std;

#define dump(n) cerr<<"# "<<#n<<"="<<(n)<<endl
#define rep(i,n) for(int i=0;i<n;i++)

typedef vector<string> vs;

int main()
{
	for(int r,c,w,b;cin>>r>>c>>w>>b;){
		cin.get();
		
		vs lines;
		for(string s;getline(cin,s),s!="?";){
			if(s=="")
				s+='.';
			while(s.size()%w)
				s+='.';
			for(int i=0;i<s.size();i+=w)
				lines.push_back(s.substr(i,w));
		}
		while(lines.size()%(r*c))
			lines.push_back(string(w,'.'));
		for(int i=0;i<lines.size();i+=r*c){
			rep(j,r) rep(k,c)
				cout<<lines[i+j+k*r]<<(k==c-1?"\n":string(b,'.'));
			cout<<'#'<<endl;
		}
		cout<<'?'<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <iostream>

using namespace std;

int SumDigits(int n) {
    int sum = 0;
    while (n > 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}


int main() {
    int n;  cin >> n;
    if (SumDigits(n) == 1) {
        cout << 10 << endl;
    } else {
        cout << SumDigits(n) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
/**
 * File    : C.cpp
 * Author  : Kazune Takahashi
 * Created : 2018-7-9 22:57:40
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <functional>
#include <random> // auto rd = bind(uniform_int_distribution<int>(0, 9), mt19937(19920725));
#include <chrono> // std::chrono::system_clock::time_point start_time, end_time;
// start = std::chrono::system_clock::now();
// double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

int N;
ll L[100010];
ll imos_L[100010];
ll R[100010];
ll imos_R[100010];

int main()
{
  cin >> N;
  for (auto i = 0; i < N; i++)
  {
    cin >> L[i] >> R[i];
    R[i] = -R[i];
  }
  sort(L, L + N);
  reverse(L, L + N);
  sort(R, R + N);
  reverse(R, R + N);
  imos_L[0] = 0;
  imos_R[0] = 0;
  for (auto i = 0; i < N; i++)
  {
    imos_L[i + 1] = imos_L[i] + L[i];
    imos_R[i + 1] = imos_R[i] + R[i];
  }
  ll ans = 0;
  for (auto i = 0; i <= N; i++)
  {
    for (auto j = i - 1; j <= i + 1; j++)
    {
      if (0 <= j && j <= N)
      {
        ans = max(ans, imos_L[i] + imos_R[j]);
      }
    }
  }
  cout << 2 * ans << endl;
}

Measured memory_bytes: 3328
using System;

class Program
{
    static void Main(string[] args)
    {
        var nl = Console.ReadLine().Split();
        var n = int.Parse(nl[0]);
        var l = int.Parse(nl[1]);

        var min = int.MaxValue;
        var sum = 0;
        for (int i = 0; i < n; i++)
        {
            sum += l + i;
            if (Math.Abs(l + i) < Math.Abs(min))
            {
                min = l + i;
            }
        }

        Console.WriteLine(sum - min);
    }
}


Measured memory_bytes: 11092
#include <stdio.h>
#include <vector>
#include <stack>
#include <functional>
#include <numeric>
#include <complex>
#include <queue>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <unordered_set>
#include <assert.h>
#include <cstring>
#include <sstream>
#include <string>
#include <algorithm>
#include <iostream>
 
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define X first
#define Y second
#define pb(x) push_back(x)
#define FOR(k, n) for (int k = 0; k < n; k++)
#define FORN(k, s, n) for (int k = s; k < n; k++)
#define debug(x) printf("%s = %d\n", #x, x)
#define debug2(x, y) printf("%s = %d, %s = %d\n", #x, x, #y, y)
#define debug3(x, y, z) printf("%s = %d, %s = %d, %s = %d\n", #x, x, #y, y, #z, z)
#define debug4(x, y, z, t) printf("%s = %d, %s = %d, %s = %d, %s = %d\n", #x, x, #y, y, #z, z, #t, t)
 
#pragma warning(disable : 6031)
#pragma warning(disable : 4101)
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> pii;
typedef long double ld;
typedef complex<double> cd;
 
const int INF = 1e9;
const long long LINF = 1e18;
const double PI = acos(-1);
 
// Solution

const int MAXN = 100005;

int n, l, r, m, A[MAXN];
vector<int> P;

int main() {
    scanf("%d", &n);

    for (int i = 0; i < n; i++) {
        scanf("%d", &A[i]);
        A[i] = -A[i];
    }

    P = {A[0]};

    for (int i = 1; i < n; i++) {
        if (A[i] >= P.back()) {
            P.push_back(A[i]);
        } else {
            l = 0;
            r = sz(P) - 1;

            while (l != r) {
                m = (l + r) / 2;

                if (P[m] > A[i]) {
                    r = m;
                } else {
                    l = m + 1;
                }
            }

            P[l] = A[i];
        }
    }

    printf("%d\n", sz(P));

    return 0;
}

Measured memory_bytes: 1276
#include<iostream>
#include<cstdio>
using namespace std;
int prime[1000000];
bool is_prime[1000001];

int sieve(int n){
  int p=0;
  for(int i=0;i<=n;i++) is_prime[i]=true;
  is_prime[0]=is_prime[1]=false;
  for(int i=2;i<=n;i++){
    if(is_prime[i]==true){
      prime[p++]=i;
      for(int j=2*i;j<=n;j+=i)is_prime[j]=false;
    }
  }
  return p;
}

int main(){
  int n;
  while(scanf("%d",&n)!=EOF)
    cout<<sieve(n)<<endl;
  return 0;
}

Measured memory_bytes: 2492
N, M = map(int, input().split())
max_L, min_R = 1, N
for i in range(M):
    L, R = map(int, input().split())
    if L > max_L:
        max_L = L
    if R < min_R:
        min_R = R
ans = min_R - max_L + 1
if ans < 0:
    ans = 0
print(ans)

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 59;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

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++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  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<double> v(n);
  rep(i, n) cin >> v[i];
  sort(ALL(v));
  rep(i, n-1) {
    v[i+1] = (v[i]+v[i+1])/2;
  }
  printf("%0.10f\n", v[n-1]);
}

Measured memory_bytes: 3828
#include <bits/stdc++.h>
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
typedef long long int ll;
using namespace std;

int main(){
	int n;cin >> n;
	vector<int> v(n),c(n),a(n);
	cinf(n,v); cinf(n,c);
	int ans=0;

	for(int i=0;i<n;i++){
		a[i]=v[i]-c[i];
	}
	sort(a.begin(),a.end(),greater<int>());
	for(int i=0;i<n;i++){
		if(a[i]>0) ans+= a[i];
	}
	cout << ans << endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<utility>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#define EPS 1e-9
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define LL long long
const int MOD = 1E9+7;
const int N = 100000+5;
const int dx[] = {-1,1,0,0,-1,-1,1,1};
const int dy[] = {0,0,-1,1,-1,1,-1,1};
using namespace std;
 
LL a[N];
LL inv[N];
LL fac[N];
map<LL,int> bucket;
void init() {
    fac[0]=1;
    fac[1]=1;
    inv[0]=1;
    inv[1]=1;
    for(LL i=2; i<N; i++) {
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=(MOD-MOD/i)*inv[MOD%i]%MOD;
    }
    for(int i=1; i<N; i++)
        inv[i]=inv[i]*inv[i-1]%MOD;
}
LL C(LL n, LL m) {
    if(m>n)
        return 0;
    return ((fac[n]*inv[m]%MOD)*inv[n-m])%MOD;
}
int main() {
    init();
    LL n;
    scanf("%lld",&n);
    LL pos=0;
    for(int i=1;i<=n+1;i++){
        scanf("%lld",&a[i]);
        if(!bucket[a[i]])
            bucket[a[i]]=i;
        else
            pos=i;
    }
    for(int i=0;i<=n;i++){
        LL res=0;
        res=(res+C(n+1,i+1))%MOD;
        res=(res-C(n-pos+bucket[a[pos]],i))%MOD;
        while(res<0)
            res+=MOD;
        printf("%lld\n",res);
    }
 
    return 0;
}

Measured memory_bytes: 9856
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
int main() {
  cin.tie(0);
  cout << fixed << setprecision(10);
  string s, t; cin >> s >> t;
  int szs = (int)(s.size()), szt = (int)(t.size());
  s += s;
  map<char, vector<int>> mp;
  for(int i=0;i<szs * 2;++i) {
    mp[s[i]].push_back(i+1);
  }
  ll now = 0;
  for(int i=0;i<szt;++i) {
    if((int)(mp[t[i]].size()) == 0) {
      cout << -1 << endl;
      return 0;
    }
    auto it = upper_bound(mp[t[i]].begin(), mp[t[i]].end(), now%szs);
    ll pos = distance(mp[t[i]].begin(), it);
    now += mp[t[i]][pos] - now%szs;
  }
  cout << now << endl;
}


Measured memory_bytes: 1788
n, m = map(int, input().split())
a = [input() for i in range(n)]
b = "".join([input() for i in range(m)])
ans = "No"
for i in range(n-m+1):
    for j in range(n-m+1):
        s = ""
        for k in range(m):
            s+=a[i+k][j:j+m]
        if s==b:
            ans = "Yes"
print(ans)

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

namespace ConsoleApp69 {
    class Program {
        static long mod = 1000000007;

        static void Main(string[] args) {
            long N = long.Parse(Console.ReadLine());

            Console.WriteLine(FactorialMod(N));
        }

        static long FactorialMod(long N) {
            if (N == 1) {
                return 1;
            }

            return N * FactorialMod(N - 1) % mod;
        }
    }
}


Measured memory_bytes: 12628
n,k=map(int,input().split( ))
ans = 0
#個数で10**100以上の桁の値が一意
#それ未満の桁の値の個数下界から上界が1きざみ
for i in range(k,n+2):
    ans += i*(2*n-i+1)//2-i*(i-1)//2+1
print(ans%(10**9+7))


Measured memory_bytes: 9148
#include <bits/stdc++.h>
#define r(i,n) for(i=0;i<n;i++)
using namespace std;
int main(){
  int a[100],i,j,s=0;
  char c[100];
  r(i,1000000){
    cin>>a[i]>>c[i];
    if(c[i]=='=')break;
  }
  s=a[0];
  r(j,i){
    if(c[j]=='+')s+=a[j+1];
    if(c[j]=='-')s-=a[j+1];
    if(c[j]=='*')s*=a[j+1];
    if(c[j]=='/')s/=a[j+1];
  }
  cout<<s<<endl;
}

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


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
int main()
{
	int n, m;
  	cin >> n >> m;
  	long long a;
  	int b;
  	unsigned long long ans = 0;
  	vector<pair<long long, int>> pairs(n);
  	for (int i = 0; i < n; i++){
    	cin >> a >> b;
      	pairs[i] = make_pair(a, b);
    }
  	sort(pairs.begin(), pairs.end());
  	for (int i = 0; i < n; i++){
    	if (pairs[i].second <= m){
        	ans += pairs[i].first * pairs[i].second;
          	m -= pairs[i].second;
        } else {
        	ans += pairs[i].first * m;
          	break;
        }
    }
  	cout << ans << endl;
}

Measured memory_bytes: 1792
#include <cstdio>
#define ll long long
#define rep(i,j,k) for (i=j;i<=k;i++)
using namespace std;
const int N=1e5+5,mod=1e9+7;
int n,m,i,j,t,x[N];
struct mat{
	int r,c,a[3][3];
	mat operator *(const mat &B)
	{
		mat ret;
		int i,j,k;
		ret.r=r; ret.c=B.c;
		rep(i,0,ret.r-1)
			rep(j,0,ret.c-1) ret.a[i][j]=0;
		rep(i,0,ret.r-1)
			rep(j,0,ret.c-1)
				rep(k,0,c-1)
					ret.a[i][j]=(ret.a[i][j]+(ll)a[i][k]*B.a[k][j])%mod;
		return ret;
	}
}A,B,ans;
mat fgm(const mat &A,int n)
{
	mat ret=A,bsc=A;
	for (n--;n>0;n>>=1,bsc=bsc*bsc)
		if (n&1) ret=ret*bsc;
	return ret;
}
int main()
{
//	freopen("square.in","r",stdin);
//	freopen("square.out","w",stdout);
	scanf("%d%d",&n,&m);
	rep(i,1,m) scanf("%d",&x[i]);
	A.r=A.c=B.r=B.c=3;
	rep(i,0,2) rep(j,0,2) A.a[i][j]=B.a[i][j]=1;
	A.a[1][0]=A.a[1][2]=A.a[2][2]=B.a[1][0]=2;
	A.a[0][1]=B.a[0][1]=B.a[0][2]=B.a[1][2]=0;
	x[0]=-1; x[m+1]=n; ans.r=3; ans.c=1; ans.a[0][0]=1;
	rep(i,1,m+1)
	{
		t=x[i]-x[i-1]-1;
		if (t) ans=fgm(A,t)*ans;
		if (i<=m) ans=B*ans;
	}
	printf("%d\n",ans.a[2][0]);
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N; cin >> N;
  vector<int> p;
  for (int i = 0; i < N; i++) {
    int x; cin >> x; p.push_back(x);
  }
  sort(p.begin(), p.end());
  int res = 0;
  for (int i = 0; i < N-1; i++) {
    res += p[i];
  }
  res += (p[N-1]/2);
  cout << res << endl;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
s = []
for i in range(M):
    s.append(list(map(int, input().split())))
p = list(map(int, input().split()))

ans = 0
for i in range(2**N):
    Flg = True
    for j in range(M):
        cnt = 0
        for k in range(1, s[j][0]+1):
            if((i>>(s[j][k]-1))&1):
                cnt += 1
        if(cnt%2 != p[j]):
            Flg = False
    if(Flg):
        ans += 1        
print(ans)   

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

#define rep(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ROF(i,a,b) for(int i=(a);i>(b);i--)
#define all(a) (a).begin(),(a).end()
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumlate(all(a),0)
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef long long ll;

int main(){
  ll n,m; cin >> n >> m;
  ll ans = 0;
  if(2*n > m) ans = m / 2; // cが足りない
  else{
    ans = n;
    m -= 2*n;
    ans += m / 4;
  }
  cout << ans << endl;
}


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

using namespace std;

using uint = unsigned int;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)
#define dbg_p(x) cerr<<#x": "<<(x).first<<' '<<(x).second<<endl
#define dbg_v(x, n) {cerr<<#x"[]: ";for(long long _=0;_<n;++_)cerr<<(x)[_]<<' ';cerr<<endl;}
#define all(v) v.begin(), v.end()
#define fi first
#define se second
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}
 
template<typename T1, typename T2>
ostream& operator <<(ostream &out, const pair<T1, T2> &item) {
	out << '(' << item.first << ", " << item.second << ')';
	return out;
}
 
template <typename T>
ostream& operator <<(ostream &out, const vector<T>& v) {
	for(const auto &item : v) out << item << ' ';
	return out;
}

ll zeros, n, k, V[300005];

void flip()
{
	reverse(V+1, V+n+1);
	for (int i=1; i<=n; i++)
		V[i] *= -1;
}

ll cautBin(ll st, ll dr, ll x, ll prod)
{
	ll inist = st, inidr = dr;
	while (st <= dr)
	{
		ll mijl = (st+dr)/2;
		if (x * V[mijl] <= prod)
			st = mijl + 1;
		else
			dr = mijl - 1;
	}

	if (st <= inidr && x * V[st] <= prod)
		return st;

	if (inist <= dr && x * V[dr] <= prod)
		return dr;

	return -1;
}

ll compute(ll prod, ll &inter)
{
	ll tot = 0, firstMinus = 1e18;

	for (int i=1; i<=n; i++)
		if (V[i] < 0)
			firstMinus = i;

	for (int i=2; i<=n; i++)
	{
		ll x = V[i];
		if (x < 0)
			continue;

		ll poz = cautBin(1, i-1, x, prod);

		if (poz == -1) 
			continue;

		inter += min(poz, firstMinus);
		tot += poz;
	}
	return tot;
}

bool check(ll prod)
{
	ll inter1 = 0, inter2 = 0;

	ll tot = compute(prod, inter1);
	flip();
	tot += compute(prod, inter2);
	flip();

	//assert(inter1 == inter2);

	tot -= min(inter1, inter2);

	if (prod >= 0)
		tot += n * zeros + zeros * (zeros-1) / 2;
	return tot >= k;
}

int main()
{
	ios_base::sync_with_stdio(false);

	vector<ll> A;
	cin>>n>>k;
	for (int i=1; i<=n; i++)
	{
		ll x;
		cin>>x;
		if (x != 0)
			A.push_back(x);
		else
			zeros++;
	}

	for (int i=0; i<A.size(); i++)
		V[i+1] = A[i];
	n = A.size();

	sort(V+1, V+n+1);

	ll st = -1e18, dr=1e18;
	while (st <= dr)
	{
		ll mijl = (st + dr)/2;
		if (check(mijl))
			dr = mijl - 1;
		else
			st = mijl + 1;
	}
	if (check(dr))
		cout<<dr;
	else
		cout<<st;
	cout<<'\n';
	return 0;
}

Measured memory_bytes: 3184
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline

##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)

##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順

# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順

##### 無限 #####
# inf = float('inf')

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))

inf = float('inf')

def main():
	A,B,C = inputMap()

	if A == B:
		if A != C:
			print("Yes")
			sys.exit()
	elif A == C:
		if A != B:
			print("Yes")
			sys.exit()
	elif B == C:
		if A != B:
			print("Yes")
			sys.exit()

	print("No")

if __name__ == "__main__":
	main()


Measured memory_bytes: 38256
import java.util.Scanner;

public class Main {

  /**
   * @param args
   */
  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    String f[] = sc.next().split("");
    String a[] = sc.next().split("");

    int count = 0;
    for (int i = 0; i < 3; i++) {
      if (f[i].equals(a[i])) {
        count++;
      }
    }

    System.out.println(count);
  }

}


Measured memory_bytes: 22996