akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;

template <class T>
inline void read(T &x) {
    x = 0;
    char c = getchar();
    bool f = 0;
    for (; !isdigit(c); c = getchar()) f ^= c == '-';
    for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48);
    x = f ? -x : x;
}

template <class T>
inline void write(T x) {
    if (x < 0) {
        putchar('-');
        x = -x;
    }
    T y = 1;
	int len = 1;
    for (; y <= x / 10; y *= 10) ++len;
    for (; len; --len, x %= y, y /= 10) putchar(x / y + 48);
}

const int MAXN = 1e3, MAXM = 1 << 13;
int n, m, a[MAXN + 5], b[MAXN + 5], f[MAXM + 5];

int main() {
	read(n), read(m);
	for (int c, i = 1; i <= m; ++i) {
		read(a[i]), read(c);
		for (int x, j = 1; j <= c; ++j) {
			read(x);
			b[i] |= 1 << (x - 1);
		}
	}
	memset(f, 0x3f, sizeof (f));
	f[0] = 0;
	for (int i = 0; i <= (1 << n); ++i)
		for (int j = 1; j <= m; ++j)
			f[i | b[j]] = min(f[i | b[j]], f[i] + a[j]);
	write(f[(1 << n) - 1] == 0x3f3f3f3f ? -1 : f[(1 << n) - 1]);
	putchar('\n');
	return 0;
}

Measured memory_bytes: 256
A,V=map(int, input().split())
B,W=map(int,input().split())
T=int(input())
d=abs(A-B)
if A==B:
    print("YES")
    exit()
if V-W==0:
    print("NO")
    exit()
if 0<=d/(V-W)<=T:
    print("YES")
