akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;
 
int map[5][5];
 
int all(int ax,int ay,int bx,int by){
    for( int i = ax ; i <= bx ; i++ ){
	for( int j = ay ; j <= by ; j++ ){
	    if(! map[i][j]) return 0; 
	}
    }
    return 1;
}
 
int main(){
    int m;
    int max;
 
    cin >> m;
    for( int o = 0 ; o < m ; o++ ){
	max = 0; 
	for( int i = 0 ; i < 5 ; i++ ){
	    for( int j = 0 ; j < 5 ; j++ ){
		cin >> map[i][j];    
	    }
	}
 
	for( int i = 0 ; i < 5 ; i++ ){
	    for( int j = 0 ; j < 5 ; j++ ){
		for( int k = i ; k < 5 ; k++ ){
		    for( int l = j ; l < 5 ; l++ ){
			if( all( i , j , k , l ) ){
			    if( max < (k-i+1)*(l-j+1) ) max=(k-i+1)*(l-j+1);
			}
		    }
		}
	    }
	}
	cout << max << endl;
    }
    return 0;
}

Measured memory_bytes: 3080
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n, m = list(map(int, readline().split()))
    a = list(map(int, readline().split()))
    s = sum(a)

    if n < s:
        print(-1)
    else:
        print(n-s)


if __name__ == '__main__':
    main()


Measured memory_bytes: 68116
#include <iostream>
#include <string>
#include <vector>
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include <cmath>
#include <iomanip>
#include <ctype.h>

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi >;
using vl = vector<ll>;
using vvl = vector<vl >;
using pairi = pair<int, int>;
using pairl = pair<ll, ll>;

#define TR ","
#define TS " "
#define rep(i,N) for(ll i=0;i<(ll)N;++i)
#define rpt(i,a,b) for(ll i=a;i<(ll)b;++i)
#define all(v) v.begin(), v.end()
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

ll gcd(ll a, ll b) {
    if (a < b) swap(a, b);
    if (b == 0) return a;
    return gcd(b, a % b);
}

ll lcm(ll x, ll y) {
    return x / gcd(x, y) * y;
}

void printVector(const vector<ll>& vec) {
    for (ll value : vec) {
        cout << value << " ";
    }
    cout << endl;
}

vector<int> IntegerToVector(int bit, int N) {
    vector<int> S;
    for (int i = 0; i < N; ++i) {
        if (bit & (1 << i)) {
            S.push_back(i);
        }
    }
    return S;
}

int main()
{
    IO;

    ll N; cin >> N;
    string str; cin >> str;
    vl wkosuu(N), ekosuu(N);

    ll x = 0, y = 0, z=0;

    rep(i, N) {
        if (str[i] == 'E') { ++y; }
        else if (str[i] == 'W') { ++z; }
    }

    ll jj = 0;

    wkosuu[0] = 0;
    wkosuu[N - 1] = z;
    ekosuu[0] = y;
    ekosuu[N - 1] = 0;

    for (ll i = 1; i < N-1; ++i) {
        if (str[i-1] == 'E') {
            wkosuu[i] = wkosuu[i - 1];
        }
        else if (str[i-1] == 'W') {
            ++x;
            wkosuu[i] = x;
        }
    }

    for (ll i = 0; i < N-1; ++i) {
        if (str[i] == 'W') {
            if (i > 0) {
                ekosuu[i] = ekosuu[i - 1];
            }
        }
        else if (str[i] == 'E') {
            --y;
            ekosuu[i] = y;
        }
    }

    ll ans = N;

    rep(i, N) {
        ans = min(ans, wkosuu[i] + ekosuu[i]);
    }

    cout << ans << endl;

}

Measured memory_bytes: 8068
import java.io.*;
import java.util.*;

/**
 * Created by Ayushi on 21 Jun 2020.
 * Problem:
 * Round:
 */

public class Main {
    public static void main(String[] args) throws IOException {
        StringTokenizer st;
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        HashMap<Integer, Integer> hmap = new HashMap<>();
        st = new StringTokenizer(br.readLine(), " ");
        int[] a = new int[n];
        int j = 0;
        long tot = 0;
        while (st.hasMoreTokens()) {
            a[j] = Integer.parseInt(st.nextToken());
            if (hmap.containsKey(a[j])) {
                hmap.replace(a[j], hmap.get(a[j])+1);
            }
            else {
                hmap.put(a[j], 1);
            }
            tot += a[j];
            j++;
        }
        int q = Integer.parseInt(br.readLine());
        int b, c;
        for (int i = 0; i < q; i++) {
            st = new StringTokenizer(br.readLine(), " ");
            b = Integer.parseInt(st.nextToken());
            c = Integer.parseInt(st.nextToken());

            if (hmap.containsKey(b)) {
                if (hmap.containsKey(c)) {
                    hmap.replace(c, hmap.get(c) + hmap.get(b));
                }
                else {
                    hmap.put(c, hmap.get(b));
                }
                //System.out.println(hmap);
                tot += ((c-b) * hmap.get(b));
                hmap.replace(b, 0);
            }
            System.out.println(tot);
        }
        br.close();
    }
}


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

using namespace std;

#define REP(i, a, n) for (int i = a, _n = n; i <= _n; ++i)
#define DREP(i, a, n) for (int i = a, _n = n; i >= _n; --i)
#define FOR(i, a, n) for (int i = a, _n = n; i < _n; ++i)
#define EREP(i, a) for (int i = first[a]; i; i = edge[i].nxt)
#define debug(x) cout << #x << " = " << x << endl

const int SIZE = 100005, Mod = 1000000007;

int n, k;

int first[SIZE], ecnt;
struct Edge {
	int v, nxt;
} edge[SIZE << 1];
void Add_Edge (int u, int v) {
	++ecnt;
	edge[ecnt].v = v;
	edge[ecnt].nxt = first[u];
	first[u] = ecnt;
}

int deg[SIZE];

long long ans;

