akhauriyash/Code-Regression huggingface dataset:
N=int(input())
A=list(map(int,input().split()))
s=0
t=0
for i in range(N):
  t+=A[i]
for i in range(1,N,2):
  s+=A[i]
X=[0]*N
X[0]=t-2*s
for i in range(N-1):
  X[i+1]=2*A[i]-X[i]
for i in range (N):
  print(X[i],end=" ")
  
  
  

Measured memory_bytes: 14028
n,m = map(int,input().split())
dp = [10**9]*(2**n)
dp[0] = 0
for _ in range(m):
  a,_ = map(int,input().split())
  c = list(map(int,input().split()))
  t = 0
  for x in c:
    t |= 1<<(x-1)
  for b in range(2**n):
    if dp[b|t] > dp[b]+a:
      dp[b|t] = dp[b] + a
if dp[-1] > 10**8:
  print(-1)
else:
  print(dp[-1])


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

int main()
{
    int n, l, i, sum=0;

    cin>>n>>l;
    l = l-1;

    int f[n];

    for(i=1; i<=n; i++)
    {
        f[i] = l+i;
        sum = sum + f[i];
    }
    if((f[1] <= 0 && f[n] > 0) || (f[n] >=0 && f[1] <0))
    {
        cout<<sum;
    }
    else if(f[n] < 0)
    {
        sum = sum - f[n];
        cout<<sum;
    }
    else if(f[1] > 0 && f[n] > 0)
    {
        sum = sum - f[1];
        cout<<sum;
    }


}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <set>
#include <vector>
#include <map>
#include <cstdio>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <cassert>
#include <climits>
using namespace std;
typedef long long ll;
#define DEBUG
#ifdef DEBUG
	#define debug printf
#else
	#define debug(...)
#endif
const ll maxn = 1e5 + 5;
ll a[maxn],b[maxn],sum1,sum2;
int main(int argc, char const *argv[])
{
	ll n;
	cin>>n;
	for(ll i = 0;i < n; ++i)
	{
		scanf("%lld",&a[i]);
		sum1 += a[i];
	}
	for(ll i = 0;i < n; ++i)
	{
		scanf("%lld",&b[i]);
		sum2 += b[i];
	}
	if(sum1 < sum2)
	{
		printf("-1\n");
		return 0;
	}
	ll sum = sum1 - sum2;
	priority_queue< ll,vector<int>,greater<int> > v; 
	ll ans = 0;
	ll ret = 0;
	for(ll i = 0;i < n; ++i)
	{
		if(a[i] < b[i])
		{
			ret++;
		}
		else
		{
			v.push(a[i] - b[i]);
		}
	}
	ll p = n - ret;
	while(!v.empty() && sum >= 0)
	{
		ll x = v.top();
		v.pop();
		// printf("x = %lld\n",x);
		if(sum >= x)
		{
			sum -= x;
			ans++;
		}
		else
		{
			break;
		}
	}//p - ans
	printf("%lld\n",ret + p - ans);
	return 0;
}

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

int main() {
  int X;
  cin >> X;
  int n = 1;
  
  while(true){
    if((n * X) % 360 == 0){
      cout << n << endl;
      break;
    }
    else{
      n++;
    }
  }
}

Measured memory_bytes: 3640
s = input()
n = len(s)
l = (n - 1)//2 - 1
r = (n + 3) //2 -1

s1 = s[:l+1]
s2 = s[r:]

sr = s[::-1]
s1r = s1[::-1]
s2r = s2[::-1]

if s == sr and s1 == s1r and s2 == s2r:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
H,W = map(int,input().split())
S = [list(input().split()) for _ in range(H)]
#print(S)
al=[chr(ord('A') + i) for i in range(26)]
for h in range(H):
  for w in range(W):
    if S[h][w] == "snuke":
      print(al[w],h+1,sep="")

Measured memory_bytes: 3060
#![allow(non_snake_case)]

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

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

fn gcd(a: i64, b: i64) -> i64 {
    if b == 0 {
        a
    } else {
        gcd(b, a%b)
    }
}

fn main() {
    let N: usize = read_line().parse().unwrap();
    let A = read_vec();

    let mut left = vec![0; N];
    let mut right = vec![0; N];

    left[0] = A[0];
    for i in 1..N {
        left[i] = gcd(left[i-1], A[i]);
    }
    right[N-1] = A[N-1];
    for i in (0..N-1).rev() {
        right[i] = gcd(right[i+1], A[i]);
    }

    let mut max = right[1];
    for i in 1..N-1 {
        max = std::cmp::max(max, gcd(left[i-1], right[i+1]));
    }
    max = std::cmp::max(max, left[N-2]);
    println!("{}", max);
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}

int cnt[5];

