akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python
#-*- coding: utf-8 -*-

# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_2_D

if __name__ == '__main__':
    w, h, x, y, r = map(int, raw_input().split())
    if x - r < 0 or x + r > w or y - r < 0 or y + r > h:
        print "No"
    else:
        print "Yes"


Measured memory_bytes: 4632
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

ll ketawa(ll n) {   // nの各桁の数の和
    ll res = 0;    
    while(n != 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}
 
int main() {
    ll n;
    cin >> n;

    if(n%ketawa(n) == 0) {
        out("Yes");
    }
    else {
        out("No");
    }
    
    re0;
}

Measured memory_bytes: 384
n = int(input())
l = list(map(int, input().split()))
l.sort(reverse=True)

lptr = [-1] * 1001
lptr[0] = n - 1
for i in range(1, 1001):
  maxptr = n -1
  minptr = 0
  fixed = [-1] * n
  cptr = (maxptr + minptr + 1) // 2

  while fixed[cptr] == -1:

#    print(str(cptr)+','+str(l[cptr]))
    if l[cptr] > i:
      fixed[cptr] = 0
      minptr = cptr
    else:
      fixed[cptr] = 1
      maxptr = cptr
    cptr = (maxptr + minptr + 1) // 2
      
  lptr[i] = cptr - fixed[cptr]

#print(lptr)

    
cnt = 0
for i in range(n-2):
  for j in range(i+1,n-1):
    tgt = l[i] - l[j]
    if lptr[tgt] > j:
      cnt += lptr[tgt] - j

print(cnt)

Measured memory_bytes: 41836
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N=1e6+5;
ll a[N];
__int128 b[N],c[N];
int prime[N],tot=0;
bool vis[N];
map<__int128,int>mp;
int main()
{
    int n=2500;
    vis[1]=1;
    for(int i=2;i<=n;i++)
    {
        if(!vis[i])prime[++tot]=i;
        for(int j=1;j<=tot&&i*prime[j]<=n;j++)
        {
            vis[i*prime[j]]=true;
            if(i%prime[j])break;
        }
    }
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%lld",&a[i]);b[i]=c[i]=1;
        for(int j=1;j<=tot&&a[i]>1;j++)
        {
            if(a[i]%prime[j])continue;
            int x=0;
            while(a[i]%prime[j]==0)a[i]/=prime[j],x++;
            x%=3;
            if(x==1)b[i]*=prime[j],c[i]*=1ll*prime[j]*prime[j];
            if(x==2)c[i]*=prime[j],b[i]*=1ll*prime[j]*prime[j];
        }
        //ll xx=b[i],yy=c[i];
        //cout<<xx<<" "<<yy<<endl;
        if(a[i]==1){mp[b[i]]++;continue;}
        int x=sqrt(a[i]);
        if(1ll*x*x==a[i])b[i]*=a[i],c[i]*=x;
        else b[i]*=a[i],c[i]*=a[i],c[i]*=a[i];
        mp[b[i]]++;
    }
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        if(b[i]==c[i])ans+=(mp[b[i]]!=0);
        else ans+=max(mp[b[i]],mp[c[i]]);
        mp[b[i]]=mp[c[i]]=0;
    }
    printf("%d\n",ans);
}


Measured memory_bytes: 26112
#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)

void turn(int x, int y, int data[10][10]) {
	int dx[5] = {0,1,0,-1,0};
	int dy[5] = {0,0,1,0,-1};
	
	REP(i, 5) {
		int nx = x + dx[i], ny = y + dy[i];
		if (!(nx >= 0 && nx < 10 && ny >= 0 && ny < 10)) continue;
		data[ny][nx]++;
	}
}

bool check(int data[10][10]) {
	bool res = true;
	
	REP(i, 10) if (data[9][i] & 1) res = false;
	
	return res;
}

int main() {
	int n;
	cin >> n;
	while (n--) {
		int in[10][10];
		REP(i, 10) REP(j, 10) scanf("%d", &in[i][j]);
		
		bool ans[10][10];
		int data[10][10];
		
		REP(i, 1<<10) {
			memset(ans, 0, sizeof(ans));
			memcpy(data, in, sizeof(in));
			
			REP(j, 10) if ((i >> j) & 1) {
				ans[0][j] = true;
				turn(j, 0, data);
			}
			FOR(j, 1, 10) REP(k, 10) {	
				if (data[j - 1][k] & 1) {
					ans[j][k] = true;
					turn(k, j, data);
				}
			}
			
			if (check(data)) break;
		}
		
		REP(j, 10) REP(k, 10)
			printf("%d%c", ans[j][k] ? 1 : 0, k == 9 ? '\n' : ' ');
	}
	return 0;
}

Measured memory_bytes: 1228
# init
cards = [[False for i in range(13)] for j in range(4)]

# 0: S
# 1: H
# 2: C
# 3: D
pattern = ["S", "H", "C", "D"]
numbers = 13
n = int(input())

for loop in range(n):
    i = input()
    card = list(map(str, i.split()))
    ch = card[0]
    rank = card[1]
    if ch =='' or rank =='': break
    cards[pattern.index(ch)][int(rank)-1] = True
    
# lst = list(map(str,input().split('\n')))
# pattern = ["S", "H", "C", "D"]

# for elm in lst:
#     card = elm.split()
#     print(card)
#     ch = card[0]
#     rank = card[1]
    
#     # S x  ==> card[0][x-1]
#     cards[pattern.index(ch)][rank-1] = True
    
# output
for i in range(len(pattern)):
    for j in range(numbers):
        if cards[i][j] == False:
            print(pattern[i], j+1)



