akhauriyash/Code-Regression huggingface dataset:
import sys
n=int(input())
a=[]
for i in range(1,n+1):
    if (i%3==0):
        a.append(i)
    else:
        j=str(i)
        for k in range(len(j)):
            if j[k]=="3":
                a.append(i)
                break
for i in a:
    sys.stdout.write(" {0}".format(i))
sys.stdout.write("\n")

Measured memory_bytes: 5952
#include <vector>
#include <map>
#include <string>
#include <iostream>
#include <cmath>
#include <random>
#include <cstdlib>
#include <algorithm>
using namespace std;
#define MK make_pair
#define PB push_back
#define MSI map<string,int>
#define VI vector<int>
#define VII vector<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define W1 while(1);
const int MOD = 1000000007;
int main()
{
	int a, b, c,d;
	cin >> a >> b >> c >> d;
	if (a*b>c*d)
	{
		cout << a*b << endl;
	}
	else
	{
		cout << c*d << endl;
	}
	return 0;
}

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

int main() {
	// your code goes here
	string s;
	cin >> s;
	int cond = 1, cond1 = 0;
	if(s[0] != 'A') cond = 0;
	for(int i = 1; i < s.size(); i++){
	    if(s[i] >= 'A' && s[i] <= 'Z'){
	        if(s[i] == 'C' && cond1 == 0 && i > 1 && i < s.size()-1) cond1 = 1;
	        else cond = 0;
	        
	    }
	}
	if(cond && cond1) cout << "AC";
	else cout << "WA";
	return 0;
}


Measured memory_bytes: 256
case=1
while True:
    n=input()
    if n==0:break
    value=1
    grid=[[0]*n for i in range(n)]
    x=y=0
    if n==1:
        grid[y][x]=1
    while value<n*n:
        grid[y][x]=value
        if x<n-1:
            x+=1
            value+=1
            grid[y][x]=value
        else:
            y+=1
            value+=1
            grid[y][x]=value
        while x>0 and y<n-1:
            y+=1
            x-=1
            value+=1
            grid[y][x]=value
        if y<n-1:
            y+=1
            value+=1
            grid[y][x]=value
        else:
            x+=1
            value+=1
            grid[y][x]=value
        while y>0 and x<n-1:
            y-=1
            x+=1
            value+=1
            grid[y][x]=value
    print "Case %d:"%case
    for i in range(n):
        print "%3d"*n%tuple(grid[i])
    case+=1

Measured memory_bytes: 4296
import sys
input = sys.stdin.readline
sys.setrecursionlimit(pow(10, 6))


