akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <type_traits>
using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)
#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using ll = long long;
using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;
using str = string;

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

long int M = 1e+9+7;
int inf = 1e+9;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::setprecision(10);

    int ans=0;
    int k=0;
    cin >> k;
    string s="";
    cin >> s;
    
    if(s.size() <= k){
        cout << s << endl;
    }else{
        s.erase(k);
        s+= "...";
        cout << s << endl;
    }
    return 0;
}

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

int n;
int a[100][100];

int main(){
	scanf("%d", &n);
	rep(i,n) rep(j,n) scanf("%d", &a[i][j]);
	for(int i = 1; i < n; i++) a[0][i] += a[0][i-1];
	for(int i = 1; i < n; i++) a[i][0] += a[i-1][0];
	for(int i = 1; i < n; i++){
		for(int j = 1; j < n; j++){
			a[i][j] += a[i-1][j]+a[i][j-1]-a[i-1][j-1];
		}
	}
	int ans = -2000000000;
	rep(i,n) rep(j,n){
		for(int u = i; u < n; u++){
			for(int v = j; v < n; v++){
				if(i == 0 && j == 0) ans = max(ans,a[u][v]);
				else if(i == 0) ans = max(ans,a[u][v]-a[u][j-1]);
				else if(j == 0) ans = max(ans,a[u][v]-a[i-1][v]);
				else ans = max(ans,a[u][v]-a[i-1][v]-a[u][j-1]+a[i-1][j-1]);
			}
		}
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 1064
# include <iostream>
# include <cmath>
# include <algorithm>
# include <stdio.h>
# include <cstdint>
# include <cstring>
# include <string>
# include <cstdlib>
# include <vector>
# include <bitset>
# include <map>
# include <queue>
# include <ctime>
# include <stack>
# include <set>
# include <list>
# include <random>
# include <chrono>
# include <deque>
# include <functional>
# include <iomanip>
# include <sstream>
# include <fstream>
# include <complex>
# include <numeric>
# include <cassert>
# include <array>
# include <tuple>
# include <cctype>
# include <unistd.h>
# include <unordered_map>
# include <unordered_set>
using namespace std;

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define fast_work {ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);}

const ll INF = 1e9 + 5, NMAX = 2e5 + 5, MOD = 1000000007, N = 1e9 + 5, LOG = 25;
const ld EPS = 1e-8, pi = 3.14159265358979323846;

ll a[NMAX];

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

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

    ll answer = 0;

    sum %= MOD;

    for(int i = 0; i < n; ++i) {
        sum = (sum - a[i] + MOD) % MOD;
        ll add = (a[i] * sum) % MOD;
        answer = (answer + add) % MOD;
    }

    cout << answer;
}


Measured memory_bytes: 5204
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long
#define TBMod 1000000007

int main(int argc, char const *argv[])
{
	int n,ans = 0;
	int temp,divby = 1000000000;
	scanf("%d",&n);
	temp = n;
	for (int i = 0; i < 10; ++i)
	{
		if(temp < 10){
			ans += temp % 10;
			break;
		}
		else{
			ans += temp / divby;
			temp -= temp / divby * divby;
			divby /= 10;
		}
	}
	if(n % ans == 0)	puts("Yes");
	else puts("No");
	return 0;
}


Measured memory_bytes: 128
#include <cstdlib>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

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

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

const ll INF = 1e17;
const ll MOD = 1e9+7;

int main() {
    // input, ready
    int N;
    string S;
    cin >> N;
    cin >> S;

    // resolve
    string ans = S;
    int cnt=0;

    for(auto c:S)
    {
        ans[cnt]=c+N;
        if (ans[cnt] > 'Z')
        {
            ans[cnt] = 'A' + ans[cnt] - 'Z' -1;
        }
        cnt++;
    }

    cout << ans << 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;

ll n,a,b,h[100000];

bool f(ll x){
    ll cnt=0;
    rep(i,n){
        ll H=max(0ll,h[i]-b*x);
        cnt+=(H+a-1)/a;
    }
    return cnt<=x;
}

int main(){
    cin>>n>>a>>b;
    a-=b;
    rep(i,n)cin>>h[i];
    int l=0,r=1e9;
    while(r-l>1){
        int mid=(l+r)/2;
        if(f(mid))r=mid;
        else l=mid;
    }
    cout<<r<<endl;
}

Measured memory_bytes: 1024
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		String[] array = line.split(" ");
		int a = Integer.parseInt(array[0]);
		int b = Integer.parseInt(array[1]);

		int d = a / b;
		int r = a % b;

		BigDecimal A = BigDecimal.valueOf(a);
		BigDecimal B = BigDecimal.valueOf(b);
		BigDecimal f = A.divide(B, 8, BigDecimal.ROUND_HALF_UP);

		System.out.println(d + " " + r + " " + f.toPlainString());
	}

}

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

int main(){

	string str1, str2;

	str1 = "Possible";
	str2 = "Impossible";

	int a, b;

	cin >> a >> b;

	int c, d, e;

	c = a % 3;
	d = b % 3;
	e = (a + b) % 3;

	if(c==0||d==0||e==0){
		cout << str1 << endl;
	}else{
		cout << str2 << endl;
	}
}

Measured memory_bytes: 256
#!/usr/bin/env python

def main():
    N = int(input())
    K = int(input())
    x_list = list(map(int, input().split(" ")))

    sum = 0
    for x in x_list:
        A = x * 2
        B = (K - x) * 2
        sum += A if A <= B else B
    print(sum)

if __name__ == '__main__':
    main()


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

