akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = 0;
		int b = 0;
		int c = 0;
		String delimeter = " ";
		List<Integer> list = new ArrayList<>();

		while(sc.hasNextInt()) {
			list.add(sc.nextInt());
		}

		Collections.sort(list);

		a = list.get(0);
		b = list.get(1);
		c = list.get(2);

		System.out.println(a + delimeter + b + delimeter + c);
	}
}

Measured memory_bytes: 26236
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;

int main() {
	int N;
	long double total = 0.0;
	long double answer = 0.0;
	cin >> N;
	int A[N];
	for(int i = 0; i < N; i++) cin >> A[i];
	for(int i = 0; i < N; i++) {
		total += 1.0/A[i];
	}

	answer = 1.0/total;
	cout << answer <<endl;
}

Measured memory_bytes: 256
use std::cmp::max;
use std::io::*;
use std::str::FromStr;

fn main() {
    let n: usize = read();
    let s: Vec<char> = read::<String>().chars().collect();
    let mut dp: Vec<i32> = vec![0; n + 1];
    for i in 0..n {
        dp[i + 1] = max(dp[i + 1], dp[i]);
        if s[i] == '0' && i > 0 && i < n - 1 && s[i - 1] == '1' && s[i + 1] == '1' {
            let mut prev = i - 1;
            let mut next = i + 1;
            while prev >= 0 && s[prev] == '1' {
                dp[i + 1] = max(
                    dp[i + 1],
                    if prev > 0 { dp[prev - 1] } else { 0 } + (i - prev) as i32,
                );
                if prev > 0 {
                    prev -= 1;
                } else {
                    break;
                }
            }
            while next < n && s[next] == '1' {
                dp[next] = max(
                    dp[next],
                    if i > 1 { dp[i - 2] } else { 0 } + (next - i) as i32,
                );
                next += 1;
            }
        }
    }
    println!("{}", dp[n]);
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}


Measured memory_bytes: 8948
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>    
#define inf 100000000
#define INF 9223372036854775807
#define EPS 1e-10
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r);
#define TYPE long long
#define MEMSET(a) memset(a,0,sizeof(a))
long long mod=(long long)1e09+7;

int in(void){
    int i;scanf("%d",&i);
    return i;
}
long long llin(void){
    long long i;scanf("%lld",&i);
    return i;
}
double din(void){
    double i;scanf("%lf",&i);
    return i;
}
void chin(char s[]){
    scanf("%s",s);
}
void print(int a){
    printf("%d\n",a);
}
void llprint(long long a){
    printf("%lld\n",a);
}
void dprint(double a){
    printf("%.10f\n",a);
}
void print2(int a,int b){
    printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
    return a>b?a:b;
}
long long min(long long a,long long b){
    return a<b?a:b;
}
int cmp(const void *a,const void *b){
    return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
    return *(TYPE *)b-*(TYPE *)a;
}
int char_cmp(const void *a,const void *b){
    return strcmp((char *)a,(char *)b);
}
int char_cmp_r(const void *a,const void *b){
    return strcmp((char *)b,(char *)a);
}
void swap(int *a,int *b){
    int t=*a;
    *a=*b;
    *b=t;
}
long long gcd(long long x,long long y){
    return x%y?gcd(y,x%y):y;
}
long long lcm(long long x,long long y){
    return x/gcd(x,y)*y;
}

// write codes below this
// when you use 'sort',
// make sure TYPE macro is correct

int main(void){
    int n,i,ans;
    char f[100][10];
    while(1){
        n=in();
        if(!n)break;
        rep(i,n)chin(f[i]);
        ans=0;
        rep(i,n-1){
            if(f[i][1]==f[i+1][1]&&f[i][0]!=f[i+1][0])ans++,i++;
        }
        print(ans);
    }
    return 0;
}



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

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<(n);i++)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

const ll MOD = 1000000007;
const int MAX=2000;
ll fact[MAX], fact_inv[MAX];

