akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
#define rep(...) overload_rep(__VA_ARGS__, rep_1, rep_0) (__VA_ARGS__)
#define rep_0(i, end) for (int i = 0; i < (end); ++i)
#define rep_1(i, fr, ba) for (int i = (fr); i <= (ba); ++i)
#define overload_rep(arg_0, arg_1, arg_2, name, ...) name
#define all(box) box.begin(), box.end()
 
template <class T, class U> inline bool chmax(T& lhs, const U& rhs) { if (lhs < rhs) { lhs = rhs; return 1; } return 0; }
template <class T, class U> inline bool chmin(T& lhs, const U& rhs) { if (lhs > rhs) { lhs = rhs; return 1; } return 0; }

constexpr int inf = (1 << 30) - 1;

int N;
int A[18], B[18];
int dp[2][50][1 << 18];
// dp[][i][j]: i: 最後においたカードの数字 j: 今までに並べたカードの集合

int main() {

  std::cin >> N;
  rep (i, N) {
    std::cin >> A[i];
    --A[i];
  }
  rep (i, N) {
    std::cin >> B[i];
    --B[i];
  }

  rep (i, 2) {
    rep (j, 50) {
      rep (k, 1 << N) {
        dp[i][j][k] = inf;
      }
    }
  }

  dp[0][0][0] = 0;
  int i = 0, ni = 1;
  rep (step, N) {
    rep (S, 1 << N) {
      if (__builtin_popcount(S) != step) {
        continue;
      }
      rep (last, 50) {
        int cnt = 0;
        rep (l, N) {
          if ((1 << l) & S) {
            ++cnt;
            continue;
          }
          int num = std::abs(l - step) % 2 == 0 ? A[l] : B[l];
          if (num < last) {
            continue;
          }
          chmin(dp[ni][num][S | (1 << l)], dp[i][last][S] + l - cnt);
        }
        dp[i][last][S] = inf;
      }
    }
    std::swap(i, ni);
  }

  int ans = inf;
  rep (k, 50) {
    rep (j, 1 << N) {
      chmin(ans, dp[i][k][j]);
    }
  }
  std::cout << (ans == inf ? -1 : ans) << '\n';

}


