akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <limits>
#include <stack>
#include <queue>
#include <map>
#include <set>

using namespace std;

using ll = long long;
using ui = unsigned int;
const ll MOD = 1000000007;
const ll INF = 9223372036854775807;


//AtCoder Grand Contest 023-A
int main() {
	ll N;
	scanf("%lld", &N);
	vector<ll> A(N + 1);
	A[0] = 0;
	for (ll i = 1; i <= N; i++) {
		scanf("%lld", &A[i]);
	}

	vector<ll> T(N + 1, 0);
	T[0] = A[0];
	for (ll i = 1; i <= N; i++) {
		T[i] = T[i - 1] + A[i];
	}

	ll result = 0;

	map<ll, ll> mp;
	for (ll i = 0; i <= N; i++) {
		mp[T[i]]++;
	}

	auto begin = mp.begin(), end = mp.end();
	for (auto iter = begin; iter != end; iter++) {
		// iter->first: key, iter->second: value
		ll var = iter->second;
		result += var * (var - 1) / 2;
	}

	//TLE
	//for (ll i = 1; i <= N; i++) {
	//	for (ll j = i; j <= N; j++) {
	//		if (T[j] - T[i - 1] == 0) {
	//			result++;
	//		}
	//	}
	//}

	printf("%lld\n", result);
}


//AtCoder Regular Contest 074-C
/*
int main() {
	ll H;
	scanf("%lld", &H);
	ll W;
	scanf("%lld", &W);

	ll result = INF;

	//holizontal cut
	for (ll i = 1; i < H; i++) {
		vector<ll> s;
		s.push_back(W * i);
		ll lastH = H - i;

		if (W * lastH % 2 == 0) {
			s.push_back(W * lastH / 2);
			s.push_back(W * lastH / 2);
		}
		else {
			if (lastH > W) {
				//holizontal cut
				ll cutIndex = lastH / 2;
				s.push_back(W * cutIndex);
				s.push_back(W * (lastH - cutIndex));
			}
			else {
				//vartical cut
				ll cutIndex = W / 2;
				s.push_back(cutIndex * lastH);
				s.push_back((W - cutIndex) * lastH);
			}
		}

		sort(s.begin(), s.end());
		result = min(result, s[2] - s[0]);
	}

	//vartical cut
	for (ll i = 1; i < W; i++) {
		vector<ll> s;
		s.push_back(H * i);
		ll lastW = W - i;

		if (lastW * H % 2 == 0) {
			s.push_back(lastW * H / 2);
			s.push_back(lastW * H / 2);
		}
		else {
			if (lastW > H) {
				//vartical cut
				ll cutIndex = lastW / 2;
				s.push_back(H * cutIndex);
				s.push_back(H * (lastW - cutIndex));
			}
			else {
				//holizontal cut
				ll cutIndex = H / 2;
				s.push_back(cutIndex * lastW);
				s.push_back((H - cutIndex) * lastW);
			}
		}

		sort(s.begin(), s.end());
		result = min(result, s[2] - s[0]);
	}

	printf("%lld\n", result);
}
*/

//AtCoder Beginner Contest 045-C
/*
int main() {
	char S[11];
	scanf("%s", S);
	int len = (int)strlen(S);

	ll result = 0;

	for (int i = 0; i < (1 << (len - 1)); i++) {
		ll keta = 1;

		for (int j = 0; j < len; j++) {
			result += (ll)(S[len - j - 1] - '0') * keta;
			if ((i & (1 << j)) == 0) {
				keta *= 10;
			}
			else {
				keta = 1;
			}
		}
	}


	printf("%lld\n", result);
}
*/

//AtCoder Regular Contest 067-D
/*
int main() {
	ll N;
	scanf("%lld", &N);
	ll A;
	scanf("%lld", &A);
	ll B;
	scanf("%lld", &B);

	vector<ll> X(N);
	for (ll i = 0; i < N; i++) {
		scanf("%lld", &X[i]);
	}

	ll result = 0;

	for (ll i = 0; i < N - 1; i++) {
		ll dist = X[i + 1] - X[i];
		result += min(A * dist, B);
	}

	printf("%lld\n", result);
}
*/

Measured memory_bytes: 15872
#include<bits/stdc++.h>
 
using namespace std;
 