Measured memory_bytes: 5616
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <fstream>
 
using namespace std;
 
#define INF 100000000
#define EPS 1e-9
#define PI acos(-1)
 
typedef long long ll;
typedef pair<int, int> P;

#define MAX_N 10000

int n;
int v[60*60*24 + 5];

vector<int> ans_list;

int conv(string str){
  string hh,mm,ss;
  hh += str[0];
  hh += str[1];
  mm += str[3];
  mm += str[4];
  ss += str[6];
  ss += str[7];

  return atoi(hh.c_str()) * 3600 + atoi(mm.c_str()) * 60 + atoi(ss.c_str());

}

int main(){

  while(true){
    cin >> n;
    if(n == 0)
      break;

    memset(v,0,sizeof(v));
    string str1, str2;

    for(int i = 0; i < n; i++){
      cin >> str1 >> str2;
      v[conv(str1)]++;
      v[conv(str2)]--;
    }

    int ans = 0;
    int tmp = 0;
    for(int i = 0; i <= 60*60*24+1; i++){
      tmp += v[i];
      ans = max(ans,tmp);
    }

    ans_list.push_back(ans);

  }

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

  return 0;

}

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

int main() {
    int k, a, b; cin >> k >> a >> b;
    int x = (a+k-1) / k * k;
    cerr << x << endl;
    cout << (a<=x and x<=b?"OK":"NG") << endl;
    return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
#define MOD 10007
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

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

Measured memory_bytes: 256
H, W = map(int, input().split())
lst = []
for i in range(H):
    lst.append(list(input()))
for i in range(H-1, -1, -1):
    if '#' not in lst[i]:
        del lst[i]
for j in range(W-1, -1, -1):
    cnt = 0
    for i in range(len(lst)):
        if lst[i][j] == '#':
            cnt += 1
    if cnt == 0:
        for i in range(len(lst)):
            del lst[i][j]
for i in lst:
    print(''.join(i))

Measured memory_bytes: 3064
package main

import (
	"fmt"
	"strconv"
	"strings"
)

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	as := strings.Repeat(strconv.Itoa(a), b)
	bs := strings.Repeat(strconv.Itoa(b), a)
	if as < bs {
		fmt.Println(as)
	} else {
		fmt.Println(bs)
	}
}


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

int n;

void dfs(string s, char c){
	if(s.size() == n){
		cout << s << endl;
	}else{
		for (char i = 'a'; i <= c ; ++i) {
			if(i == c){
				dfs(s+i, char(c+1));
			}else{
				dfs(s+i, c);
			}
		}
	}
	
}

int main(){
	cin >> n;
	dfs("", 'a');
    return 0;
}



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

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX / 10;
//const ll INF = (1ll << 31) - 1;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
//typedef pair<int, int> P;
//typedef pair<double, double> P;

bool contain(set<P> &s, P a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);


void print_line(vector<ll> &line) {
    if (line.size() == 0ll) {
        cout << endl;
        return;
    }
    for (ll i = 0; i < line.size(); i++) {
        cout << line[i];
        if (i == line.size() - 1) cout << endl;
        else cout << ' ';
    }
}


typedef priority_queue<long long, vector<long long>, greater<long long>> PQ_ASK;
const int mod = 1000000007;

class CumulativeSum {
    vector<double> numbers;
    vector<double> sums;

public:
    CumulativeSum(int n) {
        numbers.resize(n);
        sums.resize(n);
    }

    void set(int i, double value) {
        numbers[i] = value;
    }

    double getSum(int i) {
        if (i == -1) return 0;
        if (i == sums.size()) return 0;
        return sums[i];
    }

    double getSectionSum(int start, int end) {
        return getSum(end) - getSum(start - 1);
    }

    void calculate() {
        for (int i = 0; i < numbers.size(); i++) {
            sums[i] = getSum(i - 1) + numbers[i];
        }
    }

};


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

    vector<int> dices(n);
    rep(i, n) cin >> dices[i];
    vector<double> es(n);
    rep(i, n) {
        double d = dices[i];
        es[i] = d * (d + 1) / 2 / d;
    }

    CumulativeSum cs(n);
    rep(i, n) cs.set(i, es[i]);
    cs.calculate();
    double ans = 0;
    for (int i = 0; i + k <= n; i++) {
        cmax(ans, cs.getSectionSum(i, i + k - 1));
    }

    printf("%.20f\n", ans);

}




Measured memory_bytes: 5760
N = int(input())
H = list(map(int, input().split()))


INF = 10 ** 18
cost = [INF] * N
cost[0] = 0
cost[1] = abs(H[0] - H[1])

for i in range(2, N):
    cost[i] = min(abs(H[i] - H[i - 1]) + cost[i - 1], abs(H[i] - H[i - 2]) + cost[i - 2])

print (cost[-1])

Measured memory_bytes: 13976
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

int main(){
  int N;
  cin >> N;
  vector<ll> v;
  ll sum = 0;
  ll mn = 10000000000LL, mx = -1;
  rep(i,N){
    ll a;
    cin >> a;
    v.push_back(a);
    sum += a;
    mn = min(mn, a);
    mx = max(mx, a);
  }

  ll ep = N*(ll)(N+1)/2LL;
  if(sum%ep != 0){
    cout << "NO" << endl;
  }else{
    ll n = sum / ep;

    ll ret = 0;
    rep(i,N){
      int nxt = (i+1)%N;
      ll diff = v[nxt] - v[i];

      ll a = abs(diff - n);
      if(a%N != 0){
        ret = -1;
        break;
      }
      ret += a / N;
    }
    /*
    FOR(it,valid){
      cout << " " << it->first << " " << it->second << endl;
    }
    cout << ret << " " << n << endl;
    */
    if(ret == n){
      cout << "YES" << endl;
    }else{
      cout << "NO" << endl;
    }
  }
  
  return 0;
}