else:
    print("NO")

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

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N,P=MI()
    if P==1:
        print(1)
        exit()
        
    #nの素因数分解，[[a1,b1],[a2,b2]...]   aがb個,
    def factorization(n):
        if n==1:
            return [0,1]
        arr = []
        temp = n
        for i in range(2, int(-(-n**0.5//1))+1):
            if temp%i==0:
                cnt=0
                while temp%i==0:
                    cnt+=1
                    temp //= i
                arr.append([i, cnt])

        if temp!=1:
            arr.append([temp, 1])

        if arr==[]:
            arr.append([n, 1])

        return arr
    
    L=factorization(P)
    ans=1
    for i in range(len(L)):
        a=L[i][0]
        b=L[i][1]
        c=b//N
        temp=pow(a,c)
        ans*=temp
        
    print(ans)
        

main()


Measured memory_bytes: 63496
#include <bits/stdc++.h>
typedef long long i64;
using std::cout;
using std::endl;
using std::cin;

int main(){
	int n; cin >> n;
	
	int ma = 0, c = 0;
	for(int i = 0; i < n; i++) {
		int a; cin >> a;
		
		c = (c + 1) * a;
		ma = std::max(ma, c);
	}
	
	cout << ma + 1 << endl;
	return 0;
}



Measured memory_bytes: 3044
// at_abc150c.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<string>
using namespace std;
vector<int> v;
#define FOR(i,a) for(int i=0;i<a;i++)
int main()
{
    int n;cin >> n;
    int a, b;
    int idx = 0;
    string tempa = "", tempb = "";
    FOR(i, n) {
        int num;cin >> num;
        tempa += to_string(num);
    }
    FOR(i, n) {
        int num;cin >> num;
        tempb += to_string(num);
    }
    FOR(i, n) {
        v.push_back(i + 1);
    }
    do{
        string cur = "";
        FOR(i, n) {
            cur += to_string(v[i]);
        }
        if (cur.compare(tempa) == 0) {
            a = idx;
        }
        if (cur.compare(tempb) == 0) {
            b = idx;
        }
        idx++;
    } while (next_permutation(v.begin(),v.end()));
    cout << abs(a - b) << "\n";
}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started: 
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
//    ios_base::sync_with_stdio(0); cin.tie(0);
    int n; string s;
    cin >> n >> s;
    vector<pair<int, int>> vals;
    vector<string> mx(n + 1);
    vector<int> go(2 * n);
    vector<int> label(2 * n);
    int it1 = 0, it2 = 0;
    while(it1 != 2 * n && it2 != 2 * n){
        while(s[it1] != 'a') it1++;
        while(s[it2] != 'b') it2++;
        vals.emplace_back(min(it1, it2), max(it1, it2));
        go[it1] = it2, go[it2] = it1;
        it1++, it2++;
    }
    sort(vals.begin(), vals.end());
    for(int i = 0; i < n; i++){
        label[vals[i].first] = i;
        label[vals[i].second] = i;
    }
    for(int loc = n - 1; loc >= 0; loc--){
        int st = vals[loc].first, ed = vals[loc].second;
        int last = st;
        if(s[st] == 'b'){
            int cut = ed;
            while(last != cut){
                cut = max(cut, go[last]);
                last++;
            }
            if(go[last] > last) last--;
        }
        else{
            last = ed;
        }
        string fin = "";
        if(s[st] == 'a'){
            fin = "ab";
        }
        else{
            for(int i = st; i <= last; i++){
                if(s[i] == 'a' && go[i] < st) continue;
                fin += s[i];
            }
        }
        int nxt = -1;
        for(int i = last + 1; i < 2 * n; i++){
            if(go[i] > i){
                nxt = i;
                break;
            }
        }
        if(nxt != -1) fin += mx[label[nxt]];
        mx[loc] = max(mx[loc + 1], fin);
    }
    cout << mx[0] << '\n';
    return 0;
}


Measured memory_bytes: 12204
fun main() {
    val s = readLine()!!.toCharArray().map { it.toString() }.distinct().sorted()

    var c: Char = 'a'
    while (c <= 'z') {
        if(!s.contains(c.toString())) {
            print(c)
            return
        }
        c++
    }

    print("None")
}

Measured memory_bytes: 47092
// -----------------------------------------------
// Framework <https://github.com/vain0x/procon>
//
// See the bottom of file for solution.
// -----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

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

#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

const P: i64 = 1_000_000_007;

struct Solver {
    N: usize,
    G: Vec<Vec<usize>>,
    done: Vec<bool>,
    dpw: Vec<i64>,
    dpb: Vec<i64>,
}

impl Solver {
    fn calc(&mut self, u: usize) {
        self.done[u] = true;

        let mut w = 1;
        let mut b = 1;

        for i in 0..self.G[u].len() {
            let v = self.G[u][i];

            if self.done[v] {
                continue;
            }

            self.calc(v);

            w *= (self.dpw[v] + self.dpb[v]) % P;
            w %= P;
            b *= self.dpw[v];
            b %= P;
        }

        self.dpw[u] = w;
        self.dpb[u] = b;
    }
}

fn main() {
    let N = read!(usize);
    let T = read![usize, usize; N - 1];

    let mut G = vec![vec![]; N];
    for (u, v) in T {
        G[u - 1].push(v - 1);
        G[v - 1].push(u - 1);
    }

    let mut solver = Solver {
        N: N,
        G: G,
        done: vec![false; N],
        dpw: vec![0; N],
        dpb: vec![0; N],
    };
    solver.calc(0);

    println!("{}", (solver.dpw[0] + solver.dpb[0]) % P);
}


Measured memory_bytes: 21500
import java.util.Scanner;

public class Main {



    public static void main(String[] args) {
    	Scanner input = new Scanner(System.in);
    	int n = input.nextInt();
    	long[] num = new long[n + 1];
    	num[0] = 2l;
    	num[1] = 1l;
    	for (int i = 2; i <= n; i++) {
    		num[i] = num[i-1] + num[i - 2];
    	}
     	System.out.println(num[n]);
    }
}



Measured memory_bytes: 23764
#include<bits/stdc++.h>
#define inf 0x3f3f3f3f
#define lson root<<1
#define rson root<<1|1
#define Mid int mid=(l+r)>>1;
#define FREI freopen("in.txt","r",stdin)
#define FREO freopen("out.txt","w",stdout)
#define Mem(a,b) memset(a,b,sizeof(a))
#define MAXN 400
#define mod 1000000007
#define ll long long
#define eps 1e-6
using namespace std;
const int N=1e5+10;
struct point{
    int v;
    ll cost;
};
vector<point> G[N];//用vector存的图
#define DEEP 20
int fa[N],deep[N],_fa[N][DEEP];
ll realdeep[N];
int find(int x)
{
    if(fa[x]==-1) return x;
    return find(fa[x]);
}
void dfs(int u,int Father,ll cost)
{
    //cout<<realdeep[Father]<<endl;
    deep[u]=deep[Father]+1,_fa[u][0]=Father;
    realdeep[u]=realdeep[Father]+cost;
    for(int i=1;i<DEEP;i++) _fa[u][i]=_fa[_fa[u][i-1]][i-1];//16为树的最大深度
    for(int i=0;i<G[u].size();i++){
        if(G[u][i].v!=Father)
            dfs(G[u][i].v,u,G[u][i].cost);
    }
}
int lca(int x,int y){
    if(deep[x]<deep[y]) swap(x,y);
    int d=deep[x]-deep[y];
    for(int i=0;i<DEEP;i++){
        if((1<<i)&d) x=_fa[x][i];
    }
    if(x==y) return x;
    for(int i=DEEP-1;i>=0;i--){
        if(_fa[x][i]!=_fa[y][i]) x=_fa[x][i],y=_fa[y][i];
    }
    return _fa[x][0];
}
ll dist(int x,int y){
    ll xy=lca(x,y);
    return realdeep[x]+realdeep[y]-2*realdeep[xy];
}
ll work(int x,int y,int z){
    int s=lca(y,z),s1=lca(x,y),s2=lca(x,z);
    if(s1==x&&s2==s||s1==s&&s2==x) return dist(y,z);
    else{
        int s3=lca(x,s);
        if(s3!=s){
            return dist(y,z)+2*dist(x,s);
        }
        else{
            if(s1!=s){
                return dist(y,z)+2*dist(x,s1);
            }
            else return dist(y,z)+2*dist(x,s2);
        }
    }
}
int main()
{
    //FREI;
    Mem(deep,0);
    Mem(realdeep,0);
    Mem(fa,-1);
    int n;
    scanf("%d",&n);
    for(int i=1;i<n;i++){
        ll u,v,cost;
        scanf("%d%d%lld",&u,&v,&cost);
        G[u].push_back({v,cost});
        G[v].push_back({u,cost});
        fa[v]=u;
    }
    //cout<<"test"<<endl;
    dfs(find(1),0,0);
   // cout<<"test"<<endl;
    int q,k;
    scanf("%d%d",&q,&k);
    while(q--){
        int u,v;
        scanf("%d%d",&u,&v);
        //cout<<u<<' '<<k<<endl;
        printf("%lld\n",work(k,u,v));
    }

}


Measured memory_bytes: 22912
def BigAdd(numa, numb):
	longer = (numa if len(numa) >= len(numb) else numb)
	shorter = (numa if len(numa) < len(numb) else numb)
	carry = 0
	s = ''
	for i in range(-1, -len(shorter) - 1, -1):
		curr = carry + int(longer[i]) + int(shorter[i])
		if curr >= 10:
			carry = 1
			s = str(curr - 10) + s
		else:
			carry = 0
			s = str(curr) + s
	for i in range(-len(shorter) - 1, -len(longer) - 1, -1):
		curr = carry + int(longer[i])
		if curr >= 10:
			carry = 1
			s = str(curr - 10) + s
		else:
			carry = 0
			s = str(curr) + s
	if carry == 1:
		s = '1' + s
	return s

while True:
	try:
		numa, numb = [item for item in input().split()]
		print(len(BigAdd(numa, numb)))
	except EOFError:
		break

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

const int inf = 2000000000;

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

    sort(h.begin(), h.end());

    int m = inf;
    for (int i = 0; i < N - K + 1; i++) {
        m = min(m, h[i + K - 1] - h[i]);
    }

    cout << m << endl;
    return 0;
}

Measured memory_bytes: 640
from collections import Counter

n = int(input())
aaa = list(map(int, input().split()))
cnt = Counter(aaa)

base = 0
for c in cnt.values():
    base += c * (c - 1) // 2

buf = []
cache = {}
for a in aaa:
    if a in cache:
        buf.append(cache[a])
        continue
    c = cnt[a]
    ans = base - c * (c - 1) // 2 + (c - 1) * (c - 2) // 2
    buf.append(ans)
    cache[a] = ans
print('\n'.join(map(str, buf)))


Measured memory_bytes: 44948
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define forx(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)

struct pref{
    int num;
    ll p;
    ll y;
    string ans;
};

bool one( const pref& left, const pref& right ) {
    return left.y < right.y;
}

bool two( const pref& left, const pref& right ) {
    return left.num < right.num;
}


int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n,m;
    cin>>n>>m;
    vector<pref>x(m);
    vector<int>count(n+1,1);

    rep(i,m){
        cin>>x[i].p>>x[i].y;
        x[i].num=i+1;
    }

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

    rep(i,m){
        ll t =1000000*x[i].p + count[x[i].p];
        count[x[i].p]++;

        string s=to_string(t);
        while(s.size()<12)s="0"+s;

        x[i].ans=s;
    }
    
    sort(x.begin(),x.end(),two);

    rep(i,m)cout<<x[i].ans<<endl;

    return 0;
}


