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

using namespace std;

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long

int main(){
    lint n, m; cin >> n >> m;
    vector<lint> a;
    rep(i, n){
        lint x; cin >> x; a.push_back(x);
    }
    sort(all(a));

    lint max_x = a[n-1]*2, min_x = a[0]*2;
    while(max_x - min_x > 1){
        lint x = (max_x + min_x) / 2; 
        lint count = 0;
        rep(i, n){
            auto itr = lower_bound(all(a), x - a[i]);
            count += a.end() - itr;
        }
        if(count < m){
            max_x = x;
        }
        else{
            min_x = x;
        }
    }

    vector<lint> sum; lint tmp = 0;
    repr(i, n){
        tmp += a[i];
        sum.push_back(tmp);
    }
    reverse(all(sum)); sum.push_back(0);

    lint y = min_x + 1; lint c = 0, ans = 0;
    rep(i, n){
        auto itr = lower_bound(all(a), y - a[i]);
        lint c_ = a.end() - itr; c += c_;
        ans += a[i] * c_ + sum[itr - a.begin()];
    }
    ans += min_x * (m - c);

    cout << ans << endl;
}

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

public class Main {

	public static void main(String[] args) {

		FastScanner sc = new FastScanner();
		int N = sc.nextInt();
		int[] A = new int[N];
		for (int i = 0; i < N; i++)
			A[i] = sc.nextInt();
		Arrays.sort(A);
		long ans = A[0];
		for (int i = 0; i < N - 1; i++) {
			ans = gcd(ans, A[i + 1]);
		}
		System.out.println(ans);

	}
	//以下、自作ライブラリ

	//最大公約数
	public static long gcd(long a, long b) {
		if (a < b)
			return gcd(b, a);
		long c = 0;
		c = a % b;
		if (c == 0)
			return b;
		return gcd(b, c);
	}

	//最小公倍数
	public static long lcm(long m, long n) {
		return m * n / gcd(m, n);
	}

	//素数判定
	public static boolean isPrime(int n) {
		if (n < 2)
			return false;
		if (n == 2)
			return true;
		if (n % 2 == 0)
			return false;

		for (int i = 3; i * i <= n; i += 2) {
			if (n % i == 0)
				return false;
		}
		return true;
	}
}

//以下、高速スキャナークラス
class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 23416
#include<iostream>
#include<string>
#include<cctype>
using namespace std;
int main(){
int N,K,p[1010],j,i,v,a;

cin >> N >> K;
for(i=0;i<N;i++){
cin >> p[i];
}
for(i=1;i<N;i++){
v=p[i];
j=i-1;
while(j>=0&&p[j]>v){
p[j+1]=p[j];
j--;
}
p[j+1]=v;
}
a=0;
for(i=0;i<K;i++){
a=a+p[i];
}
cout << a << endl;
return 0;
}

Measured memory_bytes: 3636
import java.io.IOException;
import java.util.LinkedList;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	public static int require_time(int min_time, int min_difficult, int actual_difficult, final int n, final int nth){
		final int ret_time = (min_time / actual_difficult) * actual_difficult;
		
		if(min_time == ret_time && min_difficult < actual_difficult){
			if(min_difficult < actual_difficult){
				return ret_time;
			}else if(min_difficult == actual_difficult && nth < n){
				return ret_time;
			}else{
				return ret_time + actual_difficult;
			}
		}else{
			return ret_time + actual_difficult;
		}
	}
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		while(true){
			final int n = sc.nextInt();
			final int m = sc.nextInt();
			
			if(n == 0 && m == 0){
				break;
			}
			
			int[] inputs = new int[n];
			for(int i = 0; i < n; i++){
				inputs[i] = sc.nextInt();
			}
			
			int min_time = (m / inputs[0]) * inputs[0];
			int min_difficult = inputs[0];
			int report_num = 1;
			
			for(int i = 1; i < n; i++){
				final int actual_difficult = inputs[i];
				final int require_time = require_time(min_time, min_difficult, actual_difficult, n, i + 1);
				
				final int actual_time = (require_time > m) ? ((m / actual_difficult) * actual_difficult) : require_time;
				//System.out.println("> (" + actual_time + " " + actual_difficult + ") " + min_time + " " + min_difficult + " "  + report_num);
				if(actual_time < min_time){
					min_time = actual_time;
					min_difficult = actual_difficult;
					report_num = i + 1;
				}else if(actual_time == min_time && actual_difficult < min_difficult){
					min_difficult = actual_difficult;
					report_num = i + 1;
				}else if(actual_time == min_time && actual_difficult == min_difficult){
					report_num = n;
				}
				
				//System.out.println(">> (" + actual_time + " " + actual_difficult + ") " + min_time + " " + min_difficult + " "  + report_num);
			}
			
			System.out.println(report_num);
			
		}
		
	}

}

Measured memory_bytes: 27168
import java.util.Scanner;
import java.util.Arrays;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		char b[] = a.toCharArray();
		int c[] = new int[26];
		String d = "";
		for(int i = 0; i < b.length; i++) {
			c[b[i] - 'a']++;
		}
		for(int i = 0; i < 26; i++) {
			if(c[i] == 0) {
				d = d + (char)('a' + i);
			}
		}
		if(d.length() > 0) {
			System.out.print(d.charAt(0));
		}else {
			System.out.print("None");
		}
	}
}

Measured memory_bytes: 28300
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using P = pair<ll,ll>;
const ll INF = ll(1e18)+5;

int main() {
    ll H,W,M;
    cin >> H >> W>> M;
    vector<P> bomH(H),bomW(W);
    for(int i=0;i<H;i++){
        bomH[i] = P(0,i);
    }
    for(int i=0;i<W;i++){
        bomW[i] = P(0,i);
    }
    map<P,int> mp;
    for(int i=0;i<M;i++){
        ll h,w;
        cin >> h >> w;
        --h;--w;
        bomH[h].first++;
        bomW[w].first++;
        mp[P(h,w)]++;
    }
    if(H == 1 || W==1){
        cout << M << endl;
        return 0;
    }
    ll ans =0;
    for(auto itr = mp.begin();itr != mp.end();++itr){
        P p= itr->first;
        ans = max(ans,bomH[p.first].first + bomW[p.second].first-1);
    }

    if(H*W==M){
        cout << ans << endl;
        return 0;

    }

    // 二分探索でM+1番目の値を求める
    ll l= 0;
    ll r = INF;
    sort(bomH.rbegin(),bomH.rend());
    sort(bomW.rbegin(),bomW.rend());
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(mp[P(bomH[i].second,bomW[j].second)] == 0){
                ans = max(ans,bomH[i].first+ bomW[j].first);
                break;
            }
        }
    }
    cout << ans << endl;


    


    return 0;
}

