akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main()
{
   int t,k;
   cin>>t>>k;
   int a[t+1]={0};
  for(int i=1;i<=t;i++){ 
      cin>>a[i];
      a[i] = a[i-1] + a[i];
      //cout<<a[i];
  }
  int i;
  for(i=0;i<=t;i++){
      //cout<<a[i]<<".";
      if(k<a[i]){ cout<<i; exit(0);}
      else if(k==a[i]){cout<<i+1; exit(0); }
  }
  cout<<i;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <math.h>
#include <iomanip>

using namespace std;

int main(void){
  int A,B,H,M;
  cin >> A;
  cin >> B;
  cin >> H;
  cin >> M;
  std::cout << std::fixed;
  int minu;
  minu = 60.0*H + M;
  double radH = 2.0*M_PI*(minu/(12.0*60.0));
  double radM = 2.0*M_PI*M/60.0;
  double rad = radH-radM;
  double ans = sqrt(A*A + B*B -2.0*A*B*cos(rad));
  cout <<std::setprecision(10)<< ans << endl;
  return 0;
}


Measured memory_bytes: 4140
import java.util.*;
public class Main
{
	public static long gcd(long a,long b)
	{
		if(b==0)
		{
			return a;
		}
		return gcd(b,a%b);
	}
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		long a=in.nextLong();
		long b=in.nextLong();
		gcd(a,b);
		System.out.println((a*b)/gcd(a,b));
	}
}


Measured memory_bytes: 35684
L,R=map(int,input().split())

if L==0:
    print(0)
elif L%2019==0 or R%2019==0:
    print(0)
elif (R-L)>=2019:
    print(0)