void DFS (int u, int fa) {
	ans *= (k - deg[fa]);
	ans %= Mod;
	EREP (i, u) {
		Edge& e = edge[i];
		if (e.v == fa) continue;
		++deg[u];
		++deg[e.v];
		DFS (e.v, u);
	}
}

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

	REP (i, 1, n - 1) {
		int u, v;
		scanf ("%d%d", &u, &v);
		Add_Edge (u, v);
		Add_Edge (v, u);
	}

	REP (i, 1, n) if (deg[i] >= k) {
		puts ("0");
		return 0;
	}

	ans = 1;
	DFS (1, 0);

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

	return 0;
}


Measured memory_bytes: 6144
#include <iostream>
#include <vector>
#include <queue>
using namespace std;

typedef int Flow;
const Flow INF = 1<<27;
struct Edge {
    int src,dst;
    Flow cap;
    Edge(int s,int d,int c) : src(s), dst(d), cap(c) {}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

Flow edmonds_karp(const Graph &g,int s,int t, vector<vector<Flow> > &flow) {
    const int n = g.size();
    vector<vector<Flow> > cap(n, vector<Flow>(n, (Flow)0));
    for(int i=0; i<n; ++i) for(int j=0; j<n; ++j) flow[i][j] = (Flow)0;

    for(int i=0; i<n; ++i)
        for(int j=0; j<g[i].size(); ++j)
            cap[i][g[i][j].dst] = g[i][j].cap;

    queue<int> q;
    Flow fret = (Flow)0;
    while(true) {
        vector<int> prev(n,-1);
        prev[s] = s;
        q.push(s);
        while(!q.empty()) {
            int v = q.front(); q.pop();
            for(int i=0; i<g[v].size(); ++i) {
                int w = g[v][i].dst;
                if(prev[w] == -1 && cap[v][w]-flow[v][w] > 0) {
                    q.push(w);
                    prev[w] = v;
                }
            }
        }

        if(prev[t] == -1) break;
        Flow fm = INF;
        for(int j=t; j != prev[j]; j = prev[j])
            fm = min(fm, cap[prev[j]][j] - flow[prev[j]][j]);
        fret += fm;
        for(int j=t; j != prev[j]; j = prev[j])
            flow[prev[j]][j] += fm, flow[j][prev[j]] -= fm;
    }
    return fret;
}

int main() {
    int n,m,a,b,s,t;
    cin>>n>>m;
    Graph g(n);
    vector<pair<int,int> > e;

    for(int i=0; i<m; ++i) {
        cin>>a>>b;
        a--,b--;
        g[a].push_back(Edge(a,b,1));
        g[b].push_back(Edge(b,a,1));
        e.push_back(make_pair(a,b));
    }
    cin>>s>>t;
    s--,t--;
    vector<vector<Flow> > flow(n,vector<Flow>(n,0));

    int f = edmonds_karp(g,s,t,flow);
    cout<<f<<endl;
    vector<int> reversed;
    for(int i=0; i<m; ++i)
        if(flow[e[i].second][e[i].first] > 0) 
            reversed.push_back(i+1);

    cout<<reversed.size()<<endl;
    for(int i=0; i<reversed.size(); ++i)
        cout<<reversed[i]<<endl;
}

Measured memory_bytes: 0
n = int(input())
al = list(map(int,input().split()))

ave = sum(al)//n
ans = 10**9
for y in range(n-5000,n+5000+1):
    cost = 0
    for x in al:
        cost += (x - y)**2
    ans = min(ans,cost)
print(ans)

Measured memory_bytes: 9108
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner in = new Scanner(System.in);
		int cnt5 = 0;
		int cnt7 = 0;
		for(int i = 0; i < 3; i++) {
			int val = in.nextInt();
			if(val == 5)
				cnt5++;
			else if(val ==7)
				cnt7++;
		}
		if(cnt5 == 2 && cnt7 == 1)
			System.out.println("YES");
		else 
			System.out.println("NO");
	}

}