const int N = (int) 1e5;
int n,k;
long long a[N+5],ans=(long long)2e15;
int main()
{
 
    cin>>n>>k;
    for(int i=1;i<=n;i++)
    cin>>a[i];
     for(int i=1;i+k-1<=n;i++)
    {  
        int l=i,r=i+k-1;
        ans=min(ans,a[r]-a[l]+min(abs(a[l]),abs(a[r])));
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define MAX 10000001
using namespace std;

int main(){
    int N,ans=0;
    long long D,X,Y;
    cin >> N >> D;
    for(int i=0; i<N; i++){
        cin >> X >> Y;
        if(D*D >= X*X + Y*Y){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//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; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

const int mod = 998244353;

int main(){
    int N; cin >> N;
    vector<int> a(N);
    int sum = 0;
    for(int i=0; i<N; i++){
        cin >> a[i];
        sum += a[i];
    }

    vector<vector<ll>> dp(N, vector<ll>(sum+1, 0));
    vector<vector<ll>> dp2(N, vector<ll>(sum+1, 0));

    // 初期化
    dp[0][a[0]] = 1;
    dp[0][0] = 2;

    // 配るdp：dp[i][A]がdp[i+1][?]に貢献する値を配っていく
    for(int i=0; i<N-1; i++){
        for(int A=0; A<=sum; A++){
            if(dp[i][A] == 0) continue;

            // i+1番目をAに入れないなら、BかCに入れるかの２通りがある
            dp[i+1][A] += 2*dp[i][A];
            dp[i+1][A] %= mod;
            // i+1番目をAに入れるなら、１通り
            dp[i+1][A+a[i+1]] += dp[i][A];
            dp[i+1][A+a[i+1]] %= mod;
        }
    }

    // printf("  |");
    // for(int i=0; i<N; i++) printf("%4d|", i);
    // printf("\n");
    // for(int A=0; A<=sum; A++){
    //     printf("---");
    //     for(int i=0; i<N; i++) printf("-----");
    //     printf("\n");
    //     printf("%2d|", A);
    //     for(int i=0; i<N; i++) printf("%4lld|", dp[i][A]);
    //     printf("\n");
    // }

    ll sub1 = 0;
    for(int A=((sum-1)/2+1); A<=sum; A++){
        sub1 += dp[N-1][A];
        sub1 %= mod;
    }
    sub1 = sub1*3%mod;
    //cout << sub1 << endl;


    // 初期化
    dp2[0][a[0]] = 1;
    dp2[0][0] = 1;

    // 同様にやっていく
    for(int i=0; i<N-1; i++){
        for(int A=0; A<=sum; A++){
            if(dp[i][A] == 0) continue;

            // Aに入れない場合はBに入れるので１通り
            dp2[i+1][A] += dp2[i][A];
            dp2[i+1][A] %= mod;

            dp2[i+1][A+a[i+1]] += dp2[i][A];
            dp2[i+1][A+a[i+1]] %= mod;
        }
    }

    // printf("  |");
    // for(int i=0; i<N; i++) printf("%4d|", i);
    // cout << endl;
    // for(int A=0; A<=sum; A++){
    //     printf("---");
    //     for(int i=0; i<N; i++) printf("-----");
    //     printf("\n");
    //     printf("%2d|", A);
    //     for(int i=0; i<N; i++) printf("%4lld|", dp2[i][A]);
    //     cout << endl;
    // }

    ll sub2;
    if(sum%2 == 1) sub2 = 0;
    else sub2 = dp2[N-1][sum/2];

    sub2 = 3*sub2%mod;
    //cout << sub2 << endl;

    ll ans = 1LL;
    for(int i=0; i<N; i++) ans = ans*3%mod;
    //cout << ans << endl;

    ans -= sub1;
    if(ans < 0){
        ans += mod;
        ans %= mod;
    }
    ans += sub2;
    ans %= mod;

    cout << ans << endl;
}

Measured memory_bytes: 422464
#include <cstdio>
#include <cstring>

using namespace std;

int main()
{
	char s[1000];
	
	while(scanf("%s", s) != EOF){
		
		int len = strlen(s);
		
		for(int i = 0; i < len; i++){
			if(s[i] == '@'){
				int j = s[i+1] - '0';
				while(j-- > 0){
					printf("%c", s[i+2]);
				}
				i+=2;
			}
			else printf("%c", s[i]);
		}
		puts("");
	}
	
	return(0);
}

Measured memory_bytes: 948
N = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]

need = 0
small_num = 0
large = []
for a, b in zip(A, B):
    if a > b:
        large.append(a - b)
    elif a < b:
        need += b - a
        small_num += 1
large.sort()
for i, x in enumerate(reversed(large)):
    if need <= 0:
        print(i + small_num)
        quit()
    need -= x
if need <= 0:
    print(len(large) + small_num)
else:
    print(-1)


Measured memory_bytes: 18356
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;

signed main(){
	cout<<fixed<<setprecision(10);
	
	int N;
    
    cin>>N;
	
    cout<<N/3<<endl;
	
	return 0;
}

Measured memory_bytes: 3612
def modpow(a,n,mod):
    res=1
    a=a%mod
    while(n>0):
        if(n&1):
            res=res*a%mod
        a=a*a%mod
        n>>=1
    return res

m,n=map(int,input().split())
print(modpow(m,n,10**9+7))


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

int main(){
    long int N, a, b;
    cin >> N;
    long int lim = floor(sqrt(N)); //aの上限を設定
    vector<long int> vec; //要素数0のvectorを宣言
    for(a=1;a<=lim;a++){
        if(N%a == 0){
            b = N/a;
            vec.push_back(a + b - 2); //vecの末尾にa+b-2を追加
        }
    }
    cout << *min_element(vec.begin(),vec.end()) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(nullptr);
#define ll long long int
#define f(i, a, b) for(int i=a; i<b; i++)
#define fr(i, a, b) for(int i=a; i>=b; i--)
#define l long int
#define endl '\n'
#define pb push_back
#define pf pop.front()
#define all(x) x.begin(),x.end()
#define debug(X) cout<<"[ X = "<<X<<"]\n";
#define lcm(a,b) a*b/__gcd(a,b)
#define maxn 100001
using namespace std;

vector <l>g[maxn];
bool vis[maxn];
l ccp =0;
void dfs(l node){
	vis[node] = true;
	
	for(l child : g[node])
	{
		if(!vis[child])
		{
			dfs(child);
		}
	}
}

void solve()
{
l n,m;
cin>>n>>m;

l a,b;
for(l i=0;i<m;i++)
{
cin>>a>>b;
a-- , b--;
g[a].pb(b);
g[b].pb(a);
	
}

for(l i=0;i<n;i++){
	if(!vis[i])
	{
		ccp++;
		dfs(i);
	}
}

cout<<ccp-1;
}


int32_t main()
{
FAST
l T=1;
//cin>>T;
while(T--)
{
solve();
}
}










Measured memory_bytes: 10408
import queue

N, M = map(int, input().split())
adj = [[] for i in [0]*N] # 隣接リスト
for i in [0]*M:
    a, b = map(int, input().split())
    adj[a-1].append(b)
    adj[b-1].append(a)

que = queue.Queue()
que.put(1)
guide = [-1]*(N)
 
while not que.empty():
    x = que.get()
    for y in adj[x-1]:
        if guide[y-1] == -1:
            que.put(y)
            guide[y-1] = x


print('Yes')
for i in guide[1:]:
        print(i)




Measured memory_bytes: 34948
import Data.List
import Data.Char
import Data.Maybe
import Control.Monad
import qualified Data.Vector as Vector
import Data.Vector ((!))
import qualified Data.ByteString.Char8 as BS8

main :: IO ()
main = do
  n <- fst . fromJust . BS8.readInt <$> BS8.getLine
  a <- unfoldr (BS8.readInt . BS8.dropWhile isSpace) <$> BS8.getLine

  let
    al = map (\x -> (x - 1, 1)) a
    l = Vector.accum (+) (Vector.replicate n 0) al
    s = sum $ Vector.map (\x -> x * (x - 1) `div` 2) l

  mapM_ (\x -> print $ s - ((l ! (x - 1)) * ((l ! (x - 1)) - 1) `div` 2) + (((l ! (x - 1)) - 1) * ((l ! (x - 1)) - 2) `div` 2)) a


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

#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    char grid[52][52];
    rep(i, 52) rep(j, 52) grid[i][j] = '.';
    int H, W; cin >> H >> W;
    rep(i, H){
        string S; cin >> S;
        rep(j, W){
            grid[i+1][j+1] = S[j];
        }
    }
    bool res = true;
    for(int i = 1; i <= H; i++){
        for(int j = 1; j <= W; j++){
            if(grid[i][j] == '#'){
                if(grid[i-1][j] == '.' && grid[i][j-1] == '.' && grid[i+1][j] == '.' && grid[i][j+1] == '.') res = false;
            }
        }
    }
    if(res) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3648
import java.util.*;
public class Main {
	static final Scanner stdin = new Scanner(System.in);
	public static void main(String[] args) {
		int i = 9;
		while(i-- > 0){
			String s = stdin.next();
                        int a = stdin.nextInt(), b = stdin.nextInt();
			System.out.println(s + " " + (a+b) + " " + (200*a+300*b));
		}
	}
}

Measured memory_bytes: 17248
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()


using namespace std;

typedef long long ll;

static const long long MOD = 1000000007;
static const long long INF = 1000000000000000005;

ll ans;
vector<ll> v1, v2;
ll N, K;

//積が正になるときの、x未満となる値の数をカウントする
long long syakutori1(vector<ll> v, long long x) {
  int s = 0, t = (int)v.size()-1;
  ll res = 0;
  while (s<t) {
    while (v[s]*v[t]>=x && s<t) t--;
    res += t-s;
    s++;
  }
  return res;
}
//積が負のときのx未満の数をカウント
long long syakutori2(long long x) {
  int n = (int)v2.size()-1;
  int s = 0, t = n;
  ll res = 0;
  while (s<(int)v1.size()) {
    while (v1[s]*v2[t]<x && t>=0) t--;
    res += n-t;
    s++;
  }
  return res;
}

//積が正の時のk番目の数を探索
long long bs1(long long k) {
  ll l = -INF, r = INF;
  while(r - l > 1) {
    ll m = (l + r) / 2;
    ll s = syakutori1(v1, m);
    ll t = syakutori1(v2, m);
    if (s+t >= k) r = m;
    else l = m;
  }
  return l;
}

//積が負のときのk番目の数を探索
long long bs2(long long k) {
  ll l = -INF, r = INF;
  while(r - l > 1) {
    ll m = (l + r) / 2;
    ll s = syakutori2(m);
    if (s>= k) r = m;
    else l = m;
  }
  return l;
}

int main(void) {
  scanf("%lld %lld", &N, &K);
  rep(i, 0, N) {
    ll t;
    scanf("%lld", &t);
    if (t > 0) v1.pb(t);
    else v2.pb(t);
  }
  sort(v1.bg, v1.en);
  sort(v2.bg, v2.en, greater<ll>());
  
  
  ll x = (ll)v1.size()*(ll)v2.size();
  
  if (K<=x) ans = bs2(K);
  else ans = bs1(K-x);
  
  printf("%lld\n", ans);

  return 0;
}



Measured memory_bytes: 3440
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
#define MOD 1000000007
using namespace std;



int main(int argc, char* argv[])
{
    long n;
    scanf("%ld", &n);

    vector<long> t(n);
    long sum=0;
    long i;
    for(i=0; i<n; i++) {
        scanf("%ld", &t[i]);
        sum += t[i];
    }

    long m;
    scanf("%ld", &m);
    vector<pair<long,long> > z(m);
    for(i=0; i<m; i++) {
        long p, x;
        scanf("%ld%ld", &p, &x);
        z[i] = make_pair(p-1, x);
    }

    for(i=0; i<m; i++) {
        printf("%ld\n", sum-t[z[i].first]+z[i].second);
    }


    return 0;
}



Measured memory_bytes: 384
import fractions

A, B, C, D = map(int, input().split())

# B以下でC, Dで割り切れるものの個数
b_c = B // C
b_d = B // D

# B以下でCでもDでも割り切れるものの個数
b_c_d = B // ((C*D)//fractions.gcd(C,D))

# A未満でC, Dで割り切れるものの個数
a_c = (A-1) // C
a_d = (A-1) // D

# A未満でCでもDでも割り切れるものの個数
a_c_d = (A-1) // ((C*D)//fractions.gcd(C,D))


count = b_c + b_d - b_c_d - (a_c + a_d - a_c_d)

ans = B-A+1 - count
print(int(ans)) 



Measured memory_bytes: 5048
#include<iostream>

using namespace std;

int X, Y;
int status[17][18];	//status[x][y]
int i, j;
int count;

void check(int x, int y);

int main(){

	while(1){

		count = 0;

		cin >> X >> Y;

		if(X == 0 && Y == 0){break;}

		else{

			//フィールドの入力
			//i行目について( 1 <= i <= Y+2 )
			for(i = 1; i <= Y+2; i++){
				//j文字目について( 0 <= j <= X+1)
				for(j = 0; j <= X+1; j++){

					//Y+1, Y+2列目に移動できるようにする。
					if(i > Y){
						status[j][i] = 0;
					}
					//両サイドには障害物を敷き詰める。
					else if(j == 0 || j == X+1){
						status[j][i] = 1;
					}
					else{
						cin >> status[j][i];
					}
				}
			}

			for(i = 1; i <= X; i++){
				check(i, 1);
			}

			cout << count << endl;
		}
	}

	return 0;
}


void check(int x, int y){

	if(status[x][y] == 0 && y >= Y){
		count++;
	}
	else if(status[x][y] == 1){}
	else if(status[x][y] == 2){
		check(x, y+2);
	}
	else{
		if(status[x-1][y+1] == 0){
			check(x-1, y+1);
		}
		if(status[x][y+1] == 0 || status[x][y+1] == 2){
			check(x, y+1);
		}
		if(status[x+1][y+1] == 0){
			check(x+1, y+1);
		}
	}
}

Measured memory_bytes: 1160
use proconio::fastout;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;

#[fastout]
fn main() {
    input! {
        x: f64,
    }
    let mut cash = 100_f64;
    let mut cnt = 0;
    while cash < x {
        cnt += 1;
        cash = (cash * 1.01).floor();
    }
    println!("{}", cnt);
}


Measured memory_bytes: 2652
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    int T=1;
    //cin>>T;
    while(T--){
        int a,b;
      cin>>a>>b;
      cout<<a*b;
        
    }
    return 0;
}

Measured memory_bytes: 3636
while True:
  n,p = map(int,input().split())
  if n*p == 0:
    break
  a = [0 for _ in range(n)]
  stone = p
  ans = 0
  while True:
    for i in range(n):
      if stone==0:
        stone = a[i]
        a[i] = 0
      elif stone==1:
        a[i]+=1
        stone-=1
        if a[i]==p:
          stone = -1
          ans = i
          break
      else:
        a[i]+=1
        stone-=1
    if stone==-1:
      print(ans)
      break


Measured memory_bytes: 5596
N=int(input())
A=list(map(int,input().split()))
B=[0]*N
for j in A:
  B[j]+=1
m=10**9+7
if N%2==0:
  if B[0]!=0:
    print(0)
    exit()
  for j in range(1,N//2+1):
    if B[2*j-1]!=2:
      print(0)
      exit()
else:
  if B[0]!=1:
    print(0)
    exit()
  for i in range(1,N//2+1):
    if B[2*i]!=2:
      print(0)
      exit()
print((2**(N//2))%m)


Measured memory_bytes: 52844
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll a, b, c, d, e, f; std::cin >> a >> b >> c >> d >> e >> f;
  bool dp[5][31][3001];
  re(i, 5) re(j, 31) re(k, 3001) dp[i][j][k] = false;
  dp[0][0][0] = true;

  for(int i=1;i<=4;i++){
    for(int j=0;j<=30;j++){
      for(int k=0;k<=3000;k++){
        dp[i][j][k] |= dp[i-1][j][k];
        if(i==1){
          if(j>=a) dp[i][j][k] |= dp[i][j-a][k];
        }else if(i==2){
          if(j>=b) dp[i][j][k] |= dp[i][j-b][k];
        }else if(i==3){
          if(k>=c) dp[i][j][k] |= dp[i][j][k-c];
        }else {
          if(k>=d) dp[i][j][k] |= dp[i][j][k-d];
        }
      }
    }
  }
  ld ans = 0, A, B;
  for(int j=1;j<=30;j++){
    for(int k=0;k<=3000;k++){
      if((j*100+k>f)||(j*e)<k||dp[4][j][k]==false) continue;
      //std::cout << j << " " << k << " " << dp[4][j][k]<< '\n';
      ld t = (ld)((ld)100.0*(ld)k)/((ld)j*100.0+(ld)k);
      if(t >=ans) ans= t, A = j*100, B = k;
    }
  }
  std::cout << A + B << " " << B << '\n';
  return 0;
}


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

//int nm[10001][10001] = {0};

map<pair<int,int>,int> nm;

int b[10000];

int main() {
    int n,m;

    cin >> n >> m;

    while(1){
        int s,t,e;
        scanf(" %d %d %d",&s,&t,&e);
        if( (s+t+e) == 0) break;
        //nm[s][t] = e;
        nm[make_pair(s,t)] = e;
    }

    int l;

    cin >> l;

    pair<int,int> tmp;

    while(l--) {

        long long c[10001] = {0};

        for(int i=1;i<=m;i++){
            scanf(" %d",&b[i]);
        }

        int i, j;
        for (i = 1; i <= n; i++) {
            /*for (j = 0; j < m; j++) {
                c[i] = c[i] + nm[i][j+1] * b[j];
            }*/
        }
        for(map<pair<int,int>,int>::iterator itr = nm.begin(); itr != nm.end(); ++itr) {
            tmp = itr->first;
            c[tmp.first] += b[tmp.second] * itr->second;
            //cout << "I'm hungry " << c[tmp.first] << " " << tmp.first << " " << tmp.second << endl;
        }


        for(int i=1;i<=n;i++){
            //cout << c[i];
            printf("%d",c[i]);
            if(i!=n) printf(" ");//cout <<  ' ';
        }
        printf("\n");

    }
    return 0;
}

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

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;
template<class T> struct edge{
	int to;
	T wt;
	edge(int to,const T& wt):to(to),wt(wt){}
};
template<class T> using weighted_graph=vector<vector<edge<T>>>;

const int INF=1<<29;

int main(){
	int n,m; scanf("%d%d",&n,&m);
	weighted_graph<int> G(n);
	rep(i,m){
		int u,v,d; scanf("%d%d%d",&u,&v,&d); u--; v--;
		G[u].emplace_back(v,d);
		G[v].emplace_back(u,d);
	}
	int Tmax; scanf("%d",&Tmax);

	// Warshall-Floyd
	vector<vector<int>> d(n,vector<int>(n,INF));
	rep(u,n) d[u][u]=0;
	rep(u,n) for(auto e:G[u]) {
		int v=e.to;
		d[u][v]=min(d[u][v],e.wt);
	}
	rep(w,n) rep(u,n) rep(v,n) d[u][v]=min(d[u][v],d[u][w]+d[w][v]);

	list<pair<int,int>> Wait,Now;
	int phase=0;
	int cur=0,next,edge_pos,goal;
	bool on_edge=false;
	rep(t,Tmax){
		int n_new; scanf("%d",&n_new);
		if(n_new>0){
			int id,dst; scanf("%d%d",&id,&dst); id--; dst--;
			Wait.emplace_back(id,dst);
		}

		int res=-1;

		if(phase%2==0 && cur==0){ // at the shop
			Now.insert(Now.end(),Wait.begin(),Wait.end());
			Wait.clear();
			if(!Now.empty()){
				goal=Now.front().second;
				phase++;
			}
		}
		else if(phase%2==0){ // at customer
			for(auto it=Now.begin();it!=Now.end();++it) if(it->second==goal) {
					it=Now.erase(it);
					--it;
			}
			goal=0;
			for(auto p:Now){
				if(goal==0 || d[cur][p.second]<d[cur][goal]) goal=p.second;
			}
			phase++;
		}

		if(phase%2==1){ // moving
			if(!on_edge){
				next=-1;
				for(auto e:G[cur]){
					if(next==-1 || d[cur][goal]==e.wt+d[e.to][goal]) next=e.to;
				}
				edge_pos=1;
				on_edge=true;
			}
			else{ // on_edge
				edge_pos++;
			}
			res=next;

			if(on_edge && edge_pos==d[cur][next]){
				on_edge=false;
				if(next==goal){
					phase++;
				}
				cur=next;
			}
		}

		printf("%d\n",res==-1?-1:res+1);
	}

	return 0;
}


Measured memory_bytes: 1024
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    Integer[] l = new Integer[n];
    for (int i = 0; i < n; i++) {
      l[i] = sc.nextInt();
    }
    Arrays.sort(l, Comparator.reverseOrder());
    int ans = 0;
    for (int i = 0; i < k; i++) {
      ans += l[i];
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 35752
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn main() {
    let n: usize = read();
    let grid: Vec<Vec<char>> = (0..n).map(|_| read::<String>().chars().collect()).collect();

    let mut ans = 0;
    for a in 0..n {
        let mut success = true;
        for i in 0..n {
            success &= (0..n).map(|j| grid[i][(j + a) % n] == grid[j][(i + a) % n]).all(|x| x);
        }
        if success {
            ans += n;
        }
    }
    println!("{:?}", ans);
}


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

int main() {
  int N;
  cin >> N;
  vector<int> v(N);
  
  for (int i=0; i<N; i++) cin >> v[i];
  
  sort(v.begin(), v.end());
  reverse (v.begin(), v.end());
  int a=0, b=0;
  for (int i=0; i<N; i++){
  	if (i%2==0) a+=v[i];
    else b+=v[i];
  }
  cout << a-b <<endl;
}


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

#define debug(s) cout << s << endl
#define debug1(s, t) cout << s << " " << t << endl
#define debug2(s, t, u) cout << s << " " << t << " " << u << endl
#define printvec(v)       \
    for (auto &&i : v)    \
        cout << i << " "; \
    cout << endl

using namespace std;
using i64 = long long;

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

    int counter = 0;
    for (int i=0; i<3; i++)
    {
        if (s[i]==t[i]) counter++;
    }

    cout << counter << endl;

    return 0;
}

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

int main() {
  int n;
  cin >> n;
  map<string, int> mp;
  rep(i,n) {
    string s;
    cin >> s;
    mp[s]++;
  }

  cout << "AC x " << mp["AC"] << endl;
  cout << "WA x " << mp["WA"] << endl;
  cout << "TLE x " << mp["TLE"] << endl;
  cout << "RE x " << mp["RE"] << endl;
  return 0;
}

Measured memory_bytes: 3628
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n)for(int i=0;i<(int)(n);i++)
#define PI 3.141592653589793
//vector < vector<int>>a(0, vector<int>(0));二次元配列宣言


int main()
{
	int a, b, t;
	cin >> a >> b >> t;
	int sum = 0;
	for (int i = a; i <= t; i += a)
	{
		sum += b;
	}
	cout << sum << endl;
}

Measured memory_bytes: 3568
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <cctype>
#include <unordered_map>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<long, long>;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(int i = 0; i<n; i++)
#define rep_s(i, start, n) for(int i= start;  i<n; i++)
#define rep_down(i, n) for(int i = n-1; i>=0; i--)
#define rep_down_s(i, n, start) for(int i = n-1; i>=start; i--)
#define ALL(a) (a).begin(), (a).end()
#define ALL_str(a) (a).cbegin(), (a).cend()

string alphabet_upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alphabet_lower  = "abcdefghijklmnopqrstuvwxyz";
string numbers = "0123456789";
/*
for (iterator = hash.begin(); iterator != hash.end(); iterator++)
{
// ここで、要素毎の操作を行います。
std::pair<std::string, CMyClass> element = *iterator;

}
*/
/*
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/
int keta_sum(int num){
  int dig, sum = 0;
  while(num){
    dig = num % 10;
    sum = sum + dig;
    num = num / 10;
  }
  return sum;
}

ll binary_search(ll left_key, ll border, ll low, ll high) {
     // 配列 a の左端と右端
    ll mid = (low+high)/2;
    while (high > low+1) {
       mid = (low+high)/2;
        if (left_key*mid>border) high = mid;
        else if (left_key*mid<border) low = mid;
        else {
          mid =mid-1;
          break;
        }
    }
    return mid;
}

bool IsPrime(ll a){
  ll b = sqrt(a);
  b++;
  while(b-->=2){
    if (a%b==0) return false;
  }
  return true;
}

ll gcd(ll a, ll b){
  ll tmp;
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }

  ll r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}

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

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

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

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(void){
  ll N, M, A, B, C, D, E, F, K,L, W, H, P, Q, R, X, Y;
  ll ans;
  string S, T;
  cin >> N;
  ll d[N];
  ans = 0;
  rep(i, N) cin>>d[i];
  rep(i, N-1){
    rep_s(j, i+1, N){
      ans += d[i]*d[j];
    }
  }
  
  cout << ans << endl;
  
  
   




}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#define EPS 1e-10
using namespace std;

struct P{
	double x,y;
	P(double xx=0,double yy=0){
		x=xx;
		y=yy;
	}
	P operator +(P &p){
		return P(x+p.x,y+p.y);	
	}
	P operator -(P &p){
		return P(x-p.x,y-p.y);	
	}
	P operator *(double d){
		return P(x*d,y*d);	
	}
	P operator /(double d){
		return P(x/d,y/d);	
	}
	double abs(){
		return sqrt(norm());
	}
	double norm(){
		return x*x+y*y;
	}
	bool operator ==(const P &p)const{
		return fabs(x-p.x)<EPS && fabs(y-p.y)<EPS;
	}
	double dot(P p){
		return x*p.x+y*p.y;
	}
	double cross(P p){
		return x*p.y-y*p.x;
	}
};

typedef P Vector;

int ccw(P p0,P p1,P p2){
	Vector a=p1-p0;
	Vector b=p2-p0;
	if(a.cross(b)>EPS)return 1;
	if(a.cross(b)<-EPS)return -1;
	if(a.dot(b)<-EPS)return 2;
	if(a.norm()<b.norm())return -2;
	return 0;
}

int main(void){
	P p0,p1,p2;
	scanf("%lf %lf %lf %lf",&p0.x,&p0.y,&p1.x,&p1.y);
	int q;
	scanf("%d",&q);
	for(int i=0;i<q;i++){
		scanf("%lf %lf",&p2.x,&p2.y);
		int res=ccw(p0,p1,p2);
		if(res==2)printf("ONLINE_BACK\n");
		if(res==1)printf("COUNTER_CLOCKWISE\n");
		if(res==0)printf("ON_SEGMENT\n");
		if(res==-1)printf("CLOCKWISE\n");
		if(res==-2)printf("ONLINE_FRONT\n");
	}
	return 0;
}

Measured memory_bytes: 1052
#include<cstdio>
#include<cstring>
#include<algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define N 210
#define M 10000010
using namespace std;
int n,a[M],q[N],w[N],bz[M],p[M],last[N],nxt[N*N],to[N*N],tot=0,b[N],jy=0,ans=0;
void link(int x,int y)
{
	nxt[++tot]=last[x];last[x]=tot;to[tot]=y;
}
int dg(int x)
{
	if(bz[x]==tot) return 0;
	bz[x]=tot;
	for(int i=last[x];i;i=nxt[i])
	{
		int y=to[i];
		if(b[y]==0||dg(b[y]))
		{
			b[y]=x;return 1;
		}
	}
	return 0;
}
int main()
{
	fo(i,2,10000000)
	{
		if(!bz[i]) p[++p[0]]=i;
		fo(j,1,p[0])
		{
			int k=i*p[j];
			if(k>=10000000) break;
			bz[k]=1;
			if(i%p[j]==0) break;
		}
	}
	scanf("%d",&n);
	fo(i,1,n)
	{
		int x;scanf("%d",&x);
		a[x]=1;
	}
	fo(i,1,10000002)
	if(a[i]!=a[i-1])
	{
		if(i%2==1) q[++q[0]]=i;
		else w[++w[0]]=i;
	}
	bz[1]=bz[2]=1;
	fo(i,1,q[0]) fo(j,1,w[0]) if(bz[abs(q[i]-w[j])]==0) link(i,j);
	memset(bz,0,sizeof(bz));
	for(tot=1;tot<=n;tot++) jy+=dg(tot);
	ans=jy;
	ans+=2*((q[0]-jy)/2);
	ans+=2*((w[0]-jy)/2);
	ans+=3*((q[0]-jy)%2);
	printf("%d\n",ans);
}

Measured memory_bytes: 81792
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,k; cin>>n>>k;
    int ans=1e9;
    vector <int> a;
    for(int i=0;i<n;i++){
        int tmp;
        cin>>tmp;
        a.push_back(tmp);
    }
    for(int i=0;i<n-k+1;i++){
        int tmp;
        //cout<<a[i+k-1]<<endl;
        if(a[i]<=0&&a[i+k-1]>=0){
        int tmp1=abs(min(a[i],0))*2+abs(max(0,a[i+k-1]));
        int tmp2=abs(min(a[i],0))+2*abs(max(0,a[i+k-1]));
        tmp=min(tmp1,tmp2);
        }
        if(a[i]>0) tmp=abs(max(0,a[i+k-1]));
        if(a[i+k-1]<0) tmp=abs(min(a[i],0));
        //cout<<tmp<<endl;
        ans=min(tmp,ans);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 892
#include <iostream>
#include <stdio.h>
#include <tuple>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
  int n, m, a;
  while(scanf("%d%d%d", &n, &m, &a) != EOF && n) {
    vector<tuple<int,int,int>> ami;
    for (int i=0; i<m; i++) {
      int h, p, q;
      scanf("%d%d%d", &h, &p, &q);
      ami.push_back(make_tuple(h, p, q));
    }
    sort(ami.begin(), ami.end());
    reverse(ami.begin(), ami.end());
    int now = a;
    for (unsigned int i=0; i<ami.size(); i++) {
      if (get<1>(ami[i]) == now) {
	now = get<2>(ami[i]);
      } else if (get<2>(ami[i]) == now) {
	now = get<1>(ami[i]);
      }
    }
    printf("%d\n", now);
  }
}

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

  double h,Max=0,Min=1000000000;

  while(scanf("%lf",&h)!=EOF)
    {
      if(Max<h)Max=h;
      if(Min>h)Min=h;
}
  printf("%.1f\n",Max-Min);

  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main(){
	long a,b,k;
  	cin>>a>>b>>k;
  	if(k>=a){
    	if(b-(k-a)>=0){
        	cout<<0<<' '<<b-(k-a)<<endl;
        }
    	else{
     	cout<<0<<' '<<0<<endl;
     	}
    }
  	else{
    cout<<a-k<<' '<<b<<endl;
    }
}

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

int N, G[2][101];

int main(){
	int large = 0;
	scanf("%d", &N);
	for(int i = 0; i < 2; i++)
		for(int j = 1; j <= N; j++)
			scanf("%d", &G[i][j]), G[i][j] += G[i][j - 1];
	for(int i = 1; i <= N; i++) large = max(large, G[0][i] + G[1][N] - G[1][i - 1]);
	printf("%d\n", large);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,n,m) for(int i=n;i<=(int)(m);i++)
#define RFOR(i,n,m) for(int i=(int)(n);i>=m;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
typedef long long ll;
const int INF = 1e9;
const int MOD = 998244353;
const ll LINF = 1e18;
const double PI=3.14159265358979323846;
using namespace std;
vector<int> dx={1,0,-1,0};
vector<int> dy={0,1,0,-1};
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    int n;
    cin>>n;
    map<int,ll> mp;
    vector<int> vec(n);
    rep(i,n) {
        int d;
        cin>>d;
        vec[i]=d;
        mp[d+1]++;
    }
    if(vec[0]!=0) {
        cout<<0<<endl;
        return 0;
    }
    
    ll ans=1;
    rep(i,n) {
        if(i==0) continue;
        ans*=(ll)mp[vec[i]];
        ans%=MOD;
    }
    //cout<<MOD<<endl;
    cout<<ans<<endl;
}


Measured memory_bytes: 6912
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
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; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define req(i,n) for(long long i=n-1; i>=0; i--)
#define range(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define onBoard(y,x) (y>=0 && y<h && x>=0 && x<w)
#define vint vector<int>
#define pri_que priority_queue
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a/gcd(a,b)*b;}
const long long dx[8]={1,0,-1,0,1,-1,-1,1};
const long long dy[8]={0,1,0,-1,1,1,-1,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    int n,m; cin >> n >> m;
    int res=1;
    if(abs(n-m)>=2){
        cout<<0<<endl;
        return 0;
    }else if(abs(n-m)==1){
        for(int i=1; i<=n; i++){
            res*=i;
            res%=MOD;
        }
        for(int i=1; i<=m; i++){
            res*=i;
            res%=MOD;
        }
    }else{
        for(int i=1; i<=n; i++){
            res*=i;
            res%=MOD;
        }
        for(int i=1; i<=m; i++){
            res*=i;
            res%=MOD;
        }
        res*=2;
        res%=MOD;
    }
    cout<<res<<endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
const int N=2e3+5;
int n,x,y;
int sum[N];
int main(){
	scanf("%d%d%d",&n,&x,&y);
	for (register int i=1; i<n; ++i)
	for (register int j=i+1; j<=n; ++j)
	{
		int now;
		now=min(j-i,abs(i-x)+abs(j-y)+1);
		sum[now]++;
/*		if (i<=j && j<=x && x<=y) {sum[j-i]++; continue;}
		if (i<=x && x<=j && j<=y) 
		{
			now=min(j-i,x-i+y-j+1);
			sum[now]++;
			continue;
		}
		if (i<=x && x<=y && y<=j) {sum[j-i-1]++; continue;}
		if (x<=i && i<=j && j<=y) 
		{
			now=min(j-i,i-x+y-j+1);
			sum[now]++;
			continue;
		}	
		if (x<=i && i<=y && y<=j)
		{
			now=min(j-i,i-x+j-y+1);
			sum[now]++;
			continue;
		}
		if (x<=y && y<=i && i<=j) {sum[j-i]++; continue;}*/
	}	
	for (register int i=1; i<n; ++i) printf("%d\n",sum[i]);
return 0;	
}

Measured memory_bytes: 256
using System;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        int[] I = Console.ReadLine().Split(' ').Select(o => int.Parse(o)).ToArray();
        int A = I[0];
        int B = I[1];

        int O = A - B * 2;
        O = O < 0 ? 0 : O;

        Console.WriteLine(O);
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define ll long long
#define ls id << 1
#define rs id << 1 | 1
#define mem(array, value, size, type) memset(array, value, ((size) + 5) * sizeof(type))
#define memarray(array, value) memset(array, value, sizeof(array))
#define pb(x) push_back(x)
#define st(x) (1LL << (x))
#define pii pair<int, int>
#define mp(a, b) make_pair((a), (b))
#define Flush fflush(stdout)
using namespace std;
const int N = 500050;
const int inf = 0x3f3f3f3f;
const ll llinf = 0x3f3f3f3f3f3f;
const ll mod = 998244353LL;
clock_t TIME_START, TIME_END;
void program_end()
{
#ifdef ONLINE
    printf("\nTime used: %.6lf(s)\n", ((double)TIME_END - TIME_START) / CLOCKS_PER_SEC);
    system("pause");
#endif
}
int n;
string s;
int a[4];

void solve()
{
    cin >> n;
    while(n--)
    {
        s.clear();
        cin>>s;
        if(s=="WA")
            a[1]++;
        if(s=="AC")
            a[0]++;
        if(s=="TLE")
            a[2]++;
        if(s=="RE")
            a[3]++;
    }
    printf("AC x %d\n", a[0]);
    printf("WA x %d\n", a[1]);
    printf("TLE x %d\n", a[2]);
    printf("RE x %d\n", a[3]);
}

int main()
{
    TIME_START = clock();
    int Test = 1;
    // cin >> Test;
    while (Test--)
        solve();
    TIME_END = clock();
    program_end();
    return 0;
}

Measured memory_bytes: 3764
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <stdlib.h>

using namespace std;


int main(){
	string line;

	while(getline(cin, line)){
		int flag = 0;

		for(int i=0 ; i<26 ; i++){
			for(int j=0 ; j<line.size() ; j++){
				if(line[j] != ' ' && line[j] != '.'){
					if(line[j] == 'a'){
						line[j] = 'z' ;
					}else{
						line[j]--;
					}
				}
			}

			for(int k=0 ; k<line.size()-2 ; k++){
				if(line[k] == 't' && line[k+1] == 'h'){
					flag = 1;
					cout << line << endl;
					break;
				}
			}
			if(flag == 1) break;
		}
		//cout << line << endl;
	}
	return 0;
}

Measured memory_bytes: 1172
using System;

class Test{
  public static void Main(){
    var num = Console.ReadLine().Split(' ');
    if(num[0]==num[1]||num[2]==num[1]||num[0]==num[2]){
      if(num[0]!=num[1]||num[2]!=num[1]||num[0]!=num[2]){
        Console.Write("Yes");
      }else{
        Console.Write("No");
      }
    }else{
        Console.Write("No");
    }
  }
}

Measured memory_bytes: 11092
N,M = map(int,input().split())
A = sorted(list(map(int,input().split())))
B = sorted([list(map(int,input().split())) for _ in range(M)],key=lambda x:x[1],reverse=True)
cur = 0
cnt = B[0][0]
for i in range(N):
    a = A[i]
    if cur<M and B[cur][1]>a:
        if cnt>0:
            A[i] = B[cur][1]
            cnt -= 1
        else:
            cur += 1
            if cur<M:
                cnt = B[cur][0]
                if B[cur][1]>a:
                    A[i] = B[cur][1]
                    cnt -= 1
print(sum(A))

Measured memory_bytes: 101884
#include <iostream>

#define SIZE 100000
#define INF  1000000000

int  N, K;
long h[SIZE];
long dp[SIZE];

long calc(int idx) {
    long res = INF;
    int  m = std::max(0, idx - K);
    for (int i=idx-1; i>=m; --i) {
        long tmp = dp[i] + std::abs( h[i] - h[idx] );
        res = std::min(res, tmp);
    }
    return res;
}

void solve() {
    for (int i=1; i<N; ++i) {
        dp[i] = calc( i );
    }
    std::cout << dp[N-1] << std::endl;
}

int main() {
    std::cin >> N >> K;
    for (int i=0; i<N; ++i) std::cin >> h[i];
    solve();
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include "unistd.h"
using namespace std;
#define WA cout<<"char134217728";exit(0)
#define RE throw
#define TLE sleep(1000)
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define uniq(v) sort(all(v));v.erase(unique(all(v)), v.end());
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return (x%m+m)%m;}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 1e5;
string s;
int c[2];
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> s;
  FOR(i, 0, sz(s)) c[s[i]-'0']++;
  cout << min(c[0], c[1])*2 << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(long long i = 0; i < (n); ++i)
#define ll long long
#define P pair<ll,ll>
#define all(v) (v).begin(),(v).end()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    ll n,k; cin>>n>>k;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    sort(all(a));
    ll ans=INF;
    for(int i=0; k-1+i<n ;i++){
        ans=min(ans,a[k-1+i]-a[i]);
    }

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

Measured memory_bytes: 3968
#include <bits/stdc++.h>
using namespace std;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i));
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a); i>n; --i)
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
inline int f(int n, vi s, int q, vi t) {
	int cnt = 0;
	rep(j, 0, q) {
		if (binary_search(all(s), t[j])) ++cnt;
	}
	return cnt;
}
int main() {
	int n; cin >> n;
	vi s(n); rep(i, 0, n) cin >> s[i];
	int q; cin >> q;
	vi t(q); rep(i, 0, q) cin >> t[i];
	P(f(len(s), s, q, t));
	return 0;
}

Measured memory_bytes: 3996
package main

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

var sc *bufio.Scanner = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}()

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