int main() {
	int n;
	cin >> n;
	ll x = 0;
	for (int i = 0; i < n; i++) {
		int y;
		cin >> y;
		x += y - 1;
	}
	cout << x << endl;
}

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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;

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

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

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

int main() {
   string s;
   cin >> s;
   int len = s.size();
   bool a9 = true;
   repp (i, 1, len) {
      if (s[i] != '9') {
         a9 = false;
      }
   }

   cout << (s[0]-'1') + (len-1)*9 + a9 << endl;

   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll S,x1 = 0,x2 = 0,x3 = 0,y1 = 0,y2 = 0,y3 = 0;
  cin >> S;
  ll l = sqrt(S);
  if(l*l == S){
    y2 = l;
    x3 = l;
  }
  else if(S < l*(l+1)){
    ll t = S-l*l;
    x1 = 1;
    x2 = l+1;
    y2 = t;
    y3 = l;
  }
  else if(S == l*(l+1)){
    y2 = l;
    x3 = l+1;
  }
  else if(S < l*(l+2)){
    ll t = S-l*(l+1);
    x1 = 1;
    x2 = l+1;
    y2 = t;
    y3 = l+1;
  }
  else{
    y2 = l;
    x3 = l+2;
  }
  cout << x1 << ' ' << y1 << ' ' << x2 << ' ' << y2 << ' ' << x3 << ' ' << y3;
  return 0;
}

Measured memory_bytes: 256
/*** keep hungry and calm CoolGuang!***/
#include <bits/stdc++.h>
#include<stdio.h>
#include<vector>
#include<algorithm>
#pragma GCC optimize(2)
using namespace std;
typedef long long ll;
const ll INF=1000000000000007;
const ll maxn=1e6+5;
const int mod=1e9+7;
ll n,m,p;
char str[maxn];
int main()
{
    scanf("%s",str+1);
    int res=0,ans=0;
    int len=strlen(str+1);
    str[0]='0';
    for(int i=len;i>=1;i--){
        if(str[i]>'5'){
            res+=(10-(str[i]-'0'));//进位之后对方需要还款的贡献
            str[i]='0';//借位之后，这位就不需要继续付款了
            str[i-1]++;//因为借位，所以相当于使用了 str[i-1]+1个(i-1)
        }
        else if(str[i]=='5'&&str[i-1]>='5'){
            res+=(10-(str[i]-'0'));//进位之后对方需要还款的贡献
            str[i]='0';//借位之后，这位就不需要继续付款了
            str[i-1]++;//因为借位，所以相当于使用了 str[i-1]+1个(i-1)
        }
    }
    for(int i=0;i<=len;i++)
        ans+=str[i]-'0';
    printf("%d\n",ans+res);
    return 0;
}


Measured memory_bytes: 1280
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<vector>
#include<string>
#include <ios>     
#include <iomanip> 
using namespace std;
typedef long long llong;
typedef unsigned long long ullong;



llong gcd(llong a, llong b) {
	if (a < b) swap(a, b);
	if (a % b == 0) return b;
	else return gcd(b, a % b);
}

llong lcm(llong a, llong b) {
	llong g = gcd(a, b);
	return a * b / g;
}

//ここまで共通

string S;
llong K;

int main() {
	cin >> S >> K;
	for (int i = 0; i < K; i++) {
		if (S[i] == '1' && i == K - 1) {
			cout << 1;
			break;
		}

		else if (S[i] != '1') {
			cout << S[i];
			break;
		}
	}
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  string s;
  cin>>s;
  cout<<s[0]<<s.size()-2<<s[s.size()-1]<<endl;
  return 0;
}


Measured memory_bytes: 256
//R<3S
#include <bits/stdc++.h>
#define DECIMAL(n)  std::cout << std::fixed;std::cout << std::setprecision(n);
#define FAST std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define hell 1000000007
#define PI 3.14159265358979323844
#define mp make_pair
#define pb push_back
#define fi first 
#define se second
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))  
#define REVERSE(v) reverse(ALL(v))
#define endl "\n"
#define vecmax(v) max_element(all(v))
#define vecmin(v) min_element(all(v))
#define GCD(m,n) __gcd(m,n)
#define LCM(m,n) m*(n/GCD(m,n))
#define inputarr(a,n) for(int i=0;i<n;++i) cin>>a[i]
#define initarr(a,n,x) for (int i=0;i<n;++i) a[i]=x
#define int long long
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(x) for(auto i : x)
#define sz(a) (int)a.size()
#define sl(a) (int)a.length()
#define invect(data,n) for(int i = 0;i<n;i++){int tmp;cin>>tmp;data.pb(tmp);}
#define inset(data,n) for(int i = 0;i<n;i++){int tmp;cin>>tmp;data.insert(tmp);}
#define ll long long

#define ld long double 
#define pii std::pair<int, int> 
#define pll std::pair<ll, ll>  
#define vi vector<int>  
#define vl vector<ll>
#define vvi vector<vi > 
#define vii vector<pii >
#define mii map<int,int>
#define mll map<ll,ll>
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl


using namespace std;

void solve()
  {
	int n;
	cin>>n;
	int a[n+1];
	rep(i,n)cin>>a[i+1];int cnt=0;
	mii m1,m2;
	repA(i,1,n)
	{
		m1[i+a[i]]++;
		if(i-a[i]>0)m2[i-a[i]]++;
		
	}
	int sum=0;
	repA(i,1,n)
	{
		sum+=m2[i+a[i]];
	}
	cout<<sum<<endl;
	// trav(m)if(i.se-1)cout<<i.fi<<" "<<i.se<<endl;
	
	

  }



