akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define N 100005

typedef struct pp{
  char name[100];
  int time;
}P;

P Q[N];
int head, tail, n;

void enqueue(P);
P dequeue(void);
int min(int a,int b){return a<b ? a:b;};

int main(){
  int x,q,sum,lap=0,a;
  P u;

  scanf("%d%d",&n,&q);
  tail=n+1;

  for(x=1;x<=n;x++){
    scanf("%s",Q[x].name);
    scanf("%d",&Q[x].time);
  }
  
  head=1;
  while(head!=tail){
    u=dequeue();
    a=min(q,u.time);
    u.time-=a;
    lap+=a;
    if(u.time>0) enqueue(u);
    else{
      printf("%s %d\n",u.name,lap);
    }
  }
  return 0;
}

void enqueue(P x){
  Q[tail]=x;
  tail=(tail+1) % N;
}

P dequeue(){
  P x =Q[head];
  head=(head+1)%N;
  return x;
}


Measured memory_bytes: 11888
#include <stdio.h>
int main(){
  int a, b, c, e, x, y, total;

  scanf("%d %d %d %d", &a, &b, &c, &e);

  total = a + b + c + e;
  x = total / 60;
  y = total % 60;

  printf("%d\n", x);
  printf("%d\n", y);

  return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define Inf 0x3f3f3f3f
#define rg register
#define pii pair<int, int>
#define mp(x, y) make_pair(x, y)
using namespace std;
typedef long long ll;
const int Maxn = 1e5 + 5;
typedef int arr[Maxn];
//ll Add(ll x, ll y) { return (x += y) >= Mod ? x - Mod : (x < 0 ? x + Mod : x); }
ll min(ll x, ll y) { return x < y ? x : y; }
ll max(ll x, ll y) { return x > y ? x : y; }
inline ll read()
{
	rg ll res = 0, sign = 1;
	rg char ch = getchar();
	while (!isdigit(ch))
	{
		if (ch == '-')
			sign = -1;
		ch = getchar();
	}
	do
	{
		res = (res << 3) + (res << 1) + (ch ^ 48);
		ch = getchar();
	} while (isdigit(ch));
	return res * sign;
}
ll n,ans;
int main()
{
	cin >> n;
	if (n & 1)
		puts("0");
	else
	{
		while (n)
		{
			ans += n / 10;
			n /= 5;
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#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 INF 1e9
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << ": " << x << endl;

using namespace std;
typedef long long ll;

signed main() {
  ll h, w;
  cin >> h >> w;
  ll a = h * w;
  if(h == 1 || w == 1) {
    cout << 1 << endl;
    return 0;
  }
  if(a % 2 == 0) {
    cout << a / 2 << endl;
  } else {
    cout << (a + 1) / 2 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
const int mod = 1000000007;
#define ll long long

int main()
{
	string S; cin >> S;
	for (int i = 0; i < S.size()-8; i++)
	{
		cout << S[i];
	}
	cout << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int a,b,c;
	int t,flag;
	while(cin>>a>>b>>c)
	{

		if(a>b)
		{
			t=a;
			a=b;
			b=t;
		}
		if(b>c)
		{
			t=b;
			b=c;
			c=t;
		}
		if(a>b)	
		{
			t=a;
			a=b;
			b=t;
		}	//	cout<<a<<" "<<b<<" "<<c<<endl;	
		t=0;
		t+=c-b;
		a+=c-b;
		b=c;
		flag=(c-a+1)/2;
		t+=flag;
		a+=flag*2;
        //cout<<flag<<endl;
		if(a>c)t++;
		cout<<t<<endl; 
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
bool flag[26];
int main(){
    string s; cin>>s;
    for(int i=0;i<s.size();i++)
        flag[s[i]-'a']=true;  
    for(int i=0;i<26;i++){
        if(!flag[i]){
            cout<<(char)('a'+i)<<"\n";
            return 0;
        }
    }
    cout<<"None"<<"\n";
    return 0;
}

Measured memory_bytes: 512
n = int(input())
a = list(map(int, input().split()))

# DP
# dp[i]: i日目の所持金の最大値（持ち株は売る）
dp = [0] * n
dp[0] = 1000

# dp[1] = 0日目に全部買って1日目に全部売る or 0日目から何もしない
# dp[2] = 0 or 1日目に全部買って2日目に全部売る or 1日目から何もしない
# dp[i+1] + 0~i日目のどこかで全部買ってi+1日目に全部売る or i日目から何もしない
for i in range(n):
    if i == 0:
        dp[i] = 1000
        continue
    
    dp[i] = dp[i-1]
    for j in range(i):
        # j日目に全部買ってi日目に全部売る
        dp[i] = max(dp[i], (dp[j] // a[j]) * a[i] + dp[j] % a[j])
    
print(dp[n-1])

Measured memory_bytes: 9088
open Printf
open Scanf

let () =
  let n, m = scanf "%d %d " (fun x y -> (x, y)) in
  let g = Array.make n [] in
  let rec set_graph x =
    if x = 0 then ()
    else begin
        let u, v = scanf "%d %d " (fun x y -> (x, y)) in
        g.(u) <- v :: g.(u);
        g.(v) <- u :: g.(v);
        set_graph (x-1)
      end
  in
  let grp = Array.make n 0 in
  let rec set_group i gi =
    let que = Queue.create () in
    let rec iter () =
      if Queue.is_empty que then ()
      else let j = Queue.pop que in
           if grp.(j) <> 0 then iter ()
           else begin
               grp.(j) <- gi;
               List.iter (fun k -> Queue.push k que) g.(j);
               iter ()
             end
    in
    if i = n then ()
    else begin
        Queue.push i que;
        iter ();
        set_group (i+1) (gi+1)
      end
  in
  let rec iter x =
    if x = 0 then ()
    else begin
        let u, v = scanf "%d %d " (fun x y -> (x, y)) in
        printf "%s\n" (if grp.(u) = grp.(v) then "yes" else "no");
        iter (x-1)
      end
  in
  set_graph m;
  set_group 0 1;
  let q = scanf "%d " (fun x -> x) in
  iter q

Measured memory_bytes: 15788
#include<iostream>
#include<string>
#include<map>

using namespace std;

typedef struct _index_t{
  int l;
  int r;
} index_t;

int main(){
  int N, Q;
  string S;
  map<int, int> mp;
  cin >> N >> Q;
  cin >> S;
  index_t ind[Q];
  
  mp.insert(make_pair(-1,0));
  for(int i=0; i < N-1; i++){
    if(S[i] == 'A' && S[i+1] == 'C') {
      mp.insert(make_pair(i,mp[i-1] + 1));
    }else{
      mp.insert(make_pair(i,mp[i-1]));
    }
  }
  
  for(int i=0; i<Q; i++){
    cin >> ind[i].l >> ind[i].r;
    cout << (mp[ind[i].r-2] - mp[ind[i].l-2]) << endl;
  }
  return 0;
}

Measured memory_bytes: 6400
import sys
from collections import defaultdict
import math

def input():
    return sys.stdin.readline().rstrip()


def main():
    N = int(input())
    A = list(map(int,input().split()))
    A.sort(reverse=True)
    g = A[0]

    for i in range(1,N):
        g = math.gcd(g,A[i])

    print(g)





if __name__ == "__main__":
    main()


Measured memory_bytes: 87140
N, K = map(int, input().split())

import math

prob = 0
for i in range(1, N+1):
    if (i<K):
        init = i
        times = math.ceil(math.log2(K/init))
        prob += (1/N)*(1/2)**(times)
    else:
        prob += 1/N
        
print(prob)

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

int main()
{
  int count;
  count = 1;
  int numbers[5];
  for(int i = 0; i < 5; i++)
  {
    cin >> numbers[i];
  }

  for(int i = 0; i < 5; i++)
  {
    if(numbers[i] == 0)
    break;
    else
    count++;
  }

  cout << count << endl;

}


Measured memory_bytes: 3472
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		int X = stdIn.nextInt();
		int Y = stdIn.nextInt();
		int b = 0;
		String ans = "No";
		for(int a = 0; a < X+1; a++){
			b = X - a;
			if(2 * a + 4 * b == Y){
				ans = "Yes";
			}
		}
		System.out.println(ans);
		stdIn.close();
	}
}

Measured memory_bytes: 35856
#include <iostream>
#include <cstring>
#include <algorithm>
#include <map>
#include <cstdio>
#include <string>
#include <queue>
using namespace std;
typedef long long ll;
ll min(ll a,ll b,ll c)
{
    return min(a,min(b,c));
}
ll max(ll a,ll b,ll c)
{
    return max(a,max(b,c));
}
ll a,b,c;
map<pair<ll,ll>,int>mmp;
int main()
{
    bool flag=1;
    int ans=0;
    scanf("%lld%lld%lld",&a,&b,&c);
    while(a%2!=1&&b%2!=1&&c%2!=1)
    {
        if(mmp[make_pair(min(a,b,c),max(a,b,c))]) {flag=0;break;}
        mmp[make_pair(min(a,b,c),max(a,b,c))]=1;
        ll x=a/2,y=b/2,z=c/2;
        a=a/2+z;
        b=b/2+x;
        c=c/2+y;
        ans++;
    }
    printf("%d\n",flag?ans:-1);
    return 0;
}


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

signed main() {
	int n;
	cin >> n;
	int ans = 0;
	int now = 0;
	rep(i, n) {
		int w;
		cin >> w;
		if(w >= now) {
			ans++;
		}
		now = max(now, w);
	}
	cout << ans << endl;
}

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

class Program
{
    static void Main(string[] args)
    {
        var input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var A = input[0];
        var B = input[1];
        
        if (A > 12) {
            Console.WriteLine(B);
        } else if (6 <= A && A <= 12) {
            Console.WriteLine(B / 2);
        } else {
            Console.WriteLine(0);
        }
    }
}


Measured memory_bytes: 13268
sx,sy,tx,ty = map(int,input().split())
dx,dy = tx-sx,ty - sy
print("R"*dx + "U"*dy + "L"*dx + "D"*(dy+1) +  
      "R"*(dx+1) + "U"*(dy+1) + "LU" +
      "L"*(dx+1)+ "D"*(dy+1) + "R")

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

#define MAXN 1121
#define MAXK 15

int N, K;
int dp[MAXN][MAXK];
int i, j;
vector<int> prime;

void makeprime(){
    bool primebool[MAXN];
    for(i = 0; i < MAXN; i++){
        primebool[i] = true;
    }

    primebool[0] = false;
    primebool[1] = false;

    for(i = 0; i < sqrt(MAXN); i++){
        if(!primebool[i]) continue;
        for(int j = 2 * i; j < MAXN; j += i){
            primebool[j] = false;
        }
    }

    for(i = 0; i < MAXN; i++){
        if(primebool[i]) prime.push_back(i);
    }
}


int main(){
    makeprime();
    while(true){
        cin >> N >> K;
        if(N == 0 && K == 0) break;

        for(i = 0; i < MAXN; i++){
            for(j = 0; j < MAXK; j++){
                dp[i][j] = 0;
            }
        }
        dp[0][0] = 1;

        for(int x: prime){
            if(x > N) break;
            for(j = K; j >= 0; j--){
                for(i = 0; i <= N; i++){
                    if(dp[i][j] != 0 && i + x <= N) dp[i + x][j + 1] += dp[i][j];
                }
            }
        }
        cout << dp[N][K] << endl;
    }
}



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

int main(void) {
    int m, n;
    int A[100][100] = {};
    int B[100] = {};
    int C[100] = {};
    
    cin >> n >> m;
    
    for(int i = 0; i < n; ++i) {
        for(int j = 0; j < m; ++j) {
            cin >> A[i][j];
        }
    }
    for(int i = 0; i < m; ++i) {
        cin >> B[i];
    }
    for(int i = 0; i < n; ++i) {
        for(int j = 0; j < m; ++j) {
            C[i] += A[i][j] * B[j];
        }
    }
    for(int i = 0; i < n; ++i) {
        cout << C[i] << endl;
    }
    
    return 0;
}



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

int main()
{
    int n,k;
    cin>>n>>k;
    int dp[200005],h[200005];
    for(int i=0;i<n;i++)
    {
        cin>>h[i];
    }
    dp[0]=0;
    dp[1]=abs(h[1]-h[0]);

    for(int i=2;i<n;i++)
    {
        dp[i]=1e9;
        for(int j=1;j<=k;j++)
        {
            if(i-j<0)
            break;
            dp[i]=min(dp[i-j]+abs(h[i]-h[i-j]),dp[i]);
        }
    }
    cout<<dp[n-1];
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    while(cin >> n, n){
        int ans = 0;
        rep(i, 1, 1010){
            rep(j, 2, 1010){
                int sum = (i + i + j - 1) * j / 2;
                if(sum == n) ans++;
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3236
#include <iostream>
#include <string.h>

using namespace std;
bool IsPrime[250000];
int PrimeCount[250000];
void calc()
{
	memset(IsPrime, 1, sizeof(bool) * 250000);
	int count = 0;
	PrimeCount[0] = count;
	PrimeCount[1] = count;
	for(int i = 2; i < 250000; ++i)
	{
		if(IsPrime[i])
		{
			count++;
			for(int j = 2 * i; j < 250000; j += i)
			{
				IsPrime[j] = false;
			}
		}
		PrimeCount[i] = count;
	}
}

void solve()
{
	calc();
	int n;
	while(cin >> n, n)
	{
		cout << PrimeCount[2 * n] - PrimeCount[n] << endl;
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 0
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <complex>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << (x) << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010

ll fac[SIZE];
ll inv[SIZE];

ll factorial(int n,int M){
  ll ret=1;
  if(n<=1) return 1;
  
  for(int i=1;i<=n;i++){
    ret = (ret*i)%M;
  }
  
  return ret;
}

ll power(int k,int n,int M){
  if(n==0) return 1;
  if(n==1) return (ll)k;
  
  ll ret = power(k,n/2,M);
  
  ret=(ret*ret)%M;
  
  if(n%2==1)
    ret=(ret*k)%M;
  
  return ret;
}

void fac_init(int n){
  fac[0] = 1;
  for(int i=1;i<=n;i++) fac[i] = (fac[i-1] * i)%mod;
  inv[n] = power(fac[n],mod-2,mod);
  for(int i=n;i>0;i--) inv[i-1] = (inv[i] * i)%mod;
}

//nCm nPm nHm (mod M)

/*Combination*/
int C(int n,int m,int M){
  if(n<m) return 0;
  if(m==0 || n==m) return 1;
  
  ll chi = fac[n];
  ll mot = (inv[m] * inv[n-m])%M;
  
  ll ret = (chi*mot)%M;
  
  return (int)ret;
}

int main(){
  int n;
  int a[SIZE];
  
  scanf("%d",&n);

  fac_init(n);
  
  int flag[SIZE];
  for(int i=0;i<=n;i++) flag[i] = -1;
  
  int b = -1, c = -1;
  
  for(int i=0;i<n+1;i++){
    scanf("%d",a+i);
    if(flag[a[i]] != -1){
      b = i;
      c = flag[a[i]];
    }
    flag[a[i]] = i;
  }

  ll ans = 0;

  printf("%d\n",n);

  //debug(c);
  //debug(n-b);
  
  for(int i=2;i<=n+1;i++){
  
    ans = C(n,i,mod);
    ans = (ans + C(n,i-1,mod))%mod;
    ans = (ans + mod - C(c + (n-b) ,i-1,mod))%mod;
    
    printf("%lld\n",ans);
  }
  
  return 0;
}


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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define dbg(x) cout<<#x" = "<<(x)<<ln

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > mat;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int n, a[100000], r;

int main() {
	cin >> n;
	rep(i,n) cin >> a[i];
	rep(i,n) {
		int j = i+1;
		while(j<n && a[i]==a[j]) j++;
		if (a[i]<a[j]) while (j<n-1 && a[j]<=a[j+1]) j++;
		else while (j<n-1 && a[j]>=a[j+1]) j++;
		i = j;
		r++;
	}
	cout << r << ln;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#include <set>

using namespace std;

int main()
{
  string s,t;
  cin >> s >> t;
  string tp;
  tp = t.substr(0, s.length());
  if(s == tp) cout << "Yes" << endl;
  else cout << "No" << endl;
  
}


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

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

            Console.WriteLine(N * N - A);
            Console.ReadKey();
        }
        
    }
}

Measured memory_bytes: 11092
s = list(raw_input())
k = int(raw_input())
 
for i in range(len(s)):
    numChanges = ord('z') - ord(s[i]) + 1
    if s[i] != 'a' and numChanges <= k:
        s[i] = 'a'
        k -= numChanges
 
    if i == len(s) - 1:
        s[i] = chr(ord(s[i]) + (k % 26))
 
print ''.join(s)

Measured memory_bytes: 6532
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		
		int[][] e = new int[n][5];
		long sum = 0;
		long dmg = 0;
		boolean flag = false;
		for(int i=0;i<n;i++){
			e[i][0] = sc.nextInt();
			e[i][1] = sc.nextInt() - c;
			if(e[i][1]<=0) e[i][1] = 0;
			e[i][2] = b - sc.nextInt();
			if(e[i][2]<=0) e[i][2] = 0;
			if(e[i][1]>0 && e[i][2]==0) flag = true;
			e[i][3] = sc.nextInt();
			e[i][4] = -1;
			if(e[i][2]!=0){
				e[i][4] = e[i][0]/e[i][2];
				if(e[i][0]%e[i][2]!=0) e[i][4]++;
			}
			sum += e[i][1];
			if(e[i][3]>d) dmg+=e[i][1];
		}
		
		if(flag==false){
			Arrays.sort(e, new Comparator<int[]>(){
				public int compare(int[] o1, int[] o2) {
					if(((double)o2[1]/o2[4])-((double)o1[1]/o1[4])>0) return 1;
					else return -1;
				}
			});	
			
			dmg -= sum;
			for(int i=0;i<n;i++){
				dmg += e[i][4]*sum;
				sum -= e[i][1];
			}
			if(dmg>=a || dmg<0) flag = true;
		}
		
		if(flag==true) System.out.println(-1);
		else System.out.println(dmg);
	}	
}

Measured memory_bytes: 99232
import java.util.Scanner;

public class Main {

	public static void main(final String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		char[] S = sc.next().toCharArray();
		sc.close();
		S[K - 1] = (char)(S[K - 1] + 32);
		for(int i = 0; i < N; i++) {
			System.out.print(S[i]);
		}
	}
}

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

int bubbleSort(int A[] ,int);

int main()
{
  int A[100],N,sw;
  cin>>N;
  for(int i=0;i<N;i++) cin>>A[i];
  sw=bubbleSort(A,N);
  for(int i=0;i<N;i++){
    if(i) cout<<" ";
    cout<<A[i];
  }
  cout<<endl;
  cout<<sw<<endl;
  return 0;
}

int bubbleSort(int A[],int N)
{
  int sw=0;
  bool flag=1;
  for(int i=0;flag;i++){
    flag=0;
    for(int j=N-1;j>=i+1;j--){
      if(A[j]<A[j-1]){
	swap(A[j],A[j-1]);
	flag=1;
	sw++;
      }
    }
  }
  return sw;
}






Measured memory_bytes: 3104
#include<iostream>

using namespace std;

int main(){
  int n;
  cin>>n;
  int h[20];
  for(int i=0;i<n;i++){
    cin>>h[i];
  }
  
  int now=h[0];
  int ans=1;
  for(int i=1;i<n;i++){
    if(now<=h[i]){
      now=h[i];
      ans++;
    }
  }
  
  cout<<ans;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
ans = 0
plus_lis = [A[i] + i for i in range(N)]
minus_lis = [k - A[k] for k in range(N)]

ans_lis = [0] * 10 ** 6
for x in plus_lis:
    if x < 10 ** 6:
        ans_lis[x-1] += 1
for y in minus_lis:
    if y > 0:
        ans += ans_lis[y-1]
print(ans)


Measured memory_bytes: 41532
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end())
#define vecmin(A) *min_element(A.begin(),A.end())
#define vecmax(A) *max_element(A.begin(),A.end())
typedef long long ll;

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

Measured memory_bytes: 19260
#include <stdio.h>
int main(void){
    int a[10],b[10],d[10],e[10],c,i,cnt=0;
    for(i=1;i<=6;i++){
        scanf("%d",&b[i]);
        a[i] = b[i];}
    for(i=1;i<=6;i++){
        scanf("%d",&e[i]);
        d[i] = e[i];}
    for(i=1;i<=5;i++){
        if(a[i]>a[i+1]){
            c = a[i+1];
            a[i+1] = a[i];
            a[i] = c;}
        if(d[i]>d[i+1]){
            c = d[i+1];
            d[i+1] = d[i];
            d[i] = c;}}
    for(i=1;i<=6;i++){
        if(a[i] == d[i])
            cnt++;}
    if((cnt==6) && (a[1]==a[2]) && (a[2]==a[3]) && (a[3]==a[4]) && (a[4]==a[5])){
        printf("Yes\n");
        return 0;}
    for(i=0;i<4;i++){    /*tate idou*/
        if(b[1] == e[1])
            break;
        c = b[1];
        b[1] = b[2];
        b[2] = b[6];
        b[6] = b[5];
        b[5] = c;}
    for(i=0;i<4;i++){    /*tate(1ga yokoniarutoki) idou*/
        if(b[1] == e[1])
            break;
        c = b[1];
        b[1] = b[3];
        b[3] = b[6];
        b[6] = b[4];
        b[4] = c;}
    for(i=0;i<4;i++){    /*yoko idou*/
        if(b[2] == e[2])
            break;
        c = b[2];
        b[2] = b[3];
        b[3] = b[5];
        b[5] = b[4];
        b[4] = c;}
    for(i=2;i<=6;i++){
        if(b[i] != e[i]){
            printf("No\n");
            return 0;}}
    printf("Yes\n");    
    return 0;
}        

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

#define FOR(i,n,j) for(int i=(j);i<(n);++i)
#define ssort(n) sort((n).begin(),(n).end())
#define rsort(n) sort((n).begin(),(n).end(),greater<int>())
using ll=long long;
using ld=long double;
typedef pair<int,int> P;
typedef pair<P,int> COST;
#define repl(i,n) for(ll i=0;i<(n);++i)
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define M 100000
int main()
{
    string s,t;
    cin >> s ;
    cin >> t;
    int max=0;
    int count=0;
    rep(i,s.size()-t.size()){
        rep(j,t.size()){
            if(s[i+j]==t[j]){
                count++;
            }
        }
        if(max<count){
            max=count;
        }
        count=0;
    }if(s.size()==t.size()){
        rep(j,t.size()){
            if(s[j]==t[j]){
                max++;
            }
        }
    }
    
    cout << t.size()-max << endl;
    
    
}

Measured memory_bytes: 3596
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<string>
#include<math.h>
#include<stdlib.h>
#include<time.h>
#include<map>
#include<queue>
#include<set>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;
int n,be[120000],x[120000],y[120000],d[120000],et,tot,con[120000];
struct edg{
	int y,ne;
};
edg e[220000];
inline void add_edge(int x,int y){
	e[++et].y=y;
	e[et].ne=be[x];
	be[x]=et;
}
int q[120000],he,ta;
int main(){
	scanf("%d",&n);
	fo(i,2,n){
		scanf("%d%d",&x[i],&y[i]);
		add_edge(x[i],y[i]);
		add_edge(y[i],x[i]);
		d[x[i]]++;
		d[y[i]]++;
	}
	fo(i,1,n)
		if (d[i]==1) q[++ta]=i;
	he=1;
	while (he<=ta){
		int &x=q[he];
		int i=be[x],y;
		while (i){
			if (d[e[i].y]){
				y=e[i].y;
				break;
			}
			i=e[i].ne;
		}
		if (d[y]==2){
			//printf("cut%d %d\n",x,y);
			d[y]-=2;
			i=be[y];
			while (i){
				if (d[e[i].y]){//!!!!!!!
					d[e[i].y]--;
					if (d[e[i].y]==1) q[++ta]=e[i].y;
					if (d[e[i].y]==2&&con[e[i].y]) q[++ta]=con[e[i].y];		
				}
				i=e[i].ne;
			}
		}
		else{
			if (con[y]&&con[y]!=x){//!!!!!! forgot con[y]!=x
				printf("First\n");
				return 0;
			}
			con[y]=x;
		}
		he++;
	}
	bool du=0;
	fo(i,1,n) if (d[i]){
		du=1;
		break;
	}
	if (!du){
		printf("First\n");
		return 0;
	}
	/*fo(x,1,n){
		tot=0;
		int i=be[x];
		while (i){
			if (d[e[i].y]==1) tot++;
			i=e[i].ne;
		}
		if (tot>=2){
			printf("First\n");
			return 0;
		}
	}*/
	printf("Second\n");
	return 0;
}

Measured memory_bytes: 4352
/***********************
*  Author: xuziyuan    * 
***********************/

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++) 
#define LL long long
#define pii pair <int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

int a,b,k,num=0;

int main()
{
	cin>>a>>b>>k;
	for(int i=100;i>=1;i--)
	{
		if(a%i==0&&b%i==0) num++;
		if(num==k)
		{
			cout<<i<<endl;
			rt0;
		}
	}
	rt0;
}

Measured memory_bytes: 256
N=int(raw_input())
numbers=[int(x) for x in raw_input().split()]
mat=[[0 for x in range(21)] for y in range(N)]
mat[0][numbers[0]]=1
fin=numbers[-1]
for i in range(1,N-1):
    n=numbers[i]
    for j in range(21):
        if j+n<21:
            mat[i][j+n]+=mat[i-1][j]
        if j-n>-1:
            mat[i][j-n]+=mat[i-1][j]
print mat[N-2][fin]

Measured memory_bytes: 6464
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define watch(x) cout << "["<<(#x) << " is " << (x) << "]" << endl
void watchVecI(vector<int>a){
	for(int i = 0; i < a.size(); ++i){
		cout << a[i] << " ";
	}
	cout << endl;
}
void watchVecS(vector<string>a){
	for(int i = 0; i < a.size(); ++i){
		cout << a[i] << " ";
	}
	cout << endl;
}
long double binets(double n){
	long double first = (1+sqrt(5.0))/2.0;
	long double second = (1-sqrt(5.0))/2.0;
	long double third = pow(first,n)-pow(second,n);
	return (third/sqrt(5.0));
}



void solve(){
	int n;
	cin >> n;
	if(n>=400&&n<=599){
		cout << 8 << endl;
		return;
	}
	if(n>=600&&n<=799){
		cout << 7 << endl;
		return;
	}
	if(n>=800&&n<=999){
		cout << 6 << endl;
		return;
	}
	if(n>=1000&&n<=1199){
		cout << 5 << endl;
		return;
	}
	if(n>=1200&&n<=1399){
		cout << 4 << endl;
		return;
	}
	if(n>=1400&&n<=1599){
		cout << 3 << endl;
		return;
	}
	if(n>=1600&&n<=1799){
		cout << 2 << endl;
		return;
	}
	if(n>=1800&&n<=1999){
		cout << 1 << endl;
		return;
	}
}


int main(){
	//freopen("input.txt", "r", stdin);
	solve();
	return 0;
}

Measured memory_bytes: 3636
{-# LANGUAGE BangPatterns #-}
import           Control.Monad (replicateM)
import           Data.List     (foldl')

main :: IO ()
main = do
  s <- getLine
  q <- readLn
  qs <- replicateM q getQuery
  putStrLn $ solve s qs

data Query = Reverse | Add Bool Char

getQuery :: IO Query
getQuery = do
  (t:xs) <- words <$> getLine
  if t == "1"
    then return Reverse
    else let [f, c] = xs in return $ Add (f == "1") (head c)

solve :: String -> [Query] -> String
solve s qs = toList $ foldl' g (fromList s) qs
  where g !xs Reverse   = rev xs
        g !xs (Add f c) = add c f xs

data DoubleList a = DoubleList ![a] ![a] Bool
  deriving Show

fromList :: [a] -> DoubleList a
fromList xs = DoubleList xs [] True

toList :: DoubleList a -> [a]
toList (DoubleList xs ys True)  = xs ++ reverse ys
toList (DoubleList xs ys False) = ys ++ reverse xs

rev :: DoubleList a -> DoubleList a
rev (DoubleList xs ys f) = DoubleList xs ys $ not f

add :: a -> Bool -> DoubleList a -> DoubleList a
add x True (DoubleList xs ys True)   = DoubleList (x:xs) ys True
add x True (DoubleList xs ys False)  = DoubleList xs (x:ys) False
add x False (DoubleList xs ys True)  = DoubleList xs (x:ys) True
add x False (DoubleList xs ys False) = DoubleList (x:xs) ys False


Measured memory_bytes: 172284
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;
const int inf = 10e9 + 7;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,m,n) for(int i=m;i<n;i++)
#define endre getchar(); getchar();return 0;

signed main() {
	int a, b;
	cin >> a >> b;
	if (b%a == 0) { cout << a + b << endl; }
	else { cout << b - a << endl; }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
//#include <functional> // for less
//using namespace __gnu_pbds;
using namespace std;
typedef long long  L;

#define max_(x, y) (((x) > (y)) ? (x) : (y))
#define min_(x, y) (((x) < (y)) ? (x) : (y))
#define ___ ios_base::sync_with_stdio(false);cin.tie(NULL);
#define Mx 2000001
#define inf 1e17
const L MOD = 1e9+7;
const double pi = 2 * acos (0.0);

/*------------------------------Graph Moves----------------------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/


//typedef tree<L,null_type,less<L>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

L a,b,a1,a2,a3,b1,b2,b3,c,c1,c2,c3,d,d1,d2,d3,d4,d5,e1,e2,e3,f,h,k,l,n,m,m1,m2,n1,n2,o,p1,p2,p3,p4,
q1,q2,q3,q4,r,s,t,x,y,z,sum,mn,flg,flg1,flg2,id1,id2,id3,lim,cost;
L A[Mx];
int main()
{
    c=0;
    scanf("%lld%lld",&n,&k);
    for(L i=0;i<k;i++){
        scanf("%lld",&d);
        for(L j=0;j<d;j++){
            scanf("%lld",&a);
            A[a]++;
        }
    }
    for(L i=1;i<=n;i++)if(A[i]==0)c++;
    printf("%lld\n",c);
    // solve();
    return 0;
}
/// empty() lld I64d push_back() top() pop() insert() upper_bound() lower_bound() memset() max() min() scanf continue


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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
//template<typename T> using vec=std::vector<T>;

const int inf=1<<30;
const long long int infll=1LL<<58;
const double eps=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    while(true){
        ll n,m;
        cin >> n; if(n==0) break;
        vector<ll> hp(n);
        for(ll& in:hp) cin >> in;
        cin >> m;
        vector<ll> consume(m),damage(m);
        vector<string> type(m);
        rep(i,0,m){
            string s;
            cin >> s >> consume[i] >> type[i] >> damage[i];
        }

        const ll sup=200001;
        ll ans=inf,dp1[sup],dp2[sup];
        fill_n((ll*)dp1,sup,inf);
        fill_n((ll*)dp2,sup,inf);
        dp1[0]=dp2[0]=0;
        rep(i,0,m){
            ll* dp;
            if(type[i]=="Single") dp=dp1;
            else dp=dp2;
            rep(j,0,sup) dp[j]=min(dp[j],dp[max(j-damage[i],0LL)]+consume[i]);
        }
        rep(i,0,sup){
            ll tmp=dp2[i];
            rep(j,0,n) if(hp[j]-i>=0) tmp+=dp1[hp[j]-i];
            ans=min(ans,tmp);
        }
        cout << ans << endl;
    }
}

int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    solve();
    return 0;
}

Measured memory_bytes: 6312
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        Map<String, Integer> map = new HashMap<>();
        for (int i = 0; i < N; i++) {
            String S = sc.next();
            map.put(S, map.getOrDefault(S, 0)+1);
        }
        int max = 0;
        for (int c : map.values()) {
            max = Math.max(max, c);
        }

        List<String> list = new ArrayList<>();
        for (Map.Entry<String, Integer> e : map.entrySet()) {
            String s = e.getKey();
            int c = e.getValue();
            if (c == max) {
                list.add(s);
            }
        }

        Collections.sort(list);
        StringBuilder ans = new StringBuilder();
        for (String l : list) {
            ans.append(l).append('\n');
        }

        System.out.print(ans);
    }
}



Measured memory_bytes: 85092
#define _CRT_SECURE_NO_WARNINGS

#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<map>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<math.h>

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

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

const int mod = 1e9 + 7;
const long double pi = 3.141592653589793238462643383279502884197;
const long double eps = 1e-7;

int main() {
	string s,ans;
	cin >> s;
	int w;
	cin >> w;
	REP(i, s.size()) {
		if (i % w == 0) {
			ans += s[i];
		}
	}
	cout << ans;
	system("pause");
	return 0;
}

Measured memory_bytes: 504
n = int(input())
a = [0]
mx_cost = 0
tmp = 0
for i in map(int, input().split()):
    a.append(i)
    mx_cost += abs(tmp - i)
    tmp = i
mx_cost += abs(tmp)
a.append(0)

for i in range(1,n+1):
    cost = abs(a[i] - a[i+1]) + abs(a[i-1] - a[i])
    print(mx_cost - cost + abs(a[i-1] - a[i+1]))



Measured memory_bytes: 14128
#include<bits/stdc++.h>
#define mod 1000000007
typedef long long ll;
ll gi(){
	ll x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch))f^=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
int pow(int x,int y){
	int ret=1;
	while(y){
		if(y&1)ret=1ll*ret*x%mod;
		x=1ll*x*x%mod;y>>=1;
	}
	return ret;
}
int a[100010],p[100010],cir[100010],CIR,vis[100010];
int L[100010],D[100010],c[100010];
int fact[100010],ifact[100010],f[100010];
int C(int n,int m){return 1ll*fact[n]*ifact[m]%mod*ifact[n-m]%mod;}
int main(){
#ifdef XZZSB
	//freopen("in.in","r",stdin);
	//freopen("out.out","w",stdout);
#endif
	int n=gi();
	for(int i=1;i<=n;++i)a[i]=gi();
	int ans=1;
	for(int i=1;i<=n;++i)
		if(!vis[i]){
			int j;
			for(j=i;!vis[j];j=a[j])vis[j]=i;
			if(vis[j]==i){
				++CIR;
				while(!cir[j])cir[j]=CIR,j=a[j];
			}
		}
	for(int i=1;i<=n;++i)
		if(!cir[i]){
			if(p[a[i]])return puts("0"),0;
			p[a[i]]=i;
		}
	memset(vis,0,sizeof vis);
	for(int i=1;i<=n;++i)
		if(cir[i]&&!vis[cir[i]]){
			vis[cir[i]]=1;
			int m=0,id=0,j=i;
			do{
				++id;
				if(p[j]){
					L[++m]=id;D[m]=0;
					for(int o=p[j];o;o=p[o])++D[m];
				}
			}while(j=a[j],j!=i);
			if(m){
				L[0]=L[m]-id,D[0]=D[m];
				for(int j=1;j<=m;++j)
					if(L[j]-L[j-1]>D[j])ans=2*ans%mod;
					else if(L[j]-L[j-1]<D[j])return puts("0"),0;
			}else ++c[id];
		}
	fact[0]=1;for(int i=1;i<=n;++i)fact[i]=1ll*fact[i-1]*i%mod;
	ifact[n]=pow(fact[n],mod-2);for(int i=n;i;--i)ifact[i-1]=1ll*ifact[i]*i%mod;
	f[0]=1;for(int i=1;i*2<=n;++i)f[i]=1ll*(2*i-1)*f[i-1]%mod;
	for(int i=1;i<=n;++i){
		int res=0;
		for(int j=0;j*2<=c[i];++j)
			res=(res+1ll*C(c[i],2*j)*f[j]%mod*pow(i,j)%mod*((i>1&&(i&1))?pow(2,c[i]-2*j):1))%mod;
		ans=1ll*ans*res%mod;
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

ll a[100010];
int main() {
	ll n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	ll ans=0;
	ll now=a[0],sum=0;
	for(int i=1;i<n;i++){
		if(now>=a[i]){
			now=a[i];
			sum++;
		}
		else{
			now=a[i];
			ans=max(ans,sum);
			sum=0;
		}
		if(i==n-1){
			ans=max(ans,sum);
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<string>

int main() {
	int K, X;
	std::cin >> K >> X;
	int kaisu = K * 2 - 1;
	std::vector<int> a(kaisu);
	int ans = X - (K - 1);
	for (int i = 0; i < kaisu; i++) {
		std::cout << ans << std::endl;
		ans++;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
#define debug(x) cout << #x << " = " << x << '\n'
#define debug_arr(a , n) for(int i = 0 ; i < n ; i++)cout << a[i] << " "
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define vll vector<ll> 
#define inf 1000000000
#define mod 1000000007

const int max_n = 1e5 + 9;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
ll power(ll a , ll b)
{
    ll prod = 1;
    while(b)
    {
        if(b&1)
        prod = (prod*a)%mod;
        a = (a*a)%mod;
        b >>= 1;
    }
    return prod;
}
int main()
{
    ll n , k;
    cin >> n >> k;
    if(k == n+1){
        cout << 1;
        return 0;
    }
    ll pref[n+1] , suff[n+1];
    pref[0] = 0 , suff[n] = n;
    for(ll i = 1 ; i <= n ; i++){
        pref[i] = pref[i-1] + i;
    }

    for(ll i = n-1 ; i >= 0 ; i--){
        suff[i] = suff[i+1] + i;
    }
    ll ans = 0;
    for(ll i = k ; i <= n+1 ; i++){
        ll sum1 = pref[i-1];
        ll sum2 = suff[n-i+1];
        ans = (ans%mod + (sum2 - sum1 + 1)%mod)%mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6544
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int INF = 1<<30;

int main(){
  string s;cin>>s;
  int k=(int)s.size();
  int count=0;
  for(int i=0;i<k;i++){
  	count += (s[i]!='o');
  }
  cout<<(count>=8?"NO":"YES")<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
    char a[100]={0},b[100]={0},del[100]={0};
    int n,m;
    scanf("%s %s",a,b);
    scanf("%d %d",&n,&m);
    scanf("%s",del);
    if(strcmp(a,del) == 0)
        n--;
    else if(strcmp(b,del) == 0)
        m--;
    printf("%d %d",n,m);
    return 0;
}

Measured memory_bytes: 128
# main

input_line = input().split()

high_bridge = int(input_line[0])
mid_bridge = int(input_line[1])
low_bridge = int(input_line[2])
exec_times = int(input_line[3])

if abs(high_bridge - mid_bridge) > pow(10, 18):
    print("Unfair")
elif exec_times % 2 == 0:
    print(str(high_bridge - mid_bridge))
else:
    print(str(mid_bridge - high_bridge))


Measured memory_bytes: 3060
#include <sstream>
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<ctime>
#include<cmath>
#include<map>
#include<stack>
#include<random>
#include<queue>
#include<list>
#include<math.h>
#include<complex>
using namespace std;
#define ll long long int
#define ld long double
#define key pair<ld,ld>
#define ii pair<int,int>
#define si set<int>
#define vii vector<pair<int,int> >
#define vi vector<int>
#define vll vector<ll>
#define vb vector<bool>
#define vvi vector<vector<int> >
#define vs vector<string>
#define all(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define nu 100001
#define mul(x,y) ((ll)(x)*(y))%mod
#define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++)
#define fastio  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define forn(i, n) for (int i = 0; i < int(n); i++)
const ll INF=1000000000000;
const ll mod=1000000007;

ll  MOD(ll  a,ll  b)
{
    if(a>b)
        return a-b;
    else
        return b-a;
}
ll  max3(ll  a,ll  b,ll c)
{
    return max(c,max(a,b));
}
ll min3(ll a,ll  b,ll  c)
{
    return min(a,min(b,c));
}
ll  power(ll  x,ll  y )
{
    ll res = 1;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x);//%mod;
        y = y>>1;
        x = (x*x);//%mod;
    }
    return res;//%mod;
}
ll  power1(ll  x,ll  y )
{
    ll res = 1;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x)%mod;
        y = y>>1;
        x = (x*x)%mod;
    }
    return res%mod;
}
ll logg(ll  a)
{
    ll  x=0;
    while(a>1)
    {
        x++;
        a/=2;
    }
    return x;
}
ll  gcd(ll  a,ll   b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
ll abso(ll x)
{
    if(x<0)
    {
        return -x;
    }
    return x;
}
ll ceiling (ll  a,ll  b)
{
    if(a%b==0)
    {
        return a/b;
    }
    else
    {
        return a/b+1;
    }
}
ll modinv(ll x)
{
    return power1(x,mod-2);
}
int n,k;
vi a;
int main()
{
    cin>>n>>k;
    a.resize(n);
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    vll dp(k+1);
    dp[0]=false;
    for(int i=1;i<=k;i++)
    {
        bool c=false;
        for(int j=0;j<n;j++)
        {
            if(a[j]<=i)
            {
                if(!dp[i-a[j]])
                {
                    c=true;
                }
            }
        }
        dp[i]=c;
    }
    if(dp[k])
    {
        cout<<"First";
    }
    else
    {
        cout<<"Second";
    }
}


Measured memory_bytes: 1024
H,W = $stdin.gets.chomp.split(" ").map{ |a| a.to_i }
M = (0...H).map{ $stdin.gets.chomp.split("").map{ |a| a == "#" ? -2 : H*W } }

def outm
  M.each{ |row|
    #$stderr.puts row.map{ |a| a == -2 ? "#" : a == H*W ? "." : "*" }.join
  }
end

outm
$stderr.puts ""

xs = [0]
t = 0
while true 
  t += 1
  nx = {}
  xs.each{ |ij|
    i = ij / W
    j = ij % W
    next if M[i][j] == -2
    next if M[i][j] < t
    M[i][j] = t
    nx[ij-1] = 1 if 0 < j
    nx[ij+1] = 1 if j < W-1
    nx[ij-W] = 1 if 0 < i
	nx[ij+W] = 1 if i < H-1
  }
  xs = nx.keys
  #$stderr.puts "#{t} #{xs}"
  break if nx.length == 0
end

outm

if (M[H-1][W-1] == H*W)
  puts -1
  exit
end

$stderr.puts M[H-1][W-1]
whites = H*W - M.map{ |row| row.count{ |a| a == -2 } }.inject(:+)
puts whites - M[H-1][W-1]


Measured memory_bytes: 2172
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1e18) + 1;

struct edge
{
    ll from;
    ll to;
    ll cost;
};

int V, E, r;
edge e[2010];
ll d[1010];

bool bf(int s)
{
    int i;
    bool update = true;
    int upcount = 0;

    rep(i, 0, V)
    {
        d[i] = INF;
    }

    d[s] = 0;

    while (update)
    {
        update = false;
        upcount++;

        if (upcount > V)
        {
            return false;
        }

        rep(i, 0, E)
        {
            if (d[e[i].from] != INF && d[e[i].to] > d[e[i].from] + e[i].cost)
            {
                d[e[i].to] = d[e[i].from] + e[i].cost;
                update = true;
            }
        }
    }

    return true;
}

int main(void)
{
    int i;
    int x, y, z;
    bool update = false;

    cin >> V >> E >> r;

    rep(i, 0, E)
    {
        cin >> x >> y >> z;
        e[i].from = x;
        e[i].to = y;
        e[i].cost = z;
    }
    if (bf(r))
    {
        rep(i, 0, V)
        {
            if (d[i] == INF)
            {
                cout << "INF" << endl;
            }
            else
            {
                cout << d[i] << endl;
            }
        }
    }
    else
    {
        cout << "NEGATIVE CYCLE" << endl;
    }
}


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

const int mod = 998244353;
const int g = 3;
const int N = 65536;

int a[100010];
int res[100010];
int f[100010], t[100010];
int cnt[100010];
long long fac[100010], inv[100010], ways[100010];
int num[100010];

long long power(int a, int b) {
	if (!b) return 1;
	long long tmp = power(a, b >> 1);
	return b & 1 ? tmp * tmp % mod * a % mod : tmp * tmp % mod;
}

void NTT(int *a, int N, int *f, int flag) {
	for (int i = 0; i < N; i++) {
		f[i] = a[num[i]];
	}
	for (int len = 2; len <= N; len <<= 1) {
		long long E = power(g, (mod - 1) / len);
		if (flag) E = power(E, mod - 2);
		for (int i = 0; i < N; i += len) {
			long long now = 1;
			for (int j = i; j < i + (len >> 1); j++) {
				long long tmp = now * f[j + (len >> 1)] % mod;
				f[j + (len >> 1)] = f[j] - tmp;
				if (f[j + (len >> 1)] < 0) f[j + (len >> 1)] += mod;
				f[j] = f[j] + tmp;
				if (f[j] >= mod) f[j] -= mod;
				now = now * E % mod;
			}
		}
	}
	if (flag) {
		long long inv = power(N, mod - 2);
		for (int i = 0; i < N; i++) {
			f[i] = f[i] * inv % mod;
		}
	}
}

long long C(int n, int k) {
	return fac[n] * inv[k] % mod * inv[n - k] % mod;
}

int main () {
	fac[0] = inv[0] = 1, ways[0] = 1;
	for (int i = 1; i <= 100000; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = power(fac[i], mod - 2);
		ways[i] = (2 * i - 1) * ways[i - 1] % mod;
	}
	int n; scanf("%d", &n), n <<= 1;
	for (int i = 0; i < n; i++) {
		int x; scanf("%d", &x);
		cnt[x]++;
	}
	for (int i = 0; i < N; i++) {
		num[i] = num[i >> 1] >> 1 | (i & 1 ? N >> 1 : 0);
	}
	f[0] = 1;
	NTT(f, N, res, 0);
	for (int i = 1; i <= 100000; i++) {
		a[cnt[i]]++;
	}
	for (int i = 1; i <= 100000; i++) {
		if (!a[i]) continue;
		memset(f, 0, sizeof(f));
		for (int j = 0; j * 2 <= i; j++) {
			f[j] = C(i, j * 2) * ways[j] % mod;
		}
		NTT(f, N, t, 0);
		for (int j = 0; j < N; j++) {
			res[j] = 1ll * res[j] * power(t[j], a[i]) % mod;
		}
	}
	NTT(res, N, f, 1);
	long long ans = 0;
	for (int i = 0; i < N; i++) {
		if (2 * i > n) break;
		long long tmp = 1ll * f[i] * ways[n - 2 * i >> 1] % mod;
		ans = (ans + (i & 1 ? -1 : 1) * tmp + mod) % mod;
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 7648
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18) + 1;
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int n, m;
string s;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> s;
    if(s[0]==s[1]&&s[1]==s[2])return no,0;
    yes;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()


int main(){
  int n,x,c=0;
  cin >> n >> x;
  vector<int>a(n);
  for(int i=0;i<n;i++)cin >> a[i];
  sort(ALL(a));
  for(int i=0;i<n-1;i++){
    if(a[i]>x){
      cout << c;
      return 0;
    }
    if(a[i]==x){
      c++;
      cout << c;
      return 0;
    }
    if(a[i]<x){
      c++;
      x-=a[i];
    }
  }
  if(x == a[n-1])c++;
  cout << c;
}


Measured memory_bytes: 256
H,W=map(int,input().split())
s=[list(map(int, list(input().replace('#','1').replace('.','0')))) for _ in range(H)]

padded = [[0 for i in range(W+2)] for j in range(H+2)]

for i in range(H):
  for j in range(W):
    padded[i+1][j+1] = s[i][j] 

for i in range(1,H+1):
  for j in range(1,W+1):
    if padded[i][j]==1:
      if padded[i+1][j]==0 and padded[i-1][j]==0 and padded[i][j+1]==0 and padded[i][j-1]==0:
        print('No')
        exit()
print('Yes')

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

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

    ll N; cin >> N;
    vector<P> m;
    vector<P> m2;
    map<ll,bool> t_l;
    for (int i = 0;i < N;i++){
        ll a,b; cin >> a >> b;
        m.push_back(P(a,b));
        m2.push_back(P(a-b,a+b));
        t_l[a-b] = true;
        t_l[a+b] = true;
    }
    sort(m.begin(),m.end());

    /*map<ll,ll> t_l2;
    ll tmp = 0;
    for (auto mp : t_l2){
        t_l2[mp.first] = tmp;
        tmp++;
    }

    for (int i = 0;i < N;i++){
        m2[i].first = t_l2[m2[i].first];
        m2[i].second = t_l2[m2[i].second];
    }*/

    ll dp[N+1];
    memset(dp,-1,sizeof(dp));
    dp[0] = 0;

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



    for (int i = 0;i < N;i++){
        int nex = lower_bound(m2.begin(),m2.end(),P(m2[i].second,INT_MIN))-m2.begin();
        //cout << nex << endl;
        if(m2[N-1].first < m2[i].second){
            dp[N] = max(dp[N],dp[i]+1);
        }else{
            dp[nex] = max(dp[nex],dp[i]+1);
        }
        dp[i+1] = max(dp[i+1],dp[i]);
    }

    cout << dp[N] << endl;

    return 0;

}

Measured memory_bytes: 16608