Measured memory_bytes: 50236
a = [input().split() for a in range(3)]
a1 = [a[0][0],a[0][1],a[0][2]]
a2 = [a[1][0],a[1][1],a[1][2]]
a3 = [a[2][0],a[2][1],a[2][2]]
a4 = [a[0][0],a[1][1],a[2][2]]
a5 = [a[0][2],a[1][1],a[2][0]]
a6 = [a[0][0],a[1][0],a[2][0]]
a7 = [a[0][1],a[1][1],a[2][1]]
a8 = [a[0][2],a[1][2],a[2][2]]
n = int(input())
B = [input() for i in range(n)]
if set(a1) <= set(B) or set(a2) <= set(B) or set(a3) <= set(B) or set(a4) <= set(B) or set(a5) <= set(B) or set(a6) <= set(B) or set(a7) <= set(B) or set(a8) <= set(B):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
N = int(input())
S = input()
c1 = [0] * N
c2 = [0] * N
ans = N
for i in range(N):
    c1[i] += c1[i - 1] + 1 * (S[i] == "#")
    c2[i] += c2[i - 1] + 1 * (S[i] == ".")
c1 = [0] + c1
c2 = [0] + c2
#print(c1)
#print(c2)
for i in range(N):
    #print(c1[i], c2[N] - c2[i])
    ans = min(ans, c1[i] + c2[N] - c2[i + 1])
print(ans)

Measured memory_bytes: 20712
#include"bits/stdc++.h"
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first - r.first, l.second - r.second); }
typedef pair<int, int> P;

lint N;
const lint MAXN = 1005;
const lint MAXV = MAXN * (MAXN - 1) / 2;
int dp[MAXV];
vector<lint> to[MAXV];
lint id[MAXN][MAXN];
bool visited[MAXV];
bool calculated[MAXV];

int ToID(int i, int j) {
	if (i > j) swap(i, j);
	return id[i][j];
}

int dfs(int v) {
	if (visited[v]) {
		if (!calculated[v]) return -1;
		return dp[v];
	}
	visited[v] = true;
	dp[v] = 1;
	for (auto u : to[v]) {
		int res = dfs(u);
		if (res == -1) return -1;
		dp[v] = max(dp[v], res + 1);
	}
	calculated[v] = true;
	return dp[v];
}

int main() {
	cin.tie(0); ios_base::sync_with_stdio(false);
	cin >> N;
	vector<vector<int>> vec(N, vector<int>(N-1));
	REP(i, N) {
		REP(j, N - 1) {
			cin >> vec[i][j];
			vec[i][j]--;
		}
	}

	int V = 0;
	REP(i, N) {
		REP(j, N) {
			if (i < j) {
				id[i][j] = V++;
			}
		}
	}
	REP(i, N) {
		REP(j, N - 1) {
			vec[i][j] = ToID(i, vec[i][j]);
		}
		REP(j, N - 2) {
			to[vec[i][j + 1]].push_back(vec[i][j]);
		}
	}
	int ans = 0;
	REP(i, V) {
		int res = dfs(i);
		if (res == -1) {
			cout << -1;
			return 0;
		}
		ans = max(ans, dfs(i));
	}
	cout << ans;
}


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