Measured memory_bytes: 21844
#include<stdio.h>
int main(){
	char a[3];
	int i;
	int n=0,m=0;
	for(i=0;i<3;i++){
		scanf("%c",&a[i]);
		if(a[i]=='A')
			n=1;
		if(a[i]=='B')
			m=1;
	}
	if(n==1&&m==1)
		printf("Yes");
	else
		printf("No");
} 

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    int N; cin >> N;
    vector<int> h(N);
    for (int i = 0; i < N; ++i) cin >> h[i];

    // 高さが全部 0 になるまでやる
    int res = 0;
    while (true) {
        // 最高高さが 0 だったらおしまい
        if (*max_element(h.begin(), h.end()) == 0) break;
        
        // 区間分割する
        int i = 0;
        while (i < N) {
            if (h[i] == 0) ++i; // 0 なら何もせずに次に進む
            else {
                ++res; // 区間の始まり
                while (i < N && h[i] > 0) {
                    --h[i]; // ついでに引いとく
                    ++i; // 区間の終わりまで一気に
                }
            }
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 384
kai=0

while True:
    try:
        k=input()
        n=int(len(k)/2)
        ch=0
        
        for i in range(n):
            if k[i]!=k[-(i+1)]:
                ch=1
                break
        
        if ch==0:
            kai+=1
    
    except:
        print(kai)
        break


Measured memory_bytes: 5560
#include<bits/stdc++.h>
using namespace std;
long long gcd(long long a,long long b){return !b?a:gcd(b,a%b);}
long long n,m;
char s[200001],t[200001];
int main()
{
	scanf("%lld%lld%s%s",&n,&m,s,t);
	long long g=gcd(n,m),a=n/g,b=m/g;
	for(int i=0;i<g;i++)
		if(s[i*a]!=t[i*b])return puts("-1"),0;
	printf("%lld\n",n/g*m);
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;

int main(){
	int n,m;
	cin>>n>>m;
	vector<int>a(n);
	int ans=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		ans+=a[i];
	}
	int num=0;
	for(int i=0;i<n;i++){
		if(a[i]*4*m>=ans)num++;
	}
	if(num>=m)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
n = int(input())
ans = True
t = x = y = 0
for i in range(n):
    t1,x1,y1 = map(int,input().split())
    num = abs(x1-x) + abs(y1-y)
    tdif = abs(t1-t)
    if num <= tdif and (num-tdif) % 2 == 0:
        pass
    else:
        ans = False
if ans:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 44904
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

X = INT()

if X == 2:
	print(2)
	exit()
if X == 3:
	print(3)
	exit()

for i in range(X, mod):
	flag = 0
	if i % 2 == 0:
		continue
	elif i % 3 == 0:
		continue
	else:
		for j in range(2, int(sqrt(i)) + 1):
			if i % j == 0:
				flag = 1
				break
		if flag == 0:
			print(i)
			exit()

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

const int N = 666666;

char s[N];

vector<int> a;
int sm;

void ml() {
    for (int i = 0; i < int(a.size()); ++i) {
        a[i] *= 9;
    }

    int cr = 0;

    for (int i = 0; i < int(a.size()); ++i) {
        cr += a[i];
        a[i] = cr % 10;
        cr /= 10;
    }

    while (cr > 0) {
        a.push_back(cr % 10);
        cr /= 10;
    }
}

void ad() {
    int cr = 9;

    for (int i = 0; cr > 0 && i < int(a.size()); ++i) {
        cr += a[i];
        sm -= a[i];
        a[i] = cr % 10;
        sm += a[i];
        cr /= 10;
    }

    while (cr > 0) {
        a.push_back(cr % 10);
        sm += cr % 10;
        cr /= 10;
    }
}

int main() {
    scanf("%s", s);
    
    for (int i = 0; s[i]; ++i) {
        a.push_back(s[i] - '0');
    }
    reverse(a.begin(), a.end());

    ml();

    sm = accumulate(a.begin(), a.end(), 0);

    for (int x = 1; ; x++) {
        ad();
        if (sm <= 9 * x) {
            printf("%d\n", x);
            return 0;
        }
    }
}


Measured memory_bytes: 2932
#include <bits/stdc++.h>
using namespace std;
long long test,n,s,check;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    //cin>>test;
    test=1;
    while (test--)
    {
        cin>>n;
        n%=10;
        if (n==3) cout<<"bon";
        else
        if (n==0 || n==1 || n==6 || n==8) cout<<"pon";
        else
        {
            cout<<"hon";
        }
        
    }
    
}    




Measured memory_bytes: 3620
import sys
import heapq


# \n
def input():
    return sys.stdin.readline().rstrip()


def main():
    X, Y, Z, 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)

    L=[]

    for i in range(X):
        for j in range(Y):
            for k in range(X):
                if (i+1)*(j+1)*(k+1)<=K:
                    L.append(A[i]+B[j]+C[k])
                else:
                    break

    L.sort(reverse=True)

    for i in range(K):
        print(L[i])



if __name__ == "__main__":
    main()


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

using namespace std;

typedef long long ll;

int main() {
  string s;
  cin>>s;
  int cnum = 0;
  int lownum = 0;
  for (int i = 2; i <= s.size() - 2; i++) {
    if (s[i] == 'C') cnum++;
  }
  for (int i = 0; i < s.size(); i++) {
    if (s[i] >= 'a' && s[i] <= 'z') lownum++;
  }
  if (s[0] != 'A') cout<<"WA"<<endl;
  else if (cnum != 1) cout<<"WA"<<endl;
  else if (lownum != s.size() - 2) cout<<"WA"<<endl;
  else cout<<"AC"<<endl;
  return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    rep(i, N) cin >> a[i];
    
    int S = a[0];
    REP(i, N) S = S ^ a[i];
    if (S == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 640
//#pragma GCC optimize(2)
#include<set>
#include<map>
#include<stack>
#include<cmath>
#include<queue>
#include<cstdio>
#include<vector>
#include<climits>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define LL long long
using namespace std;
LL read(){
	bool f=0;LL x=0;char c=getchar();
	while(c<'0'||'9'<c){if(c=='-')f=1;c=getchar();}
	while('0'<=c&&c<='9') x=(x<<3)+(x<<1)+(c^48),c=getchar();
	return !f?x:-x;
}
#define MAXN 100000
#define INF 0x3f3f3f3f
LL gcd(LL a,LL b){return !b?a:gcd(b,a%b);}
vector<LL> P;
int main(){
	LL a=read(),b=read(),g=gcd(a,b),tmp=g,cnt=1;
	for(LL i=2;i*i<=tmp;i++)
		if(g%i==0){
			while(g%i==0)
				g/=i;
			cnt++;
		}
	if(g!=1)
		cnt++;
	printf("%lld\n",cnt);
	return 0;
}

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

int d[5009], c[1009], r[1009];
bool vs[19];

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m; cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int b; cin >> c[i] >> b;
		for (int j = 0; j < b; j++) {
			int t; cin >> t; t--;
			r[i] += (1 << t);
			vs[t] = true;
		}
	}
	for (int i = 0; i < n; i++) {
		if (!vs[i]) {
			cout << -1 << '\n';
			return 0;
		}
	}
	for (int i = 1; i < (1 << n); i++) {
		d[i] = 1000000009;
		for (int j = 0; j < m; j++) 
			d[i] = min(d[i], d[i - (i & r[j])] + c[j]);
	}
	cout << d[(1 << n) - 1] << '\n';
	return 0;
}	

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	public static final int BIG_NUM  = 2000000000;
	public static final int MOD  = 1000000007;

	public static void main(String[] args) {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		try {
			int N = Integer.parseInt(br.readLine());
			String input[] = new String[N];
			input = br.readLine().split("\\s+");

			int S[] = new int[N];
			for(int i = 0; i < input.length; i++){
				S[i] = Integer.parseInt(input[i]);
			}

			int Q = Integer.parseInt(br.readLine());
			String inputQ[] = new String[Q];
			inputQ = br.readLine().split("\\s+");

			int T[] = new int[Q];
			for(int i = 0; i < inputQ.length; i++){
				T[i] = Integer.parseInt(inputQ[i]);
			}

			Arrays.sort(T);

			int ans = 0;
			int left = 0,right,m;

			for(int i = 0; i < T.length; i++){
				right = S.length-1;
				m = (left+right)/2;

				while(left <= right){
					if(S[m] == T[i]){
						ans++;
						left = m;
						break;
					}else if(S[m] > T[i]){
						right = m-1;
					}else{
						left = m+1;
					}
					m = (left+right)/2;
				}
			}

			System.out.println(ans);

		} catch (NumberFormatException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}



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


const int modulo = 1000000007;

int ctoi(char a){
  return a - '0';
}

int main(){
  string s; cin >> s;
  vector<vector<long> > dp(s.length(), vector<long>(13, 0));
  // init
  if(s[0] == '?'){
    for (int i = 0; i < 10; i++) dp[0][i] = 1;
  } else {
    dp[0][ctoi(s[0])] = 1;
  }
  
  for (int i = 1; i < s.length(); i++) {
    for(int j = 0; j < 13; j++) {
      if(s[i] == '?') {
        for(int n = 0; n < 10; n++) {
          dp[i][(j * 10 + n) % 13] += dp[i - 1][j];
          dp[i][(j * 10 + n) % 13] = dp[i][(j * 10 + n) % 13] % modulo;
        }
      }
      else{
        int n = ctoi(s[i]);
        dp[i][(j * 10 + n) % 13] += dp[i - 1][j];
        dp[i][(j * 10 + n) % 13] = dp[i][(j * 10 + n) % 13] % modulo;
      }
    }
  }
  
  cout << dp[s.length() - 1][5] % modulo << "\n";
}

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

#define ll long long int

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<vector<int>> cp(n, vector<int>(26, 0));
    for(int i = 0; i < n; i++) {
        if(i)
            cp[i] = cp[i - 1];
        // cout << s[i] << " ";    
        cp[i][s[i] - 'a']++;    
    }
    int ret = 0;
    for(int i = 1; i < n - 1; i++) {
        int cnt = 0;
        vector<int> l(26, 0), r(26, 0);
        for(int j = 0; j < 26; j++) {
            l[j] = cp[i][j];
        }
        for(int j = 0; j < 26; j++) {
            r[j] = cp[n - 1][j] - cp[i][j];
            if(l[j] && r[j])
                cnt++;
        }
        ret = max(ret, cnt);
    }
    cout << ret << endl;
}

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

//#define Fast ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
typedef vector<int>Vl;
typedef pair<int,int>PII;
typedef vector<PII>Vll;
typedef vector<pair<int,pair<int,int> > >Vlll;
typedef priority_queue<int>PQL;
typedef map<int,int>MP;
#define S second
#define F first
#define mp make_pair
#define ms(x,y) memset(x,y,sizeof(x))
#define pb push_back
#define sl(n) scanf("%lld",&n)
#define pl(n) printf("%lld",n)
const int mod=1e9+7;
const int sze=1e5+2;
signed main(){
int n,k;
sl(k);sl(n);
if(k*500>=n)cout<<"Yes"<<endl;
else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 384
#include <stdio.h>

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

Measured memory_bytes: 580
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;

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

using ll = long long;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }

std::vector<ll> pFactorization(ll n) {
  std::vector<ll> rtn;
  for(ll i=2; i*i<=n; i++) {
    if ( n % i != 0 ) continue;
    rtn.push_back(i);
    while( n%i == 0 ) n/=i;
  }
  if ( n != 1 ) rtn.push_back(n);
  return rtn;
}

int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  ll N; std::cin >> N;

  auto P = pFactorization(N);
  std::vector<int> e(sz(P));
  ll T = N;
  for(int i=0; i<sz(P); i++) {
    int cnt = 0;
    while( T % P[i] == 0 ) {
      cnt++;
      T /= P[i];
    }
    e[i] = cnt;
  }

  int ans = 0;
  for(int i=0; i<sz(P); i++) {
    int sum = 0;
    int j;
    for(j=1; sum+j <= e[i]; j++) sum += j;
    ans += (j-1);
    //std::cout << P[i] << " " << e[i] << " " << j-1 << std::endl;
  }
  std::cout << ans << std::endl;
  return 0;
}



