akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
using namespace std;

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

  int n = s.size();
  vector<char> v;
  for (int i = 0; i < n; i++) {
    char c = s[i];
    if(c == '0') v.push_back('0');
    else if(c == '1') v.push_back('1');
    else if(c == 'B' && !v.empty()) v.pop_back();
  }

  while(!v.empty()) {
    char c = v.front();
    v.erase(v.begin());
    cout << c;
  }
  cout << endl;

  return 0;
}

Measured memory_bytes: 3544
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i32 = int32_t;
using i64 = int64_t;
constexpr char newl = '\n';

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define F first
#define S second
#define debug(x) cout << #x << ": " << x << '\n';

#if 1

string getLCS(const string &a, const string &b) {

  // string dp[a.size() + 1][b.size() + 1]はメモリが爆発するので
  // string dp[2][b.size() + 1] にするか、もしくは
  // <方向, 長さ> dp[a.size() + 1][b.size() + 1] にする

  vector<vector<string>> dp(2, vector<string>(b.size() + 1, ""));

  FOR(i, 1, a.size() + 1) {
    FOR(j, 1, b.size() + 1) {
      if (a[i - 1] == b[j - 1]) {
        dp[1][j] = dp[1 - 1][j - 1] + a[i - 1];
      }
      else {
        if (dp[1 - 1][j].size() > dp[1][j - 1].size()) {
          dp[1][j] = dp[1 - 1][j];
        }
        else {
          dp[1][j] = dp[1][j - 1];
        }
      }
    }
    swap(dp[0], dp[1]);
  }

  return dp[0][b.size()];
}

// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  string s, t;
  cin >> s >> t;

  cout << getLCS(s, t);
}
#endif


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

typedef long long int ll;
typedef long double ld;
typedef unsigned long long uli;

#define fastio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define test ll t;cin>>t;while(t--)
#define nin ll n;cin>>n;
#define ain ll n;cin>>n;ll arr[n];for(ll i=0;i<n;i++){cin>>arr[i];}
#define out(arr,n) for(ll i=0;i<n;i++){cout<<arr[i]<<" ";}cout<<'\n';
#define fr(i,n) for(ll i=0;i<n;i++)
#define fri(i,l,n) for(ll i=l;i<n;i++)
#define sr(a,n) sort(a,a+n);
#define gr(a,n) sort(a,a+n,greater<ll>());
#define cen cout<<endl;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define vll vector<ll>
#define pll pair<ll,ll>


const ll MAX = 1e5 + 10;
const ll mod = 1e9 + 7;


int main() {
    fastio;
    //test{}
    //test{ ain;}
    ll a, b;
    cin >> a >> b;
    if (b < a) {
        cout << "safe\n";
    } else {
        cout << "unsafe\n";
    }







}

Measured memory_bytes: 3636
#!/usr/bin/python3
# -*- coding: utf-8 -*-


"""
https://beta.atcoder.jp/contests/abc051/tasks/abc51_d
"""

import sys
import math
import copy
from inspect import currentframe

def debug_print(*args):
    names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args), file=sys.stderr)

N, M = map(int, input().split())

d = [[0 if i == j else float('inf') for i in range(N)] for j in range(N)]
edges = []

for _ in range(M):
    a, b, c = map(int, input().split())
    d[a-1][b-1] = c
    d[b-1][a-1] = c
    edges.append((a,b,c))

graph = copy.deepcopy(d)

# 全点対最短路問題　ワーシャルフロイドで簡単に計算可能

for k in range(N):
    for i in range(N):
        for j in range(N):
            d[i][j] = min(d[i][j], d[i][k] + d[k][j])
    
#debug_print(d)
unused_edge = 0
for edge in edges:
    if edge[2] > d[edge[0] - 1][edge[1] - 1]:
        unused_edge += 1
print(unused_edge)
    
    





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

int main(){
    vector<int> candy(3);
    for(int i = 0; i < 3; i++){
        cin >> candy.at(i);
    }
    sort(candy.begin(), candy.end());
    if((candy.at(0) + candy.at(1)) == candy.at(2)){
        cout << "Yes";
    } else {
        cout << "No";
    }
}


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