int main() {
    int n;
    cin >> n;
    vector<int> p(n);
    for (int i = 0; i < n; i++){
        cin >> p[i];
    }
    int ans = 0;
    for (int i = 1; i < n-1; i++){
        if (p[i-1] < p[i] && p[i] < p[i+1]){
            ans ++;
        } else if (p[i-1] > p[i] && p[i] > p[i+1]){
            ans ++;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a_sum, b_sum = sum(A), sum(B)
turns = b_sum - a_sum
a_small = 0
b_small = 0
for a, b in zip(A,B):
    if a < b:
        a_small += (b - a + 1) // 2
    else:
        b_small += a - b
if a_small <= turns and b_small <= turns:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 41200
N, M, Q = map(int, input().split())
data = []
for _ in range(Q):
	data.append(tuple(map(int, input().split())))

max_total = 0
def check(items, l):
	global max_total
	if l == N + 1:
		total = 0
		for a, b, c, d in data:
			if items[b] - items[a] == c:
				total += d
		if max_total < total:
			max_total = total
	else:
		for i in range(items[l - 1], M + 1):
			items[l] = i
			check(items, l + 1)

items = [None] * (N + 1)
items[0] = 1
check(items, 1)

print(max_total)


Measured memory_bytes: 71120
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
const int INF = 2000000000;
using namespace std;

const int MAX_N = 100005;
int dp[MAX_N];

int solve(int n, int a[MAX_N]){
    fill(dp, dp + n, INF);
    rep(i,n){
        *lower_bound(dp, dp + n, a[i]) = a[i];
    }
    return (lower_bound(dp, dp + n, INF) - dp);
}

int main(){
    int n, a[MAX_N];
    cin >> n;
    rep(i,n){ cin >> a[i]; }

    cout << solve(n,a) << endl;
}

Measured memory_bytes: 3880
D = int(input())
c = list(map(int, input().split()))
S = [list(map(int, input().split())) for i in range(D)]
T = [int(input()) for i in range(D)]
SUM = 0
last = [0] * 28
for d in range(1, D + 1):
    i = T[d - 1]
    SUM += S[d - 1][i - 1]
    SU = 0
    last[i] = d
    for j in range(1, 27):
        SU += (c[j - 1] * (d - last[j]))
    SUM -= SU
    print(SUM)

Measured memory_bytes: 9372
#include<stdio.h>
#include<numeric>
int a[10][10],o[10][10],f[10][10],N;
int dy[]={-1,-1,0,0,0,1,1},dx[]={-1,0,-1,0,1,0,1};
int C(int y,int x)
{
	if(y<0||x<0||y>=N||x>y)return 0;
	return 1;
}
int F(int y,int x,int s)
{
	if(!C(y,x))return 1;
	if(a[y][x]==0)return 0;
	if(a[y][x]!=s)return 1;
	if(f[y][x])return 1;
	f[y][x]=1;
	int r=1,i;
	for(i=0;i<7;++i)r=r&&F(y+dy[i],x+dx[i],s);
	return r;
}
int G(int y,int x,int s)
{
	if(!C(y,x))return 0;
	if(a[y][x]!=s)return 0;	
	a[y][x]=-1;	
	int r=1,i;
	for(i=0;i<7;++i)r+=G(y+dy[i],x+dx[i],s);
	return r;
}
int main()
{
	int S,i,j,k,l,m,r,s,t;
	while(scanf("%d%d",&N,&S),N)
	{
		for(i=0;i<N;++i)for(j=0;j<=i;++j)scanf("%d",&o[i][j]);
		r=-999;
		for(i=0;i<N;++i)for(j=0;j<=i;++j)
		{
			if(o[i][j]==0)
			{
				for(l=0;l<N;++l)for(m=0;m<=l;++m)a[l][m]=o[l][m];
				a[i][j]=S;
				for(s=k=0;k<7;++k)
				{
					for(l=0;l<N;++l)for(m=0;m<=l;++m)f[l][m]=0;
					l=i+dy[k],m=j+dx[k];
					if(C(l,m))
					{
						if(a[l][m]!=-1&&F(l,m,a[l][m]))	t=G(l,m,a[l][m]),s+=(i==l&&j==m || o[l][m]==S?-t:t);
					}
				}
				r=(r>s?r:s);
			}
		}
		printf("%d\n",r);
	}
	return 0;
}

Measured memory_bytes: 0
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Scanner;

class Main {
	public static void main(String[] args) throws Exception {
		new Main().run();
	}
	
	long pow(long a,long n) {
		long r=1;
		for(;n>0;n>>=1,a=a*a%MOD)if(n%2==1)r=r*a%MOD;
		return r;
	}
	
	final long MOD=(long)1e9+7;
	
	int N=(int)1e6;
	long[] fac=new long[N];
	long[] inv=new long[N];
	long[] ifac=new long[N];
	{
		fac[0]=fac[1]=inv[0]=inv[1]=ifac[0]=ifac[1]=1;
		for(int i=2;i<fac.length;++i) {
			fac[i]=i*fac[i-1]%MOD;
			inv[i]=MOD-inv[(int)(MOD%i)]*(MOD/i)%MOD;
			ifac[i]=inv[i]*ifac[i-1]%MOD;
		}
	}
	
	long comb(long n,int k) {
		long ret=1;
		for(long i=n;i>=n-k+1;--i)ret=ret*i%MOD;
		for(int i=1;i<=k;++i)ret=ret*inv[i]%MOD;
		return ret;
		//return fac[n]*ifac[k]%MOD*ifac[n-k]%MOD;
	}
	
	void run() {
		Scanner sc=new Scanner(System.in);
		long n=sc.nextLong();
		int a=sc.nextInt();
		int b=sc.nextInt();
		long ans=pow(2,n)-1;
		ans-=comb(n,a)+comb(n,b);
		ans=(ans%MOD+MOD)%MOD;
		System.out.println(ans);
	}
	
	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
	
}


Measured memory_bytes: 48596
#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 double ld;									// XD
#define int long long
#define PB push_back
#define all(x) (x).begin(),(x).end()
#define ii pair <int,int>
#define mii map <int,int>
#define vi vector<int>
#define vii vector< ii >
#define F first
#define S second
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define rep1(i,a,b) for(int i=a;i<=b;i++)
#define repd(i,a,b) for(int i=a; i>=b; --i)
#define sz(x) (int)((x).size())
#define mem(a,x) memset(a,x,sizeof(a))   
const long double PI=3.141592653589793238462643383279502884197169399375105820974944;
typedef tree<int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;  

inline void io(){
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

const int mod = 1e9+7;
const int inf = 1e18;
const int maxn = 5e5+5;
int primefactor(int x){
	int cnt  = 0;
	while(x%2==0){
		cnt++; x/=2;
	}
	int res = cnt+1;
	for(int i=3; i*i <=x ; i++){
		cnt = 0;
		while(x%i==0){
			cnt++; x/=i;
		}
		res *= (cnt+1);
	}
	cnt = 0;
	if(x > 2)
		cnt++;
	res *= (cnt+1);
	return res;
}

void solve(){
	int n; cin>>n;
	int ans = 0;
	rep(i, 1, n){
		ans += primefactor(n-i);
	}
	cout<<ans;
}

signed main() 
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); //io();
    //cout<<setprecision(16);
    int tc=1; //cin>>tc; 
    while(tc--){
        solve();cout<<'\n';
    }
    return 0;
}



Measured memory_bytes: 3600
n = int(input())
s = list(input())
b = [0]*(n)
w = [0]*(n)
if n == 1:
    print(0)
    exit()
if s[0] ==".":
    w[0] =1
else:
    b[0] =1

for i in range(1,n):
    if s[i] == ".":
        w[i] = w[i-1] + 1
        b[i] =b[i-1]
    else:
        b[i] = b[i-1] + 1
        w[i] = w[i-1]
ans = w[-1]
for j in range(n):
    ans = min(ans,b[j]+w[-1]-w[j])
print(ans)

Measured memory_bytes: 64880
# include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,i;
	cin>>n;
	vector <int>h;
	h.resize(n);
	vector <int>dp(n);
	
	
	for(i=0;i<n;i++)
		cin>>h[i];
	dp[0]=0;
	dp[1]=abs(h[0]-h[1]);
	for(i=2;i<n;i++)
	{
		dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
		

	}
	cout<<dp[n-1]<<endl;
	return 0;


}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int vx = -(y2 - y1);
    int vy = x2 - x1;
    cout << x2 + vx << " " << y2 + vy << " " << x1 + vx << " " << y1 + vy << endl;
}

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

using namespace std;

typedef long long ll;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, start, end) for(int i = start; i < end; i++)
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << (x) << endl;
#define INF (1e9)
#define add_mod(a, b, x) ( (ll)(a) + (ll)(b) ) % (ll)(x)
#define mul_mod(a, b, x) ( ((ll)(a) % (ll)(x)) * ((ll)(b) % (ll)(x)) ) % (ll)(x)