signed main()
{
   FAST
   int t;
   t=1;
   //cin>>t;
   while(t--)
    {
        solve();
    }


   return 0;
}


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

#define REP(i, a, b) for(int i = (a); i <= (b); i++)
#define PER(i, a, b) for(int i = (a); i >= (b); i--)
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define debug(x) cerr << #x << " = " << x << endl;
#define SET(c, v) memset(c, v, sizeof c)
#define pi 3.14159265358979323846264338
#define all(S) (S).begin(), (S).end()
#define INF 0x3f3f3f3f
#define mod 1000000007
#define pf push_front
#define pb push_back
#define mk make_pair
#define MAX 1010
#define S second
#define F first
typedef long long ll;
typedef long double lf;
typedef pair<int, int> ii;
typedef unsigned long long int ull;
char v[MAX][MAX];
ll pd[MAX][MAX];
int N, M;

bool ver(int i, int j) {
	return (i >= 0 && i < N && j >= 0 && j < M && v[i][j] == '.');
}

ll solve(int i, int j) {
	ll &ans = pd[i][j];
	if(ans != -1) return ans;
	if(i == N-1 && j == M-1) return 1;
	ans = 0;
	if(ver(i+1, j)) ans = (ans + solve(i+1, j)) % mod;
	if(ver(i, j+1)) ans = (ans + solve(i, j+1)) % mod;
	return ans;
}

int main(int argc, char** argv) {
	scanf("%d%d", &N, &M);
	rep(i, 0, N) scanf("%s", v[i]);
	memset(pd, -1, sizeof pd);
	printf("%lld\n", solve(0, 0));
	return 0;
}



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

using namespace std;

int main(){

   int K, T;
   cin>> K>> T;
   int a[T];
   for(int i=0; i<T; i++) cin>> a[i];

   cout<< max(0, (*max_element(a, a+T)-1)-(accumulate(a, a+T, 0)-(*max_element(a, a+T))))<< endl;

   return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int num = scanner.nextInt();
		int t = 0;
		int room[][][] = new int[4][3][10];
		int f = 0;
		int n = 0;
		int h = 0;
		for (int i = 0; i < 4; i++) {
			for (int c = 0; c < 3; c++) {
				for (int q = 0; q < 10; q++) {
					room[i][c][q] = 0;
				}
			}
		}
		for (int w = 0; w < num; w++) {
			t = scanner.nextInt();
			f = scanner.nextInt();
			n = scanner.nextInt();
			h = scanner.nextInt();
			room[t - 1][f - 1][n - 1] = room[t - 1][f - 1][n - 1]+h;
		}
		for (int i = 0; i < 4; i++) {
			for (int c = 0; c < 3; c++) {
				for (int q = 0; q < 10; q++) {
					System.out.print(" " + room[i][c][q]);
				}
				System.out.println();
			}
			if (i < 3) {
				System.out.println("####################");

			}
		}

	}
}



Measured memory_bytes: 29344
#include<bits/stdc++.h>
#define reg register
#define inf 9982443530000000
#define maxn 5001
#define int long long
using namespace std;
inline int  read() {
    reg int s = 0, t = 0; reg char ch = getchar();
    while(ch > '9' || ch < '0') t |= ch == '-', ch = getchar();
    while(ch >= '0' && ch <= '9') s = (s << 1) + (s << 3) + (ch ^ 48), ch = getchar();
    return t ? -s : s;
}
int n, A, B, a[maxn], b[maxn], pos[maxn], ans = inf, dp[maxn][maxn];
signed main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	n = read(); A = read(); B = read();
	for(int i = 1; i <= n; i++) a[i] = read(), pos[a[i]] = i;
	memset(dp, 0x3f3f3f, sizeof dp);
	dp[0][0] = 0;
	for(int i = 1; i <= n; i++){
		for(int j = 0; j < i; j++)
		{
			if(pos[i] > pos[j]) {
				dp[i][i] = min(dp[i - 1][j], dp[i][i]);
				dp[i][j] = dp[i - 1][j] + B;
			}
			else dp[i][j] = dp[i - 1][j] + A;
		}
	}
	for(int i = 1; i <= n; i++) ans = min(ans, dp[n][i]);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 195712
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define sz(v) (int)v.size() 
#define all(v) v.begin(), v.end()
void dbg_out() { cerr << "\b\b]\n"; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T){ cerr << H << ", "; dbg_out(T...);}
#define watch(...) cerr << "[" << #__VA_ARGS__ << "]: [", dbg_out(__VA_ARGS__)


/****************************** CODE IS HERE ***********************************/


int main(){
    ios_base::sync_with_stdio(false); cin.tie(nullptr);

    string s; cin >> s;
    if (s.back() == 's') s += "es";
    else s += 's';
    cout << s;

    return 0;
}



Measured memory_bytes: 3664
from heapq import heappush, heappop

class UnionFind:
    def __init__(self, size):
        self.data = [-1] * size
    def find(self, x):
        if self.data[x] < 0:
            return x
        else:
            self.data[x] = self.find(self.data[x])
            return self.data[x]
    def union(self, x, y):
        x, y = self.find(x), self.find(y)
        if x != y:
            if self.data[y] < self.data[x]:
                x, y = y, x
            self.data[x] += self.data[y]
            self.data[y] = x
        return (x != y)
    def same(self, x, y):
        return (self.find(x) == self.find(y))
    def size(self, x):
        return -self.data[self.find(x)]

N, *XY = map(int, open(0).read().split())
YtoI = {y : i for i, y in enumerate(XY[1::2])}