func countChangingPalindrome(s string) (count int) {
	rns := []rune(s)
	l := len(s)
	for i := 0; i < l/2; i++ {
		if rns[i] != rns[l-1-i] {
			count++
		}
	}
	return
}

func main() {
	s := nextString()
	r := countChangingPalindrome(s)
	fmt.Println(r)
}


Measured memory_bytes: 640
from math import log2,ceil
N,K = map(int,input().split())
ans = 0
for i in range(1,N+1):
    if i >= K:
        ans += N-K+1
        break
    t = ceil(log2(K) - log2(i))
    ans += (0.5**t)
ans /= N
print(ans)

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

bool solve(const vector<string>& w){
    const int n=w.size();
    // condition 1
    for(int i=0;i<n-1;++i){
        if(w[i].back() != w[i+1].front()){
            return false;
        }
    }
    //condition 2
    for(int i=0;i<n;++i){
        for(int j=i+1;j<n;++j){
            if(w[i]==w[j]){
                return false;
            }
        }
    }

    return true;

}
vector<string> input(){
    int n;cin>>n;
    vector<string> w(n);
    for(int i=0;i<n;++i){
        cin>>w[i];
    }
    return w;
}
int main(){
    const vector<string> w = input();
    if(solve(w)){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}

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

namespace ABC085A
{
    class Program
    {
        static void Main(string[] args)
        {
            string s;
            s = Console.ReadLine();
            Char[] cs = s.ToCharArray();
            cs[3] = '8';
            Console.WriteLine(cs);
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <string>

using namespace std;

int main()
{
	int a[200005],j,i,n;
	cin >> n;
	for(i=0; i<n; i++)
		cin >> a[i];
	for(i=n-1; i>=0; i-=2)
		cout << a[i] <<" ";
	if(i==-2) i=0;
	for(j=i+1; j<n; j+=2)
		cout << a[j] << " ";
}


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

int main() {
    string s;
    cin >> s;
    bool odd_check = true;
    bool even_check = true;
    for (int i=0; i<s.size(); i++) {
        if (i%2 == 0 && s[i] == 'L') odd_check = false;
        if (i%2 == 1 && s[i] == 'R') even_check = false;
    }
    if (odd_check && even_check) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

int main() {
	long long n, a, b;
	cin >> n >> a >> b;

	vector<long long> x(n, 0);
	for (int i = 0; i < n; i++) {
		cin >> x[i];
	}

	long long ans = 0;
	for (int i = 1; i < n; i++) {
		ans += min(a * (x[i] - x[i-1]), b);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
def main():
    from operator import itemgetter
    import sys
    sys.setrecursionlimit(10**9)
    input = sys.stdin.readline

    N = int(input())
    AB = [tuple(map(int, input().split())) for _ in range(N)]
    AB.sort(key=itemgetter(1))

    now = 0
    for a, b in AB:
        if now + a <= b:
            now += a
        else:
            print("No")
            return
    print("Yes")

main()

Measured memory_bytes: 37388
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll GCD(ll a, ll b){ return a ? GCD(b % a, a) : b; }
int main(){
    string s,t;
    cin>>s>>t;
    int cnt=0;
    for(int i=0; i<s.size(); i++){
        if(s[i]!=t[i]) cnt++;
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 3860