Measured memory_bytes: 3652
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
ll h,w;
string a[10];
ll cnt = 0;
ll saiki(ll x, ll y,ll now){
    bool ok = false;
    if(x==w-1 && y==h-1&& now == cnt){
        return true;
    }
    if(x<w-1){
        if(a[y][x+1] == '#'){
            ok = ok || saiki(x+1,y,now+1);
        }
    }
    if(y<h-1){
        if(a[y+1][x] == '#'){
            ok = ok || saiki(x,y+1,now+1);
        }
    }
    return ok;
}
int main() {
    
    std::cin >> h>>w;
    
    for (int i = 0; i < h; i++) {
        std::cin >> a[i];
        for (int j = 0; j < w; j++) {
            if(a[i][j] == '#')cnt++;
        }
    }
    if(saiki(0,0,1)){
        std::cout << "Possible" << std::endl;
    }else{
        std::cout << "Impossible" << std::endl;
    }
}


Measured memory_bytes: 256
e=enumerate
h,w=map(int,input().split())
a=[list(map(int,input().split()))for _ in range(h)]
b=[list(map(int,input().split()))for _ in range(h)]
dp=[0]*w
c=13000
for i,(a,b)in e(zip(a,b)):
  for j,(x,y)in e(zip(a,b)):
    x=abs(x-y)
    if i==j==0:
      dp[j]=2**c<<x
      continue
    t=0
    if j:
      t|=dp[j-1]<<x
      t|=dp[j-1]>>x
    if i:
      t|=dp[j]<<x
      t|=dp[j]>>x
    dp[j]=t