Measured memory_bytes: 9728
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <set>
#include <string>
#include <cstring>
using namespace std;
int gcd(int a,int b)
{
    if(b==0)
        return a;
    else{
        return gcd(b,a%b);
    }
}
int main()
{
    int n,x,X,d=1;
    while(cin>>n>>x){
        for(int i=0;i<n;i++){
            cin>>X;
            if(i==0){
                d=abs(x-X);
            }
            else{
                d=gcd(d,abs(x-X));
            }
        }
        cout<<d<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
use std::io::{self, BufRead};
use std::cmp::min;

fn main() {
  let stdin = io::stdin();
  let mut lines = stdin.lock().lines();
  let _ = lines.next();
  let xs: Vec<usize> = lines.next().unwrap().unwrap().split(' ').map(|x| x.parse().unwrap()).collect();
  let n = xs.iter().max().unwrap();
  let k = xs.iter().max_by(|x, y| min(**x, n - *x).cmp(&min(**y, n - *y))).unwrap();
  println!("{} {}", n, k);
}

Measured memory_bytes: 6396
#include <iostream>
using namespace std;
int main(){
  int W,H,N;
  int a;
  int Wmin=0,Wmax,Hmin=0,Hmax;
  cin >> W >> H >> N;
  Wmax = W;
  Hmax = H;
  for(int i = 0;i<N;i++){
    cin >> W >> H >> a;
    switch(a){
      case 1:
        Wmin = max(Wmin,W);
        break;
      case 2:
        Wmax = min(Wmax,W);
        break;
      case 3:
        Hmin = max(Hmin,H);
        break;
      case 4:
        Hmax = min(Hmax,H);
        break;
      default:
        break;
    }
  }
  cout << max(0,(Wmax-Wmin))*max((Hmax-Hmin),0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define con_input(v) for(auto it=v.begin();it!=v.end();it++){cin>>*it;}
#define con_debug(v) for(auto it=v.begin();it!=v.end();it++){cerr<<*it<<" ";}cerr<<endl;
using namespace std;
using ll = long long;
template <typename T>T digitsum(T n);
template <typename T>bool isPrime(T n);
template <typename T>vector<pair<T, T>> prime_factor(T n);
long long int intpow(long long int,long long int);
template <typename T>T intlog(T);

int main(){
    int x,n,j=0;
    int ans=0;
    cin>>n;
    rep(i,n){
        cin>>x;
        if(x-1!=j){
            ans++;
        }else{
            j++;
        }
    }
    cout<<(ans==n?-1:ans)<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int a,b,c,s,i,h,n;
	while(scanf("%d%d%d",&a,&b,&c) , a != 0){
		s = 0;
		for(i = 1;i <= a;i++){
			scanf("%d\n",&n);
			if(i == b) h = n;
			s+=n;
		}
		if(h)printf("%d\n",(s*(100-c))/h);
		else printf("0\n");
	}
	return 0;
}

Measured memory_bytes: 612
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
//#include <stack>
//#include <queue>
//#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
//#include <list>
#include <iomanip>

using namespace std;

#define IOS ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define prec std::cout << std::fixed << std::setprecision(15);
#define endl "\n"
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define ssort(z) sort(z.begin(), z.end())
#define rsort(z) sort(z.rbegin(), z.rend())
#define eerase(z) z.erase(unique(z.begin(), z.end()), z.end())
#define ccnt(z, w) count(z.begin(), z.end(), w)
#define rep(i,a,n) for(Int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(Int (i)=(a); (i)<=(n); (i)++)
const int MAX_N = 1000000;
const Int MAX_N_Int = 1000000000000;

template <typename T>
void printV(const std::vector<T>& v, const char * const separator = " ")
{
    if(!v.empty())
    {
        std::copy(v.begin(),
                  --v.end(),
                  std::ostream_iterator<T>(std::cout, separator));
        std::cout << v.back() << "\n";
    }
}

bool isPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}
Int gcd(Int a, Int b) {
    return b != 0 ? gcd(b, a % b) : a;
}

Int lcm(Int a, Int b) {
    return a / gcd(a, b) * b;
    //a*bは64bit integer overflow
}

int Max(int a, int b, int c) {
    int temp = max(a, b);
    return max(temp, c);
}

int Min(int a, int b, int c) {
    int temp = min(a, b);
    return min(temp, c);
}

bool integer(double num) {
    return floor(num) == num;
}

Int fact(int num) {
    if (num == 0)
        return 1;
    else
        return num * fact(num - 1);
}

Int yakusu(int n) {
    int cnt = 0;
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            cnt++;
            if (i * i != n) cnt++;
        }
    }
    return cnt;
}


Int fact_mod(Int n, Int mod) {
    Int f = 1; repq(i,2,n) f = f * (i % MOD) % MOD;
    return f;
}

// 繰り返し二乗法 (modの世界での累乗)
Int mod_pow(Int x, Int n, Int mod) {
    Int res = 1;
    while(n > 0) {
        if(n & 1) res = (res * x) % mod;
        x = (x * x) % mod;
        n >>= 1;
    }
    return res;
}

// 組み合わせ nCr を求める
Int combination_mod(Int n, Int r, Int mod) {
    if(r > n-r) r = n-r;
    if(r == 0) return 1;
    Int a = 1;
    rep(i, 0, r) a = a * ((n-i) % mod) % mod;
    Int b = mod_pow(fact_mod(r, mod), mod-2, mod);
    return (a % mod) * (b % mod) % mod;
}

int main() {
    //COMinit();
    IOS;
    prec;
    Int a,b,c,n,m,k,x,y=0,ans=1;
    string str,s="",t,u;
    cin>>s;

    int now=0;
    if(s[0]=='Y' and s[1]=='A' and s[2]=='K' and s[3]=='I'){
        cout<<"Yes";
    }else cout<<"No";




    cout<<endl;
    return 0;
}




Measured memory_bytes: 256
function Main(input) {
  input = input.split("\n");
  const N = parseInt(input[0],10);
  const a_i = input[1].split(' ');
  let a_sum = 0;
  let b_sum = 0;
  for (var i = 0; i < a_i.length; i++) {
     a_i[i] = parseInt(a_i[i],10); 
  }
  a_i.sort((a,b) => {
    return b-a;
  });
  for (var a_i_index = 0; a_i_index < a_i.length; a_i_index++) {
    if (a_i_index % 2 === 0) {
      a_sum += a_i[a_i_index];
    } else {
      b_sum += a_i[a_i_index];
    }
  }
  console.log(a_sum - b_sum);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

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

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
	int q, x;
  char com[20];

  list<int> v;
  cin >> q;
  rep(i, q) {
    cin >> com;
    if (com[0] == 'i') {
      cin >> x;
      v.push_front(x);
    }
    else if(com[6] == 'L') v.pop_back();
    else if(com[6] == 'F') v.pop_front();
    else if(com[0] == 'd') {
      cin >> x;
      for(auto itr = v.begin(); itr != v.end(); itr++) {
        if(*itr == x) {
          v.erase(itr);
          break;
        }
      }
    }
  }
  int i = 0;
  for(auto j : v) {
    if(i++) cout << " ";
    cout << j;
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 34328
N = int(input())

t0, a0 = 1, 1
for _ in range(N):
  t, a = map(int,input().split())
  vote = max((t0+t-1)//t, (a0+a-1)//a)
  t0 = t * vote
  a0 = a * vote
print(t0+a0)


Measured memory_bytes: 2940
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		while(true) {
			String s=sc.next();
			int ans=0;
			if(s.equals("0")) {
				System.exit(0);
			}
			for(int i=0; i<s.length(); i++) {
				ans+=s.charAt(i)-'0';
			}
			System.out.println(ans);
		}

	}
}


Measured memory_bytes: 26580
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)

int main(void) {
  string s;
  cin >> s;
  int n = s.size();
  int res = 0;
  REP(i2, n+1) {
    REP(i1, i2) {
      bool ok = true;
      for(int i = i1; i < i2; ++i) {
        if(s[i] != 'A' && s[i] != 'C' && s[i] != 'G' && s[i] != 'T') {
          ok = false;
          break;
        }
      }
      if(ok) {
        res = max(res, i2-i1);
      }
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 504
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
using namespace std;

typedef int64_t ll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define vll vector<ll>
#define all(v) v.begin(), v.end()



int main() {
	ll N, K;
	cin >> N >> K;
	vector<ll> f(N + 10);
	priority_queue<pair<ll, ll>> q;
	priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>> q2;
	rep(i, N) {
		ll t, d; cin >> t >> d;
		q.push(pair<ll, ll>(d, t));
	}

	ll x = 0, s = 0, ans = 0;
	rep(i, K) {
		pair<ll, ll> p = q.top(); q.pop();
		q2.push(p);
		s += p.first;
		if (f[p.second] == 0) ++x;
		++f[p.second];
	}
	ans = s + x * x;
	while (!q.empty()) {
		pair<ll, ll> p = q.top(); q.pop();
		if (f[p.second]) continue;
		ll m = -1;
		while (!q2.empty()) {
			pair<ll, ll> p2 = q2.top(); q2.pop();
			if (f[p2.second] > 1) {
				f[p2.second]--;
				m = p2.first;
				break;
			}
		}
		if (m == -1) break;
		x++;
		f[p.second]++;
		s += p.first;
		s -= m;
		ans = max(ans, s + x*x);
	}
	cout << ans << endl;
}

Measured memory_bytes: 5616
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <stack>
#include <functional>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <numeric>

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define rrep()
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vi vector<int>
#define INF (int)1e9
#define INFL 1e18
#define MOD 1000000007
#define pb push_back
#define MP make_pair
typedef long long int ll;
typedef std::pair<int,int> P;
int D=1;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

using namespace std;

int main(){
    int n,m,x;
    cin>>n>>m>>x;
    vector<int> v(n+1,0);
    rep(i,0,m){
        int x; cin>>x;
        v[x-1]=1;
        
    }
    
    int ans1=0,ans2=0;
    for(int i=x-1;i>=0;i--){
        ans1+=v[i];
    }
    
    rep(i,x-1,n+1){
        ans2+=v[i];
    }
    
    cout<<min(ans1,ans2)<<endl;
    return 0;
}


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

int main(void) {
	int N, T, c, t;
	int  min = 9999;
	scanf("%d %d", &N, &T);

	for (int i = 0; i < N; ++i) {
		scanf("%d %d", &c, &t);
		if (t <= T) {
			min = fmin(min, c);
		}
	}

	if (min == 9999) {
		printf("TLE");
	}
	else
	{
		printf("%d", min);
	}

	return 0;
}

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

vector<int> v, t;
int main() {
	int n;
	cin>>n;
	int i, j;
	for(i=1;i<=n;i++)  {
		int x;
		cin>>x;
		v.push_back(x);
	}
	t = v;
	sort(v.begin(), v.end());
	string ans = "NO\n";
	for(i=0;i<n;i++) {
		for(j=i;j<n;j++) {
			swap(t[i], t[j]);
			if(t==v){
				ans = "YES\n";
				break;
			}
			swap(t[i], t[j]);
		}
		if(ans=="YES\n") break;
	}
	cout<<ans;
}

Measured memory_bytes: 256
/* Bismillahirrahmanirrahim */
/* Author : Jehian Norman Saviero (@Reiva5) */
#include <bits/stdc++.h>

// MACROS SAMPAH
#define Jehian using
#define Norman namespace
#define Saviero std

Jehian Norman Saviero;

// MACROS TYPE
typedef long l;
typedef long long ll;
typedef unsigned long ul;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<l,l> pl;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<l> vl;
typedef vector<ll> vll;

// MACROS FOR PRINT
#define nl printf("\n")
#define sp printf(" ")

// MACROS FOR ATTRIBUTE
#define fi first
#define se second

// MACROS FOR FUNCTION AND METHOD
#define eb emplace_back
#define mp make_pair
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define ALL(x) (x).begin(), (x).end()
#define ALLN(x,n) (x), (x)+(n)
#define CUBE(x) (SQR(x)*(x))
#define SET(x,y) for (int _qwe = sizeof(x)/sizeof(x[0]); _qwe; ) x[--_qwe] = (y)
#define SQR(x) ((x)*(x))
#define SSORT(x,sz) sort(ALLN(x,sz))
#define RESET(x) memset((x), 0, sizeof(x))
#define VSORT(x) sort(ALL(x))

// MACROS READ INPUT
#define sci(x) scanf("%d", &x)
#define scl(x) scanf("%ld", &x)
#define scll(x) scanf("%lld", &x)
#define scul(x) scl(x)
#define scull(x) scll(x)

int main() {
	map<ll,ll> dp;
	int N, M;
	sci(N), sci(M);
	int arr[N];
	SET(arr, 1);
	for (int i = 0; i < M; ++i) {
		int tmp;
		sci(tmp);
		arr[tmp] = 0;
	}
	dp[0] = 1;
	const int MD = 1e9+7;
	for (int i = 1; i <= N; ++i) {
		if (arr[i-1]) dp[i] += dp[i-1];
		if (arr[i-2]) dp[i] += dp[i-2];
		dp[i] %= MD;
	}
	printf("%lld\n", dp[N]);
	return 0;
}

Measured memory_bytes: 6912
def swap(X,Y):
    Z=X
    X=Y
    Y=Z
    return X,Y
X=list(map(int,input().split()))
X[0],X[1]=swap(X[0],X[1])
X[0],X[2]=swap(X[0],X[2])
print(X[0],X[1],X[2])

Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.math.BigDecimal;

class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String[] strs = br.readLine().split(" ");
    BigDecimal T = new BigDecimal(strs[0]);
    BigDecimal X = new BigDecimal(strs[1]);
    System.out.println(T.divide(X, 4, BigDecimal.ROUND_UP));
  }
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define pb push_back
#define cmin(a,b) (a>b?a=b:a)
#define cmax(a,b) (a<b?a=b:a)
#define lop(i,s,t) for(int i=s;i<(t);++i)
#define rep(i,s,t) for(int i=s;i<=(t);++i)
#define dec(i,s,t) for(int i=s;i>=(t);--i)
#define fore(i,v) for(int i=g[v],d=es[i].d;i;i=es[i].nxt,d=es[i].d)
using namespace std;

#define Pr(f,...) printf(f,##__VA_ARGS__),fflush(stdout)

typedef long long ll;

const int N=233,P=2333;

int mul(int a,int b){ return 1ll*a*b%P; }
int add(int a,int b){ a+=b; return a>=P?a-P:a; }
int sub(int a,int b){ a-=b; return a<0?a+P:a; }

string s;
bool occ[26]; 

int main(int argc,char *argv[]){
#ifdef CURIOUSCAT
//	freopen("dat.in","r",stdin);
//	freopen("my.out","w",stdout);
#endif
	cin>>s;
	if(s.length()!=26){
		for(char c:s)occ[c-'a']=true;
		for(char c='a';c<='z';++c)if(occ[c-'a']==false){
			s+=c;
			break;
		}
		cout<<s<<endl;
	}else{
		string ss=s;
		if(next_permutation(ss.begin(),ss.end())==false){
			puts("-1");
		}else{
			string res;
			lop(i,0,26){
				if(ss[i]==s[i])res+=s[i];
				else {res+=ss[i];break;}
			}
			cout<<res<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

int main() {
    int n,m;
    cin >> n >> m;
    vector<int> vec(n); 
    REP(i,m){
        int a,b;
        cin >> a >> b;
        vec.at(a-1) += 1;
        vec.at(b-1) += 1;
    }
    REP(i,n){
        cout << vec.at(i) << endl;
    }
}

Measured memory_bytes: 3568
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;
typedef unsigned long long ull;


vector<ull> get_divisors(ull n) {
    vector<ull> ret;
    for (ull i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) {
                ret.push_back(n / i);
            }
        }
    }
    sort(ret.begin(), ret.end());
    return ret;
}

ull f(ull b, ull n) {
    if (n < b) {
        return n;
    }
    return f(b, n / b) + n % b;
}

int main(int argc, char const *argv[]) {
    ull n, s;
    cin >> n >> s;

    ull b = 0;
    if (n == s) {
        b = n + 1;
    } else if (n > s) {
        vector<ull> divisors = get_divisors(n-s);
        for (ull i = 0; i < divisors.size(); i++) {
            ull b_cand = divisors[i] + 1;
            if (f(b_cand, n) == s) {
                b = b_cand;
                break;
            }
        }
    }

    if (b > 0) {
        cout << b << endl;
    } else {
        cout << -1 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    int ans=0;
    vector<int> v;
    for(int i=0;i<n;i++)
    {
        if(a[i]==ans+1)
        {
            v.push_back(i);
            ans=ans+1;
        }
    }
    if(v.size()!=0)
    cout<<n-v.size()<<endl;
    else
        cout<<"-1"<<endl;
}


Measured memory_bytes: 2168
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <iomanip>

using namespace std;

#define fori(x) for (int i = 0; i < x; ++i)
#define forj(x) for (int j = 0; j < x; ++j)

int main() {
    int r;
	cin >> r;
    cout<<fixed<<setprecision(5)<<((float)r*2)*3.14159265;
	return 0;
}

Measured memory_bytes: 3808
/*  (: ///////|||||| BEGINS |||||||\\\\ :) */
/* REMEMBER
Deletes all characters except first one     Deletes 4 characters from index number 1
    str.erase(1);                               str.erase(1,4);
Deletes character at position 4
 str.erase(str.begin() + 4);
bool compare(const pair<int, int>&a, const pair<int, int>&b)
{
   return a.second<b.second;
}
maxn = max_element(mp.begin(), mp.end(), compare)->second;
bool sortbysec(const pair<int,int> &a, const pair<int,int> &b)
{
    return (a.second < b.second);
}
min(a,b,c,d)==min({a,b,c,d});
priority_queue <int, vector<int>, greater<int>> gquiz; // to create min heap
*/
#include<bits/stdc++.h>
using namespace std;
#define ll             long long int
#define endl           '\n'
#define mod            1000000007
#define fo(i,n)        for(int i=1;i<=n;i++)
#define tol(s)         transform(s.begin(),s.end(),s.begin(),::tolower)
#define tou(s)         transform(s.begin(),s.end(),s.begin(),::toupper)
#define all(x)         (x).begin(), (x).end()
#define pb             push_back
#define lb             lower_bound
#define ub             upper_bound
#define tr(it, a)      for(auto it = a.begin();it!=a.end();it++)
#define gcd(a,b)       __gcd(a,b)
#define pq             priority_queue
#define fr             first
#define sc             second
#define sz(x)          x.size()
 
const int inf=0x3f3f3f3f;
bool ispalindrome(string s) 
{ 
    ll len=s.length(); 
    for(ll i=0;i<len;i++){ 
        if(s[i]!=s[len-i-1]) 
        return false; 
    } 
    return true; 
} 
long long binpow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
long long isprime(long long n)
{
    for(long long i=2;i<=sqrt(n);i++)
    {
        if(n%i==0)return 0;
    }
    return 1;
}
bool compare(const pair<int, int>&a, const pair<int, int>&b)
{
   return a.second<b.second;
}
int main()
{
ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
 

double l;
cin>>l;
double ans=(l/3)*(l/3)*(l/3);
cout<<fixed<<setprecision(12)<<ans<<endl;

return 0;
}

Measured memory_bytes: 3868
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;

typedef long long  LL;
const int N=200010,mo=924844033,g=5;
struct edge{int s,t,n;}e[2*N];
int n,h[N],a[N],siz[N],fac[N],ifac[N],A[1<<19],B[1<<19],W[1<<19];

int qpow(int a,int b)
{
	int x=a;  a=1;
	while (b)
		{
			if (b&1)  a=1LL*a*x%mo;
			x=1LL*x*x%mo,b>>=1;
		}
	return a;
}

void NTT(int *a,int n,int op)
{
	for (int i=1,j,p,t; i<n; i++)
		{
			for (j=0,p=i,t=1; t<n; j<<=1,j|=p&1,p>>=1,t<<=1);
			if (i<j)  swap(a[i],a[j]);
		}
	int *w=(op>0?W:W+n/2),u,v;
	for (int len=2; len<=n; len<<=1)
		for (int i=0; i<n; i+=len)
			for (int j=0; j<(len>>1); j++)
				{
					u=a[i+j],v=1LL*a[i+j+(len>>1)]*w[n/len*j]%mo;
					a[i+j]=(u+v)%mo,a[i+j+(len>>1)]=(u+mo-v)%mo;
				}
	if (op==-1)
		{
			int inv=qpow(n,mo-2);
			for (int i=0; i<n; i++)  a[i]=1LL*a[i]*inv%mo;
		}
}

void FFT()
{
	int N=1;
	while (N<=2*n)  N<<=1;
	W[0]=1,W[1]=qpow(g,(mo-1)/N);
	for (int i=2; i<N; i++)  W[i]=1LL*W[i-1]*W[1]%mo;
	reverse(W+N/2+1,W+N),W[N/2]=1;
	NTT(A,N,1),NTT(B,N,1);
	for (int i=0; i<N; i++)  A[i]=1LL*A[i]*B[i]%mo;
	NTT(A,N,-1);
}

void dfs(int x)
{
	siz[x]=1;
	for (int i=h[x]; i; i=e[i].n)
		if (!siz[e[i].t])  dfs(e[i].t),siz[x]+=siz[e[i].t];
	if (siz[x]!=n)  a[siz[x]]--,a[n-siz[x]]--;
}

void work()
{
	scanf("%d",&n);
	for (int i=1,u,v,tot=0; i<n; i++)
		{
			scanf("%d %d",&u,&v);
			e[++tot]=(edge){u,v,h[u]},h[u]=tot;
			e[++tot]=(edge){v,u,h[v]},h[v]=tot;
		}
	dfs(rand()%n+1),a[n]=n,fac[0]=1;
	for (int i=1; i<=n; i++)  fac[i]=1LL*fac[i-1]*i%mo;
	ifac[n]=qpow(fac[n],mo-2);
	for (int i=n; i; i--)  ifac[i-1]=1LL*ifac[i]*i%mo;
	for (int i=1; i<=n; i++)  A[i]=1LL*(a[i]+mo)*fac[i]%mo;
	for (int i=1; i<=n; i++)  B[i]=ifac[n-i];
	FFT();
	for (int i=1; i<=n; i++)
		printf("%d\n",int(1LL*A[n+i]*ifac[i]%mo));
}

int main()
{
	work();
	return 0;
}


Measured memory_bytes: 21888
from itertools import permutations
N, M, R = map(int, input().split())
r = list(map(int, input().split()))
G = [[10**18]*(N+1) for _ in range(N+1)]
for _ in range(M):
    a, b, c = map(int, input().split())
    G[a][b] = c
    G[b][a] = c

for k in range(1, N+1):
    for i in range(1, N+1):
        for j in range(1, N+1):
            if G[i][k]+G[k][j] < G[i][j]:
                G[i][j] = G[i][k] + G[k][j]


ans = 10**18
for elem in permutations(r):
    res = 0
    for i in range(R-1):
        res += G[elem[i]][elem[i+1]]
    ans = min(ans, res)
print(ans)


Measured memory_bytes: 48120
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        // 数の準備
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);

        int[] numbers = new int[3];

        for (int i = 0; i < numbers.length; i++) {
            numbers[i] = sc.nextInt();
        }

        // 魔法の回数
        int magicNumber = sc.nextInt();

        while (magicNumber > 0) {
            if (numbers[0] >= numbers[1]) {
                numbers[1] *= 2;
            } else if (numbers[1] >= numbers[2]) {
                numbers[2] *= 2;
            }
            magicNumber--;
        }

        if (numbers[0] < numbers[1] && numbers[1] < numbers[2]) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

    }
}


Measured memory_bytes: 35676
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<queue>
#include<stdio.h>

using namespace std;


int a,b,ans;
int main()
{
    cin>>a>>b;
    if((a+b)>16){cout<<":(";return 0;}
    else if(a>b && a<=8){cout<<"Yay!";return 0;}
    else if(a==b && a<=8){cout<<"Yay!";return 0;}
    else if(a<b && b<=8){cout<<"Yay!";return 0;}
    else {cout<<":(";return 0;}
    //system("pause");
    return 0;
}  
   

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>

using namespace std;
int main()
{
    int w[10],k[10];
    for(int i=0;i<10;i++){
        cin >> w[i];
    }
    
    for(int i=0;i<10;i++){
        cin >> k[i];
    }
    
    sort(w,w+10);
    sort(k,k+10);
    int cnt=0;
    int cnt2=0;
    for(int i=7;i<10;i++){
        cnt+=w[i];
        cnt2+=k[i];
    }
    
    cout << cnt << " " << cnt2 << endl;
    return 0;
}


Measured memory_bytes: 3160
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
k=int(input())
if e-d<=k and e-c<=k and e-b<=k and e-a<=k and d-c<=k and d-b<=k and d-a<=k and c-b<=k and c-a<=k and b-a<=k:
  print('Yay!')
else:
  print(':(')


Measured memory_bytes: 3060
h,w,k = map(int,input().split())
lay = ['']*h
ans = 0
for i in range(h):
    lay[i] = input()
for i in range(2**h):
    for j in range(2**w):
        #行と列を選択した
        kuro = 0
        for i2 in range(h):
            if (i>>i2) & 1:
                for j2 in range(w):
                    if (j>>j2) & 1:
                        if lay[i2][j2] == '#':
                            kuro += 1
        if kuro == k:
            ans += 1
print(ans)

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

int main()
{
    int d[500000];
    int alphabet_max = 26;
    long long N;
    const long long MOD = 1000000007;
    cin >> N;
    string S;
    cin >> S;
    long long kosuu[26];
    for (int i = 0; i < alphabet_max; i++)
    {
        kosuu[i] = 0;
        for (int j = 0; j < N; j++)
        {
            if (S.at(j) == 'a' + i)
            {
                kosuu[i]++;
            }
        }
        kosuu[i]++;
    }
    long long ans = 1;
    for (int i = 0; i < alphabet_max; i++)
    {
        ans *= kosuu[i];
        ans %= MOD;
    }
    if (ans == 0)
    {
        cout << MOD - 1 << endl;
        return 0;
    }
    cout << ans - 1 << endl;
}

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

using namespace std;

const int maxn = 2e3 + 5;
int preC[maxn][maxn], preR[maxn][maxn];


int main()
{
    int h, w;
    cin >> h >> w;
    vector<string> a(h);
    for (int i = 0; i < h; i++){
        cin >> a[i];
    }
    for (int i = 0; i < h; i++){
        for (int j = 0; j < w; j++){
            if (a[i][j] != '#')
                preR[i][j + 1] = preR[i][j] + 1;
        }
    }
    for (int i = 0; i < w; i++){
        for (int j = 0; j < h; j++){
            if (a[j][i] != '#'){
                preC[j + 1][i] = preC[j][i] + 1;
            }
        }
    }
    for (int i = 0; i < h; i++){
        for (int j = w; j > 1; j--){
            if (preR[i][j] != 0){
                if (a[i][j - 2] != '#')
                    preR[i][j - 1] = preR[i][j];
            }
        }
    }
    for (int i = 0; i < w; i++){
        for (int j = h; j > 1; j--){
            if (preC[j][i] != 0){
                if (a[j - 2][i] != '#'){
                    preC[j - 1][i] = preC[j][i];
                }
            }
        }
    }
    int ans = 0;
    for (int i = 0; i < h; i++){
        for (int j = 0; j < w; j++ ){
            ans = max(ans, preR[i][j + 1] + preC[i + 1][j] - 1);
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 35712
#include<stdio.h>

int main()
{
    int count[2];
    for(count[0]=1;count[0]<10;count[0]++)
    {
        for(count[1]=1;count[1]<10;count[1]++)
        {
            printf("%dx%d=%d\n",count[0],count[1],count[0] * count[1]);
        }
    }
    return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
using namespace std;
#define maxx 3010
#define mp make_pair
typedef pair<int,int> ii;
ii rt[maxx][maxx];
int dp[maxx][maxx];
int m,n;
string s,t,ans = "";
void bfs(int i,int j){
	queue <ii> q;
	q.push(mp(i,j));
	while(!q.empty()){
		ii k = q.front();
		q.pop();
		int y = k.first;
		int x = k.second;
		if(dp[y][x] == 0) break;
		
		if(rt[y][x].first == y-1 && rt[y][x].second == x-1)  ans += s[y-1];
		
		q.push(mp(rt[y][x].first,rt[y][x].second));
	}
}

int main() {
	cin >> s;
	cin >> t;
	if(s.size() > t.size()) swap(s,t);
	
	for(int i = 1; i <= (int)s.size(); i++){
		for(int j = 1; j <= (int)t.size(); j++){
			if(s[i-1] == t[j-1]){
				if(dp[i-1][j-1] + 1 >= dp[i-1][j]){
					dp[i][j] = dp[i-1][j-1]+1;
					rt[i][j] = mp(i-1,j-1);
				}
				else{
					dp[i][j] = dp[i-1][j];
					rt[i][j] = mp(i-1,j);
				}
			}
			else{
				if(dp[i][j-1] > dp[i-1][j]){
					dp[i][j] = dp[i][j-1];
					rt[i][j] = mp(i,j-1);
				}
				else{
					dp[i][j]  = dp[i-1][j];
					rt[i][j] = mp(i-1,j);
				}
			}
		}
	}

	bfs(s.size(),t.size());
/*	
	for(int i = 1; i <= s.size(); i++){
		for(int j = 1; j <= t.size(); j++){
			cout << dp[i][j] << " ";
		}
		cout << s[i-1]; 
		cout << endl;
	}
	for(int i = 1; i <= s.size(); i++){
		for(int j = 1; j <= t.size(); j++){
			cout << rt[i][j].first << "," << rt[i][j].second << " ";
		}
		cout << s[i-1]; 
		cout << endl;
	}
*/
	
	for(int i = (int)ans.size()-1; i >= 0; i--){
		cout << ans[i];
	}
	cout << "\n";
  	
	return 0;
}

Measured memory_bytes: 109444
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <functional>
#include <map>
#include <numeric>
#include <random>
#include <vector>
#include <bitset>
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using namespace std;

#define INF 100000000


int main() {
	int n, k;
	vector<int> a;
	while (cin >> n >> k) {
		a.resize(n);
		rep(i, n) cin >> a[i];
		int ans = 0;
		int right = 0;
		while (true) {
			if (ans == 0) right += k;
			else right += k - 1;
			ans++;

			if (right >= n) break;
		}
		cout << ans << endl;
	}
	
	
 	return 0;
}

Measured memory_bytes: 640
//
//  main.cpp
//  atcoder94
//
//  Created by cfhaiteeh on 2018/4/14.
//  Copyright © 2018 cfhaiteeh. All rights reserved.
//

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#define LL long long
using namespace std;
int a,b,x;
int main() {
    // insert code here...
    while(scanf("%d%d%d",&a,&b,&x)!=EOF){
        if(a<=x&&a+b>=x){
            printf("YES\n");
        }
        else{
            printf("NO\n");
        }
    }
    return 0;
}


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

using namespace std;


#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()

#define int long long

#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second

template <typename T>
void print(T x)
{
	std::cout << x <<" " ;
}


template <typename T>
void println(T x)
{
	std::cout << x << "\n";
}

int N;
using pairs = pair<int, int>;
vector<vector<pairs>> a;

bool judge(int bit) {//整数bitに対応する「決め打ち」が整合しているかを判定
	rep(i, N) {//i人目の証言を検証
		if (!(bit&(1 << i)))continue;
		for (pairs xy : a[i]) {
			int x = xy.first;
			int y = xy.second;
			if (y == 1 && !(bit&(1 << x)))return false;
			if (y == 0 &&  (bit&(1 << x)))return false;
		}

	}return true;
}

signed main(void) {
	cin >> N;
	a.resize(N);
	rep(i, N) {
		int A;
		cin >> A;
		a[i].resize(A);
		rep(j, A) {
			cin >> a[i][j].first >> a[i][j].second;
			--a[i][j].first;
		}
	}
	int ans = 0;
	for (int bit = 0; bit<(1 << N); bit++) {
		if (judge(bit)) {
			int count = 0;
			rep(i, N) {
				if (bit & (1 << i)) count++;
			}
			ans = max(ans, count);
		}
	}print(ans);
}

Measured memory_bytes: 256
n=int(input())
sp=[list(map(str,input().split())) for _ in range(n)]
for i in range(n):
    sp[i].append(i+1)
    sp[i][1]=int(sp[i][1])
sp=sorted(sp, key=lambda x:(x[0], -x[1]))

for i in range(n):
    print(sp[i][2])


Measured memory_bytes: 38384
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int n;
  cin >> n;
  int a[100];
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  sort(a,a+n);
  int sum=0;
  int before=0;
  for(int i=0;i<n;i++){
    if(before != a[i]){
      sum++;
      before = a[i];
    }
  }
  cout << sum;
}


Measured memory_bytes: 256
#include <algorithm>  // sort, 二分探索(lower_bound)など
#include <cmath>      // pow, logなど
#include <complex>    // 複素数
#include <deque>      // 両端アクセスのキュー
#include <iostream>   // 入出力
#include <iterator>
#include <map>
#include <numeric>  // iota(整数列の生成), gcd, lcm
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>  // 順序保持しないmap
#include <unordered_set>  // 順序保持しないset
#include <utility>        // pair
#include <vector>

#define REP(i, a, b) for (int i = (a); i < (b); i++)
#define REPR(i, a, b) for (int i = (a); i >= (b); i--)
#define ALL(container) (container).begin(), (container).end()
#define MAX(x) *max_element(ALL(x))  // 最大値を求める
#define MIN(x) *min_element(ALL(x))  // 最小値を求める

using namespace std;
typedef long long ll;

constexpr int INF = 1e9;
constexpr int MOD = 1000000007;

int main() {
  size_t N, M, X;
  cin >> N >> M >> X;
  vector<size_t> C(N);
  vector<vector<size_t>> A(N, vector<size_t>(M));
  int min_price = INF, tmp_price;
  vector<size_t> tmp_a(M);

  for (size_t i = 0; i < N; ++i) {
    cin >> C[i];
    for (size_t j = 0; j < M; ++j) {
      cin >> A[i][j];
    }
  }

  for (size_t i = 0; i < pow(2, N); ++i) {
    for (size_t j = 0; j < N; ++j) {
      if (i & (1 << j)) {
        tmp_price += C[N - (j + 1)];
        for (size_t k = 0; k < M; ++k) {
          tmp_a[k] += A[N - (j + 1)][k];
        }
      }
    }
    if (all_of(ALL(tmp_a), [&X](size_t x) { return x >= X; }) && tmp_price < min_price) {
      min_price = tmp_price;
    }
    tmp_price = 0;
    for (size_t j = 0; j < M; ++j) {
      tmp_a[j] = 0;
    }
  }
  if (min_price == INF) {
    min_price = -1;
  }

  cout << min_price << endl;

  return 0;
}


Measured memory_bytes: 4108
import java.util.Scanner;

public class Main {
	public static void main (String args[]) {
		Scanner scan = new Scanner(System.in);
		Long n = scan.nextLong();
		long ans = 0;
		for(int i = 1; i < n + 1; i++) {
			if(!(i % 3 == 0 || i % 5 == 0)) {
				ans = ans + i;
			}
		}
		System.out.println(ans);
	}
}

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

#define ll long long
#define ull unsigned long long

using namespace std;

int main() {
    int x, y, z;
    cin >> x >> y >> z;
    cout << z << " " << x << " " << y;
    return 0;
}


Measured memory_bytes: 256