ll sub_mod(ll a, ll b, ll x){
    ll tmp = (a - b) % x;
    if(tmp < 0) tmp += x;
    return tmp;
}

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

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

    int a, b;
    cin >> a >> b;

    if(b % a == 0) cout << a + b << endl;
    else  cout << b - a << endl;
}

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 1e9+7;
const int maxn = 303;


int n, m, k;
int g[maxn][maxn];

int ans[maxn][maxn];


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

    cin>>n>>m>>k;
    for (int i=1; i<=n; i++) {
	string s;
	cin>>s;
	for (int j=1; j<=m; j++) {
	    if (s[j-1]=='#') {
		g[i][j]=1;
	    }
	}
    }

    int at=1;

    for (int i=1; i<=n; i++) {
	for (int j=1; j<=m; j++) {
	    if (g[i][j]) {
		for (int k=j; k>=1; k--) {
		    if (ans[i][k]) break;
		    ans[i][k]=at;
		}
		at++;
	    }
	}
    }
    
    for (int i=1; i<=n; i++) {
	int last = 0;
	for (int j=1; j<=m; j++) {
	    if (ans[i][j]==0) {
		ans[i][j] = last;
	    }
	    last = ans[i][j];
	}
	
	last = 0;
	for (int j=m; j>=1; j--) {
	    if (ans[i][j]==0) {
		ans[i][j] = last;
	    }
	    last = ans[i][j];
	}
    }


    for (int i=1; i<=n; i++) {
	bool z=true;
	for (int j=1; j<=m && z; j++) {
	    if (ans[i][j]) z=false;
	}
	if (z) {
	    for (int j=1; j<=m; j++) {
		ans[i][j]=ans[i-1][j];
	    }
	}
    }

    for (int i=n; i>=1; i--) {
	bool z=true;
	for (int j=1; j<=m && z; j++) {
	    if (ans[i][j]) z=false;
	}
	if (z) {
	    for (int j=1; j<=m; j++) {
		ans[i][j]=ans[i+1][j];
	    }
	}
    }

    for (int i=1; i<=n; i++) {
	for (int j=1; j<=m; j++) {
	    cout<<ans[i][j]<<" ";
	}
	cout<<"\n";
    }
    
    return 0;
}


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

using namespace std;

int main(){
  string s;
  cin>>s;
  int k=s.length(),win=0;
  for(int i=0;i<k;i++){
	if(s[i]=='o'){
      win++;
    }
  }
  win+=15-k;
  if(win>=8){
    cout<<"YES\n";
  }
  else{
    cout<<"NO\n";
  }
  return 0;
}


Measured memory_bytes: 3416
# -*- coding: utf-8 -*-
N = int(input())
S = []
AC = 0
WA = 0
TLE = 0
RE = 0
for i in range(N):
    s = input()
    if s =="AC":
        AC+=1
    if s=="WA":
        WA+=1
    if s == "TLE":
        TLE += 1
    if s=="RE":
        RE +=1

print("AC x "+str(AC))
print("WA x "+str(WA))
print("TLE x "+str(TLE))
print("RE x "+str(RE))


Measured memory_bytes: 74680
import sys
if sys.platform == 'ios':
	sys.stdin = open('input.txt')

h,w = map(int,input().split())

s = [list(map(str,input().split())) for i in range(h)]

a = 0
b = 0

for i in range(h):
	for j in range(w):
		if s[i][j]=='snuke':
			a = i + 1
			b = chr(j+97).upper()
			
print(str(b)+str(a))			
			



Measured memory_bytes: 38256
N = gets.to_i
a = gets.split.map(&:to_i)
ans = 1
cnt = 0
(0..(N-1)).each do |i|
  if ans == a[i]
    ans += 1
  else
    cnt += 1
  end
end

if N == cnt
  puts -1
else
  puts cnt
end


Measured memory_bytes: 17284
// Problem : F - Knapsack for All Segments
// Contest : AtCoder Beginner Contest 159
// URL : https://atcoder.jp/contests/abc159/tasks/abc159_f
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/coder3101/cp-editor)

#include <bits/stdc++.h>
using namespace std;

#ifdef LOCAL
#define DEBUG(...) cerr << #__VA_ARGS__ << ": ", debug(__VA_ARGS__);
#else
#define DEBUG(...)
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename 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];} return os << "]";}
void debug() {cerr << "\n";} template<typename T, typename... Args> void debug(T x, Args... args) {cerr << x << "; "; debug(args...);}

#define MOD 998244353

void add(int &a, int b) {
    a += b;
    if (a >= MOD)
        a -= MOD;
}

int a[3000], dp[3001][3001][3] = {};

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    
    int n, s;
    cin >> n >> s;
    for (int i=0; i<n; i++)
        cin >> a[i];
    
    dp[0][0][0] = 1;
    for (int i=0; i<n; i++)
        for (int j=0; j<=s; j++) {
            add(dp[i+1][j][0], dp[i][j][0]);
            add(dp[i+1][j][1], dp[i][j][0]);
            add(dp[i+1][j][1], dp[i][j][1]);
            add(dp[i+1][j][2], dp[i][j][0]);
            add(dp[i+1][j][2], dp[i][j][1]);
            add(dp[i+1][j][2], dp[i][j][2]);
            if (j + a[i] <= s) {
                add(dp[i+1][j+a[i]][1], dp[i][j][0]);
                add(dp[i+1][j+a[i]][1], dp[i][j][1]);
                add(dp[i+1][j+a[i]][2], dp[i][j][0]);
                add(dp[i+1][j+a[i]][2], dp[i][j][1]);
            }
        }
    
    cout << dp[n][s][2] << "\n";

    return 0;
}


Measured memory_bytes: 105728
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i <(n) ; ++i)
using namespace std;
using ll = long long;
void self_max(int &a,int b){
	a = max(a,b);
}
void self_min(ll &a,ll b){
	a = min(a,b);
}