*a,=map(int,(bin(dp[w-1])[2:]).zfill(26001))
print(min([i for i,f in e(a[13000:])if f]+[i for i,f in e(a[13000::-1])if f]))

Measured memory_bytes: 48348
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#define PI 3.141592653589793
#define MOD 1000000007

//qsort用、昇順
int compare_int(const void *a, const void *b)
{
	return *(int*)a-*(int*)b;
}
//qsort(data, 10, sizeof(int), compare_int)


int main(){
	char s[11], t[11];
	scanf("%s%s", s, t);
	int l = strlen(s);
	int c=1;
	for(int i=0; i<l; i++){
		if(s[i] != t[i]) c=0;
	}
	if(c==0) printf("No\n");
	else printf("Yes\n");
	
	return 0;
}

Measured memory_bytes: 1648
#!/usr/bin/env python3
#AGC16 B

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
a = LI()
a.sort()
low,high = a[0],a[-1]
if high - low >= 2:
    print('No')
    quit()
if high - low == 1:
    x,y = 0,0
    for i in range(n):
        if a[i] == high:
            y += 1
        else:
            x += 1
    if x < high and 2*(high-x) <= y:
        print('Yes')
    else:
        print('No')
else:
    for i in range(n):
        if a[i] != n-1:
            break
    else:
        print('Yes')
        quit()
    for i in range(n):
        if 2*a[i] > n:
            print('No')
            break
    else:
        print('Yes')

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

#define fo(i,s,t) for(int i = s; i <= t; ++ i)
#define fd(i,s,t) for(int i = s; i >= t; -- i)
#define bf(i,s) for(int i = head[s]; i; i = e[i].next)
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pb push_back
#define VI vector<int>
#define sf scanf
#define pf printf
#define fp freopen
#define SZ(x) ((int)(x).size())
#define IF_DEBUG 0
typedef long long ll;
typedef double db;
typedef unsigned long long ull;
const int inf = 1<<30;
const ll INF = 1ll<<60;
const db Inf = 1e20;
const db eps = 1e-9;

void gmax(int &a,int b){a = (a > b ? a : b);}
void gmin(int &a,int b){a = (a < b ? a : b);}

const int maxn = 100050;

int n, a[maxn], p;