class BIT:
    def __init__(self, n):
        self.size = n
        self.tree = [0 for _ in range(n+1)]
        self.p = 2**(n.bit_length() - 1)
        self.dep = n.bit_length()

    def get(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s

    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

    def bl(self, v):
        if v <= 0:
            return -1
        s = 0
        k = self.p
        for _ in range(self.dep):
            if s + k <= self.size and self.tree[s+k] < v:
                s += k
                v -= self.tree[s+k]
            k //= 2
        return s + 1


def main():
  n, m = map(int, input().split())
  lr = [tuple(map(int, input().split())) for _ in range(n)]
  bt = BIT(m)

  lr = list(sorted(lr, key=lambda x: x[1]-x[0]))
  i = 0
  for d in range(1, m+1):
    for i in range(i, n):
      if lr[i][1]-lr[i][0]+1==d:
        bt.add(lr[i][0], 1)
        bt.add(lr[i][1]+1, -1)
        if i == n-1:
          i = n
          break
      else:
        break

    ans = n - i
    for j in range(d, m+1, d):
      ans += bt.get(j)
    print(ans)


if __name__ == '__main__':
  main()


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

#define REP(i,n) for(int i=0;i<n;++i)
#define REPR(i,n) for(int i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(int i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define SUR 1000000007
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define MP make_pair
#define SV(n,v) {int tmp;for(int i=0;i<n;++i){scanf("%d",&tmp);v.push_back(tmp);}}

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

using namespace std;

typedef pair<int,int> pii;

int main(){

  string s;
  cin >> s;

  llong len = s.length();
  llong ans = len * (len - 1) / 2 + 1;
  REP(i,26){
    llong count = 0;
    REP(j,len){
      if(s[j] == 'a' + i){
        count++;
      }
    }
    if(count > 1){
      ans -= count * (count - 1) / 2;
    }
  }

  printf("%lld\n", ans);
  return 0;
}



Measured memory_bytes: 640
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Scanner;

public class Main {

	Scanner sc;

	Main() {
		sc = new Scanner(System.in);
	}

	void run() {
		boolean p[] = new boolean[30001];

		Arrays.fill(p, true);

		p[0] = false;
		p[1] = false;
		LinkedList<Integer> pr = new LinkedList<Integer>();

		int dp[] = new int[30001];

		for (int i = 2; i * i < 30001; i++) {
			if (p[i]) {
				for (int j = i + i; j < 30001; j = j + i) {
					p[j] = false;
				}
			}
		}
		int pm[] = new int[3333];
		int ind = 0;
		for (int i = 0; i < 30001; i++) {
			if (p[i]) {
				pm[ind++] = i;
			}
		}
//		System.out.println(Arrays.toString(pm));
		for (int i = 0; pm[i]!=0; i++) {
			int pi = pm[i];
			for (int j = i; pm[j]!=0; j++) {
				int pj = pm[j];
				if (pi + pj > 30000) {
					break;
				}
				for (int k = j; pm[k]!=0; k++) {
					int pk = pm[k];
					if (pi + pj <= pk) {
						break;
					}
					if(pi+pj+pk>30000){
						break;
					}
//					System.out.println(pi+" "+pj+" "+ pk +" " + (pi + pj + pk));
					dp[pi + pj + pk]++;
				}
			}
		}

		for (;;) {
			int t = sc.nextInt();

			if (t == 0) {
				break;
			}
			System.out.println(dp[t]);
		}
	}

	public static void main(String[] args) {
		Main m = new Main();
		m.run();
	}

}

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

long long f(long long n) {
  long long res = 0;
  while (n > 0) {
    res += n % 10;
    n /= 10;
  }
  return res;
}

double g(long long n) {
  return (double)(n)/f(n);
}

int main() {
  vector<long long> res;
  long long base = 1;

  // まずは候補を (1〜150)99999 的なやつを全列挙
  for (int k = 0; k < 15; k++) {
    for (int l = 1; l < 150; l++) {
      res.push_back(base * (l + 1) - 1);
    }
    base *= 10;
  }
  sort(res.begin(), res.end());
  res.erase(unique(res.begin(), res.end()), res.end());

  // ダメなやつを除く
  for (long long k = 0; k < res.size(); k++) {
    for (long long l = k + 1; l < res.size(); l++) {
      if (g(res[k]) > g(res[l])) {
        res.erase(res.begin() + k--);
        break;
      }
    }
  }

  long long num;
  cin >> num;
  for (long long k = 0; k < num; k++) {
    cout << res[k] << endl;
  }
}

Measured memory_bytes: 256
N = int(input())
S = [''] * N
for i in range(N):
  S[i] = input()
cnt = 0
for a in range(N):
  for i in range(N):
    _i = (i - a) % N
    for j in range(i):
      if S[_i][j] != S[(j - a) % N][i]:
        break
    else:
      continue
    break
  else:
    cnt += N
print(cnt)

Measured memory_bytes: 41948
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<cmath>
#include<string>

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

using namespace std;
 
typedef long long int ll;

const ll INF=(ll)1e18;

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

    map<ll,int> m;

    REP(i,N){
        ll a;
        cin >> a;
        m[a]++;
    }

    int ans=0;
    for(auto itr = m.begin(); itr != m.end(); itr++){
        if(itr->second % 2 != 0){
            ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 6528
#include<stdio.h>

int main (void){
	
	int a,i,l,m,n,max1,max2,max3;
	
	scanf("%d",&a);
	
	for(i=0;i<a;i++){
		scanf("%d",&l);
		max1 = l;
		
		scanf("%d",&m);
		if(max1<m){
			max1 = m;
			max2 = l;
		}else{
			max1 = l;
			max2 = m;
		}
		
		scanf("%d",&n);
		if(max1<n){
			max3 = max2;
			max2 = max1;
		    max1 = n;
		}else if(max2>n){
			max3 = n;
		}else if(max2<n<max1){
			max3 = max2;
			max2 = n;
		}
	if((max1)*(max1)==(max2)*(max2)+(max3)*(max3)){
		printf("YES\n");
	}else{
		printf("NO\n");
	}
	}
return 0;
}
		

Measured memory_bytes: 580
n = int(input())

X = [0]*(n+1)
for i in range(1, n+1):
    X[i] += 1
    j = 2*i
    while j <= n:
        X[j] += 1
        j += i
#print(X[0:10])

ans = 0
for k in range(1, n+1):
    ans += k*X[k]
print(ans)


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

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

using namespace std;

int main(){
  ll n;cin>>n;
  vector<ll> a(n),ca(n);
  rep(i,n){
    cin>>a[i];
    ca[i]=a[i];
  }

  sort(a.begin(), a.end());
  sort(ca.begin(), ca.end());
//rep(i,n)cout<<a[i]<<' ';cout<<endl;

  rep(i,n-1)ca[i+1] = ca[i]+ca[i+1];
//rep(i,n)cout<<a[i]<<' ';cout<<endl;

  ll c=1;
  rep(i,n-1){
    if(ca[i]*2 >= a[i+1])c++;
    else c=1;
  }
  cout<<c<<endl;

  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define LL long int
#define ULL unsigned long int
#define MOD (long int)10e9 + 7
#define LD long double

int main(){
    ULL n;
    cin >> n;

    int i = 0;

    LL k = 100;

    while(k < n){
        i++;
        k *= (LD)1.01;
    }


    cout << i << endl;


    return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<math.h>
#include<algorithm>

using namespace std;

int main(){
  int n;
  cin >> n;
  long long a[100000];
  int numm = 0;
  int zflag = 0;
  int min = 1000000000;
  long long sum = 0;
  for(int i = 0; i < n ; i++){
    cin >> a[i];
    int aai = abs(a[i]);
    sum += aai;
    if(min > aai) min = aai;
    if(a[i] < 0) numm++;
    else if(a[i] == 0) zflag = 1;
  }
  if(zflag || numm%2 == 0) cout << sum << endl;
  else{
    cout << sum - 2*min << endl;
  }
}


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

int main(){
    int N,ans = 0;
    cin>>N;
    vector<int> P(N);
    for (int i=0;i<N;i++){
        cin>>P.at(i);
    }
    int min = P.at(0);
    for (int i=0;i<N;i++){
        if(min>=P.at(i)){
            min = P.at(i);
            ans += 1;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;

#define SCD(t) scanf("%d",&t)
#define SCLD(t) scanf("%ld",&t)
#define SCLLD(t) scanf("%lld",&t)
#define SCC(t) scanf("%c",&t)
#define SCS(t) scanf("%s",t)
#define SCF(t) scanf("%f",&t)
#define SCLF(t) scanf("%lf",&t)
#define MEM(a, b) memset(a, (b), sizeof(a))
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert( B <= A && A <= C)
#define MP make_pair
#define PB push_back
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
const double pi=acos(-1.0);
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<vi> vvi;
typedef map<int,int> mpii;
typedef set<int> seti;
typedef multiset<int> mseti;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }

int main(int argc, const char * argv[]) {
    int n, weightCapacity;
    SCD(n);
    SCD(weightCapacity);
    int weight[n], value[n];
    int total_sum_value = 0;
    FOR(i, 0, n, 1) {
        SCD(weight[i]);
        SCD(value[i]);
        total_sum_value += value[i];
    }
    // dp[i] = minimum weight to have value exactly i
    vector<ull> dp;
    dp.assign(total_sum_value + 1, weightCapacity + 1);
    dp[0] = 0;
    
    FOR(item, 0, n, 1) {
        RFOR(target_value, total_sum_value, value[item], 1) {
            amin(dp[target_value], dp[target_value - value[item]] + weight[item]);
        }
    }
    

    // answer = largest i such that dp[i] <= weightCapacity
    int ans = 0;
    RFOR(i, total_sum_value, 0, 1) {
        if (dp[i] <= weightCapacity) {
            ans = i;
            break;
        }
    }
    
    printf("%d\n", ans);
}


Measured memory_bytes: 1024
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <list>
#include <stack>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){
    string s; cin>>s;
    int ans=0;
    for (int i=0;i<sz(s);i++){
        ans += s[i]-'0';
    }
    cout << ((ans%9)?"No":"Yes") << endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


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

typedef long long ll;

int to_win(int K, int p) {
    int num = 0;
    while (p < K) {
        num++;
        p *= 2;
    }
    return num;
}

int main() {
double N, K;  cin >> N >> K;

double ans = 0;
for (int p = 1; p <= N; p++) {
    ans += 1 / N * pow(0.5, to_win(K, p));
}

cout << setprecision(12) << ans << endl;

}

Measured memory_bytes: 256
use std::io::{self, Read};
use std::str::FromStr;
pub struct Scanner<R: Read> {
    reader: R,
}
impl<R: Read> Scanner<R> {
    pub fn new(reader: R) -> Scanner<R> {
        Scanner { reader: reader }
    }
    pub fn read<T: FromStr>(&mut self) -> T {
        let s = self
            .reader
            .by_ref()
            .bytes()
            .map(|c| c.expect("failed to read char") as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        s.parse::<T>().ok().expect("failed to parse token")
    }
}

struct UnionFind {
    vals: Vec<usize>, // 自身の親を記録する。親がない場合は自身のindexを保持する
}

impl UnionFind {
    fn new(size: usize) -> UnionFind {
        UnionFind {
            vals: (0..size).map(|i| i).collect(),
        }
    }

    fn parent(&mut self, idx: usize) -> usize {
        if self.vals[idx] == idx {
            idx
        } else {
            // 親の探索と同時に根となる親へ参照を変更する
            let p = self.vals[idx];
            let p = self.parent(p);
            self.vals[idx] = p;
            p
        }
    }

    fn same(&mut self, id1: usize, id2: usize) -> bool {
        self.parent(id1) == self.parent(id2)
    }

    fn unite(&mut self, id1: usize, id2: usize) {
        let p1 = self.parent(id1);
        let p2 = self.parent(id2);
        if p1 != p2 {
            self.vals[p1] = p2;
        }
    }
}

fn main() {
    let sin = io::stdin();
    let sin = sin.lock();
    let mut sc = Scanner::new(sin);

    let n: usize = sc.read();
    let q: usize = sc.read();

    let mut uf = UnionFind::new(n);

    for _ in 0..q {
        let com: usize = sc.read();
        let x: usize = sc.read();
        let y: usize = sc.read();

        match com {
            0 => { uf.unite(x, y); },
            1 => { 
                if uf.same(x,y) {
                    println!("1");
                } else {
                    println!("0");
                };
            },
            _ => { panic!("irregular command"); },
        }
    }
}



Measured memory_bytes: 5276
A, B, C = [int(x) for x in input().split()]

def IsOdd(a, b, c):
    if a % 2 == 1:
        return True
    if b % 2 == 1:
        return True
    if c % 2 == 1:
        return True
    return False

def Exchange(a, b, c):
    retA = 0
    retB = 0
    retC = 0
    retA = (b // 2) + (c // 2)
    retB = (a // 2) + (c // 2)
    retC = (a // 2) + (b // 2)
    return retA , retB , retC

cnt = 0
routedA = []
while True :
    if IsOdd(A, B, C):
        break
    if A in routedA:
        cnt = -1
        break
    routedA.append(A)
    cnt += 1
    ret = Exchange(A, B, C)
    A = ret[0]
    B = ret[1]
    C = ret[2]

print(cnt)



Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define N 5006
using namespace std;
int a,b,n,t,p[N],ans[N];char c;
int ask(int x,int y)
{
	printf("? %d %d\n",x,y);
	fflush(stdout);
	scanf("%*c%c",&c);
	return c=='Y'?1:0;
}
int main()
{
	scanf("%d%d",&a,&b);n=a+b;
	if(a<=b)return puts("Impossible"),0;
	for(int i=0;i<n;i++){
		if(t){
			if(ask(p[t],i))p[++t]=i;
			else t--;
		}else p[++t]=i;
	}
	for(int i=0;i<n;i++)ans[i]=ask(p[t],i);
	putchar('!');
	for(int i=0;i<n;i++)putchar(ans[i]+48);
	return puts(""),0;
}

Measured memory_bytes: 724
#include <stdio.h>

int main() {
  int a, b, ans;
  char op;
  while (scanf("%d %c %d", &a, &op, &b), op != '?') {
    if (op == '+') ans = a + b;
    else if (op == '-') ans = a - b;
    else if (op == '*') ans = a * b;
    else ans = a / b;
    printf("%d\n", ans);
  }
  return 0;
}


Measured memory_bytes: 2128
import java.util.*;

public class Main
{
    public static int smallest(int n) {
        int ret = Integer.MAX_VALUE;
        for (int i = 1; i <= n/2; i++) {
            int k = i;
            int j = n - i;
            int n1 = 0;
            while (k != 0) {
                n1 += (k % 10);
                k /= 10;
            }
            int n2 = 0;
            while (j != 0) {
                n2 += (j % 10);
                j /= 10;
            }
            ret = Math.min(ret, n1 + n2);
        }
        return ret;
    }


    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        System.out.println(smallest(n));

    }

}


Measured memory_bytes: 21716
import math
import collections
import bisect
from collections import deque
from copy import copy, deepcopy
 
 
def main():
    X,K,D = map(int,input().split())
    N = abs(X)//D
    if N>=K:
        ans = abs(X)-K*D
    else:
        if (K-N)%2==0:
            ans = abs(X)-N*D
        else:
            ans = (N+1)*D-abs(X)
    print(ans)
        
 
if __name__ == '__main__':
    main()

Measured memory_bytes: 9548
N = gets.to_i
ps = gets.split.map(&:to_i)

ans = 0
same_count = 0
(ps + [-1]).each.with_index do |n, i|
  i += 1
  if n == i
    same_count += 1
  else
    m = same_count / 2
    ans += (same_count.even? ? m : m + 1)
    same_count = 0
  end
end
puts ans


Measured memory_bytes: 8836
program sample
    implicit none
    character(100)::s,t
    integer(8) :: i,j,k,m,n
    integer(8)::a,b,c,d,ans
    integer(8),allocatable::x(:),y(:)
  
    read(*,*) n
    allocate(x(n))
    read(*,*)x
    m=0
    do i=1,n
        if(x(i)>m)then
            m=x(i)
        elseif(x(i)<m)then
            ans=ans+m-x(i)
        endif
    end do
	write(*,*)ans
    stop
end program sample
  



Measured memory_bytes: 4656
#include <cstdio>
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
using namespace std;

int main()
{
	int n;
	cin >> n;
	int a [1001];
	int maxn = 1000000000;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = -100; i <= 100; i++) {
		int sum = 0;
		for (int j = 0; j < n; j++) {
			sum += (a[j] - i) * (a[j] - i);
		}
		maxn = min(maxn, sum);
	}
	cout << maxn << endl;
}

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

int main() {
  int N; cin>>N;
  map<int, int> kouho;
  for(int i=0; i<N; i++){
    int a; cin>>a;
    kouho[a-1]++;
    kouho[a]++;
    kouho[a+1]++;
  }
  int max=0;
  for(auto p:kouho){
    auto v=p.second;
    if(v>max) max=v;
  }
  cout<<max<<endl;
}


Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
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;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

bool dp[90][90][14000];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w;
    cin >> h >> w;
    vector<vector<int>> c(h, vector<int>(w));
    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            cin >> c[i][j];
        }
    }
    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            int b;
            cin >> b;
            c[i][j] = abs(c[i][j] - b);
        }
    }
    dp[0][0][c[0][0]] = 1;
    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            for(int k = 0; k <= 12800; k++) {
                if(dp[i][j][k]) {
                    if(i + 1 < h) {
                        dp[i + 1][j][k + c[i + 1][j]] =
                            dp[i + 1][j][abs(k - c[i + 1][j])] = 1;
                    }
                    if(j + 1 < w) {
                        dp[i][j + 1][k + c[i][j + 1]] =
                            dp[i][j + 1][abs(k - c[i][j + 1])] = 1;
                    }
                }
            }
        }
    }
    int ans = INF;
    for(int i = 0; i < 14000; i++) {
        if(dp[h - 1][w - 1][i]) {
            chmin(ans, i);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 99584
import sys

n,m = (int(i) for i in input().split())

h = [int(i) for i in input().split()]

a = [None]*m
b = [None]*m
for i in range(m):
    a[i],b[i] = (int(j) for j in input().split())
    a[i]-=1
    b[i]-=1

hantei = [True]*n

for i in range(m):
    if h[a[i]] < h[b[i]]:
        hantei[a[i]] = False
    elif h[a[i]] > h[b[i]]:
        hantei[b[i]] = False
    else:
        hantei[a[i]] = hantei[b[i]] = False

ans = 0

for i in range(n):
    if hantei[i] == True:
        ans +=1

print(ans)
        

Measured memory_bytes: 21880
#include <iostream>
using namespace std;
int main(){
	int A,B,C,D,rectangle1,rectangle2;
	//Vertical side length of rectangle1
	cin >> A;
	// Horizontal side length of rectangle1
	cin >>  B;
	//Vertical side length of rectangle2
	cin >> C;
	// Horizontal side length of rectangle2
	cin >>  D;
	rectangle1 = A*B;
	rectangle2 = C*D;
	if( rectangle1 >= rectangle2 ){
		cout << rectangle1<<endl;
		
	}
	else if(rectangle2 >= rectangle1 ){
		cout << rectangle2 << endl;
	}
}

Measured memory_bytes: 256
#include<iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
#include <functional>
#include<climits>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)
int main(){ 
  string a;cin>>a;
  if(a[1]=='B')cout<<"ARC";
  else cout<<"ABC";
  }


Measured memory_bytes: 3592
def lunlundfs(num, digs):
    if digs == 0:
        return [num]
    if num > 0:
        a = lunlundfs(num-1, digs-1)
    else:
        a = []
    b = lunlundfs(num, digs-1)
    if num < 9:
        c = lunlundfs(num+1, digs-1)
    else:
        c = []
    res = []
    for x in a:
        res.append(num*10**digs + x)
    for x in b:
        res.append(num*10**digs + x)
    for x in c:
        res.append(num*10**digs + x)
    return res

def genlunlun(dig):
    lunlunlist = []
    for front in xrange(1,10):
        for d in xrange(dig):
            lunlunlist.extend(lunlundfs(front,d))
    lunlunlist = sorted(lunlunlist)
    return lunlunlist

ll = genlunlun(10)
k = int(raw_input())
print ll[k-1]

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

using namespace std;

#define pb push_back
#define mp make_pair
#define MOD ((int)(1e9) + 7)
#define fast cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false)
const int N = ((int)1e5) + 5;
const int M = ((int)1e3) + 5;
const int mod = 2019;

long long int l,r;

int main ()
{
	fast;
	cin >> l >> r;

	if ((l-1) / 2019 != r / 2019)
		return cout << 0,0;
	int a = INT_MAX;
	l = l % 2019;
	r = r % 2019;
	for (int i = l; i <= r - 1; i++)
	{
		for (int j = i + 1; j <= r; j++)
		{
			a = min(a,(i * j) % mod);
		}
	}
	cout << a;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> v(n), c(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> c[i];
  }
  int sum = 0;
  for (int i = 0; i < n; i++) {
    if (v[i] - c[i] > 0) sum += (v[i] - c[i]);
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define max(p,q)((p)>(q)?(p):(q))

typedef struct edge{ll s,g,c;}E;
int edgehikaku(const void*a,const void*b){
	E*p=(E*)a,*q=(E*)b;
	if((*p).s<(*q).s)return -1;
	if((*p).s>(*q).s)return  1;
	if((*p).g<(*q).g)return -1;
	return 1;
}

E e[200010];
ll es[200010];
ll d[100010];
int n;

void dfs(int v,ll c){
	if(d[v])return;
	d[v]=c;
	for(int t=es[v];t<2*n-2&&e[t].s==v;t++)dfs(e[t].g,c+e[t].c);
}

int main(){
	scanf("%d",&n);
	rep(i,0,n-1){
		ll a,b,c;
		scanf("%lld%lld%lld",&a,&b,&c);
		a--;
		b--;
		e[i].s=e[i+n-1].g=a;
		e[i].g=e[i+n-1].s=b;
		e[i].c=e[i+n-1].c=c;
	}
	qsort(e,2*n-2,sizeof(E),edgehikaku);
	es[0]=0;
	ll t=0;
	rep(i,1,n){
		while(t<2*n-2&&e[t].s<i)t++;
		es[i]=t;
	}
	
	int q,k;
	scanf("%d%d",&q,&k);
	k--;
	dfs(k,1);
	while(q--){
		int a,b;
		scanf("%d%d",&a,&b);
		a--;
		b--;
		printf("%lld\n",d[a]+d[b]-2);
	}
	return 0;
}

Measured memory_bytes: 11052
#include<bits/stdc++.h>
using namespace std;
#define forr(i,a,n)	for(long long int i=a; i<n; i++)
#define loop(i,a,n)	for(long long int i=a; i>=n; i--)

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

	long long int a,b,c;
	cin>>a>>b>>c;
	swap(a,b);
	swap(a,c);
	cout<<a<<' '<<b<<' '<<c;
		
	
	return 0;	
}

Measured memory_bytes: 256
using System;

class Rectangle
{
    public static void Main()
    {
        var input = Console.ReadLine().Trim().Split(' ');
        int a = int.Parse(input[0]);
        int b = int.Parse(input[1]);
        int w = a * b;
        int l = (a + b) * 2;

        Console.WriteLine(string.Format("{0} {1}", w, l));
    }
}

Measured memory_bytes: 5624
#include <stdio.h>

int main() {
    int c[3][3];
    for(int i = 0; i < 3; ++i) {
        scanf("%d %d %d", &c[i][0], &c[i][1], &c[i][2]);
    }

    if (c[0][1] - c[0][0] == c[1][1] - c[1][0] &&
        c[1][1] - c[1][0] == c[2][1] - c[2][0] &&
        c[0][2] - c[0][0] == c[1][2] - c[1][0] &&
        c[1][2] - c[1][0] == c[2][2] - c[2][0]) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }

    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#include<queue>
#define ll long long
#define itn int
#define co(ans) cout<<ans<<endl;
#define COYE cout<<"YES"<<endl;
#define COYe cout<<"Yes"<<endl;
#define COye cout<<"yes"<<endl;
#define CONO cout<<"NO"<<endl;
#define CONo cout<<"No"<<endl;
#define COno cout<<"no"<<endl;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
using namespace std;


int main(){
  int A[3],ans=0;
  REP(i,3){
    cin>>A[i];
    ans+=A[i];
  }
  
  if(ans<=21) cout<<"win"<<endl;
  else cout<<"bust"<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#define rep(i,n) for(int i=0;i<n;i++)
using  namespace std;
int main(){
	int n,m,ans;
	double sx[500],sy[500],sz[500],tx[50],ty[50],tz[50],phi[50];
	while(cin>>n,n){
		rep(i,n)cin>>sx[i]>>sy[i]>>sz[i];
		cin>>m;rep(i,m)cin>>tx[i]>>ty[i]>>tz[i]>>phi[i];
		ans=0;
		rep(i,n){
			bool f=0;
			if(!f)rep(j,m){
				if((sx[i]*tx[j]+sy[i]*ty[j]+sz[i]*tz[j])/
					sqrt(sx[i]*sx[i]+sy[i]*sy[i]+sz[i]*sz[i])/
					sqrt(tx[j]*tx[j]+ty[j]*ty[j]+tz[j]*tz[j])>=cos(phi[j])){
					f=1;break;
				}
			}
			ans+=f;
		}
		cout<<ans<<endl;
	}
	return 0;
}

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

const int maxn=2e5+10;
int h,w,n,ans=1e9;
vector<int> vec[maxn];
bool st[maxn<<2],tag[maxn<<2];

inline void push_up(int rt){
	st[rt]=st[rt<<1]|st[rt<<1|1];
}
inline void push_down(int rt){
	if(tag[rt]){
		tag[rt<<1]=tag[rt<<1|1]=true;
		st[rt<<1]=st[rt<<1|1]=true;
		tag[rt]=false;
	}
}
void modify0(int rt,int l,int r,int pos){
	if(l==r){
		st[rt]=false;
		return;
	}
	push_down(rt);
	int mid=l+r>>1;
	if(pos<=mid)
		modify0(rt<<1,l,mid,pos);
	else
		modify0(rt<<1|1,mid+1,r,pos);
	push_up(rt);
}
void modify1(int rt,int l,int r,int x,int y){
	if(l==x&&r==y){
		st[rt]=true;
		tag[rt]=true;
		return;
	}
	push_down(rt);
	int mid=l+r>>1;
	if(y<=mid)
		modify1(rt<<1,l,mid,x,y);
	else if(x>mid)
		modify1(rt<<1|1,mid+1,r,x,y);
	else{
		modify1(rt<<1,l,mid,x,mid);
		modify1(rt<<1|1,mid+1,r,mid+1,y);
	}
	push_up(rt);
}
int query(int rt,int l,int r,int x,int y){
	if(!st[rt])
		return -1;
	if(l==r)
		return l;
	push_down(rt);
	int mid=l+r>>1;
	if(y<=mid)
		return query(rt<<1,l,mid,x,y);
	else if(x>mid)
		return query(rt<<1|1,mid+1,r,x,y);
	else{
		int tmp=query(rt<<1,l,mid,x,mid);
		if(~tmp)
			return tmp;
		else
			return query(rt<<1|1,mid+1,r,mid+1,y);
	}
}

int main(){
	scanf("%d%d%d",&h,&w,&n);
	while(n--){
		int x,y;
		scanf("%d%d",&x,&y);
		vec[y].push_back(x);
	}
	modify1(1,1,h,1,1);
	for(int i=1;i<=w;++i){
		sort(vec[i].begin(),vec[i].end());
		for(int j=0;j<vec[i].size();++j)
			modify0(1,1,h,vec[i][j]);
		vec[i].push_back(h+1);
		for(int j=0,last=0;j<vec[i].size();last=vec[i][j],++j){
			if(last==vec[i][j]-1)
				continue;
			int pos=query(1,1,h,last+1,vec[i][j]-1);
			if(~pos){
				modify0(1,1,h,pos);
				if(pos!=vec[i][j]-1)
					modify1(1,1,h,pos+1,vec[i][j]-1);
				ans=min(ans,vec[i][j]-1);
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 12416
/*
auth - @sportykush
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
 
using namespace __gnu_pbds;
using namespace std;
 
typedef long long int ll;
typedef long double ld;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; 
 
//#define mp make_pair
#define bug(v)                    cerr<<#v<<" = "<<(v)<<endl;
#define ERASE(x)                  x.erase(unique(x.begin(),x.end()),x.end())
#define pb                        emplace_back
#define vii                       vector<int>
#define vll                       vector<ll>
#define vpll                      vector< pair <ll,ll> >
#define pll                       pair <ll,ll>
#define pii                       pair <int,int>
#define pq                        priority_queue< int >
#define khtm                      "\n"
#define F                         first
#define S                         second
#define fr(i,a,n)                 for(i=a;i<n;i++)
#define mem(arr,l)                memset(arr,l,sizeof arr)
#define ALL(x)                    x.begin(), x.end()
#define frr(i,a,n)                for(i=n-1;i>=a;i--)
#define fast                      ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define testcase                  ll T; cin>>T; while(T--)


const double pi = 3.14159265359;
const int MAX = 1e6 +2;
const ll inf =  1e18;
const int N = 1010;
//const ll mod = 998244353 ;
const ll mod=1e9+7;
inline ll add(ll a,ll b){a+=b;if(a>=mod)a-=mod;return a;}
inline ll mul(ll a,ll b){return ((a%mod)*1ll*b)%mod;}
inline ll power(ll a,ll b){ll rt=1;while(b>0){if(b&1)rt=mul(rt,a);a=mul(a,a);b>>=1;}return rt;}


/*
important builtin functions
__gcd(value1, value2)
__builtin_ffs(x)
  Number of leading zeroes: __builtin_clz(x)
  Number of trailing zeroes : __builtin_ctz(x)
  Number of set bits: __builtin_popcount(x)
*/
 

ll i,j,k,l,m,r,n;
ll a[MAX],b[MAX];

ll dp[MAX];


int main()
{
 

//cout << setprecision(15) << fixed;
fast

	ll val = 0;
	cin >> n >> k;
	fr(i,1,1+n)
	{
		cin >> a[i] >> b[i];
		val += b[i];
	}
	fr(i,0,val+1)
		dp[i] = inf;
	dp[0] = 0;
	
	for(int item = 1;item<=N;item++){
		int w = a[item], v = b[item];
		for(int i = val;i>=v;i--){
			dp[i] = min(dp[i],dp[i - v] + w);
		}
	}
	ll ans = val;
	for(int i = val;i>=0;i--){
		if(dp[i] <= k){
			ans = i;
			break;
		}
	}
	cout << ans;

 
  return 0;
 
}


Measured memory_bytes: 5120
_ = int(input())
ales = sorted(list(map(int, input().split())))[::-1]
def gcd(a, b):
  while b != 0:
    a, b = b, a%b
  return a
def lcm(a, b):
  return a * b / gcd(a, b)
k = ales[0]
for a in ales[1:]:
  k = lcm(k, a)
numerator = int(k/ales[0])
for a in ales[1:]:
  numerator += int(k/a)
print(k/numerator)

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


int main(){
  string O, E;
  cin >> O >> E;

  for(int ii=0; ii<E.size(); ii++){
    cout << O[ii] << E[ii];
  }
  if(O.size() != E.size()){
    cout << O.back();
  }
  cout << endl;
  return 0;
}

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

using namespace std;

typedef long long ll;

const ll modi = 1e9+7;

inline int mod(ll n, ll m){ ll ret = n%m; if(ret < 0) ret += m; return ret; }

ll exp(ll a,ll b,ll m){
    if(b==0LL) return 1LL;
    if(b==1LL) return mod(a,m);
    ll k = mod(exp(a,b/2,m),m);
    if(b&1LL){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);

}

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

    ll n, k;

    cin >> n >> k;

    vector<ll> ans(k+1);

    ll res = 0;

    for(ll i=k; i>=1; i--){
        ll qtd = k/i;

        ans[i] = exp(qtd, n, modi);

        for(ll j=i+i; j<=k; j+=i){
            ans[i] = (ans[i] - ans[j] + modi)%modi;
        }

        res = (res + ((ans[i]*i)%modi))%modi;
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 3992
#include<iostream>
#include<vector>
using namespace std;
string a;
int main(){
	cin >> a;
	int res = 0, ans = 0;
	for(int i = 0;i < a.size();i += 2){
		if(a[i] != '1')++res;
		if(i + 1 < a.size() and a[i + 1] != '0')++res;
	}
	for(int i = 0;i < a.size();i += 2){
		if(a[i] != '0')++ans;
		if(i + 1 < a.size() and a[i + 1] != '1')++ans;
	}
	cout << min(ans, res) << '\n';
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, a, b) for (int i = a; i < b; i++)

#define MAX ((int)2.0e5)

int n, q;
int S[MAX];
int T[MAX];

bool is_exists(int v) {
  rep(i, n) {
	if (S[i] == v) return true;
  }
  return false;
}

int main() {
  cin >> n;
  rep(i, n) cin >> S[i];
  cin >> q;
  rep(i, q) cin >> T[i];

  int cnt = 0;
  rep(i, q) {
	if (is_exists(T[i])) cnt++;
  }
  cout << cnt << endl;
  return 0;
}

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

int main(){
  int N;
  cin>>N;
  string S;
  cin>>S;
  int cnt=0,mc=0;
  for(int i=0;i<N;i++){
    if(S[i]=='('){
      cnt++;
    }else{
      cnt--;
    }
    mc=min(mc,cnt);
  }
  while(mc){
    cout<<'(';
    mc++;
    cnt++;
  }
  cout<<S;
  while(cnt){
    cout<<')';
    cnt--;
  }
  cout<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		String a = sc.next();
		String aa = "abcdefghijklmnopqrstuvwxyz";
		if(aa.indexOf(a) < 0) {
			System.out.println("A");
		} else {
			System.out.println("a");
		}



	}
}


Measured memory_bytes: 26960
#include <iostream>
#include <cstdio>
#include <string.h>
#include <queue>
#include <algorithm>
#include <math.h>
using namespace std;
typedef pair<int, int> P;
const int MAX_N = 1 << 24;
const int MAX_C = 8*7*6*5*4*3*2;
int checked[MAX_C + 10];
const int ele[] = {10000000,1000000,100000,10000,1000,100,10,1};


int convert(int n) {
    bool used[8];
    memset(used, 0, sizeof(used));
    int ret = 0;
    for (int i = 0; i < 8; i++) {
        int x = n/ele[i];  //i番目の番号
        n %= ele[i];
        used[x] = true;
        int E = 1;
        for (int j = 1; j < 8-i; j++) E *= j;
        int count = 0;
        for (int j = 0; j < x; j++) if (!used[j]) count++;
        ret += count*E;
    }
    return ret;
}

int main(int argc, const char * argv[])
{
    fill(checked, checked+MAX_C+10, MAX_C+100);
    queue<P> que;
    //数字と回数
    que.push(make_pair(1234567, 0));
    checked[convert(1234567)] = 0;
    //上、右、下、左
    int dx[] = {0, 1, 0, -1};
    int dy[] = {-1, 0, 1, 0};
    while (!que.empty()) {
        P p = que.front();
        que.pop();
        int num = p.first;
        int count = p.second;
        int n[2][4];  //現在の数値をカードの並びに変換
        int temp = num;
        //0の位置
        int zx;
        int zy;
        for (int i = 0; i < 2; i++) {
            for (int j = 0; j < 4; j++) {
                n[i][j] = temp / ele[i*4+j];
                temp -= n[i][j] * ele[i*4+j];
                if (n[i][j] == 0) {
                    zx = j;
                    zy = i;
                }
            }
        }
        
        for (int i = 0; i < 4; i++) {
            //交換する位置の候補
            int nx = zx + dx[i];
            int ny = zy + dy[i];
            //交換可能
            if (nx >= 0 && nx < 4 && ny >= 0 && ny < 2) {
                int nxt = 0;
                for (int j = 0; j < 2; j++) {
                    for (int k = 0; k < 4; k++) {
                        if (j == ny && k == nx) {
                            
                        } else if (j == zy && k == zx) {
                            nxt += n[ny][nx] * ele[j*4+k];
                        } else {
                            nxt += n[j][k] * ele[j*4+k];
                        }
                    }
                }
                int conv_nxt = convert(nxt);
                if (checked[conv_nxt] == MAX_C+100) {
                    checked[conv_nxt] = count+1;
                    que.push(make_pair(nxt, count+1));
                }
            }
        }
        
    }
   
    int n[8];
    while (~scanf("%d%d%d%d%d%d%d%d", &n[0], &n[1], &n[2], &n[3], &n[4], &n[5], &n[6], &n[7])) {
        int num = 0;
        for (int i = 0; i < 8; i++) {
            num += n[i]*ele[i];
        }
        int conv_num = convert(num);
        printf("%d\n", checked[conv_num]);
    }
    return 0;
}

Measured memory_bytes: 1388
#include<stdio.h>

int main() {
  int A,B,C;
  scanf("%d %d %d",&A,&B,&C );
  if (A+B+C==17,A*B*C==5*5*7) {
    printf("YES\n");
  }else{
    printf("NO\n");
  }
  return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] a = new int[n];
        int k = 0;
        for (int i = 0; i < n; i++) {
            int nextInt = in.nextInt();
            if (nextInt > k) k = nextInt;
            a[i] = nextInt;
        }
        int[] b = new int[n];
        System.out.println(countingSort(a, b, k));
    }

    private static String countingSort(int[] a, int[] b, int k) {
        int[] c = new int[k+1];
        // Count each value
        for (int value : a) {
            c[value]++;
        }
        // Number of values <= to i
        for (int i = 1; i <= k; i++) {
            c[i] += c[i-1];
        }
        for (int j = a.length - 1; j >= 0; j--) {
            b[c[a[j]]-1] = a[j];
            c[a[j]]--;
        }

        return printArray(b);
    }

    static String printArray(int[] a) {
        StringBuilder sb = new StringBuilder();
        sb.append(a[0]);
        for (int i = 1; i < a.length; i++) {
            sb.append(" ").append(a[i]);
        }
        return sb.toString();
    }
}



Measured memory_bytes: 507908
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>
#include <numeric>

using namespace std;

#define mod 1000000007

int main()
{
	int n;
	string s;
	cin >> n >> s;
	int e_sum_l[300001] = {};
	int e_sum_r[300001] = {};
	if(s[0] == 'E') e_sum_l[0] = 1;
	for(int i = 1; i < n; i++){
		e_sum_l[i] = e_sum_l[i - 1];
		if(s[i] == 'E') e_sum_l[i]++;
	}
	if(s[n - 1] == 'E') e_sum_r[n - 1] = 1;
	for(int i = n - 2; i >= 0; i--){
		e_sum_r[i] = e_sum_r[i + 1];
		if(s[i] == 'E') e_sum_r[i]++;
	}
	int ans = min(e_sum_r[1], n - 1 - e_sum_l[n - 2]);
	for(int i = 1; i < n - 1; i++){
		int l = i - e_sum_l[i - 1];
		int r = e_sum_r[i + 1];
		ans = min(ans, l + r);
	}
	cout << ans << endl;
}

Measured memory_bytes: 3076
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    int n;
    cin >> n;
    vector<int> x(n), y(n);
    vector<int> v(n); // n-1の順列
    rep(i,n) {
        cin >> x[i] >> y[i];
        v[i] = i;
    }
    double ans = 0;
    int fact = 0;
    do {
        double d = 0;
        rep(i,n-1) {
            int ind1 = v[i];
            int ind2 = v[i+1];
            d += sqrt( pow((x[ind1]-x[ind2]),2) + pow((y[ind1]-y[ind2]),2) );
        }
        ans += d;
        ++fact;
    } while (next_permutation(v.begin(), v.end()));
    cout << fixed; // std::fixedフラグ 小数点以下の桁数をsetprecisionで固定に
    cout << setprecision(6) << (double) ans/fact << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <tuple>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define repn(i, x) for (int i = 1; i <= (int)(x); i++)
#define repr(i, x) for (int i = ((int)(x) - 1); i >= 0; i--)
#define reprn(i, x) for (int i = ((int)(x)); i > 0; i--)
#define all(x) (x).begin, (x).end()
using namespace std;
typedef long long int64;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
const int MAX_NUM = 999999999;
//逆元を求める関数
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;
}
void solve() {
	int n; cin >> n;
	map<int, int> mp;
	vector<int> v;
	rep (i, n) {
		int x; cin >> x;
		mp[x]++;
		if (mp[x] == 2) v.push_back(x);
		if (mp[x] == 4) v.push_back(x);
	}	
	sort(v.begin(), v.end(), greater<>());
	if (v.size() < 2) cout << 0;
	else cout << 1LL * v[0] * v[1] << endl;
	return;
}
int main() {
	solve();
	return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <vector>
#include <unordered_map>
#include <map>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <deque>
#include <cmath>
#include <stack>
#include <queue>

#define endl "\n"

using namespace std;

int k, x, mx, mn;

int main(){

    cin >> k >> x;
    mx = x + (k-1);
    mn = x - (k-1);

    for(int i = mn; i < mx+1; i++){
        cout << i << " ";
    }




}

//g++ -std=c++14 comp.cpp; ./a.exe


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <queue>
#include <map>
#include <vector>
#include <set>
#include <cstdlib>
#include <stack>

using namespace std;

typedef long long LL;
typedef double db;
#define FAST ios::sync_with_stdio(false);
const int MaxN = 1e7;

int main(){
	int n , m , k;
	cin >> n >> m >> k;
	for(int i = 1 ; i <= k ; i++)
	{
		if(i % 2 == 1){
			if(n % 2 == 1)n--;
			n /= 2;
			m += n;
			}
		else {
			if(m % 2 == 1)m--;
			m /= 2;
			n += m;
			}
		}
	cout << n << " " << m << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{
    long int a,b;
    long long int c;
    scanf("%ld %ld",&a,&b);
    if(a==1||b==1)
    {
        printf("1");
        return 0;
    }
    if(a%2==0)  printf("%ld",(a/2)*b);
    if(a%2!=0&&b%2==0)
    {
        c=((a+1)/2+(a-1)/2)*(b/2);
        printf("%lld",c);
    }
    if(a%2!=0&&b%2!=0)
    {
        c=((a+1)/2+(a-1)/2)*((b-1)/2)+(a+1)/2;
        printf("%lld",c);
    }

    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>
int main(void)
{
  char s[200001];
  scanf("%s", s);
  int len=strlen(s);
  int i,sum=0;
  for(i=0;i<len;i++) sum+=s[i]-'0';
  if(sum%9==0) printf("Yes");
  else printf("No");

  return 0;
}

Measured memory_bytes: 1900
#include <stdio.h> 

int main(void) 
{ 

   int H, W,i,j; 
   while(scanf("%d %d",&H,&W) != EOF){
     if(H == 0 && W == 0){
       break;
     }

     for (i = 1; i <= H; i++) { 
         for (j = 1; j <= W; j++) { 
             if(i>1 && i<H && j>1 && j<W){
                printf("."); 
             }
             else{
                printf("#");
             }

         } 
           printf("\n"); 
        
     } 
    printf("\n");
   }
   return 0; 

} 



Measured memory_bytes: 1984
import sys
input = sys.stdin.readline

def main():
    n = int(input())

    def yakusu():
        for i in range(1, int(n**0.5)+1):
            if n%i == 0:
                yield i
                if i != n //i:
                    yield n//i

    for m in yakusu():
        m -= 1
        if m == 0:
            continue

        if n // m == n % m:
            yield m

print(sum(main()))

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
#define L long long
L f(L a,L b)
{
    if(a%b == 0)return a/b;
    else return a/b+1;
}
int main()
{
    L a,b,c;
    cin >> a >> b >> c;
    if(b >= a)cout << 1;
    else if(c >= b)cout << -1;
    else cout << f(a-b,b-c)*2+1;
    return 0;
}


Measured memory_bytes: 256