Measured memory_bytes: 102784
#include <iostream>
using namespace std;
int main(int argc, char const *argv[]) {
  int d;
  cin>>d;
  if(d==25){
    cout<<"Christmas"<<endl;
  }else if(d==24){
    cout<<"Christmas Eve"<<endl;
  }else if(d==23){
    cout<<"Christmas Eve Eve"<<endl;
  }else{
    cout<<"Christmas Eve Eve Eve"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int X[N];
int main() {
	int n, A, B;
	long long ans = 0;
	scanf("%d%d%d", &n, &A, &B);
	for (int i = 1; i <= n; ++ i) scanf("%d", &X[i]);
	for (int i = 2; i <= n; ++ i) ans += min(1LL * (X[i] - X[i - 1]) * A, 1LL * B);
	cout << ans << endl;
}



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

int main()
{
    //string s;
    //cin >> s;
    int K;
    cin >> K;
    int64_t ans;
    if(K < 10) ans = K;

    queue<int64_t> Q;

    rep2(i,1,10) Q.push(i);
    
    int count = 9;
    rep(i,K - 9){
        int64_t v = Q.front(); Q.pop();
        if(v%10 != 0){
            ans = v * 10 + v%10 - 1;
            Q.push(ans);
            count ++;
            if(count == K) break;
        }
        ans = v * 10 + v%10;
        Q.push(ans);
        count ++;
        if(count == K) break;
        if(v%10 != 9){
            ans = v * 10 + v%10 + 1;
            Q.push(ans);
            count ++;
            if(count == K) break;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 768
#include <stdio.h>
int main(){

  int e,a,n,m,result;

  while(1){

    result=0;
    scanf("%d",&e);
    e *= 2;
    if(e == 0) break;

    for(n = 2; n < 50; n++){

      a=e-n*n;

      if(a > 0 && a%n == 0 && a/n%2 == 1) result++;

    }

    printf("%d\n",result);

  }

  return 0;

}

Measured memory_bytes: 596
#include <cstdint>
#include <iostream>
#include <unordered_map>

using namespace std;

int main()
{
    int64_t n, mod;
    cin >> n >> mod;

    unordered_map<int64_t, int64_t> count;
    int64_t total = 0;
    int64_t sum = 0;

    for (int64_t i = 0; i < n; i += 1) {
        int64_t num;
        cin >> num;

        sum += num;
        sum %= mod;

        if (sum == 0) {
            total += 1;
        }
        total += count[sum];
        count[sum] += 1;
    }

    cout << total << "\n";
    return 0;
}


Measured memory_bytes: 3596
from heapq import*
def m():
 n=int(input())
 A=[]
 for _ in[0]*n:
  e=list(map(int,input().split()))
  A+=[zip(e[2::2],e[3::2])]
 d=[0]+[float("inf")]*n
 H=[(0,0)]
 while H:
  u=heappop(H)[1]
  for v,c in A[u]:
   t=d[u]+c
   if d[v]>t:
    d[v]=t
    heappush(H,(t,v))
 print('\n'.join(f'{i} {d[i]}'for i in range(n)))
m()


Measured memory_bytes: 40084
N,M,X=map(int,input().strip().split(" "))
A=input().strip().split(" ")
A=[int(i) for i in A]

countmax=0
count0=0

for i in range(M):
    if(A[i]<X):
        count0+=1
    elif(A[i]>X):
        countmax+=1
    else:
        count0+=1
        countmax+=1

if(count0>countmax):
    print(countmax)
else:
    print(count0)




Measured memory_bytes: 3060
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    S=input()
    ans=0
    b=0
    for s in S:
        if s=="B": b+=1
        else: ans+=b
    print(ans)
resolve()

Measured memory_bytes: 40048
#include <bits/stdc++.h>
#define pb push_back
#define fs first
#define sc second
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

const int N=350;
const int INFTY=1e9;
int a[N][N], out[N], cnt[N];

int main() {
    int n, m, i, j, t, cm, cmax, ans=INFTY;
    scanf("%d%d", &n, &m);
    for(i=1; i<=n; i++) for(j=1; j<=m; j++) {
        scanf("%d", &t);
        a[i][t]=j;
    }
    for(cm=m; cm;) {
        cmax=0;
        for(i=1; i<=m; i++) cnt[i]=0;
        for(i=1; i<=n; i++) {
            t=0;
            for(j=1; j<=m; j++) if(!out[j])
                if(!t || a[i][j]<a[i][t]) t=j;
            cnt[t]++;
            cmax=max(cmax, cnt[t]);
        }
        ans=min(ans, cmax);
        for(i=1; i<=m; i++) if(!out[i])
            if(cnt[i]==cmax) out[i]=1, cm--;
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 640
#![allow(unused)]

use std::{cmp, collections, fmt, io, iter, ops, str};
use cmp::Ordering::{Equal, Greater, Less};
use collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, LinkedList, VecDeque};
use io::{Read, Write};

#[cfg(feature = "debug")]
macro_rules! debug {
    ($fmt: expr) => { eprintln!($fmt) };
    ($fmt: expr, $($arg: tt)*) => { eprintln!($fmt, $($arg)*) };
}

#[cfg(not(feature = "debug"))]
macro_rules! debug {
    ($fmt: expr) => {};
    ($fmt: expr, $($arg: tt)*) => {};
}

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().to_owned()
}

fn read_word() -> String {
    const CAPACITY: usize = 16;

    let mut stdin = io::stdin();
    let mut byte: [u8; 1] = [0];

    loop {
        let mut buf = Vec::with_capacity(CAPACITY);

        loop {
            let res = stdin.read(&mut byte);

            if res.unwrap_or(0) == 0 || byte[0] <= b' ' {
                break;
            } else {
                buf.push(byte[0]);
            }
        }

        if buf.len() > 0 {
            return String::from_utf8(buf).unwrap();
        }
    }
}

fn parse_line<T: str::FromStr>() -> T {
    read_line().parse().ok().unwrap()
}

fn parse_word<T: str::FromStr>() -> T {
    read_word().parse().ok().unwrap()
}

fn parse_vec<T: str::FromStr>() -> Vec<T> {
    read_line()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn flush() {
    io::stdout().flush();
}

fn main() {
    let a_price = parse_word::<i32>();
    let b_price = parse_word::<i32>();
    let ab_price = parse_word::<i32>();

    let calc_price = |a, b, ab| a as i32 * a_price + b as i32 * b_price + ab as i32 * ab_price;

    let a_num = parse_word::<usize>();
    let b_num = parse_word::<usize>();

    let mut a_buy = a_num;
    let mut b_buy = b_num;
    let mut ab_buy = 0;
    let mut price = calc_price(a_buy, b_buy, ab_buy);

    loop {
        debug!(
            "a: {}, b: {}, ab: {}, price: {}",
            a_buy,
            b_buy,
            ab_buy,
            calc_price(a_buy, b_buy, ab_buy)
        );

        if a_buy == 0 && b_buy == 0 {
            break;
        }

        let new_a_buy = a_buy - if a_buy > 0 { 1 } else { 0 };
        let new_b_buy = b_buy - if b_buy > 0 { 1 } else { 0 };
        let new_ab_buy = ab_buy + 2;

        let new_price = calc_price(new_a_buy, new_b_buy, new_ab_buy);
        if new_price >= price {
            break;
        }

        a_buy = new_a_buy;
        b_buy = new_b_buy;
        ab_buy = new_ab_buy;
        price = new_price;
    }

    println!("{}", calc_price(a_buy, b_buy, ab_buy));
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test() {
        //
    }
}


Measured memory_bytes: 4352
#include <stdio.h>
int main(int argc, char *argv[])
{
	int t;
	scanf("%d",&t);
	int a[1000];
	int count=0;
	for(int i=1;i<=t;i++){
		scanf("%d",&a[i]);
		if(i%2==1&&a[i]%2==1) count++;
	}
	printf("%d",count);
	return 0;
}

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

int main() {
    int n, a = 1000000, cnt = 1;
    cin >> n;
    vector<int> p(n);
    rep(i,n) cin >> p[i];

    for (int i = 1; i < n; i++) {
        a = min(a, p[i-1]);
        if (p[i] <= a) cnt++;
    }
    
    cout << cnt << endl;
    
    return 0;
}

Measured memory_bytes: 3968
#include <bits/stdc++.h>
#define r(i,n) for(int i = 0; i<n; i++)
typedef long long ll;
using namespace std;

int main(){
  int a[9];
  r(i,9)cin >> a[i];
  if(a[1]-a[0]==a[4]-a[3]&&a[4]-a[3]==a[7]-a[6]&&a[2]-a[1]==a[5]-a[4]&&a[5]-a[4]==a[8]-a[7]&&a[3]-a[0]==a[4]-a[1]&&a[4]-a[1]==a[5]-a[2]&&a[6]-a[3]==a[7]-a[4]&&a[7]-a[4]==a[8]-a[5])cout << "Yes"<<endl;
  else cout << "No"<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<complex>
#include<algorithm>
#define EPS 1e-10
using namespace std;

typedef complex<double> P;

int n,m;
P p[100][4];

double cross(P a,P b){return imag(conj(a)*b);}
double dot(P a,P b){return real(conj(a)*b);}

int ccw(P a,P b,P c){
  b -= a;c -= a;
  if (cross(b,c)>EPS) return 1;
  if (cross(b,c)<-EPS) return -1;
  if (dot(b, c)<-EPS) return 2;
  if (abs(b)<abs(c)) return -2;
  return 0;
}

bool is_cp(P a1, P a2, P b1, P b2){
  return (ccw(a1,a2,b1)*ccw(a1,a2,b2) <= 0 && ccw(b1,b2,a1)*ccw(b1,b2,a2) <= 0);
}

bool interp(int q, P x){
  for(int i=0;i<4;i++)
    if(ccw(p[q][i],p[q][(i+1)%4],x) == 1)return false;
  return true;
}

bool inter(int q1,int q2){
  for(int i=0;i<3;i++)
    for(int j=0;j<3;j++)
      if(is_cp(p[q1][i],p[q1][(i+1)%4],p[q2][j],p[q2][(j+1)%4]))return true;
  for(int i=0;i<4;i++)if(interp(q1,p[q2][i]))return true;
  for(int i=0;i<4;i++)if(interp(q2,p[q1][i]))return true;
  return false;
}

int par[100];
int rank[100];

void init(int n){
  for(int i=0;i<n;i++){
    par[i] = i;
    rank[i] = 0;
  }
}

int find(int x){
  if(par[x] == x)return x;
  return par[x] = find(par[x]);
}

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x==y)return;

  if(rank[x] < rank[y])par[x] = y;
  else{
    par[y] = x;
    if(rank[x] == rank[y])rank[x]++;
  }
}

int main(){
  while(cin >> n && n){
    for(int i=0;i<n;i++){
      cin >> m;
      for(int j=0;j<m;j++)
	for(int k=0;k<4;k++)cin >> p[j][k].real() >> p[j][k].imag();

      init(m);

      for(int j=0;j<m;j++)
	for(int k=0;k<j;k++)
	  if(find(j)!=find(k) && inter(j,k))unite(j,k);

      int ans = 0;
      for(int j=0;j<m;j++){
	find(j);
	if(par[j]==j)ans++;
      }
      cout << ans << endl;
    }
  }
}

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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int k = sc.nextInt();
		
		long [] pwr = new long[n];
		
		for (int i=0;i<n; i++) {
			pwr[i] = sc.nextLong();
		}
		Arrays.sort(pwr);

		// pwr の高い法からk回必殺攻撃
		int rest = n-k;
		long regAttacks = 0;
		for (int i=0; i<rest;i++) {
			regAttacks+=pwr[i];
		}
		
		log(regAttacks);
		sc.close();
	}

	static void log(String s) {
		System.out.println(s);
	}

	static void log(int i) {
		System.out.println(i);
	}

	static void log(long i) {
		System.out.println(i);
	}

	static void log(double d) {
		System.out.printf("%.12f\n",d);
	}
	
}


Measured memory_bytes: 65464
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

from collections import deque 
def main():
    s = deque(readline().rstrip().decode())
    q = int(readline())
    dir = 1
    for _ in range(q):
        txt = readline().rstrip().decode()
        if txt[0] == '1':
            dir ^= 1
        elif txt[0] == '2':
            f = txt[2]
            c = txt[4]
            if ((dir==1) and (f=='1')) or ((dir==0) and (f=='2')):
                s.appendleft(c)
            else:
                s.append(c)
    if dir!=1:
        print(''.join(reversed(s)))
    else:
        print(''.join(s))
if __name__ == '__main__':
    main()


Measured memory_bytes: 8628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    vector<int>a(n),b(n),c(n);
    for(auto& x:a)cin>>x;
    for(auto& x:b)cin>>x;
    int cur = 1;
    for(auto& x:c)x = cur++;
    int A,B;
    cur = 1;
    do{
        bool flag = true;
        for(int i=0;i<n;i++)if(a[i]!=c[i])flag = false;
        if(flag)A = cur;
        flag = true;
        for(int i=0;i<n;i++)if(b[i]!=c[i])flag = false;
        if(flag)B = cur;
        cur++;
    }while(next_permutation(c.begin(),c.end()));
    cout<<abs(A-B)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
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 gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
//最小公倍数
int lcm(int x, int y) { return x / gcd(x, y) * y; }
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    int A,B,C; cin >> A >> B >> C;
    int X; cin >> X;
    int out=0;
    for(int i=0;i<=A;i++){
        for(int j=0;j<=B;j++){
            for(int k=0;k<=C;k++){
                if(500*i+100*j+50*k==X) out++;
            }
        }
    }
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep( i, n ) for (int i = 0; i < ( long long )(n); i++)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair< int , int > P;
typedef tuple<int, int, int> T;
    
int main(){
    int n;
    cin>>n;
    map<string,int> s;

    rep(i,n){
        string t;
        cin>>t;
        s[t]++;
    }
    cout<<"AC"<<" "<<"x"<<" "<<s["AC"]<<endl;
    cout<<"WA"<<" "<<"x"<<" "<<s["WA"]<<endl;
    cout<<"TLE"<<" "<<"x"<<" "<<s["TLE"]<<endl;
    cout<<"RE"<<" "<<"x"<<" "<<s["RE"]<<endl;

}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <stdio.h>
#include <cmath>
#include <tgmath.h>

using namespace std;

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const ll inf = 1e18+7;
const ll mod = 1e9+7;


int main() {
    string s;
    cin>>s;

    rep(i,s.size()/2){
        if(s[i]!=s[s.size()-1-i]){
            cout<<"No"<<endl;
            return 0;
        }
    }

    rep(i,(s.size()-1)/4){
        if(s[i]!=s[(s.size()-1)/2-1-i]){
            cout<<"No"<<endl;
            return 0;
        }
    }

    rep2(i,(s.size()+3)/2-1,s.size()/2+s.size()/4){
        if(s[i]!=s[s.size()-1-i]){
            cout<<"No"<<endl;
            return 0;
        }
    }

    cout<<"Yes"<<endl;

}


Measured memory_bytes: 256
x, k, d = map(int, input().split())
x = abs(x)
ans = 0
if x >= k * d:
    ans = x - d * k
else:
    i = x // d
    j = k - i
    if (j % 2 == 0):
        ans = x - d * i
    else:
        ans = x - d * (i + 1)
print(abs(ans))

Measured memory_bytes: 9200
#include <iostream>

using namespace std;

int main() {
    int n;
    int hi = -1;
    int sum = 0;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int cost;
        cin >> cost;
        sum += cost;
        if (hi < 0 || hi < cost) {
            hi = cost;
        }
    }
    cout << sum - hi / 2 << endl;
    return 0;
}



Measured memory_bytes: 256
x,n = map(int,input().split())
P = list(map(int,input().split()))
A = []
a = 0
for i in range(200):
    if x+a in P:
        a += 1
    else:
        A.append(x+a)
        break
a = -1
for i in range(200):
    if x+a in P:
        a -= 1
    else:
        A.append(x+a)
        break

if abs(x-A[0]) < abs(x-A[1]):
    print(A[0])
    exit()
elif abs(x-A[0]) > abs(x-A[1]):
    print(A[1])
    exit()
else:
    print(min(A[0],A[1]))

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

typedef long long ll;

int main(){
    ll x, y;
    cin >> x >> y;
    
    ll cnt=0;
    while(1){
        if(abs(x)==abs(y)){
            if(x==y) break;
            else{
                cnt++;
                break;
            }
        }
        else if (((x<0&&y<0)&&abs(x)<abs(y)) || ((x>=0&&y<0)&&abs(x)>abs(y)) || ((x<0&&y>=0)&&abs(x)<abs(y)) || ((x>=0&&y>=0)&&abs(x)>abs(y))){
            x *= -1;
            cnt++;
        }
        else {
            //cout << abs(y)-abs(x) << endl;
            ll temp = abs(abs(y)-abs(x));
            x += temp;
            cnt += temp;
        }
        //cout << x <<" "<< cnt << endl;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
// Ver19.03
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF (1 << 29) * 2
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

ll a[100005], b[100005], c[100005];

int isOK_a(ll key, ll mid) { return a[mid] >= key ? 1 : 0; }
int isOK_c(ll key, ll mid) { return c[mid] <= key ? 1 : 0; }

ll binary_search(ll key, ll n, ll aORc) // a -> aORC=1, c -> aORC=0,
{
  ll ok = n, ng = -1;
  while (llabs(ok - ng) > 1)
  {
    ll mid = (ok + ng) / 2;
    if (aORc)
      isOK_a(key, mid) ? (ok = mid) : (ng = mid);
    else
      isOK_c(key, mid) ? (ok = mid) : (ng = mid);
  }
  return ok;
}

int main()
{
  ll n, ans = 0;
  scanf("%lld", &n);
  for (int i = 0; i < n; i++)
    scanf("%lld", a + i);
  for (int i = 0; i < n; i++)
    scanf("%lld", b + i);
  for (int i = 0; i < n; i++)
    scanf("%lld", c + i);
  sortup(a, n);
  sortup(b, n);
  sortdown(c, n);
  for (int i = 0; i < n; i++)
    ans += binary_search(b[i], n, 1) * binary_search(b[i], n, 0);
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 3324
using System;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string[] sh = Console.ReadLine().Split(' ');
            int[] dp = new int[N + 5];
            int[] h = new int[N]; 
            dp[0] = 0;
            
            for(int i=0;i<N;i++)
            {
                h[i] = int.Parse(sh[i]);                   
            }
            for (int i = 0; i < N; i++)
            {
                dp[i] = 2147483647;
            }
            dp[0] = 0;
            for (int i=1;i<N;i++)
            {
                dp[i] = Math.Min(dp[i], dp[i - 1] + Math.Abs(h[i] - h[i - 1]));
                if (i > 1)
                {
                    dp[i] = Math.Min(dp[i], dp[i - 2] + Math.Abs(h[i] - h[i - 2]));
                }

            }
            Console.WriteLine(dp[N-1]);
        }
    }
}


Measured memory_bytes: 35380
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
//typedef pair<int,int> P;
//typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef pair<ll, pair<int, int>> P;
typedef pair<ll,pair<ll,ll>> T;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2147483600;//10^9
int INFM =100000000;
ll MOD  = 1000000007;
int cost[3][35];
int main(){
    int N,C;
    cin >> N >> C;
    int D[C][C];
    for(int i = 0; i < C; i++){
        for(int j = 0; j < C; j++){
            cin >> D[i][j];
        }
    }
    int c[N][N];
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            cin >> c[i][j];
            c[i][j]--;
        }
    }
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < C; j++){
            for(int h = 0; h < N; h++){
                for(int w = 0; w < N; w++){
                    if((h + w) % 3 != i)continue;
                    cost[i][j] += D[c[h][w]][j];
                    
                }
            }
        }
    }
    int ans = INF;
    for(int i = 0; i < C; i++){
        for(int j = 0; j < C; j++){
            for(int k = 0; k < C; k++){
                if(i == j || j == k || k == i)continue;
                ans = min(ans, cost[0][i] + cost[1][j] + cost[2][k]);
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1280
import sys

sys.setrecursionlimit(1000000)

MOD = 1000000007

state = [-1 for i in range(100010)]

def step_state(n, broken):
    if state[n] != -1:
        return state[n]

    if n == 0:
        state[0]=1
        return 1
    elif n == 1:
        if broken[1]:
            state[1]=0
            return 0
        else:
            state[1]=1
            return 1
    else:
        if broken[n - 1] and broken[n - 2]:
            state[n]=0
            return 0
        elif broken[n - 1]:
            state[n]=step_state(n-2, broken) % MOD
            return state[n]
        elif broken[n-2]:
            state[n] = step_state(n-1, broken) % MOD
            return state[n]
        else:
            state[n] = (step_state(n-1, broken)+step_state(n-2, broken)) % MOD
            return state[n]


if __name__ == '__main__':
    n, m = map(int, input().split())
    a = set([int(input()) for i in range(m)])
    broken = [False] * (n+1)
    for i in range(n+1):
        if i in a:
            broken[i] = True

    answer = step_state(n, broken)

    print(answer)


Measured memory_bytes: 92300
//文字列
import java.util.Scanner;
public class Main{

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		String s = sc.next();

		int[] w = new int[26];

		boolean flag = false;

		for(int i=0;i<s.length();i++) {

			w[s.charAt(i)-97] ++;

		}

		for(int i=0;i<26;i++) {

			if(w[i]!=0 && w[i]%2!=0) {

				flag = true;

				break;
			}
		}

		if(flag) System.out.println("No");

		else System.out.println("Yes");
	}

}


Measured memory_bytes: 23252
#include<iostream>
#include<cstdio>
using namespace std;
int main(){

  int n;
  cin >> n;

  int min=999999999;
  int max=-999999999;
  long long int sum=0;

  for(int i=0;i<n;i++){
    int a;
    cin >> a;
    if(a<min) min=a;
    if(a>max) max=a;
    sum=sum+a;
  }
  cout << min << " " << max << " " << sum <<endl; 

  return 0;
}

Measured memory_bytes: 3036
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <queue>
#include <tuple>
#include <cstring>
#include <cctype>
#include <ctype.h>
#include <ios>
#include <iomanip>

#define INF 200000000
#define MOD 1000000007

using namespace std;

int main()
{
    string s;
    cin >> s;
    int n = s.length();
    int cnt = 0;
    for (int i = 0; i < n; i++)
    {
        cnt = 0;
        for (int j = 0; j < n; j++)
        {
            if (s[i] == s[j])
            {
                cnt++;
            }
        }
        if (cnt % 2 == 0)
        {
            continue;
        }
        else
        {
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes\n";

    return 0;
}


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

using namespace std;

#define f first
#define s second
#define pb push_back
#define FILL(a, b) memset(a, b, sizeof(a))

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<pii, pii> piii;
typedef vector<int> vi;
typedef vector<pii> vii;
const int INF = 0x3F3F3F3F;
const int MOD = 1e9 + 7;
const int MAX = 2e5 + 5;

string S;

int main() {
    
    cin.sync_with_stdio(0);
    cin.tie(0);
    
    cin >> S;
    
    bool good = 1;
    int cnt = 0, upper = 0, pos = 0;
    for (int i = 0; i < S.length(); i++) {
        if (S[i] == 'C') {
            cnt++;
            pos = i;
        }
        if (isupper(S[i])) {
            upper++;
        }
    }
    good &= cnt == 1 && pos >= 2 && pos <= S.length() - 2 && upper == 2 && S[0] == 'A';
    printf(good ? "AC\n" : "WA\n");
    
    return 0;
}


Measured memory_bytes: 256
package main

import (
        "fmt"
)

const MAX_N = 31
var lines [MAX_N]int

func main() {
        var n, w int
        fmt.Scanf("%d", &n)
        fmt.Scanf("%d", &w)

        Init()
        var l, r int
        for {
                _, err := fmt.Scanf("%d,%d", &l, &r)
                if err != nil {
                        break
                }

                Swp(l, r)
        }

        for i := 1; i <= n; i++ {
                fmt.Printf("%d\n", lines[i])
        }
}

func Swp(l int, r int) {
        var s int
        s = lines[l]
        lines[l] = lines[r]
        lines[r] = s
}

func Init() {
        for i := 0; i < MAX_N; i++ {
                lines[i] = i
        }
}



Measured memory_bytes: 1104
#include <iostream>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <cmath>
#include <cstdarg>
#include <cstdlib>
#include <string>

#include <vector>
#include <tuple>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

int main(int argc, char const *argv[]) {
    int N, W;
    cin >> N >> W;
    int v[N], w[N];
    for (int i = 0; i < N; i ++) {
        cin >> v[i] >> w[i];
    }
    int dp[2][W + 1];
    memset(dp[0], 0, sizeof(dp[0]));
    int now;
    for (int i = 0; i < N; i ++) {
        now = (i+1) & 1;
        for (int j = 0; j <= W; j ++) {
            if (j < w[i]) {
                dp[now][j] = dp[now ^ 1][j];
            } else {
                dp[now][j] = max(
                    dp[now ^ 1][j],
                    dp[now ^ 1][j - w[i]] + v[i]
                );
            }
        }
    }
    cout << dp[now][W] << endl;
    return 0;
}


Measured memory_bytes: 3188
import math

def trial_division(target):
    dest = int(math.sqrt(target))

    for i in range(2, dest):
        if target % i == 0:
            return False
    return True


def main():
    x = int(input())
    for i in range(x, (10**6)):
        if trial_division(i):
            print(i)
            return


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,m,X,Y,x,y;
    cin>>n>>m>>X>>Y;
    int max_X=X,min_Y=Y;
    for (int i=0;i<n;i++) {
        cin>>x;
        if (x>max_X) {
            max_X=x;
        }
    }
    for (int j=0;j<m;j++) {
        cin>>y;
        if (y<min_Y) {
            min_Y=y;
        }
    }
    if (max_X<min_Y&&min_Y-max_X>0) {
        cout<<"No War"<<endl;
    } else {
        cout<<"War"<<endl;
    }
}

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

using namespace std;

typedef long long ll;

int main(){
	int n, k, q;
	cin >> n >> k >> q;
	vector<int> S(n),A(q);

	int min_ans = k - q;

	for(int i = 0; i < q; i++){
		int tmp;
		cin >> tmp;
		S[tmp-1]++;
	}

	if(min_ans > 0){
		for(int i = 0; i < n; i++){
			cout << "Yes" << endl;
		}
	}else{
		for(int i = 0; i < n; i++){
			if(S[i] >= ((-1)*min_ans + 1)){
				cout << "Yes" << endl;
			}else{
				cout << "No" << endl;
			}
		}
	}

}

Measured memory_bytes: 1408
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <string>
#include <vector>
#include <cmath>

//AOJ0074
#define rep(x,to) for(int x=0;x<to;x++)
#define rep2(x,from,to) for(int x=from;x<to;x++)

using namespace std;

int main(void){

int tm[3];
	while(cin >> tm[0] >> tm[1] >> tm[2]){
		if(tm[0]==-1 && tm[1]==-1 && tm[2]==-1 || cin.eof()) break;
		int fl[3]={1,59,60};
		rep(i,3) fl[i] -= tm[i];
		rep(i,2) while(fl[2-i] >= 60){ fl[2-i] -=60; fl[1-i]++; }
		printf("%02d:%02d:%02d\n",fl[0],fl[1],fl[2]);
		rep(i,3) fl[i] *= 3;
		rep(i,2) while(fl[2-i] >= 60){ fl[2-i] -=60; fl[1-i]++; }
		printf("%02d:%02d:%02d\n",fl[0],fl[1],fl[2]);
		
	}
	return 0;
	
}

Measured memory_bytes: 1160
/*
 * cpp_filepath
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
void solve();
int main() { solve(); return 0; }


void solve() {
  int ans = 0;
  int x;
  loop(i,1,6) {
    cin >> x;
    if (x!=i) ans = i;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3640
#include<cstdio>
#include<cstring>
#define INF 1e9+7
int main()
{
    int m;
    int a[100004][3];
    while(scanf("%d",&m)!=EOF)
    {
    	a[0][0]=a[0][1]=a[0][2]=0;
    	for(int i=1;i<=m;i++)
    	{
    		int x,y,z;
    		scanf("%d%d%d",&x,&y,&z);
    		a[i][0]=x;a[i][1]=y;a[i][2]=z;
		}
		int ans=0;
		for(int i=1;i<=m;i++)
		{
			int ant=a[i][1]+a[i][2]-a[i-1][1]-a[i-1][2];
			int ant1=a[i][0]-a[i-1][0];
			if(ant1==ant)
			ans++;
			else if(ant1>ant)
			{
				ant1=ant1-ant;
				if(ant1%2==0)
			    ans++;
			}	
		}
//		printf("%d\n",ans);
		if(ans==m)
		printf("Yes\n");
		else
		printf("No\n");
	}
return 0;
}

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

int main(){
    string S;  cin >> S;
    vector<string> cand;
    cand.push_back("KIHBR");
    cand.push_back("AKIHBR");
    cand.push_back("KIHABR");
    cand.push_back("AKIHABR");
    cand.push_back("KIHBAR");
    cand.push_back("AKIHBAR");
    cand.push_back("KIHABAR");
    cand.push_back("AKIHABAR");
    cand.push_back("KIHBRA");
    cand.push_back("AKIHBRA");
    cand.push_back("KIHABRA");
    cand.push_back("AKIHABRA");
    cand.push_back("KIHBARA");
    cand.push_back("AKIHBARA");
    cand.push_back("KIHABARA");
    cand.push_back("AKIHABARA");
    for(int i=0; i<16; i++){
        if(S==cand[i]){
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
 
int main() {
    string S;
    cin >> S;
    if(S.size()==2){
      cout << S << endl;
    }else{
      cout << S[2] << S[1] << S[0] << endl;
    }
 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  char c;
  bool hasVowel = false;
  cin >> c;
  string vowel = "aiueo";
  for (int i=0; i<5; i++) {
	if (c == vowel.at(i)) hasVowel = true;
  }
  if (hasVowel == true) cout << "vowel" << endl;
  else cout << "consonant" << endl;
}
  
  

Measured memory_bytes: 3492
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const long long INF = 1000000007;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(void){
    int a,b,c; cin >> a >> b >> c;
    if(a==b && a==5 && c==7) cout << "YES" << endl;
    else if(a==c && a==5 && b==7) cout << "YES" << endl;
    else if(b==c && b==5 && a==7) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stdio.h>
#include <stdlib.h>

static void C_FiveTransportations();

int main()
{
	C_FiveTransportations();

	return 0;
}

static void C_FiveTransportations()
{
	char szNum[64] = { 0 };
	unsigned long long N = 0;
	unsigned long long capacity[5] = { 0 };
	unsigned long long city[5] = { 0 };

	//scanf(" %lu", &N);
	fgets(szNum, sizeof(szNum), stdin);
	N = strtoull(szNum, NULL, 10);

	unsigned long long tmpCapa = 0xFFFFFFFFFFFFFFFFull;
	int minCapaIdx = 0;
	for (int p = 0; p < 5; p++) {
		fgets(szNum, sizeof(szNum), stdin);
		capacity[p] = strtoull(szNum, NULL, 10);

		if (tmpCapa > capacity[p]) {
			tmpCapa = capacity[p];
			minCapaIdx = p;
		}
	}

	

	city[0] = N;
	unsigned long long time = 0;
	unsigned long long moveNum = 0;

	time = N / capacity[minCapaIdx];
	if (N % capacity[minCapaIdx]) {
		time++;
	}

	time += 4;
	int idx = 0;
	char szTime[64] = { 0 };
	while (time) {
		szTime[idx] = '0' + (time % 10);
		time = time / 10;
		idx++;
	}
	char szTime2[64] = { 0 };
	for (int i = 0; i < idx; i++) {
		szTime2[i] = szTime[idx - i - 1];
	}


	printf("%s\n", szTime2);
	fflush(stdout);
}


Measured memory_bytes: 256
import java.util.Scanner;

class Circle {
	public float xx;
	public float yy;
	public float rr;
	public void Cricle(float x, float y, float r) {
		if(x<-1000||x>1000||y<-1000||y>1000) {
			System.out.println("error");
		}
		else if(r>1000||r<1) {
			System.out.println("error");
		}else {
			this.xx=x;
			this.yy=y;
			this.rr=r;
		}
	}
	public float getx() {
		return xx;
	}
	public float gety() {
		return yy;
	}
	public float getr() {
		return rr;
	}	
}

public class Main {
	static Circle C1,C2;
	public static void main(String[] args) {
		C1= new Circle();
		C2= new Circle();
		listenC();
		judge();
	    
	}
	public static void listenC() {
		Scanner scanner=new Scanner(System.in);
		float c1x=scanner.nextFloat();
		float c1y=scanner.nextFloat();
		float c1r=scanner.nextFloat();
		float c2x=scanner.nextFloat();
		float c2y=scanner.nextFloat();
		float c2r=scanner.nextFloat();
		C1.Cricle(c1x, c1y, c1r);
		C2.Cricle(c2x, c2y, c2r);
		if (C1==C2)System.out.println("error");
	}
	private static void judge() {
		double i;
		i=Math.sqrt((C1.getx()-C2.getx())*(C1.getx()-C2.getx())+(C1.gety()-C2.gety())*(C1.gety()-C2.gety()));
		if(i>C1.getr()+C2.getr())    
			System.out.println(4);
		else if(i==Math.abs(C1.getr()+C2.getr()))    
			System.out.println(3);
		else if(i>Math.abs(C1.getr()-C2.getr())&&i<C1.getr()+C2.getr())   
			System.out.println(2);
		else if(i==Math.abs(C1.getr()-C2.getr()))     
			System.out.println(1);
		else             
			System.out.println(0);
	}
}



Measured memory_bytes: 28076
#include<stdio.h>

int main(void)
{
  int a, b, sum;
  
  scanf("%d%d", &a, &b);
  
  if(a > b)
  {
    sum = a + a - 1;
  }
  else if(b > a)
    sum = b + b - 1;
  else
    sum = a + b;
  
  printf("%d", sum);
  
  return 0;
}

Measured memory_bytes: 128
import collections
N=int(input())
n_list=input().split()
count=0
L_list=[]
R_list=[]
for i,item in enumerate(n_list) :
  L_list.append(str(i+int(item)))
  R_list.append(str(i-int(item)))
L_dic=collections.Counter(L_list)
R_dic=collections.Counter(R_list)
count=0
for i in range(N) :
  L_count=L_dic[str(i)]
  R_count=R_dic[str(i)]
  count+=L_count*R_count
print(count)

Measured memory_bytes: 178340
//競技プログラミング用のテンプレート
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <math.h>
#include <stack>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repr(i, n) for(int i = n - 1; i >= 0; i--)

using namespace std;
using ll = long long int;
using p = pair<int, int>;
using pl = pair<ll, ll>;
using v = vector<int>;
using vd = vector<double>;
using vs = vector<string>;
using vl = vector<ll>;

int main()
{
  ll h;
  cin >> h;
  int height = log2(h) + 1;
  ll c = pow(2, height) - 1;
  cout << c << endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define REP(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
const ll MOD = 1000000007;

int main() {
  int n, d, c = 0;
  cin >> n >> d;
  int x[n][d];
  REP(i, n) REP(j, d) {
    cin >> x[i][j];
  }

  REP(i, n) for (int j = i + 1; j < n; ++j) {
    double dist = 0;
    REP(k, d) dist += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
    dist = sqrt(dist);
    if (floor(dist) == dist) ++c;
  }

  cout << c << endl;
  return 0;
}

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

int main(){
    int N,Y;
    cin >>N >>Y;
    
    for(int i=0;i<=N;i++){
        for (int j=0;j<=N-i;j++){
            int k=N-i-j;
            if(k>=0 && Y==10000*i+5000*j+1000*k ){
                cout << i <<" " <<j <<" " <<k <<endl;
                return 0;
            }
        }
    }
    cout <<"-1 -1 -1" <<endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
#N = 2
#A = [1000000000,1000000000]

def check_yakusuu(n):
    list_yakusuu = []
    for i in range(1,int(n**0.5)+1):
        if n % i == 0:
            if i != n//i:
                list_yakusuu.append(i)
                list_yakusuu.append(n//i)
            else:
                list_yakusuu.append(i)
    list_yakusuu.sort(reverse = True)
    return list_yakusuu
ans = []
for i in range(2):
    list_yakusuu = check_yakusuu(A[i])
    for j in list_yakusuu:
        tmp = 0
        for k in range(N):
            if A[k] % j == 0:
                tmp += 1
        if tmp >= N - 1:
            ans.append(j)
            break
print(max(ans))

Measured memory_bytes: 14436
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.close();
		int tmp = n;
		StringBuffer anstmp = new StringBuffer();
		if(tmp == 0)anstmp.append("0");
		while(tmp != 0) {
			int r = 0;
			if(tmp % (-2) != 0)r = 1;
			anstmp.append(String.valueOf(r));
			if(tmp < 0)tmp = (tmp - 1) /(-2);
			else tmp /= (-2);
		}
		anstmp = anstmp.reverse();
		String ans = anstmp.substring(0);
		System.out.println(ans);
	}

}


Measured memory_bytes: 20820
S = [0,0,0,0,0,0,0,0,0,0,0,0,0,0]
H = [0,0,0,0,0,0,0,0,0,0,0,0,0,0]
C = [0,0,0,0,0,0,0,0,0,0,0,0,0,0]
D = [0,0,0,0,0,0,0,0,0,0,0,0,0,0]
l=int(input())
for i in range(l):
	a,b = input().split()
	b = int(b) 
	if   a == 'S':
			S[b] = 1
	elif a == 'H' :
			H[b] = 1
	elif a == 'C':
			C[b] = 1
	elif a == 'D':
			D[b] = 1
for k in range(1,14):
	if not S[k] :
		print('S',k)
for k in range(1,14):
	if not H[k] :
		print('H',k)
for k in range(1,14):
	if not C[k] :
		print('C',k)
for k in range(1,14):
	if not D[k] :
		print('D',k)


Measured memory_bytes: 5604
#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() {
  string S, T;
  cin >> S >> T;

  cout << T << S << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>

using namespace std;
typedef long long ll;

int main(){
  int n; cin>>n;
  if(n/1000==(n%1000)/100&&(n%1000)/100==(n%100)/10){
    cout<<"Yes"<<endl;
  }else if((n%1000)/100==(n%100)/10&&(n%100)/10==n%10){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}

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

using namespace std;

#define pb push_back

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

const int mn=1e5+5;

int n,m;
int a[mn];
pii p[mn];

int f[mn];
int sf(int x){return f[x]==x?x:f[x]=sf(f[x]);}
set<int> s[mn];

int main() {
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]),f[i]=i;
	for(int i=1;i<=m;i++){
		int u,v;
		scanf("%d%d",&u,&v);
		if (sf(u)!=sf(v)){
			f[sf(u)]=sf(v);
		}
	}
	for(int i=1;i<=n;i++){
		s[sf(i)].insert(a[i]);
	}
	int ans=0;
	for(int i=1;i<=n;i++){
		if (s[sf(i)].count(i)) ans++;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 11136
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		FastScanner in = new FastScanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		ProblemA solver = new ProblemA();
		solver.solve(1, in, out);
		out.close();
	}

	static class ProblemA {
		public void solve(int testNumber, FastScanner in, PrintWriter out) {
			int n = in.nextInt();
			int[] a = new int[n];
			for (int i = 0; i < n; i++) {
				a[i] = in.nextInt();
			}
			int ans = 0;
			int i = 0;
			while (i < n) {
				int j = i;
				while (j < n && a[i] == a[j]) {
					++j;
				}
				ans += (j - i) / 2;
				i = j;
			}
			out.println(ans);
		}

	}

	static class FastScanner {
		private BufferedReader in;
		private StringTokenizer st;

		public FastScanner(InputStream stream) {
			in = new BufferedReader(new InputStreamReader(stream));
		}

		public String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					String rl = in.readLine();
					if (rl == null) {
						return null;
					}
					st = new StringTokenizer(rl);
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return st.nextToken();
		}

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

	}
}



Measured memory_bytes: 21460
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <queue>
#include <cmath>
#include <limits>
#include <stack>

using namespace std;

int main(){
  long N,T,now,t;
  long count = 0;
  cin >> N >> T;
  cin >> now;
  for(long i=1;i<N;++i){
    cin >> t;
    if(now+T<t){
      count += T;
    }else{
      count += t-now;
    }
    now = t;
  }
  cout << count+T << endl;
}


Measured memory_bytes: 256
/*
Author: TianyuZhou
Accepted / Wrong Answer / Time Limit Error / Memory Limit Error / Compile Error
*/
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	int sum=0;
	if(a==1)
		sum+=300000;
	else if(a==2)
		sum+=200000;
	else if(a==3)
		sum+=100000;
	if(b==1)
		sum+=300000;
	else if(b==2)
		sum+=200000;
	else if(b==3)
		sum+=100000;
	if(a==1&&b==1)
		sum+=400000;
	cout<<sum<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define fi first
#define se second
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
    vector<int> size;
    UnionFind(int N): par(N),size(N) {

         //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++){
            par[i] = i;
            size[i] = -1;
        }
            
    }
    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
        size[ry] += size[rx];
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
    int getsize(int x){
        return -size[root(x)];
    }
    int getNunion(){//これちょっと遅い sameと組み合わせて順次数えていけば早くなりそう。
        map<int,int> m;
        rep(i,par.size()){
            m[this->root(i)]++;
        }
        return int(m.size());
    }
};

int main(){
    ll N, M;
    cin >> N >> M;
    vector<ll> L(M), R(M), D(M);
    vector<vector<Pll>> G(N);
    rep(i,M){
        cin >> L[i] >> R[i] >> D[i];
        L[i]--;R[i]--;
        G[L[i]].push_back(Pll(R[i],D[i]));
        G[R[i]].push_back(Pll(L[i],-D[i]));
    }
    vector<ll> memo(N, 1e18);
    rep(i,N){
        queue<ll> que;
        if(memo[i] != 1e18) continue;
        memo[i] = 0;
        que.push(i);
        while(!que.empty()){
            ll v = que.front();
            que.pop();
            for(auto& p:G[v]){
                ll u = p.fi;
                ll c = p.se;
                if(memo[u] != 1e18) continue;
                memo[u] = memo[v] + c;
                que.push(u);
            }
        }
    }
    rep(i,M){
        if(memo[L[i]] + D[i] != memo[R[i]]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 21896