akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <map>

using namespace std;

int main(int argc, const char * argv[]) {

    long long a, b, c, k;
    long long ans = 0, max = 0;
    
    cin >> a >> b >> c >> k;
    if(k <= a) {
        
        ans = k;
        
    } else{
        

        
        ans = a;
        k = k - a;
        

            k = k - b;
        
        
        if(k>0)
        {
            ans = ans - k;
        }
        
    
        
    }
    
    cout << ans << endl;
    
}


Measured memory_bytes: 3632
#include<stdio.h>
#include<string.h>
  
#define M 1000003
#define L 14
  
char H[M][L];
  
int getChar(char C) {
  switch(C){
  case 'A':
    return 1;
    break;

  case 'C':
    return 2;
    break;

  case 'G':
    return 3;
    break;

  case 'T':
    return 4;
    break;
    
  default:
    return 0;
  }
}
  
int getKey(char* str) {
    int sum = 0, p = 1, i;
    for (i = 0; i < strlen(str); i++) {
        sum += p * (getChar(str[i]));
        p *= 5;
    }
    return sum;
}
  
int moji1(int key) {
    return key % M;
}
  
int moji2(int key) {
    return 1 + key % (M - 1);
}
  
int getValue(char* str, int i) {
    return (moji1(getKey(str)) + i * moji2(getKey(str))) % M;
}
  
int find(char* str) {
    int moji, i = 0;
  
    while (1) {
        moji = getValue(str, i);
        if (!strcmp(H[moji], str)) return 1;
        if (!strcmp(H[moji], "\0")) return 0;
        i++;
    }
}
  
void insert(char* str) {
    int moji, i = 0;
  
    while (1) {
        moji = getValue(str, i);
        if (!strcmp(H[moji], "\0")) {
            strcpy(H[moji], str);
            break;
        }
        i++;
    }
}
  
int main() {
    int i, n;
    char str[L], com[9];
  
    for (i = 0; i < M; i++) {
        H[i][0] = '\0';
    }
  
    scanf("%d", &n);
  
    for (i = 0; i < n; i++) {
        scanf("%s %s", com, str);
  
        if (com[0] == 'i') {
            insert(str);
        } else {
            if (find(str)) {
                printf("yes\n");
            } else {
                printf("no\n");
            }
        }
    }
    return 0;
}

Measured memory_bytes: 14280
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, 1000000007)
	sc.Split(bufio.ScanWords)
	h, _ := strconv.Atoi(Scanner())
	w, _ := strconv.Atoi(Scanner())
	s := make([][]int, h)
	for i := 0; i < h; i++ {
		st := Scanner()
		stt := make([]int, len(st))
		for j := 0; j < len(st); j++ {
			if string(st[j]) == "#" {
				stt[j] = 1
			} else {
				stt[j] = 0
			}
		}
		s[i] = stt
	}
	ans := make([][]int, h)
	for i := 0; i < h; i++ {
		a := make([]int, w)
		ans[i] = a
	}
	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			up := 1000000000
			left := 1000000000
			if i != 0 {
				if s[i-1][j] == 0 && s[i][j] == 1 {
					up = ans[i-1][j] + 1
				} else {
					up = ans[i-1][j]
				}
			}
			if j != 0 {
				if s[i][j-1] == 0 && s[i][j] == 1 {
					left = ans[i][j-1] + 1
				} else {
					left = ans[i][j-1]
				}
			}
			if i == 0 && j == 0 {
				ans[0][0] = s[0][0]
			} else {
				ans[i][j] = smaller(up, left)
			}
		}
	}
	fmt.Println(ans[h-1][w-1])
}
func smaller(x, y int) int {
	if x < y {
		return x
	} else {
		return y
	}
}


Measured memory_bytes: 768
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <cctype>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const ll INFLL = 1001001001001001001;  // > 10^18
const int MOD = (int)1e9 + 7;
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;



int main() {
    
    int n; cin >>n;
    vector<int> a(n); REP(i,n) cin >> a[i];
    vector<int> v;
    v.push_back(a[0]);

    for (int i = 1; i < n; i++) {
        int this_a = a[i];
        int ok = v.size();
        int ng = -1;
        while (abs(ok - ng) > 1) {
            int m = (ok+ng)/2;
            if (v[m] < this_a) {
                ok = m;
            } else {
                ng = m;
            } 
        }
        if (ok != v.size()) {
            v[ok] = this_a;
        } else {
            v.push_back(this_a);
        }
    }
    
    cout << v.size() << endl;
    return 0;

}