int main(){
    string s; cin >> s;
    int n = s.size();
    reverse(s.begin(), s.end());
    vector<string> kouho = {"dream","dreamer","erase","eraser"};
    rep(i,4) reverse(kouho[i].begin(), kouho[i].end());
    for(int i = 0; i < n; ){
        bool flag = true;
        rep(j,4){
            if(s.substr(i,kouho[j].size()) == kouho[j]){
                flag = false;
                i += kouho[j].size();
            }
        }
        if(flag){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);	

	string s;
	cin >> s;
	int n = (int)s.size();
	int ans = n;
	for (int i = 0; i + 1 < n; i++) {
		if (s[i] != s[i + 1]) {
			ans = min(ans, max(i + 1, n - (i + 1)));
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
using namespace std;
typedef vector <int> vi;
typedef vector <vi> vvi;
int counter=0;

int addedge(vvi &graph, int y, int x, int val=1){
	graph[y][x] = val;
	return val;
}

int make_graph(vvi &graph, vvi &stamp){
	int n1=graph.size(), n2, row, col;

	for (int j=0; j<n1; j++){
		cin>>row;
		cin>>n2;
		for (int i=0; i<n2; i++){
			cin>>col;
			addedge(graph, row-1, col-1);
		}
		stamp[j][0] = -1;
	}
	return 0;
}

int Depth_First_Search(vvi &graph, vvi &stamp, int key=0){
	if (stamp[key][0] != -1) return 0;
	stamp[key][0] = ++counter;
	for (int i=0; i<int(graph[0].size()); i++){
		if (graph[key][i]==1 && stamp[i][0]==-1){
			Depth_First_Search(graph, stamp, i);
		}
	}
	stamp[key][1] = ++counter;
	return 0;
}

int resultout(vvi &stamp){
	for (int i=0; i<int(stamp.size()); i++){
		cout<<i+1<<" "<<stamp[i][0]<<" "<<stamp[i][1]<<endl;
	}
	return 0;
}

int main(void){

	int n, row;
	cin>>n;
	vvi G(n, vi(n)), stamp(n, vi(2));

	make_graph(G, stamp);

	for (int i=0; i<n; i++){
		Depth_First_Search(G, stamp, i);
	}
	resultout(stamp);

	return 0;
} 

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

int main() {
  
  int N; 
  cin >> N;
  
  int h[N+1];
  int max_height;
  for (int i = 0; i < N; i++) {
    cin >> h[i];
  }
  h[N] = 0;
  max_height = *max_element(h, h+N);
  
  
  
  int A[N+1][max_height];
  

  
  for (int i = 0; i < N+1; i++) {
    for (int j = 0; j < h[i]; j++) {
      A[i][j] = 1;
    }
    for (int j = h[i]; j < max_height; j++) {
      A[i][j] = 0;
    }
  }
 
  
  
  int ans = 0;
  
  for (int j = 0; j < max_height; j++) {
    for (int i = 0; i < N; i++) {
      if (A[i][j] == 1 && A[i+1][j] == 0) ans++;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define MOD 1000000007
typedef long long ll;
int cmpint(const void *x, const void *y) {
	return *(int *)x - *(int *)y;
}
int main() {
	int n, a[100000];
	ll ans = 1;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	qsort(a, n, sizeof(int), cmpint);
	if (n % 2 == 1) {
		if (a[0] != 0) {
			ans = 0;
		}
		for (int i = 1; i < n; i += 2) {
			if (a[i] != a[i + 1] || a[i] != i + 1) {
				ans = 0;
				break;
			}
		}
	} else {
		for (int i = 0; i < n; i += 2) {
			if (a[i] != a[i + 1] || a[i] != i + 1) {
				ans = 0;
				break;
			}
		}
	}
	if (ans != 0) {
		for (int i = 0; i < n / 2; i++) {
			ans *= 2;
			ans %= MOD;
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 892
#include <cmath>
#include <iostream>
#include <map>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int a;
  cin >> a;
  cout << a + a * a + a * a * a << endl;
  return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <vector>

using namespace std;

int main(){
	int n,f = 0;
	vector<int> c{10,50,100,500};
	while(cin >> n,n){
		if(f++) cout << endl;
		int sum = 0;
		vector<int> num(4);
		for(int i=0;i<4;i++){
			cin >> num[i];
			sum += num[i]*c[i];
		}
		int change = sum - n;
		for(int i=3;i>=0;i--){
			num[i] = num[i] - change / c[i];
			change %= c[i];
		}
		for(int i=0;i<4;i++){
			if(num[i]>0){
				cout << c[i] << " " << num[i] << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1192
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

int n,x,y;
int dis[200020];



int main(){
	cin>>n>>x>>y;
	
	for (int i=1;i<=n;i++){
		for (int j=1;j<=i;j++){
			dis[min(i-j,abs(x-j)+abs(y-i)+1)] ++;
		}
	}
	
	for (int i=1;i<n;i++){
		cout<<dis[i]<<endl;
	}
	
	return 0; 
} 

Measured memory_bytes: 3552
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int c = 0,n;
    map<string,int>q;
    string ss[5] = {"Zero","One","Two","Three","Four"};
    string s;
    cin>>n;
    for(int i = 0;i < n;i ++)
    {
        cin>>s;
        if(!(q[s] ++))c ++;
    }
    cout<<ss[c];
}


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


int main(){
  string s;
  cin >> s;
  int n,i,co1,co0,sum;
  sum=0;
  co1=co0=0;
  n=s.size();
  for(i=0;i<n;++i){
    if(s[i]=='1'){
      co1++;
    }else{
      co0++;
    }
  }
  sum=min(co1,co0)*2;
  cout << sum << endl;

}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
long long pw[1000005];

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    if(fopen(".inp", "r")) freopen(".inp", "r", stdin);

    int k; cin >> k;
    if(k % 2 == 0) return cout << -1, 0;

    if(k % 7 == 0) k/=7;
    if(k == 1) return cout << 1, 0;

    pw[0] = 1;
    long long sum=1;

    for(int i=1 ; i<=k+1 ; ++i) {
        pw[i] = 1ll*pw[i-1]*10 % k;
        sum = (sum + pw[i]) % k;
        if(sum == 0) return cout << i+1, 0;
    }
    cout << -1;



    return 0;
}


Measured memory_bytes: 11440
import sys
def f(P):
 i=0
 for _ in[0]*k:
  s=0
  while s+w[i]<=P:
   s+=w[i];i+=1
   if i==n: return n
 return i
n,k=map(int,input().split())
w=list(map(int,sys.stdin.readlines()))
l=0;r=sum(w)
while r-l>1:
 m=(l+r)//2
 if f(m)>=n:r=m
 else:l=m
print(r)


Measured memory_bytes: 15824
//Author : Nishit Patel
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef double db;
typedef long long ll;
#define pb push_back
#define FAST cin.sync_with_stdio(0); cin.tie(0);
#define rep(i, n)      for(int i = 0; i < (n); ++i)
#define arep(i, a, n)  for(int i = a; i <= (n); ++i)
#define drep(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x)     for(auto& a : x)
#define all(x) x.begin(), x.end()
typedef pair<int, int> pii;
typedef vector<ll> vl;
typedef map<ll, ll> ml;
typedef unordered_map<ll, ll> hash;
#define deb_1(A)                     {cerr << "[" << #A << "] : " << A << endl;}
#define deb_2(A,B)                   {cerr << "[" << #A << "] : " << A << endl<< "[" << #B << "] : " << B << endl;}
#define deb_3(A,B,C)                 {cerr << "[" << #A << "] : " << A << endl<< "[" << #B << "] : " << B << endl\
									   << "[" << #C << "] : " << C << endl;}
#define deb_4(A,B,C,D)               {cerr << "[" << #A << "] : " << A << endl<< "[" << #B << "] : " << B << endl\
									   << "[" << #C << "] : " << C << endl<< "[" << #D << "] : " << D << endl;}
#define deb_X(x,A,B,C,D,FUNC, ...)  FUNC  
#define deb(...)                    deb_X(,##__VA_ARGS__,\
                                          deb_4(__VA_ARGS__),\
                                          deb_3(__VA_ARGS__),\
                                          deb_2(__VA_ARGS__),\
                                          deb_1(__VA_ARGS__),\
                                         )
                                         
                                         
#define L 1000005
bitset<L> bt;
ll memo[1000005];
ll dfs(ll curr,vector<vector<ll>> &v,ll depth)
{
	 if(bt[curr] == 1)
	 {
		 return memo[curr]+1;
	 }
	 bt[curr] = 1;
	 ll logest_depth =0;
	 for(int i=0;i<v[curr].size();i++)
	 {
		 if(memo[v[curr][i]] == 0)
		 {
			 logest_depth = max(logest_depth,dfs(v[curr][i],v,depth));
		 }
		 else{
			 logest_depth = max(logest_depth,memo[v[curr][i]]+1);
		 }
	 }
	 memo[curr] = logest_depth;
	 return 1+logest_depth;
}
int main() {
	FAST
	ll n,m,x,y;
	cin>>n>>m;
	vector<vector<ll>> v(n+1);
	rep(i,m)
	{
		cin>>x>>y;
		v[x].pb(y);
	}
	ll depth = INT_MIN;
	arep(i,1,n)
	{
		if(bt[i] == 0)
		{
			depth= max(depth,dfs(i,v,0));
		}
			
	}
	cout<<depth-1<<endl;
}


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

#define ll long long

int main(void){
    int n;
    cin >> n;
    while(0 <= n){
        if(n % 7 == 0){
            cout << "Yes" << endl;
            return 0;
        }
        n -= 4;
    }
    cout << "No" << endl;
    return 0;

}

Measured memory_bytes: 256
import numpy as np

n, k = (int(x) for x in input().split())
p = np.array(list(int(x) for x in input().split()))

p = (p + 1) / 2

sump = []
e = []
s = 0

for i in range(len(p)):
    s += p[i]
    sump.append(s)

sump.insert(0, 0)
sump = np.array(sump)

for i in range(n - k + 1):
    e.append(sump[i + k] - sump[i])


print(max(e))

Measured memory_bytes: 34004
from collections import deque
N = int(input())
A = [int(i) for i in input().split()]
values = [str(i+1) for i in range(N)]
dic = {key: val for key, val in zip(A, values)}
dic_s = deque(sorted(dic.items()))
s =deque()
for i in range(N):
    s.append(dic_s[i][1])

ans = ' '.join(list(s))
print(ans)

Measured memory_bytes: 29780
#include <bits/stdc++.h>
using namespace std;
#define f(a,b)  for(int i=a; i<b; i++)
int main(){
  int sum =0;

  int a,b,c;
  cin >> a >> b >> c;

  sum = a+b+c;
  sum -= max (a,max(b,c));
  
    cout << sum << endl;
    

  return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>

struct set {
	int h;
	int w;
	int diagonel;
} all[22500];

int suffix = 0;

void InsSort(int n)
{
	int i, j, temp_dia, temp_h, temp_w;

	for (i = 1; i < n; i++) {
		temp_h = all[i].h;
		temp_w = all[i].w;
		temp_dia = all[i].diagonel;
		for (j = i; j > 0; j--) {
			if (all[j - 1].diagonel > temp_dia) {
				all[j].h = all[j - 1].h;
				all[j].w = all[j - 1].w;
				all[j].diagonel = all[j - 1].diagonel;
			}
			else if (all[j - 1].diagonel == temp_dia) {
				if (all[j - 1].h > temp_h) {
					all[j].h = all[j - 1].h;
					all[j].w = all[j - 1].w;
					all[j].diagonel = all[j - 1].diagonel;
				}
				else {
					break;
				}
			}
			else {
				break;
			}
		}

		all[j].h = temp_h;
		all[j].w = temp_w;
		all[j].diagonel = temp_dia;
	}
}

void search() {
	for (int i = 1; i <= 150; i++) {
		for (int j = 1; j <= 150; j++) {
			if (i >= j) {
				continue;
			}

			all[suffix].h = i;
			all[suffix].w = j;
			all[suffix].diagonel = (i * i) + (j * j);

			suffix++;
		}
	}
}

int main() {
	search();
	InsSort(suffix);

	//FILE *fp;
	//fp = fopen("C:\\Users\\owata\\Desktop\\answer1.txt", "w");

	while (1) {
		int h, w, my;

		scanf("%d %d", &h, &w);

		if (h == 0 && w == 0) {
			break;
		}

		my = (h * h) + (w * w);

		for (int i = 0; i < suffix; i++) {
			if (all[i].h == h && all[i].w == w) {
				continue;
			}

			if (all[i].diagonel > my) {
				printf("%d %d\n", all[i].h, all[i].w);
				//fprintf(fp, "%d %d\n", all[i].h, all[i].w);
				break;
			}
			else if (all[i].diagonel == my && h < all[i].h) {
				printf("%d %d\n", all[i].h, all[i].w);
				//fprintf(fp, "%d %d\n", all[i].h, all[i].w);
				break;
			}
		}
	}

	//fclose(fp);

	return 0;
}

Measured memory_bytes: 1160
// A.

#include <iostream>
#include <sstream>
#include <algorithm>

using namespace std;

int main(int argc, char *argv[]) {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	bool ans = abs(a - c) <= d || (abs(a - b) <= d && abs(b - c) <= d);
	cout << (ans ? "Yes" : "No") << endl;
	return 0;
}


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

#define INF 1<<20


int main(){
    ll a,b,c,k;
    cin >>a>>b>>c>>k;
    ll ans;
    ans = 0;

    ans += min(a,k);
    k = k - min(a,k);

    k = k - min(b,k);

    ans = ans - min(c, k);

    cout << ans << endl;
}


Measured memory_bytes: 3636
#include <cstdio>
#include <algorithm>
#include <vector>
#include <utility>
using namespace std;

const int INF = 1<<29;

int n, m, a, b, c, t, k;
int dp[2][100][100];

int main(){
    for(; scanf("%d%d", &n, &m), n||m;){
        for(int x = 0; x < m; x++){
            fill(dp[0][x], dp[0][x]+m, INF);
            fill(dp[1][x], dp[1][x]+m, INF);
        }
        for(int x = 0; x < m; x++){
            dp[0][x][x] = dp[1][x][x] = 0;
        }
        for(int x = 0; x < n; x++){
            scanf("%d%d%d%d", &a, &b, &c, &t);
            --a; --b;
            dp[0][a][b] = c;
            dp[0][b][a] = c;
            dp[1][a][b] = t;
            dp[1][b][a] = t;
        }
        for(int z = 0; z < m; z++){
            for(int x = 0; x < m; x++){
                for(int y = 0; y < m; y++){
                    for(int w = 0; w < 2; w++){
                        dp[w][x][y] = min(dp[w][x][y],
                                dp[w][x][z] + dp[w][z][y]);
                    }
                }
            }
        }
        scanf("%d", &k);
        for(int x = 0; x < k; x++){
            scanf("%d%d%d", &a, &b, &c);
            printf("%d\n", dp[c][--a][--b]);
        }
    }
    return 0;
}

Measured memory_bytes: 1104
import math
a,b,h,m = map(int,input().split())

sho_deg = h*0 + m*6 #6(deg/m)
lon_deg = h*30 + m*0.5 #0.5(deg/m)

deg_dif = abs(sho_deg-lon_deg)

print((a**2 + b**2-2*a*b*math.cos(deg_dif/180*math.pi))**0.5)

Measured memory_bytes: 9524
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>

using namespace std;

int main()
{
  int num;
  char h[101];
  scanf("%d", &num);
  scanf("%s", h);
  int ans = 0;
  for (int i=0;i < num; i++) {
    if (h[i]=='R') ans++;
    else ans--;
  }
  if (ans > 0) printf("Yes\n");
  else printf("No\n");
  return 0;
}


Measured memory_bytes: 256
//#pragma GCC oplmize(2)
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
#define ll long long
#define sc(x) scanf("%lld",&x)
#define scs(x) scanf("%s",x+1)
#define pr(x) printf("%lld\n",x)
#define prs(x) printf("%s\n",x)
using namespace std;
const int maxn=1e5+5;
const int mod=1e9+7;
const double pi=acos(-1.0);
const double eps = 1e-8;
string s;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>s;
    if(s[s.size()-1]=='s') cout<<s<<"es"<<endl;
    else cout<<s<<"s"<<endl;
    return 0;
}

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

int main(){
  int n,l,i,a,b,c;
  int sum = 0;
  cin >> n >> l;

  for (i = 0; i < n; i++){
    b = i + l;
    sum = sum + b;
  }

  a = n + l - 1;
  if (a >= 0 && l <= 0){
    cout << sum;
  } else if (a <= 0 && l >= 0){
    cout << sum;
  } else if (l > 0){
    c = sum - l;
    cout << c;
  } else {
    c = sum - a;
    cout << c;
  }
}


Measured memory_bytes: 256
#include <stdio.h>

constexpr int N = 1e5;
char vS[N+3], vT[N+3];
constexpr short K = 'A' - 1;

int main(void){
    int i, q;char c1, c2;
    scanf("%s%s", vS+1, vT+1);
    vS[0] = 0; i = 1; while(vS[i] != '\0') {(vS[i] += vS[i-1] - K) %= 3; i++;}
    vT[0] = 0; i = 1; while(vT[i] != '\0') {(vT[i] += vT[i-1] - K) %= 3; i++;}
    scanf("%d", &q);
    while(q--){
        int a, b, c, d; scanf("%d%d%d%d", &a, &b, &c, &d); a--; c--;
        c1 = (vS[b] - vS[a] + 3) % 3;
        c2 = (vT[d] - vT[c] + 3) % 3;
        puts(c1 == c2 ? "YES" : "NO");
    }
    return 0;
}


Measured memory_bytes: 640
N, M = map(int, input().split())
edges = [[] for _ in range(N)]

for _ in range(M):
    fr, to = map(int, input().split())
    fr -= 1
    to -= 1
    edges[fr].append(to)
    edges[to].append(fr)

def isBipartite():
    sign = [-1] * N
    st = [(0, 0)]
    while st:
        now, p = st.pop()

        if sign[now] != -1 and sign[now] != p:
            return -1
        if sign[now] == p:
            continue
        sign[now] = p

        for to in edges[now]:
            st.append((to, (p + 1) % 2))

    return sum(sign)

s = isBipartite()

if s == -1:
    print(N * (N - 1) // 2 - M)
else:
    print(s * (N - s) - M)


Measured memory_bytes: 26432
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    a,b = f()
    for i in range(1,4):
        if a*b*i%2 == 1:
            print("Yes")
            return
    
    print('No')
    

solve()


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

using namespace std;

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

    int ans = 0;
    char prev = 'A';
    for (const auto s: S){
        if (s != prev)
            ans++;
        prev = s;
    }

    cout << ans << endl;
}

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

using namespace std;

#define PI 3.14159265358979323846264338327950L

int main(void){
    int N;
    long long ans=0;

    cin>>N;


    vector<long long>L(N,0);

    for(int i=0;i<N;i++){
        cin>>L[i];
    }

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

    for(long long  i=0;i<N;i++){
        for(long long  j=i+1;j<N;j++){
            for(long long  k=j+1;k<N;k++){
                if(L[i] == L[j] || L[j] == L[k])continue;
                if(L[i]+L[j] <= L[k])continue;
                if(L[j]+L[k] <= L[i])continue;
                if(L[k]+L[i] <= L[j])continue;

                ans++;

            }
        }
    }
    cout<<ans<<endl;

    return 0;
}



Measured memory_bytes: 3628
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>
#define ll long long
#define pi (acos(-1))


int main()
{
    std::string s;
    std::cin >> s;
    for (int i = 0; i != 3; ++i) { std::cout << s[i]; }
    std::cout << std::endl;
    return 0;
}

Measured memory_bytes: 3624
N = int(input())
st = []
for i in range(N):
    s,t = input().split()
    st.append((s,int(t)))
X = input()

tmp = -1
for i in range(N):
    if st[i][0] == X:
        tmp = i
        break

ans = 0
for i in range(tmp+1,N):
    ans += st[i][1]
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>

int main(void) {
	char *day[7] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};
	int month, date;
	int count;
	int mon;
	int monlon[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
	_Bool finish;
	while (1) {
		scanf("%d %d", &month, &date);
		if( month == 0)
			break;
		count = 3;
		for (mon = 1; mon <= 12; mon++) {
			if( month == mon) {
				count = (count+date-1)%7;
				break;
			}
			else
				count = (count+monlon[mon-1])%7;
		}
		printf("%s\n", day[count]);
	}
	return 0;
}

Measured memory_bytes: 584
#include<iostream>
#include<algorithm>

using namespace std;
const int INF = 1000000000;
int M,N,ans;
int ma[10003];
int ha[503][2];
int dp[503][10003];
int main(void){
	cin >> M >> N;
	for(int i = 0;i < M;i++){
		cin>>ma[i];
	}
	sort(ma,ma + M,greater<int>());
	for(int i = 1;i < M;i++)ma[i] += ma[i-1];
	for(int i = 0;i < N;i++){
		cin >> ha[i][0] >>ha[i][1];
	}
	
	
	for(int i = 0;i <= N;i++){
		for(int j = 1;j <= M;j++){
			dp[i][j] = INF;
		}
	}
	for(int i = 1;i <= ha[0][0];i++){
		dp[1][i] = ha[0][1];
		ans = max(ans,ma[i-1]-dp[1][i]);
	}
	for(int i = 2;i <= N;i++){
		for(int j = 1;j <= M;j++){
			dp[i][j] = min(dp[i-1][j],ha[i-1][1]+dp[i-1][max(0,j-ha[i-1][0])]);
			ans = max(ans,ma[j-1]-dp[i][j]);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 22772
#!/usr/bin/python3
# -*- coding: utf-8 -*-

import sys

n = int(sys.stdin.readline())
x = list(map(int, sys.stdin.readline().split()))
y = list(map(int, sys.stdin.readline().split()))

for dim in range(1, 4):
    total = 0
    for i in range(n):
        total += abs(x[i]-y[i]) ** dim
    print(round(total ** (1/dim), 6))

maxval = 0
for i in range(n):
    if abs(x[i]-y[i]) > maxval:
        maxval = abs(x[i]-y[i])

print(float(maxval))



Measured memory_bytes: 5660
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    int count=0;
    cin >> s;
    for (int i =0;i<3;i++)
    {
      if(s.at(i)=='o')
      count++;
    }
    cout << 700+count*100 << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.math.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int s = sc.nextInt();
        int w = sc.nextInt();
        System.out.println(s <= w ? "unsafe" : "safe");
    }
}

Measured memory_bytes: 27084
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>

static const int MOD = 1000000007;
using ll = int64_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

template <class T, class U>
vector<T> make_v(U size, const T& init){ return vector<T>(static_cast<size_t>(size), init); }

template<class... Ts, class U>
auto make_v(U size, Ts... rest) { return vector<decltype(make_v(rest...))>(static_cast<size_t>(size), make_v(rest...)); }

template<class T> void chmin(T &a, const T &b){ a = (a < b ? a : b); }
template<class T> void chmax(T &a, const T &b){ a = (a > b ? a : b); }

int main() {
    int n;
    cin >> n;
    vector<vector<int>> G(n);
    for (int i = 0; i < n-1; ++i) {
        int a;
        scanf("%d", &a);
        G[a-1].emplace_back(i+1);
    }
    vector<int> v(n);
    for (auto &&i : v) scanf("%d", &i);

    deque<int> Q;
    {
        vector<int> num(n);
        {
            stack<int> s;
            int cnt = 0;
            vector<int> visited(n, 0);
            s.emplace(0);
            while(!s.empty()){
                int a = s.top(); s.pop();
                visited[a]++;
                num[a] = cnt++;
                Q.emplace_front(a);
                for (auto &&i : G[a]) {
                    if(!visited[i]) s.emplace(i);
                }
            }
        }
    }
    auto dp = make_v(n, 2, 2, INF<int>);
    while(!Q.empty()){
        int x = Q.front(); Q.pop_front();
        if(G[x].empty()) {
            dp[x][0][0] = dp[x][1][1] = 0;
            dp[x][0][1] = dp[x][1][0] = v[x];
            continue;
        }
        vector<array<int, 5001>> knap(G[x].size()+1);
        for (int c = 0; c < 2; ++c) {
            for (auto &&k : knap) {
                fill(k.begin(), k.end(), INF<int>);
            }
            knap[0][0] = 0;
            for (int i = 0; i < G[x].size(); ++i) {
                int y = G[x][i];
                for (int j = 0; j <= v[x]; ++j) {
                    if(knap[i][j] == INF<int>) continue;
                    for (int k = 0; k < 2; ++k) {
                        int id = dp[y][k][c], val = dp[y][k][c^1];
                        if(j+id <= v[x]){
                            chmin(knap[i+1][j+id], knap[i][j]+val);
                        }
                    }
                }
            }
            for (int j = 0; j <= v[x]; ++j) {
                if(knap[G[x].size()][j] != INF<int>){
                    chmin(dp[x][c][c^1], knap[G[x].size()][j]);
                    dp[x][c][c] = v[x];
                }
            }
        }
    }
    if(dp[0][0][0] != INF<int> || dp[0][1][1] != INF<int>){
        puts("POSSIBLE");
    }else {
        puts("IMPOSSIBLE");
    }
    return 0;
}


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

using namespace std;

typedef long long ll;

#define newline cout<<"\n"
#define deb(x) cout<<#x<<" "<<x<<endl;

template<typename... T>
void read(T&... args){
    ((cin>>args), ...);
}

template<typename... T>
void write(T... args){
    ((cout<<args<<" "), ...);
}

void printarr(vector<int> &v){
    for(int x: v){
        cout<<x<<" ";
    }
    newline;
}

const int MOD = 1e9+7;
const int nax = 1e7+7;

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    
    int n; cin>>n;

    int a[n];

    for(int i=0; i<n; i++){
        cin>>a[i];
    }

    int ans = __gcd(a[0], a[1]);

    for(int i=2; i<n; i++){
        ans = __gcd(ans, a[i]);
    }

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

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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  
  for (int i=0; i<N; i++){
    cin >> vec.at(i);
  }
  
  int c=0, sum=0;
  while (sum < N){
    if (c == 1){
      break;
    }
    else{
      c = vec.at(c)-1;
      sum++;
    }
  }
  
  if (sum < N){
    cout << sum << endl;
  }
  else{
    cout << -1 << endl;
  }
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int n;
    cin>>n;
    string s;
    vector<long long int> v(5,0);
    for(int i=0;i<n;i++){
        cin>>s;
        switch(s[0]){
            case 'M':
                v[0]++; break;
            case 'A':
                v[1]++; break;
            case 'R':
                v[2]++; break;
            case 'C':
                v[3]++; break;
            case 'H':
                v[4]++; break;
            default: break;
        }
    }
    long long int ans=0;
    for(int i=0;i<3;i++){
        for(int j=i+1;j<4;j++){
            for(int k=j+1;k<5;k++){
                ans+=v[i]*v[j]*v[k];
            }
        }
    }
    cout<<ans;
}


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

int main() {
  int n,m;
  cin >> n >> m;
  vector<P>data(m);
  rep(i,m){
    int a,b;
    cin >> a >> b;
    data[i].first = b;
    data[i].second = a;
  }
  sort(data.begin(),data.end());
  int ans = 1;
  int top = data[0].first;
  rep(i,m){
    if(data[i].second >= top){
      ans++;
      top = data[i].first;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <cstdio>
#include <queue>
#include <set>
using namespace std;

long long int ipow(long long int x, int n);

int main(){
  
  /* read input */
  int N;
  scanf("%d", &N); // read int
  
  /* check digits of N */
  int digits=0;
  int N_tmp=N;
  while(N_tmp != 0){
    N_tmp /= 10;
    digits++;
  }
  
  long long int ans=0;
  /*count 753 number with smaller digit than N*/
  for(int i = 3; i < digits; i++){
    ans += (ipow(3,i)-3*ipow(2,i)+3);
  }
  
  /*count 753 number with same digit as N*/
  for(long long int i = 0; i < ipow(3,digits); i++){
    //printf("%lld\n", i); // check
    long long int i_tmp = i;
    // make candidate of 753 number
    long long int cand_753 = 0;
    int check[3];
    for(int j = 0; j < 3; j++)check[j]=0;

    for(int j = 0; j < digits; j++){
      // update check
      check[i_tmp%3]=1;
      // update cand_753
      if(i_tmp %3 == 0){
        cand_753 += 3*ipow(10, j);
      }
      else if(i_tmp %3 == 1){
        cand_753 += 5*ipow(10, j);
      }
      else if(i_tmp %3 == 2){
        cand_753 += 7*ipow(10, j);
      }
      i_tmp /= 3;
    }
    // check 753 number
    //printf("%lld\n",cand_753);
    if(cand_753 <= N){
      if(check[0]==1 && check[1]==1 && check[2]==1){
        ans++;
      }
    }
    else // once (cand_753 > N) is true there is no more answer to check
      break;
  }
  
  printf("%lld", ans);
  
  
  return 0;
}

long long int ipow(long long int x, int n){
  long long int ans = 1;
  for(int i = 0; i < n; i++){
    ans *= x;
  }
  return ans;
}

Measured memory_bytes: 128
symbol = input().rstrip().split()
stack = []
operator = ['+', '-', '*']

for s in symbol:
    if s not in operator:
        stack.append(int(s))
    else:
        b = stack.pop(-1)
        a = stack.pop(-1)
        if s == '+':
            stack.append(a + b)
        elif s == '*':
            stack.append(a * b)
        else:
            stack.append(a - b)

print(stack[0])


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

// repetition
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

// container util
#define all(x) (x).begin(), (x).end()

// typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

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

// conversion
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
inline ll toLL(string s) {
  ll v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T> inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) {
  return a < b && (a = b, true);
}

template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) {
  return a > b && (a = b, true);
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;
  cin >> n;
  ll ans = 0;
  rep(i, n + 1) {
    if(i % 3 == 0 || i % 5 == 0)
      continue;
    else
      ans += i;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3612
#include<stdio.h>
#include<algorithm>
using namespace std;
int dp[31][51][6];
int s[15][30];
int t[15][30];
int main(){
	int a,b,c,d;
	while(scanf("%d%d%d%d",&a,&b,&c,&d),a+b+c+d){
		for(int i=0;i<a;i++)
			for(int j=0;j<b;j++)
				scanf("%d",&s[i][j]);
		for(int i=0;i<a;i++)
			for(int j=0;j<b;j++)
				scanf("%d",&t[i][j]);
		for(int i=0;i<31;i++)
				for(int k=0;k<51;k++)
					for(int l=0;l<6;l++)
						dp[i][k][l]=-99999999;
		dp[0][0][0]=0;
		for(int i=0;i<b;i++){
			for(int j=0;j<=c;j++){
				for(int k=0;k<=d;k++){
					dp[i+1][j][k]=max(dp[i+1][j][k],dp[i][j][k]);
					for(int l=0;l<a;l++){
						if(s[l][i]==0)continue;
						int cost=0;
						int W=0;
						for(int m=l;m<a;m++){
							if(s[m][i]==0)break;
							if(k==d&&l!=m)break;
							cost+=t[m][i];
							W+=s[m][i];
							if(l==m&&j+cost<=c){
								dp[i+1][j+cost][k]=max(dp[i+1][j+cost][k],dp[i][j][k]+W);
							}
							if(l!=m&&j+cost<=c&&k<d){
								dp[i+1][j+cost][k+1]=max(dp[i+1][j+cost][k+1],dp[i][j][k]+W);
							}
						}
					}
				}
			}
		}
		int ret=0;
		for(int i=0;i<51;i++)
			for(int j=0;j<6;j++)
				ret=max(ret,dp[b][i][j]);
		printf("%d\n",ret);
	}
}

Measured memory_bytes: 804
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int gcd(int a, int b){
  if(b==0) return a;
  return gcd(b,a%b);
}

int main(){
  int n; cin>>n;
  int maxnum;
  vector<int> num(n),toright(n-1),toleft(n-1);
  for(int i=0;i<n;i++){
    cin>>num[i];
  }for(int i=0;i<n-1;i++){
    if(i==0){
      toright[i]=num[i];
      toleft[n-i-2]=num[n-i-1];
    }
    toright[i]=gcd(toright[i-1],num[i]);
    toleft[n-i-2]=gcd(toleft[n-i-1],num[n-i-1]);
  }for(int i=0;i<n;i++){
    if(i==0){
      maxnum=toleft[i];
    }else if(i==n-1){
      maxnum=max(maxnum,toright[n-2]);
    }else{
      maxnum=max(maxnum,gcd(toright[i-1],toleft[i]));
    }
  }cout<<maxnum<<endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N;
    cin >>N;
    vector<pair<int,int>>a;
    for(int i=0;i<N;i++){
        int x,y;
        cin>>x>>y;
        a.push_back(make_pair(x,y));
    }
    vector<int>vec(N);
    for(int i=0;i<N;i++){
        vec.at(i)=i;
    }
     double sum=0;
    do{
        for(int i=0;i<N-1;i++){
        double c=(a.at(vec.at(i)).first-a.at(vec.at(i+1)).first)*(a.at(vec.at(i)).first-a.at(vec.at(i+1)).first);
        double b=(a.at(vec.at(i)).second-a.at(vec.at(i+1)).second)*(a.at(vec.at(i)).second-a.at(vec.at(i+1)).second);
        sum+=sqrt(c+b);
        }
    }while(next_permutation(vec.begin(),vec.end()));
    double waru=1;
    for(int i=1;i<=N;i++){
        waru*=i;
    }
    cout<< fixed << setprecision(10)<<sum/waru<<endl;


}

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

int main() {
    int k;
    string s;
    cin >> k >> s;
    if(s.size() <= k) {
        cout << s << endl;
    } else {
        rep(i, k) cout << s[i];
        cout << "..." << endl;
    }

    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long

int32_t main() {
	fastio;

    int n; cin >> n;
    int ans = (n/500)*1000 + ((n%500)/5)*5;
    cout << ans << endl;
	return 0;
}


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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

const ll MOD = 1e9 + 7;

ll powmod(ll num, ll cnt)
{
    ll res = 1;
    rep(i, cnt)
    {
        res = res * num % MOD;
    }
    return res;
}

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

    ll ans = powmod(10, n) - powmod(9, n) - powmod(9, n) + powmod(8, n);
    ans %= MOD;
    ans = (ans + MOD) % MOD;
    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
int n,t;
int c[110],p[110];
int main()
{
	cin>>n>>t;
	int mn=1e9;
	for(int i=0;i<n;i++)
	{
		cin>>c[i]>>p[i];
		if(p[i]<=t)
			mn=min(mn,c[i]);
	}
	if(mn==1e9)
	{
		puts("TLE");
	}
	else
	{
		cout<<mn<<endl;
	}
	return 0;
}

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

using namespace std;

long long mod = 1000000007;

long long modpow(long long a, long long n) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long waru(long long a, long long b){
	return ((a % mod) * (modpow(b, mod-2) % mod)) % mod;
}

vector<int> factorization(int M){
	int sqrt_M = (int)sqrt(M);
	vector<int> fact;

	for (int m=2; m<=sqrt_M; m++){
		int num = 0;
		while (M % m == 0){
			num += 1;
			M = M / m;
		}
		if (num != 0){
			fact.push_back(num);
		}
		if (M == 1){
			break;
		}
	}
	if (M != 1){
		fact.push_back(1);
	}
	return fact;
}

long long combination(int a, int b){
	long long bunbo = 1;
	long long bunshi = 1;
	for (int i=1; i <= b; i++){
		bunbo = ((bunbo % mod) * i) % mod;
	}
	for (int j=a; j>a-b; j--){
		bunshi = ((bunshi % mod) * j) % mod;
	}
	return waru(bunshi, bunbo);
}

int main(){
	int N;
	int M;
	cin >> N >> M;
	long long ans = 1;

	vector<int> fact;
	fact = factorization(M);

	for (int f : fact){
		// cout << f << endl;
		// cout << combination(f+N-1, f) << endl;
		ans = ((ans % mod) * (combination(f+N-1, f) % mod)) % mod;
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n = ni()
a = na()
q = ni()
l = [na() for _ in range(q)]

import collections

c = collections.Counter(a)
ans = sum(a)
for i in l:
  if c[i[0]] >0:
    ans = ans - c[i[0]]*i[0] + i[1]*(c[i[0]])
    c[i[1]] = c[i[1]] + c[i[0]]
    c[i[0]] = 0
    print(ans)
  else:
    print(ans)
    

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

int main() {
	string youbi[7] = {"Wednesday","Thursday","Friday","Saturday","Sunday","Monday","Tuesday"};
	int month[12] = {31,29,31,30,31,30,31,31,30,31,30,31};
	
	int gathu,nichi;
	while ( cin >> gathu >> nichi,gathu ) {
		int keika = 0;
		for ( int i = 0; i < gathu-1; i++ ) {
			keika += month[i];
		}
		keika += nichi;
		
		cout <<  youbi[keika % 7] << endl;
	}
	return 0;
}

Measured memory_bytes: 1192
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

int main(void){
	int N,i=0,len;
	int ans[32]={0};
	scanf("%d",&N);
	if(N==0){printf("0");return 0;}
	while(N!=0){
		ans[i] = abs(N)%2;
		N -= ans[i]*pow(-1,i);
		N /= 2;
		i++;
	}
	len = i-1;	
	for(i=len;i>=0;i--) printf("%d",ans[i]);
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
using ll = long long;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
const ll INF = 1LL << 60;

int main() {
  //
  ll a, b;
  cin >> a >> b;
  cout << max(a + a - 1, max(a + b, b + b - 1)) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int a,b;
	int atai;
	char op;
	while(1){
		scanf("%d %c %d",&a,&op,&b);
		if(op=='+')atai=a+b;
		else if(op=='-')atai=a-b;
		else if(op=='*')atai=a*b;
		else if(op=='/')atai=a/b;
		else if(op=='?')break;
		printf("%d\n",atai);
	}
	return 0;
}

Measured memory_bytes: 2688
import math

a,b,x = [int(i) for i in input().split(" ")]

S = a**2*b

# 満タンの場合
if S==x:
    theta = math.pi/2

# 半分以下の場合（水平に近い状態でこぼれる）
elif S/2 < x:
    theta = math.atan(a**3/(2*(S-x)))

# 半分以上の場合（垂直に近い状態でこぼれる）
else:
    theta = math.atan(2*x/(a*b**2))    
    
print(90-math.degrees(theta))


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define mod 998244353LL
#define maxn 100005
#define IN freopen("C.in","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG pf("Hi\n")
#define INF 1000000000
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define ln 17
#define off 2

using namespace __gnu_pbds;
using namespace std ;

typedef tree< i64, null_type, less<i64>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef pair<i64, i64> pii;


class numberTheory{

public:
    numberTheory(){}

    pii extendedEuclid(i64 a, i64 b) { // returns x, y | ax + by = gcd(a,b)

        if(b == 0) return pii( a >= 0 ? 1 : -1 , 0LL);
        else {
            pii d = extendedEuclid(b, a % b);
            return pii(d.yy, d.xx - d.yy * (a / b));
        }

    }

    i64 modularInverse(i64 a, i64 n) {
        pair<i64,i64> ret = extendedEuclid(a, n);
        return ((ret.xx % n) + n) % n;
    }


    i64 bigMod(i64 a, i64 n , i64 m)
    {
        if(n==0) return 1 ;
        i64 ret = bigMod(a,n/2,m) ;
        ret = (ret*ret)%m ;
        if(n%2) ret = (ret*a)%m ;
        return ret ;
    }
};

const i64 N = 5000000 ;

i64 fact[N+5] , invFact[N+5] ;

i64 C(i64 n, i64 r)
{
    if( n<0 || r<0 || r>n ) return 0 ;
    i64 ret = (fact[n]*invFact[r])%mod ;
    return (ret*invFact[n-r])%mod ;
}

void preprocess()
{
    numberTheory nt ;

    fact[0] = 1 ;
    for(i64 x=1 ; x<=N ; x++) fact[x] = (fact[x-1]*x)%mod ;

    invFact[N] = nt.modularInverse(fact[N],mod) ;

    for(i64 x=N-1 ; x>=0 ; x--) invFact[x] = (invFact[x+1]*(x+1) )%mod ;
}

int main()
{
    preprocess() ;

    i64 n , m ;
    scanf("%lld %lld",&n,&m) ;

    i64 ans = 0 ;

    for(int odd=0 ; odd<=min(m,n) ; odd++)
    {
        if( (3*m)%2 != odd%2 ) continue ;

        i64 sum = 3*m-odd , ret = 0 ;

        ret += C( sum/2+n-1 , n-1 ) ;

        ret -= (C( (sum-2*m)/2+n-1 , n-1 )*odd)%mod ;

        ret -= (C( ( sum-2*m-2 )/2 +n-1 , n-1 )*(n-odd))%mod ;

        ret %= mod ;

        ret = (ret*C(n,odd))%mod ;

        ans = ( ans + ret )%mod ;

     //   printf("%d: %lld\n",odd,ans) ;
    }

    ans = (ans%mod + mod)%mod ;

    printf("%lld\n",ans) ;

    return 0 ;
}


Measured memory_bytes: 78336
#include<stdio.h>
int main()
{
	int D,N;
	 scanf("%d",&D);
	 scanf("%d",&N);

	 if(N<100){
  if(D==0){
	  printf("%d",1*N);
	 }
if(D==1){
	  printf("%d",100*N);
}
if(D==2){
	  printf("%d",10000*N);
}
	 }
	 if(N==100){

			 if(D==0){
			 	  printf("%d",101);
			 	 }
			 if(D==1){
			 	  printf("%d",10100);
			 }
			 if(D==2){
			 	  printf("%d",1010000);

		 }

	 }
  return 0;
}

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

int main() {
  int N,P;
  cin>>N>>P;
  int64_t Z=0,E=1,O=0;
  for(int i=0;i<N;i++){
    int a;
    cin>>a;
    if(a%2==0){
      E*=2;
    }
    else{
      O++;
    }
  }
  int64_t Q=E;
  for(int64_t i=1;i<=O+1;i++){
    P=(P^1);
    if(P){
      Z+=Q;
    }
    Q*=O+1-i;
    Q/=i;
  }
  cout<<Z<<endl;
  
}

Measured memory_bytes: 3620
#include <iostream>

using namespace std;

int main()
{
	int a, b;
	cin >> a >> b;
	bool zero = false;
	bool puls = true;

	if (a < 0)
	{
		for (int i = a; i <= b; i++)
		{
			if (i == 0)
			{
				zero = true;
			}
			if (i < 0)
			{
				puls = !puls;
			}
		}
	}
	if (zero)
	{
		cout << "Zero" << endl;
	}
	else
	{
		if (puls)
		{
			cout << "Positive" << endl;
		}
		else
		{
			cout << "Negative" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <stdio.h>
#define rep(i,o,u) for(int i = o;i <= u; i++)
typedef unsigned long long ll;
using namespace std;
int isPrime(int a){
	if(a == 2) return 1;
	if(a % 2 == 0) return 0;
	for(int i = 2;i <= sqrt(a); i++){
		if(a % i == 0){
			return 0;
		}
	}
	return 1;
}
int main(){
	int n,a,ans = 0;
	cin >> n;
	while(n--){
		cin >> a;
		if(isPrime(a)) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  int r;
  cin >> r;
  cout << 3*r*r << endl;
}


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

int main(){
    long long int i=0,j=1,ans=0,b=0,bko=0,sum=0;
    string s;
    cin >> s;
    for(i=0;i<s.size();i++){
        if(s[i]=='B'){b += i;bko++;}        
    }
    for(i=0;i<bko;i++){
        sum += s.size()-1-i;
    }
    cout << sum - b << endl;
    return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <string>
#include <iostream>
using namespace std;
int a,b;
string ab="",ba="";
int main(){
	scanf("%d%d",&a,&b);
	for (int i=0;i<a;i++){
		ab+=(char)(b+'0');
	}
	for (int i=0;i<b;i++){
		ba+=(char)(a+'0');
	}
	if (ab<ba){
		cout<<ab;
	}
	else{
		cout<<ba;
	}
	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Collections;

public class Main {

	public static void main(String[] args) throws IOException {
			BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
			String W = in.readLine();

			int N = Integer.parseInt(W.split(" ")[0]);
			int M = Integer.parseInt(W.split(" ")[1]);

			Integer[] A = new Integer[N];

			String Y = in.readLine();
			for(int i = 0; i < N; i++) {
				A[i] = Integer.parseInt(Y.split(" ")[i]);
			}

			long sum = 0;
			for(long i:A) {
			sum+=i;
			}


			 Arrays.sort(A, Collections.reverseOrder());

			if(A[M -1] >= (double)sum/(4*M)) {
				System.out.println("Yes");
			}else {
				System.out.println("No");
			}

	}

}


Measured memory_bytes: 22100