int main(){
	int n,k; cin >> n >>k;
	int arr[n+1] ={};
	rep(i,n) cin >> arr[i+1];

	vector<ll> dp(n+1,INT_MAX);
	dp[2] = abs(arr[2] - arr[1]);
    dp[1] = 0;
    dp[0] = 0;

    ll cur;
	
	for(int i=3;i<=n;i++){
		for(int j=k; j > 0; --j){
			if(i-j > 0){
				cur = dp[i-j] + abs(arr[i] - arr[i-j]);
				self_min(dp[i],cur);
			}
			    
		}
	}

	cout << dp[n] << endl;
	return 0;
}




Measured memory_bytes: 1408
import scala.io.StdIn

object Main extends App {
  val n= StdIn.readInt()
  val all = BigInt(10).pow(n)
  val withoutANuber = BigInt(9).pow(n)
  val withoutTwoNumber = BigInt(8).pow(n)

  val ans = all - (2 * withoutANuber - withoutTwoNumber)
  val mod = BigInt(10).pow(9) + 7
  println(ans % mod)
}







Measured memory_bytes: 100376
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
	int N, M, X;
	int A[101], B[101];
	cin >> N >> M >> X;
	for (int i = 0; i < M; i++) {
		cin >> A[i];
	}
	for (int i = 0; i <= N; i++) {
		B[i] = 0;
	}
	for (int i = 0; i < M; i++) {
			B[A[i]] = 1;
	}
	int c = 0, d = 0;
	for (int i = X; i <= N; i++) {
		c += B[i];
	}
	for (int i = 0; i <= X; i++) {
		d += B[i];
	}
	cout << min(c, d) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define pll pair<ll,ll>
#define v vector<ll>
#define st stack<ll>
#define pq  priority_queue <int>
#define q queue<ll>
#define mod 1000000005
using namespace std;
 char ch[1000000];
int main(){
    int a,b;
    cin>>a>>b;
    if(a+b>=10){
    	cout<<"error"<<endl;
    	return 0;
    }
    cout<<a+b<<endl;
    return 0;
   }

Measured memory_bytes: 3596
def warshal_floyd(d):
  for k in range(n):
    for i in range(n):
      for j in range(n):
        d[i][j] = min(d[i][j], d[i][k]+d[k][j])
  return d

n, m, r = map(int, input().split())
R = list(map(int, input().split()))
R = [r_-1 for r_ in R]

d = [[float('inf') for i in range(n)] for j in range(n)]

for i in range(m):
  x, y, z = map(int, input().split())
  x, y = x-1, y-1
  d[x][y] = z
  d[y][x] = z
  
for i in range(n):
  d[i][i] = 0

d = warshal_floyd(d)

import itertools
ans = float('inf')
for p in itertools.permutations(R):
  q = 0
  for i in range(len(p)-1):
    q += d[p[i]][p[i+1]]
  if q <= ans:
    ans = q
print(ans)

Measured memory_bytes: 59736
# 初期入力
N = int(input())
word = [ input() for i in range(N) ]

# 単語をキーに数を数えて辞書
from collections import Counter
kazu_word = Counter(word)

#一番多い単語を抜き出す
kazu_word_a = max(kazu_word.values()) #　内包表記の中で毎回MAXを計算するより出したほうが１回で済む
kazu_word_max =[i for i,v in kazu_word.items() if v == kazu_word_a ]
kazu_word_max_sorted = sorted(kazu_word_max)
"""
print(kazu_word)
print(kazu_word_max)
"""
print(*kazu_word_max_sorted,sep="\n")

Measured memory_bytes: 37516
#include<stdio.h>
int main(void)
{
  int n;
  int cnt=0;
  int p;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d",&p);
    if(i+1!=p){
      cnt++;
      //printf("%d %d\n",i+1,p);
    }
  }
  // printf("cnt=%d\n",cnt);
  if(cnt<3){
    puts("YES");
  }else{
    puts("NO");
  }
  return 0;
}


Measured memory_bytes: 128
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = Integer.parseInt(sc.next());
		int m = Integer.parseInt(sc.next());
		int[] a = new int[n];
		int sum = 0;

		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(sc.next());
			sum += a[i];
		}

		Arrays.sort(a);

		if (a[n - m] * 4 * m < sum) {
			System.out.println("No");
		} else {
			System.out.println("Yes");
		}
	}

}


Measured memory_bytes: 22868
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int sum = 0, num = n * (n + 1) / 2;
    rep(i, n) sum += a[i];
    if (sum % num != 0)
    {
        cout << "NO" << endl;
        return 0;
    }
    sum /= num;
    vector<int> b(n);
    rep(i, n - 1) b[i] = a[i + 1] - a[i] - sum;
    b[n - 1] = a[0] - a[n - 1] - sum;
    bool ok = true;
    rep(i, n) if (b[i] > 0 || b[i] % n != 0) ok = false;
    cout << (ok ? "YES" : "NO") << endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
