akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include<algorithm>
#include <iomanip>
using namespace std;
typedef long long ll;
//定義場所//
int i, j, k, l, m, n;
////////////

int main()
{
	int N;
	cin >> N;
	int ans = 1000000;
	for (i = 0; i <= N; i++) {
		int task = i;
		int count = 0;
		while (task>0) {
			count += task % 6;
			task /= 6;
		}
		task = N - i;
		while (task > 0) {
			count += task % 9;
			task /= 9;
		}
		ans = min(ans, count);
	}
	cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#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 FORR(i, m, n) for (int i = (m); i >= (n); --i)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;

int main() {
  int n;
  cin >> n;
  vector<tuple<string, int , int>> re;
  rep(i, n) {
    string s;
    int p;
    cin >> s >> p;
    re.emplace_back(s, -p, i+1);
  }
  sort(re.begin(), re.end());
  rep(i, n) {
    cout << get<2>(re[i]) << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <utility>
#include <algorithm>
#include <set>
#include <string>
#include <queue>
#include <math.h>
#include <unordered_set>
using namespace std;

#define endl "\n"
#define pb push_back
#define INF INT_MAX/10
typedef long long ll;
typedef pair<ll,ll> PII;
typedef long long ll;



int main(){
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int n, T;
    cin >> n >> T;

    int c, t;
    int mc = 10000000;
    for ( int i = 0 ; i < n ; i++ ){
    	cin >> c >> t;
    	if ( t > T )	continue;
    	else {
    		mc = min(mc, c);
    	}
    }
    if ( mc < 10000000 )
    	cout << mc << endl;
    else cout << "TLE" << endl;

    return 0;
}


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

#define rep(i,n) for(ll i=0;i<n;i++)
#define repm(i,m,n) for(ll i=m;i<n;i++)
#define max(a,b) (((a)>(b))?(a):(b))
#define min(a,b) (((a)<(b))?(a):(b))
#define YesNo(a) (a)?cout<<"Yes"<<endl:cout<<"No"<<endl
#define YESNO(a) (a)?cout<<"YES"<<endl:cout<<"NO"<<endl
#define INF (2e9)
#define PI (acos(-1))
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007

typedef long long ll;

int main(){
    int n, x, t; cin >> n >> x >> t;

    cout << ((n-1)/x+1) * t << endl;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define makei(N) int N; cin >> N;
#define makel(N) ll N; cin >> N;
#define makes(s) string s; cin >> s;
#define maked(d) double d; cin >> d;
#define makev(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 1000000007
#define re return 0
#define distance(x1,y1,x2,y2) sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2));

using namespace std;
using ll = long long int;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using msi = map<string, int>;

template<typename T>
void say(T s) {
	cout << s << "\n";
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << "\n";
}

void yn(bool b) {
	if (b)say("Yes");
	else say("No");
}

template<typename T>
void maxi(T &a, T b) {
	a = max(a, b);
}

template<typename T>
void mini(T &a, T b) {
	a = min(a, b);
}

void exact_say(double x) {
	cout << setprecision(numeric_limits<double>::max_digits10) << x << endl;
}

int main() {
	ll ans = 0;
	makei(n);
	rep(n) {
		makei(a);
		ans += a - 1;
	}
	say(ans);
}

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

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL


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

    string s;
    cin >> s;
    int y = 0;
    rep (i, 4)
    {
        y *= 10;
        y += (s[i] - '0');
    }

    int m = 0;
    rep (i, 2)
    {
        m *= 10;
        m += (s[i + 5] - '0');
    }

    int d = 0;
    rep (i, 2)
    {
        d *= 10;
        d += (s[i + 8] - '0');
    }

    if (y > 2019) s = "TBD";
    else if (y == 2019 && m > 4) s = "TBD";
    else s = "Heisei";
    cout << s << "\n";
    return 0;
}



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

#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n,m[N][N];
int color[N],d[N],f[N],tt;

void visit(int a){
  int b;
  color[a]=GRAY;
  d[a]=++tt;
  for(b=0;b<n;b++){
    if(m[a][b]==0) continue;
    if(color[b]==WHITE) visit(b);
  }
  color[a]=BLACK;
  f[a]=++tt;
}

void dfs(){
  int a;
  for(a=0;a<n;a++) color[a]=WHITE;

  tt=0;

  for(a=0;a<n;a++){
    if(color[a]==WHITE) visit(a);
  }
  for(a=0;a<n;a++) printf("%d %d %d\n",a+1,d[a],f[a]);

}

int main(){
  int u,v,k,i,j;

  cin >> n;
  for(i=0;i<n;i++){
    for(j=0;j<n;j++) m[i][j]=0;
  }

  for(i=0;i<n;i++){
    cin >> u >> k;
    u--;
    for(j=0;j<k;j++){
      cin >> v;
      v--;
      m[u][v]=1;
    }
  }
  dfs();
  return 0;
}


Measured memory_bytes: 3260
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

A, B, C = MAP()

tmp = sorted([A, B, C], reverse=True)
print(tmp[0]*10+tmp[1]+tmp[2])

Measured memory_bytes: 3896
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using static MyIO;


public class D
{
	public static void Main()
	{
		long K = GetLong();

		Console.WriteLine(50);  // N = 50
		long[] a = new long[50];		
		long numLoop = K/50;
		for(int i = 0; i < 50; i++)
			a[i] = i + numLoop;

		long rest = K - 50 * numLoop;
		for(int i = 0; i < rest; i++)
		{
			for(int j = 0; j < 50; j++)
			{
				if(i == j)
				{
					a[j] += 50;
				}
				else
				{
					a[j]--;
				}
			}
		}

		for(int i = 0; i < 50; i++)
			Console.Write("{0} ", a[i]);
		Console.WriteLine();
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}


Measured memory_bytes: 13268
package main
import "fmt"
func main() {
  var n int
  fmt.Scan(&n)
  a := make([]int,n)
  for i:=0;i<n;i++ { fmt.Scan(&a[i]) }
  b := make([]int,n)
  for i:=0;i<n;i++ { fmt.Scan(&b[i]) }
  need := make([]bool,51)
  for i:=0;i<51;i++ { need[i] = true }
  ans := int64(0)
  Outside:
  for x:=51;x>-1;x-- {
    g := make([][]int,51)
    for i:=0;i<51;i++ {
      for k:=1;k<51;k++ {
        if k == x || !need[k] { continue }
        j := i%k
        if j == i { continue }
        g[i] = append(g[i],j)
      }
    }
    var dfs func(int,int) bool
    dfs = func(v,t int) bool {
      if v == t { return true }
      for _,e := range g[v] {
        if dfs(e,t) { return true }
      }
      return false
    }
    for i:=0;i<n;i++ {
      if !dfs(a[i],b[i]) {
        if x == 51 { fmt.Println(-1);return }
        ans |= 1<<uint(x)
        continue Outside
      }
    }
    if x != 51 { need[x] = false }
  }
  fmt.Println(ans)
}

Measured memory_bytes: 1664
a,b=map(int,input().split())
if a==1 and b==1:
    print(1)
elif a==1 or b==1:
    print(max(a,b)-2)
elif a==2 or b==2:
    print(0)
else:
    print(a*b-2*a-2*b+4)
    

Measured memory_bytes: 2940
import sys

def input(): return sys.stdin.readline()[:-1]

#mod = 10**9+7
#w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

#N = int(input())
_, S = map(int, input().split())
#L = [int(input()) for i in range(N)]
#A = tuple(map(int, input().split()))
#S = [list(map(int, input().split())) for i in range(N)]
mod=998244353

ans=0
dp=[0]*(S+1)
for a in map(int, input().split()):
    dp[0]+=1
    for i in range(S,a-1,-1):
        dp[i]+=dp[i-a]
        dp[i]%=mod
    ans+=dp[-1]
    ans%=mod
    #print(dp)

print(ans)


Measured memory_bytes: 70656
#include <iostream>
#include <cstdio>

using namespace std;

int main() {
	int n;

	cin >> n;

	int a[100];

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

	for (int i = n-1; i > 0; i--) {
		printf("%d ", a[i]);
	}
	printf("%d\n", a[0]);

	return 0;
}

Measured memory_bytes: 1144
#include <iostream>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define MOD 1000000007
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep(i,j,n) for(ll (i)=(j);(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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;
}

//グラフ関連
struct Edge {//グラフ
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}


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

	ll n, y;
	cin >> n >> y;

	REP(i, n+1) {
		REP(j, n - i+1) {
			ll k = n - i - j;

			if (10000 * i + 5000 * j + 1000 * k == y) {
				cout << i << " " << j << " " << k << endl;
				return 0;
			}
		}
	}

	cout << "-1 -1 -1" << endl;
	return 0;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<i64>();
    let (n, l) = (v[0] as usize, v[1]);
    let l = (0..n).map(|x| l + x as i64).collect::<Vec<_>>();
    let sum = l.iter().sum::<i64>();

    let mut ans = l[0];
    for i in 1..n {
        if l[i].abs() < ans.abs() {
            ans = l[i];
        }
    }
    println!("{}", sum - ans);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 2112
#include<bits/stdc++.h>
#define fo(i,a,b) for((i)=(a);i<=(b);i++)
#define rfo(i,a,b) for((i)=(a);i>=(b);i--)
#define inrange(x,y,z) (((x)>=(y))&&((x)<=(z)))
#define ALL(vec) ((vec).begin(),(vec).end())
#define SOR(vec) sort(ALL(vec))
#define UNI(vec) (vec).erase(unique(ALL(vec)),(vec).end())
using namespace std;
int n,opt;
long long cnt[8],res,MOD=998244353;
string s;
void Add(int a,int b){if(cnt[a]){cnt[a]--,cnt[b]++;}}
int main(){
	#ifdef FILIN
		#ifndef DavidDesktop
			freopen(FILIN,"r",stdin);
			freopen(FILOUT,"w",stdout);
		#endif
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>s;
	res=1LL;
	for(int i=0;i<n*3;i++){
		opt=(s[i]=='R'?1:(s[i]=='G'?2:3));
		if(cnt[7-opt])
			res=(res*cnt[7-opt])%MOD,cnt[7-opt]--;
		else if(opt==1&&(cnt[2]+cnt[3]))
			res=res*(cnt[2]+cnt[3])%MOD,Add(2,4),Add(3,5);
		else if(opt==2&&(cnt[1]+cnt[3]))
			res=res*(cnt[1]+cnt[3])%MOD,Add(1,4),Add(3,6);
		else if(opt==3&&(cnt[1]+cnt[2]))
			res=res*(cnt[1]+cnt[2])%MOD,Add(1,5),Add(2,6);
		else
			cnt[opt]++;
	}
	for(int i=1;i<=n;i++) res=(res*i)%MOD;
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 720
a = int(input())
b = int(input())
c = int(input())
x = int(input())
d =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:
                d += 1          
print(d)

Measured memory_bytes: 3060
#include<iostream>
#include<stdio.h>
using namespace std;

int main()
{
    while(1) {
        int h;
        int w;
        
        cin >> h >> w;
        
        if (h == 0 && w == 0) {
            break;
        }
        
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
    }
    
    return 0;
}


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

int main() {
	int num;
	int ans = 0;

	cin >> num;

	if ((num / 100) == 1) {
		ans += 900;
	}
	else{
		ans += 100;
	}
	num %= 100;


	if((num /10) == 1 ){
		ans += 90;
	}
	else{
		ans +=10;
	}

	num %=10;

	if(num  == 1 ){
		ans += 9;
	}
	else{
		ans +=1;
	}


	cout << ans;

	return 0;
}


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

int main() {
  int array[10]={};
  int N=0,sum=0;
  cin >> N;
  int t=N;
  while(t>0) {
    sum+=t%10;
    t/=10;
  }
  if(N%sum == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#!python3

import sys
sys.setrecursionlimit(10 ** 6)

LI = lambda: list(map(int, input().split()))

# input
N, M = LI()
XY = [LI() for _ in range(M)]

w = [None] * N
links = [[] for _ in range(N)]
visit = [False] * N


def create_links():
    for x, y in XY:
        links[x - 1].append(y - 1)


def dfs(u):
    visit[u] = True
    n = 0
    for v in links[u]:
        if not visit[v]:
            w[v] = dfs(v)
        n = max(n, w[v])
    return n + 1


def main():
    create_links()
    for i in range(N):
        if not visit[i]:
            w[i] = dfs(i)
    ans = max(w) - 1
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 80300
#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++)
typedef long long ll;
#define ALL(v) v.begin(), v.end()
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define chmax(x, a) x = max(x, a)
#define chmin(x, a) x = min(x, a)
const ll MOD = 1e9 + 7;

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main() {
    ll N; cin >> N;
    if (N == 1) {
        cout << 0 << endl;
        return 0;
    }
    cout << (modpow(10, N, MOD) - modpow(9, N, MOD)*2 + modpow(8, N, MOD) + 2*MOD) % MOD << endl;
}


Measured memory_bytes: 3632
s_list = list(map(str, input().rstrip()))

ans = []

for s in s_list:
    if s=="0":
        ans.append("0")
    elif s=="1":
        ans.append("1")
    elif s=="B":
        if len(ans)==0:
            continue
        else:
            ans.pop()

print("".join(ans))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<functional>
using namespace std;
#define ll long long int
#define ld long double
using namespace __gnu_pbds;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,
tree_order_statistics_node_update> in_set;
#define rep(n) for(ll i=0;i<(n);i++)
#define jrep(n) for(ll j=0;j<(n);j++)
#define all(a) (a).begin(), (a).end()
#define dpp(a) cout<<(a).first<<" "<<(a).second<<endl;
#define append push_back
#define mod 1000000007
#define ff first
#define ss second
#define ffast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fast ios::sync_with_stdio(0);
ll pw(ll x,ll y,ll p=mod){ll r=1; x=x%p;while(y>0){ if(y&1)r=(r*x)%p;
y=y>>1;x=(x*x)%p;} return r; } vector<ll> uniq(vector<ll> arr)
{vector<ll>brr;sort(all(arr));brr.append(arr[0]);
for(auto i:arr)if(brr.back()!=i)brr.append(i);return brr;}

ll spf[10000000+5];

ll npf(ll a){
    ll p=0; ll pr=0; ll cf=0; ll ret=1;
    map<ll,ll> mp;
    while(a>1){
        mp[spf[a]]++;
        a/=spf[a];
    }
    for(auto i:mp) ret*=(i.ss+1);
    return ret;
}
void solve(){
    ll n; cin>>n; ll tot=0;
    rep(n) tot+=((i+1)*npf(i+1)); cout<<tot<<endl;
}

int main(){
    rep(10000000+5) spf[i]=i;
    rep(10000000/2+2) spf[i*2]=2;
    for(ll i=3;i<10000000+5;i++) if(spf[i]==i){
        for(ll j=i*i;j<10000000+5;j+=i) spf[j]=min(spf[j],i);
    }
    ffast;
    ll t=1; //cin>>t;
    rep(t) solve();
}


// *p.find_by_order(n) : nth value (0 indexed)
// p.order_of_key(7): index of 7 (0 indexed)

Measured memory_bytes: 81772
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string.h>
#include<stack>
#include<ctype.h>
using namespace std;
typedef struct LNode
{
    int data;
    struct LNode *next;
} LNode, *LinkList;

typedef struct Binode
{
    char data[4];
    struct Binode *lchild,*rchild;
} Binode,*Bitree;

int main(){
int n,k;
cin>>n;
cin>>k;
int a[n];
for(int i=0;i<n;i++)
    cin>>a[i];
sort(a,a+n);
int sum=0;
for(int i=0;i<k;i++)
    sum+=a[i];
cout<<sum<<endl;
}


Measured memory_bytes: 3636
#pragma GCC optimize ("O3")
// #pragma GCC target ("avx")
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int H, W, K;
char F[11][11];

void MAIN() {
    scanf("%d%d%d", &H, &W, &K);
    REP (i, H) scanf("%s", F[i]);

    int ans = 0;
    REP (s, 1<<H) REP (t, 1<<W) {
	int cnt = 0;
	REP (i, H) if (s>>i&1) REP (j, W) if (t>>j&1) if (F[i][j] == '#') cnt++;
	if (cnt == K) ans++;
    }

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

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 3812
//2018-1-22
//miaomiao
//
#include <bits/stdc++.h>
using namespace std;
 
#define For(i, a, b) for(int i = (a); i <= (int)(b); ++i)
#define N (100000+5)

int Gcd(int a, int b){return !b? a: Gcd(b, a%b);}

int n, a[N];
 
int Check(){
	int odd = 0, even = 0;
	For(i, 1, n) if(a[i] & 1) ++odd; else ++even;
	
	if(even & 1) return 1;
	if(odd >= 2) return 0;
	For(i, 1, n) if(a[i] == 1) return 0;
	
	For(i, 1, n) if(a[i] & 1) --a[i];
	
	int g = a[1];
	For(i, 2, n) g = Gcd(g, a[i]);
	For(i, 1, n) a[i] /= g;

	return -1;
}
 
int main(){
	scanf("%d", &n);
	For(i, 1, n) scanf("%d", &a[i]);
	
	if(n == 1){
		if(a[1] & 1) puts("Second"); else puts("First");
		return 0;
	}
 
	int o = 0;
	while(true){
		int now = Check();
 
		if(now != -1){
			if(now ^ o) printf("First"); else puts("Second");
			break;
		}
		o ^= 1;
	}
 
	return 0;
}

Measured memory_bytes: 768
import java.util.Scanner;
        
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int x = sc.nextInt();
        int y = sc.nextInt();

        int tsuru = 0;
        int kame = 0;
        String answer = "Yes";

        if (y % 2 == 1) {
            answer = "No";
        } else if (x * 2 > y) {
            answer = "No";
        } else if (x * 4 < y) {
            answer = "No";
        } else if (((x * 4 - y) / 2) > x) {
            answer = "No";
        }

        if (x * 4 == y || x * 2 == y) {
            answer = "Yes";
        }
        
        System.out.println(answer);
    }
}

Measured memory_bytes: 35728
N = int(input())
if 1 <= N <= 9:
    ans = N
elif 10 <= N <= 99:
    ans = 9
elif 100 <= N <= 999:
    ans = 9 + N - 99
elif 1000 <= N <= 9999:
    ans = 9 + 900
elif 10000 <= N <= 99999:
    ans = 9 + 900 + N - 9999
elif N == 100000:
    ans = 9 + 900 + 90000
print(ans)


Measured memory_bytes: 61940
#include<stdio.h>
using namespace std;

int p[3], im[3];

int all(int a[]){
	if(a[0]>=a[1] && a[0]>=a[2]) return (a[0]-a[1])/2 + (a[0]-a[2])/2;
	if(a[1]>=a[0] && a[1]>=a[2]) return (a[1]-a[0])/2 + (a[1]-a[2])/2;
	if(a[2]>=a[1] && a[2]>=a[0]) return (a[2]-a[0])/2 + (a[2]-a[1])/2;

}

int nall(int a[], int b[]){
	a[1] = b[0]+1;
	a[2] = b[1]+1;
	return all(a)+1;
}

int main(){

	int i=0, j=0, k, n;
	for(k=0; k<3; k++){
		scanf("%d", &n);
		if(n%2==0) p[i]=n, i++;
		if(n%2!=0) im[j]=n, j++;
	}
	
	if(i==3) printf("%d\n", all(p));
	if(j==3) printf("%d\n", all(im));
	if(i==2) printf("%d\n", nall(im, p));
	if(j==2) printf("%d\n", nall(p, im));


}	

Measured memory_bytes: 128
import sys

use_clipboard=True
bbn=1000000007
	
#+++++

		
def main():
	n,m,x_c,y_c = map(int, input().split())
	xl=list(map(int, input().split()))
	yl=list(map(int, input().split()))
	xl.append(x_c)
	yl.append(y_c)
	#pa(xl)
	#pa(yl)
	if max(xl)+1 <= min(yl):
		print('No War')
	else:
		print('War')
	return 
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
class input_clipboard:
	def __init__(self,s):
		self.input_l=s.splitlines()
		self.ii=0
		
	def input(self):
		ret = self.input_l[self.ii]
		self.ii+=1
		return ret

if __name__ == "__main__":
	if sys.platform =='ios':
		if use_clipboard:
			import clipboard
			input_text=clipboard.get()
			ic=input_clipboard(input_text)
			input = lambda : ic.input()
			#sys.stdin=clipboard.get()
		else:
			sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<ll,ll> P;
#define pb push_back
#define mp make_pair
#define fr(i,n) for(int i=0;i<n;i++)
#define Fr(i,n) for(int i=0;i++<n;)
#define ifr(i,n) for(int i=n-1;i>=0;i--)
#define iFr(i,n) for(int i=n;i>0;i--)

ll f(ll i){return 2*i-1;}

int main(){
  ll n,m,x,y,z,dp[2][2][2][1010][1010]={},ans=0;
  cin>>n>>m;
  Fr(i,n){
    cin>>x>>y>>z;
    fr(i1,2){fr(i2,2){fr(i3,2){
      Fr(j,i){
        if(i==j) dp[i1][i2][i3][i][j]=dp[i1][i2][i3][i-1][j-1]+f(i1)*x+f(i2)*y+f(i3)*z;
        else dp[i1][i2][i3][i][j]=max(dp[i1][i2][i3][i-1][j],dp[i1][i2][i3][i-1][j-1]+f(i1)*x+f(i2)*y+f(i3)*z);
      }
    }}}
  }
  fr(i1,2){fr(i2,2){fr(i3,2){
    ans=max(ans,dp[i1][i2][i3][n][m]);
  }}}
  cout<<ans<<endl;
}

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

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

using namespace std;

typedef long long ll;

int main()
{
    string S;
    ll K;
    cin >> S;
    cin >> K;
    int cnt = 0;
    while(S[cnt] == '1')
    {
        cnt++;
    }

    char ans;
    if (K <= cnt)
    {
        ans = '1';
    }
    else
    {
        ans = S[cnt];
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
int X[200000], Y[200000];
int main() {
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> X[i];
		Y[i] = X[i];
	}
	sort(Y, Y + N);
	for (int i = 0; i < N; i++) {
		if (X[i] <= Y[N / 2 - 1]) cout << Y[N / 2] << endl;
		else cout << Y[N / 2 - 1] << endl;
	}
}

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

int main(){
    int n;
    cin >> n;
    string name;
    map<string, int> vote;

    for(int i = 0; i < n; i++){
        cin >> name;
        if(vote.count(name)) vote[name]++;
        else vote[name] = 1;
    }

    int maxv = 0;
    vector<string> vec[n + 1];
    for(auto it = vote.begin(); it != vote.end(); it++){
        maxv = max(maxv, it->second);
        vec[it->second].push_back(it->first);
    }
    sort(vec[maxv].begin(), vec[maxv].end());

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

    return 0;
}

Measured memory_bytes: 31604
#include <bits/stdc++.h>
    using namespace std;
     
    int main()
    {
    	string str;
      	cin>>str;
      	int toppings=0;
      	for(int i=0 ; i<str.length() ; ++i)
    	toppings+=str[i]=='o';
      	cout<<(700+100*toppings)<<endl;
    	return 0;
    }

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

typedef long long ll;

// 最大公約数の計算
ll CalcGCD(ll x, ll y)
{
    if(y==0)    return x;
    else        CalcGCD(y, x%y);
}

// 素因数分解
vector<pair<ll, int>> Factorize(ll n)
{
    vector<pair<ll, int>> vecRes;
    for(ll i=2; i*i<=n; i++){
        if(n%i != 0)
            continue;
        
        vecRes.emplace_back(i, 0);
        while(n%i==0){
            n /= i;
            vecRes.back().second++;
        }
    }

    if(n != 1)
        vecRes.emplace_back(n, 1);
    
    return vecRes;
}

int main()
{
    ll a, b;
    cin >> a >> b;

    // 最大公約数を計算
    ll gcd;
    gcd = CalcGCD(a, b);

    // 素因数分解
    vector<pair<ll, int>> vecPF;
    vecPF = Factorize(gcd);

    // 結果
    int res = vecPF.size() + 1;
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
using namespace std;


int main() {
    const long long int mod = 1000000007,INF=100000000000000;
	map<long long int, long long int>mp;
	cout << fixed << setprecision(10);
    string str;
    priority_queue<long long int,vector<long long int>,greater<long long int>> que;
    long long int n,m,left=0,right=0,res=0,resfin=0,now=0;
    cin>>n>>str;

    for(int i=0;i<str.length();i++){
        if(now==0&&str[i]==')'){
            left++;
        }else if(str[i]==')'){
            now--;
        }else{
            now++;
        }
    }
    for(int i=0;i<left;i++){
        cout<<"(";
    }
    cout<<str;
    for(int i=0;i<now;i++){
        cout<<")";
    }
    
} 


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

int main()
{
  int n, k, sum = 0;
  cin >> n >> k;
  vector<int> l(n);
  for (int i = 0; i < n; i++)
  {
    cin >> l.at(i);
  }
  sort(l.begin(), l.end());

  int buf = n - 1;
  for (int i = 0; i < k; i++)
  {
    sum += l.at(buf);
    buf--;
  }
  cout << sum << endl;
}


Measured memory_bytes: 3588
# coding: utf-8
# Your code here!

try:
   n = int(input())
   a = list(map(int, input().split()))
   
   for i in range(n):
      print(a[n - 1 - i], end = "")
      if i != n - 1:
         print(end = " ")
   print("")

except EOFError:
   pass


Measured memory_bytes: 5624
#include <bits/stdc++.h>
#define rep(i,n) for(int i= 0; i <(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int main()
{
    int n;
    cin >>n;
    int x =  (n+1000-1)/1000;
    int ans =  x *1000 -n;
    cout <<ans<<endl;


       return 0;
}

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

long long N, K;
long long a[5005];
bool ldp[5005][5005];
bool rdp[5005][5005];

int main(){
	cin >> N >> K;
	for(long long i = 0; i < N; i++){
		cin >> a[i];
	}

	//ldp[i] <-- i 未満
	for(long long i = 0; i < N; i++){
		for(long long j = 0; j < K; j++){
			if(j == 0 || ldp[i][j]){
				ldp[i+1][j] = true;
				if(j + a[i] < K){
					ldp[i+1][j+a[i]] = true;
				}
			}
		}
	}

	//for(int i = 0; i < N; i++){
	//	for(int j = 0; j < K; j++){
	//		cout << "ldp[" << i << "][" << j << "]=" << ldp[i][j] << endl;
	//	}
	//}

	//rdp[i] <-- i 以上
	for(long long i = N-1; i >= 0; i--){
		for(long long j = 0; j < K; j++){
			if(j == 0 || rdp[i+1][j]){
				rdp[i][j] = true;
				if(j + a[i] < K){
					rdp[i][j+a[i]] = true;
				}
			}
		}
	}

	//cout << endl;
	//for(int i = 0; i < N; i++){
	//	for(int j = 0; j < K; j++){
	//		cout << "rdp[" << i << "][" << j << "]=" << rdp[i][j] << endl;
	//	}
	//}

	long long ans = N;
	for(long long i = 0; i < N; i++){
		if(a[i] >= K){
			ans--;
			continue;
		}
		//can I create [K-a[i], K)
		bool ok = false;
		for(long long create = K - a[i]; create < K && ok == false; create++){
			for(long long left = 0; left <= create && ok == false; left++){
				long long right = create - left;
				if((left == 0 || ldp[i][left]) && (right == 0 || rdp[i+1][right])){
					ans--;
					ok = true;
				}
			}
		}
	}
	cout << ans << endl;;
}



Measured memory_bytes: 49280
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define ll long long
 
//const int INF = 1e8;
typedef pair<int,int>P;
int dx[4] = {1,0,-1,0};int dy[4] = {0,1,0,-1};
queue<P> que;

int main(void){
  int a,b;cin >> a >> b;
  if(a>=13){
    cout << b << endl;
  }else if(a >= 6){
    cout << b/2 << endl;
  }else{
    cout << 0 << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>

using namespace std;

#define MAX 10000;
#define INFTY (1<<29)

class DisjointSet{
public:
    vector<int> rank,p;
    DisjointSet(int size){
        rank.resize(size, 0);
        p.resize(size, 0);
        for (int i=0;i<size;i++){
            makeSet(i);
        }
    }
    void makeSet(int x){
        p[x] = x;
        rank[x] = 0;
    }
    bool same (int x, int y){
        return findSet(x) == findSet(y);
    }
    void unite (int x, int y){
        link(findSet(x), findSet(y));
    }
    void link(int x, int y){
        if (rank[x] > rank[y]){
            p[y] = x;
        }else{
            p[x] = y;
            if (rank[x] == rank[y]){
                rank[y]++;
            }
        }
    }
    int findSet(int x){
        if (x != p[x]){
            p[x] = findSet(p[x]);
        }
        return p[x];
    }

};

class Edge{
public:
    int source, target, cost;
    Edge(int source = 0, int target = 0, int cost = 0):
    source(source), target(target), cost(cost) {}
    bool operator < (const Edge &e) const{
        return cost < e.cost;
    }
};

int kruskal (int N, vector<Edge> edges){
    int totalCost = 0;
    sort(edges.begin(), edges.end());
    DisjointSet dset = DisjointSet(N+1);

    for (int i=0;i<N;i++){
        dset.makeSet(i);
    }
    int source, target;
    for (int i=0;i<edges.size();i++){
        Edge e = edges[i];
        if (!dset.same(e.source, e.target)) {
            totalCost += e.cost;
            dset.unite(e.source, e.target);
        }
    }
    return totalCost;
}
int main() {
    
    int N,M,cost;
    int source, target;
    cin >> N >> M;

    vector<Edge> edges;
    for (int i=0;i<M;i++){
        cin >> source >> target >> cost;
        edges.push_back(Edge(source,target,cost));
    }
    cout << kruskal(N, edges) << endl;

}


Measured memory_bytes: 5476
import java.util.Scanner;

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

        while(true){

            int m = sc.nextInt();
            int f = sc.nextInt();
            int r = sc.nextInt();

            if(m == -1 && f == -1 && r == -1){
                break;
            }

            else if(m == -1 || f == -1){
                System.out.println("F");
            }

            else if((m + f) >= 80){
                System.out.println("A");
            }  

            else if((m + f) >= 65 && (m + f) < 80){
                System.out.println("B");
            }

            else if((m + f) >= 50 && (m + f) < 65){
                System.out.println("C");
            }

            else if((m + f) >= 30 && (m + f) < 50){
                if(r >= 50){
                    System.out.println("C");
                }

                else{
                    System.out.println("D");
                }

            }

            else{
                System.out.println("F");
            }

        }

        sc.close();

    }


}


Measured memory_bytes: 26516
//Name : Rupa Dey
  //Date : 28 august 2020
//joi sri gour hori gobindo...
//gobindo ja hobe vlor jonnoi hobe..
#include<bits/stdc++.h>
#define ll long long
#define d double
#define ld long double
#define vi vector<int>
#define vul vector<ull>
#define vl vector<ll>
#define pb push_back
#define si set<int>
#define sl set<ll>
#define yes cout<<"YES\n"<<endl
#define no cout<<"NO\n"<<endl
#define ys cout<<"Yes\n"<<endl
#define n cout<<"No\n"<<endl
#define test cin>>t; while(t--)
#define for(i,a,n) for(i=a;i<n;i++)
#define mp make_pair
#define ft first
#define sc second
#define gap " ";
#define MAX 9999999
#define MOD 1000000007
#define nd endl
using namespace std;
int main()
{
   ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll a,b,print,m,k,mi;
    cin>>a>>b;
    m = b-a%b;
    a%=b;
   // cout<<m<<endl;
    //cout<<a<<endl;
    cout<<min(m,a);


}
//hare krishna...
//hey gobindo kripa koro......
//only gobindo exists..^..


Measured memory_bytes: 3592
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
#include<deque>
#include<cassert>
using namespace std;
typedef long long ll;
typedef pair<ll,int> p;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;
const int INF = 1001001001;

int main() {
  int w, a, b;
  cin >> w >> a >> b;
  int ans = 0;
  if(abs(a - b) <= w) cout << 0 << endl;
  else cout << abs(a - b) - w << endl;

}


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

using namespace std;
const double pi=acos(-1.0);
const double eps=1e-9;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pii pair <int,int>
#define piii pair < pii, int>
#define pll pair <long long , long long>
#define plll pair <pll , long long>
#define hjsagjfasjg y1
typedef long long ll;

int n,k,d[10];
vector <int> v;

bool check(int x)
{
	v.clear();
	while(x>0)
	{
		v.pb(x%10);
		x/=10;
	}
	for(int i=0;i<v.size();i++)
		for(int j=0;j<k;j++)
			if(v[i]==d[j])return false;
	return true;
}

int main()
{
	ios:: sync_with_stdio(false);
	cin >> n >> k;
	for(int i=0;i<k;i++)
		cin >> d[i];
	for(int i=n;;i++)
		if(check(i))
		{
			cout << i;
			return 0;
		}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DBG(X) cout << #X << "=" << (X) << '\n';
#else
	#define DBG(X)
#endif

using std::cin;
using std::cout;
using std::vector;
using std::string;
using std::pair;
using std::swap;
using std::sort;
using std::lower_bound;
using std::unique;

using int64 = long long int;
using pii   = pair<int, int>;
using pii64 = pair<int64, int64>;

const int NIL = -1;
const int INF = (int)2e9;
const int64 INF64 = (int64)2e18;

void init_IO() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
}

template<typename T>
std::ostream& operator<<(std::ostream& os, const vector<T>& vec) {
	os << '[';
	int fst = 1;

	for(auto& elem: vec) {
		if(fst == 0) {
			os << ' ';
		}

		os << elem;
		fst = 0;
	}

	os << ']';
	return os;
}

void solve() {
	int n;
	int64 C;
	cin >> n >> C;

	vector<int64> x(n);
	vector<int64> v(n);

	for(int i = 0; i < n; ++i) {
		cin >> x[i] >> v[i];
	}

	vector<int64> pref(n + 1, 0), pref2(n + 1, 0);

	for(int i = 1; i <= n; ++i) {
		pref[i] = v[i - 1] + pref[i - 1];
		pref2[i] = pref[i];
	}

	for(int i = 1; i <= n; ++i) {
		pref[i] -= x[i - 1];
		pref2[i] -= 2 * x[i - 1];

		pref[i] = std::max(pref[i], pref[i - 1]);
		pref2[i] = std::max(pref2[i], pref2[i - 1]);
	}

	vector<int64> suff(n + 1, 0), suff2(n + 1, 0);

	for(int i = 1; i <= n; ++i) {
		suff[i] = v[n - i] + suff[i - 1];
		suff2[i] = suff[i];
	}

	for(int i = 1; i <= n; ++i) {
		suff[i] -= std::abs(C - x[n - i]);
		suff2[i] -= 2 * std::abs(C - x[n - i]);

		suff[i] = std::max(suff[i], suff[i - 1]);
		suff2[i] = std::max(suff2[i], suff2[i - 1]);
	}

	int64 answ = -INF64;

	for(int l = 0; l <= n; ++l) {
		int64 opt1 = pref2[l] + suff[n - l];
		int64 opt2 = pref[l]  + suff2[n - l]; 

		answ = std::max({answ, opt1, opt2});
	}

	cout << answ << '\n';
}

int main() {
	init_IO();
	solve();

	return 0;
}


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

int main(){
        int a ,b, c;
        char g;
        int sum;
        while(1){
        cin >> a>> b >>c;
        if(a == -1 && b== -1 &&c == -1)break;
        sum = a + b;
        if(a >= 0 && b >= 0){
                if(sum >=80){
                        g = 'A';
                }else if ( 65<= sum&& sum < 80 ){
                        g = 'B';
                }else if (50 <= sum&&sum <65){
                        g = 'C';
                }else if(30 <= sum&& sum < 50){
                        g = 'D';
                        if(c >= 50)g = 'C';
                } else{
                        g = 'F';
                }
        }else{
                g = 'F';
        }

        cout << g << endl;
        }
}


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

int main(){
    int x,y,s;
    while(cin>>x>>y>>s){
        if(x==0&&y==0&&s==0){
            break;
        }
        int ans = 0 , t = 0;
        int in = 0;
        for(int i=1;i<s;i++){
            for(int j=1;j<s;j++){
                t = 0;
                in = 0;
                if(i+j<s/2)continue;
                //t=i+j;
                //cout<<t<<endl;
                t+=i*(100+y)/100+j*(100+y)/100;
                //cout<<t<<endl;
                //in+=i+j;
                in+=i*(100+x)/100+j*(100+x)/100;
                if(in==s){
                  //  cout<<"i:"<<i<<" j;"<<j<<" t:"<<t<<" in:"<<in<<endl;
                    ans = max(ans,t);
                }
            }
        }
        cout<<ans<<endl;
    }
}


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

int main() {
  
  long long A,B,C;
  cin >>A>>B>>C;
  
  if(A+B<=C) {
	cout<<"0 0"<<endl;
  }
  
  else if(A<=C) {
    cout<<"0 "<<B-(C-A)<<endl;
  }
  
  else {
    cout<<A-C<<" "<<B<<endl;
  }
  return 0;
}


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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
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; }
typedef long long ll;

const long long INF = 1LL << 60;

int main()
{
    int N, M, X, Y;
    cin >> N >> M >> X >> Y;

    vector<int> x(N), y(M);

    rep(i, N) cin >> x[i];
    rep(i, M) cin >> y[i];

    sort(x.begin(), x.end());
    sort(y.begin(), y.end());

    int Z = y[0];

    if (X < Z && Z <= Y) {
        if (x[N - 1] < Z) {
            cout << "No War" << endl;
        }
        else {
            cout << "War" << endl;
        }
    }
    else {
        cout << "War" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
string S,T;int n;
int main(){
	cin>>n;
	cin>>S>>T;
	if(S==T){cout<<n<<endl;return 0;}
	int maxn=0;
	for(int i=1;i<=T.size();i++){
		if(T.substr(T.size()-i,i)==S.substr(0,i)){maxn=max(maxn,i);}
	}
	for(int i=1;i<=T.size();i++){
		if(T.substr(0,i)==S.substr(S.size()-i,i)){maxn=max(maxn,i);}
	}
	cout<<S.size()+T.size()-maxn<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<math.h>
#include<string>
#include<algorithm>
#include<functional>
#include<vector>
#include<set>
#include<map>
#define INF 999999
#define EPS 1.0e-6

using namespace std;

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

int n;
ll d[105];

int main()
{
	d[0] = 2;
	d[1] = 1;
	cin >> n;
	for (int i = 2; i < 100; i++) {
		d[i] = d[i - 1] + d[i - 2];
	}
	cout << d[n] << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
 
using namespace std;
 
int n;
 
int main() {
	int t1 = 0, t2 = 0;
	int a1 = 0, a2 = 0;
	int b1= 0, b2 = 0;
 
	cin >> n;
	for (int i = 1; i <= n; i ++) {
		cin >> t1 >> a1 >> b1;
		int s = abs(a1 - a2) + abs(b1 - b2);
		if (s > (t1 - t2) || ((s % 2) != ((t1 - t2) % 2))) {
			cout << "No" << endl;
 
			return 0;
		}
		a2 = a1;
		b2 = b1;
		t2 = t1;
	}
	cout << "Yes" << endl;
 
	return 0;
}

Measured memory_bytes: 384
import sys
range = xrange
input = raw_input
 
def find_SCC(coupl):
    SCC, S, P = [], [], []
    depth = [0] * len(coupl)
 
    stack = list(range(len(coupl)))
    while stack:
        node = stack.pop()
        if node < 0:
            d = depth[~node] - 1
            if P[-1] > d:
                SCC.append(S[d:])
                del S[d:], P[-1]
                for node in SCC[-1]:
                    depth[node] = -1
        elif depth[node] > 0:
            while P[-1] > depth[node]:
                P.pop()
        elif depth[node] == 0:
            S.append(node)
            P.append(len(S))
            depth[node] = len(S)
            stack.append(~node)
            stack += coupl[node]
    return SCC[::-1]

class TwoSAT:
    def __init__(self, n):
        self.n = n
        self.graph = [[] for _ in range(2 * n)]

    def _imply(self, x, y):
        """ x => y """
        self.graph[x].append(y if y >= 0 else 2 * self.n + y)

    def either(self, x, y):
        """x or y must be True"""
        self._imply(~x, y)
        self._imply(~y, x)

    def set(self, x):
        """x must be True"""
        self._imply(~x, x)

    def solve(self):
        SCC = find_SCC(self.graph)
        
        inSCC = [0] * (2 * self.n)
        for scc_ind, scc in enumerate(SCC):
            for node in scc:
                inSCC[node] = scc_ind
        
        for i in range(self.n):
            if inSCC[i] == inSCC[~i]:
                return False, None
        
        return True, [+(inSCC[i] < inSCC[~i]) for i in range(self.n)]

inp = [int(x) for x in sys.stdin.read().split()]; ii = 0
 
n = inp[ii]; ii += 1
d = inp[ii]; ii += 1

sat = TwoSAT(n)

X = inp[ii + 0: ii + 2 * n: 2] 
Y = inp[ii + 1: ii + 2 * n: 2] 
ii += 2 * n

for i in range(n):
    for j in range(i + 1, n):
        if abs(X[i] - X[j]) < d:
            sat.either(i, j)
        
        if abs(Y[i] - Y[j]) < d:
            sat.either(~i, ~j)
        
        if abs(X[i] - Y[j]) < d:
            sat.either(i, ~j)
        
        if abs(Y[i] - X[j]) < d:
            sat.either(~i, j)

exists, solution = sat.solve()

if not exists:
    print 'No'
else:
    print 'Yes'
    print ' '.join(str(X[i] if b else Y[i]) for i, b in enumerate(solution))


Measured memory_bytes: 74184
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	N := getInt()

	for i := 1; i <= 3500; i++ {
		for j := 1; j <= 3500; j++ {
			Nhn := N * i * j
			NN := 4*i*j - N*i - N*j
			if NN <= 0 {
				continue
			}
			if Nhn%NN == 0 {
				k := Nhn / NN
				if k > 3500 {
					continue
				}
				out(i, j, k)
				return
			}
		}
	}
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    long long ans=0,p=1,now=0,cnt[2020]={0};
    cnt[0]=1;
    for(int i=s.size()-1;i>=0;i--)
    {
        now=(now+(s[i]-'0')*p)%2019;
        ans+=cnt[now]++;
        p=p*10%2019;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3772
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define FOR(i) for(cin>>i;i>0;i--)
#define elif else if
#define pb push_back
#define ll long long
#define mp make_pair
#define all(x) x.begin(),x.end()
#define re(x) {cout<<x<<endl;return 0;}
//#define x first
//#define y second

using namespace std;

int main()
{
	ll m,n;
	cin>>m>>n;
	if(m%n<n-(m%n)) cout<<m%n<<endl;
	else cout<<n-(m%n)<<endl;
	return 0;}

Measured memory_bytes: 256
#include <iostream>

int main()
{
  int S;
  std::cin >> S;

  int up = S / 100;
  int down = S % 100;

  bool up_mm = false;
  bool down_mm = false;
  bool invalid = true;

  if(1 <= up && up <= 12) {
    up_mm = true;
  }

  if(1 <= down && down <= 12) {
    down_mm = true;
  }

  std::string ret = "NA";
  if(up_mm && down_mm) {
    ret = "AMBIGUOUS";
  } else if(up_mm) {
    ret = "MMYY";
  } else if(down_mm) {
    ret = "YYMM";
  }

  std::cout << ret << std::endl;
  return 0;
}


Measured memory_bytes: 3604
n=int(input())
l=[None]*n
for i in range(n):
  a,b=map(int,input().split())
  l[i]=[a,b]
l.sort(key=lambda x:x[0]+x[1], reverse=True)
#print(l)
ans=0
for i in range(n):
  if i%2:
    ans-=l[i][1]
  else:
    ans+=l[i][0]
print(ans)

Measured memory_bytes: 24412