Measured memory_bytes: 1528
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<string.h>
#include<complex>
#include<math.h>
using namespace std;
typedef long long int llint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<llint, llint>> vpllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;

bool check(int a, int b) {
	return a > b;
}

int main() {
	int n;
	cin >> n;
	int cnt;
	if (n % 4 == 0 || n % 7 == 0) {
		cout << "Yes" << endl;
		return 0;
	}
	rep(i, n / 4 + 2) {
		cnt = i * 4;
		if (cnt > n) {
			break;
		}
		if (cnt == n) {
			cout << "Yes" << endl;
			return 0;
		}
		while (cnt <= n) {
			cnt += 7;
			if (cnt == n) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
string alp="abcdefghijklmnopqrstuvwxyz";
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

ll n;
ll a[3001];
ll memo[3001][3001];

ll hoge(ll x,ll y){
    if(memo[x][y]!=-inf){
        return memo[x][y];
    }
    if(x==y){
        return memo[x][y]=a[x];
    }
    return memo[x][y]=max(a[x]-hoge(x+1,y),a[y]-hoge(x,y-1));
}

int main(){fastio
    cin>>n;
    rep(i,0,n-1)cin>>a[i];
    rep(i,0,n-1){
        rep(j,0,n-1){
            memo[i][j]=-inf;
        }
    }
    ll ans=hoge(0,n-1);
    cout<<ans<<endl;
    
    
    return 0;
}


Measured memory_bytes: 70784
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>

using namespace std;

int main()
{
    int n;
    cin >> n;
    long int ans[87];
    ans[0]=2;
    ans[1]=1;
    for(int i=2; i<87; i++){
        ans[i]=ans[i-1]+ans[i-2];
    }
    cout << ans[n];
    
    return 0;
}

Measured memory_bytes: 256
def solve(T_X_Y):
    curr_t = 0
    curr_x = 0
    curr_y = 0
    for t_x_y in T_X_Y:
        t = t_x_y[0]
        x = t_x_y[1]
        y = t_x_y[2]
        if not travelable(curr_t, curr_x, curr_y, t, x, y):
            return "No"
    return "Yes"


def travelable(curr_t, curr_x, curr_y, t, x, y):
    dist_x = abs(x - curr_x)
    dist_y = abs(y - curr_y)
    min_step = dist_x + dist_y
    if t - curr_t < min_step:
        return False
    return (t - curr_t - min_step) % 2 == 0


N = int(input())
T_X_Y = [list(map(int, input().split())) for _ in range(N)]

print(solve(T_X_Y))

Measured memory_bytes: 27324
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define P pair<int, int>
#define F first
#define S second
#define mod 1000000007
#define INF 40000000000000000
int dx8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int dy8[8] = {1, 1, 1, 0, -1, -1, -1, 0};
int dx4[4] = {-1, 0, 1, 0};
int dy4[4] = {0, -1, 0, 1};
signed main(void) {
    int A,B,K;cin>>A>>B>>K;
    if(K<A)cout<<A-K<<' '<<B<<endl;
    else if(K<A+B)cout<<0<<' '<<B-(K-A)<<endl;
    else cout<<0<<' '<<0<<endl;

}


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

int main() {
  int n,k;
  cin >> n >> k;
  
  vector<int> a(n);
  for(int i=0; i<n; i++) cin >> a[i];
  
  vector<int> b(n+1);
  vector<int> c(n);
  int count = 0;
  
  for(int i=1; i<=k; i++){
   
      for(int i=0; i<n; i++){
        b[max(1,1+i-a[i])-1]++;
        b[min(n,1+i+a[i])]--;    
      }
    
      for(int i=0; i<n; i++){
        if(i == 0) c[i] = b[i];
        else c[i] += c[i-1] + b[i];
      }
    
      for(int i=0; i<n; i++){
       a[i] = c[i];
       b[i] = 0;
       c[i] = 0;
      }
    
      for(int i=0; i<n; i++){
        if(a[i] == n) count++;
     }
      
     if(count == n){
            break;
     }
      
        count = 0;
   
  }
  
  if(n == 1) cout << a[0] << endl;
  else{
    for(int i=0; i<n-1; i++) cout << a[i] << " ";
    cout << a[n-1] << endl;
  }
	return 0;
}


Measured memory_bytes: 5560
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)    for(int i=0; i<(n); ++i)
#define REP(i, d, n) for(int i=(d); i<(n); ++i)
#define rrep(i, n)   for(int i=(n-1); i>=0; --i)
#define all(v)       v.begin(), v.end()
#define rall(v)      v.rbegin(), v.rend()
#define int          long long
template<typename T>
using vv  = vector<vector<T>>;
using vi  = vector<int>;
using vvi = vector<vector<int>>;
using P   = pair<int, int>;
using ll  = long long;
constexpr ll INF = 1LL << 60;

signed main(){

    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n){
        cin >> a[i];
    }

    sort(all(a));
    if(a[0] == 0){
        cout << 0 << endl;
        return 0;
    }
    
    int res = 1;
    rep(i, n){
        if(a[i] <= (ll)1e18 / res){
            res *= a[i];
        }
        else{
            cout << -1 << endl;
            return 0;
        }
    }

    cout << res << endl;

    return 0;
}



Measured memory_bytes: 4056
#include<stdio.h>
int main()
{
    int a,A,b,B,c;
    scanf("%d",&a);
    A=a%10;
    b=a/10;
    B=b%10;
    c=b/10;
    if(A==7||B==7||c==7)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;

}


Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
const int MAX = 3000;
int n, m;
struct edge {
	int from, to;
	long long cost;
};
edge e[MAX];
long long d[MAX];
void bellmanford() {
	fill(d, d + MAX, INF);
	d[0] = 0;
	for(int i = 0; i < n; i++) {
		bool reached = false;
		for(int j = 0; j < m; j++) {
			edge tmp = e[j];
			if(d[tmp.from] != INF && d[tmp.to] > d[tmp.from] + tmp.cost) {
				d[tmp.to] = d[tmp.from] + tmp.cost;
					//cout << d[tmp.to] << endl;
				if(tmp.to == n - 1) {
					reached = true;
				}
			}
		}
		if(i == n - 1 && reached) {
			cout << "inf" << endl;
			exit(0);
		}
	}
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);  
	cin >> n >> m;
	for(int i = 0; i < m; i++) {
		int a, b, c;
		cin >> a >> b >> c;
		a--;
		b--;
		c = -c;
		e[i] = edge{a, b, c};
	}
	bellmanford();
					/*for(int i = 0; i < n; i++) {
						cout << d[i] << endl;
					}*/
	cout << -d[n - 1] << endl;
	return 0;	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(c) c.begin(),c.end()
#define init(c) memset(c,0,sizeof c)
#define S second
#define F first
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int N=20000005;
ll n,k,x,t,a,b,m,c,d;
string s;
vi v;
int main(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r" , stdin);
	#endif // ONLINE_JUDGE
	cin >> x;
	ll cur = 100;
	int ans = 0;
	while(cur<x){
		ans++;
		cur = cur+ll(cur/100);
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<iomanip>
#include<cassert>
#include<math.h>
#include<complex>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<functional>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

string S;
ll precnt[2020];
ll cnt[2020];
int main(){
    cin>>S;
    ll sum=0;
    ll ans=0;
    for(ll i=0;i<S.length();i++){
        for(ll j=0;j<2019;j++){
            cnt[j*10%2019]=(cnt[j*10%2019]+precnt[j]);
        }
        sum=(sum*10+S[i]-'0')%2019;
        if(sum%2019==0)ans++;
        ans+=cnt[sum%2019];
        cnt[sum%2019]++;
        for(ll j=0;j<2019;j++){
            precnt[j]=cnt[j];
            cnt[j]=0;
        }
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 3780
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << endl;
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << "";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define wh while
#define ve vector
#define mp make_pair
#define tp tuple
#define mt make_tuple
#define pb push_back
#define pof pop_front
#define pob pop_back
#define pf push_front
#define fr front
#define ft first
#define sc second
#define tos to_string
#define len length
#define rt return
#define br break
#define con continue
#define lcm(n, m) (n * m / gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define repill(i, m, n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define repll(i, n) repill(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m);i>(int)(n);i--)
#define rev(i, m) revi(i, m, 0)
#define revill(i, m, n) for(ll i=(ll)(m);i>(ll)(n);i--)
#define revll(i, n) revill(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) (n.begin(), n.end())
#define allr(n) (n.rbegin(), n.rend())
#define sp(n) cout << fixed << setprecision(n)
#define inf pow(10, 9)
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数
// __builtin_popcount bitの個数

ve<int> dx = {0, 0, 1, -1}, dy = {1, -1, 0, 0};

int main() {
  ll N, M;
  cin >> N >> M;
  if(N == 1 && M == 1){
    cout << 1 << endl;
  }
  else if(N == 1){
    cout << M - 2 << endl;
  }
  else if(M == 1){
    cout << N - 2 << endl;
  }
  else{
    cout << (M - 2) * (N - 2) << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
#include<string.h>
#include<math.h>
#define ll long long
using namespace std;
ll b[100005];
int main()
{
    int n;
    scanf("%d",&n);
    
    ll a[100005],i;
    
    for(i=0; i<n; i++)
    {
        scanf("%lld",&a[i]);
        if(a[i]>=1e5)
            a[-2]=0;
    }
        
    for(i=0;i<100005;i++)
        b[i]=0;
    
    if(a[0]!=0)
            printf("0\n");
    else
    {
        ll ans=1;
        for(i=0;i<n;i++)
            b[a[i]]++;
        for(i=1;i<n;i++)
        {
            ans*=b[a[i]-1];
            ans%=998244353;
        }

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


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <vector>
#define INF 1e9+7
using namespace std;
typedef long long int ll;

int main() {

	int a;
	cin >> a;
	if (a < 1200) {
		cout << "ABC" << endl;
	}
	else if (a >= 1200&&a<2800) {
		cout << "ARC" << endl;
	}
	else {
		cout << "AGC" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
import qualified Data.ByteString.Char8 as BS
import Data.Maybe
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words

getIntList = readIntList <$> BS.getLine

main = do
  xs <- getIntList
  print $ fromJust (0 `elemIndex` xs) + 1


Measured memory_bytes: 3664
#include <iostream>

#define N_MAX 100

using namespace std;

int t = 1;
int adj_matrix[N_MAX][N_MAX];
int d[N_MAX];
int f[N_MAX];

void dfs(int v, int n)
{
    if (d[v] == 0) {
        d[v] = t;
        t++;
        for (int i = 0; i < n; i++) {
            if (adj_matrix[v][i] != 0) {
                dfs(i, n);
            }
        }
        if (f[v] == 0) {
            f[v] = t;
            t++;
        }
    }
}

int main()
{
    int n, u, k, v;
    cin >> n;
    for (int i = 0; i < n; i++) {
        d[i] = 0;
        f[i] = 0;
    }

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            adj_matrix[i][j] = 0;
        }
    }

    for (int i = 0; i < n; i++) {
        cin >> u;
        cin >> k;
        for (int j = 0; j < k; j++) {
            cin >> v;
            adj_matrix[u-1][v-1] = 1;
        }
    }

    for (int i = 0; i < n; i++) {
        dfs(i, n);
    }

    for (int i = 0; i < n; i++) {
        cout << i+1 << " " << d[i] << " " << f[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 3136
#include<bits/stdc++.h>
using namespace std;
string s;
int a,b,l;
int main(){
	cin>>s;
	for(int i=0;i<s.size();i++){
		if(a==b){
			a++;
			if(s[i]=='p')l--;
		}
		else {
			b++;
			if(s[i]=='g')l++;
		}
	}
	printf("%d\n",l);
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <array>
#include <tuple>
#include <string>
#include <algorithm>
#include <functional> // greater など
#include <cmath>      // abs など
#include <numeric>    // accumulate, gcd など
#include <cassert>    // assert
#include <stdexcept>
#include <bitset>
using namespace std;

// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
// typedef int128_t ll;
// typedef cpp_int ll;

// GCC, 配列のアクセスなど
#define _GLIBCXX_DEBUG
// Clang, 配列のアクセスなど
#define _LIBCPP_DEBUG 0

// #define NDEBUG 1
// debug用出力 https://trap.jp/post/998/
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{
    cerr << H << " ";
    debug_out(T...);
}
#ifdef NDEBUG
#define debug(...)
#else
#define debug(...) debug_out(__VA_ARGS__)
#endif

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

constexpr inline ll mod = 1'000'000'007;
vector<int> s(3);
int n;
ll res = 1;

int main()
{
    // 高速な入出力
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << setprecision(15); // 浮動小数の表示の精度

    cin>>n;
    rep(i,n) {
        int a; cin>>a;
        auto it = find(s.begin(), s.end(), a);
        int cnt = count(s.begin(), s.end(), a);
        res *= cnt;
        res %= mod;
        (*it)++;
    }
    cout << res << '\n';

    return 0;
}


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

int main()
{
    int n;
  cin >> n;
    vector <int> a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    int cnt = 1;
    int ans = 0;
  
    for(int i=0;i<n;i++){
        if(a[i] == cnt){
            cnt++;
        }else{
         ans++;   
        }
    }
  	if(ans == a.size() && cnt == 1)cout << "-1" << endl;
    else{cout << ans << endl;}
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <iomanip>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
const int inf = 1e9;
const ll linf = 1LL << 50;
int n;
vector<P> vec1;
vector<P> vec2;
bool used[101];

bool comp(const P &x, const P &y){
		if(x.first != y.first)return x.first < y.first;
		else return x.second < y.second;
}

bool comp2(const P &x, const P &y){
		if(x.first != y.first)return x.first < y.first;
		else return x.second > y.second;
}

int main(int argc, char const* argv[])
{
	cin >> n;
	fill(used, used + n, false);
	for(int i = 0; i < n; i++){
			int a, b;
			cin >> a >> b;
			vec2.pb(mk(a, b));
	}
	for(int i = 0; i < n; i++){
			int a, b;
			cin >> a >> b;
			vec1.pb(mk(a, b));
	}
	sort(vec1.begin(), vec1.end(), comp);
	sort(vec2.begin(), vec2.end(), comp2);
	int res = 0;
	for(auto itr = vec1.begin(); itr != vec1.end(); ++itr){
			int index = -1;
			int cur = -1;
			for(int i = 0; i < n; i++){
					if(!used[i] && vec2[i].first < (*itr).first && vec2[i].second < (*itr).second){
							if(cur < vec2[i].second){
									index = i;
									cur = vec2[i].second;
							}
					}
					if(vec2[i].first > (*itr).first)break;
			}
			if(index != -1){
					used[index] = true;
					res++;
			}
	}
	cout << res << endl;
	return 0;
}


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

int main() {
    string s;
    while(cin >> s) {
        for(auto& c : s) {
            if(c == ',') c = ' ';
        }
        stringstream ss(s);
        vector<int> l(11), v(2);
        for(int i = 1; i <= 10; ++i) {
            int d; ss >> d;
            l[i] += l[i - 1] + d;
        }
        ss >> v[0] >> v[1];
        int mid = (l.back() * v[0] + v[0] + v[1] - 1) / (v[0] + v[1]);
        cout << (lower_bound(begin(l), end(l), mid) - begin(l)) << endl;
    }
}


Measured memory_bytes: 3136
using System;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.IO;


namespace SolutionCS
{

    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());

            int[] buf = new int[N];
            for (int i = 0; i < N; i++)
            {
                buf[i] = -1;
            }
            int count = 0;

            for (int i = 0; i < N; i++)
            {
                int v = int.Parse(Console.ReadLine());

                if ( count != 0 && buf[count - 1] >= v)
                {
                    buf[count] = v;
                    count++;
                }
                else
                {
                    int indStart = count / 2;

                    if ( buf[indStart] < v)
                    {
                        indStart = 0;
                    }

                    for (int j = indStart; j < N; j++)
                    {
                        if (buf[j] < 0)
                        {
                            buf[j] = v;
                            count++;
                            break;
                        }

                        if (buf[j] < v)
                        {
                            buf[j] = v;
                            break;
                        }
                    }
                }
            }

            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 15328
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<assert.h>
#include<string>
#include<cstdlib>
#include<cctype>
#include<unordered_map>
#include<sstream>
#include<numeric>
#include<stack>
// #include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 9e18;
constexpr int inf = 1e9;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
};
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
};

// intやllをstringに変換
template<typename T> inline string toString(const T &a){
  ostringstream oss;
  oss << a;
  return oss.str();
};
// ----------------------------------------------------------------------------


int main(){
  int N,M;
  cin >> N >> M;
  vector<vector<int>> G(M);
  for(int i=0; i<M; i++){
    int k;
    cin >> k;
    for(int j=0; j<k; j++){
      int s;
      cin >> s;
      G[i].push_back(s);
    }
  }
  vector<int> p(M);
  for(int i=0; i<M; i++){
    cin >> p[i];
  }
  int ans = 0;
  for(int bit=0; bit<(1<<N); bit++){
    vector<int> cnt(M,0);
    for(int i=0; i<M; i++){
      for(int m: G[i]){
        if(bit & (1<<m-1)){
          cnt[i]++;
        }
      }
    }
    bool can = true;
    for(int i=0; i<M; i++){
      if(cnt[i]%2 != p[i]){
        can = false;
        break;
      }
    }
    if(can){
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
N, X, Y = map(int, input().split())
X -= 1; Y -= 1;
ans = [0] * (N)
for i in range(N):
  for j in range(i + 1, N):
    tmp = min(j - i, abs(i - X) + abs(j - Y) + 1)
    ans[tmp] += 1
for i in range(1, N):
  print(ans[i])

Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define fi first
#define se second
#define pb push_back
#define vi vector<int >
#define vii vector < pair<int ,int > >
#define IO ios::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0)
#define IOfiles freopen("input.txt","r+",stdin) ; freopen("output.txt","w+",stdout)
#define PI 3.14159265
const long long mod = 1e9 + 7LL;
typedef long long ll;
typedef pair<int, int> ii;
typedef double db;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a;}
ll pwr(ll x , ll n) { ll ans = 1; while (n) {ans *= x; n--;} return ans;}

void solve(){
    
}

int main()
{
    IO;
    int n;
    cin>>n;
    int arr[n+1]={};
    for(int i=2;i<=n;i++){
        int v;
        cin>>v;
        arr[v]++;
    }
    for(int i=1;i<=n;i++)
        cout<<arr[i]<<endl;
    
}   

Measured memory_bytes: 4472
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define debug(x) cerr << #x << " " << x << '\n'
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
const int INF = 0x3f3f3f3f, N = 2e5 + 5;
const ll LINF = 1e18 + 5;

int main()
{
 	ios::sync_with_stdio(false);
 	cin.tie(0);
 	int m, k;
 	cin >> m >> k;
 	int up = (1<<m)-1;
 	if(k>up) cout << -1;
 	else if(m==1 && k==1) cout << -1;
 	else if(m==1 && k==0) cout << "0 0 1 1";
 	else
 	{
 		vector <int> a;
 		for(int i=0; i<=up; i++)
 		{
 			if(i==k) continue;
 			a.pb(i);
 		}
 		a.pb(k);
 		for(int i=up; i>=0; i--)
 		{
 			if(i==k) continue;
 			a.pb(i);
 		}
 		a.pb(k);
 		for(auto x : a) cout << x << ' ';
 	}
	return 0;
}


Measured memory_bytes: 2932
#pragma target("avx")
#pragma optimize("O3")
#include<bits/stdc++.h>
using ll = int_fast64_t;
using P = std::pair<ll,ll>;
using PP = std::pair<ll,P>;
using V = std::vector<ll>;
template<typename T> using pq = std::priority_queue<T>;
template<typename T> using rpq = std::priority_queue<T, std::vector<T>, std::greater<T>>;

#define REP(i,b,e) for(ll i=b; i<e; i++)
#define ALL(vec) vec.begin(),vec.end()
#define PRINT(vec) printf("[ ");for(auto &i:vec)printf("%ld ",i);puts("]");
#define SCAN(vec) for(auto &i:vec)scanf("%ld",&i)
#define fi first
#define se second

const int MOD = 1e9+7;
const ll INF = 1e18;
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

int main(){
        int n;
        scanf("%d", &n);
        V a(n);
        SCAN(a);
        std::sort(ALL(a), std::greater<ll>());

        ll ans = a[0], pos = 1;
        n -= 2;
        while(n){
                if(n>=2){
                        ans += 2 * a[pos];
                        pos++;
                        n -= 2;
                }else if(n>=1){
                        ans += a[pos];
                        pos++;
                        n--;
                }else{
                        break;
                }
        }
        printf("%ld\n", ans);
        return 0;
}

Measured memory_bytes: 4856
#B
A, B, C, D=map(int, input().split())

A_survive=0
C_survive=0

while A>0:
    A-=D
    A_survive+=1
while C>0:
    C-=B
    C_survive+=1
if A_survive >= C_survive:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9176
#include <cstdio>
#include <cmath>
typedef long long ll;

double a, b, x, l, h, t, ans1, ans2;

int main(){
	
	scanf("%lf%lf%lf", &a, &b, &x);
	l = a * a * b - x;
	h = l * 2 / (a * a);
	if(h <= b){
		t = a / h;
		ans1 = atan(t) / acos(-1) * 180;
		printf("%.9lf\n", 90 - ans1);
	}
	else{
		t = x / (b * a) * 2;
		ans2 = atan(t / b) / acos(-1) * 180;
		printf("%.9lf\n", 90 - ans2);
	}
	
	return 0;
}

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

namespace CSharpSample01
{

    

    class Program
    {
        
        
        static void Main(string[] args)
        {
            
            while(true)
            {
                string[] input = Console.ReadLine().Split(' ');
                int rate_before = int.Parse(input[0]);
                int rate_after = int.Parse(input[1]);
                int sum_before = int.Parse(input[2]);

                if(rate_before == 0 && rate_after == 0 && sum_before == 0)
                {
                    break;
                }

                int sum_after_max = 0;

                for(int a_after = 1; a_after <= sum_before / 2; a_after++)
                {
                    int b_after = sum_before - a_after;

                    int a_before = -1;
                    int b_before = -1;

                    int a_before_down = a_after * 100 / (100 + rate_before);
                    int a_before_up = (int)Math.Ceiling((double)a_after * 100 / (100 + rate_before));

                    int a_after_down = a_before_down * (100 + rate_before) / 100;
                    int a_after_up = a_before_up * (100 + rate_before) / 100;

                    if (a_after_down == a_after)
                    {
                        a_before = a_before_down;                        
                    }
                    if (a_after_up == a_after)
                    {
                        a_before = a_before_up;
                    }

                    if (a_before == -1)
                    {
                        continue;
                    }
                    

                    int b_before_down = b_after * 100 / (100 + rate_before);
                    int b_before_up = (int)Math.Ceiling((double)b_after * 100 / (100 + rate_before));

                    int b_after_down = b_before_down * (100 + rate_before) / 100;
                    int b_after_up = b_before_up * (100 + rate_before) / 100;


                    if (b_after_down == b_after)
                    {
                        b_before = b_before_down;                        
                    }
                    if (b_after_up == b_after)
                    {
                        b_before = b_before_up;
                    }

                    if (b_before == -1)
                    {
                        continue;
                    }
                    

                    int sum_after = a_before * (100 + rate_after) / 100 + b_before * (100 + rate_after) / 100;

                    if (sum_after > sum_after_max)
                    {
                        sum_after_max = sum_after;
                    }

                }

                Console.WriteLine(sum_after_max);

            }
            
        }
    }
}


Measured memory_bytes: 15872
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;

#ifdef local
	#include "debug/debug.h"
#endif


#ifndef local
	#define deb(x...) ;	
#endif

#define int long long  
#define ll long long
#define vi vector <int>
#define vii vector <pair<int,int> >
#define vvi vector <vi>
#define rep(i,a,b) for (int i=a;i<b;i++)
#define repD(i,a,b) for (int i=a;i>b;i--)
#define pb push_back
#define pii pair <int,int>
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define MOD 1000000007
#define M_PI 3.14159265358979323846 

typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
///*X.find_by_order("index")
///X.order_of_key("key")

///----------------------------------------------------------------------------------

int r, c, k;
int grid[3001][3001], DP[3001][3001][4];

int fun(int x, int y, int taken=0)
{
	if (x == r-1 && y == c-1)
	{
		if (taken != 3) return grid[x][y];
		else return 0;
	}
	if (DP[x][y][taken] != -1) return DP[x][y][taken];
	
	int res = 0;
	if (x+1 < r)
	{
		if (grid[x][y] && taken != 3) res = max(res, grid[x][y] + fun(x+1, y, 0));
		res = max(res, fun(x+1, y, 0));
	}
	if (y+1 < c)
	{
		if (grid[x][y] && taken != 3) res = max(res, grid[x][y] + fun(x, y+1, taken+1));
		res = max(res, fun(x, y+1, taken));
	}
	return DP[x][y][taken] = res;
	
}
void solve()
{
	cin >> r >> c >> k;
	
	rep(i,0,k)
	{
		int x, y, w;
		cin >> x >> y >> w;
		grid[x-1][y-1] = w;
	}
	memset(DP, -1, sizeof DP);
	cout << fun(0, 0) << "\n";
}
signed main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	
	#ifdef local
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	clock_t TIMER = clock();
	#endif
	
	int t = 1;
	//cin >> t;
	rep(a,0,t)
	{
		//cout<<"Case #"<<a+1<<": ";
		solve();
		#ifdef local
		cout << "\n";
		#endif

	}
	
	#ifdef local
	{TIMER = clock() - TIMER;double time_taken = ((double)TIMER)/CLOCKS_PER_SEC;cerr<<fixed<<setprecision(5)<<"\n\nTime Taken : "<<time_taken<<" seconds\n";}
	#endif
}

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

int main(void) {
  long long N;
  cin >> N;
  map<long long, long long> A;
  for (int i = 0; i < N; i++) {
    long long a;
    cin >> a;
    A[a]++;
  }
  long long Q;
  cin >> Q;
  long long ans = 0;
  for (auto m : A) {
    ans += m.second * m.first;
  }
  for (int i = 0; i < Q; i++) {
    long long B, C;
    cin >> B >> C;
    A[C] += A[B];
    ans -= B * A[B];
    ans += C * A[B];
    A.erase(B);
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 7476
n = int(input())
A = [int(input()) for _ in range(n)]
ans = 0
tmp = 0
for a in A:
    if tmp > a:
        ans += a
        tmp = 0
        continue
    else:
        ans += tmp
        a -= tmp
        ans += a // 2
        tmp = a - (a // 2) * 2
print(ans)

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

int main(){
    int a,b;
    for(a=1;a<=9;a=a+1){
        for(b=1;b<=9;b=b+1){
             printf("%dx%d=%d\n",a,b,a*b);
        }
    }
    return 0;
}

Measured memory_bytes: 524
import java.util.*
fun main(args: Array<String>){
	val cin = Scanner(System.`in`)
    val n = cin.nextInt()
    val k = cin.nextInt()
    var ans = 1;
    var flag = 0;

    for(i in 1..n){
        if(ans * 2 > ans + k){
            flag = 1;
        }
        if(flag == 1){
            ans = ans + k;
        } else if(flag == 0){
            ans = ans * 2;
        }
    }
    println(ans);
}


Measured memory_bytes: 31252
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int h, w, k;
  cin >> h >> w >> k;
  vector<string> s(h);
  rep(i, h) cin >> s[i];
  int ans = 0;
  rep(i, 1<<h+w) {
    int mw = i>>h;
    int mh = i^mw<<h;
    int cnt = 0;
    rep(j, h) {
      if (mh>>j&1)
        continue;
      rep(k, w) {
        if (mw>>k&1)
          continue;
        if (s[j][k] == '#')
          cnt++;
      }
    }
    if (cnt == k)
      ans++;
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n), b(n), c(n - 1);
  rep(i, n)
  {
    cin >> a[i];
  }
  rep(i, n)
  {
    cin >> b[i];
  }
  rep(i, n-1)
  {
    cin >> c[i];
  }
  int sum = 0;
  int p = -1;
  rep(i, n)
  {
    sum += b[a[i] - 1];
    if (p + 1 == a[i]) {
      sum += c[p - 1];
    }
    p = a[i];
  }
  cout << sum;
  return 0;
}

Measured memory_bytes: 256
n = int(input())
if n==3: print(2,3,25)
elif n<15003:
	print(3,9,end=" ")
	if n%3:
		for i in range(1,n-1): print(2*i,end=" ")
	else:
		print(2,4,end=" ")
		for i in range(4,n): print(2*i,end=" ")
else:
	for i in range(2,30000,2): print(i,end=" ")
	if n%2:
		for i in range(n-14999): print(6*i+3,end=" ")
	else:
		print(30000,end=" ")
		for i in range(n-15000): print(6*i+3,end=" ")

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

using namespace std;

/*  テンプレここから */
typedef long long ll;

#define rep(i, n) for(int i = 0; i < n; ++i)
#define repi(i, start, end) for(int i = start; i < end; ++i)
#define all(x) (x).begin(), (x).end()
#define INF (1e9)
#define INFL (1e18)
#define add_mod(a, b, x) ( (ll)(a) + (ll)(b) ) % (ll)(x)
#define mul_mod(a, b, x) ( ((ll)(a) % (ll)(x)) * ((ll)(b) % (ll)(x)) ) % (ll)(x)
#define out(x) cout << (x) << endl;
#define outyes(bool_val) cout << (bool_val ? "yes" : "no") << endl;
#define outYes(bool_val) cout << (bool_val ? "Yes" : "No") << endl;
#define outYES(bool_val) cout << (bool_val ? "YES" : "NO") << endl;
#define outPossible(bool_val) cout << (bool_val ? "Possible" : "Impossible") << endl;
#define outPOSSIBLE(bool_val) cout << (bool_val ? "POSSIBLE" : "IMPOSSIBLE") << endl;

ll sub_mod(ll a, ll b, ll x){
    ll tmp = (a - b) % x;
    if(tmp < 0) tmp += x;
    return tmp;
}
ll gcd(ll a, ll b){
    if(b == 0) return a;
    else return gcd(b, a % b);
}

int dx[] = {0, 1, 0, -1};
int dy[] = {-1, 0, 1, 0};
/*  テンプレここまで */

ll calc(long long num){
    if(num <= 0) return 0;
    ++ num;

    // 最大値 pow(10, 12) -> pow(2, 40)くらい
    // 各i桁目のxorを取る -> 足し算
    ll sum = 0;
    rep(i, 50){
        ll loop = 1LL << (i + 1);
        ll cnt = (num / loop) * (loop / 2);               // ループ回数 x 各ループの1の個数(0 1:1 1)
        cnt += max(0LL, (num % loop) - (loop / 2));       // 端数 - ループ内の0の個数
        if(cnt % 2 == 1) sum += 1LL << i;
    }

    return sum;
}

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

    ll a, b;
    cin >> a >> b;

    cout << (calc(b) ^ calc(a - 1)) << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
  int a = sc.nextInt();
  int b = sc.nextInt();
  if((a*b)%2 == 0){System.out.println("Even");}
  else{System.out.println("Odd");}
}
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
#define int long long int
#define endl "\n"
#define arrinp(v) for(auto &i:v) cin>>i;
#define arrout(v) for(auto &i:v) cout<<i<<" ";
#define newline cout<<endl;
using namespace std;
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int t=1;
    // cin >> t;
    while (t--) {
        string s,t;
        cin>>s>>t;
        int ans=INT_MAX,count=0;;
        int l1=s.size(),l2=t.size();
        for(int i=0;i<l1-l2+1;i++){
            count=0;
            for(int j=0;j<l2;j++){
                if(s[i+j]!=t[j]){
                    count++;
                }
            }
            ans=min(count,ans);
        }
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pii pair<int,int>
const long long MOD=1000000007;

int main(){
    string n;
    cin>>n;
    if(n[0]==n[2]) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

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

int main(void) {
    int N;
    string S;
    cin>>N>>S;
    char cur = S[0];
    int slimes = 1;
    for (int i = 1; i < N; i++) {
        if (cur != S[i]) slimes++; cur = S[i];
    }
    cout << slimes << endl;
    return 0;
}

Measured memory_bytes: 512