uf = UnionFind(N)
Q = []
for x, y in sorted(zip(*[iter(XY)] * 2)):
    heappush(Q, y)
    mi = Q[0]
    while Q and Q[0] <= y:
        uf.union(YtoI[y], YtoI[heappop(Q)])
    heappush(Q, mi)

for i in range(N):
    print(uf.size(i))

Measured memory_bytes: 59128
#include<stdio.h>
#include<string.h>

int main(void)
{
  double weight[100];
  char class[100][100];
  int i = 0 , j;

  while(1){
    if(scanf("%lf",&weight[i])==EOF){
      break;
    }

    if(weight[i] <= 48.00){
      strcpy(class[i], "light fly");
    }else if(weight[i] > 48.00 && weight[i]<=51.00){
      strcpy(class[i], "fly");
    }else if(weight[i] > 51.00 && weight[i]<=54.00){
      strcpy(class[i], "bantam");
    }else if(weight[i] > 54.00 && weight[i]<=57.00){
      strcpy(class[i], "feather");
    }else if(weight[i] > 57.00 && weight[i]<=60.00){
      strcpy(class[i], "light");
    }else if(weight[i] > 60.00 && weight[i]<=64.00){
      strcpy(class[i], "light welter");
    }else if(weight[i] > 64.00 && weight[i]<=69.00){
      strcpy(class[i], "welter");
    }else if(weight[i] > 69.00 && weight[i]<=75.00){
      strcpy(class[i], "light middle");
    }else if(weight[i] > 75.00 && weight[i]<=81.00){
      strcpy(class[i], "middle");
    }else if(weight[i] > 81.00 && weight[i]<=91.00){
      strcpy(class[i], "light heavy");
    }else if(weight[i] > 91.00){
      strcpy(class[i], "heavy");
    }
    i++;
  }

  for(j=0; j<i; j++){
    printf("%s\n", class[j]);
  }

  return 0;
}

Measured memory_bytes: 612
#include <stdio.h>
#include <string.h>
 int main(){
 char x[1000],y[1000];
 int n,i,j;
 scanf("%d",&n);
 for(i = 0;i < n;i++){
    scanf("%s %s",x, y);
   printf("%d\n",lcs(x,y));
 }
 return 0;     
}

int lcs(char x[], char y[]){
 int i,j;
 int m = strlen(x);
 int n = strlen(y);
 int c[m+1][n+1];
 for(i = 0;i <= m; i++)
  c[i][0] = 0;
 for(j = 0;j <= n; j++)
  c[0][j] = 0;
 
 for(i = 1;i <= m; i++){
  for(j = 1;j <= n; j++){
    if(x[i-1] == y[j-1])
     c[i][j] = c[i-1][j-1] + 1;
    else if(c[i-1][j] >= c[i][j-1])
     c[i][j] = c[i-1][j];
    else
     c[i][j] = c[i][j-1];
  }
 }
 return c[m][n];
}

Measured memory_bytes: 4520
import itertools

import math
n, l = map(int, input().split())
l_list = []
abs_list = [0]*n

for i in range(0, n):
    l_list.append(l + i)

min_tmp = 10**9
mini = 0
for i in range(0, n):
    if(abs(l_list[i]) <= min_tmp):
        min_tmp = abs(l_list[i])
        mini = l_list[i]
print(sum(l_list) - mini)

Measured memory_bytes: 38256
#import<bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long LL;
LL i,j,k,m,n,x,y,z,a[200040];
string s;
main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin>>x>>y>>z>>k;
	for(;y<=x;)k--,y*=2;
	for(;z<=y;)k--,z*=2;
	if(k<0)cout<<"No";
	else cout<<"Yes";
}

Measured memory_bytes: 3648
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000000LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

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

  if(d == 0 && n != 100) cout << n << ln;
  else if(d == 0 && n == 100) cout << 101 << ln;
  else if(d == 1 && n != 100) cout << n * 100 << ln;
  else if(d == 1 && n == 100) cout << 10100 << ln;
  else if(d == 2 && n != 100) cout << n * 10000 << ln;
  else cout << 1010000 << ln;
}


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

ll xorsum(ll n) {
  if (n%4==0) return n;
  else if (n%4==1) return 1;
  else if (n%4==2) return n^1;
  else return 0;
}

int main() {
  ll A,B;
  cin>>A>>B;
  ll a = xorsum(A-1);
  ll b = xorsum(B);
  ll ans=a^b;
  cout<<ans<<endl;
}

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

int main(void) {
	// input
	int n;
	std::cin >> n;
	std::string s;
	std::cin >> s;

	// sum of w
	std::vector<int> wl(n);
	wl[0] = 0;
	for(int i = 1; i < n; ++i) {
		if(s[i-1] == 'W') wl[i] = wl[i-1] + 1;
		else wl[i] = wl[i-1];
	}

	// sum of e
	std::vector<int> er(n);
	er[n-1] = 0;
	for(int i = n-2; i >= 0; --i) {
		if(s[i+1] == 'E') er[i] = er[i+1] + 1;
		else er[i] = er[i+1];
	}

	// calc minumum
	int n_turn_min = n;
	for(int i = 0; i < n; ++i) {
		int n_turn = wl[i] + er[i];
		n_turn_min = (n_turn < n_turn_min ? n_turn : n_turn_min);
	}

	std::cout << n_turn_min << std::endl;

	return 0;
}


Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1000000007;