ll power(ll a, ll b){
	ll res=1;
	while(b>0){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}

ll comb(ll n, ll r){
	return (fact[n]*fact_inv[r])%MOD*fact_inv[n-r]%MOD;
}

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

    fact[0]=1;
    rep(i, n) fact[i+1]=fact[i]*(i+1)%MOD;
	fact_inv[n]=power(fact[n], MOD-2);
    FORR(i, 0, n) fact_inv[i]=fact_inv[i+1]*(i+1)%MOD;

    vl d(k+1);
    rep1 (i, k+1){
        if(i > n-k+1){
            d[i] = 0;
        }
        else{
            d[i] = comb(n-k+1, i);
            d[i] = d[i] * comb(k-1, i-1);
            d[i] = d[i] % MOD;
        }
    }
    rep1 (i, k+1){
        cout << d[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import sys

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def main():
    n, m = MI()
    ac = [False]*(n+1)
    wa = [0]*(n+1)
    for _ in range(m):
        temp = input().split()
        p, s = int(temp[0]), temp[1]
        if not ac[p]:
            if s == 'AC':
                ac[p] = True
            else:
                wa[p] += 1
    penalty = 0
    for i in range(n+1):
        if ac[i]:
            penalty += wa[i]
    print('{} {}'.format(sum(ac), penalty))

if __name__ == '__main__':
    main()

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

#define ALL(v) (v).begin(), (v).end()
#define rep(i, n) for (ll i = 0, __##i##_length = (n); i < __##i##_length; i++)
#define rep_reverse(i, n) for (ll i = (n)-1; 0 <= i; i--)
#define FOR(i, from, to) for (ll i = (from), __##i##_end = (to); i < __##i##_end; i++)
#define FOR_REVERSE(i, from, to) for (ll i = (to)-1, __##i##_end = (from); __##i##_end <= i; i--)
#define foreach(e, v) for (const auto e : (v))
#define vfree(v) std::vector<int>().swap(v)
#define DEBUG(x) cout << #x << " = " << (x) << endl

using namespace std;
typedef int64_t ll;
typedef vector<ll> llv;
typedef vector<llv> llvv;

int main()
{
    ll N;
    cin >> N;
    map<ll, ll> D;
    rep(i, N)
    {
        ll d;
        cin >> d;
        if (D.find(d) != D.end())
        {
            D[d] = D[d] + 1;
        }
        else
        {
            D[d] = 1;
        }
    }

    ll M;
    cin >> M;
    map<ll, ll> T;
    rep(i, M)
    {
        ll t;
        cin >> t;
        if (T.find(t) != T.end())
        {
            T[t] = T[t] + 1;
        }
        else
        {
            T[t] = 1;
        }
    }

    foreach (e, T)
    {
        ll diff = e.first;
        // cout << e.first << " " << e.second << " " << D[diff] << endl;
        if (D.find(diff) == D.end())
        {
            cout << "NO" << endl;
            return 0;
        }
        if (D[diff] < e.second)
        {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}


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

int main(){
  string a,b;
  cin>>a>>b;
int M,N,j;
  j=stoi(a+b);
    for(int i=0;i<1000;i++){
    if(i*i==j){
      cout<<"Yes"<<endl;
      break;
    }
      if(i==999){
        cout<<"No"<<endl;
      }
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <numeric>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)

int main() {
    int a, b, c, k;
    cin >> a >> b >> c >> k;

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

Measured memory_bytes: 3636
import fractions
a,b,c,d = map(int,input().split())
lcm = c*d // fractions.gcd(c,d)
A = ((a-1) // c) + ((a-1) // d) - ((a-1) // lcm) 
B = (b // c) + (b // d) - (b // lcm)
ans = B-A
print(b-a+1-ans)

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}


struct UnionFind {
  vector<int> data; // 根の場合は集合の大きさ*-1、子の場合は親の番号が入る
  UnionFind(int size) : data(size, -1) { }
  bool link(int x, int y) { //新たな併合を行うとtrue
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  int root(int x) { // 代表元を返す
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
};


const int MAX_N = 112345;
const int MAX_M = 112345;

struct Edge {
  int a, b;
  int id;
  int to;
};

Edge edge[MAX_M];
vector<Edge> g[MAX_N];
int outdeg[MAX_N];

void dfs(int cur, int prev, int eid) {
  for (auto nxt : g[cur]) if (nxt.b != prev) {
    dfs(nxt.b, cur, nxt.id);
  }

  if (prev != -1) {
    if (outdeg[cur] % 2 == 0) {
      outdeg[prev]++;
      edge[eid].to = cur;
    } else {
      outdeg[cur]++;
      edge[eid].to = prev;
    }
  }
}

int main2() {
  REP(i, MAX_N) g[i].clear();
  CLR(outdeg, 0);
  int N = nextInt();
  int M = nextInt();

  UnionFind uf(N);
  REP(i, M) {
    int a = nextInt() - 1;
    int b = nextInt() - 1;

    edge[i] = {a, b, i, b};
    if (uf.root(a) == uf.root(b)) {
      outdeg[a]++;
    } else {
      uf.link(a, b);
      g[a].push_back({a, b, i, 0});
      g[b].push_back({b, a, i, 0});
    }
  }
  if (M % 2 != 0) {
    cout << -1 << endl;
    return 0;
  }

  dfs(0, -1, -1);

    // cout << edge[i].a << " " << edge[i].b << " " << edge[i].to << endl;
  REP(i, M) {
    int from = edge[i].a;
    int to = edge[i].b;
    if (to != edge[i].to) swap(from, to);
    printf("%d %d\n", from + 1, to + 1);
  }
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


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

int main(){
	int a,b,c,d;

	cin >>a >>b >>c >>d;
	if(a<c){
		if(a+d>=b&&b+d>=c)cout<<"Yes"<<endl;
		else if(a+d>=c)cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
	else{
		if(c+d>=a)cout<<"Yes"<<endl;
		else if(c+d>=a)cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<utility>
#include<memory>
#include<cmath>

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define pb push_back

using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;
const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const int MAX_N=9;
const ll LINF=100000000000000000;

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
typedef int64_t ll;

int main(){
  ll n,m,a,b;
  cin>>n>>m;
  atcoder::scc_graph g(n);
  for(int i=0;i<m;i++){cin>>a>>b;g.add_edge(a,b);}
  vector<vector<int>> ans=g.scc();
  ll sz=ans.size();
  cout<<sz<<endl;
  for(int i=0;i<sz;i++){
    cout<<ans[i].size()<<" ";
    for(int j : ans[i]){
      cout<<j<<" ";
    }
    cout<<endl;
  }
}


Measured memory_bytes: 40564
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
BC_List = x = [list(map(int, input().split())) for i in range(Q)]

int_list = [0 for _ in range(10**5+1)]
sum = 0
for i in A:
   int_list[i] += 1
   sum += i

for B, C in BC_List:
    sum = sum + (C-B) * int_list[B]
    int_list[C] += int_list[B]
    int_list[B] = 0
    print(sum)


Measured memory_bytes: 100532
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const long long INF = 1LL << 60;

int main(){
    ll N;
    cin >> N;
    vector<vector<ll>> A(2, vector<ll>(N));
    for (int i = 0; i < 2; i++){
      for (int j = 0; j<N; j++)cin >> A[i][j];
    }

    vector<ll> top(N);
    top[0] = A[0][0];
    for (int i = 1; i < N; i++)top[i] = top[i-1] + A[0][i];

    vector<ll> under(N);
    under[N-1] = A[1][N-1];
    for (int i = N-2; i>=0; i--)under[i] = under[i + 1] + A[1][i];
    
    ll out = 0;
    for (int i = 0; i<N; i++){
      out = max(out, top[i] + under[i]);
    }
    cout << out << endl;
    return 0;
}

Measured memory_bytes: 3596
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=3005;
int n,mod,inv[N],bin[N],pw[N],g[N][N],ans;
int main(){
	scanf("%d%d",&n,&mod);
	inv[1]=1;
	for(int i=2;i<=n;++i)inv[i]=1ll*inv[mod%i]*(mod-mod/i)%mod;
	bin[0]=1;pw[0]=2;
	for(int i=1;i<=n;++i){
		bin[i]=(bin[i-1]<<1)%mod;
		pw[i]=1ll*pw[i-1]*pw[i-1]%mod;
	}
	for(int i=g[0][0]=1;i<=n;++i)
		for(int j=0;j<=i;++j)
			g[i][j]=((j?g[i-1][j-1]:0)+1ll*g[i-1][j]*(j+1))%mod;
	for(int i=0,C=1;i<=n;++i,C=1ll*C*(n-i+1)%mod*(mod-inv[i])%mod){
		int res=0;
		for(int j=0,k=1;j<=i;++j,k=1ll*k*bin[n-i]%mod)
			res=(res+1ll*g[i][j]*k)%mod;
		ans=(ans+1ll*res*pw[n-i]%mod*C)%mod;
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 34176
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<utility>
#include<cmath>
#include<string>
#include<cstring>
#include<map>
#include<queue>
#include<set>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) std::cout<<arg<<"\n"
#define prin2(arg1,arg2) std::cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) std::memset(arg,n,sizeof(arg))
#define mp(a,b) std::make_pair(a,b)
#define pb push_back
using std::cin;
using std::min;
typedef long long ll;
typedef std::pair<int,int> pi;
typedef std::vector<int> vi;
typedef std::set<int> si;
typedef std::string str;
const int INF=1e+9;
const ll INFLL=1e+17;
const ll MOD=1e+9+7;
ll Q,H,S,D,N;
int main(){
  cin>>Q>>H>>S>>D>>N;
  ll x=min(4*Q,min(2*H,S));
  if(2*x>D){
    prin((N/2)*D+(N%2)*x);
  }
  else{
    prin(N*x);
  }
  return 0;
}


Measured memory_bytes: 256
A,B,C,X,Y=map(int,input().split())
price = 0
a,b,c=0,0,0
if 2*C<=A:
    c+=X*2
    Y=max(0, Y-X)
    X=0
    
if 2*C<=B:
    c+=Y*2
    X=max(0, X-Y)
    Y=0
if C*2 < A+B:
    cc = min(X,Y)
    c+=cc*2
    X=max(0,X-cc)
    Y=max(0,Y-cc)
a=X
b=Y
print(A*a+B*b+C*c) 

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

using namespace std;

int main(void)
{
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);

	long long a, b, x;
	cin >> a >> b >> x;
	int e = 1;
	if (a != 0) {
		--a;
		e = 0;
	}
	cout << b / x - a / x + e << '\n';

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
// #include <regex> //正規表現
using namespace std;
#define rep(i,a,b) for(int i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
#define MOD 1000000007ll
#define INF 1000000000
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;
// グリッドグラフの移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

int N, W; cin >> N >> W;
VI w(N), v(N);
rep(i, 0, N) cin >> w[i] >> v[i];

// 全探索は 品物を選ぶ選ばないの O(2^N)
// ナップザックDP
// dp[i][j] = i 番目の品物まででの， 重さ j 以下での最大価値．サイズ O(NW)
// dp[0][0 ~ W] = 0
vector<vector<int64_t>> dp(N + 1, vector<int64_t>(W + 1, 0LL));

rep(i, 1, N+1){
    rep(j, 1, W + 1){
        if (w[i - 1] <= j) // 品物を選ぶことが可能
            // 選んだ場合と選ばない場合との比較
            dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w[i - 1]] + v[i -1]);
        else  // 選ぶことが不可能
            dp[i][j] = dp[i - 1][j];
    }
}

cout << dp[N][W] << "\n";
}

// 境界，出力文字列 チェック



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

int main(){
  int N, K, R, S, P;
  long long int total = 0;
  bool free;
  string T;

  cin >> N >> K;
  cin >> R >> S >> P;
  cin >> T;
  
  for(int i=0; i<K; i++){
    total+=((T[i]=='s')?R:0)+((T[i]=='r')?P:0)+((T[i]=='p')?S:0);
    free = false;
    for(int j=i+K; j<N; j+=K){
      if(!free && T[j-K]==T[j]){
        free = true;
        continue;
      }
      free = false;
      total+=((T[j]=='s')?R:0)+((T[j]=='r')?P:0)+((T[j]=='p')?S:0);
    }
  } 
  cout << total << "\n";
  return 0;
}


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

long long n;
vector<long long> ans;

void solve();
bool ch(long long x);

int main() {
  cin >> n;
  solve();
  for(int i = 0; i < ans.size(); ++i)
    cout << ans[i] << endl;
  return 0;
}

void solve() {
  long long l = 0, r = n;
  while(r - 1 > l) {
    long long now = (l + r) / 2;
    if(ch(now))
      r = now;
    else
      l = now;
  }
  for(long long i = r; i >= 1; --i)
    if(n >= i) {
      ans.push_back(i);
      n -= i;
    }
  assert(n == 0);
  reverse(ans.begin(), ans.end());
}

bool ch(long long x) {
  long long now = n;
  for(long long i = x; i >= 1; --i)
    if(now >= i) now -= i;
  return now <= 0;
}

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

#define LL long long
#define LD long double
#define SC(t,x) static_cast<t>(x)
#define AR(t) vector < t >
#define PII pair < int, int >
#define PLL pair < LL, LL >
#define PIL pair < int, LL >
#define PLI pair < LL, int >
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define PRF first
#define PRS second
#define INIT(ar,val) memset ( ar, val, sizeof ( ar ) )
#define lp(loop,start,end) for ( int loop = start; loop < end; ++loop )
#define lpd(loop,start,end) for ( int loop = start; loop > end; --loop )
#define lpi(loop,start,end) for ( int loop = start; loop <= end; ++loop )
#define lpdi(loop,start,end) for ( int loop = start; loop >= end; --loop )
#define qmax(a,b) (((a)>(b))?(a):(b))
#define qmin(a,b) (((a)<(b))?(a):(b))
#define qabs(a) (((a)>=0)?(a):(-(a)))

const int INF = 0x3fffffff;
const int SINF = 0x7fffffff;
const long long LINF = 0x3fffffffffffffff;
const long long SLINF = 0x7fffffffffffffff;
const int MAXN = 200007;
const int MAXM = 400007;

struct eT
{
	void setd ( int _u, int _v, int _l )
	{
		u = _u, v = _v, last = _l;
	}

	int u, v, last;
}edge[MAXM];

int n, m;
int ke, la[MAXN];

void init ();
void input ();
void work ();



int main()
{
	init();
	input();
	work();
}



void init ()
{
	// Init Everything Here

	ios::sync_with_stdio ( false );
}

void input ()
{
	// input method

	scanf ( "%d%d", &n, &m );
	int u, v;
	ke = 0;
	INIT ( la, -1 );
	lp ( i, 0, m ){
		scanf ( "%d%d", &u, &v );
		edge[ke].setd ( u, v, la[u] );
		la[u] = ke++;
		edge[ke].setd ( v, u, la[v] );
		la[v] = ke++;
	}
}

void work ()
{
	// main work

	bool t1, tn;
	lp ( now, 1, n ){
		t1 = tn = false;
		for ( int i = la[now]; ~i; i = edge[i].last ){
			if ( edge[i].v == 1 ) t1 = true;
			if ( edge[i].v == n ) tn = true;
		}

		if ( t1 && tn ){
			printf ( "POSSIBLE\n" );
			return;
		}
	}

	printf ( "IMPOSSIBLE\n" );
}

Measured memory_bytes: 5760
// ░░░░░░░░( •̪●)░░░░░░░░░░░░░░░░░░░░░░░░
// ░░░░░░███████ ]▄▄▄▄▄▄▄▄▃░░░▃░░░░ ▃░
// ▂▄▅█████████▅▄▃▂░░░░░░░░░░░░░░░░░
// [███████████████████].░░░░░░░░░░░░░░
// ◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤...░░░░░░░░░░░░

//PointBlank's code (⌐■_■)

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
#define repp(I, A, B) for(int I = A; I <= B; I++)
#define rep(I, A, B) for(int I = A; I < B; I++)
#define rrep(I, B, A) for(int I = B; I >= A; I--)
#define pb emplace_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define LB lower_bound
#define UB upper_bound
#define MP make_pair
#define mem(A, B) memset(A, B, sizeof(A));
#define mem0(A) memset(A, 0, sizeof(A));
#define quickio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define in_edges(M) repp(I, 1, M){ll A, B; cin >> A >> B; v[A].pb(B), v[B].pb(A);}
#define in_edges2(M) repp(I, 1, M){ll A, B; cin >> A >> B; v[A].pb(B);}
#define endl "\n"
#define debug(this) cerr<<"> "<<#this<<" : "<<this<<"\n"
#define bitsf(n) __builtin_popcount(n)
ll power(ll x, ll y); 

const ll MOD = 1000000007;
 
int main() //PointBlank's code ¯\_(ツ)_/¯
{
    ll a, b;
    cin >> a >> b;
    cout << a*b;
}
 
ll power(ll x, ll y)
{ 
    ll res = 1; x %= MOD;
    while(y > 0){if(y & 1) res = (res*x) % MOD; y = y>>1, x = (x*x) % MOD;} 
    return res; 
}


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

int main() {
  bool flag = true;
  for (int i = 0;i < 4;i++) {
    char S,a;
    cin >> S;
    // cout << S << a << endl;
    if (S == a) {flag = false;break;}
    a = S;
  }
  if (flag == false) {
    cout << "Bad" << endl;
  } else {
    cout << "Good" << endl;
  }
}



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

int main(){
    string s;
    cin >> s;
    int l = s.length();

    int a=l-1;
    int z=0;

    for(int i=1;i<=l;i++){
        if(s.at(l-i)=='A') a=l-i;
    }
    for(int i=0;i<l;i++){
        if(s.at(i)=='Z') z=i;
    }
    cout << z-a+1 << endl;
    return 0;
}

Measured memory_bytes: 640
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=2010;
int n,m,ans,a[N][N],up[N],L[N],R[N];
char s[N];
int main(){
    scanf("%d%d",&n,&m);ans=max(n,m);
    for(int i=1;i<=n;i++){
        scanf("%s",s+1);
        for(int j=1;j<=m;j++)
            a[i][j]=s[j]=='.'?0:1;
    }
    --n;--m;
    for(int i=1;i<=m;i++)L[i]=1,R[i]=m;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
            a[i][j]^=a[i+1][j]^a[i][j+1]^a[i+1][j+1];
    for(int i=1;i<=n;i++){
        int l=0,r=m+1;
        for(int j=1;j<=m;j++)
            if(a[i][j])up[j]=0,l=j,L[j]=1;
            else ++up[j],L[j]=max(L[j],l+1);
        for(int j=m;j;j--)
            if(a[i][j])r=j,R[j]=m;
            else {
                R[j]=min(R[j],r-1);
                ans=max((R[j]-L[j]+2)*(up[j]+1),ans);
            }
    }
    printf("%d\n",ans);
}

Measured memory_bytes: 17428
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		sc.close();
		System.out.println(Math.max(c - (a - b), 0));
	}
}


Measured memory_bytes: 23636
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")

#include<bits/stdc++.h>

using namespace std;

typedef long long  ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;

#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define mp make_pair
#define pb push_back
#define all(x) x.begin(), x.end()
#define ins insert
#define pi  3.14159265359
#define mod 1000000007
#define si(x) int(x.size())
#define FOOR(i, a, b)  for (int i=a; i<=(b); i++)
#define FOR(i, a)  for (int i=0; i<(a); i++)
#define FOORd(i,a,b)  for (int i = (b)-1; i >= a; i--)
#define FORd(i,a)  for (int i = (a)-1; i >= 0; i--)

int main()
{
    //ios_base::sync_with_stdio(false);
    //cin.tie(NULL);
    ll s;
    cin>>s;
    ll arr[s+1];
    for(int i=0;i<=s;i++)
    {
        if(i<3){
            arr[i]=0;
        }else{
        arr[i]=1;
        }
    }
    for(int i=3;i<=s;i++)
    {
        for(int j=3;j<=i;j++)
        {
            arr[i]=(arr[i]+arr[i-j])%mod;
        }
    }
    cout<<arr[s];
}



















Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    int n;
    int r;
    int ans=0;
    
    cin >> n >> r;
    
    if(n>=10){
        
        ans = r;
        
    } else {
        
        ans = r + 100 * (10-n);
        
    }
    
    cout << ans << endl;
    
    return 0;
    
}

Measured memory_bytes: 256
//2019.7.22 by ljz
//email 573902690@qq.com
//if you find any bug in my code
//please tell me
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define LL long long
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f
#define eps 1e-10
#define RG register
#define db double
#define lb long db
#define pc(x) __builtin_popcount(x)
typedef pair<int,int> Pair;
#define mp make_pair
#define fi first
#define se second
#define pi acos(-1.0)
#define pb push_back
#define gc getchar
#define Pi 2.0*acos(-1.0)
//inline char gc() {
//    static char buf[100000],*p1,*p2;
//    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
//}
inline int read() {
    res s=0,ch=gc();
    while(ch<'0'||ch>'9')ch=gc();
    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
    return s;
}
//inline int read() {
//    res s=0,ch=gc(),w=1;
//    while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=gc();}
//    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
//    return s*w;
//}
//inline LL Read() {
//    RG LL s=0;
//    res ch=gc();
//    while(ch<'0'||ch>'9')ch=gc();
//    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
//    return s;
//}
//inline LL Read() {
//    RG LL s=0;
//    res ch=gc(),w=1;
//    while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=gc();}
//    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
//    return s*w;
//}
//inline void write(RG __int128 x){
//    if(x>10)write(x/10);
//    putchar(x%10+'0');
//}
inline void swap(res &x,res &y) {
    x^=y^=x^=y;
}
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int N=5e2+10;
namespace MAIN{
    int n;
    int A[N][N];
    LL dp[N][N],pre[N][N],suf[N][N];
    inline void MAIN(){
        n=read();
        for(res i=1;i<=n;i++)
            for(res j=1;j<=n;j++)
                if(i!=j)A[i][j]=read();
        for(res i=1;i<=n;i++){
            for(res j=i+1;j<=n+1;j++){
                pre[i][j]=pre[i][j-1];
                for(res k=i;k<j;k++)pre[i][j]+=A[k][j];
            }
            for(res j=n;j>=i+1;j--){
                suf[i][j]=suf[i][j+1];
                for(res k=1;k<=i;k++)suf[i][j]+=A[j][k];
            }
        }
        for(res i=0;i<=n+1;i++)
            for(res j=0;j<=n+1;j++)
                dp[i][j]=INF;
        dp[0][0]=0;
        for(res i=0;i<=n;i++)
            for(res j=i;j<=n;j++)
                if(dp[i][j]!=INF)
                    for(res k=j+1;k<=n+1;k++)
                        dp[j][k]=min(dp[j][k],dp[i][j]+pre[j+1][k]+suf[j][k+1]-suf[i][k+1]);
        RG LL ans=INF;
        for(res i=0;i<=n;i++)ans=min(ans,dp[i][n+1]);
        printf("%lld\n",ans);
    }
}
int main(){
    MAIN::MAIN();
    return 0;
}

Measured memory_bytes: 7296
n = io.read("*n")
t = 1
a = {}
haszero = false
for i = 1, n do
  a[i] = io.read("*n")
  if a[i] == 0 then haszero = true end
end
if haszero then
  print(0)
  os.exit()
end
for i = 1, n do
  local lim = (1000000000 * 1000000000) // t
  if lim < a[i] then
    t = -1
    break
  end
  t = t * a[i]
end
print(t)


Measured memory_bytes: 4844
using System;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections.Generic;

class Program
{


	//Main
	static void Main(string[] args)
	{
		//読み込む
		string[] line = Console.ReadLine().Split(' ');
		long K = long.Parse(line[0]);
		long N = long.Parse(line[1]);

		long[] An = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

		//最小値を格納する変数
		long min = K;

		//ループ処理
		for(long i=0; i<N; i++){
				//まず、時計回りの場合の距離を求める
				long right = 0;
				if(i == 0){
						right = An[N-1] - An[0];
				}else{
						right = (K - An[i]) + An[i-1];
				}
				if(right < min){
						min = right;
				}

				//次に、反時計回りの場合の距離を求める
				long left = 0;
				if(i == N-1){
						left = An[N-1] - An[0];
				}else{
						left = An[i] + (K - An[i+1]);
				}
				if(left < min){
						min = left;
				}
		}

		Console.WriteLine(min);
	}
}



Measured memory_bytes: 36452
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void){
int n;
int ki=0,gu=0;
double odd;
scanf("%d",&n);
for(int count=1;count!=n+1;count++){
if(count%2==0){gu++;}
else{ki++;}
}
printf("%lf",(double)ki/n);
return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch RestoreTheTree | diff RestoreTheTree.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address RestoreTheTree.cpp && ./a.out

/*
 
 2/4/2019
 
 20:46-
 
 */

const int MAX_N=1e6+1;
VI G[MAX_N];
int N,M;

int D[MAX_N];
int res[MAX_N];
void solve() {
  REP(u,N) FORR(v,G[u]) {
    D[v]++;
  }
  
  MINUS(res);
  queue<int> Q;
  REP(u,N) if(D[u]==0) Q.emplace(u);
  assert(SZ(Q)==1);
  while(SZ(Q)) {
    int u=Q.front(); Q.pop();
    FORR(v,G[u]) {
      D[v]--;
      if(D[v]==0) res[v]=u,Q.emplace(v);
    }
  }
  REP(u,N) cout<<res[u]+1<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>N>>M;
  REP(i,N+M-1) {
    int u,v; cin>>u>>v;
    --u,--v;
    G[u].push_back(v);
  }
  solve();
  
  return 0;
}


Measured memory_bytes: 35200
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;

namespace Main
{
    class Program
    {
        static void Main(string[] args)
        {
            //ここから
            //int n=Readint();
            //string[] str = Console.ReadLine().Split(' ');

            int n = Readint();
            n %= 10;
            if (n == 3) Console.WriteLine("bon");
            else if (n == 0 || n == 1 || n == 6 || n == 8) Console.WriteLine("pon");
            else Console.WriteLine("hon");

            //ここまで
        }

        
        static int Readint()
        {
            return int.Parse(Console.ReadLine());
        }

        static long Readlong()
        {
            return long.Parse(Console.ReadLine());
        }

        static int Min(int a,int b)
        {
            if (a < b) return a;
            return b;
        }

        static int Max(int a, int b)
        {
            if (a > b) return a;
            return b;
        }
        

    }

}


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

int main () {
  int a[4];
  for (int i = 0; i < 4; i++) {
    cin >> a[i];
  }
  if (a[3] == 1) {
    cout << 1 << endl;
  }
  else {
    cout << 0 << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//pbds
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T>   using orderedSet =tree<T, null_type, less<T>,rb_tree_tag, tree_order_statistics_node_update>;
///use less_equal in pbds template to work as multiset...................................................
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define pb push_back
//BFS+DFS
#define boundary(i,j) (i>=0 && i<n && j>=0 && j<m)
int X[]={-1,1,0,0};
int Y[]={0,0,1,-1};
int x=1000002;
int spf[1000005];
void sieve()
{
    spf[1]=1;
    spf[2]=2;
    for(int i=4; i<=x; i+=2)
        spf[i]=2;
    for(int i=3; i<=sqrt(x); i+=2)
    {
        if(spf[i]==0)
        {
            for(int j=i*i; j<=x; j+=i*2)
                spf[j]=i;
        }
    }
    for(int i=3; i<=x; i+=2)
        if(spf[i]==0) spf[i]=i;

}
vector<int>vis(1000006,0);
int main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     sieve();
    int n;
    cin>>n;
    int a[n+5];
    int flag=0;
    for(int i=0; i<n; i++)
    {
        cin>>a[i];
        int temp=a[i];
        set<int>st;
        while(temp>1)
        {
            st.insert(spf[temp]);
            temp=temp/spf[temp];
        }
        for(auto it:st)
        {
            if(vis[it]) flag=1;
            vis[it]=1;
        }
    }
    if(flag==0)
    {
        cout<<"pairwise coprime"<<endl;
        return  0;
    }
    int num=a[0];
    for(int i=1; i<n; i++)
        num=__gcd(num,a[i]);
    if(num==1)
    {
        cout<<"setwise coprime"<<endl;
        return 0;
    }
    cout<<"not coprime"<<endl;
}




Measured memory_bytes: 15132
#include <bits/stdc++.h>
using namespace std ;
 
#define lli long long int
#define pb push_back

vector <string> v ;
set <string> s ;
map <string , int> m ;
vector <string> ans ;

int main ()
{
    int n ;
    cin >> n ;
    int c = 0 ;

    for (int i = 0 ; i < n ; i++)
    {
        string r ;
        cin >> r ;

        if (s.find(r) == s.end())
        {
            s.insert(r);
            m.insert(make_pair(r , 1));
            v.pb(r);
        }
        else
        {
            m[r] += 1 ;
        }
    }

    int mq = 0 ;


    for (int i = 0 ; i < v.size() ; i++)
    {
        if (m[v[i]] > mq)
        {
            ans.clear();
            ans.pb(v[i]);
            mq = m[v[i]] ;
        }
        else if (m[v[i]] == mq)
        {
            ans.pb(v[i]);
        }
    }

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

    for (int i = 0 ; i < ans.size() ; i++)
    {
        cout << ans[i] << endl ;
    }

    return 0 ;
}

Measured memory_bytes: 38256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
 int main(){
 int n;
 cin>>n;
 int x[n];
 rep(i,n) cin>>x[i];
vector<int>sum(200);  
 rep(p,200){
 	rep(i_cou,n){//100
    sum[p]+=pow(x[i_cou]-(p+1-100),2.0);
  //  cout<<sum[p]<<endl;
    }
 }
sort(sum.begin(),sum.end()); 
cout<<sum[0]<<endl;
 }

Measured memory_bytes: 256
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

    int n;
    cin >> n;

    if (n % 2 == 0) {
        cout << fixed << setprecision(8) << 1.0 / 2.0 << "\n";
    } else {
        cout << fixed << setprecision(8) << (double)(n / 2 + 1) / (double)n << "\n";
    }

    return 0;
}

Measured memory_bytes: 888
#include <stdint.h>
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-12;
static const double PI = acos(-1.0);
static const ll MOD = 1000000007;

#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(a) (a).begin(), (a).end()
#define DEBUG(x) cout << #x << ": " << x << endl

ll calc_score(long long D, const std::vector<long long> &c, const std::vector<std::vector<long long>> &s,
              const std::vector<long long> &t, vector<set<ll>> &last) {
  ll score = 0;
  REP(d, D) {
    ll i = t[d] - 1;
    score += s[d][i];
    last[i].insert(d + 1);
    REP(j, 26) {
      score -= c[j] * (d + 1 - *last[j].rbegin());
    }
  }
  return score;
}

ll area(const set<ll> &last, ll d, ll D) {
  auto it = last.lower_bound(d);
  auto x = *it - d;
  it--;
  auto y = d - *it;
  return x * y;
}

void solve(long long D, std::vector<long long> c, std::vector<std::vector<long long>> s, std::vector<long long> t,
           long long M, std::vector<long long> d, std::vector<long long> q) {
  vector<set<ll>> last(26);
  REP(j, 26) {
    last[j].insert(0);
  }
  ll score = calc_score(D, c, s, t, last);
  REP(j, 26) {
    last[j].insert(D + 1);
  }
  REP(i, M) {
    ll pre = t[d[i] - 1] - 1;
    ll next = q[i] - 1;
    t[d[i] - 1] = next + 1;
    ll diff = s[d[i] - 1][next] - s[d[i] - 1][pre];
    {
      auto it = last[next].insert(d[i]).first;
      it++;
      auto n = *it;
      it--;
      it--;
      auto p = *it;
      ll x = n - d[i];
      ll y = d[i] - p;
      diff += c[next] * x * y;
    }
    {
      last[pre].erase(d[i]);
      diff -= c[pre] * area(last[pre], d[i], D);
    }
    score += diff;
    cout << score << endl;
  }
}

int main() {
  long long D;
  scanf("%lld", &D);
  std::vector<long long> c(26);
  for (int i = 0; i < 26; i++) {
    scanf("%lld", &c[i]);
  }
  std::vector<std::vector<long long>> s(D, std::vector<long long>(26));
  for (int i = 0; i < D; i++) {
    for (int j = 0; j < 26; j++) {
      scanf("%lld", &s[i][j]);
    }
  }
  std::vector<long long> t(D);
  for (int i = 0; i < D; i++) {
    scanf("%lld", &t[i]);
  }
  long long M;
  scanf("%lld", &M);
  std::vector<long long> d(M);
  std::vector<long long> q(M);
  for (int i = 0; i < M; i++) {
    scanf("%lld", &d[i]);
    scanf("%lld", &q[i]);
  }
  solve(D, std::move(c), std::move(s), std::move(t), M, std::move(d), std::move(q));
  return 0;
}


Measured memory_bytes: 4740
#include <bits/stdc++.h>
using namespace std;
#define null NULL
#define mp make_pair
#define pb(a) push_back(a)
#define sz(a) ((int)(a).size())
#define all(a) a.begin() , a.end()
#define fi first
#define se second
#define relaxMin(a , b) (a) = min((a),(b))
#define relaxMax(a , b) (a) = max((a),(b))
#define SQR(a) ((a)*(a))
#define PI 3.14159265358979323846
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

const int MAXN = 100010;

int par[MAXN];

int GetPar(int a){
  return par[a] == a ? a : par[a] = GetPar(par[a]);
}

void Merge(int a, int b){
  par[GetPar(a)] = GetPar(b);
}

int n;
int x[MAXN], y[MAXN];

bool CmpX(const int& f, const int& s){
  return x[f] < x[s];
}

bool CmpY(const int& f, const int& s){
  return y[f] < y[s];
}

int Cost(int a, int b){
  return min(abs(x[a] - x[b]),
             abs(y[a] - y[b]));
}

vector<pair<int, pii>> edj;

int main(){
  for(int i = 0;i < MAXN;++i)
    par[i] = i;

  scanf("%d", &n);
  for(int i = 0;i < n;++i)
    scanf("%d%d", &x[i], &y[i]);

  vi nal(n);
  for(int i = 0;i < n;++i) nal[i] = i;

  sort(all(nal), CmpX);
  for(int i = 1;i < n;++i)
    edj.pb(mp(Cost(nal[i - 1], nal[i]),
              mp(nal[i - 1], nal[i])));

  sort(all(nal), CmpY);
  for(int i = 1;i < n;++i)
    edj.pb(mp(Cost(nal[i - 1], nal[i]),
              mp(nal[i - 1], nal[i])));

  sort(all(edj));
  ll ans = 0;
  for(const auto& e : edj)
    if(GetPar(e.se.fi) != GetPar(e.se.se)){
      ans += e.fi;
      Merge(e.se.fi, e.se.se);
    }

  cout << ans << '\n';

  return 0;
}


Measured memory_bytes: 6516
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <string>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;

#define N 100000;

int main()
{
	int n;
	int a;
	a = N;
	cin >> n;
	for (int i = 0; i < n; ++i)
	{
		a *= 1.05;
	if(a % 1000 != 0){
		a += 1000 - (a % 1000);
	}
}
	cout << a << endl;
}

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

int main(){
  string S;
  cin >>S;
  bool suc = 1;
  for(int i=0;i<S.size();i++){
    if(i%2 == 0){
      if(S[i] == 'R' || S[i] == 'U' || S[i]  == 'D'){
      }else{
        suc = 0;
      }
    }else{
      if(S[i] == 'L' || S[i] == 'U' || S[i]  == 'D'){
      }else{
        suc = 0;
      }
    }
  }
  
  if(suc) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

  int ans = 0;
  string s;
  cin >> s;
  for(int i = 0; i < (int)s.size() / 2; i++){
  if (s[i] != s[s.size() - 1 - i]){
  ans++;
  }
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int a, b;
	scanf("%d%d",&a, &b);
	if (a >= 9 || b >= 9) {
		printf(":(");
		return 0;
	}
	else {
		printf("Yay!");
		return 0;
	}
	return 0;
}

Measured memory_bytes: 128
import std.stdio;
import std.ascii;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.random;
import std.regex;
import std.typecons;
import core.bitop;

const INF = 1 << 28;

int R, C;
string[] F;

void input() {
    scanf("%d %d\n", &R, &C);
    F = new string[R];
    foreach (i; 0 .. R) {
        F[i] = readln.chomp;
    }
}

int calc() {
    auto dp = new int[][](2, 1 << C);
    foreach (i; 0 .. 2) dp[i][] = -INF;
    int p = 0, q = 1;
    dp[p][0] = 0;
    foreach (y; 0 .. R) {
        foreach (x; 0 .. C) {
            dp[q][] = -INF;
            for (int bit = 0; bit < (1 << C); bit++) {
                if (dp[p][bit] < 0) continue;
                int l = (bit & ((1 << x) - 1)).popcnt,
                    r = (bit & ~((1 << x) - 1)).popcnt;

                int f() {
                    int ret = 0;
                    if (x >= 1 && l >= 1 && (bit & (1 << (x - 1))) && F[y][l - 1] == F[y][l]) ret++;
                    if (y >= 1 && r >= 1 && (bit & (1 << x)) && F[y - 1][$ - r] == F[y][l]) ret++;
                    return ret;
                }

                if (l + 1 <= F[y].length) {
                    int nbit = bit | 1 << x;
                    dp[q][nbit] = max(dp[q][nbit], dp[p][bit] + f());
                }
                if (C - x - 1 >= F[y].length - l) {
                    int nbit = bit & ~(1 << x);
                    dp[q][nbit] = max(dp[q][nbit], dp[p][bit]);
                }
            }
            p = !p; q = !q;
            //writeln(dp[p].reduce!max);
        }
    }
    return dp[p].reduce!max;
}

void solve() {
    writeln(calc * 2);
}

void main() {
    input; solve;
}

Measured memory_bytes: 1504
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>

/*  j
   m t w u f 
a
p
k
  1...N
   Fijk

 */
using namespace std;

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

    boost::multi_array<bool, 2> F(boost::extents[N][10]);
    for (auto p = F.data(); p < (F.origin() + F.num_elements()); ++p) {
        std::cin >> *p;
    }

    boost::multi_array<int64_t, 2> P(boost::extents[N][11]);

    for (auto p = P.data(); p < (P.origin() + P.num_elements()); ++p) {
        std::cin >> *p;
    }

    int64_t maxP = INT64_MIN;

    for (int64_t b = 1; b < (1<<10); ++b) {
        // 自分の営業時間帯のパタン網羅
        int64_t p = 0;
        for (int n = 0; n < N; ++n) {
            //店ごとに重複回数を調べる
            int count = 0;
            for (int d = 0; d < 10; ++d) {
                if (F[n][d] && (b & (1<<d))) {
                    // 同時営業
                    count++;
                }
            }
            p += P[n][count];
        }

        maxP = std::max(maxP, p);
    }

    std::cout << maxP << std::endl;

    return 0;
}


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

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


int main(){
	ll n, a, b;

	cin >> n >> a >> b;

	ll ans = n/(a+b);
	ans *= a;
	if((n%(a+b))>a) ans += a;
	else ans += n%(a+b);

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less

#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define FASTIO ios::sync_with_stdio(0); cin.tie(0);
#define show(x) cout << #x << " = " << x << "\n"
#define mem( a , b ) memset( a , b , sizeof a )
#define popcnt(x) __builtin_popcount(x)
#define all(x) x.begin() , x.end()
#define mod(x,m) ((x%m + m )%m)
#define SZ(a) (int)a.size()
#define ll  long long
#define ld  long double
#define vii vector  <ll>
#define dqi deque   <ll>
#define sii set     <ll>
#define vpi vector  <pii>
#define mii map     <ll,ll>
#define pii pair    <ll,ll>
#define pi  pair    <int,int>
#define pb  push_back
#define F   first
#define S   second
#define L   length()
#define OO  (ll)1e18
#define lSOne(x)(x&-x)
#define EPS 1e-20
using namespace std;
using namespace __gnu_pbds;
void ONLINE__JUDGE();

typedef tree<ll, null_type, less<ll>, rb_tree_tag,
tree_order_statistics_node_update> ordered_set;
pii swapii( pii pr ){ return { pr.S , pr.F }; }
ll binEXP( ll x , ll pw , ll MOD = LLONG_MAX );
int dx[] = {  0 ,  0 , -1 , +1 , -1 , +1 , -1 , +1 };
int dy[] = { -1 , +1 ,  0 ,  0 , -1 , +1 , +1 , -1 };

const ll MOD = 1e9 + 7;
const ll MAX = 2e6 + 7;

bool ok( ll n ){
    int cnt = 0;
    while ( n ){
        cnt++; n /= 10;
    }
    return cnt&1;
}

int main()
{
    FASTIO //ONLINE__JUDGE();

    ll x , cnt = 0; cin >> x;
    for ( int i = 1; i <= x; ++i ){
        if ( ok(i) ) cnt++;
    }
    cout << cnt;
    return 0;
}

void ONLINE__JUDGE()
{
    #ifndef ONLINE_JUDGE
    freopen( "inp.c"         , "r" , stdin  );
    //freopen( "OutPut.txt"   , "w" , stdout );
    #endif // ONLINE_JUDGE
}

ll binEXP( ll x , ll pw , ll MOD )
{ ll res=1; while(pw>0){ pw%2 ? res *= x : 0; x *= x; x%=MOD; pw /= 2; res%= MOD; } return res%=MOD; }


Measured memory_bytes: 256