int main()
{
	sf("%d",&n);
	fo(i,1,n) sf("%d",&a[i]);
	sort(a+1,a+n+1); reverse(a+1,a+n+1);
	fo(i,1,n) if(i+1 > a[i+1])
	{
		p = 1;
		for(int j = i+1; a[j] == i; ++ j) p ^= 1;
		p &= ((a[i]-i+1)&1);
		if(!p) pf("First"); else pf("Second");
		return 0;
	}
	return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int L[2005];

int main() {

	int N;

	scanf("%d",&N);

	int i, j;

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

	sort(L, L + N);

	int ans = 0;

	for (i = 0; i < N - 2; i++) {
		for (j = i + 1; j < N - 1; j++) {
			int l, r, mid;
			l = j + 1;
			r = N - 1;
			while (r - l > 1) {
				mid = (l + r) / 2;
				if (L[mid] < L[i] + L[j]) { l = mid; }
				else { r = mid; }
			}
			if (L[r] < L[i] + L[j]) {
				//printf("i=%d,j=%d,k=%d\n", i, j, r);
				ans += r - j;
			}
			else if (L[l] < L[i] + L[j]) {
				//printf("i=%d,j=%d,k=%d\n", i, j, l);
				ans += l - j;
			}
		}
	}

	/*

	int cnt = 0;
	for (i = 0; i < N - 2; i++) {
		for (j = i + 1; j < N - 1; j++) {
			for (k = j + 1; k < N; k++) {
				if (L[i] + L[j] > L[k]) {
					printf("cnt:%d,i=%d,j=%d,k=%d\n", cnt + 1, i, j, k);
					cnt++;
				}
			}
		}
	}
	*/

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

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n, m, num, i, as=1, bs;
  scanf("%d%d", &n, &m);
  bs = n / 2 + n % 2 + 1;
  num = bs;
  for(i = 0;i < m;i++){
    if(i % 2 == 0){
      printf("%d %d\n", as, num - as);
      as++;
    } else {
      if(n % 2 != 0)
        printf("%d %d\n", bs, n - bs + num);
      else
        printf("%d %d\n", bs, n - bs + num - 1);
      bs++;
    }
  }
  return 0;
}

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

int main(void) {
    int n;
    cin >> n;
    int ans = 0;
    for (int i = 1; i < n; i++) {
        ans += ceil((double)n/i) - 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
cnt=0
for i in range(n-1):
  cnt+=b[a[i]-1]
  if a[i+1]==a[i]+1:
    cnt+=c[a[i]-1]
cnt+=b[a[n-1]-1]
print(cnt)

    
  

Measured memory_bytes: 3064
#include <iostream>

int main()
{
	using namespace std;

	int r,g,b;
	cin >> r >> g >> b;
	if ((r * 100 + g * 10 + b) % 4 == 0) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}

int main(){
	int n,m;
	int i,j,k;
	int a,b,c;
	cin>>a>>b;
	if(b==1){
		cout<<0<<endl;
		return 0;
	}
	a--,b--;
	a=(b-1)/a+1;
	cout<<a<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
 
int a,b,c,d,e;
scanf("%d",&a);
scanf("%d",&b);
scanf("%d",&c);
 
d=b-a; e=c-b;
 
if(d==e){
printf("YES\n");
}else{
printf("NO\n");
}
 
return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rep_ll(i,n) for(ll i = 0; i < (ll)(n); i++)

using namespace std;
 
typedef long long ll;
typedef unsigned long long u_ll;
typedef pair<int, int> pair_;

const long double PI = (acos(-1));
 
const int INF = 1001001001;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 int n,m,x;
 
int gcd(int a, int b){
    if(b == 0) return a;
 
    return gcd(b, a%b);
}
 
int main(){

    int n,m,x;
    cin >> n >> m >>x;

    vector<int> c(n);
    vector<vector<int>> a(n,vector<int>(m));

    rep(i, n){
        cin >> c[i];
        rep(j, m) cin >> a[i][j];
    }
    vector<int> rikai(m, 0);
    int cost_t=INF;
    int cost;
   rep(s, 1<<n){
       rep(j, m) rikai[j] = 0;
       cost=0;
       rep(i, n){
           if(s>>i&1) {
               cost+=c[i];
               rep(j,m) rikai[j]+=a[i][j];
           }
       }
       bool ans=true;
       rep(j,m) {
           if(rikai[j]>=x) continue;
           else ans=false;
       }
       if(ans) cost_t=min(cost_t, cost);
       else continue;
   }

   if(cost_t!=INF) cout << cost_t;
   else cout << "-1";
    return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define N 5004
#define INF 1000000007
typedef long long int ll;
typedef long int li;

unordered_map<string,int> m;
int n; string s;
ll ans = 0;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    
    cin>>n;
    while(n--) { cin>>s;  sort(s.begin(),s.end()); m[s]++; }
    for(auto x : m) {
        ans += (1ll*(x.ss)*(x.ss-1))/2;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 10660
def prime?(n, single_primes)
  return false if n <= 1
  return true if single_primes.include?(n)
  return false if n % 2 == 0
  return false if single_primes.any? { |sp| n % sp == 0 }

  2.upto((n ** 0.5).to_i) do |i|
    if n % i == 0
      return false
      break
    end
  end

  true
end

res = 0
gets.to_i.times { |i| res += 1 if prime?(gets.to_i, [2, 3, 5, 7]) }
puts res



Measured memory_bytes: 6968
//#pragma GCC optimize "trapv"
//-D_GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
#define pm(m) for(auto itr=(m).begin();itr!=(m).end();itr++){itr->first<<" "<<itr->second<<"\n";}
#define int long long int
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define ii pair<int,int>
#define Max 100000+5
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define f first
#define s second
#define pb push_back
#define bug(x) cout<<(x)<<" ";exit(0);
int mod = 1000000007;
int mod1 = 998244353;
vector<int> g[Max];
bool vis[Max];
int d, x, y;
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
void ex(int A, int B) {
    if(B == 0) {
        d = A;
        x = 1;
        y = 0;
    }
    else {
        ex(B, A%B);
        int temp = x;
        x = y;
        y = temp - (A/B)*y;
    }
}


void dfs(int u){

	vis[u]=1;
	for(int i=0;i<g[u].size();i++){
		int v=g[u][i];
		if(vis[v]!=1)
			dfs(v);
	}
}



int power(int a,int b){
    if(b==1)return a;
    if(a>mod)a%=mod;
    int r=1;
    while(b){
        if(b&1)r=r%mod*a%mod;
        a=a%mod*a%mod;
        b/=2;
    }
    return r;
}
class uf{
    vector<int> v;
    vector<int> sz;
    
    
    public :
    uf(int n){
        v.resize(n+1);
        iota(v.begin()+1,v.end(),1);
        sz.resize(n+1,1);
        //1 to sz
    }
    int root(int b){
        while(v[b]!=b){
            b = v[b];
        }   
        return b;
    }
    void u(int a, int b){
        //combine a and b
        
        int ra=root(a);
        int rb=root(b);
        if(ra==rb)return ;
        if(sz[ra]<sz[rb]){
            v[ra] = v[rb];
            sz[rb]+=sz[ra];
        }else{
            v[rb]=v[ra];
            sz[ra]+=sz[rb];
        }
    }
    bool f(int a,int b){
        //same set
        return (root(a)==root(b));
    }
   
    
};
vector<int> matmul(vector<int> a,vector<int> b){
    vector<int> c(4,0);
    c[0] = (a[0]%mod*b[0]%mod + a[1]%mod*b[2]%mod)%mod;
    c[1] = (a[0]%mod*b[1]%mod + a[1]%mod*b[3]%mod)%mod;
    c[2] = (a[2]%mod*b[0]%mod + a[3]%mod*b[2]%mod)%mod;
    c[3] = (a[2]%mod*b[1]%mod + a[3]%mod*b[3]%mod)%mod;
    return c;
}
vector<int> id={1,0,0,1};

int32_t main(){
	IO
	//freopen("input.txt","r",stdin);
    	//freopen("output.txt","w",stdout);
	int n;
	cin>>n;
	vector<int> a(n),b(n),c(n);
	vector<int> x(n),y(n),z(n);
	for(int i=0;i<n;i++){
	    cin>>a[i]>>b[i]>>c[i];
	}
	x[0]=a[0];
	y[0]=b[0];
	z[0]=c[0];
	for(int i=1;i<n;i++){
	    x[i] = max(y[i-1],z[i-1])+a[i];
	    y[i] = max(x[i-1],z[i-1])+b[i];
	    z[i] = max(x[i-1],y[i-1])+c[i];
	}
	cout<<max({x[n-1],y[n-1],z[n-1]});
}

Measured memory_bytes: 10340
#include <iostream>
using namespace std;
#include <string>
int main() {
	string a, b, c;

	int na, nb, nc;
	na = nb = nc = 0;
	char now = 'a';
	cin >> a >> b >> c;

	while (1) {
		switch (now) {
		case 'a':now = (a[na]); if (na == a.size()) { cout << "A" << endl; now = 0; } na++; break;
		case 'b':now = (b[nb]);  if (nb == b.size()) { cout << "B" << endl; now = 0; }nb++; break;
		case 'c':now = (c[nc]);  if (nc == c.size()) { cout << "C" << endl; now = 0; }nc++; break;




		}


		if (!now)
			break;


	}


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define exrep(i, a, b) for(long long i = a; i <= b; i++)
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
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; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
ll modpow(ll a, ll n){
  if(n==0)return 1;
  if(n%2==0){
    ll t=modpow(a,n/2);
    return t*t%MOD;
  }
  return a*modpow(a,n-1)%MOD;
}
ll modinv(ll a){
  return modpow(a,MOD-2);
}
long long fac[MAX], finv[MAX], inv[MAX];
 
// テーブルを作る前処理
void COMinit() {
    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[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
long long COM(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;
}
struct UnionFind {
    vector<int> par; // 親ノード
    vector<int> rank; // ランク
 
    UnionFind(int n = 1) {
        init(n);
    }
 
    void init(int n = 1) {
        par.resize(n); rank.resize(n);
        for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0;
    }
 
    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            return par[x] = r;
        }
    }
 
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
 
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        return true;
    }
};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  COMinit();
  
  ll n;
  cin >> n;
  vl a(n);
  rep(i,n)cin >> a[i];
  
  ll ans=0;
  ll two_factor=1;
  rep(d,60){
    ll even=0,odd=0;
    rep(i,n){
      if(a[i]&(1ll<<d))odd++;
      else even++;
    }
    ll add=(odd*even)%MOD*two_factor%MOD;
    ans = (ans+add)%MOD;
    two_factor=(two_factor*2)%MOD;
  }
  cout << ans << endl;
}


Measured memory_bytes: 14592
# import math
# import statistics
# a=int(input())
#b,c=int(input()),int(input())
# c=[]
# for i in a:
#     c.append(int(i))
e1,e2,e3,e4 = map(int,input().split())
#f = list(map(int,input().split()))
# g = [input() for _ in range(a)]

a=e1*e3
b=e1*e4
c=e2*e3
d=e2*e4
print(max(a,b,c,d))

Measured memory_bytes: 9164
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	ll h;
	int n;
	cin>>h>>n;
	ll a[100010];
	ll s=0;
	for(int i=0; i<n; i++){
		cin>>a[i];
		s+=a[i];
	}
	if(h<=s) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;
 
class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    String str = sc.nextLine();
    String str2 = "";
    for(int i = 0; i < str.length(); i++){
      char c = str.charAt(i);
      if('A' <= c && c <= 'Z'){
        c += 'a' - 'A';
      }else if('a' <= c && c <= 'z'){
        c += 'A' - 'a';
      }
      str2 += String.valueOf(c);
    }
    System.out.println(str2);
  }
}


Measured memory_bytes: 31288
S=input()+'R'
L=len(S)
RL=0
l,r,f=0,0,0
a=[0]*(L-1)
for i in range(1,L):
    if f:r+=1
    else:l+=1
    if S[i-1:i+1]=='LR':
        a[RL-1]=r//2+(l+1)//2
        a[RL]=(r+1)//2+l//2  
        l,r,f=0,0,0
    if S[i-1:i+1]=='RL':RL,f=i,1
print(' '.join(map(str,a)))

Measured memory_bytes: 17152
// 21
#include <bits/stdc++.h>
using namespace std;
#define coutc "\033[48;5;196m\033[38;5;15m"
#define endc "\033[0m"
#define endl '\n'
#define M(_1, _2, _3, _4, NAME, ...) NAME
#define rep(...) M(__VA_ARGS__, rep4, rep3, rep2)(__VA_ARGS__)
#define rep4(_, x, n, s) for (int _ = x; (s < 0) ? _ > n : _ < n; _ += s)
#define rep3(_, x, n) rep4(_, x, n, (x < n ? 1 : -1))
#define rep2(_, n) rep3(_, 0, n)
#define fi first
#define se second
#define pb push_back
#define pairii pair<int, int>
#define all(x) x.begin(), x.end()
#define len(x) int(x.size())
#define lli __int128_t
#define li long long int
#define ld long double
// 4
template <class A, class B>
ostream &operator<<(ostream &o, const pair<A, B> &p) {
  return o << "(" << p.fi << ", " << p.se << ")";
}
// 5
template <class T>
ostream &operator<<(ostream &o, const vector<T> &v) {
  rep(i, len(v)) o << setw(7) << v[i];
  return o << endc << endl << coutc;
}
// 5
template <class A, class B>
ostream &operator<<(ostream &o, const map<A, B> &m) {
  for (auto &kv : m) o << kv;
  return o;
}
// 7
template <class T, class... Ts>
void debug(const T &e, const Ts &... r) {
#ifdef LOCAL
  cerr << coutc << e;
  ((cerr << " " << r), ..., (cerr << endc << endl));
#endif
}

// notes:
// https://lh4.googleusercontent.com/28KF2smjyS_2sb8o3Eo-eMulA145VpehdkwVKnP6VPbYQS4_WcdPBYqDV0LDsOAkZNf9sZ4=w16383

void _main(int tc) {
  int n;
  cin >> n;
  vector<li> v(n);
  rep(i, n) cin >> v[i];
  const li inf = 2e18;
  vector<li> pref = v;
  rep(i, 1, n) pref[i] += pref[i - 1];
  /************* Recursive *************
  vector<vector<li>> mem(n, vector<li>(n, inf));
  function<li(int, int)> f = [&](int L, int R) -> li {
    if (L == R) return 0;
    if (mem[L][R] != inf) return mem[L][R];
    li sum = pref[R] - (L == 0 ? 0 : pref[L - 1]);
    rep(pivot, L, R) {
      mem[L][R] = min(mem[L][R], f(L, pivot) + f(pivot + 1, R) + sum);
    }
    return mem[L][R];
  };
  cout << f(0, n - 1) << endl;
  *********** End Recursive ***********/
  vector<vector<li>> mem(n, vector<li>(n, inf));
  rep(R, n) {
    rep(L, R, -1) {
      if (L == R) {
        mem[L][R] = 0;
        continue;
      }
      li sum = pref[R] - (L == 0 ? 0 : pref[L - 1]);
      rep(pivot, L, R) {
        mem[L][R] = min(mem[L][R], mem[L][pivot] + mem[pivot + 1][R] + sum);
      }
    }
  }
  cout << mem[0][n - 1] << endl;
}
// 7
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  _main(0), exit(0);
  int tc;
  cin >> tc;
  rep(i, tc) _main(i + 1);
}

Measured memory_bytes: 1536
A,B,C = [int(x) for x in input().split()]
li = []
n = 1
while(True):
    i=A*n%B
    if(i in li):
        break
    else:
        li.append(i)
        n+=1
if(C in li):
    print('YES')
else:
    print('NO')


Measured memory_bytes: 2940
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define RREP(i,a,b) for (int i = a; i > (b); --i)
#define all(x) (x).begin(),(x).end()
#define YY cout << "Yes" << endl
#define NN cout << "No" << endl
const int INF = 1000000007;
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
int solve(){
  int n;
  cin>>n;
  if(n == 3 || n == 5 || n == 7)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  return 0;
}
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  // cout << fixed;cout << setprecision(16);
  solve();
  return 0;
}

Measured memory_bytes: 256
// C - 白昼夢

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const int MOD = 1e9 + 7;

bool is_valid(string& S, int pos, string& s) {
	for (int i=0; i<s.size(); i++) {
		if (S[pos + i] != s[i]) {
			return false;
		}
	}

	return true;
}

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

	reverse(S.begin(), S.end());

	string s1 = "maerd";
	string s2 = "remaerd";
	string s3 = "esare";
	string s4 = "resare";

	string ans = "YES";
	int pos = 0;
	while (pos < S.size()) {
		if(is_valid(S, pos, s1)) {
			pos += s1.size();
		} else if (is_valid(S, pos, s2)) {
			pos += s2.size();
		} else if (is_valid(S, pos, s3)) {
			pos += s3.size();
		} else if (is_valid(S, pos, s4)) {
			pos += s4.size();
		} else {
			ans = "NO";
			break;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <stdint.h>

int main() {

  uint32_t N, K, X, Y;
  scanf("%u\n%u\n%u\n%u", &N, &K, &X, &Y);

  if(N<=K)
    printf("%u\n", N*X);
  else
    printf("%u\n", K*X+(N-K)*Y);

  return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
int main()
{
    int a,b,c,d;
    scanf("%d %d %d",&a,&b,&c);
    d=a+b;
    if(d>c||d==c){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
 
using namespace std;
 
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define rep(i,n) REP(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;

const int INF = 1e9;
const double EPS = 1e-8;
const int mod = 1e9 + 7;
const ll LINF = 1e18;
const double PI = acos(-1);

struct Input
{
	int n;char c;char str[1024];string s;ll l;
	int nextInt(){scanf("%d", &n);return n;}
	ll nextLong(){scanf("%lld", &l);return l;}
	char nextChar(){scanf("%c", &c);return c;}
	string next(){scanf("%s", str);return string(str);}
	string nextLine(){getline(cin, s);return s;}
};
Input in;

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

int h, w;
string s[60];
int d[100][100];

bool isOutOfRange(int x, int y){
	if(x < 0 || x >= w | y < 0 || y >= h) return true;
	return false;
}

void calc(int y, int x, bool f){
	if(d[y][x] == 3) return ;
	if(d[y][x] == 1 && !f) return ;
	if(d[y][x] == 2 && f) return;
	
	if(d[y][x] == 0) d[y][x] = f ? 2 : 1;
	else d[y][x] = 3;
	rep(i, 4){
		int ny = y + dy[i], nx = x + dx[i];
		if(isOutOfRange(nx, ny)) continue;
		calc(ny, nx, f);
	} 
}

int main(){
	while(1){
		w = in.nextInt(); h = in.nextInt();
		if(h == 0 && w == 0) break;
		rep(i, h) s[i] = in.next();
		
		rep(i, h) rep(j, w) d[i][j] = s[i][j] == '.' ? 0 : 3;
		rep(i, h) rep(j, w) if(s[i][j] != '.') {
			rep(k, 4){
				int ni = i + dy[k], nj = j + dx[k];
				if(isOutOfRange(nj, ni)) continue;
				calc(ni, nj, s[i][j] == 'W');
			}
		}
		int ans[2] = {};
		rep(i, h) rep(j, w) {
			if(d[i][j] == 1) ans[0]++;
			else if(d[i][j] == 2) ans[1]++;
		}
		printf("%d %d\n", ans[0], ans[1]);
	}
}

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

signed main(void){
    int n; cin >> n;
    string s,t; cin >> s >> t;
    for(int i=0;i<n;i++){
        cout << s[i] << t[i];
    }cout << endl;
    return 0;
}

Measured memory_bytes: 256
"use strict";
    
const main = arg => {
    arg = arg.split("\n");
    const N  = parseInt(arg[0].split(" ")[0]);
    const Q  = arg[0].split(" ")[1];
    const S  = arg[1];

    let dp = new Array(N).fill(0);
    let cnt = 0;
    
    for(let i in dp) {
        if(S[i] === "A" && S[parseInt(i)+1] === "C") {
            cnt++;
        }
        
        dp[parseInt(i)+1] = cnt;
    }

    for(let i=0; i<Q; i++) {
        let lr = arg[i+2].split(" ");
        let l = lr[0];
        let r = lr[1];
        
        console.log(dp[r-1]-dp[l-1]);
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


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

int cnt;
string s1, s2;

int main() {
  cin >> s1 >> s2;
  for (int i = 0; i < 3; i++) {
    if (s1[i] == s2[i]) { cnt++; }
  }
  printf("%d\n", cnt);
  return 0;
}


Measured memory_bytes: 256
n = int(input())
h = list(map(int,input().split()))
ans = 0
max_ans = 0
for i in range(n-1):
    if h[i] >= h[i+1]:
        ans+=1
    else:
        if max_ans < ans:
            max_ans = ans
        ans = 0
        
if max_ans < ans:
            max_ans = ans
            
print(max_ans)

Measured memory_bytes: 63984