akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <cstring>
#include <climits>
#include <algorithm>
#include <map>

using namespace std;

int main() {
    int a[10];
    for (int i=0; i<10; i++) {
        cin >> a[i];
    }
    sort(a, a+10, greater<int>());
    for (int i=0; i<3; i++) {
        cout << a[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 3144
import bisect

N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

A.sort()
B.sort()
C.sort()

total = 0
for i in range(N):
    a = bisect.bisect_left(A,B[i])
    c = N - bisect.bisect_right(C,B[i])
    total += a*c

print(total)

Measured memory_bytes: 105572
N = int(input())
arms = []
for i in range(0, N):
  X, L = map(int, input().split(" "))
  arms.append((X + L, X - L))

arms.sort()
ans = 0
coord = -float('inf')

for arm in arms:
  if arm[1] >= coord:
    ans += 1
    coord = arm[0]

print(ans)

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

int main(void){
  int n, s = 0;
  
  cin >> n;
  
  int x = n;
  
  while(n>0){
    s += n%10;
    n /= 10;
  }
  
  cout << (x%s?"No":"Yes") << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#include <map>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

bool is_prime(int k, int i) {
    if(k == 2) return true;
    if(k <= i) return true;
    else {
        if(k % i == 0) return false;
        else return is_prime(k, i + 1);
    }
}


int main() {
    int n;
    cin >> n;
    vector<string> s(n);
    vector<int> p(n);
    REP(i, n) {
        cin >> s[i] >> p[i];
    }
    vector<pair<pair<string, int>, int>> pairs(n);
    REP(i, n){
        pairs[i] = make_pair(make_pair(s[i], -p[i]), i);
    }
    sort(pairs.begin(), pairs.end());
    REP(i, n){
        cout << pairs[i].second + 1 << endl;
    }


}

Measured memory_bytes: 768
#include<stdio.h>
#define N 100

int a[N];
int cnt=0;

void swap(int x,int y){
	int temp=a[x];
	a[x]=a[y];
	a[y]=temp;
	return;
}

void bubbleSort(int n){
	int i,j;
	
	for(i=n-1;i>=0;i--){
		for(j=0;j<i;j++){
			if(a[j] > a[j+1]){
				swap(j,j+1);
				cnt++;
			}
		}
	}
	
	return;
}

int main(){
	int n,i;
	
	scanf("%d",&n);
	
	for(i=0;i<n;i++)
		scanf("%d",&a[i]);
	
	bubbleSort(n);
	
	for(i=0;i<n-1;i++)
		printf("%d ",a[i]);
	printf("%d\n",a[n-1]);
	
	printf("%d\n",cnt);
	
	return 0;
	
}


Measured memory_bytes: 2088
import math
def colon(a, b, h, m):
  hour = 0.5 * (h * 60 + m) 
  minute = 6 * m
  angle = abs(hour - minute)
  angle = min(360 - angle, angle)
  rad = angle*(3.141592653589793238/180)
  #print(angle, rad)
  ans = math.sqrt(a**2+b**2-(2*a*b*(math.cos(rad))))
  return ans
  

a, b, h, m = map(int, input().split())
print(colon(a,b,h, m))


Measured memory_bytes: 9576
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main {
	private	static	BufferedReader	br = null;
	private	static	char[][]		wt = { { 'a', 'b', 'c', 'd', 'e' }, { 'f', 'g', 'h', 'i', 'j' }, { 'k', 'l', 'm', 'n', 'o' }, { 'p', 'q', 'r', 's', 't' }, { 'u', 'v', 'w', 'x', 'y' }, { 'z', '.', '?', '!', ' ' } };

	static {
		br = new BufferedReader(new InputStreamReader(System.in));
	}
 
    /**
     * @param args
     */
	public static void main(String[] args) {
		String  stdin = null;
		while ((stdin = parseStdin()) != null) {
			int		i = 0;
			int		l = stdin.length();
			boolean	f = (l % 2 == 0 && stdin.equals(stdin.replaceAll("[^1-6]", "")));
			String	o = "";

			while (f && i < l) {
				int	j = (stdin.charAt(i)-'1');
				int	k = (stdin.charAt(i+1)-'1');

				if ((f = (0 <= j && j <= 5 && 0 <= k && k <= 4))) {
					o += wt[j][k];
					i+=2;
				}
			}

			System.out.println((f) ? o: "NA");
		}
	}

	private static String parseStdin() {
		String  stdin = null;

		try {
			String  tmp = br.readLine();
			if (tmp != null) {
				if (!tmp.isEmpty()) stdin = tmp;
			}
		}
		catch (IOException e) {}

		return stdin;
	}
}

Measured memory_bytes: 17148
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

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

void solve() {
  int m, n;
  cin >> m >> n;
  vector<int> v;
  v.resize(n);
  for(int i = 0; i < n; i++) cin >> v[i];
  sort(v.begin(), v.end());
  int ret = v[n-1] - v[0];
  vector<int> diff;
  for(int i = 1; i < n; i++) diff.push_back(v[i] - v[i-1]);
  sort(diff.begin(), diff.end());
  reverse(diff.begin(), diff.end());
  for(int i = 0; i < diff.size() && i < m-1; i++) ret -= diff[i];
  cout << ret << "\n";
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  /*
  int t;
  cin >> t;
  for(int i = 1; i <= t; i++) {
    cout << "Case #" << i << ": ";
    solve();
  }
  */
  solve();
}


Measured memory_bytes: 1276
from collections import defaultdict, Counter, namedtuple, deque
import itertools
import functools
import bisect
import heapq
import math
# MOD = 10**9+7
# MOD = 998244353

NN = 202020
MOD = 998244353

f = [0]*NN
rf = [0]*NN
inv = [0]*NN
f[0], f[1] = 1, 1
rf[0], rf[1] = 1, 1
inv[1] = 1

for i in range(2, NN):
    f[i] = (f[i-1] * i) % MOD
    inv[i] = (-inv[MOD % i] * (MOD // i)) % MOD
    rf[i] = (rf[i-1] * inv[i]) % MOD


def C(n, r):
    return (f[n] * rf[r] * rf[n-r]) % MOD


n, m, k = map(int, input().split())
A = [0]*n
A[0] = m
for i in range(1, n):
    A[i] = (A[i-1]*(m-1))%MOD

# print(A)
ans = 0
for i in range(1, k+2):
    ans = (ans + A[-i]*C(n-1, i-1))%MOD
    # print(A[-i], C(n-1, i-1), A[-i]*C(n-1, i-1), ans)

# print(sum([48,96,72,24,3]))
print(ans)


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


#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define pii pair<int,int>
#define pli pair<long long,int>
#define pil pair<int,long long>
#define ll long long
#define el '\n'

using namespace std;

int a;
string s;

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

    cin >> a >> s;
    if (a >= 3200){
        cout << s << el;
    } else{
        cout << "red" << el;
    }

    return 0;
}

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
vector<long long int> a;
long long int f(long long int x){
    int n= a.size();
    long long int sum = 0;
    rep(i,n) sum = sum + (x ^ a[i]);
    return sum;
}

int main(){
    long long int n,k; cin >> n >> k;
    rep(i,n){long long int temp; cin >> temp;  a.push_back(temp);}
    long long int twopow = 1, bw = 0;
    while(twopow - 1 < k){ twopow = twopow * 2; bw++;}
    //cout << bw << endl;
    long long int x = 0;
    for(int i = bw-1; i >= 0; i--){
        long long int tp = 1; tp = tp << i;
        int zc=0, oc=0;;
        rep(j,n){
            if((a[j] & tp) == 0) zc++;
            else oc++;
        }
        if(zc > oc && k >= (x | tp)) x = x | tp; 
    }
    //cout << x << endl;
    cout << f(x) << endl;
    return 0;
}

Measured memory_bytes: 1528
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#include <iostream>
#include <set>
 
int main(void){
  int n,m;
  cin >> n;
  vector<string> s(n);for(int i=0;i<n;i++) cin >> s[i];
  cin >> m;
  vector<string> t(m);for(int i=0;i<m;i++) cin >> t[i];

  int ans=0;
  for(int i=0;i<n;i++){
    int score=0;
    for(int j=0;j<n;j++) if(s[i]==s[j]) score++;
    for(int j=0;j<m;j++) if(s[i]==t[j]) score--;
    ans = max(ans,score);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3612
#include<stdio.h>

int digit(int s){
	int d = 1;
	while(1){
		if(s >= 10){
			s = s/10;
			d++;
		}else{
			break;
		}
	}
	return d;
}


int main(){
	int a, b;

	while(scanf("%d %d", &a, &b) != EOF){
		printf("%d\n", digit(a + b));
	}

	return 0;
}

Measured memory_bytes: 1028
import sys, math
from collections import defaultdict, deque, Counter
from bisect import bisect_left, bisect_right
from itertools import combinations, permutations, product
from heapq import heappush, heappop
from functools import lru_cache
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mat = lambda x, y, v: [[v]*y for _ in range(x)]
ten = lambda x, y, z, v: [mat(y, z, v) for _ in range(x)]
mod = 1000000007
sys.setrecursionlimit(1000000)

s = rs()

if s[-1] != 's':
	print(s+'s')
else:
	print(s+'es')


Measured memory_bytes: 67932
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#define rep(index,num) for(int index=0;index<num;index++)
#define eps 1e-15
typedef long long ll;
int main(){
	char card[3][101];
	int nowcard[3]={0},who=0;
	int winner;
	rep(i,3){
		scanf("%s",card[i]);
	}
	while(1){
		if(card[who][nowcard[who]]=='\0'){
			winner=who;
			break;
		}
		else{
			int oldwho=who;
			who=card[who][nowcard[who]]-'a';
			nowcard[oldwho]++;
		}
	}
	printf("%c\n",'A'+winner);
	return 0;
}


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

#define pb push_back
#define ppb pop_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define ll long long
#define bit __builtin_popcountll
#define sqr(x) (x) * (x)
#define forit(it,S) for(__typeof((S).begin()) it = (S).begin(); it != (S).end(); it++)
#define debug(x) cout << #x <<" = " << x << endl
#define forn(i, n) for(int i = 0 ; (i) < (n) ; ++i)
#define printvpair(v) for(int i = 0 ; (i) < (v.size()) ; ++i) cout << v[i].first  <<" " << v[i].second << endl;
#define printv(v) for(int i = 0 ; (i) < (v.size()) ; ++i) cout << v[i] << " "; cout << endl;

using namespace std;

typedef pair<int, int> pii;

const double eps = 1e-9;
const double pi = acos(-1.0);
const ll INF = 2524157763907942;

const int dx[4] = {0,  0, 1, -1};
const int dy[4] = {1, -1, 0,  0};
const int N = 5;
int a[N];
ll n,w[N],p1[N],p2[N];
int main() {
	ios_base::sync_with_stdio(0);
	cin >> p1[0] >> p1[1] >> p1[2] >> p1[3] >> n;
	p2[0] = 8 * p1[0];
	p2[1] = 4 * p1[1];
	p2[2] = 2 * p1[2];      	  
	p2[3] = p1[3];
	ll mn = INF; 
	for(int i = 0; i < 4; i++)
		mn = min(mn,p2[i]);
	if (n % 2 == 0){
		ll ans = (n / 2) * mn;	
		cout << ans << endl;
	}
	else {
		ll ans = (n / 2) * mn;
		ll extra = INF;
		for(ll i = 0; i <= (100)/ 25; i++)
			for(ll j = 0; j <= ( 100) / 50; j++)
				for(ll k = 0; k <= (100)/ 100; k++) {	
					if(i * 25 + j * 50 + k * 100 == 100){
						extra = min(extra,i * p1[0] + j * p1[1] + k * p1[2]);
					}
				}
		cout << ans + extra << endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

a = int(input()) # 500
b = int(input()) # 100
c = int(input()) # 50
x = int(input())

ans = 0

for i in range(a + 1):
    for j in range(b + 1):
        for k in range(c + 1):
            if 500 * i + 100 * j + 50 * k == x:
                ans += 1

print(ans)


Measured memory_bytes: 3060
#AC
n = gets.to_i
arr = gets.chomp.split(' ').map(&:to_i)
i = 1
while i <= n
  arr[i-1] -= i
  i += 1
end
arr.sort!
a = arr[n/2]
sum = 0
j = 1
while j <= n
  sum += (arr[j-1] - a).abs
  j += 1
end
puts sum


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

/* #include<cstdio>*/
int main(){
	int a, b;
	cin >> a >> b;
	if (a == b) cout << "a == b" << endl;
	if (a < b) cout << "a < b" << endl;
	if (a > b) cout << "a > b" << endl;



	return 0; 
}




Measured memory_bytes: 3092
import java.io.*;

class Main{
	public static void main(String[] args){
		try{
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			Dice d1 = new Dice(br.readLine());
			Dice d2 = new Dice(br.readLine());

			while(true){
				if(rightCheck(d1,d2)){
					System.out.println("Yes");
					break;
				}

				d2.simN();
				if(rightCheck(d1,d2)){
					System.out.println("Yes");
					break;
				}
				d2.simN();
				if(rightCheck(d1,d2)){
					System.out.println("Yes");
					break;
				}
				d2.simN();
				if(rightCheck(d1,d2)){
					System.out.println("Yes");
					break;
				}
				d2.simN();

				d2.simE();
				if(rightCheck(d1,d2)){
					System.out.println("Yes");
					break;
				}
				d2.simE();
				if(rightCheck(d1,d2)){
					System.out.println("Yes");
					break;
				}
				d2.simE();
				if(rightCheck(d1,d2)){
					System.out.println("Yes");
					break;
				}

				System.out.println("No");
				break;
			}
		} catch(IOException e){
			System.out.println("Exception :" + e);
		}
	}
	public static boolean rightCheck(Dice d1, Dice d2){
		if(check(d1,d2)){
			return true;
		}
		d2.simR();
		if(check(d1,d2)){
			return true;
		}
		d2.simR();
		if(check(d1,d2)){
			return true;
		}
		d2.simR();
		if(check(d1,d2)){
			return true;
		}
		d2.simR();
		return false;
	}
	public static boolean check(Dice d1, Dice d2){
		if((d1.getTop()==d2.getTop())&&(d1.getForth()==d2.getForth())&&
			(d1.getRight()==d2.getRight())&&(d1.getLeft()==d2.getLeft())&&
			(d1.getBack()==d2.getBack())&&(d1.getBottom()==d2.getBottom())){
			return true;
		} else{
			return false;
		}
	}
}
class Dice{
	private int top;
	private int forth;
	private int right;
	private int left;
	private int back;
	private int bottom;
	Dice(String label){
		String lab[] = label.split(" ", 0);
		top    = Integer.parseInt(lab[0]);
		forth  = Integer.parseInt(lab[1]);
		right  = Integer.parseInt(lab[2]);
		left   = Integer.parseInt(lab[3]);
		back   = Integer.parseInt(lab[4]);
		bottom = Integer.parseInt(lab[5]);
	}
	public void simN(){
		int work;
		work   = top;
		top    = forth;
		forth  = bottom;
		bottom = back;
		back   = work;
	}
	public void simE(){
		int work;
		work   = top;
		top    = left;
		left   = bottom;
		bottom = right;
		right  = work;
	}
	public void simW(){
		int work;
		work   = top;
		top    = right;
		right  = bottom;
		bottom = left;
		left   = work;
	}
	public void simS(){
		int work;
		work   = top;
		top    = back;
		back   = bottom;
		bottom = forth;
		forth  = work;
	}
	public void simR(){
		int work;
		work   = forth;
		forth  = right;
		right  = back;
		back   = left;
		left   = work;
	}
	public void simL(){
		int work;
		work   = forth;
		forth  = left;
		left   = back;
		back   = right;
		right  = work;
	}
	public int getTop(){
		return top;
	}
	public int getForth(){
		return forth;
	}
	public int getRight(){
		return right;
	}
	public int getLeft(){
		return left;
	}
	public int getBack(){
		return back;
	}
	public int getBottom(){
		return bottom;
	}
}

Measured memory_bytes: 17092
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define is(a, b) a == b
#define len(v) ll(v.size())

class UnionFind {
public:
	vector<int> par;//親の番号
    vector<int> rank;//木の深さ
 
	UnionFind(int n){//全ての要素に対して自身が根となるように初期化, 木の深さは0になる
		rep(i,n){
            par.push_back(i);
            rank.push_back(0);
        }
	}
 
	int find(int x) {//木の根を求める
		if(par[x]==x){
            return x;
        }else{
            return par[x]=find(par[x]);
        }
	}
 
	void unite(int x,int y){//xとyの属する集合を併合
        x=find(x);
        y=find(y);
        if(x==y) return;
        if(rank[x]<rank[y]){//木の深さが小さい方を大きい方へ繋げる
            par[x]=y;
        }else{
            par[y]=x;
            if(rank[x]==rank[y]) rank[x]++;
        }
    }

    bool same(int x,int y){//xとyが同じ集合に属するか否か
        return find(x)==find(y);
    }
};
//x以下の要素への最小index, ソートしてから使ってね
template <class T> 
int former(const vector<T> &v, T x){
  return upper_bound(v.begin(), v.end(), x) - v.begin() - 1;
}
//x以上の要素への最小index
template <class T> 
int latter(const vector<T> &v, T x){
  return lower_bound(v.begin(), v.end(), x) - v.begin();
}
//vector書き出し
template <class T>
void cout_vec(const vector<T> &vec1){
  rep(i,len(vec1)){
    cout<<vec1[i]<<' ';
  }
  cout<<'\n';
}
//nCk
template <class T>
T comb(T n,T k){
    T ans=1;
    FOR(i,n-k+1,n+1){
        ans*=i;
    }
    FOR(i,1,k+1){
        ans/=i;
    }
    return ans;
}
//a,bの最大公約数
template <class T>
T gcd(T a,T b) {
	if (b == 0) return a;
	else return gcd(b, a % b);
}
//素因数分解
template <class T>
map<T,T> prime_factor(T x){
    map<T,T> ans;
    for(T i=2;i*i<=x;i++){
        while(x%i==0){
            x/=i;
            ans[i]++;
        }
    }
    if (x!=1){
        ans[x]=1;
    }
    return ans;
}
//約数列挙
template <class T>
vector<T> divisor(T x){
    vector<T> res;
    for(T i=1;i*i<=x;i++){
        if(x%i==0){
            res.push_back(i);
            if(i!=x/i){
                res.push_back(x/i);
            }
        }
    }
    return res;
}
//素数判定
template <class T>
bool is_prime(T x){
    for(T i=2;i*i<=x;i++){
        if(x%i==0){
            return false;
        }
    }
    return x!=1;
}

const ll inf=1e9+7;

ll mult(ll n,ll m){//n^m%infを求める
    if(m==1){
        return n%inf;
    }else if(m%2==0){//オーバーフロー防止のためにn^(m/2)*n^(m/2)を考える
        ll t=mult(n,m/2);
        return (t*t)%inf;
    }else{//奇数の時はn^(m-1)*nを考える
        ll t=mult(n,m-1);
        return (t*n)%inf;
    }
}

typedef pair<ll,ll> P;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    set<int> d;
    rep(i,n){
        int x;
        cin>>x;
        d.insert(x);
    }
    cout<<len(d)<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい
// https://github.com/atcoder/live_library
// cppdbg: test.exeのterminalに標準入力を打てる

#define ALL(x) x.begin(),x.end()
#define get_tp(t,i) get<i>(t)
#define len(x) (ll)(x.size())
#define ub(a,x) (upper_bound(ALL(a),x)-a.begin())
#define lb(a,x) (lower_bound(ALL(a),x)-a.begin())
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef pair<long long,long long> pllll; //pair<ll,ll>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<ll, vector<ll>, greater<ll> > gpq; //逆順priority_queue
typedef priority_queue<ll> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const long double PI=3.1415926535897932;

int main(){
    int R;cin>>R;
    if(R<1200){
        cout<<"ABC"<<endl;
    }else if(R<2800){
        cout<<"ARC"<<endl;
    }else{
        cout<<"AGC"<<endl;
    }
}

Measured memory_bytes: 3580
// tsukasa_diary's programing contest code template
#include <bits/stdc++.h>
using namespace std;
// define
#define for_(i,a,b) for(int i=a;i<b;++i)
#define for_rev(i,a,b) for(int i=a;i>=b;--i)
#define allof(a) a.begin(),a.end()
#define minit(a,b) memset(a,b,sizeof(a))
#define size_of(a) (int)a.size()
// typedef
typedef long long lint;
typedef double Double;
typedef pair<int, int> pii;
//
typedef vector< int > Array;
typedef vector< Array > Matrix;
typedef vector< Double > DArray;
typedef vector< DArray > DMatrix;
typedef vector< string > SArray;
typedef vector< pii > PArray;
// popcount
inline int POPCNT(int _x) { return __builtin_popcount(_x); }
inline int POPCNT(lint _x) { return __builtin_popcountll(_x); }
// inf
const int iINF = 1L << 30;
const lint lINF = 1LL << 60;
// eps
Double EPS = 1e-9;
// in range
inline bool in_range(int _v, int _mx, int _mi) { return _mi <= _v && _v < _mx; }
inline bool in_range(Double _v, Double _mi, Double _mx) { return -EPS < _v - _mi && _v - _mx < EPS; }
inline bool in_range(int _x, int _y, int _W, int _H) { return 0 <= _x && _x < _W && 0 <= _y && _y < _H; }
// neighbor clockwise
const int DX[4] = {0,1,0,-1}, DY[4] = {-1,0,1,0};
const int DX_[8] = {0,1,1,1,0,-1,-1,-1}, DY_[8] = {-1,-1,0,1,1,1,0,-1};

int N;

void solve() {
	int rep = N * (N - 1) / 2;
	
	Array win(N);
	for_(i,0,rep) {
		int a, b, c, d; cin >> a >> b >> c >> d;
		--a; --b;
		if (c > d) win[a] += 3;
		else if (c < d) win[b] += 3;
		else ++win[a], ++win[b];
	}
	
	Array swin = win;
	sort(allof(swin));
	
	for_(i,0,N) {
		int v = win[i];
		int rank = swin.end() - upper_bound(allof(swin), v);
		cout << rank + 1 << endl;
	}
}

int main() {
	cin >> N;
	solve();
	return 0;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=1; i<(n); ++i)
typedef long long ll;
ll k,n;
string s;
int main(){
  cin >> k >> n;
  vector<ll> v;
  rep(i,n+1){
    ll a; cin >> a; v.push_back(a);
  }
  v.resize(n);
  /*
  for(auto e: v){
    cout << e << endl;
  }*/
  ll d=0;
  ll c=1; // サタン
  ll t=n-1; // 右端
  ll gyaku=0; 
  rep(i,n){
    //cout << i << "." << d << endl;
    //cout << c << "," << v[c] << "," << v[c-1] << endl;
    ll len1=v[c]-v[c-1];
    //cout << i << "," << len1 << endl;
    if(gyaku==0){
      if(v[0]+(k-v[n-1])<len1){
        gyaku=1;
        d+=v[0]+(k-v[n-1]);
        continue;
      }
      d+=len1;
      //cout << i << "." << d << endl;
      c+=1;
      continue;
    }
    //cout << i << "i=3" << t<< endl;
    ll len0=v[t]-v[t-1];
    if(len1<len0){
      d+=len1;
      c++;
      continue;
    }
    d+=len0;
    t--;
    continue;
  }

  cout << d;
}

Measured memory_bytes: 2420
#include <stdio.h>

char field[109][109];

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

void f(int n) {
    int r = n + 3;
    // init
    for(int i=1; i<r; i++) {
        field[0][i] = field[r][i] = field[i][0] = field[i][r] = '#';
        for(int j=1; j<r; j++) {
            field[i][j] = ' ';
        }
    }
    // do
    int y = r - 2;
    int x = 2;
    field[y][x] = '#';
    int pass = 0;
    for(int dir = 0; ;dir = (dir + 1) & 3) {
        int count = 0;
        while(field[y+dy[dir]*2][x+dx[dir]*2]!='#') {
            y += dy[dir];
            x += dx[dir];
            field[y][x] = '#';
            count++;
        }
        if(pass && count<2) break;
        pass = 1;
    }
    // print
    r--;
    for(int i=2; i<r; i++) {
        field[i][r] = '\0';
        puts(&field[i][2]);
    }
    
}

int main(void)
{
    int d, n;
    scanf("%d", &d);
    while(d--) {
        scanf("%d", &n);
        f(n);
        if(d) puts("");
    }
    return 0;
}


Measured memory_bytes: 2044
n,p = map(int,input().split())
a = list(map(int,input().split()))
flg = True
for i in a:
    if i % 2 != 0:
        flg = False
        break
if flg:
    if p == 0:
        print(2**n)
    else:
        print(0)
else:
    print(2**(n-1))

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

int main() {
  char c[6]; rep(i,6) cin>>c[i];
  bool ans = c[0] == c[5] && c[1] == c[4] && c[2] == c[3];
  cout << (ans ? "YES" : "NO") << endl;
}


Measured memory_bytes: 256
# coding: utf-8
# 48

while True:
    
    n,k = map(int,input().split())
    if n==0 and k==0:
        break
    
    a=[]
    cnt=0
    S=[]
    s=0
    
    
    for i in range(n):
        a.append(int(input()))
    
    S.append(sum(a[0:k]))
    
    for i in range(k,n):
        s = S[cnt]-a[i-k]+a[i]
        S.append(s)
        cnt += 1
        
    print(max(S))
     
     


Measured memory_bytes: 11732
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string>
using namespace std;
int main(){
  int A,B, C, D ,E ,F;
  string S,Sa,Sb,Sc;
  cin >> A >> B;
  if(A == 1)A = 14;
  if(B == 1)B = 14;
  if(A == B)cout << "Draw" << endl;
  else if(A > B)cout << "Alice" << endl;
  else cout << "Bob" << endl;
        return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
/*iamsorry*/
 
#define thegamebegins   ios_base::sync_with_stdio(false); cin.tie(NULL);
#define fileio          freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define int             long long
#define float           long double
#define test            int t; cin>>t; while(t--)
#define in(a,n)         for(int i=0; i<n; ++i)  cin>>a[i]
#define r0              return 0
#define E               "\n"
#define S               " "
#define elif            else if
#define M               1000000007
#define fi(i,x,y)       for(int i=x; i<y; ++i)
#define fa(i,s)         for(auto i:s)
#define fp(i,s)         for(auto i=(s).begin(); i!=(s).end(); ++i)
#define vi              vector <int>
#define vpii            vector <pair <int,int> >
#define mii             map <int,int>
#define pii             pair <int,int>
#define seti            set <int>
#define setd            set <int,greater <int> >
#define all(s)          (s).begin(),(s).end()
#define sortd(a,n)      sort(a, a+n, greater<int>())
#define pb              push_back
#define mp              make_pair
#define fr              first
#define sc              second
#define lb              lower_bound
#define ub              upper_bound
#define er              equal_range
 
const int INF = 0x3f3f3f3f;

signed main()
{
    thegamebegins

    int n,x,y;  cin>>n>>x>>y;
    mii m;
    fi(i,1,n)   fi(j,i+1,n+1)
    {
        int dist;
        if(i<x)
        {
            if(j<=x)    dist=j-i;
            elif(j<y)   dist=min(j-i,x-i+1+y-j);
            elif(j==y)  dist=x-i+1;
            else    dist=x-i+1+j-y;
        }
        elif(i==x)
        {
            if(j<y)     dist=min(j-i,1+y-j);
            elif(j==y)  dist=1;
            else        dist=1+j-y;
        }
        elif(i<y)
        {
            if(j<=y)     dist=min(j-i,i-x+1+y-j);
            else         dist=min(y-i,i-x+1)+j-y;
        }
        else
        {
            dist=j-i;
        }
        if(m.find(dist)==m.end())   m[dist]=1;
        else    ++m[dist];
    }
    fi(i,1,n)   
    {
        if(m.find(i)==m.end())  cout<<0<<E;
        else    cout<<m[i]<<E;
    }
    r0;
}

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

using namespace std;

typedef long long ll;
#define _ ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);

#define sll(x) scanf("%I64d",&x)
#define sd(x)  scanf("%d",&x)
#define pll(x) printf("%I64d",x)
#define pd(x)  printf("%d",x)

#define clr(x) memset(x,0,sizeof x)

#define mid    ((l+r)>>1)
#define Pi acos(-1)
#define EPS 1e-12
#define MOD  1000000007
#define MOD1 1000000009
#define INFL 10000000000000LL
#define INF  2000000000

#define N 100005

ll ar[N][3],dp[N][3],n;

ll solve(int i,int last){

    if(i == n) return 0;
    if(dp[i][last] != -1) return dp[i][last];
    ll c1= -1*INFL ,c2= -1*INFL,c3= -1*INFL;
    if(last != 1)
    c1 = solve(i+1,1) + ar[i][0];
    if(last != 2)
    c2 = solve(i+1,2)+ ar[i][1];
    if(last != 3)
    c3 = solve(i+1,3)+ ar[i][2];


    ll ret = max(c1,max(c2,c3));


    return dp[i][last] = ret;
}



int main()
{_
    memset(dp,-1,sizeof dp);
    cin >> n;
    for(int i=0;i<n;i++)
        for(int j=0;j<3;j++) cin >> ar[i][j];

    cout << solve(0,0);

    return 0;
}


Measured memory_bytes: 11136
/*-- ILSH  --*/
#include "bits/stdc++.h"
using namespace std;
typedef long long int ll;
#define pb push_back 
#define pop pop_back
#define mp make_pair
#define vii vector < int >
#define vll vector < ll > 
#define pii pair < int , int >
#define pll pair < ll , ll >
#define vpi vector < pii >
#define vpl vector < pll >
#define fi first
#define se second 
#define sz size 
#define len length 

const ll mod = 1e9+7;
const ll inf=1e18+1e17;
//const ll mod = 998244353;

ll modInverse(ll a,ll m){ll m0=m;ll y=0,x=1;if(m == 1)return 0;while(a> 1){ll q=a/m;ll t=m;m=a%m,a=t;t=y;y=x-q*y;x=t;}if(x<0)x+=m0;return x;}  
ll powm(ll a,ll b){a=a%mod;ll res=1;while(b){if(b&1)res=(res*a)%mod;a=(a*a)%mod;b>>=1;}return (res%mod);}

const ll N=2e5+6;


void solve(){
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	int j=0;
	while ( a>0&&c>0){
		if ( j%2==0)
			c=c-b;
		else
			a=a-d;
		j++;
	}
	if ( c<=0)
		cout<<"Yes\n";
	else
		cout<<"No\n";

}


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
//	#ifndef ONLINE_JUDGE
	//  freopen ("INPUT.txt" , "r" , stdin);
//	freopen ("OUTPUT.txt", "w" , stdout);
//	#endif	
    ll t=1;
	//cin>>t;
    for (int i=1;i<=t;i++){
    //	cout<<"Case #"<<i<<": ";
    	solve();
 	}
}





Measured memory_bytes: 3600
#include <stdio.h>
#include <math.h>

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

    if(n == 0)
        printf("%d", x);
    else{
        int p[101],pp[101];
        int menor_num = 101;
        int maior_num = 0;
        int cont = 0;

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

        for(int j = 0; j < n; ++j){
            if(p[j] <= menor_num)
                menor_num = p[j];
            if(p[j] >= maior_num)
                maior_num = p[j];
        }

        for(int t = 0; t < 101; ++t){
            int c = 0;
            for(int s = 0; s < n; ++s){
                if(t == p[s])
                    c = -1;
            }
            if(c == 0){
                pp[cont] = t;
                ++cont;
            }
        }

        int resp = 101;

        for(int k = 0; k < cont; ++k){
             if(abs(pp[k] - x) <= abs(resp - x)){
                if(abs(pp[k] - x) == abs(resp - x)){
                    if(pp[k] < resp)
                        resp = pp[k];
                }
                else
                    resp = pp[k];
             }
        }
        
    
        printf("%d", resp);
    }

    return 0;
}

Measured memory_bytes: 1728
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int count = 0;
	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int n = in.nextInt();
			int[] p = new int[n+1];
			for (int i = 0; i < n; i++) {
				p[i] = in.nextInt();
			}
			p[n] = -1;
			boolean[] isMatch = new boolean[n+1];
			for (int i = 0; i < n; i++) {
				if (p[i] == i+1) isMatch[i] = true;
			}

			for (int ban = 0; ban < n; ban++) {
				if (ban == 0) {
					if (isMatch[0]) {
						swap(p, 0, 1);
						ban++;
					}
				} else {
					if (isMatch[ban] && isMatch[ban+1]) {
						swap(p, ban, ban+1);
						ban++;
					} else if (isMatch[ban] && !isMatch[ban+1]) {
						swap(p, ban-1, ban);
					}
				}
			}
			out.println(count);

		}
	}
	static void swap(int[] p, int i, int j) {
		int tmp = p[i];
		p[i] = p[j];
		p[j] = tmp;
		count++;
	}

	static class ArrayUtils {
		public static Map<Integer, Integer> getCountMap(int[] array) {
			Map<Integer, Integer> map = new TreeMap<>();
			for (int x : array)
				map.merge(x, 1, Integer::sum);
			return map;
		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}


Measured memory_bytes: 34588
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline int my_getchar_unlocked(){
  static char buf[1048576];
  static int s = 1048576;
  static int e = 1048576;
  if(s == e && e == 1048576){
    e = fread_unlocked(buf, 1, 1048576, stdin);
    s = 0;
  }
  if(s == e){
    return EOF;
  }
  return buf[s++];
}
inline void rd(long long &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = my_getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = my_getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
struct MY_WRITER{
  char buf[1048576];
  int s;
  int e;
  MY_WRITER(){
    s = 0;
    e = 1048576;
  }
  ~MY_WRITER(){
    if(s){
      fwrite_unlocked(buf, 1, s, stdout);
    }
  }
}
;
MY_WRITER MY_WRITER_VAR;
void my_putchar_unlocked(int a){
  if(MY_WRITER_VAR.s == MY_WRITER_VAR.e){
    fwrite_unlocked(MY_WRITER_VAR.buf, 1, MY_WRITER_VAR.s, stdout);
    MY_WRITER_VAR.s = 0;
  }
  MY_WRITER_VAR.buf[MY_WRITER_VAR.s++] = a;
}
inline void wt_L(char a){
  my_putchar_unlocked(a);
}
inline void wt_L(long long x){
  int s=0;
  int m=0;
  char f[20];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    my_putchar_unlocked('-');
  }
  while(s--){
    my_putchar_unlocked(f[s]+'0');
  }
}
int main(){
  int i;
  long long N;
  rd(N);
  long long res = 0;
  for(i=(1);i<(N);i++){
    res += (N-1) / i;
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20200916-1

// --- original code ---
// {
//   ll @N, res = 0;
//   rep(i,1,N) res += (N-1) / i;
//   wt(res);
// }


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

const string YES = "Yes";
const string NO = "No";

void solve(long long H, long long N, std::vector<long long> A) {
    rep(i, N) { H -= A[i]; }
    if (H <= 0) {
        cout << YES << endl;
    } else {
        cout << NO << endl;
    }
}

int main() {
    long long H;
    scanf("%lld", &H);
    long long N;
    scanf("%lld", &N);
    std::vector<long long> A(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &A[i]);
    }
    solve(H, N, std::move(A));
    return 0;
}


Measured memory_bytes: 4024
// Mehul Mathur randi hai
// Murali big ghey
// RisHiH is slave
// Anamaya is Sexy
// Arihanth is gay
// Aakash Aanegola is god

#include <bits/stdc++.h>
#define lp(var,start,end) for (ll var = start; var <end ; ++var)
#define rlp(var,start,end) for(ll var = start; var>=end ; var--)
#define pb push_back
#define mp make_pair
#define pf push_front
#define ff first
#define ss second
#define vll vector<ll>
#define vld vector<ld>
#define pll pair<ll,ll> 
#define pld pair<ld,ld> 
#define vpll vector<pll>
#define vpld vector<pld>
#define all(X) X.begin(),X.end()
#define endl "\n"
#define sz(x) ((ll)((x).size()))
#define pq priority_queue

using namespace std;

typedef long long int ll;
typedef long double ld;
vll dp;
vll a;
ll n,k;

ll calc(ll idx){
    if(dp[idx]!=-1){
        return dp[idx];
    }

    else if(idx==n-2){
        dp[n-2] = abs(a[idx]-a[idx+1]) + calc(n-1);
        return dp[n-2];
    }

    else if(idx>=(n-1)){
        dp[n-1] = 0;
        return dp[n-1];
    }
    ll mn = INT64_MAX;
    for(ll i=1;i<=k && idx+i<n;i++)
        mn = min( mn, abs(a[idx]-a[idx+i]) + calc(idx+i));
    dp[idx] = mn;
    return dp[idx];
}

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    cin>>n>>k;
    ll ans = 0;
    dp.resize(n);
    dp.assign(n,-1);
    a.resize(n);
     
    lp(i,0,n) cin>>a[i];

    cout<<calc(0)<<endl;
    
}


Measured memory_bytes: 8064
N = int(input())
X = list(map(int, input().split()))

Xmax = max(X)
Xmin = min(X)

ans = 0
ans_sum = 0

for P in range(Xmin,Xmax+1):
  for i in range(N):
    cal = (X[i] - P)**2
    ans_sum = ans_sum + cal
  if P == Xmin:
    ans = ans_sum
    ans_sum = 0
  elif ans >= ans_sum:
    ans = ans_sum
    ans_sum = 0
  else :
    ans_sum = 0
print(ans)
  
  

Measured memory_bytes: 3064
#define _USE_MATH_DEFINES
#include<stdio.h>
#include<cmath>

using namespace std;
struct CD2D{
  double x,y;
  
  CD2D(double x,double y){
      this -> x = x;
      this -> y = y;
  }
  CD2D operator -(CD2D *obj){
      CD2D  return_CD2D = {
          (this -> x) - (obj -> x),
          (this -> y) - (obj -> y)
      };
      return return_CD2D;
  }
  void print(){printf("%lf %lf\n",this -> x,this -> y);}
 
  
};

void AskKoch(int n,CD2D p1,CD2D p2){
    CD2D s= {0,0},t = {0,0},u = {0,0};
    if(n <= 0) return ;
    s.x = (2*p1.x + 1*p2.x) / (1 + 2);
    s.y = (2*p1.y + 1*p2.y) / (1 + 2);
    u.x = (1*p1.x + 2*p2.x) / (2 + 1);
    u.y = (1*p1.y + 2*p2.y) / (2 + 1);
    t.x = (u.x - s.x)*cos(M_PI/3) - (u.y - s.y)*sin(M_PI/3) + (s.x);
    t.y = (u.x - s.x)*sin(M_PI/3) + (u.y - s.y)*cos(M_PI/3) + (s.y);
    AskKoch(n-1,p1,s);
    s.print();
    AskKoch(n-1,s,t);
    t.print();
    AskKoch(n-1,t,u);
    u.print();
    AskKoch(n-1,u,p2);
}

int main(){
    int n;
    scanf("%d",&n);
    CD2D ps = {0,0},pe = {100,0};
    ps.print();
    AskKoch(n,ps,pe);
    pe.print();
}



Measured memory_bytes: 2764
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;
 
int x[501];
int a[250001];
 
int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin>>n;
	deque<ii> require;
	deque<ii> require2;
	vector<ii> v;
	for(int i = 1; i <= n; i++)
	{
		cin>>x[i];
		x[i]--;
		if(a[x[i]]!=0)
		{
			cout<<"No\n"; return 0;
		}
		a[x[i]]=i;
		v.pb(mp(x[i],i));
	}
	sort(v.begin(),v.end());
	for(int i = 0; i < n; i++)
	{
		if(v[i].se>1) require.pb(mp(v[i].se-1,v[i].se));
	}
	int ptr = 0;
	for(int i = 0; i < n; i++)
	{
		while(ptr<v[i].fi)
		{
			if(require.empty()&&require2.empty())
			{
				cout<<"No\n"; return 0;
			}
			if(!require.empty())
			{
				a[ptr] = require.front().se;
				require.front().fi--;
				if(require.front().fi==0) require.pop_front();
			}
			else
			{
				a[ptr] = require2.front().se;
				require2.front().fi--;
				if(require2.front().fi==0) require2.pop_front();
			}
			ptr++;
		}
		ptr++;
		if(n-v[i].se>0) require2.pb(mp(n-v[i].se,v[i].se));
	}
	if(!require.empty())
	{
		cout<<"No\n"; return 0;
	}
	while(ptr<n*n)
	{
		if(require2.empty())
		{
			cout<<"No\n"; return 0;
		}
		a[ptr] = require2.front().se;
		require2.front().fi--;
		if(require2.front().fi==0) require2.pop_front();
		ptr++;
	}
	int cnt[n+1];
	memset(cnt,0,sizeof(cnt));
	for(int i = 0; i < n*n; i++)
	{
		cnt[a[i]]++;
		if(cnt[a[i]]>n)
		{
			cout<<"No\n"; return 0;
		}
		if(cnt[a[i]]==a[i]&&i!=x[a[i]])
		{
			cout<<"No\n"; return 0;
		}
	}		
	
	cout<<"Yes\n";
	for(int i = 0; i <n*n;i++)
	{
		cout<<a[i];
		if(i<n*n-1) cout<<' ';
	}
	cout<<'\n';
}


Measured memory_bytes: 2176
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N,num):
    if N<=0:
        return [[]]*num
    elif num==1:
        return [I() for _ in range(N)]
    else:
        read_all = [tuple(II()) for _ in range(N)]
        return map(list, zip(*read_all))

#################

N = I()
A = [0]*N
x = []
y = []
for i in range(N):
    A[i] = I()
    x0,y0 = Line(A[i],2)
    for j in range(len(x0)):
        x0[j] -= 1
    x.append(x0)
    y.append(y0)

ans = 0
from itertools import product
a = list(product([0,1],repeat=N))

for b in a:
    flag = True
    for i in range(N):
        if b[i]==1:
            for k in range(len(x[i])):
                if b[x[i][k]]!=y[i][k]:
                    flag=False
                    break
    if flag:
        now = sum(b)
        if now>ans:
            ans = now
print(ans)        


Measured memory_bytes: 49260
#include<iostream>
#include<cstring>
using namespace std;
 
const int MOD = 100000;
int n, m, s;
int dp[2][2001][3001];
int main()
{
  while(cin >> n >> m >> s && n && m && s){
    memset(dp, 0, sizeof dp); 
    int ans = 0;
    dp[0][0][0] = 1;
 
    for(int i = 1; i <= n * n; i++){
      for(int j = 1; j <= m; j++)
	for(int k = j; k <= s; k++)
	  dp[i % 2][j][k] = (dp[i % 2][j - 1][k - 1] + dp[(i + 1) % 2][j - 1][k - j]) % MOD; 
      
      memset(dp[(i + 1) % 2], 0, sizeof dp[(i + 1) % 2]);
      
     
    }
 
    for(int i = 1; i <= m; i++)
      ans = (ans + dp[n * n % 2][i][s]) % MOD;
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 48080
IDENTIFICATION DIVISION.
PROGRAM-ID. 147B.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 INP   PIC X(100).
01 S     PIC X(100).
01 N     PIC 9(3).
01 H     PIC 9(2).
01 I     PIC 9(3).
01 J     PIC 9(3).
01 OUT-H PIC Z9.
*>
PROCEDURE DIVISION.
  ACCEPT INP.
  UNSTRING INP DELIMITED BY ' '
      INTO S COUNT N.
*>
  MOVE 0  TO H.
  MOVE 1  TO I.
  MOVE N  TO J.
  PERFORM UNTIL I >= J
    IF (S(I:1) NOT = S(J:1))
      ADD 1 TO H
    END-IF
    ADD      1 TO   I
    SUBTRACT 1 FROM J
  END-PERFORM.
*>
  MOVE H TO OUT-H.
  DISPLAY OUT-H.
*>
  STOP RUN.


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

#define ll long long
#define sd(x) scanf("%d", &(x))
#define pii pair<int, int>
#define F first
#define S second
#define all(c) ((c).begin()), ((c).end())
#define sz(x) ((int)(x).size())
#define ld long double

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<", "<<p.second<<")";
	return os;
}

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

#ifdef LOCAL
#define cerr cout
#else
#endif

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
const int N = 1024;
int dist[N * N];
int getInd(int i, int j){return N * i + j;}
char s[N];
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
const int INF = 1 << 30;
int main(){
	int h, w; sd(h); sd(w);
	queue<int> q;
	fill(dist, dist + N * N, INF);
	for(int i = 0; i < h; i++){
		scanf("%s", s);
		for(int j = 0; j < w; j++){
			if(s[j] == '#'){
				q.push(getInd(i, j));
				dist[getInd(i, j)] = 0;
			}
		}
	}
	int ans = 0;
	while(!q.empty()){
		int u = q.front(); q.pop();
		int i = u / N, j = u % N;
		int d = dist[u];
		// trace(u, d);
		ans= d;
		for(int dir = 0; dir < 4; dir++){
			int _i = i + dx[dir], _j = j + dy[dir];
			if(min(_i, _j) >= 0 && _i < h && _j < w){
				int v = getInd(_i, _j);
				if(dist[v] == INF){
					dist[v] = d + 1;
					q.push(v);
				}
			}
		}
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 11332
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
//typedef vector<unsigned int>vec;
typedef vector<ll>vec;
typedef vector<vec> mat;
typedef vector<vector<int>> Graph;

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
//const ll MOD = 998244353;
const double PI = acos(-1.0);
const double EPS = 1e-10;

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; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    if(a <= 9 && b <= 9) cout << a * b << endl;
    else cout << -1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
 
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;
 
#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second
 
int main(int argc, char **argv) {
	ll a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a+3);
	cout << (a[2] - a[1] + (a[1] + 1 - a[0]) / 2 + (a[1] - a[0]) % 2) << endl;
	return 0;
}
 

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

int main()
{
  string n;
  cin >> n;
  bool ans = false;
  for(int i = 0;i < n.size();i++){
    if(n.at(i) == '7'){
      ans = true;
    }
  }
  if(ans){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3628
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
#define REP(i,a,b) for(i=a;i<b;++i)
#define rep(i,n) REP(i,0,n)
#define ll long long
#define ull unsigned ll
typedef long double ld;
#define ALL(a) (a).begin(),(a).end()
#define ifnot(a) if(not a)
#define dump(x)  cerr << #x << " = " << (x) << endl
using namespace std;

// #define int ll
bool test = 0;
int dx[] = { 0,1,0,-1 };
int dy[] = { 1,0,-1,0 };
#define INF (1 << 28)
ull mod = (int)1e9 + 7;
//.....................
#define MAX (int)1e6 + 5

int main() {
	ll i, j, k, l;
	int N;
	cin >> N;
	int a[100];
	int sum = 0;
	rep(i, N) {
		cin >> a[i];
		sum += a[i];
	}
	//int ave = sum / N;
	//if (sum / (N / 2)) ave++;
	//int ans = 0;
	//rep(i, N) {

	//}
	int ans = INT_MAX;
	REP(i, -100, 101) {
		int ans_i = 0;
		rep(j, N) {
			ans_i += (i - a[j])*(i - a[j]);
		}
		ans = min(ans, ans_i);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<set>
#include<string>
using namespace std;
int main(){
	string str;
	set<string> s;
	int num, count=0;

	cin>>num;

	for(int i=0;i<num;i++){
		cin>>str;
		s.insert(str);
	}

	set<string>::iterator it;
	for(it=s.begin();it!=s.end();it++){
		count++;
	}
	cout<<count<<endl;

	return 0;
}

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

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t,n,m,a;
	long long i,j;
	t = 1;
	while(t--) {
          a = 2018;
	      cin >> n >> m;
          for(i = n; i <= m && i <= n + 2019; i++) {
           for(j = i + 1; j <= m && j <= n + 2019; j++) {
            if((i * j) % 2019 < a)
             a = (i * j) % 2019;
           }
          }
          cout << a << endl;
	}
	return 0;
}



Measured memory_bytes: 256