elif (L//2019)<(R//2019):
    print(0)
else:
    A=[]
    for i in range(L,R+1):
        A.append(i%2019)
    M=10000
    for i in range(len(A)-1):
        for j in range(i+1,len(A)):
            if (A[i]*A[j])%2019<M:
                M=(A[i]*A[j])%2019
    print(M)

Measured memory_bytes: 40812
import java.util.*;
public class Main {
	static Scanner sc = new Scanner(System.in);
	static boolean[] prime = new boolean[10000001];
	static int n;
	public static void main(String[] args) {
		make_prime();
		while(read()){
			solve();
		}
	}
	
	static boolean read(){
		n = sc.nextInt();
		if(n == 0)return false;
		return true;
	}
	
	static void solve(){
		int res = 0;
		for(int i = n; i >= 13; i--){
			if(prime[i] && prime[i - 2] && prime[i - 6] && prime[i - 8]){
				res = i;
				break;
			}
		}
		System.out.println(res);
	}
	
	static void make_prime(){
		Arrays.fill(prime, true);
		prime[0] = false;
		prime[1] = false;
		for(int i = 2; i < prime.length; i++){
			if(prime[i]){
				for(int j = 2*i; j < prime.length; j += i){
					prime[j] = false;
				}
			}
		}
	}
}

Measured memory_bytes: 22000
N, M = map(int,input().split())
data = [list(map(int,input().split())) for _ in range(N)]

data = sorted(data,key=lambda x:x[0])

money = 0
amount = 0
for a, b in data:
  amount += b
  money += a *b
  excess = (amount - M)
  if excess >= 0:
    money -= a * excess
    break

print(money)
  

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

struct topnano{char a; int t;};

int main(){
    int n,k=1;
    while(cin>>n){
        if(n==0){break;}
        char c[n],al[30];
        cin>>c[0];
        al[0]=c[0];
        for(int i=1;i<n;i++){
            cin>>c[i];
            for(int j=0;j<k;j++){
                if(al[j]==c[i]){break;}
                else if(j==k-1){
                    al[k]=c[i];
                    k++;
                    break;
                }
            }
        }
        if(k==1){
            cout<<al[0]<<" "<<1+(n/2)<<endl;
        }else{
            int votes[k];
            for(int i=0;i<k;i++){
                votes[i]=0;
            }
            struct topnano ichii,nii;
            ichii.t=0;
            nii.t=0;
            for(int i=0;i<n;i++){
                for(int j=0;j<k;j++){
                    if(c[i]==al[j]){
                        votes[j]++;
                        if(ichii.t<votes[j]){
                            ichii.t=votes[j];
                            ichii.a=al[j];
                        }else if(nii.t<votes[j]){
                            nii.t=votes[j];
                            nii.a=al[j];
                        }
                        break;
                    }
                }
                if(ichii.t > n - i -1+ nii.t){
                    cout<<ichii.a<<" "<<i+1<<endl;
                    break;
                }
                if(i==n-1){
                    if(ichii.t==nii.t){
                        cout<<"TIE"<<endl;
                    }else{
                        cout<<ichii.a<<" "<<i+1<<endl;
                    }
                }
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int, int>> vpi;
typedef vector<pair<long long, long long>> vpl;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define FOR(i, k, n) for (int i = (k); i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.begin(), a.end(), greater<int>()
#define ROT(a) a.begin(), a.begin() + 1, a.end()
#define RROT(a) a.begin(), a.end() - 1, a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9 + 7;
const int MAX = 10000000;
template <typename T1, typename T2>
inline bool chmin(T1& a, T2 b)
{
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T1, typename T2>
inline bool chmax(T1& a, T2 b)
{
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
T gcd(T a, T b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
//cout << 'H' << endl;
/*--------------------------------------------*/

int main(){
    int X,Y,Z;
    cin >> X >> Y >> Z;
    cout << Z << " " << X << " " <<  Y << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long MD=1e9+7;
int n,a[100005],vis[100005];
long long x,y,z;
long long pro[2][100005],fact[100005];
long long fastpow(long long cur,long long ex) {
    long long res=1;
    while (ex) {
        if (ex&1) res=(res*cur)%MD;
        ex>>=1; cur=(cur*cur)%MD;
    }
    return res;
}
long long ch(long long k,long long m,int t) {
    if (k>m) return 0;
    if (k==0 or k==m) return 1;
    long long x=fastpow(fact[k],MD-2)%MD;
    return (pro[t][m-k+1]*x)%MD;
}
int main() {
    cin>>n;
    memset(vis,-1,sizeof(vis));
    for (int i=0; i<n; i++) {
        cin>>a[i];
        if (vis[a[i]]!=-1) {
            x=vis[a[i]]; z=i-vis[a[i]]-1; y=n-i;
        }
        vis[a[i]]=i;
    }
    pro[0][n+1]=n+1;
    for (int i=n; i>=1; i--) pro[0][i]=(pro[0][i+1]*i)%MD;
    pro[1][x+y]=x+y;
    for (int i=x+y-1; i>=1; i--) pro[1][i]=(pro[1][i+1]*i)%MD;
    fact[1]=1;
    for (int i=2; i<=n+1; i++) fact[i]=(fact[i-1]*i)%MD;
    for (int i=1; i<=n+1; i++) {
        long long p1=ch(i,n+1,0),p2=ch(i-1,x+y,1);
        long long p3=(p1-p2)%MD;
        cout<<(p3+5*MD)%MD<<'\n';
    }
}

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

int main () {
    int N,sum;
    cin >> N;
    vector<int> B(N - 1);

    for (int i = 0; i < N - 1; i++) {
        cin >> B.at(i);
    }

    vector<int> A(N);

    A.at(0) = B.at(0);

    A.at(N - 1) = B.at(N - 2);

    for (int i = 1; i < N - 1; i++) {
        A.at(i) = min(B.at(i - 1), B.at(i));
    }

    for (int i = 0; i < N; i++) {
        sum += A.at(i);
    }

    cout << sum << endl;


}

Measured memory_bytes: 256
// Do you knOW what it feels like?

		// To be TorTured by your own MinD?
	
	// I don't wanna feel the PAIN.

// I BeG you to KILL me, pleASE...

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

#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("Os")

#define F first
#define S second
#define pb push_back
#define SZ(x) (ll)(x.size())
#define all(x) x.begin(),x.end()

typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll maxn=1e5+10, lg=22, mod=1e9+7, inf=1e18;

ll n,m,tt=1;
ll a[maxn],b[maxn];
ll s[maxn],t[maxn],ans=0;
ll find(ll k,ll r){
	if(r==0) return 0;
	ll l=1;
	while(l<r){
		ll mid=(l+r+1)/2;
		if(a[mid]<=k) l=mid;
		else          r=mid-1;
	}
	return l;
}

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

	cin>>n>>m;
	b[tt]=n;
	for(int i=1;i<=m;i++){
		ll x; cin>>x;
		while(x<=b[tt]) tt--;
		b[++tt]=x;
	}
	m=tt;
	for(int i=1;i<=m;i++) a[i]=b[i];
	t[m]=1;
	for(int i=m;i>=1;i--){
		ll nw=a[i];
		ll p=find(nw,i-1);
		while(p){
			t[p]+=(nw/a[p])*t[i];
			nw%=a[p];
			p=find(nw,p-1);
		}
		s[1]+=t[i];
		s[nw+1]-=t[i];
	}
	for(int i=1;i<=n;i++) ans+=s[i], cout<<ans<<endl;

	return 0;
}












Measured memory_bytes: 4864
#include "iostream"
using namespace std;
int main() {
	int sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;
	cout << 'D';
	for (int i = 0; i < tx - sx + 1; i++)
		cout << 'R';
	for (int i = 0; i < ty - sy + 1; i++)
		cout << 'U';
	cout << 'L';
	for (int i = 0; i < ty - sy; i++)
		cout << 'D';
	for (int i = 0; i < tx - sx; i++)
		cout << 'L';
	for (int i = 0; i < ty - sy; i++)
		cout << 'U';
	for (int i = 0; i < tx - sx; i++)
		cout << 'R';
	cout << 'U';
	for (int i = 0; i < tx - sx + 1; i++)
		cout << 'L';
	for (int i = 0; i < ty - sy + 1; i++)
		cout << 'D';
	cout << 'R';
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main (){
    int X[10][10], i, j, N, D, H[10], k, cout = 0;
    double sum;
    scanf("%d %d", &N, &D);
    for(i = 0; i < N; ++i){
        for(j = 0; j < D; ++j){
            scanf("%d", &X[i][j]);
        }
    }
    for(i = 0; i < N - 1; ++i){
        for(j = i + 1; j < N; ++j){
            sum = 0.0;
            for(k = 0; k < D; ++k){
                 H[k] = X[i][k] - X[j][k];
                 sum += pow((double)H[k], 2.0);
                //  printf("1 : %f\n", sum);
            }
            k = (int)sum;
            // printf("k : %d\n", k);
            k = (int)sqrt(sum);
            sum = sqrt(sum) - (double)k;
            // printf("%d %d sum : %f\n\n", i + 1, j + 1, sum);
            if(sum <= 0.0) ++cout;
        }
    }
    printf("%d\n", cout);
    return 0;
}

Measured memory_bytes: 128
// In the name of god
#include <bits/stdc++.h>
#pragma GCC optimze("02")
using namespace std;
using ll =long long;
const ll maxn=1e5+5,inf=1e18+18;
ll n,m,t;
char c;
int main(){
	ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0);
	cin>>c;
	if(c>='A'&&c<='Z')cout<<'A';
	else cout<<'a';
		
}


Measured memory_bytes: 3644
n, y = list(map(int, input().split()))

flag = False
for i in range(n+1):
    for j in range(n-i+1):
        yen = 10000*i+5000*j+1000*(n-i-j)
        if yen == y:
            print(i, j, n-i-j) 
            flag = True
            break
    else:
        continue
    break

if flag == False:
    print(-1, -1, -1)

Measured memory_bytes: 3064
object Main extends App {
    val in = io.Source.stdin.getLines.map(_.split(" ")).map(a => (a(0), a(1).toInt))
    val (_, q) = in.next
    val queue = scala.collection.mutable.Queue[(String, Int)]()
    in.foreach(queue.enqueue(_))
    var t = 0
    while (!queue.isEmpty) {
        if (queue.head._2 > 0) {
            val h = queue.dequeue
            if (h._2-q <= 0) {
                t += h._2
                println(h._1 + " " + t)
            } else {
                t += q
                queue.enqueue((h._1, h._2-q))
            }
        }
    }
}

Measured memory_bytes: 112664
n,i,j,u,v=1,a[2][3];long d[25000005];s(){for(i=n;i;)d[i]=i--;for(;i<=n;++i)for(j=0;j<3;++j)a[v][j]>a[u][j]&&i>=a[u][j]&&(d[i]=fmax(d[i],d[i-a[u][j]]+a[v][j]));}main(){for(scanf("%d",&n);i<2;i++)for(j=0;j<3;)scanf("%d",a[i]+j++);s(),n=d[n],u=1,v=0,s();printf("%lld\n",d[n]);}

Measured memory_bytes: 195456
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cstring>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
using namespace std;
#define INT(x) int x; scanf("%d",&x)
#define INPUT(x) scanf("%d",&x)
#define REP1(x,n) for(int x = 0; x < n; x++)
#define REP2(x,s,e) for(int x = s; x <= e; x++)
#define RREP1(x,n) for(int x = n-1; x >= 0; x--)
#define RREP2(x,s,e) for(int x = s; x >= e; x--)
#define BR printf("\n")
#define INF 2000000000

typedef long long ll;

int main(){
    int U[100001][2] = {}; //
    INT(N);
    REP2(i,1,N){
        INT(a);
        U[i][0] = a;
    }
    int counter = 0;
    REP2(i,1,N){
        int d = U[i][0];
        if (U[d][0] == i && U[d][1] == 0){
            counter++;
            U[i][1] = 1;
            U[d][1] = 1;
        }
    }
    cout << counter << endl;
}

Measured memory_bytes: 1152
#include <iostream>
#include <cstdlib>
#include <algorithm>

using namespace std;

typedef long long ll;

const int A = 80;

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

    int n, m;
    cin >> n >> m;
    int a[n][m];
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> a[i][j];
        }
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            int b;
            cin >> b;
            a[i][j] -= b;
        }
    }

    int am = (n + m) * A;

    bool dp[n][m][am];
    fill(&dp[0][0][0], &dp[n][0][0], false);
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            if (i == 0 && j == 0) {
                dp[i][j][abs(a[i][j])] = true;
            } else {
                for (int q = -1; q <= 1; q += 2) {
                    if (i > 0) {
                        for (int k = 0; k < am - A; k++) {
                            if (dp[i-1][j][k]) {
                                dp[i][j][abs(k+q*a[i][j])] = true;
                            }
                        }
                    }
                    if (j > 0) {
                        for (int k = 0; k < am - A; k++) {
                            if (dp[i][j-1][k]) {
                                dp[i][j][abs(k+q*a[i][j])] = true;
                            }
                        }
                    }
                }
            }
        }
    }

    int ans = am;
    for (int i = 0; i < am; i++) {
        if (dp[n-1][m-1][i]) {
            ans = i;
            break;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 80256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
//typedef __int64 LL;
//typedef long long int LL;
typedef vector<int> ivec;
typedef vector<string> svec;

const int MOD=1000000007;

int main()
{
	int n,y;
	cin>>n>>y;
	for(int i=0;i<=n;i++)
	{
		for(int j=0;i+j<=n;j++)
		{
			if(i*10000+j*5000+(n-i-j)*1000==y)
			{
				cout<<i<<' '<<j<<' '<<n-i-j<<"\n";
				return 0;
			}	
		}
	}
	cout<<-1<<' '<<-1<<' '<<-1<<"\n";
}

Measured memory_bytes: 256
import numpy as np
N, M, X = map(int, input().split())
prices = []
effects = []
for i in range(N):
    c, *a = map(int, input().split())
    prices.append(c)
    effects.append(list(a))
 
prices = np.array(prices)
effects = np.array(effects)
 
 
ans = float("inf")
 
pats = []
for i in range(2 ** N):
    pat = bin(i).replace("0b", "")
    pat = "0" * (N - len(pat)) + pat
    pat = list(map(int, list(pat)))
    pats.append(pat)
    
pats = np.array(pats)
total_price = np.dot(pats, prices)
total_effects = np.dot(pats, effects)
cond = ((total_effects >= X).sum(axis=1) == M)
 
final = total_price[cond == 1]
if len(final) > 0:
    ans = int(final.min())
    print(ans)
else:
    print(-1)

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

int main(){
    long long n;
    cin >> n;
    vector<long long> h(n);
    for(int i = 0;i < n;i++){
        cin >> h[i];
    }
    long long ans = 0;
    long long cnt = 0;
    for(int i = 0;i < n-1;i++){
        if(h[i] >= h[i+1]){
            cnt++;
            ans = max(ans,cnt);
        }else{
            ans = max(ans,cnt);
            cnt = 0;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
import itertools

n, m = map(int, input().split())
g = []
for i in range(n+1):
  g.append([])

for i in range(m):
  a, b = map(int, input().split())
  g[a].append(b)
  g[b].append(a)

t = [num for num in range(1, n+1)]
ans = 0
for per in itertools.permutations(t):
  if per[0] != 1:
    continue
  for i in range(n-1):
    start = per[i]
    end = per[i+1]
    if not end in g[start]:
      break
  else:
    ans += 1
print(ans)

Measured memory_bytes: 39920
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a: i32,
        b: i32,
    }

    let right: bool = (a <= 9) && (b <= 9);
    let ans: i32 = if right {
        &a * &b
    } else {
        -1
    };
    println!("{}", ans);
}

Measured memory_bytes: 4352
#include<iostream>
#include<string>
#include<cmath>
#include<cstdlib>
#include<vector>
#include<map>
#include<set>
#include<algorithm>

using namespace std;

int main(){
  int a,b,c,d;
  string s;
  cin>>a>>b;
  if((a<=8) && (b<=8)) cout<<"Yay!"<<endl;
  else cout<<":("<<endl;

  return 0;
}


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

int main(){
    map<string, string> weather = {
            {"Sunny", "Cloudy"},
            {"Cloudy", "Rainy"},
            {"Rainy","Sunny"}
    };
    string a;
    cin >> a;
    cout << weather[a] << endl;
    return 0;
}

Measured memory_bytes: 256
#ifdef __LOCAL
  #define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
using namespace std;
template<typename T> bool chmax(T &a,T b) {if(a<b) {a=b; return true;} return false;}
template<typename T> bool chmin(T &a,T b) {if(a>b) {a=b; return true;} return false;}
#define itn int
#define fi first
#define se second
#define intmax numeric_limits<int>::max()
#define llmax numeric_limits<ll>::max()
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>=1;i--)
#define all(vec) vec.begin(),vec.end()
#define sortt(vec) sort((vec).begin(),(vec).end())
#define rsort(vec) sort((vec).rbegin(), (vec).rend())
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef tuple<ll,ll,ll> tlll;
typedef tuple<int,int,int> tiii;
const ll mod=1e9+7;
const int inf=1<<30;
const ll lnf=1ll<<60;

int main(){
  ll ans=llmax;
  itn n; cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  vector<ll> s(n+1);
  rep(i,n) s[i+1]=s[i]+a[i];
  for(int i=2;i<n-1;i++){
    int itr1=lower_bound(all(s),s[i]/2)-s.begin();
    int itr2=lower_bound(all(s),(s[i]+s[n])/2)-s.begin();
    vector<ll> b;
    if( abs(s[itr1]-(s[i]-s[itr1]))<abs(s[itr1-1]-(s[i]-s[itr1-1]))){
      b.push_back(s[itr1]);
      b.push_back(s[i]-s[itr1]);
    }
    else{
      b.push_back(s[itr1-1]);
      b.push_back(s[i]-s[itr1-1]);
    }
    if( abs((s[itr2]-s[i])-(s[n]-s[itr2]))< abs((s[itr2-1]-s[i])-(s[n]-s[itr2-1])) ){
      b.push_back(s[itr2]-s[i]);
      b.push_back(s[n]-s[itr2]);
    }
    else{
      b.push_back(s[itr2-1]-s[i]);
      b.push_back(s[n]-s[itr2-1]);
    }
    sortt(b);
    chmin(ans,b[b.size()-1]-b[0]);
  }  
  cout << ans << endl;
}

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


int main() {

    string s;
    cin >> s;
    int ans = 100000000;
    for (int i = 0; i < s.size()-2; ++i) {
        int num = (s[i]-'1'+1)*100 + (s[i+1]-'1'+1)*10 + s[i+2]-'1'+1;
        ans = min(ans, abs(num-753));
    }
    cout << ans << endl;
    return 0;
}

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

int main(){

  int n;

  cin>>n;

  long long ans=0;


  int a;
  
  for(int i=0;i<n;i++){

    cin>>a;
    
    ans+=(a-1);

  }


  cout<<ans<<endl;
  
  return 0;

}
		  


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int N,K; cin>>N>>K;
    string s; cin>>s;

    int cnt=1;
    for(int i=1;i<s.size();i++){
        if(s[i-1]!=s[i]) cnt++;
    }

    if(cnt<=2*K+1){
        cout<<N-1<<endl;
    }else{
        cout<<(N-cnt)+2*K<<endl;
    }
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
#define fi first
#define se second
pii ar[4];
bool CF(const pii &a, const pii &b){
	int sha = 1 << a.se;
	int shb = 1 << b.se;
	return a.fi * shb < b.fi * sha;
}
int main(){
	for(int i = 0 ;i < 4; ++i) {
		scanf("%d", &ar[i].fi);
		ar[i].se = i;
	}
	int n;
	sort(ar,ar + 4, CF);
	scanf("%d", &n);
	int tempn = n;
	LL tot = 0;
	for(int i = 0;i < 4; ++i){
		if(ar[i].se == 3){
			tot += 1LL * ar[i].fi * (tempn >> 1);
			tempn %= 2;
		}
		else{
			tot += 1LL * ar[i].fi * (tempn << (2 - ar[i].se));
			break;
		}
	}

	printf("%lld\n", tot);
	return 0;
}

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

#define REP(i,n) for(int i=0;i<n;i++)
#define llong long long

using namespace std;

int main(){

  int n,x;
  vector<int> a;
  cin>>n;

  REP(i,n){
    cin>>x;
    // a.push_back(x);

    if(n%2==0){
      if(i%2==0)a.push_back(x);
      else a.insert(a.begin(),x);
    }
    else{
      if(i%2!=0)a.push_back(x);
      else a.insert(a.begin(),x);
    }
  }

  
  REP(i,n){
    cout<<a[i]<<" ";
  }
  cout<<endl;
  
  return 0;
}


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <stdio.h>
#include <vector>
#define int long long
#define endre getchar();getchar();return 0
#define moder 1000000007
#define inf 1000000000000000000
#define rep(i,n) for(int i=0;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x%mod;
		}
		x = x * x%mod;
		y >>= 1;
	}
	return res;
}
int kai(int x) {
	if (x == 0)return 1;
	return (kai(x - 1)*x) % moder;
}
int comb(int x, int y) {
	return kai(x)*mod_pow(kai(x - y), moder - 2, moder) % moder*mod_pow(kai(y), moder - 2, moder) % moder;
}
map<int, int> factor(int m) {
	map<int, int>res;
	for (int i = 2; i*i <= m; i++) {
		while (m%i == 0) {
			res[i]++;
			m /= i;
		}
	}
	if (m != 1)res[m]++;
	return res;
}

/*--------Library Zone!--------*/

queue<int>que;
int n, a;
signed main() {
	cin >> n;
	rep(i, pow(2, n)) {
		cin >> a;
		que.push(a);
	}
	while (que.size() > 1) {
		int b = que.front(); que.pop();
		int c = que.front(); que.pop();
		que.push(max(b, c) - min(b, c));
	}
	cout << que.front() << endl;
	endre;
}

Measured memory_bytes: 2432
import sys
import collections

sys.setrecursionlimit(10**6)
input = sys.stdin.readline
#read = sys.stdin.buffer.read

def main():
    N = int(input())
    A = list(map(int, input().split()))
    Asum = sum(A)
    Acount = collections.Counter(A)
    Q = int(input())
    for _ in range(Q):
        B, C = map(int, input().split())
        Bcount = Acount[B]
        Asum += (C - B)*Bcount
        print(Asum)
        Acount[C] += Acount[B]
        Acount[B] -= Acount[B]

if __name__ == "__main__":
    main()


Measured memory_bytes: 24000
from __future__ import (division, absolute_import, print_function,
                        unicode_literals)
from sys import stdin

for _ in xrange(int(stdin.readline())):
    result = 'YES'
    b = c = 0
    for a in (int(s) for s in stdin.readline().split()):
        if b < a:
            b = a
        elif c < a:
            c = a
            if b < c:
                b, c = c, b
        else:
            result = 'NO'
            break
    print(result)

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

int main() {
	int ans = 0, x;
	string s, t;
	cin >> s >> t;
	x = s.length();
	for(int i = 0; i < x; i++) {
		if(s[i] != t[i]) {
			ans++;
		}
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 3832
import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main {

	int INF = 1 << 28;
	int h, w, c;
	int max;
	int count;
	void run() {
		Scanner sc = new Scanner(System.in);
		for(;;) {
			h = sc.nextInt();
			w = sc.nextInt();
			c = sc.nextInt();
			if( (h|w|c) == 0 ) break;
			max = 0;
			byte[][] map = new byte[h+2][w+2];
			for(int i=1;i<=h;i++) for(int j=1;j<=w;j++) {
				map[i][j] = sc.nextByte();
			}
			dfs(0, map);
			System.out.println(max);
		}
	}
	
	void dfs(int cnt, byte[][] map) {

		if(cnt == 5) {
//			for(byte[] a: map)
//			debug(a);
			if( map[1][1] != c ) return;
			byte[][] tmp = new byte[h+2][w+2];
			for(int i=1;i<=h;i++) for(int j=1;j<=w;j++)
				tmp[i][j] = map[i][j];
			count = 0;
			exchange(tmp, 1, 1, tmp[1][1], (byte)0);
			max = max(max, count);
		}
		else {
			for(byte c=1;c<=6;c++) {
				if(c == map[1][1]) continue;
				byte[][] tmp = new byte[h+2][w+2];
				for(int i=1;i<=h;i++) for(int j=1;j<=w;j++)
					tmp[i][j] = map[i][j];
				count = 0;
				exchange(tmp, 1, 1, tmp[1][1], c);
				dfs(cnt+1, tmp);
			}
		}
		
	}
	int dx[] = {-1,0,1,0};
	int dy[] = {0,-1,0,1};
	void exchange(byte[][] map, int x, int y, byte c, byte ex) {
		count++;
		map[y][x] = ex;
		for(int i=0;i<4;i++) {
			if(map[y+dy[i]][x+dx[i]] == c) exchange(map, x+dx[i], y+dy[i], c, ex);
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}
}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k,f=0;
  cin >> n;
  map<int,int> a;
  for(int i=1;i<=n;i++){
    cin >> k;
    a[k]=i;
  }
  for(int i=1;i<=n;i++)cout << (i-1?" ":"") << a[i] ;
  cout << endl;
}

Measured memory_bytes: 8284
import itertools
n,m,q=map(int,input().split())
a=[0 for i in range(q)]
b=[0 for i in range(q)]
c=[0 for i in range(q)]
d=[0 for i in range(q)]
for i in range(q):
    a[i],b[i],c[i],d[i]=map(int,input().split())
    a[i]-=1
    b[i]-=1
ans=0

for i in itertools.combinations_with_replacement(range(1,m+1),n):
    tmp=0
    for j in range(q):
        if i[b[j]] - i[a[j]] == c[j]:
            tmp+=d[j]
    ans=max(ans,tmp)
print(ans)

Measured memory_bytes: 9168
#include <string>
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <iomanip>

using namespace std;

#define x first
#define y second
#define int long long

signed main() {
	int n;
	cin >> n;
	vector<pair<int, int>> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i].x >> a[i].y;
	}
	int ans = 1e9;
	if (n == 1) {
		cout << 1;
		return 0;
	}
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			int p = a[j].x - a[i].x;
			int q = a[j].y - a[i].y;
			set<pair<int, int>> s;
			for (auto el : a)
				s.insert(el);
			int cnt = 0;
			while (!s.empty()) {
				auto el = *s.begin();
				s.erase(el);
				cnt++;
				int x = el.x;
				int y = el.y;
				while (s.find(make_pair(x + p, y + q)) != s.end()) {
					s.erase(s.find(make_pair(x + p, y + q)));
					x += p;
					y += q;
				}
				x = el.x;
				y = el.y;
				while (s.find(make_pair(x - p, y - q)) != s.end()) {
					s.erase(s.find(make_pair(x - p, y - q)));
					x -= p;
					y -= q;
				}
			}
			ans = min(ans, cnt);
		}
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define maxn 1000000005
using namespace std;
int h;
int main()
{
    int a;
    cin>>a;
    int m=0;
    for(int i=0;i<a;i++)
    {
        char id;
        cin>>id;
        if(id=='I')
        {
            h++;
        }
        else
        {
            h--;
        }
        m=max(m,h);
    }
    cout<<m<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

/**
 *
 * @author k16069kk
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws IOException {
        int n = 0;
        int m = 0;

        int l = 0;
        int a = 0;
        int matrix_a[][] = new int[100][100]; //n*m
        int matrix_b[] = new int[100];   //m*1
        int matrix_ans [] = new int[100]; //n*1
        
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line;
        while ((line = br.readLine()) != null) {
            java.util.StringTokenizer st = new StringTokenizer(line, " ");
            if (n == 0 && m == 0) {
                n = Integer.parseInt(st.nextToken());
                m = Integer.parseInt(st.nextToken());
            } else if (l != n && l < n) {
                while (st.hasMoreTokens()) {
                    for (int i = 0; i < m; i++) {
                        matrix_a[l][i] = Integer.parseInt(st.nextToken());
                    }
                    l++;
                }
            } else {
                while (st.hasMoreTokens()) {
                    matrix_b[a] = Integer.parseInt(st.nextToken());
                    a++;
                }
            }
            if(l == n && a == m) break;
        }
        
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                int num1 = matrix_a[i][j];
                int num2 = matrix_b[j];
                int ans = num1 * num2; 
                matrix_ans[i] += ans;
            }
        }
        
        for (int i = 0; i < n; i++) {
            System.out.println(matrix_ans[i]);
        }

    }

}



Measured memory_bytes: 27660
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <map>
#include <numeric>
#include <algorithm>
#include <stdio.h>

int main(void){
  int n;
  std::cin >> n;
  int p,min=n+1,ans=0;
  for(int i=0;i<n;i++){
    std::cin >> p;
    if(min>p){
      ans++;
      min = p;
    }
  }
  std::cout << ans;
  return 0;
}

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

using namespace std;

int main() {
  string A, B;
  cin >> A >> B;
  if (A.length() > B.length()) {
    cout << "GREATER\n";
  } else if (A.length() < B.length()) {
    cout << "LESS\n";
  } else {
    if (A > B) {
      cout << "GREATER\n";
    } else if (A < B) {
      cout << "LESS\n";
    } else {
      cout << "EQUAL\n";
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <tuple>
#include <vector>

using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define INF (1e9)

int N, M;

int main() {
    cin >> N >> M;

    vvi edge(N, vi(N, INF));
    for (int i = 0; i < N; i++) {
        edge[i][i] = 0;
    }
    for (int i = 0; i < M; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        a--, b--;
        edge[a][b] = c;
        edge[b][a] = c;
    }

    vvi dist(edge);
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            for (int k = 0; k < N; k++) {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }

    int ans = 0;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < i; j++) {
            if (edge[i][j] != INF and edge[i][j] > dist[i][j]) ans++;
        }
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define endl '\n'
#define all(x) (x).begin(),(x).end()
const int INF=1000000000+5;
const int N=2e5+5;
const ll oo=1e18+5;
const ll mod=1e9+7;

int main(){
	ios::sync_with_stdio(0); cin.tie(0);
	int n,m;
	cin>>n>>m;
	map<int,int> maps;
	multiset<int> val;
	for(int i=0;i<m;++i) maps[i]=i;
	for(int i=0;i<m;++i) val.insert(0);
	for(int i=0;i<n;++i){
		int a,b;
		cin>>a>>b;
		--a;
		auto it=maps.lower_bound(a);
		int something=-1;
		while(it!=maps.end()&&it->first<=b){
			something=max(something,it->second);
			int diff=it->first-it->second;
			maps.erase(it++);
			val.erase(val.find(diff));
		}
		if(something>=0&&b<m){
			val.insert(b-something);
			maps[b]=something;
		}
		//~ for(int j=0;j<m;++j) if(maps.find(j)!=maps.end())cout<<"maps "<<j<<" = "<<maps[j]<<" ";
		//~ cout<<endl;
		if(val.empty()){
			cout<<-1<<endl;
			continue;
		}
		int ans=*val.begin()+i+1;
		cout<<ans<<endl;
	}		
	return 0;
}


Measured memory_bytes: 22372
/// Bismillahir Rahmanir Rahim
/* Mohammad Morsalin
   Dept of ICE, NSTU
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long
#define pb push_back
#define mp make_pair
#define endl "\n"
#define int long long
#define f0(n) for(int i=0;i<n;i++)
#define ms(x) memset(x,0,sizeof(x))
#define ms2d(x,m,n) memset(x, 0, sizeof(x[0][0]) * m * n)
#define uniq(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define pi pair<int,int>
#define tc(t) int t;cin>>t;while(t--)
#define bits(n) __builtin_popcount(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define ins insert
#define ALL(v) v.begin(),v.end()
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
#define Inf INFINITY
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define fi first
#define se second
#define PI acos(-1)
#define sz(a) (int)a.size();
#define IOS ios::sync_with_stdio(false);
using namespace std;
int gcd(int a, int b) { if (a == 0) return b; return gcd(b % a, a);}
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
const long long MOD = 1000000007;
double sq(double x) {return x*x;}
template<typename T>inline T Bigmod(T base, T power, T MOD){
    T ret=1;
    while(power)
    {
        if(power & 1)ret=(ret*base)%MOD;
        base=(base*base)%MOD;
        power>>=1;
    }
    return ret;
}

bool sortinrev(const pair<int,int> &a,
               const pair<int,int> &b)
{
       return (a.first > b.first);
}
signed main()
{
    IOS
    int n,d;
    while(cin>>n>>d){
            int cnt=0;
        for(int i=0;i<n;i++){
            int a,b;
            cin>>a>>b;
            double val=sqrt((a*a)+(b*b));
            if(val<=d){
                cnt++;
            }
        }
    cout << cnt << endl;
    }
    return 0;
}
///Alhamdulillah


Measured memory_bytes: 3636
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <cstdlib>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}





int main() {
	ll H, W;
	cin >> H >> W;
	vector<string> C(H);
	rep(i, H) {
		cin >> C.at(i);
	}
	rep(i, H) {
		cout << C.at(i) << endl << C.at(i) << endl;
	}
		
	
}

Measured memory_bytes: 256
X = int(input())
result = 1
for i in range(2,X):
    if i**2 > X:
        break
    j = 2
    while True:
        if i**j > X:
            break
        j += 1
    if i**(j-1) > result:
        result = i**(j-1)
print(result)

Measured memory_bytes: 38256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int X, Y;
    cin >> X >> Y;
    int ans = 0;
    ans += max(0, 4 - X) * 100000;
    ans += max(0, 4 - Y) * 100000;
    if(X == 1 && Y == 1) ans += 400000;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
# Problem B

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

# initialization
num_sa = N // (A+B)
num_amari = N % (A+B)

# process
ans_1 = num_sa * A
if num_amari>A:
    num_amari = A
ans_2 = ans_1 + num_amari

# output
print(ans_2)


Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int n;

int main(){
	cin>>n;
	if(n==0){
		cout<<0<<endl;
		return 0;
	}
	vi a;
	while(n!=0){
		int t=abs(n)%2;
		a.push_back(t);
		n-=t;
		n/=-2;
	}
	reverse(a.begin(),a.end());
	for(auto i:a) cout<<i;
	cout<<endl;
}

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

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

    int a,b,c,k,ans=0;
    cin>>a>>b>>c>>k;
    if(k>a)
    {
        if(k>a+b)
        {
            ans=a-(k-a-b);
        }
        else
            ans=a;
    }
    else
    ans+=k;
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 3652
#if 0
date +%Y.%m.%d

题解先咕着。
#endif
#include <cstdio>
#define debug(...) fprintf(stderr, __VA_ARGS__)

inline int input() { int x; scanf("%d", &x); return x; }

int main() {
	int k = input(), x = input();
	for(int i = x - k + 1; i <= x + k - 1; i ++)
		printf("%d ", i);
	puts("");
}


Measured memory_bytes: 128
import java.util.*;

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

        int n = sc.nextInt();
        Map<String, Integer> s = new HashMap<>();
        for(int i=0; i<n; i++) {
            String tmp = sc.next();
            if(s.containsKey(tmp)) {
                s.put(tmp, s.get(tmp)+1);
            } else {
                s.put(tmp, 1);
            }
        }

        String[] rst = {"AC", "WA", "TLE", "RE"};
        boolean isAC = false;
        boolean isWA = false;
        boolean isTLE = false;
        boolean isRE = false;
        for(String tmp2: s.keySet()) {
            if(tmp2.equals(rst[0])) isAC = true;
            else if(tmp2.equals(rst[1])) isWA = true;
            else if(tmp2.equals(rst[2])) isTLE = true;
            else if(tmp2.equals(rst[3])) isRE = true;
        }

        if(isAC) {
            System.out.println("AC" + " x " + s.get("AC"));
        } else {
            System.out.println("AC" + " x " + "0");
        }

        if(isWA) {
            System.out.println("WA" + " x " + s.get("WA"));
        } else {
            System.out.println("WA" + " x " + "0");
        }

        if(isTLE) {
            System.out.println("TLE" + " x " + s.get("TLE"));
        } else {
            System.out.println("TLE" + " x " + "0");
        }

        if(isRE) {
            System.out.println("RE" + " x " + s.get("RE"));
        } else {
            System.out.println("RE" + " x " + "0");
        }
    }
}


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

int main(){
	int n,k;
	cin >> n >> k;

	vector<vector<int>> A(k);
	rep(i, k){
		int d;
		cin >> d;
		rep(j, d){
			int kari;
			cin >> kari;
			A.at(i).push_back(kari);
		}
	}

	set<int> sunuke;
	rep(i,k){
		rep(j,A.at(i).size()){
			sunuke.insert(A.at(i).at(j));
		}
	}

	cout << n - sunuke.size() << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int main(){
    ll h,w;
    cin>>h>>w;
    ll ans =h*w/2LL;
    if(h*w%2) ans++;
    if(h==1||w==1){
        cout<<1<<endl;
        return 0;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
// -*- mode:c++; coding:utf-8; c-basic-offset:2; -*-
// ALDS1_2-C: Stable Sort

#include <cstring>
#include <algorithm>
#include <iostream>

struct Card {
  char suit;
  unsigned int rank;
  bool operator<(const Card& rhs) { return rank < rhs.rank; }
  bool same(const Card& rhs) { return rank == rhs.rank && suit == rhs.suit; }
};

std::ostream& operator<<(std::ostream& os, const Card& card)
{
  return os << card.suit << card.rank;
}

std::istream& operator>>(std::istream& is, Card& card)
{
  return is >> card.suit >> card.rank;
}

static void print_cards(const Card cards[], const unsigned int n)
{
  const char* sep = "";
  for (unsigned int i = 0u; i < n; ++i) {
    std::cout << sep << cards[i];
    sep = " ";
  }
  std::cout << std::endl;
}

static void bubble_sort(Card cards[], const unsigned int n)
{
  for (unsigned int j = 0u; j < n-1; ++j) {
    for (unsigned int i = n-1; i > j; --i) {
      if (cards[i] < cards[i-1]) {
        std::swap(cards[i], cards[i-1]);
      }
    }
  }
}

static void selection_sort(Card cards[], const unsigned int n)
{
  for (unsigned int i = 0u; i < n-1; ++i) {
    unsigned int min_j = i;
    for (unsigned int j = i+1; j < n; ++j) {
      if (cards[j] < cards[min_j]) {
        min_j = j;
      }
    }
    if (i != min_j) {
      std::swap(cards[i], cards[min_j]);
    }
  }
}

int main()
{
  unsigned int n;
  std::cin >> n;
  Card cards1[n], cards2[n];
  for (unsigned int i = 0u; i < n; ++i) {
    std::cin >> cards1[i];
  }
  //std::memcpy(cards2, cards1, sizeof(cards1));
  for (unsigned int i = 0u; i < n; ++i) {
    cards2[i] = cards1[i];
  }

  bubble_sort(cards1, n);
  print_cards(cards1, n);
  std::cout << "Stable" << std::endl; // bubble sort is stable

  selection_sort(cards2, n);
  print_cards(cards2, n);
  /*
  if (std::memcmp(cards1, cards2, sizeof(cards1)) == 0) {
    std::cout << "Stable" << std::endl;
  } else {
    std::cout << "Not stable" << std::endl;
  }
  */
  for (unsigned int i = 0u; i < n; ++i) {
    /*
    if (!(cards2[i].rank == cards1[i].rank &&
          cards2[i].suit == cards1[i].suit)) {
    */
    if (!cards2[i].same(cards1[i])) {
      std::cout << "Not stable" << std::endl;
      return 0;
    }
  }
  std::cout << "Stable" << std::endl;
}

// eof

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

int main(){
  int n,a=1;
  int count=0,flag=0;
  cin >> n;
  
  vector<int> vec(n);
  
  for(int i=0; i<n; i++){
    cin >> vec.at(i);
  }
  
  for(int i=0; i<n; i++){
    count++;
    if(vec.at(a-1)==2){
      flag=1;
      break;
    }else{
      a = vec.at(a-1);
    }
  }
  
  if(flag==1){
    cout << count << endl;
  }else{
	cout << "-1" << endl;
  }
}

Measured memory_bytes: 640
using System;
using System.Linq;
using System.Collections.Generic;
using System.Numerics;
using static System.Console;

class Program {
    internal static void Main(string[] args) {
        var N = int.Parse(ReadLine());
        var a = ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray();

        var ans = 0L;
        for (int i = 0; i < N; i++) {
            ans += a[i] - 1;
        }

        WriteLine(ans);
    }
}

Measured memory_bytes: 13408
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str(); }
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = INT_MAX / 2;
const int MOD = 1000000007;

typedef vector<ll> vl;
typedef vector<vl> vvl;

int main() {
	int N;
	cin >> N;
	vl a(N);
	REP(i, N) {
		cin >> a[i];
	}

	ll ans = 0;
	ll maxx = N + 1;
	while (maxx >= N) {
		ll sum = 0;
		maxx = 0;
		vl b(N, 0);
		REP(i, N) {
			b[i] = a[i] / N;
			sum += b[i];
		}
		REP(i, N) {
			a[i] -= b[i] * N;
			a[i] += sum - b[i];
			maxx = max(maxx, a[i]);
		}
/*
		cout << "a" << endl;
		REP(i, N) {
			cout << a[i] << " ";
		}
		cout << endl;
		cout << "b" << endl;
		REP(i, N) {
			cout << b[i] << " ";
		}
		cout << endl;
*/
		ans += sum;
//		cout << ans << endl;
	}

	cout << ans << endl;
	return 0;
}


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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    long long n;
    cin>>n;
    string ans;
    while(n--){
        ans=(char)(n%26+'a')+ans;
        n/=26;
    }
    cout<<ans;
}

Measured memory_bytes: 3596
#include<cstdio>
#include<algorithm>
using namespace std;
int n,tot,now,x[510],b[510],a[250010];
bool cmp(int a,int b){
	return x[a]<x[b];
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",x+i);
		if(a[x[i]]){
			puts("No");
			return 0;
		}
		a[x[i]]=i;
		b[++tot]=i;
	}
	sort(b+1,b+n+1,cmp);
	now=1;
	for(int k=1;k<=n;k++){
		int i=b[k],cnt=i-1;
		while(cnt&&now<x[i]){
			if(!a[now]){
				cnt--;
				a[now]=i;
			}
			now++;
		}
		if(cnt){
			puts("No");
			return 0;
		}
	}
	int now=n*n;
	for(int k=n;k;k--){
		int i=b[k],cnt=n-i;
		while(cnt&&now>x[i]){
			if(!a[now]){
				cnt--;
				a[now]=i;
			}
			now--;
		}
		if(cnt){
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	for(int i=1;i<=n*n;i++)
		printf("%d ",a[i]);
	return 0;
}

Measured memory_bytes: 2048