#include <map>
using namespace std;
using ll = long long;
//typedef pair<string,string> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
//int prime[100001];
//char str[1010][1010];
//vector<pair<int,int> > pc[100001];
//int ABS(int a){return max(a,-a);}
int main(){
	int n,d[101],max,cnt=1;
	cin>>n;
	for(int i=0;i<n;i++) cin>>d[i];
	sort(d,d+n);
	max=d[n-1];
	for(int i=n-2;i>=0;i--){
		if(max>d[i]) cnt++;
		max=d[i];
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define debug2(x, y)                       \
  cerr << "(" << #x << "," << #y << ") = " \
       << "(" << x << "," << y << ")\n"
#define all(x) x.begin(), x.end()
#define each(a, x) for (auto& a : (x))
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define int long long
#define yn(x) puts((x ? "Yes" : "No"))
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
const int MX = 1e5 + 5, INF = 5LL << 57, MOD = 1e9 + 7;

int N, M;
string S;
vi va, vb;

void input() {
  ;
  ;
  int X;
  cin>>X;
  int now = 100;
  rep(i,1,99999){
    now *= 1.01;
    if (now >= X){
      cout<<i<<endl;return;

    }
  }
}
void solve() {
  ;
  ;
}
signed main() {
  cout << setprecision(12);
  input();
  solve();
  return 0;
}

Measured memory_bytes: 3624
import java.util.Scanner;
class Main{
    static public void  main(String[] av){

        Scanner sc =new Scanner(System.in);
        int n =sc.nextInt();
        int a[]= new int[n];
               for(int  i=0;i<n;i++){
            a[i] =sc.nextInt();
        }
int sum=0;
        for (int j=0;j<n;j++){
           double len = Math.sqrt(a[j]);
for ( int i=2 ; i<=len;i++){
    if(a[j]%i==0){
        sum++;
        break;
    }

    }
}



System.out.println(n-sum);       
    }
    
}


Measured memory_bytes: 42356
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define pii              pair <int,int>
#define pll              pair <long long,long long>
#define sc               scanf
#define pf               printf
#define Pi               2*acos(0.0)
#define ms(a,b)          memset(a, b, sizeof(a))
#define pb(a)            push_back(a)
#define MP               make_pair
#define db               double
#define ll               long long
#define EPS              10E-10
#define ff               first
#define ss               second
#define sqr(x)           (x)*(x)
#define D(x)             cerr<<#x " = "<<(x)<<endl
#define VI               vector <int>
#define DBG              pf("Hi\n")
#define MOD              1000000007
#define CIN              ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define SZ(a)            (int)a.size()
#define sf(a)            scanf("%d",&a)
#define sfl(a)           scanf("%lld",&a)
#define sff(a,b)         scanf("%d %d",&a,&b)
#define sffl(a,b)        scanf("%lld %lld",&a,&b)
#define sfff(a,b,c)      scanf("%d %d %d",&a,&b,&c)
#define sfffl(a,b,c)     scanf("%lld %lld %lld",&a,&b,&c)
#define stlloop(v)       for(__typeof(v.begin()) it=v.begin();it!=v.end();it++)
#define loop(i,n)        for(int i=0;i<n;i++)
#define loop1(i,n)       for(int i=1;i<=n;i++)
#define REP(i,a,b)       for(int i=a;i<b;i++)
#define RREP(i,a,b)      for(int i=a;i>=b;i--)
#define TEST_CASE(t)     for(int z=1;z<=t;z++)
#define PRINT_CASE       printf("Case %d: ",z)
#define LINE_PRINT_CASE  printf("Case %d:\n",z)
#define CASE_PRINT       cout<<"Case "<<z<<": "
#define all(a)           a.begin(),a.end()
#define intlim           2147483648
#define infinity         (1<<28)
#define ull              unsigned long long
#define gcd(a, b)        __gcd(a, b)
#define lcm(a, b)        ((a)*((b)/gcd(a,b)))

using namespace std;

//using namespace __gnu_pbds;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;


/*----------------------Graph Moves----------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*------------------------------------------------*/

/*-----------------------Bitmask------------------*/
//int Set(int N,int pos){return N=N | (1<<pos);}
//int reset(int N,int pos){return N= N & ~(1<<pos);}
//bool check(int N,int pos){return (bool)(N & (1<<pos));}
/*------------------------------------------------*/

int ara[300][300];

int g[12][12];

int main()
{

//    freopen("in.txt","r",stdin);
//	  freopen("out.txt","w",stdout);

    int n,m;
    cin>>n>>m;
    loop(i,10) loop(j,10) cin>>g[i][j];
    loop(k,10) loop(i,10) loop(j,10) g[i][j]=min(g[i][j],g[i][k]+g[k][j]);
    ll ans=0;
    loop(i,n) loop(j,m) {cin>>ara[i][j];if(ara[i][j]!=-1)ans+=g[ara[i][j]][1];};
    cout<<ans<<endl;

    return 0;
}


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

int main(){
  int N,ans,a,b;
  cin>>N;
  string S,T;
  cin>>S;
  T="";
  a=0;
  b=0;
  for(int i=0;i<N;i++){
    if(S[i]=='('){
      a++;
      T+='(';
    }
    else{
      b++;
      if(a<b){
        T='('+T;
        a++;
      }
      T+=')';
    }
  }
      for(int j=0;j<a-b;j++){
        T+=')';
      }
      cout<<T<<endl;
}

Measured memory_bytes: 256
local D=io.read"*n"

local c={}
for i=1,26 do c[i]=io.read"*n"end
local s={}
for i=1,D do s[i]={}for j=1,26 do s[i][j]=io.read"*n"end end

local function copy(t)local ret={}for i,v in ipairs(t)do ret[i]=v end return ret end

local function calc(d,t,l)
	local a=0
	l[t]=d
	for j=1,26 do
		a=a-c[j]*(d-l[j])
	end
	return a+s[d][t]
end

local t={}
for i=1,D do t[i]=io.read"*n"end

local last={}
for i=1,26 do
last[i]=0
end

local ret={}
local a=0
--score,contestid,last
local beam={{0,{},last}}
for i=1,D do
	local newbeam={}
	for k,b in ipairs(beam) do
		local lastt={}
		for j=1,26 do
			lastt[j]=copy(b[3])
		end
		for j=1,26 do
			local t=copy(b[2])
			table.insert(t,j)
			table.insert(newbeam,{b[1]+calc(i,j,lastt[j]),t,lastt[j]})
		end
	end
	table.sort(newbeam,function(a,b)return a[1]>b[1]end)
	newbeam[51]=nil
	beam=newbeam
end

for i,v in ipairs(beam[1][2])do
print(v)
end

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


int main() {
  long n;
  cin>>n;
  vector<long>a(n);
  vector<long>co(100100);
  long to=0;
  rep(i,n){
    cin>>a.at(i);
    co[a.at(i)]++;
    to+=a.at(i);
  }
  long q;
  cin>>q;
  vector<long>b(q),c(q);
  rep(i,q){
    cin>>b.at(i)>>c.at(i);
    to+=co[b.at(i)]*(c.at(i)-b.at(i));
    cout<<to<<endl;
    co[c.at(i)]+=co[b.at(i)];
    co[b.at(i)]=0;
  }
  
  
}





Measured memory_bytes: 6416
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int a[] = new int[3];
		for (int i = 0; i < a.length; i++) {
			a[i]= sc.nextInt();
		}
		if (a[0] == a[1]&&a[1]==a[2]) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


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

int main() {
  string x;
  cin>>x;
  int n=x.size(),s=0,t=0;
  for(int i=0;i<n;i++){
    if(x[i]=='S')
      s++;
    if(x[i]=='T'){
      t++;
      if(s>0){
        s--;
        t--;
      }
    }
  }
  cout<<s+t;
}

Measured memory_bytes: 640
Q = int(input())
l, r = [], []
for i in range(Q):
    _l, _r = map(int, input().split())
    l.append(_l)
    r.append(_r)
max_r = max(r)

is_sosu = [1] * (max_r + 1)
is_sosu[0] = is_sosu[1] = 0
for i in range(2, max_r + 1):
    if is_sosu[i]:
        for j in range(i * i, max_r + 1, i):
            is_sosu[j] = 0

sums = [0] * (max_r + 1)
for i in range(1, max_r + 1):
    if is_sosu[i] and is_sosu[(i + 1) // 2]:
        sums[i] = sums[i - 1] + 1
    else:
        sums[i] = sums[i - 1]

for i in range(Q):
    print(sums[r[i]] - sums[l[i] - 1])

Measured memory_bytes: 18728
#include <bits/stdc++.h>
#include <iostream>
#include <math.h>

using namespace std;

int main()
{
    long long int x, y, n, a, b, ans;
    cin >> x >> y >> n;
    a=y/n;
    b=x/n;
    ans=a-b;
    if(x%n==0)
        ans+=1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;
#define REP(i,n) for (int i = 0; i <(n); ++i)
//debug 
#ifdef _DEBUG
#define debug(var)  do{cout << #var << " :";view(var);}while(0)
#else
#define debug(...)
#endif
template<typename T> void view(T e){cout << e << endl;}
template<typename T> void view(const vector<T>& v){for(const auto& e : v){ cout << e << " "; } cout << endl;}
template<typename T> void view(const vector<vector<T> >& vv){ for(const auto& v : vv){ view(v); } }


int main(){
  string s;
  cin >> s;
  int n = s.size();
  if(n == 1){
    cout << "YES" << endl;
    return 0;
  }
  if(n == 2){
    if(s[0] == s[1]) cout << "NO" << endl;
    else cout << "YES" << endl;
    return 0;
  }
  int a = 0, b = 0, c = 0;
  REP(i,n){
    if(s[i] == 'a') a++;
    else if (s[i] == 'b') b++;
    else c++;
  }
  if(c > a) swap(a,c);
  if(c > b) swap(b,c);
  if(b > a) swap(a,b);

  bool ok = false;
  if(a == b && a == c) ok = true;
  if(a == b && a == c+1) ok = true;
  if(a == b+1 && a == c+1) ok = true;

  if(ok) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 3740
program sample
    implicit none
    character(100)::s
    integer(8) :: i,j,m,n,a,b
    integer(8),allocatable :: x(:),y(:)
  
    read(*,*) n,m
    allocate(x(n),y(n))
    x(:)=0
    y(:)=0
    do i=1,m
        read(*,*)a,b
        if(a==1)then
            x(b)=1
        elseif(b==n)then
            y(a)=1
        end if
    end do
    a=dot_product(x,y)
    if(a>0)then
        write(*,*)'POSSIBLE'
    else
        write(*,*)'IMPOSSIBLE'
    end if
    stop
end program sample
  



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


int gcd(int a, int b){
    int x = max(a, b);
    int y = min(a, b);
    if(y == 0){
        return x;
    }else{
        return gcd(y, x%y);
    }
}

int main(){
    int N, X;
    cin >> N >> X;
    int x[100000];
    for(int i = 0; i < N; i++){
        cin >> x[i];
        x[i] -= X;
        if(x[i] < 0){
            x[i] *= -1;
        }
    }
    int ans = x[0];
    for(int i = 1; i < N; i++){
        ans = gcd(ans, x[i]);
    }
    cout << ans << endl;
    
}


Measured memory_bytes: 640
#include<iostream>
#include<math.h>
#include<string>
#include<map>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<bitset>
#include<stack>
#include<algorithm>
#include<climits>
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ll long long int
#define vii vector<ll>
#define mii map<ll, ll>
#define debug(x) cerr << #x << " is " << x << "\n";
#define debug1(x, y) cerr << #x << " is " << x << "\n" << #y << " is " << y << "\n";
#define w(x) ll x; cin >> x; while(x--)
#define endl "\n"
#define f first 
#define s second 
#define fo(n) for(ll i = 0LL; i < n; ++i) 
#define setbits(n) __builtin_popcount(n)
#define all(x) x.begin(), x.end()
#define sortAll(x) sort(x.begin(), x.end())
#define pb push_back
#define mk make_pair
#define PERMUTE next_permutation
#define RESET(a, b) memset(a, b, sizeof(a))
#define MOD 1000000007
using namespace std;
 
int main(){
    fast
    ll n, w;
    cin >> n >> w;
    vector<pair<ll, ll>> list;
    fo(n) {
        ll wi, vi;
        cin >> wi >> vi;
        list.pb(mk(wi, vi));
    }
    vector<vector<ll>> dp(n + 1, vector<ll>(w + 1, 0));
    for(int i = 1; i <= n; ++i){
        for(int j = 1; j <= w; ++j){
            if(list[i - 1].first > j) {
                dp[i][j] = dp[i - 1][j];
            }
            else {
                dp[i][j] = max(list[i - 1].second + dp[i - 1][j - list[i - 1].first], dp[i - 1][j]);
            }
        }
    }
    cout << dp[n][w] << endl;
    return 0;
}

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


int main()
{
	long long int a, b, n, x, c, d, e;
	cin >> a >> b >> n;
    
    if(b>n+1)
    	cout << (a*n/b)-a*(n/b) << "\n";
    else
    	cout << (a*(b-1)/b)-a*((b-1)/b) << "\n";


	return 0;
	
}

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

int main()
{
    int n,a[1010]={};
    cin>>n;

    for(int i=1;i<=n;i++){
        cin>>a[i];
    }

    for(int i=n;i>=1;i--){
        cout<<a[i];
        if(i!=1){
            cout<<" ";
        }else{
            cout<<endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3076
#include<bits/stdc++.h>
#define LL long long 
using namespace std;
int main(void){
	int n,m;
	int ice[100001];
	LL box[100001]={0};
	int i,j;
	LL sum;
	LL MAX=-1;
	cin>>n>>m;
	for(i=0;i<n;i++)	cin>>ice[i];
	sum=0;
	for(i=0;i<n;i++){
		if(i!=n-2){
			if(ice[i]>ice[i+1]){
				sum+=(m-ice[i]);
			}
			else{//ice[i]<ice[i+1]
				sum+=(m-ice[i]);
				box[i]=sum;
				sum=0;
			}
		}
		else{
			sum+=(m-ice[i]);
		}
	}
	//cout<<sum<<endl;
	MAX=max(MAX,sum);
	sum=0;
	for(i=n-1;i>=0;i--){
		if(i!=0){
			if(ice[i]>ice[i-1]){
				sum+=(m-ice[i]);
			}
			else{//ice[i]<ice[i-1]
				sum+=(m-ice[i]);
				box[i]=max(sum,box[i]);
				sum=0;
			}
		}
		else{
			sum+=(m-ice[i]);
		}
	}
	//cout<<sum<<endl;
	MAX=max(MAX,sum);
	//for(i=0;i<n;i++)	cout<<box[i]<<endl;
	for(i=0;i<n;i++){
		MAX=max(MAX,box[i]);
	}
	cout<<MAX<<endl;
	return 0;
}


Measured memory_bytes: 4252
#include<stdio.h>

int main(void)
{
	int n;

	scanf("%d",&n);

	if(n/100==7){
		puts("Yes");
	}
	else{
		n=n%100;
		if(n/10==7){
			puts("Yes");
		}
		else{
			if(n%10==7){
				puts("Yes");
			}
			else puts("No");
		}
	}
	
	return 0;
}


Measured memory_bytes: 1624
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define pb push_back
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = 1; i <= n; ++i)
#define drep(i,n) for (int i = (n)-1; i >= 0; --i)
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
using namespace std;
typedef vector<int> vi;

const int MX = 100005;
const int INF = 1001001001;

int n, m;
int a[MX];

int main() {
  scanf("%d%d",&n,&m);
  rrep(i,n) a[i] = INF;
  rep(i,m) {
    int x;
    scanf("%d",&x);
    a[x] = 0;
  }
  rrep(i,n) mins(a[i+1],a[i]+1);
  drep(i,n) mins(a[i],a[i+1]+1);
  int ans = 0;
  rrep(i,n) maxs(ans, a[i]);
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3620
import numpy as np

inpt = input()
inpt_list = inpt.split(" ")
X, K, D = [int(x) for x in inpt_list]

X_abs = np.abs(X)
num = X_abs // D
rem = K - num
if rem < 0:
    out = X_abs - D*K
else:
    if rem%2==0:
        out = X_abs - num*D
    else:
        out = np.abs(X_abs - num*D - D)
print(out)

Measured memory_bytes: 27000
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int N;
vector<int> C;
int dp[112345][4][4][4];
vector<string> S;

bool dfs(int p, vector<int> c) {
	REP(i, 3) if (c[i] < 0) return false;
	if (p == N) return true;
	int &res = dp[p][c[0]][c[1]][c[2]];
	if (res != -1) return res;
	
	res = 0;
	REP(i, 2) {
		vector<int> nc = c;
		nc[S[p][0]-'A']++;
		nc[S[p][1]-'A']--;
		res |= dfs(p + 1, nc);
		swap(S[p][0], S[p][1]);
	}
	
	return res;
}

int main() {
	cin >> N;
	C.resize(3);
	REP(i, 3) {
		cin >> C[i];
		if (C[i] > 3) C[i] = 3;
	}
	S.resize(N);
	REP(i, N) cin >> S[i];
	
	memset(dp, -1, sizeof(dp));
	bool ok = dfs(0, C);
	puts([&] {
		return ok;
	}() ? "Yes": "No");
	if (ok) {
		vector<string> ans;
		REP(i, N) {
			REP(j, 2) {
				vector<int> nc = C;
				nc[S[i][0]-'A']++;
				nc[S[i][1]-'A']--;
				if (dfs(i + 1, nc)) {
					ans.emplace_back(S[i].substr(0, 1));
					C = nc;
					break;
				}
				swap(S[i][0], S[i][1]);
			}
		}
		for (string &s : ans) cout << s << endl;
	}
	return 0;
}


Measured memory_bytes: 59476
S,H,C,D = [],[],[],[]

def adding(card):
    if card[0] == 'S':
        S.append(int(card[1]))
    else:
        if card[0] == 'H':
            H.append(int(card[1]))
        else:
            if card[0] == 'C':
                C.append(int(card[1]))
            else:
                if card[0] == 'D':
                    D.append(int(card[1]))

def sort():
    S.sort()
    H.sort()
    C.sort()
    D.sort()

def check(pattern,cards):
    answer=[]
    for i in range(1,13+1):
        if not (i in cards):
            print pattern,i


if __name__ == '__main__':
    number = input()
    for i in range(number):
        card = map(str,raw_input().split())
        adding(card)
    sort()
    check('S',S)
    check('H',H)
    check('C',C)
    check('D',D)

Measured memory_bytes: 6476
#include <iostream>
#include <iomanip>
typedef long long ll;
using namespace std;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define repi(i, n, init) for (ll i = init; i < (n); i++)

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

int main()
{
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int cd = 0;
    repi(i, n, 0)
    {
        int a;
        cin >> a;
        if (i > 0)
        {
            cd = gcd(cd, a);
        }
        else
        {
            cd = a;
        }
    }
    cout << cd << endl;
    return 0;
}

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

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

int main() {
  int N,A,B;
  cin >> N >> A >> B;

  int ans = 0;
  for (int i = 1; i<=N; i++){
      int sum = check(i);
      if(sum>=A && sum<=B){
          ans = ans + i;
      }
  }

  cout << ans << endl;
  
}


Measured memory_bytes: 3628
INFTY = (1<<21)



def bfs(s)
	q = [s]
	d = Array.new($n, INFTY)
	d[s] = 0

	while !q.empty?
		u = q.shift
		$n.times do |v|
			next if $m[u][v] == 0
			next if d[v] != INFTY
			d[v] = d[u] + 1
			q.push(v)
		end
	end

	$n.times do |i|
		print i+1, " ", (d[i] == INFTY ? -1 : d[i]), "\n"
	end
end



$n = gets.to_i
$m = Array.new($n){ Array.new($n, 0) }

$n.times do
	u, k, *adj_list = gets.split.map &:to_i
	u -= 1
	adj_list.each do |v|
		v -= 1
		$m[u][v] = 1
	end
end

bfs(0)

Measured memory_bytes: 8760