Measured memory_bytes: 1276
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B;
    cin >> A >> B;
    REP(i, 1, 3) {
        if (A != i && B != i) {
            cout << i << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 256
SD = input()
K = input()

ans_list = []

for i in range(len(SD) - len(K) + 1):
    flag = True
    for j in range(len(K)):
        if SD[i + j] != K[j] and SD[i + j] != '?':
            flag = False
            break
    if flag:
        tmp = SD[:i] + K + SD[len(K) + i:]
        ans_list.append(tmp.replace('?', 'a'))


s_ans_list = sorted(ans_list)
if len(s_ans_list) == 0:
    print('UNRESTORABLE')
else:
    print(s_ans_list[0])



Measured memory_bytes: 3064
N = int(input())
strN = str(N)
order = len(strN)
Ns = int(strN[0])
Ne = int(strN[-1])

ces = [[0  for i in range(10) ] for j in range(10)]
cse = [[0  for i in range(10) ] for j in range(10)]
for n in range(1, N + 1):
  n_last = n % 10
  n_first = n
  while n_first >= 10:
    n_first = n_first // 10
  ces[n_last][n_first] += 1
  cse[n_first][n_last] += 1

count = 0
for e in range(1, 10):
  for s in range(1, 10):
    count += ces[e][s] * cse[e][s]
    
print(count)

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

int main(){

  int a=0;
  int b=0;
  int c=0;
  
  cin>>a>>b>>c;
  
  if(a==b && b!=c)cout<<"Yes";
  else if(a==c && c!=b)cout<<"Yes";
  else if(b==c && c!=a)cout<<"Yes";
  else cout<<"No";
  
}

Measured memory_bytes: 256
a = int(input())
l=(list(map(int ,input().split())))
l.sort()
ll=[]
j=0
r=(l[0]+l[1])/2
ll.append(r)
for i in range(a-2):
        j=(ll[0]+l[i+2])/2
        ll.append(j)
        ll.remove(ll[0])
print((ll[0]))      

Measured memory_bytes: 3064
S = input()[::-1]
S_l = len(S)
MOD = 2019
l = [0]*(S_l+1)
ans_l = [0]*2020
l[0] = 0
l[1] = int(S[0]) 
ans_l[0]+=1
ans_l[int(S[0])]+=1

for i in range(2,S_l+1):
  l[i] = (int(S[i-1]) * pow(10,i-1,MOD) + l[i-1])%MOD
  ans_l[l[i]]+=1

ans = 0
for i in ans_l:
  ans+=i*(i-1)//2
  
print(ans)

Measured memory_bytes: 70004
#include<stdio.h>
int main()
{
	int n,k,h[100001];
	int i,j,x=0,y[100001];
	scanf("%d %d",&n,&k);
	for(i=0;i<n;i++) scanf("%d",&h[i]);
	for(i=0;i<=n;i++) y[i]=1000000000;
	y[0]=0;
	for(i=0;i<n-1;i++){
		for(j=1;j<=k;j++){
			x=h[i]-h[i+j];
			if(x<0) x=-x;
			if(i+j<n){
				if(y[i+j]>x+y[i]){
					y[i+j]=x+y[i];
				}
			}
		}
	}
	printf("%d\n",y[n-1]);
	return 0;
}

Measured memory_bytes: 2516
#include <cstdio>
#include <cmath>
#include <iostream>
#include <cstring>
#include <algorithm>
/*
using std::max;

#define MAXN 100003
int d[MAXN][3],a[MAXN][3];*/
using namespace std;

int a[100003][3],d[100003][3];

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


Measured memory_bytes: 2560
#include "bits/stdc++.h"

using namespace std;

#define F first
#define S second
#define modulo ll (1e9 + 7)
#define EPS 1e-9

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

void init(){
    cin.tie(0);
    cin.sync_with_stdio(0);
}

const int N = 3005, M = 1e6 + 9, OO = 0x3f3f3f3f;
const ll llOO = 0x3f3f3f3f3f3f3f3f;



void go(int tc = 0){
    ll n, a, b;    cin >> n >> a >> b;

    ll h[n];

    for(int i = 0;i < n;i++)    cin >> h[i];

    auto check = [&](int t){
        ll op = 0;
        for(int i = 0;i < n;i++){
            ll rest = max(0ll, (h[i] - b * t));
            op += ceil(1.0 * rest / (a - b));
        }
        return op <= t;
    };


    ll l = 1, r = 1e9;
    while(l <= r){
        ll mid = (l + r) >> 1;
        if(check(mid))
            r = mid - 1;
        else
            l = mid + 1;
    }

    cout << l;
}

int main(){
    init();

//    freopen("in.in", "r", stdin);
//    freopen("out.out", "w", stdout);

   int t = 1, tc = 1;
//   cin >> t;
    while(t--)
        go(tc++);
}

Measured memory_bytes: 4408
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>

using namespace std;

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

const ll mod = 1000000007;

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

  int n;
  cin >> n;
  string s;
  cin >> s;

  for (auto &x: s) {
    x = x + n;
    if (x > 'Z') x = x - 26;
  }

  cout << s << endl;

  return 0;
}


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

int main() {
  int n; cin >>n;
  int cnt = 0;
  vector<int> a(n);
  rep(i,n) cin >>a[i];
  for(int i = 0; i<=n; i+=2){
    if(a[i]%2==1) cnt++;
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,ans=0;
  cin>>n;
  int l[n],r[n];
  for(int i=0;i<n;i++){
    cin>>l[i]>>r[i];
    ans+=r[i]-l[i]+1;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  	int a,b,t;
  	cin>>a>>b>>t;
  	int ans = 0;
  	int now = a;
  	while (now <= t){
    	ans += b;
      	now += a;
    }
  	cout<<ans<<endl;
 	return 0; 
}

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

int main (void){
    int a, b, c;
    int d, e, f;
    int cost = 0;

    cin >> a >> b >> c;

    d = abs(a - b);
    e = abs(b - c);
    f = abs(c - a);

    if(a < b && a < c){
        if(b < c){
            cost += d + e; 
        }else{
            cost += f + e;
        }
    }else if(b < a && b < c){
        if(a < c){
            cost += d + f;
        }else{
            cost += e + f;
        }
    }else if(c < a && c < b){
        if(a < b){
            cost += f + d;
        }else{
            cost += e + d;
        }
    }else{
        if(a == b){
            cost += f;
        } else if(b == c){
            cost += d;
        }else if(c == a){
            cost += e;
        }else{

        }
    }

    cout << cost << endl;
    return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1LL << 30;

queue<P> que1, que2;

void separate(int pp, int ss){
  while(!que2.empty()) que2.pop();
  int counter = 0;
  int ww, dd;
  while(!que1.empty()){
    if(counter == pp){
      ww = que1.front().first;
      dd = que1.front().second;
      que1.pop();
    }
    else{
      que2.push(que1.front()); que1.pop();
    }
    counter++;
  }
  int ex = ss % (2 * ww + 2 * dd);
  P pp1, pp2;
  if(ex < ww){
    pp1 = P(ex, dd);
    pp2 = P(ww-ex, dd);
  }
  else if(ex < ww + dd){
    pp1 = P(ww, ex - ww);
    pp2 = P(ww, ww + dd - ex);
  }
  else if(ex < 2 * ww + dd){
    pp1 = P(ex - ww - dd, dd);
    pp2 = P(2*ww + dd - ex, dd);
  }
  else{
    pp1 = P(ww, ex - 2*ww - dd);
    pp2 = P(ww, 2*ww + 2*dd - ex);
  }

  int ss1 = pp1.first * pp1.second;
  int ss2 = pp2.first * pp2.second;
  if(ss1 < ss2){
    que2.push(pp1);
    que2.push(pp2);
  }
  else{
    que2.push(pp2);
    que2.push(pp1);
  }

  que1 = que2;
}

int main(){
vvll ans(0, vll(0));
while(true){
  while(!que1.empty()) que1.pop();
  while(!que2.empty()) que2.pop();

  int n, w, d;
  cin >> n >> w >> d;
  if(n == 0 && w == 0 && d == 0) break;
  que1.push(P(w, d));

  vll p(n), s(n);
  for(int i = 0; i < n; i++){
    cin >> p.at(i) >> s.at(i);
    p.at(i)--;
    separate(p.at(i), s.at(i));
  }
  vll result(0);
  while(!que1.empty()){
    result.push_back(que1.front().first * que1.front().second);
    que1.pop();
  }
  sort(ALL(result));
  ans.push_back(result);
}
for(int i = 0; i < ans.size(); i++){
  for(int j = 0; j < ans.at(i).size(); j++){
    cout << ans.at(i).at(j);
    if(j != ans.at(i).size()-1) cout << ' ';
    else cout << endl;
  }
}
}


Measured memory_bytes: 3216
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<deque>
#include<functional>
#include<iterator>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;
template<class T> inline bool chmin(T& a, T b){if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a=b;return true;}return false;}
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll digsz(ll x){if(x==0) return 1;else{ll ans=0;while(x){x/=10;ans++;}return ans;}}
ll digsum(ll x){ll sum=0;while(x){sum+=x%10;x/=10;}return sum;}
vector<ll> pw2(62,1);vector<ll> pw10(19,1);

int main(){
    {rep1(i,61) pw2[i]=2*pw2[i-1];}
    {rep1(i,18) pw10[i]=10*pw10[i-1];}
    
    ll N; cin>>N;
    ll cnt=0,ans=INF;
    string s; cin>>s;
    
    //EEEEEEEEEEEEEEEEE
    rep(i,sz(s)){
        if(s[i]=='W') cnt++;
    }
    ans=cnt;
    
    rrep(i,sz(s)){
        if(s[i]=='W') cnt--;
        else cnt++;
        chmin(ans,cnt);
    }
    
    cout<<ans<<endl;
}



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

int main() {
  int N,M;
  cin >> N >> M;
  vector<int> m(N);
  int sum = 0;
  int minv = 1000;
  int num;
  for (int i = 0; i < N; i++) {
    cin >> m[i];
    sum += m[i];
    if(minv > m[i]){
      minv = m[i];
      num = i;
    }
  }
  cout << (M - sum) / m[num] + m.size() << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
const int MAX = 510000;
const int MOD = 1000000007;
//

int n,ans2[1000];
 int dp[2][1000000],dp2[2][1000001];
int d[1000];
void dfs(int a){
  if(a==n){
    int t=n;
    while(t>0&&d[t-1]!=1)t--;
    ans2[t]++;
    for(int i=0;i<n;i++)for(int j=i+1;j<i+d[i];j++)if(d[min(n-1,j)]!=d[min(n-1,j+1)]){
      ans2[t]--;
      return;
    }
   
    return ;
  }
  for(int i=1;i<=n;i++){
    d[a]=i;
    dfs(a+1);
  
  }
  return ;
}
     signed main(){
 int ans=0;
 cin>>n;
//for(int i=0;i<=n;i++)ans2[i]=0;
 dp[0][0]=n-1;dp[1][0]=0;
 for(int i=1;i<=n;i++){
   dp[0][i]=(dp[0][i-1]+dp[1][max(i-3,0ll)])%MOD;
 
   dp[1][i]=(dp[1][i-1]+dp[0][i])%MOD;
 }
  dp2[0][0]=0;dp2[1][0]=1;
 for(int i=1;i<n;i++){
  if(i>=3) dp2[0][i]=(dp2[0][i-1]+dp2[1][i-3])%MOD;
 else dp2[0][i]=0;
   dp2[1][i]=(dp2[1][i-1]+dp2[0][i])%MOD;
 }
 ans=(dp[1][n-1]+1+dp2[1][n-1]*(n-1)%MOD+(n-1)*(n-1)%MOD)%MOD;
 for(int i=2;i<n;i++)ans=(ans+dp2[1][n-i]*(n-1)%MOD*(n-1)%MOD)%MOD;
cout<<ans<<endl;
//for(int i=0;i<n;i++)cerr<<dp[0][i]<<' '<<dp[1][i]<<endl;
//for(int i=0;i<=n;i++)cerr<<dp2[0][i]<<' '<<dp2[1][i]<<endl;
//a!=n-1nobaai
//dfs(0);
//for(int i=n;i>=0;i--)cerr<<ans2[i]<<' ';
//cerr<<endl;
//cerr<<dp[1][n-1]+1<<' '<<dp2[1][n-1]*(n-1)%MOD<<' ';
//for(int i=2;i<n;i++)cerr<<dp2[1][n-i]*(n-1)%MOD*(n-1)%MOD<<' ';
//cerr<<(n-1)*(n-1)%MOD<<endl;

     }


 


 






    





      

        


Measured memory_bytes: 34884
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		//int n = sc.nextInt();
		//String[] array = new String[h+1];
		//List<String> list= new ArrayList<String>(Arrays.asList(s.split("")));
		//List<Integer> list=new ArrayList<Integer>();
		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();

		int x = n*a;

		if(x<=b) {
			System.out.println(x);
		}
		else {
			System.out.println(b);
		}

	}
}

Measured memory_bytes: 25172
using namespace std;
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <unordered_map>
//#include <bits/stdc++. h>
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define forn(i,n) for(int i=0;i<(n);i++)
#define forab(i,a,b) for(int i=(a);i<(b);i++)
#define fordec(i,a,b) for(int i=(a);i>=(b);i--)
#define vi vector<int>
#define vl vector<ll>
#define vd vector<double>
#define vs vector<string>
#define pb push_back
#define vpi vector<pair<int, int>
#define vpl vector<pair<ll, ll>>
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<30;
const char nl = '\n';
typedef long long ll;
inline int gcd(int a, int b) { if (a == 0) return b; return gcd(b % a, a); }
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
inline void print(vector<int> x) {for (auto& a : x) cout << a << ' '; cout << nl;}
inline void print(vector<char> x) {for (auto& a : x) cout << a << ' '; cout << nl;}
inline void print(vector<string> x) {for (auto& a : x) cout << a << ' '; cout << nl;}
inline void print(vector<ll> x) {for (auto& a : x) cout << a << ' '; cout << nl;}
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
/////////////////////////////////////////////////////////////////////



int main()
{
    ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	map<string, int> m;
	m["AC"] = 0;
	m["TLE"] = 0;
	m["WA"] = 0;
	m["RE"] = 0;
 	int times; cin >> times;
	while (times--) {
		string s; cin >> s;
		m[s]++;
	}
	cout << "AC x " << m["AC"] << nl;
	cout << "WA x " << m["WA"] << nl;
	cout << "TLE x " << m["TLE"] << nl;
	cout << "RE x " << m["RE"] << nl;
	return 0;
}


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

int dp[101010];
int as[] = {100, 101, 102, 103, 104, 105};

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

    dp[0] = 1;
    for (int i = 0; i < 6; i++) {
        for (int j = 0; j < 101010; j++) {
            if (dp[j] && j + as[i] < 101010) {
                dp[j + as[i]] = 1;
            }
        }
    }
    int x;
    cin >> x;
    cout << (dp[x] > 0) << endl;
}


Measured memory_bytes: 640
import Data.Maybe
import Data.List
import Data.Ratio
import Debug.Trace

main = do
  n <- readLn :: IO Integer
  s <- readLn :: IO Integer

  print $ case solve n s of
    Just x -> x
    Nothing -> -1

  where
    f b n
      | n < b = n
      | n >= n = (mod n b) + f b (div n b)

    maybeSeq xs = if c==[] then Nothing else Just c
      where c = catMaybes xs
      
    solve :: Integer -> Integer -> Maybe Integer
    solve n s
      | s == n = Just $ n+1
      | s > n = Nothing
      | otherwise = find (\b -> b > 1 && f b n == s) ([2..rt+1] ++ (map (\p -> div (n-s) p + 1) [rt,rt-1..1]))
      where
        rt = floor (sqrt $ fromIntegral n)

Measured memory_bytes: 2044
#include <stdio.h>

int main(void)
{
  int a ,b ,c ,i ,n;

  scanf("%d",&n);

  for(i=0;i<n;i++){

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

  if(a*a==b*b+c*c)
  { printf("YES\n"); }

  else if (b*b==c*c+a*a)
  { printf("YES\n"); }

  else if (c*c==a*a+b*b)
  { printf("YES\n"); }

  else
  { printf("NO\n");}
  }
  return 0;
}

Measured memory_bytes: 576
#include<bits/stdc++.h>
using namespace std;
#pragma optimize("-O3")

#define f first
#define s second
#define pb push_back

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n;
	cin>>n;
	int x[n];
	int y[n];
	long long int p[n];
	int mini[n];
	for(int i=0; i<n; i++){
		cin>>x[i]>>y[i]>>p[i];
		mini[i]=min(abs(x[i]), abs(y[i]));
	}
	
	long long int ans[n+1];
	for(int i=0; i<=n; i++){
		ans[i]=1e18;
	}
	for(int i=0; i<(1<<n); i++){
		int num=__builtin_popcount(i);
		int mask=i;
		vector<int>vec;
		vector<int>vecl;
		for(int j=0; j<n; j++){
			if((i&(1<<j))){
				vec.pb(j);
			}
			else{
				vecl.pb(j);
			}
		}
	
		while(mask>0){
			long long int tot=0;
			for(auto k:vecl){
				int xk=x[k];
				int yk=y[k];
				
				
				int val=mini[k];
				
				for(auto l:vec){
						if((mask&(1<<l))){
							val=min(val, abs(xk-x[l]));
						}
						else{
							val=min(val, abs(yk-y[l]));
						}
					
				}
				tot+=(val*(p[k]));
			}
			ans[num]=min(ans[num], tot);
			mask=(mask-1)&i;
		}
		long long int tot=0;
	
			for(auto k:vecl){
				int xk=x[k];
				int yk=y[k];
			
				int val=mini[k];
				
				for(auto l:vec){
					
						if((mask&(1<<l))){
							val=min(val, abs(xk-x[l]));
						}
						else{
							val=min(val, abs(yk-y[l]));
						}
					
				}
				tot+=(val*(p[k]));
			}
			ans[num]=min(ans[num], tot);
	}
	for(int i=0; i<=n; i++){
		cout<<ans[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

ll n, m;
string s;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	cin >> n;
	print(((n+1)/2)*(n/2))
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, end) for (long long int i=0; i<end; i++)
#define repp(i, begin, end) for (long long int i=begin; i<end; i++)
#define srt(x) sort((x).begin(), (x).end());
#define rsrt(x) sort((x).rbegin(), (x).rend());
#define deb(x) cout<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<<endl;
#define vdeb(x) {cout<<#x<<" = { "; rep(i, x.size()) cout<<x[i]<<' '; cout <<'}'<<" (L"<<__LINE__<<")"<<endl;}
using namespace std;
using ll = long long int;
using vi = vector<int>;
using vivi = vector<vi>;
using vll = vector<long long int>;
using vllvll = vector<vll>;
using vs = vector<string>;
ll sm(vll x) {ll sum=0; rep(i, x.size()) sum+=x[i]; return sum;}
//=======================================================================================================

int main()
{
    int n;
    cin >> n;
    vector<long double> v(n);
    rep(i,n) cin >> v[i];
    srt(v);
    repp(i,0,n-1) {
        v[i+1] = (long double)(v[i]+v[i+1]) / 2;
    }
    cout << v[n-1] << endl;
}

Measured memory_bytes: 256
n=int(input())
p=list(map(int, input().split()))
l=len(p)
cnt=0
for i in range(l):
    if i<l-1 and p[i]==i+1 :
        cnt+=1
        p[i],p[i+1]=p[i+1],p[i]
    elif p[i]==i+1:
        cnt+=1
        p[i],p[i-1]=p[i-1],p[i]

print(cnt)

Measured memory_bytes: 14008
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int i = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int i = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define MP make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int MOD = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    vector<ll> A(N);
    ll sum = 0;
    ll mi = INF;
    rep(i, N) {
        cin >> A[i];
        sum += A[i];
        mi = min(mi, A[i]);
    }
    if(N % 2) {
        if(sum % 2) {
            cout << "First" << endl;
        } else {
            cout << "Second" << endl;
        }
    } else {
        if(sum % 2) { // sente
            if(mi % 2) {
                cout << "First" << endl;
            } else {
                cout << "First" << endl;
            }
        } else { // gote
            if(mi % 2) {
                cout << "First" << endl;
            } else {
                cout << "Second" << endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 4356
#include<stdio.h>
#include<stdlib.h>
int a[20004], b[20004];
int asc1(const void* x, const void* y)
{
	if (a[*(int*)x] > a[*(int*)y])return 1;
	if (a[*(int*)x] < a[*(int*)y])return -1;
	if (b[*(int*)x] > b[*(int*)y])return 1;
	if (b[*(int*)x] < b[*(int*)y])return -1;
	return 0;
}
int asc2(const void* x, const void* y)
{
	if (*(long long int*)x > * (long long int*)y)return 1;
	if (*(long long int*)x < *(long long int*)y)return -1;
	return 0;
}
int main()
{
	int n;
	scanf("%d", &n);
	int i;
	for (i = 0; i < n - 1; i++)
	{
		scanf("%d %d", &a[2 * i], &b[2 * i]);
		a[2 * i]--;
		b[2 * i]--;
		b[2 * i + 1] = a[2 * i];
		a[2 * i + 1] = b[2 * i];
	}
	long long int c[10004];
	for (i = 0; i < n; i++)
		scanf("%lld", &c[i]);
	int d[20004];
	for (i = 0; i < 2 * n; i++)
		d[i] = i;
	qsort(d, 2 * n - 2, sizeof(int), asc1);
	qsort(c, n, sizeof(long long int), asc2);
	int count[10004];
	for (i = 0; i < n; i++)
		count[i] = 0;
	for (i = 0; i < n - 1; i++)
	{
		count[a[2 * i]]++;
		count[b[2 * i]]++;
	}
	long long int v[10004];
	for (i = 0; i < n; i++)
		v[i] = -1;
	int min;
	int j;
	long long int ans = 0;
	int p, q, r;
	for (j = 0; j < n; j++)
	{
		min = -1;
		for (i = 0; i < n; i++)
		{
			if (min < 0 && v[i] < 0)
				min = i;
			else if (v[i] < 0 && count[i] < count[min])
				min = i;
		}
		v[min] = c[j];
		ans += v[min] * count[min];
		p = 0;
		q = 2 * n - 2;
		while (q - p > 1)
		{
			r = (p + q) / 2;
			if (a[d[r]] < min)
				p = r;
			else
				q = r;
		}
		if (a[d[p]] < min)
			p++;
		if (p < 2 * n)
		{
			while (a[d[p]] == min)
			{
				if (v[b[d[p]]] < 0)
					count[b[d[p]]]--;
				p++;
				if (p == 2 * n)
					break;
			}
		}
	}
	printf("%lld\n", ans);
	for (i = 0; i < n - 1; i++)
		printf("%lld ", v[i]);
	printf("%lld\n", v[i]);
	return 0;
}

Measured memory_bytes: 764
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	m := scanInt()

	c := 1
	d := n
	f := make([]bool, n)
	for i := 0; i < m; i++ {
		if f[d-c] || d-c == n-(d-c) {
			d--
		}
		fmt.Fprintln(wr, c, d)
		f[d-c] = true
		f[n-(d-c)] = true
		c++
		d--
	}
	// debug(f)
}


Measured memory_bytes: 3412
#include <iostream>
#include <algorithm>
 
using namespace std;
 
#define rep(i, n) for(int i=0; i<(n); ++i)

int ball[10], lb[10], rb[10];

bool dfs(int n, int l, int r) {
    if(n==10) {
        rep(i, l-1) if(lb[i] > lb[i+1]) return false;
        rep(i, r-1) if(rb[i] > rb[i+1]) return false;
        return true;
    }
    lb[l] = ball[n];
    bool hoge = dfs(n+1, l+1, r);
    rb[r] = ball[n];
    bool fuga = dfs(n+1, l, r+1);
    if(hoge || fuga) return true;
    else return false;
}

int main(void){
    int N;
    cin >> N;
    rep(loop, N) {
        rep(i, 10) cin >> ball[i];
        if(dfs(0, 0, 0)) cout << "YES" << endl;
        else cout << "NO" << endl;
    }

    return 0;
}

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

vector<int64_t> fact;

int64_t factorial(int64_t n, int64_t MOD) {
    return fact[n];
}

//-RECIPE-START-//
// Use 64 bits integers to avoid overflow errors during multiplication.
int64_t modPow(int64_t a, int64_t x, int64_t p) {
    //calculates a^x mod p in logarithmic time.
    int64_t res = 1;
    while (x > 0) {
        if (x % 2)
            res = (res * a) % p;
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}

int64_t modInverse(int64_t a, int64_t p) { // (assuming p is prime).
    return modPow(a, p-2, p); //calculates the modular multiplicative of a mod m.
}
int64_t modBinomial(int64_t n, int64_t k, int64_t p) { // calculates C(n,k) mod p (assuming p is prime).
    int64_t numerator = factorial(n, p); // n!
    int64_t denominator = (factorial(k, p)*(factorial(n-k, p)))%p; // k!*(n-k)!
    return ( numerator* modInverse(denominator,p) ) % p; // numerator / denominator mod p.
}

const int64_t mod = 1e9+7;

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

	int K, S;
	string s;
	cin >> K >> s;
	S = s.size();
	vector<int64_t> pow26(K+S+5, 1), pow25(K+S+5, 1);
	fact.assign(K+S+5, 1);
	for (int i = 1; i < K+S+5; ++i) {
		pow26[i] = (pow26[i-1]*26)%mod;
		pow25[i] = (pow25[i-1]*25)%mod;
		fact[i] = (fact[i-1]*int64_t(i))%mod;
	}

	int64_t ans = 0;
	for (int i = S+K-1; i >= S-1; --i) {
		int64_t right = (S+K-1) - i;
		int64_t rem = K-right;
		int64_t others = (pow26[right]*pow25[rem])%mod;
		ans += (others*modBinomial(i, S-1, mod))%mod;
		ans %= mod;
	}

	cout << ans << endl;

}


Measured memory_bytes: 51216
A = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
bn = [int(input()) for _ in range(N)]

flag = False
for row in A:
    if all(item in bn for item in row):
        flag = True

for col in zip(*A):
    if all(item in bn for item in col):
        flag = True

if all(A[i][i] in bn for i in range(3)):
    flag = True

if all(A[i][3-1-i] in bn for i in range(3)):
    flag = True

print('Yes' if flag else 'No')


Measured memory_bytes: 3064
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <deque>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <map>
#include <cmath>

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

using namespace std;

int main(){
	int x, a, b;
	cin >> x >> a >> b;
	int c = abs(x - a);
	int d = abs(x - b);
	if(c < d) cout << "A" << endl;
	else cout << "B" << 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;
typedef long long ll;

int main() 
{
  int n, q;
  cin >> n >> q;
  vector<vector<int>> vec(n);
  rep (i, n-1) {
    int a, b;
    cin >> a >> b;
    vec[a-1].push_back(b-1);
  }

  int sum_x[n] = {};
  rep (i, q) {
    int p, x;
    cin >> p >> x;
    sum_x[p-1] += x;
  }
  
  rep (i, n) {
    int m = vec[i].size();
    while (--m >= 0) {
      sum_x[ vec[i][m] ] += sum_x[i];
    }
  }
  
  rep (i, n) {
	cout << sum_x[i] << " ";
  }
  return 0;
}

Measured memory_bytes: 14080
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;

void solve()
{
    int n;
    cin >> n;

    ll s = 1;
    ll a[n];
    for(int i = 0; i<n; i++)
    {
        cin >> a[i];
        if(a[i]==0)
        {
            cout << 0 << endl;
            return ;
        }
    }
    for(int i = 0; i<n; i++)
    {
        if(s>(ll)1e18/a[i])
        {
            cout << -1 << endl;
            return ;
        }
        s *= a[i];
    }
    cout << s << endl;
}


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


Measured memory_bytes: 4444
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <float.h>
#include <iostream>
#include <map>
using namespace std;

int main()
{
	char szStr[100];
	double x;
	int T;
	cin >> T >> x;
	double dbRet = T / (double)x;
	cout << dbRet;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>

#define inf 1000000000

using namespace std;

int main(){
	while(1){
		int n;
		cin>>n;
		if(!n)break;
		int check[6][6][6][6][6][6]={0};
		for(int i=0;i<n;i++){
			int s[7];
			for(int j=1;j<=6;j++){
				string a;
				cin>>a;
				switch(a[0]){
					case 'C':s[j]=0;break;
					case 'Y':s[j]=1;break;
					case 'R':s[j]=2;break;
					case 'M':s[j]=3;break;
					case 'G':s[j]=4;break;
					case 'B':s[j]=5;break;
				}
			}
			int bin;
			for(int i=0;i<4;i++){
				bin=s[1];
				s[1]=s[5];
				s[5]=s[6];
				s[6]=s[2];
				s[2]=bin;
				for(int j=0;j<4;j++){
					bin=s[2];
					s[2]=s[3];
					s[3]=s[5];
					s[5]=s[4];
					s[4]=bin;
					check[s[1]][s[2]][s[3]][s[4]][s[5]][s[6]]=1;
				}
			}
			
			
					bin=s[1];
					s[1]=s[3];
					s[3]=s[6];
					s[6]=s[4];
					s[4]=bin;
				for(int j=0;j<4;j++){
					bin=s[2];
					s[2]=s[3];
					s[3]=s[5];
					s[5]=s[4];
					s[4]=bin;
					check[s[1]][s[2]][s[3]][s[4]][s[5]][s[6]]=1;
				}
					bin=s[1];
					s[1]=s[3];
					s[3]=s[6];
					s[6]=s[4];
					s[4]=bin;
					bin=s[1];
					s[1]=s[3];
					s[3]=s[6];
					s[6]=s[4];
					s[4]=bin;
				for(int j=0;j<4;j++){
					bin=s[2];
					s[2]=s[3];
					s[3]=s[5];
					s[5]=s[4];
					s[4]=bin;
					check[s[1]][s[2]][s[3]][s[4]][s[5]][s[6]]=1;
				}
		}
		
		int cont=0;
		for(int a=0;a<6;a++)
		for(int b=0;b<6;b++)
		for(int c=0;c<6;c++)
		for(int d=0;d<6;d++)
		for(int e=0;e<6;e++)
		for(int f=0;f<6;f++)
		cont+=check[a][b][c][d][e][f];
		
		printf("%d\n",n-cont/24);
	}
}

Measured memory_bytes: 0
#include <bit>
#include <bitset>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <iomanip>

typedef long double ld;
typedef long long ll;

using namespace std;


/* TEMPLATE ENDS HERE */

int main() {
	cout << fixed << setprecision(12);	
	int n;
	cin >> n;
	int cur = 0;
	int curx = 0;
	int cury = 0;
	for (int i = 0; i < n; i++) {
		int x, y, t;
		cin >> t >> x >> y;
		int d = abs(curx - x) + abs(cury - y);
		int dt = t - cur;
		bool ok = true;
		if (d > dt) {
			ok = false;
		} else if ((d & 1) != (dt & 1)) {
			ok = false;
		}
		if (!ok) {
			cout << "No" << endl;
			return 0;
		}
		cur = t;
		curx = x;
		cury = y;
	}
	cout << "Yes" << endl;
	return 0;
}


ll MOD = ((ll)1e9 + 7);

struct mod {
	ll x;

	mod(ll tx = 0) {
		x = tx;
		x %= MOD;
	}
	
	mod& operator=(const ll & tx) {
		x = tx % MOD;
		return *this;
	}
	
	mod& operator=(const mod & m2) {
		x = m2.x;
		return *this;
	}

	mod operator+(const mod& m2) const {
		return mod((x + m2.x) % MOD);
	}

	mod& operator+=(const mod& m2) {
		x += m2.x;
		x %= MOD;
		return *this;
	}

	mod operator-(const mod & m2) const {
		return mod((x - m2.x + MOD) % MOD);
	}

	mod& operator-=(const mod & m2) {
		x -= m2.x;
		x = (x + MOD) % MOD;
		return *this;
	}

	mod operator*(const mod & m2) const {
		return mod((x * m2.x) % MOD);
	}

	mod& operator*=(const mod & m2) {
		x *= m2.x;
		x %= MOD;
		return *this;
	}

	mod mypow(ll k) const {
		mod ret = 1;
		mod cur = x;
		while (k) {
			if (k & 1) {
				ret *= cur;
			}
			cur *= cur;
			k >>= 1;
		}
		return ret;
	}

	mod inv() const {
		return mypow(MOD - 2);
	}

	mod operator/(const mod & m2) const {
		return (*this) * m2.inv();
	}

	mod& operator/=(const mod & m2) {
		x *= m2.inv().x;
		x %= MOD;
		return *this;
	}

	bool operator<(const mod & m2) const {
		return x < m2.x;
	}
};

ostream &operator<<(ostream & os, const mod & m) {
	return os << m.x;
}



Measured memory_bytes: 3552
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using Graph=vector<vector<pair<int,ll>>>;
using pp=pair<ll,pair<ll,ll>>;
#define MAX 1000000
#define MOD 1000000007
#define INF 1000000000000000000

int main(){
  int N,Q;
  string S;
  cin>>N>>S>>Q;
  vector<int> k(Q);
  for(int i=0;i<Q;i++){
    cin>>k[i];
  }

  for(int i=0;i<Q;i++){
    ll D=0;
    ll M=0;
    ll num=0;
    vector<ll> count(N);
    for(int j=0;j<k[i];j++){
      if(S[j]=='D'){
        D++;
      }else if(S[j]=='M'){
        M++;
        num+=D;
      }
      count[j]=num;
    }
    for(int j=k[i];j<N;j++){
      if(S[j-k[i]]=='D'){
        D--;
        num-=M;
      }else if(S[j-k[i]]=='M'){
        M--;
      }
      if(S[j]=='D'){
        D++;
      }else if(S[j]=='M'){
        M++;
        num+=D;
      }
      count[j]=num;
    }

    ll ans=0;
    for(int j=1;j<N;j++){
      if(S[j]=='C'){
        ans+=count[j];
      }
    }

    cout<<ans<<endl;
  }
}


Measured memory_bytes: 12140
#include<iostream>
using namespace std;
int main() {
    int n;
    int ts = 0, hs = 0;
    cin >> n;
    
    for (int i = 0; i < n; i++) {
        string t, h;
        cin >> t >> h;
        
        int r = 0;
        int len = min(t.size(), h.size());
        for (int j = 0; j < len; j++) {
            if (t[j] > h[j]) {
                r = 1;
                break;
            } else if (t[j] < h[j]) {
                r = -1;
                break;
            } else {
                if (j + 1 == len) {
                    if (t.size() > h.size()) {
                        r = 1;
                    } else if (t.size() < h.size()) {
                        r = -1;
                    }
                }
            }
        } 
        if (r == 1) ts += 3;
        else if ( r == -1) hs += 3;
        else { ts +=1; hs += 1; }
    }
    
    cout << ts << " " << hs << endl;
    
    return 0;
}


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

typedef long long ll;

int a, b, c, d, e, k;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> a >> b >> c >> d >> e >> k;
    if (e - a > k)
        cout << ":(" << endl;
    else
        cout << "Yay!" << endl;

    return 0;
}



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

int main(){
    ll h,w;
    cin>>h>>w;
    if(h%3==0||w%3==0){
        cout<<0<<endl;return 0;
    }
    //候補2 T字型に切る
    ll ans2=LINF;
    ll a=w/2+w%2,b=w/2;
    for(int i=1;i<h;i++){
        ll sq1=i*w,sq2=(h-i)*a,sq3=(h-i)*b;
        ll tmp=max({sq1,sq2,sq3})-min({sq1,sq2,sq3});
        ans2=min(ans2,tmp);
    }
    swap(h,w);
    ll ans3=LINF;
    a=w/2+w%2;b=w/2;
    for(int i=1;i<h;i++){
        ll sq1=i*w,sq2=(h-i)*a,sq3=(h-i)*b;
        ll tmp=max({sq1,sq2,sq3})-min({sq1,sq2,sq3});
        ans3=min(ans3,tmp);
    }
    cout<<min({h,w,ans2,ans3})<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    long long dp[n][n][2];
    for(int i = 0; i <n; i++){
        dp[i][i][0] = a[i];
        dp[i][i][1] = 0;
    }
    for(int k = 1; k < n; k++){
        for(int i = 0; i + k < n; i++){
            //compute dp[i][i+k][0], dp[i][i+k][1]
            if(dp[i+1][i+k][1]+a[i] - dp[i+1][i+k][0] > dp[i][i+k-1][1]+a[i+k] - dp[i][i+k-1][0]){
                dp[i][i+k][0] = dp[i+1][i+k][1] + a[i];
                dp[i][i+k][1] = dp[i+1][i+k][0];
            }
            else{
                dp[i][i+k][0] = dp[i][i+k-1][1] + a[i+k];
                dp[i][i+k][1] = dp[i][i+k-1][0];
            }

        }
    }
    cout << dp[0][n-1][0] - dp[0][n-1][1] << "\n";
    return 0;
}

Measured memory_bytes: 140800
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        String Slist[] = S.split("");
        int N =sc.nextInt();
        for(int i = 0; i < S.length(); i+=N){
            System.out.print(Slist[i]);
        }
        
        
    }
}


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

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

    int a[26] = {};
    for (char c : s) {
        a[c - 'a']++;
    }

    for (int i = 0; i < 26; i++) {
        if (!a[i]) {
            return cout << char(i + 'a') << endl, 0;
        }
    }
    cout << "None" << endl;

    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
 
using namespace std;
 
#define MAX 100
#define MAX_H 100000
#define INF (1<<29)
typedef long long ll;
 
int main(){
    ll N,M;
    string in;
    while(cin >> N, N){
        ll MHP = 0;
        vector<ll> HP(N);
        for(ll i = 0 ; i < N ; i++){
            cin >> HP[i];
            MHP = max(MHP,HP[i]);
        }
        cin >> M;
        vector<ll> MP(M),t(M),d(M);
        for(ll i = 0 ; i < M ; i++){
            cin >> in >> MP[i] >> in >> d[i];
            t[i] = (in == "All");
        }
        ll dp[2][MAX_H+1];
        fill(dp[0],dp[0]+2*(MAX_H+1),INF);
        dp[0][0] = dp[1][0] = 0;
        for(ll i = 0 ; i < M ; i++){
            for(ll j = 0 ; j <= MHP ; j++){
                ll nt = t[i],nhp = min(MHP,j+d[i]);
                dp[nt][nhp] = min(dp[nt][nhp],dp[nt][j]+MP[i]);
            }
        }
        for(ll i = MHP ; i > 0 ; i--){
            dp[0][i-1] = min(dp[0][i-1],dp[0][i]);
            dp[1][i-1] = min(dp[1][i-1],dp[1][i]);
        }
        ll res = INF;
        for(ll i = 0 ; i <= MHP ; i++){
            ll mp = dp[1][i],mp2 = 0;
            if(mp == INF) continue;
            for(ll j = 0 ; j < N ; j++){
                ll rest = max(HP[j]-i,0LL);
                if(rest == 0) continue;
                mp2 += dp[0][rest];
            }
            res = min(res,mp+mp2);
        }
        cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 4700
#include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <map>
#include <algorithm>
#include <stdio.h>
#include <set>
#include <cmath>

typedef long long ll;

using namespace std;

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int size = n;
    //if(n < 3) return 0;
    ll a[3];
    for(int i = 0; i < 3; i++){
        a[i] = 0;
    }
    for(int i = 0; i < size; i++){
        if(s[i] == 'R'){
            a[0]++;
        }
        else if(s[i] == 'G'){
            a[1]++;
        }
        else {
            a[2]++;
        }
    }
    int count = 0;
    for(int i = 3; i <= size; i += 2){
        int b = (i - 3) / 2;
        for(int j = 0; j + i - 1 < size; j++){
            if(s[j] != s[j + b + 1] && s[j + 2 * b + 2] != s[j + b + 1] && s[j] != s[j + 2 * b + 2]){
                count++;
            }
        }
    }
    cout << a[0] * a[1] * a[2] - count << endl;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
// Welcome to my source code!

#define MAX 200000
#define SENTINEL 2000000000

int L[MAX / 2 + 1], R[MAX / 2 + 1];

ll merge(int A[], int left, int mid, int right) {
    ll cnt = 0;
    int n1 = mid - left;
    int n2 = right - mid;
    rep(i,n1) L[i] = A[left + i];
    rep(i,n2) R[i] = A[mid + i];
    L[n1] = R[n2] = SENTINEL;
    int i = 0, j = 0;
    for (int k = left; k < right; k++) {
        if (L[i] <= R[j]) {
            A[k] = L[i++];
        } else {
            A[k] = R[j++];
            cnt += n1 - i;
        }
    }
    return cnt;
}

ll mergeSort(int A[], int left, int right) {
    int mid;
    ll v1, v2, v3;
    if (left + 1 < right) {
        mid = (left + right) / 2;
        v1 = mergeSort(A, left, mid);
        v2 = mergeSort(A, mid, right);
        v3 = merge(A, left, mid, right);
        return v1 + v2 + v3;
    } else return 0;
}

int main() {
    int A[MAX], n;
    cin >> n;
    rep(i,n) cin >> A[i];

    ll ans = mergeSort(A, 0, n);
    cout << ans << endl;
}


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

#define rep(i,n) for(int i=0;i<(n);++i)
#define loop for(;;)
#define trace(var) cerr<<">>> "<<#var<<" = "<<var<<endl;
#define inf (1e9)
#define eps (1e-9)

template<class S, class T> inline
ostream& operator<<(ostream&os, pair<S,T> p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

template<class S, class T, class U> inline
ostream& operator<<(ostream&os, tuple<S,T,U> t) {
  return os << '('
    << get<0>(t) << ", "
    << get<1>(t) << ", "
    << get<2>(t) << ')';
}

template<class T> inline
ostream& operator<<(ostream&os, vector<T> v) {
  if (v.size() == 0) { return os << "(empty)"; }
  os << v[0];
  for (int i=1, len=v.size(); i<len; ++i) os << ' ' << v[i];
  return os;
}

template<class T> inline
istream& operator>>(istream&is, vector<T>&v) {
  rep (i, v.size()) is >> v[i];
  return is;
}

bool* PrimeSieve(int n) {
  bool*s = new bool[n];
  for (int i = 0; i < n; ++i) s[i] = true;
  s[0] = s[1] = false;
  for (int i = 2; i < n; ++i)
    if (s[i]) for (int j = i << 1; j < n; j += i) s[j] = false;
  return s;
}

typedef vector<int> vi;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout.setf(ios::fixed);
  cout.precision(10);

  bool* ps = PrimeSieve(100000 * 2);
  loop {
    int n, p; cin >> n >> p;
    if (n < 0 and p < 0) break;

    vi xs;
    for (int i = n + 1, j = 0; j < p; ++i) {
      if (ps[i]) {
        ++j;
        xs.push_back(i);
      }
    }

    vi ys;
    for (int x: xs) {
      for (int y: xs) {
        if (y > x) break;
        ys.push_back(x + y);
      }}
    sort(begin(ys), end(ys));
    cout << ys[p-1] << endl;
  }

  return 0;
}

Measured memory_bytes: 1480
from collections import Counter

N = int(input())
S = input()

count = Counter(S[1:])['E']
ans = count
for i in range(1, len(S)):
    if S[i-1] == 'W':
        count += 1
    if S[i] == 'E':
        count -= 1
    ans = min(ans, count)
print(ans)


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

int main() {
    int n, t;
    cin >> n;
    vector<int> ans(n);
    for (int i=1; i<=n; i++) {
        cin >> t;
        ans.at(t-1) = i;
    }
    for (int i=0; i<n; i++) {
        cout << ans[i] << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1152