int main()
{
    int n, m, tmp;
    cin >> n >> m;

    vector<ll> dp(n + 1), a(n + 1, 1);

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

    dp[0] = 1;
    for(int i = 0; i < n; ++i)
    {
        for(int j = i + 1; j <= min(n, i + 2); ++j)
        {
            if(a[j])
            {
                dp[j] += dp[i];
                dp[j] %= mod;
            }
        }
    }

    cout << dp[n] << "\n";

    return 0;
}

Measured memory_bytes: 4716
import java.util.*;

// TLEになったので文字列結合はStringBuilderで
public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String first = sc.next();
		int n = Integer.parseInt(sc.next());

		// 入力しながらクエリにこたえていこう
		StringBuilder result = new StringBuilder();
		result.append(first);
		int reverse = 1;
		for (int i = 0; i < n; i++) {

			if (Integer.parseInt(sc.next()) == 1) {
				reverse *= -1;
			} else {
				int kind = Integer.parseInt(sc.next());
				if ((kind == 1 && reverse == 1) || (kind == 2 && reverse == -1)) {
					result.insert(0, sc.next());
					// result = sc.next() + result;
				} else {
					result.append(sc.next());
					// result = result + sc.next();
				}
			}
		}

		// 最後に今が逆行状態なら結果反転
		if (reverse == -1) {
			result.reverse();
		}

		System.out.println(result);

	}

}


Measured memory_bytes: 62008
#include <iostream>
#include <algorithm>
#include <climits>
#define SIZE 100001
#define INF INT_MAX >> 1

using namespace std;

int dp[SIZE];

int main(void){
	int n; cin >> n;
	int h[SIZE] ={0};
	for(int i=0; i<n; i++){
		cin >> h[i];
	}

	fill(dp, dp+n, INF);
	dp[0] = 0;
	dp[1] = abs(h[1]-h[0]);
	for(int i=2; i<n; i++){
		dp[i] = min(dp[i-2]+abs(h[i]-h[i-2]), dp[i-1]+abs(h[i]-h[i-1]));
	}

	cout << dp[n-1] << endl;
}

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

using namespace std;

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

    int answer = 0;
    for(int break_point = 1; break_point < length - 1; break_point++)
    {
        const int NO_OF_ALPHABETS = 26;

        vector <int> X_has(NO_OF_ALPHABETS, false);
        for(int i = 0; i <= break_point; i++)
            X_has[S[i] - 'a'] = true;

        vector <int> Y_has(NO_OF_ALPHABETS, false);
        for(int i = break_point + 1; i < length; i++)
            Y_has[S[i] - 'a'] = true;

        int current_answer = 0;

        for(int alphabet = 0; alphabet < NO_OF_ALPHABETS; alphabet++)
            current_answer += (X_has[alphabet] && Y_has[alphabet]);

        answer = max(answer, current_answer);
    }

    cout << answer;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nyan "(=^･ω･^=)"
#define mkp make_pair
#define lP pair<ll, ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;

int N, A, B;

int main() {
	cin >> N >> A >> B;
	cout << min(A, B) << sp << max(0, A + B - N) << endl;
}

Measured memory_bytes: 764
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;




int main(){
    string s,t;
    cin>>s>>t;
    vector<ll> a(s.size()+1,0);
    vector<ll> b(t.size()+1,0);
    for(int i=0;i<s.size();i++){
        a[i+1]=a[i]+(s[i]=='A'?1:-1);
    }
    for(int i=0;i<t.size();i++){
        b[i+1]=b[i]+(t[i]=='A'?1:-1);
    }
    ll q;
    cin>>q;
    while(q--){
        ll l,r,L,R;
        cin>>l>>r>>L>>R;
        l--; L--;
        ll A=a[r]-a[l];
        ll B=b[R]-b[L];
        A%=3;
        B%=3;
        if(A<0){A+=3;}
        if(B<0){B+=3;}
        cout<<(A==B?"YES":"NO")<<endl;
    }
    
    
    return 0;
}


Measured memory_bytes: 2432
n=int(input())
d=[(0,0,0)]
for i in range(n):
    a,b,c=map(int,input().split())
    d.append((a,b,c))

dp=[[0,0,0] for _ in range(n+1)]

for i in range(1,n+1):
    a,b,c=d[i]
    dp_a,dp_b,dp_c=dp[i-1]
    dp[i]=[max(dp_b+a,dp_c+a),max(dp_c+b,dp_a+b),max(dp_a+c,dp_b+c)]

dp_a,dp_b,dp_c=dp[n]
print(max(dp_a,dp_b,dp_c))

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

int main(){
	string s;ll k;cin>>s>>k;
	int l=s.size();
	int n[10],ans;
	for(int i=1;i<10;i++) n[i]=i;
	bool chk=0;
	for(int i=0;i<l;i++){
		for(int j=1;j<10;j++){
			char x ='0'+n[j];
			if(s[i]==x){
				k-=pow(n[j],5*pow(10,15));
				//cout<<s[i]<<endl;
			}
			if(k<=0){
				ans=n[j];
				chk=1;
				break;
			}
		}
		if(chk) break;
	}

	cout<<ans<<endl;
}

Measured memory_bytes: 512
#define LOCAL

#undef _GLIBCXX_DEBUG

#include <bits/stdc++.h>
using namespace std;

#define IOS ios::sync_with_stdio(false);cin.tie(0)
#define all(x) x.begin(), x.end()
#define ff first
#define ss second
#define MOD 1000000007LL
#define LLINF 100000000000000005LL
#define INF (int)1e9+1

// Copied from Gennady-Korotkevich's template

template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
	return '"' + s + '"';
}

string to_string(const char* s) {
	return to_string((string)s);
}