int main(){
	rep(i,3){
		int a,b;
		cin >> a >> b;
		cnt[a]++;
		cnt[b]++;
	}
	bool f = true;
	rep(i,4){
		if(cnt[i+1]>=3)f = false;
	}
	if(f)cout << "YES" << endl;
	else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include <stdio.h>
#include<algorithm>
#include<cstring>
#include <string>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>
#include<bits/stdc++.h>
#include <set>
#define ll   long long
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#define inf 0x3f3f3f
#define pi 3.1415926535898
using namespace std;
const int N=1e5+10;
const int mod=1e9+7;

int main()
{
    ll sum=0;
    int a;
    while(scanf("%1d",&a)!=EOF)
    {
        sum+=a;
    }
    if(sum%9==0)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    return 0;
}


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

typedef long long ll;

#define REP(i,n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define In(i) cin >> i;

int main(){
    int N,M,K,A;
    cin >> N >> M;

    int foods[M] = {0};

    for(int i = 0; i < N; i++){
        cin >> K;
        for(int j = 0; j < K; j++){
            cin >> A;
            foods[A-1]++;
        }
    }

    

    int count = 0;

    for(int i = 0; i < M; i++){
        if(foods[i] == N) count++;
    }

    cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#pragma GCC optimize(2)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define rep(i,a,b) for(int i = (a);i <= (b);i++)
#define pii pair<int,int>
#define pll pair<long long, long long>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int maxn = 2e5 + 5;
const double eps = 1e-8;
const double pi = acos(-1.0);
ll gcd(ll a,ll b){return !b?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a * b / gcd(a,b);}
ll poww(ll x,ll y,ll p){ll ans = 1;while(y){if(y & 1) ans = ans * x % p;x = x * x % p;y >>= 1;}return ans % p;}
bool isp(ll x){if(x < 2) return 0; for(ll i = 2;i * i <= x;i++){if(x % i == 0) return 0;}return 1;}
int a,b;
void solve(){
	cout << max(0,a-b*2) << endl;
} 
int main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> a >> b;
	solve();		
	return 0;
}
//do smt instead of nothing! never give up!

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long 
using namespace std;
const int N=55;
int a[N],sum;
signed main()
{
    int n;
    scanf("%lld",&n);
    for(int i=1;i<=n;i++)
        scanf("%lld",&a[i]);
    for(int i=1;i<=n;i++)
        for(int j=i+1;j<=n;j++)
            sum+=a[i]*a[j];
    cout<<sum<<endl;
    return 0;
}

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

int main() {
int n;
  string s;
  
  cin >>n;
  cin >>s;
  
  string kekka="No";
  int hantei=0;
  
  if(n%2==0){
    for(int i=0;i<n/2;i++){
      if(s.at(i)!=s.at(i+n/2)){
      break;}
      if(i==(n/2)-1){hantei=1;}
    }
    if(hantei==1){
    kekka="Yes";}
    
  }

  cout<<kekka<<endl;
  
  return(0);
}


Measured memory_bytes: 256
#include<algorithm>
#include<cstdio>
#include<functional>
#include<iostream>
#include<cfloat>
#include<climits>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<time.h>
#include<vector>
using namespace std;
int main()
{
	int x;
	long long mod=1e9+7;
	long long ans=1;
	cin >> x;
	for (long long i=1;i<=x;i++)
	{
		ans*=i;
		ans%=mod;
	}
	cout << ans << endl;
	system("pause");
	return 0;
}

Measured memory_bytes: 504
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
using namespace std;

int main() {
	int n, int_x;
	int out = 0;
	double x = 0.0;
	vector<int> a;
	string buf;
	cin >> n;
	while (getline(cin, buf, ' ')) {
		x += stof(buf) / double(n);
		a.push_back(stoi(buf));
	}
	int_x = int(round(x));
	for (size_t i = 0; i < a.size(); ++i) {
		out += pow(int_x - a[i],2.0);
	}

	cout << out << endl;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long

struct UnionFind{
    vector<int> data;
    /* constructor */
    UnionFind(int sz){ data.assign(sz,-1); }
    /* merge the set to which x belongs and the set to which y belongs */
    bool unite(int x,int y){
        x = find(x); y = find(y);
        if (x == y) return false;
        if (data[x] > data[y]) swap(x, y);
        data[x] += data[y];
        data[y] = x;
        return true;
    }
    /* find the root of k */
    int find(int k){
        if (data[k] < 0) return k;
        return data[k] = find(data[k]);
    }
    /* calculate the size of the set to which k belongs */
    int size(int k){ return -data[find(k)]; }
};

int main(void){
	int H, W; cin >> H >> W;
	vector<string> S(H);
	for (auto& si : S) cin >> si;

	UnionFind uf(H * W);
	for (int i = 0; i < H; ++i){
		for (int j = 0; j < W; ++j){
			int id = W * i + j;
			if (j != W - 1){ // 右
				int r = id + 1;
				if (S[i][j] != S[i][j + 1])
					uf.unite(id, r);
			}
			if (i != H - 1){ // 下
				int d = id + W;
				if (S[i][j] != S[i + 1][j])
					uf.unite(id, d);
			}
		}
	}

	map<int, int> b, w;
	for (int i = 0; i < H; ++i){
		for (int j = 0; j < W; ++j){
			int id = i * W + j;
			if (S[i][j] == '.') w[uf.find(id)]++;
			else b[uf.find(id)]++;
		}
	}

	ll res = 0;
	for (auto p : b){
		int s = p.first, cb = p.second;
		int cw = w[s];
		res += (ll)cb * cw;
	}

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 17124
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define rep(i, s, N) for(ll i{s}; i < N; i++)
#define rem(i, N, s) for(ll i{N}; i > s; i--)
using namespace std;using ll = long long int;using ld = long double;using P = pair<ll,ll>;const int MOD = (int)1e9+7;const string rt = "\n";const string sp = " ";/* 最大公約数 */template<typename T> T gcd(T a, T b){return b != 0 ? gcd(b, a % b) : a;}/* UnionFind */template<typename T> struct UnionFind{vector<T> par;UnionFind(T n) : par(n, -1){}void init(T n){par.assign(n, -1);}T root(T x){if (par[x] < 0) return x;else return par[x] = root(par[x]);}bool issame(T x, T y){return root(x) == root(y);}bool merge(T x, T y){x = root(x); y = root(y);if(x == y) return false;if(par[x] > par[y]) swap(x, y);par[x] += par[y];par[y] = x;return true;}int size(int x) {return -par[root(x)];}};/* コンビネーション */template<typename T> ll combpm(T N_, T C_) {const int NUM_=400001;static ll fact[NUM_+1],factr[NUM_+1],inv[NUM_+1];if (fact[0]==0) {inv[1]=fact[0]=factr[0]=1;for (int i=2;i<=NUM_;++i) inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD;for (int i=1;i<=NUM_;++i) fact[i]=fact[i-1]*i%MOD, factr[i]=factr[i-1]*inv[i]%MOD;}if(C_<0 || C_>N_) return 0;return factr[C_]*fact[N_]%MOD*factr[N_-C_]%MOD;}/* 多次元ベクター */template<class T>vector<T> mvec(size_t a){return vector<T>(a);}template<class T, class... Ts>auto mvec(size_t a, Ts... ts){return vector<decltype(mvec<T>(ts...))>(a, mvec<T>(ts...));}/* 多次元デック */template<class T>deque<T> mdeq(size_t a){return deque<T>(a);}template<class T, class... Ts>auto mdeq(size_t a, Ts... ts){return deque<decltype(mdeq<T>(ts...))>(a, mdeq<T>(ts...));}/* テスト関数 */void test(ll n){cout << "test" << n << endl;}/* 小数点以下 */void fixsp(ll n){cout << fixed << setprecision(n);}void defsp(ll n){cout << defaultfloat << setprecision(n);}/* 重み付きUnionFind */struct WUnionFind {vector<int> par;vector<int> rank;WUnionFind(int n = 1) {init(n);}void init(int n = 1) {par.resize(n); rank.resize(n);for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0;}int root(int x) {if (par[x] == x) {return x;}else {int r = root(par[x]);return par[x] = r;}}bool issame(int x, int y) {return root(x) == root(y);}bool merge(int x, int y) {x = root(x); y = root(y);if (x == y) return false;if (rank[x] < rank[y]) swap(x, y);if (rank[x] == rank[y]) ++rank[x];par[y] = x;return true;}};/* IO高速化 */void fastio(){ios::sync_with_stdio(false);cin.tie(NULL);}
/* ここからコード開始 */

int main(){
  fastio;
  ll K;
  cin >> K;
  cout << K/2*((K+1)/2) << rt;
}

Measured memory_bytes: 256
package main

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

func main() {
	n := readI()
	a := make(map[int]bool)
	for i := 0; i < n; i++ {
		tmp := readI()
		if _, ok := a[tmp]; ok {
			fmt.Println("NO")
			return
		}
		a[tmp] = true
	}
	fmt.Println("YES")
}

/*-----------Input utils-----------*/

var sc = bufio.NewScanner(os.Stdin)

func init() {
	if len(os.Args) >= 2 {
		if os.Args[1] == "debug" {
			debug()
		}
	}
	const buf = 200100
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, buf), buf)
}

func debug() {
	testFile, err := os.Open("./test/sample-1.in")
	if err != nil {
		fmt.Fprintln(os.Stderr, "There is no testfile.")
		os.Exit(1)
	}
	sc = bufio.NewScanner(testFile)
}

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

func readR() []rune {
	return []rune(readS())
}

func readI() int {
	i, _ := strconv.Atoi(readS())
	return i
}

func readF() float64 {
	f, _ := strconv.ParseFloat(readS(), 64)
	return f
}


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

using namespace std;

#define int long long

signed main() {
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  string a, b;
  cin >> a >> b;
  b.pop_back();
  cout << (a == b ? "Yes" : "No") << '\n';  

  return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define PB push_back
#define MP make_pair
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
const double PI=acos(-1.0);
const int INF=1e9;
const double EPS=1e-10;
const ll MOD=1e9+7;


int main(){
int H,W,h,w,cell;
  cin>>H>>W>>h>>w;
  cell=(H-h)*(W-w);
  if(H<=h||W<=w)cell=0;
  cout<<cell<<endl;
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
//inline int in() { int x; scanf("%d",&x); return x;}
inline ll in() { ll x; cin >> x; return x; }
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;

vector<int> to[2505];
vector<int> rto[2505];
bool reachablefrom1[2505];
bool reachableToN[2505];
bool ok[2505];

void dfs(int v) {
  if (reachablefrom1[v]) return;
  reachablefrom1[v] = true;
  for (int u : to[v]) {
    dfs(u);
  }
}
void rdfs(int v) {
  if (reachableToN[v]) return;
  reachableToN[v] = true;
  for (int u : rto[v]) {
    rdfs(u);
  }
}

int main() {
  int n=in();
  vi a(n);
  cin>>a;
  float ans=0;
  rep(i,n) ans+=1/(float)a[i];
  cout<<1/ans<<endl;
  return 0;
}


Measured memory_bytes: 384
#pragma region cp-helper
#include <bits/stdc++.h>
using namespace std;
#define AC ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long
#define ull unsigned long long
#define ii pair<int, int>
#define lll pair<ll, ll>
#define vi vector<int>
#define vvi vector<vi>
#define vl vector<ll>
#define vll vector<lll>
#define vvl vector<vl>
#define vii vector<ii>
#define all(a) a.begin(), a.end()
#define qsort(a) sort(all(a))
#define qsortd(a) sort(all(a), greater<>())
#define qsortf(a, f) sort(all(a), f)
#define pb(n) push_back(n)
#define eb(n) emplace_back(n)
#define pp(a, b) emplace_back(a, b)
#define umap unordered_map
#define nl '\n'
#define fileio(in, out) freopen(in, "r", stdin); freopen(out, "w", stdout)
#define qmod %mod
#define pls int
#define give main()
const int mod = 1000000007;
#pragma endregion

pls give {
    AC;
    int n;
    cin >> n;
    cout << "ABC" << n;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int s1s2s3;
  
  cin >> s1s2s3;
  
  int dig100 = s1s2s3 / 100;
  int dig10 = (s1s2s3 - dig100 * 100) / 10;
  int dig1 = s1s2s3 - dig100 * 100 - dig10 * 10;
  
  cout << dig100 + dig10 + dig1  << endl;
}

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

int main()
{
  int n;
  std::cin >> n;
  while (true) {
    std::vector<long long> dp(40);
    dp[0] = 1;
    for ( int now = 0; now < n; now++ ) {
      for ( int next = now + 1; next <= std::min(n, now + 3); next++ ) {
        dp[next] += dp[now];
      }
    }
    std::cout << (dp[n] + 3650 - 1) / 3650 << std::endl;
    std::cin >> n;
    if ( n == 0 ) break;
  }
  return 0;
}



Measured memory_bytes: 3100
#include <iostream>
#include<string.h>
#include<vector>
using namespace std;

#define rpt(i, n) for(i = 0; i < (n); i++)
typedef long long ll;

int main(void) {
	ll a, b;

	cin >> a >> b;
	if (a == b) {
		cout << a;
	}
	else if ((a + b) % 2 == 0) {
		cout << (a + b) / 2;
	}
	else {
		cout << "IMPOSSIBLE";
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ios::sync_with_stdio(false);cin.tie(0);
    ll n;cin>>n;
    vector <vector <ll>> vec(n,vector <ll> (3,0));
    for(int i=0;i<n;i++){
		ll x,y,z;cin>>x>>y>>z;
		vec[i][0]=x;
		vec[i][1]=y;
		vec[i][2]=z;
    }

    vector <vector <ll>> dp(n,vector <ll> (3,0));
    dp[0][0]=vec[0][0];
    dp[0][1]=vec[0][1];
    dp[0][2]=vec[0][2];
    for(int i=1;i<n;i++){
		for(int j=0;j<3;j++){
			for(int k=0;k<3;k++){
				if(j!=k){
					dp[i][j]=max(dp[i][j],vec[i][j]+dp[i-1][k]);
				}

			}
		}
    }
    ll ans=max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 11264
N = int(input())
As = list(map(int,input().split()))

if(N == 0):
    if(As[0] == 1):
        print(1)
    else:
        print(-1)
else:
    flag = True
    if(As[0] != 0):
        flag = False
    if(flag):
        D = [[0]*3 for i in range(N+1)]
        D[0] = [1,1,0] # mind maxD Ed
        for i in range(1,N+1):
            if(As[i] > 2*D[i-1][1]):
                flag = False
                break
            else:
                D[i][0] = max(0,D[i-1][0] - As[i])
                D[i][1] = min(2*D[i-1][1] - As[i],1 << i)
                D[i][2] = As[i]
    if(flag):
        D[N][1] = 0
        maxcnt = 0
        for i in range(N,-1,-1):
            depthmax = D[i][1] + D[i][2]
            maxcnt += depthmax
            if(i > 0):
                D[i-1][1] = min(D[i-1][1],depthmax)
        print(maxcnt)
    else:
        print(-1)


Measured memory_bytes: 678200
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder2 {
	class Program {
		static void Main(string[] args) {

		var inputArray = retreiveLongArray();
			var inputCount = 2;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}
			long N = inputArray[0];
			long K = inputArray[1];

			var teleDic = new Dictionary<long, long>();
			var input = retreiveLongArray();
			for (int i = 1; i <= N; i++) {
				teleDic.Add(i, input[i - 1]);
			}

			long loopCount = 0;
			long currentTown = 1;
			long inloop = 0;
			long loopNeeds = 0;

			var keiro = new Dictionary<long, long>();
			keiro.Add(currentTown, loopCount);
			while (true) {
				loopCount++;
				var nextTown = teleDic[currentTown];

				if(loopCount == K) {
					Console.WriteLine(nextTown);
					return;
				}

				if(keiro.ContainsKey(nextTown)) {
					inloop = keiro[nextTown];
					loopNeeds = loopCount - inloop;
					break;
				}
				currentTown = nextTown;
				keiro.Add(currentTown, loopCount);
			}

			var jisshitu = (K-inloop) % loopNeeds;

			long ans = 1;

			for (int i = 0; i < (jisshitu+inloop); i++) {
				ans = teleDic[ans];
			}

			//答えの出力
			Console.WriteLine(ans);

		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}
	}
}


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

L = {}

for i in range(N):
    s = input()
    if s in L.keys():
        L[s] +=1
    else:
        L[s] = 1

L = sorted(L.items(),key=lambda x:x[1],reverse=True)

S = []
c = L[0][1]
for i in range(len(L)):
    if c == L[i][1]:
        S.append(L[i][0])
    else:
        break
S = sorted(S)
for s in S:
    print(s)

Measured memory_bytes: 43228
#include <stdio.h>
int main(void)
{
	int a,b;
	scanf("%d", &a);
	scanf("%d", &b);
    
	if (a < b) {
		printf("a < b\n");
	}
	else if (a > b) {
		printf("a > b\n");
	}
	else {
		printf("a == b\n");
	}
	
    return 0;
}


Measured memory_bytes: 2040
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PLL = pair<ll, ll>;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repn(i,n) for(int i = 0; i <= (int)(n); i++)
#define srep(i,l,n) for(int i = l; i < (int)(n); i++)
#define srepn(i,l,n) for(int i = l; i <= (int)(n); i++)
#define drep(i,n) for(int i = (int)(n-1); i >= 0; i--)
#define drepn(i,n) for(int i = (int)(n); i >= 0; i--)
#define size(s) (int)s.size()
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<typename T> inline istream& operator>>(istream &i, vector<T> &v) {rep(j, size(v)) i >> v[j]; return i;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T> T gcd(T a, T b) {if(b==0)return a; else return gcd(b,a%b);}
template<class T> T lcm(T a, T b) {return a/gcd(a,b)*b;}
template<class T = int> using V = vector<T>;
template<class T = int> using VV = vector<V<T>>;
bool isIn(int i, int j, int h, int w) {return i >= 0 && i < h && j >= 0 && j < w;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void err() {cout << -1 << endl;}
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define ep emplace_back

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

#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    string s;
    cin >> n >> s;
    int ans = 0;
    for(int i = 0; i < n; i++) {
        map<char, int> mp1, mp2;
        for(int j = 0; j < n; j++) {
            if(j < i) mp1[s[j]]++;
            else mp2[s[j]]++;
        }
        int cnt = 0;
        for(char c = 'a'; c <= 'z'; c++) {
            if(mp1[c] > 0 && mp2[c] > 0) cnt++;
        }
        chmax(ans, cnt);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3660
A,B = map(int,input().split())
X = []
for i in range(100):
    if i<50:
        X.append(["."]*100)
    else:
        X.append(["#"]*100)

A = A-1
q,r = A//50, A%50
for i in range(q):
    for j in range(50):
        X[99-i*2][j*2] = "."
for i in range(r):
    X[51][i*2] = "."

B = B-1
q,r = B//50, B%50
for i in range(q):
    for j in range(50):
        X[i*2][j*2] = "#"
for i in range(r):
    X[48][i*2] = "#"

print(100,100)
for x in X:
    print("".join(x))


Measured memory_bytes: 3188
#include <iostream>
using namespace std;
typedef long long ll;

int main()
{
    ll w, h, x, y;
    cin >> w >> h >> x >> y;
    printf("%.15f\n", w * h * 1.0 / 2);
    if(x * 2 == w && y * 2 == h) cout << 1 << endl;
    else cout << 0 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <utility>
#include <queue>
#include <ios>
#include <iomanip>
#include <ctime>
#include <tuple>

#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; i++)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return 1;} return 0; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return 1;} return 0; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFF
#define Yes(q) (q ? "Yes" : "No")
#define YES(q) (q ? "YES" : "NO")

#define PInt pair<int, int>
#define PLL pair<long long, long long>
#define VInt vector<int>
#define VLL vector<long long>
#define MatrixInt vector<vector<int>>
#define MatrixLL vector<vector<long long>>

typedef long long ll;
using namespace std;

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

    int c0 = 0, c1 = 0;
    for (const char &c : s) if (c == '0') c0++; else c1++;
    cout << min(c0, c1) * 2 << endl;
    
}

Measured memory_bytes: 512
# AGC024C - Sequence Growing Easy
def main():
    N, *A = map(int, open(0))
    A.append(0)
    if A[0]:  # corner case
        print(-1)
        return
    ans = 0
    for i, j in zip(A[::-1], A[::-1][1:]):
        if i > j + 1:
            print(-1)
            return
        if j >= i:
            ans += j
    print(ans)


if __name__ == "__main__":
    main()

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

using namespace std;

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

    int ans = 0;
    for (int i = 1; i <= n; ++i) {
        if (to_string(i).length() % 2 == 1) ans++;
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
//daddy's back in town, back to rolling the damn hash yoooo babeeeeees
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define x first
#define y second
#define pi pair <int, int>
#define vi vector <int>
#define L nod<<1
#define R ((nod<<1)|1)
const ll mod = 1000000007;
#define int ll
int n, k, r, s, p, c[100010], dp[100010][3], score[3], ans;
char x;

int beat_by(int x){
	return (x+1)%3;
}
 
int32_t main(){
	ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	cin>>n>>k>>r>>s>>p;
	for(int i=1; i<=n; i++){
		cin>>x;
		if(x=='r') c[i]=0;
		else if(x=='p') c[i]=1;
		else c[i]=2;
	}
	score[0]=r, score[1]=p, score[2]=s;
	for(int i=1; i<=k; i++){
		int cnt=0;
		while(cnt*k+i<=n){
			int idx=cnt*k+i;
			for(int cur=0; cur<=2; cur++){
				for(int p=0; p<=2; p++){
					if(cnt==0) dp[idx][cur]=score[cur]*(cur==(c[idx]+1)%3);
					else if(cur!=p) dp[idx][cur]=max(dp[idx-k][p]+score[cur]*(cur==(c[idx]+1)%3), dp[idx][cur]);
				}
			}
			cnt++;
		}
	}
	for(int i=n; i>=n-k+1; i--) ans+=max(dp[i][0], max(dp[i][1], dp[i][2]));
	//for(int i=1; i<=n; i++){cout<<i<<": "<<dp[i][0]<<" "<<dp[i][1]<<" "<<dp[i][2]<<endl;}
	cout<<ans;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
struct UnionFind {
    int sz;
    std::vector<int> par;
    UnionFind(int sz) {
        this->sz = sz;
        par.clear();
        par.resize(sz, -1);
    }
    int root(int x) {
        return par[x] < 0 ? x : par[x] = root(par[x]);
    }
    void unite(int a, int b) {
        int roota = root(a);
        int rootb = root(b);
        if(roota == rootb) return;
        if(par[rootb] < par[roota]) std::swap(roota, rootb);
        par[roota] += par[rootb];
        par[rootb] = roota;
    }
    bool same(int a, int b) {
        return (root(a) == root(b));
    }
    int size(int a) {
        return -par[root(a)];
    }
};
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
int main() {
  cin.tie(0);
  cout << fixed << setprecision(10);
  int n, m; cin >> n >> m;
  vector<P> p(m);
  for(int i=0;i<m;++i) {
    cin >> p[i].first >> p[i].second;
  }
  reverse(p.begin(), p.end());
  UnionFind uf(n);
  ll ma = (ll)n * (n-1) / 2;
  ll now = 0;
  vector<ll> ans;
  for(int i=0;i<m;++i) {
    ans.push_back(ma - now);
    int a = p[i].first - 1, b = p[i].second - 1;
    ll sza = uf.size(a), szb = uf.size(b);
    if(uf.same(a, b)) continue;
    now -= sza * (sza - 1) / 2 + szb * (szb - 1) / 2;
    uf.unite(a, b);
    sza = uf.size(a);
    now += sza * (sza - 1) / 2;
  }
  reverse(ans.begin(), ans.end());
  for(int i=0;i<m;++i) {
    cout << ans[i] << endl;
  }
}


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

int main(){
  int m,f,r;

  while(1){
    cin>>m>>f>>r;
    if(m==-1 && f==-1 && r==-1) break;
    else if(m==-1 || f==-1) cout<<"F"<<endl;
    else if(m+f>=80) cout<<"A"<<endl;
    else if(m+f<80 && m+f>=65) cout<<"B"<<endl;
    else if(m+f<65 && m+f>=50) cout<<"C"<<endl;
    else if(m+f<50 && m+f>=30 && r<50) cout<<"D"<<endl;
    else if(m+f<50 && m+f>=30 && r>=50) cout<<"C"<<endl;
    else cout<<"F"<<endl;
  }
  return 0;
}



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

int c[500],s[500],f[500];

int main()
{
	int n,i,now,p;
	cin >> n;
	for(i=0;i<n-1;i++)
		cin >> c[i] >> s[i] >> f[i];
	for(i=0;i<n-1;i++)
	{
		for(now=0,p=i;p<n-1;now+=c[p],p++)
			if(now<s[p]) now=s[p];
			else now=((now-s[p]-1)/f[p]+1)*f[p]+s[p];
		cout << now << "\n";
	}
	cout << "0\n";
 } 

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>

using namespace std;

int main() {
	int r; cin >> r;
	cout << 3 * r * r << endl;
	return 0;
}


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

const int MAXN = 205;
const int T = 3;

int main() {
  int N;
  int a[MAXN][T];
  while(cin >> N) {
    for(int i = 0; i < N; ++i) {
      for(int j = 0; j < T; ++j) {
        cin >> a[i][j];
      }
    }
    int res[N];
    fill(res, res+N, 0);
    for(int j = 0; j < T; ++j) {
      for(int i = 0; i < N; ++i) {
        int tmp = a[i][j];
        for(int k = 0; k < N; ++k) {
          if(k == i) continue;
          if(a[i][j] == a[k][j]) {
            tmp = 0;
            break;
          }
        }
        res[i] += tmp;
      }
    }
    for(int i = 0; i < N; ++i) {
      cout << res[i] << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int ctoi(const char c) {
    if ('0' <= c && c <= '9') return (c - '0');
    return -1;
}
vector<int> input(int n) {
    vector<int> vec(n);
    for (int i = 0; i < n; i++) {
        cin >> vec.at(i);
    }
    return vec;
}
void output(vector<int> vec) {
    for (int i = 0; i < vec.size(); i++) {
        cout << vec[i] << " ";
    }
    return;
}
vector<vector<int>> input(int n, int m) {
    vector<vector<int>> table(n, vector<int>(m));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> table. at(i).at(j);
        }
    }
    return table;
}
void output(vector<vector<int>> table) {
    for (int i = 0; i < table.size(); i++) {
        for (int j = 0; j < table.at(0).size(); j++) {
            cout << table.at(i).at(j) << " ";
        }
        cout << endl;
    }
}
long long perm(int n, int r) {
    if (n < r) {
        cout << "error" << endl;
        return 0;
    }
    long long perm = 1;
    for (int i = n; i > n - r; i--) {
        perm *= i;
    }
    return perm;
}
long long comb(int n, int r) {
    if (n < r) {
        cout << "error" << endl;
        return 0;
    }
    long long comb = perm(n,r);
    for (int i = r; i > 0; i--) {
        comb /= i;
    }
    return comb;
}
long long homo(int n, int r) {
    return comb(n + r - 1, n - 1);
}
long long fact(int n) {
    long long fact = 1;
    for (int i = n; i > 0; i--) {
        fact *= i;
    }
    return fact;
}
int gcd(int a, int b)
{
    if (a % b == 0)
    {
        return(b);
    }
    else
    {
        return(gcd(b, a % b));
    }
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int main() {
  int n;
  cin >> n;
  if(n>63){
    cout << 64 << endl;
  }
  else if(n>31){
    cout << 32 << endl;
  }
  else if(n>15){
    cout << 16 << endl;
  }
  else if(n>7){
    cout << 8 << endl;
  }
  else if(n>3){
    cout << 4 << endl;
  }
  else if(n>1){
    cout << 2 << endl;
  }else{
    cout << 1 << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ll long long 
using namespace std;
const int N = 1e5+10;
const int M = 1e9+7;

int main(){
	FIO;
	int n;
	cin >> n;
	int a[n+2],b[n+2];
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
	}
	b[0]=0;
	b[1]=abs(a[1]-a[0]);
	for (int i = 2; i < n; ++i)
	{
		b[i] = min(b[i-1]+abs(a[i]-a[i-1]),b[i-2]+abs(a[i]-a[i-2]));
	}
	// for (int i = 0; i < n; ++i)
	// {
	// 	cout << b[i] << " ";
	// }	
	cout << b[n-1];
}

Measured memory_bytes: 1024
program test
implicit none

integer(8) :: a,b,c,i,j,k,ll(8),n,abcd(8)=1
integer(8) :: count(3),len(3),ans=1d10,cost
read(*,*) n,a,b,c

do i = 1,n
	read(*,*) ll(i)
enddo

do

	count(1:3) = 0
	len(1:3) = 0
	
	do j=1,n
		do k=1,3
			if(abcd(j) == k)then
				count(k) = count(k) + 1
				len(k) = len(k) + ll(j)
			endif
		enddo
	enddo
	
	
	if(minval(count(1:3)) >= 1)then
		
		cost = 10*(sum(count(1:3))-3) + abs(len(1)-a) + abs(len(2)-b) + abs(len(3)-c)
		ans = min(ans,cost)
		
	endif
	
	abcd(n) = abcd(n)+1
	
	do j=n,2,-1
		if(abcd(j)==5)then
			abcd(j) = 1
			abcd(j-1) = abcd(j-1)+1
		endif
	enddo
	
	if(abcd(1) == 5)then
		goto 100
	endif
	
enddo


100 continue
write(*,*) ans

end program


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

int arr[5000005];

int main(){
    long long ans = 0;
    string S;
    cin >> S;

    for(int i=0; i<S.length(); i++){
        if (S[i] == '<') {
            arr[i+1] = arr[i] + 1;
        }
    }

    for(int i=S.length() - 1; i>= 0; i--){
        if (S[i] == '>' && arr[i] <= arr[i+1]) {
            arr[i] = arr[i+1] + 1;
        }
    }

    for(int i=0; i<=S.length(); i++){
        ans += arr[i];
    }

    cout << ans << endl;
}

Measured memory_bytes: 5884
#include <vector>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <functional>
#include <map>
#include <array>
#include <cmath>

long long PRIME = 1e9 + 7;
using namespace std;


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

    if(N % 2 == 1){
        cout << 0;
        return 0;
    }

    N /= 2;
    long long count = 0;
    long long div = 5;

    while(N / div != 0){
        count += N / div;
        div *= 5;
    }

    cout << count;

}



Measured memory_bytes: 256
N=int(input())
s=[int(input()) for i in range(N)]
import collections
table=collections.defaultdict(int)
for x in s:
  if x%10!=0:
    table[x]+=1
if sum(s)%10==0:
  if len(table)==0:
    print(0)
  else:
    table=list(table.keys())
    table.sort()
    print(sum(s) - table[0])
else:
  print(sum(s))

Measured memory_bytes: 3316
//Robs Code
/***********HEADER***************/
#include<bits/stdc++.h>
/***********MACROS***************/
#define int long long int
#define fri(l,k) for (i=l;i<=k;i++)
#define frj(l,k) for (j=l;j>=k;j--)
#define fij(a,b,l,k) for(i=a;i<=b;i++) for(j=l;j<=k;j++)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define endl "\n"
#define pb push_back
#define _1 first
#define _2 second
#define mxsz 10000007
#define mxval 1e9
#define grt [](auto x,auto y){return x>y;}
#define pii pair<int,int>
/*********VARIABLE****************/
using namespace std;
int i,j,n,m,k,l,q,t,a,b,sum[3],tot[3],cnt[3];
/***********MAIN******************/
signed main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	cin>>n;
    cout<<((n-2)*180);
	return 0;
}
//.........


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

for i in range(M):
    t =  T.copy()
    t[px[i][0]-1] = px[i][1]
    print(sum(t))

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

using namespace std; 

int main() 
{ 
    long long int n1,n2,e=1000000007;
	
	cin>>n1>>n2;
	
	long long int a[n1],b[n2];
	
	for(long long int i = 0 ; i < n1 ; i++) cin>>a[i];
	for(long long int i = 0 ; i < n2 ; i++) cin>>b[i];
	
	long long int cnt[n1+1][n2+1];
	memset(cnt,0,sizeof(cnt));

    for(long long int i = 0 ; i <= n1 ; i++){
        for(long long int j = 0 ; j <= n2 ; j++){
            if(i==0||j==0) {cnt[i][j] = 1;}
            else{
                cnt[i][j] = (cnt[i-1][j]%e+cnt[i][j-1]%e-cnt[i-1][j-1]%e)%e;
                if(a[i-1]==b[j-1]){
                    cnt[i][j] += (cnt[i-1][j-1])%e;
                }
            }
        }
    }
    
    //printf("%llu\n",(cnt[n1][n2])%e);
	cout <<(cnt[n1][n2]+e)%e<<endl;
	return 0; 
} 


Measured memory_bytes: 34908
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main() {
  ll a;
  cin>>a;
  ll b=0;
  for(ll i=1;i<a+1;i++){
    b+=i;
  }
  
  ll c=0;
  if(a>=2){
    for(ll i=2;i<a+1;i++){
      for(ll j=1;j<i;j++){
        for(ll k=j;k<=j;k--){
          if(j%k==0&&i%k==0){
            c+=k;
            break;
          }
        }
      }
    }
    c=c*6;
  }
  ll d=0;
  if(a>=3){
    for(ll i=3;i<a+1;i++){
      for(ll j=2;j<i;j++){
        for(ll k=1;k<j;k++){
          for(ll l=k;l<=k;l--){
            if(i%l==0&&k%l==0&&j%l==0){
              d+=l;
              break;
            }
          }
        }
      }
    }
  d=d*6;
  }
  cout<<b+c+d<<endl;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define int long long
int dp[3001][3001];
string s,s2;
int fun(int idx,int idx2)
{
    if(idx==s.size()||idx2==s2.size())
        return dp[idx][idx2]=0;
    int &ret=dp[idx][idx2];
    if(~ret)
        return ret;
    if(s[idx]==s2[idx2])
        return ret=1+fun(idx+1,idx2+1);
    return ret=max(fun(idx+1,idx2),fun(idx,idx2+1));
}
signed main()
{
    memset(dp,-1,sizeof dp);
   cin>>s>>s2;
   int idx=0,idx2=0;
   fun(0,0);
   string ans="";
   while(idx!=s.size()&&idx2!=s2.size())
   {

       if(s[idx]==s2[idx2])
       {
           ans+=s[idx];
           idx++;
           idx2++;
           continue;
       }
         if(dp[idx][idx2+1]<=dp[idx+1][idx2])
         {
             idx++;
         }
         else idx2++;

   }
   cout<<ans<<endl;
}


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

using namespace std;

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

const double pi = 3.14159265358979323846;

// #define fio() cin.tie(0); ios::sync_with_stdio(false);
// template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
// template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define MOD 1000000007LL
#define PS(p) cout << setprecision(15) << fixed << p << endl;
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
#define ALL(c) c.begin(), c.end()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define TG0 get< 0 >
#define TG1 get< 1 >
#define TG2 get< 2 >
#define F first
#define S second
#define VL vector< ll >

// to_string(123)
// atoi("123"); atoi(s.c_str());
// "abc".size()
// s.find('+') == string::npos
// 1e18

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

  string S;
  cin >> S;

  if (S[0] != 'A') {
    cout << "WA" << endl;
    return 0;
  }
  string a = "ACabcdefghijklmnopqrstuvwxyz";

  for (auto c : S) {
    if (a.find(c) == string::npos) {
      cout << "WA" << endl;
      return 0;
    }
  }

  bool isC = false;

  for (ll i = 2; i < S.length() - 1; i++) {
    if (S[i] == 'C') {
      if (isC) {
        cout << "WA" << endl;
        return 0;
      }
      isC = true;
    }
  }

  if (isC) {
    cout << "AC" << endl;
  } else {

    cout << "WA" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
import sys
s = input()
for i, (x, y) in enumerate(zip(s, s[1:])):
    if x == y:
        print(i+1, i+2)
        sys.exit()
if len(s) <= 2:
    print(-1, -1)
    sys.exit()
for i, (x, y, z) in enumerate(zip(s, s[1:], s[2:])):
    if x == z:
        print(i+1, i+3)
        sys.exit()
print(-1, -1)

Measured memory_bytes: 9128
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }


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

    int n;cin>>n;
    vector<ll> a(n);
    rep(i,n){
        cin>>a[i];
    }
    ll ans=a[0]-1;
    ll num=2;
    for(int i=1;i<n;i++){
        if(a[i]==num){
            num++;
        }
        else if(a[i]<num){
            continue;
        }
        else{
            ans+=a[i]/num;
            if(a[i]%num==0) ans--;
        }
    }  
    cout<<ans<<endl;
    return 0;
}


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

struct Team {
	string name;
	int score, no;
	Team(const string &na, int sc, int no) : name(na), score(sc), no(no) {}

	bool operator <(const Team &t) const {
		if(score != t.score) return score > t.score;
		return no < t.no;
	}
};

int main() {
	bool first = true;
	for(int N; cin >> N, N; ) {
		if(first) first = false;
		else cout << endl;
		vector<Team> v;
		for(int i = 0; i < N; i++) {
			string s;
			int w, l, d;
			cin >> s >> w >> l >> d;
			v.push_back(Team(s, 3 * w + d, i));
		}
		sort(v.begin(), v.end());

		for(auto it = v.begin(); it != v.end(); ++it) {
			cout << it->name << ',' << it->score << endl;
		}
	}
}

Measured memory_bytes: 1220
import math
import sys
import itertools
import queue
from fractions import gcd

def lcm(a, b):
    return a * b // gcd(a, b)

def combination(n, r):
    return factorial(n) // (factorial(n - r) * factorial(r))

sys.setrecursionlimit(10000)

mod = 1000000007

"""
# 0埋め, 小数点出力桁指定時のときの出力
a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654

# 文字列をリストに格納
char_list = list("abcd") # ["a","b","c","d"]

# 標準入力取得
## 文字列
    = sys.stdin.readline().rstrip()
    = list(sys.stdin.readline().rstrip())

## 数値
    = int(sys.stdin.readline())
    = map(int, sys.stdin.readline().split())
    = list(map(int, sys.stdin.readline().split()))
    = [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき
"""

if __name__ == "__main__":
    l = sys.stdin.readline().rstrip()
    N = len(l)
    abmin = 753
    for i in range(N - 2):
        abmin = min(abmin, abs(753 - int(l[i:i + 3])))
    print(abmin)

Measured memory_bytes: 5096
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;

int main(){
    fast_io

    string s, t;
    cin>>s>>t;
    
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());
    
    if(s<t) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;

}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#define N 2

using namespace std;
void output_array_int(int*,int,char);
void input_array_int(int*,int);

////////////////////////////////////////////////////////////////////////////////

int main(){
  int a,b;
  char op;

  for(;;){
    cin>>a>>op>>b;
    if(op=='?'){
      break;
    }
    switch (op) {
      case '+':
      cout<<a+b<<endl;
      break;

      case '*':
      cout<<a*b<<endl;
      break;

      case '-':
      cout<<a-b<<endl;
      break;

      case '/':
      cout<<a/b<<endl;
      break;
    }
  }

  return 0;
}

////////////////////////////////////////////////////////////////////////////////

void output_array_int(int * a,int n,char ch){
  int i;

  for(i=0;i<n;i++){
    cout<<*(a+i);
    if(i<(n-1)){
      cout<<ch;
    }
  }

  cout<<endl;

  return;
}

void input_array_int(int *a,int n){
  int i;

  for(i=0;i<n;i++){
    cin>>*(a+i);
  }
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

vi lnk[1024];
string res[1024];

void dfs(int p,int d){
  cout<<string(d,'.')<<res[p]<<endl;
  REP(i,lnk[p].size()){
    dfs(lnk[p][i],d+1);
  }
}

int main(){
  int n;
  cin>>n;
  int root = 0;
  REP(i,n){
    int k;
    string m;
    cin>>k>>m;
    res[i] = m;
    --k;
    if(k==-1)root=i;
    else{
      lnk[k].push_back(i);
    }
  }
  dfs(root,0);
  return 0;
}

Measured memory_bytes: 1444