string to_string(bool b) {
	return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
	bool first = true;
	string res = "{";
	for (int i = 0; i < static_cast<int>(v.size()); i++) {
		if (!first) {
			res += ", ";
		}
		first = false;
		res += to_string(v[i]);
	}
	res += "}\n";
	return res;
}

template <size_t N>
string to_string(bitset<N> v) {
	string res = "";
	for (size_t i = 0; i < N; i++) {
		res += static_cast<char>('0' + v[i]);
	}
	return res;
}

template <typename A>
string to_string(A v) {
	bool first = true;
	string res = "{";
	for (const auto& x : v) {
		if (!first) {
			res += ", ";
		}
		first = false;
		res += to_string(x);
	}
	res += "}\n";
	return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
	return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
	return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
	return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

template <typename A, typename B, typename C, typename D, typename E>
string to_string(tuple<A, B, C, D, E> p) {
	return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + "," + to_string(get<4>(p)) + ")";
}

void debug_out() {
	cerr << endl;
}

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
	cerr << " " << to_string(H);
	debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "\n[" << #__VA_ARGS__ << "]:\n", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

// End of Gennady-Korotkevich's template 

using llong = long long;
using PII = pair<int, int>;

int n;
vector<int> a, dp;

int dfs(int index) {
	int& ret = dp[index];
	if (ret != -1) return ret;
	if (index == n - 1) return ret = 0;
	int ans1 = INF, ans2 = INF;
	ans1 = abs(a[index] - a[index + 1]) + dfs(index + 1);
	if(index + 2 < n)
		ans2 = abs(a[index] - a[index + 2]) + dfs(index + 2);
	return ret = min(ans1, ans2);
}

int main() {
	cin >> n;
	a = vector<int>(n);
	dp = vector<int>(n, -1);
	for (int i = 0; i < n; i++) cin >> a[i];
	int ans = dfs(0);
	cout << ans << endl;
}

Measured memory_bytes: 8804
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
const int INF = 1e18;

using namespace std;


signed main() {
  char c;
  cin >> c;
  c += 1;

  cout << c << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1e9+7
#define ll long long
#define f(x) for(ull i=0;i<x;i++)
#define F first
#define S second
#define N 100005
#define M 1000000007
#define mp make_pair
#define ull unsigned long long
#define sc(n) scanf("%d",&n)
#define gcd __gcd
using namespace std;

int main() {
	ios::sync_with_stdio(false);
	ll n,m;
    cin>>n>>m;
    if(2*n==m){
        cout<<n<<endl;
        return 0;
    }
    if(2*n<m){
        m-=2*n;
        cout<<n+m/4<<endl;
    }
    else{
        cout<<m/2<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define X 100
int main()
{
  int N,i,A[X],flag=1,j,temp,count=0,minj;

  scanf("%d",&N);

  if(N>=1 && N<=100){
    for(i=0;i<N;i++){
      scanf("%d",&A[i]);
    }
    i=0;
    for(i=0;i<N;i++){
      minj=i;
      for(j=i;j<N;j++){ 
	if(A[j]<A[minj]){
	  minj=j;
	}
      }
      if(A[i]!=A[minj]){
	temp=A[i];
	A[i]=A[minj];
	A[minj]=temp;
	count++;
      }
    }
    for(i=0;i<N-1;i++){
      printf("%d ",A[i]);
    }
    printf("%d",A[N-1]);
    printf("\n%d\n",count);
  }
  return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  int a, b;
  cin >> a >> b;
  cout << ceil(1.0 * (a + b) / 2) << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static int n;
    public static int m;
    public static int q;
    public static int[] a;
    public static int[] b;
    public static int[] c;
    public static int[] d;
    public static int max = 0;
    public static int[] f;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        m = sc.nextInt();
        q = sc.nextInt();
        a = new int[q];
        b = new int[q];
        c = new int[q];
        d = new int[q];
        for (int i = 0; i < q; i++) {
            a[i] = sc.nextInt() - 1;
            b[i] = sc.nextInt() - 1;
            c[i] = sc.nextInt();
            d[i] = sc.nextInt();
        }
        f = new int[n];
        dfs(0, 1);
        System.out.println(max);
    }

    private static void dfs(int p, int last) {
        if (p == n) {
            int sum = 0;
            for (int i = 0; i < q; i++) {
                if (f[b[i]] - f[a[i]] == c[i]) {
                    sum += d[i];
                }
            }
            max = Math.max(max, sum);
            return;
        }
        for (int i = last; i <= m; i++) {
            f[p] = i;
            dfs(p + 1, i);
        }
    }
}

Measured memory_bytes: 37496
n = gets.chomp.to_i
a = [0] + gets.split.map(&:to_i) + [0]
sum_all = 0
0.upto(n) do |i|
  sum_all += (a[i+1] - a[i]).abs
end
1.upto(n) do |i|
  puts sum_all - (a[i+1] - a[i]).abs - (a[i] - a[i-1]).abs + (a[i+1] - a[i-1]).abs
end


Measured memory_bytes: 12548
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,n=0,cnt,h;
	cin>>a;
	for(int i=0;i<=a;i++)
	{
		cnt=0;
		h=i;
		while(h>0)
		{
			cnt++;
			h=h/10;
		}
		if(cnt%2!=0){ n++;}
	}
	cout<<n;	
}

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

int main() {
  int N;
  int p=0,w=0,g=0,y=0;
  cin >>N;
  for(int i=0; i<N-1; i++){
    string col;
    cin>>col;
    if(col=="P"){
      p++;
    }
    else if(col=="W"){
      w++;
    }
    else if(col=="Y"){
      y++;
    }
    else if(col=="G"){
      g++;
    }
    else{
      cout<<"error"<<endl;
      break;
    }
  }
 if(p==0||w==0||y==0||g==0){
   cout<<"Three"<<endl;
 }
 else{
   cout<<"Four"<<endl;
 }
}




Measured memory_bytes: 256
n = int(input())
d = []
for i in range(n):
    a,b = map(int,input().split())
    d.append([a,b])
cnt,ans = 0,0
for i in d:
    if i[0] == i[1]:
        cnt += 1
        ans = max(ans,cnt)
    else:
        cnt = 0
if ans>2:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9132
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.awt.Point;
import java.util.*;
   
class Main{
public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String str;
while(!(str=br.readLine()).equals("0 0")){
String[] value=str.split(" ");
int h=Integer.parseInt(value[0]);
int w=Integer.parseInt(value[1]);
char[][] map=new char[h][w];
for(int i=0;i<h;i++){
map[i]=br.readLine().toCharArray();
}
Deque <Point> que=new  ArrayDeque<Point>();
int ans=0;
for(int m=0;m<h;m++){
for(int n=0;n<w;n++){
if(map[m][n]!='.'){
ans++;
Point p = new Point(n,m);
que.addLast(p);
while(que.peekFirst()!=null){
p=que.pollFirst();
int x=p.x;
int y=p.y;
char crop = map[y][x];
map[y][x]='.';
int [] dx ={0,1,0,-1};
int [] dy ={1,0,-1,0};                   
for(int i=0;i<4;i++){
int nx =x+dx[i];
int ny =y+dy[i];
if(nx>=0&&nx<w&&ny>=0&&ny<h&&map[ny][nx]!='.'&&map[ny][nx]==crop){
Point np = new Point(nx,ny);
que.addLast(np);                       
}
}
}
}
}
}System.out.println(ans);
}
}
}

Measured memory_bytes: 24996
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;
  
public class Main {
    private static FastScanner sc = new FastScanner();
     
    public static void main(String[] args) {
        int N = sc.nextInt();
        int W = sc.nextInt();
        int[] v = new int[N];
        int[] w = new int[N];
        for(int i=0; i<N; i++) {
            v[i] = sc.nextInt();
            w[i] = sc.nextInt();
        }
         
        int[] dp = new int[W+1];
        for(int i=0; i<N; i++) {
            for(int j=W; j>=0; j--) {
                if(j-w[i] >= 0 && dp[j-w[i]] + v[i] > dp[j]) {
                    dp[j] = dp[j-w[i]] + v[i];
                }
            }
        }
         
        int max = 0;
        for(int j=0; j<=W; j++) {
            if(dp[j] > max) {
                max = dp[j];
            }
        }
        System.out.println(max);
    }
     
    static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if(ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch(IOException e) {
                    e.printStackTrace();
                }
                if(buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
        public boolean hasNext() { skipUnprintable(); return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public int nextInt(){
            return Integer.parseInt(next());
        }
        public double nextDouble(){
            return Double.parseDouble(next());
        }
    }
}

Measured memory_bytes: 24816
#include<bits/stdc++.h>
using namespace std;
const long long m=1000000007;
typedef vector<long long>vec;
typedef vector<vec>mp;
int n;
long long k;
long long a[60][60];
vec d;
mp jc(mp a,mp b){
	int mm=a.size(),nn=a[0].size(),pp=b[0].size();
	mp c;
	for(int i=0;i<mm;i++){
		c.push_back(d);
		for(int j=0;j<pp;j++){
			c[i].push_back(0);
			for(int k=0;k<nn;k++)
				c[i][j]=(c[i][j]+a[i][k]*b[k][j])%m;
		}
	}
	return c;
}
void pr(mp k){
	for(int i=0;i<k.size();i++,cout<<endl)
		for(int j=0;j<k[0].size();j++,cout<<" ")
			cout<<k[i][j];
}
long long work(){
	mp ccf;
	for(int i=0;i<n;i++){
		ccf.push_back(d);
		for(int j=0;j<n;j++)
			ccf[i].push_back(a[i+1][j+1]);
	}
	mp cf,f;
	cf=ccf,k--;
	f=ccf;
	long long i=1;
	while(i<=k){
		if(k&i){
			cf=jc(cf,f);
		}
		f=jc(f,f);
		i*=2;
	}
	long long ans=0;
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
			ans+=cf[i][j];
	return ans%m;
}
int main(){
	cin>>n>>k;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			cin>>a[i][j];
	cout<<work();
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
const int maxN=403;
const int INF=1e9+12;
int n,ma,mb;
int a[maxN],b[maxN],c[maxN];
int dp[maxN][maxN][maxN];
int main(){
  cin>>n>>ma>>mb;
  for(int i=1;i<=n;i++){
    cin>>a[i]>>b[i]>>c[i];
  }
  for(int i=0;i<=n;i++)
    for(int j=0;j<=400;j++)
      for(int k=0;k<=400;k++)
	dp[i][j][k]=INF;
  dp[0][0][0]=0;
  for(int i=1;i<=n;i++){
    for(int j=0;j<=400;j++){
      for(int k=0;k<=400;k++){
	dp[i][j][k]=dp[i-1][j][k];
	if(j>=a[i]&&k>=b[i])
	  dp[i][j][k]=min(dp[i][j][k],dp[i-1][j-a[i]][k-b[i]]+c[i]);
      }
    }
  }
  int mn=INF;
  for(int j=0;j<=400;j++)for(int i=0;i<=400;i++){
      //cout<<i<<' '<<j<<' '<<dp[n][i][j]<<endl;
      int aa=i/ma,bb=j/mb;
      if(aa==bb&&aa>=1&&i%ma==0&&j%mb==0&&dp[n][i][j]!=INF){
	//cout<<i<<' '<<j<<' '<<aa<<' '<<bb<<' '<<dp[n][i][j]<<endl;
	mn=min(mn,dp[n][i][j]);
      }
    }
  if(mn==INF)cout<<-1<<endl;
  else
    cout<<mn<<endl;
}


Measured memory_bytes: 26880
#include <iostream>
#include <utility>
#include <vector>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

int main()
{
    int q;
    cin >> q;
    priority_queue<P> quel;
    priority_queue<P, vector<P>, greater<P>> queh;
    ll pos = 0, neg = 0;
    for(int i = 0; i < q; i++){
        int r;
        cin >> r;
        if(r == 1){
            ll a, b;
            cin >> a >> b;
            P p = P(a, b);
            if(quel.empty() || p < quel.top()){
                quel.push(p);
                pos += b - a;
                if(quel.size() > queh.size() + 1){
                    P im = quel.top();
                    pos -= im.second - im.first;
                    quel.pop();
                    neg += im.second + im.first;
                    queh.push(im);
                }
            }
            else{
                queh.push(p);
                neg += b + a;
                if(queh.size() > quel.size()){
                    P im = queh.top();
                    neg -= im.second + im.first;
                    queh.pop();
                    pos += im.second - im.first;
                    quel.push(im);
                }
            }
        }
        if(r == 2){
            ll minx = quel.top().first;
            cout << minx << " " << pos + minx * (ll)quel.size() + neg - minx * (ll)queh.size() << endl;
        }
    }
}

Measured memory_bytes: 4588
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
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 N, K, S;
    cin >> N >> K >> S;
    rep(i, N) {
        if(i != 0) cout << " ";
        if(K > 0) {
            cout << S;
            K--;
        } else if(S + 1 <= 1000000000) {
            cout << S + 1;
        } else {
            cout << 1;
        }   
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 3652
#!/usr/bin/env python3


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    N, K = map(int, input().split())

    motteru = [False] * N

    for i in range(K):
        d = int(input())
        A = list(map(int, input().split()))
        for a in A:
            a -= 1
            motteru[a] = True

    print(motteru.count(False))


if __name__ == '__main__':
    main()


Measured memory_bytes: 67816
#include <iostream>
#include <cstdio>
using namespace std;
int main() {
	int n;
	long long ans = 0;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		if (i % 3 != 0 && i % 5 != 0) {
			ans += i;
		}
	}
	cout << ans;
	return 0;
}

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

typedef long long ll;

using namespace std;

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

template<class T>
using vt = vector<T>;
template<class T>
using vvt = vector<vector<T>>;

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(b-a==c-b) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
int n,m,day[1010] = {0},cap[1010] = {0},dp[1010][1010] = {0};
int main()
{
    scanf("%d%d",&n,&m);
    for(int i = 0; i < n; i++)scanf("%d",&cap[i]);
    for(int i = 0; i < m; i++)scanf("%d",&day[i]);
    for(int i = 0; i < m + 1; i++)
    {
        for(int j = 0; j < n + 1; j++)
        {
            if(j == 0)dp[j][i] = 0;
            else if(i < j || i == 0)dp[j][i] = -1;
            else if(dp[j][i - 1] == -1)dp[j][i] = dp[j - 1][i - 1] + (cap[j - 1] * day[i - 1]);
            else dp[j][i] = min(dp[j - 1][i - 1] + cap[j - 1] * day[i - 1],dp[j][i - 1]);
        }
    }
    /*for(int i = 0; i < m + 1; i++)
    {
        for(int j = 0; j < n + 1; j++)
        {
            printf("%d ",dp[j][i]);
        }
        printf("\n");
    }*/
    printf("%d\n",dp[n][m]);
    return 0;
}

Measured memory_bytes: 5784
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
    int n;
    string s;
    cin >> n >> s;
    rep(i,s.size()) {
        s.at(i) = s.at(i)+n;
        if(s.at(i)>'Z') s.at(i) -= 26;
}
    rep(i,s.size()) cout << s.at(i);
    cout << endl;
}

Measured memory_bytes: 256
n=int(input())
al=list(map(int, input().split()))
bl=list(map(int, input().split()))

ap=al[0]
i=0
sum=0
for a in al[1:]:
    y = bl[i]

    m1 = min([ap, y])
    sum += m1

    y1 = y - m1
    if y1 < 0:
        y1 = 0

    m2 = min([a, y1])
    sum += m2

    ap = a - y1
    if ap < 0:
        ap = 0

    i += 1

print(sum)


Measured memory_bytes: 18624
def main():
    N=int(input())
    A=[int(x) for x in input().split()]
    
    cnt_4=0
    cnt_2=0
    for i in A:
        if i%4==0:
            cnt_4+=1
        elif i%2==0:
            cnt_2+=1
    
    ok=N//2
    if (cnt_4+cnt_2//2)>=ok:
        print("Yes")
    else:
        print("No")
    
if __name__=="__main__":
    main()

Measured memory_bytes: 14252
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;
typedef vector<pii> vii;
typedef priority_queue<ll> pq;

const int MOD = 1e9+7;
const int INF = 2e9;
const int MAX_N = 1;

int main() {
  int N, K; cin >> N >> K;
  if (++N / 2 >= K) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 256