akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

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

	int n, m;
	cin >> n >> m;
	vector<vector<int>> rooms(n);
	vector<int> res(n);
	for (int i = 0; i < m; i++) {
		int u, v;
		cin >> u >> v;
		--u, --v;
		rooms[u].push_back(v);
		rooms[v].push_back(u);
	}

	queue<pair<int, int>> q;
	vector<bool> visited(n);
	visited[0] = true;
	for (int u : rooms[0]) {
		q.push({ u, 1 });
	}

	while (!q.empty()) {
		pair<int, int> pr = q.front();
		q.pop();

		if (visited[pr.first]) continue;
		visited[pr.first] = true;

		res[pr.first] = pr.second;
		for (int u : rooms[pr.first]) {
			q.push({ u, pr.first + 1 });
		}
	}

	for (int i = 1; i < n; i++) {
		if (res[i] == 0) {
			cout << "No\n";
			return 0;
		}
	}

	cout << "Yes\n";
	for (int i = 1; i < n; i++) {
		cout << res[i] << '\n';
	}

	return 0;
}



Measured memory_bytes: 12256
def check(i, j, s, H, W):
    if i != 0:
        if s[i-1][j] == '#':
            return True
    if i != H-1:
        if s[i+1][j] == '#':
            return True
    if j != 0:
        if s[i][j-1] == '#':
            return True
    if j != W-1:
        if s[i][j+1] == '#':
            return True
    return False

H, W = map(int, input().split())

s = []
for i in range(H):
    s.append(input())

ans = 'Yes'
for i in range(H):
    for j in range(W):
        if s[i][j] == '#':
            if check(i, j, s, H, W) == False:
                ans = 'No'

print(ans)


Measured memory_bytes: 3064
a = int(input())
i = 1
if a == 1 or a == 2 or a == 4:
    print(4)
else:
    while True:
        if a%2 == 1:
            a = 3*a + 1
        else:
            a = a/2
        i += 1
        if a == 4:
            print(i+3)
            break

Measured memory_bytes: 2940
def d_megalomania(N, Tasks):
    tasks = sorted(Tasks, key=lambda x: x[1])
    time = 0
    for a, b in tasks:
        time += a
        if time > b:
            return 'No'
    return 'Yes'

N = int(input())
Tasks = [[int(i) for i in input().split()] for j in range(N)]
print(d_megalomania(N, Tasks))

Measured memory_bytes: 42764
#include<iostream>
#include<unordered_map>
#include<bitset>
#include<math.h>
#include<vector>
#include<set>
#include<algorithm>
#include<ctype.h>
#include<unordered_set>
#include<string>
#include<iomanip>
#include<queue>
#include<limits>
#include<map>
#include<stack>
#include<iterator>
#include<cstring>
#include<deque>
#include<chrono>
using namespace std;
#define pi 3.141592653589793238


#define MOD 1000000007
#define INF 999999999999999999 
#define pb push_back
#define ff first
#define ss second
#define mt make_tuple
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define f0 get<0>
#define f1 get<1>
#define f2 get<2>
typedef vector<ll> vi;
typedef vector<vi> vvi;


////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    fast;
    ll T = 1, i, j;
    
    
    //cin >> T;
    while (T--) {
        ll n,k ;
        cin >> n >> k;
        vector<ll> v(n);
        for(i = 0; i < n; i++){
            cin >> v[i];
        }
        ll sum = 0;
        sort(v.begin(), v.end());
        for(i =0; i < k; i++){
            sum += v[i];
        }
        cout << sum;
    }

    return 0;
}


Measured memory_bytes: 3660
//"I'll live the focused life, because it's the best kind there is" - Winifred Gallagher
#include<bits/stdc++.h>
using namespace std;
#define debug(a) cout << #a << ": " << a << endl
using namespace std;
#define ll long long
const ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int> pii;
#define sz(a) int(a.size())
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) (v).begin(),(v).end()
#define fast cin.tie(0); ios::sync_with_stdio(false);
int main(){
	int n; cin>>n;
	cout<<800 * n - 200*(n / 15)<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,i,j,k,ans=0;
  string s;
  vector<vector<int>> z(26,vector<int>(2));
  cin>>n>>s;
  for(i=0;i<n;i++){
    if(z.at(s.at(i)-'a').at(0)==0) z.at(s.at(i)-'a').at(0)=i+1;
    else z.at(s.at(i)-'a').at(1)=i+1;
  }
  for(i=1;i<n;i++){
    k=0;
    for(j=0;j<26;j++) if(z.at(j).at(0)<=i&&i<z.at(j).at(1)) k++;
    if(ans<k) ans=k;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false);cin.tie(0)
#define fre freopen("C:\\in.txt", "r", stdin)
#define _for(i,a,b) for(int i=a; i< b; i++)
#define _rep(i,a,b) for(int i=a; i<=b; i++)
#define lowbit(a) ((a)&-(a))
#define inf 0x3f3f3f3f
#define endl "\n"
using namespace std;
typedef long long ll;
template <class T>
void read(T &x)
{
    char c; bool op=0;
    while(c=getchar(), c<'0'||c>'9') if(c=='-') op=1;
    x=c-'0';
    while(c=getchar(), c>='0'&&c<='9') x=x*10+c-'0';
    if(op) x=-x;
}

const int maxn=2e5+5;
int n, sum, a[maxn];

int main()
{
    read(n);
    _rep(i, 1, n) read(a[i]), sum^=a[i];
    _rep(i, 1, n) printf("%d ", sum^a[i]);
    return 0;
}


Measured memory_bytes: 4492
unittest
{
	assert( [ "3" ].parse.expand.solve == 2 );
	assert( [ "6" ].parse.expand.solve == 9 );
	assert( [ "11" ].parse.expand.solve == 30 );
	assert( [ "50" ].parse.expand.solve == 625 );
}



import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto k = input.front.strip.to!( long );
	return tuple( k );
}

auto solve( long k )
{
	auto odd = k / 2 + ( k % 2 == 1 );
	auto even = k / 2;
	
	return odd * even;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <cstdio>
#include <numeric>
#define REP(i, n) for(LL i = 0;i < n;i++)
#define REPR(i, n) for(LL i = n;i >= 0;i--)
#define FOR(i, m, n) for(LL i = m;i < n;i++)
#define FORR(i, m, n) for(LL i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define INF (LL)1e15
#define MOD 1000000007
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

//#define int long long

/*************** using variables ***************/
int n;
vector<int> a;
LL sum = 0;
LL num;
LL ans = 0;
/**********************************************/

signed main(){
    cin >> n;
    a.resize(n);
    REP(i, n) cin >> a[i];

    REP(i, n){
        sum += a[i];
    }
    
    if(sum >= 0) num = (double)sum / n + 0.5;
    else num = (double)sum / n - 0.5;

    REP(i, n){
        ans += pow((a[i] - num), 2);
    }

    cout << ans << endl;

}


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

int main() {
  long double w,h,x,y;
  cin>>w>>h>>x>>y;
  if (w/2 == x && h/2 == y){
    cout << w*h/2 << ' ' << 1 << endl;
  }
  else{
    cout << w*h/2 << ' ' << 0 << endl;
  }
}

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

int main() {
  int n, m, k;
  cin >> n >> m >> k;
  
  vector<int> A(n), B(m);
  for(int i=0; i<n; i++)
    cin >> A.at(i);
  for(int i=0; i<m; i++)
    cin >> B.at(i);
  
  vector<long long> a(1, 0), b(1, 0);
  for(int i=1; i<n+1; i++)
    a.push_back(A.at(i-1)+a.at(i-1));
  for(int i=1; i<m+1; i++)
    b.push_back(B.at(i-1)+b.at(i-1));
  
  long long ans=0, j=m;
  
  for(int i=0; i<n+1; i++){
    if(a.at(i)>k)
      break;
    while(b.at(j) > k-a.at(i))
      j--;
    ans = max(ans, i+j);
  }
  
  cout << ans << endl;
}


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

int main() {
    string s;
    int ans = 700;
    
    cin >> s;
    
    for (int i = 0; i < 3; i++) {
        if (s[i] == 'o') {
            ans += 100;
        }
    }
    
    cout << ans << endl;
    return 0;
}

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

int main()
{
  int a, b;
  std::string result;

  std::cin >> a >> b;
  if (a < b)
  {
    for (int idx=0; idx<b; ++idx)
      result += std::to_string(a); 
  }
  else
  {
    for (int idx=0; idx<a; ++idx)
      result += std::to_string(b); 
  }

  std::cout << result;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
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; }

const int MAX = 510000;
const int mod = 1000000007;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
mint COM(int n, int k){
    mint a = 1;
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    a *= fac[n] * (finv[k] * finv[n - k] % mod) % mod;
    return a;
}


int main(void){
  int n; cin >> n;
  int a[n];
  set<int> s;
  int dup;
  FOR(i,0,n) {
    cin >> a[i];
    if(s.count(a[i])>0) dup = a[i];
    s.insert(a[i]);
  }
  vector<int> indexdup;
  FOR(i,0,n){
    if(a[i]==dup) indexdup.PB(i);
  }

  int outrange = (n+1) - (indexdup[1]-indexdup[0]+1);
  
  COMinit();
  FOR(i,1,n+1){
    mint ans = 0;
    if(i==1) {
      cout << n << endl;
      continue;
    } else if (i==n+1) {
      cout << 1 << endl;
      continue;
    }

    ans += COM(n+1,i);
    if(i-1<=outrange){
      ans -= COM(outrange,i-1);
    }
    cout << ans.x << endl;
  }
}

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

int main(){
  vector< vector<int> > G(4,vector<int>(4,0));
  vector<int> P(4);
  for(int i = 0; i < 4; ++i) P[i] = i;
  for(int i = 0; i < 3; ++i){
    int a, b;
    cin >> a >> b;
    --a,--b;
    G[a][b] = 1;
    G[b][a] = 1;
  }
  do{
    bool f = true;
    for(int i = 1; i < 4; ++i){
      if(G[P[i]][P[i-1]]) continue;
      f = false;
      break;
    }
    if(f){
      cout << "YES" << endl;
      return 0;
    }
  }while(next_permutation(P.begin(), P.end()));
  cout << "NO" << endl;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
#define MEMS(a,b) memset(a,b,sizeof(a))
#define mp make_pair
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

int main(){
    ll N;
    cin >> N;
    ll K;
    cin >> K;

    ll ans = 0;
    while(N > 0){
        N /= K;
        ans++;
    }

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


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <unordered_map> 
#include <map> 
#include <numeric>
#include <limits>
#include <utility>
#include <queue>
#include <random>
#include <bitset>
#include <memory>
using namespace std;
typedef long long LL;

int main(void) {

	int n, m, x, aa = 0, bb = 0, temp;
	cin >> n >> m >> x;
	vector<int> a(m);

	for (int i = 0; i < m; i++) {
		cin >> temp;
		if (temp < x) {
			aa++;
		} else {
			bb++;
		}
		a[i] = temp;
	}

	cout << min(aa, bb) << endl;


	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
long dp[51][51][2501];
int n,a,x[50];
main()
{
	cin>>n>>a;
	for(int i=0;i<n;i++)cin>>x[i];
	dp[0][0][0]=1;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<=i;j++)
		{
			for(int k=0;k<=2500;k++)
			{
				dp[i+1][j+1][k+x[i]]+=dp[i][j][k];
				dp[i+1][j][k]+=dp[i][j][k];
			}
		}
	}
	long ans=0;
	for(int i=1;i<=n;i++)
	{
		ans+=dp[n][i][a*i];
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 49152
n = int(input())
s = []

ac = 0
wa = 0
tle = 0
re = 0

for i in range(n):
  s.append(input())
  if s[i] == "AC":
    ac += 1
  elif s[i] == "WA":
    wa += 1
  elif s[i] == "TLE":
    tle += 1
  else:
    re += 1

print("AC x " + str(ac))
print("WA x " + str(wa))
print("TLE x " + str(tle))
print("RE x "+ str(re))

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

int main(){
    int N;
    cin >> N;
    char S[N+1];
    S[0] = 0;
    rep(i, N) cin >> S[i+1];
    ll ans = 0;
    ll numR = 0;
    ll numG = 0;
    ll numB = 0;

    rep(i, N){
        if (S[i + 1] == 'R') numR++;
        if (S[i + 1] == 'G') numG++;
        if (S[i + 1] == 'B') numB++;
    }
    ans = numR * numG * numB;

    if (ans == 0){
        cout << 0 << endl;
        return 0;
    }

    // cout << numR << " " << numG << " " << numB << " " << ans << endl;

    int gap, st;

    // for(gap = 1; 1 + 2 * gap <= N; gap++){
    for(gap = 1; gap <= N; gap++){
        for(st = 1; st + 2 * gap <= N; st++){
            if ( (S[st] != S[st + gap]) && (S[st] != S[st + 2 * gap]) ){
                if( (S[st + gap] != S[st + 2 * gap]) && (st + 2 * gap <= N) ){
                    ans--;
                }
            }
        }
        // cout << gap << " " << ans << endl;
    }

    // cout << st << " " << gap << endl;

    cout << ans << endl;

    return 0;
}


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

int main() {
	char vetor[100002];
	char alf[26] = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
	int a;
	scanf("%d",&a);
	scanf("%s",vetor);
	for(int y=0;y<strlen(vetor);++y){
	    for(int x=0;x<26;++x){
	        if(vetor[y]==alf[x]){
	            if((x+a)>25)
	                printf("%c",alf[(x+a)-26]);
                else
                    printf("%c",alf[(x+a)]);
	        }
	    }
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 128
/// Kazuki Hoshino


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<pi> vpi;
#define inf 1000000000
#define mod 1000000007
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define rep1(i, a, b) for(int i =a; i >=b; i--)
#define f first
#define ss second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple

ll n, a[101010], cnt =0 ;

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

//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);


cin >> n;

rep(i, 1, n){
cin >> a[i];
}

rep(i, 1, n-1){
if(a[i]==a[i+1]){
    a[i+1]=inf;
    cnt++;
}
}

cout << cnt << endl;




return 0;}
///.... Maria Otonashi


Measured memory_bytes: 764
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define sz(x) (int)(x).size()
typedef vector<int> vi;
// #define ll long long 
#define int long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define all(x) (x).begin(), (x).end()
const int MOD = 1e9+7;
int mpow(int a,int b,int p=MOD){a=a%p;int res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}
const int N=1e4+2;
int dp[N];
int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int h,n;
	cin>>h>>n;
	int a[n],b[n];
	for(int i=0;i<n;i++) cin>>a[i]>>b[i];
	for(int i=0;i<N;i++) dp[i]=1e17;
	dp[0]=0;
	for(int i=0;i<=h;i++)
	{
		for(int j=0;j<n;j++)
		{
			if(i>=a[j])
			{
				dp[i]=min(dp[i],dp[i-a[j]]+b[j]);
			}
			else{
				dp[i]=min(dp[i],b[j]);
			}
		}
	}
	// for(int i=0;i<=h;i++) cout<<dp[i]<<"\n";
	cout<<dp[h];
}
// I never lose. I either win or I learn

Measured memory_bytes: 384
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner s = new Scanner(System.in);
        int n = s.nextInt(), tapo=0, hapo=0;
        for (int i=0; i<n; i++){
            String taro = s.next();
            String hana = s.next();
            int co=taro.compareTo(hana);
            if (co>0) tapo += 3;
            else if (co<0) hapo += 3;
            else{
                tapo++;
                hapo++;
            }
        }
        System.out.println(tapo+" "+hapo);
    }
}


Measured memory_bytes: 29156
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i, m, n) for (int i = int(m); i < int(n); i++)
#define RREP(i, m, n) for (int i = int(n) - 1; i >= int(m); --i)
#define EACH(i, c) for (auto &(i) : c)
#define all(c) begin(c), end(c)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort(begin(c), end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x) cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) \
    do           \
    {            \
    } while (0)
#define dump(x) \
    do          \
    {           \
    } while (0)
#define BR
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int, int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template <class T>
inline T sqr(T x) { return x * x; }

void solve()
{
    int n;
    string s;
    cin >> n >> s;
    int diff = 0;
    int b = 0, a = 0;
    REP(i, 0, n)
    {
        if (s[i] == '(')
            ++diff;
        else
        {
            --diff;
            if (diff < 0)
            {
                b += -diff;
                diff = 0;
            }
        }
    }
    a = diff;

    REP(i, 0, b)
    cout << "(";
    cout << s;
    REP(i, 0, a)
    cout << ")";
    cout << endl;
}

int main()
{
    solve();

    return 0;
}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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; }

const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;

char G[105][105];

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll h,w; cin>>h>>w;
  rep(i,h) rep(j,w) cin>>G[i][j];
  
  vb tate(h), yoko(w);
  rep(i,h){
    bool flg=true;
    rep(j,w){
      if(G[i][j]=='#') flg=false;
    }
    if(flg){
      tate[i]=true;
    }
  }
  
  rep(j,w){
    bool flg=true;
    rep(i,h){
      if(G[i][j]=='#') flg=false;
    }
    if(flg) yoko[j]=true;
  }
  
  // ll cnt=0;
  // rep(i,h) if(tate[i]) cnt++;
  // cout<<h-cnt<<' ';
  // cnt=0;
  // rep(j,w) if(yoko[j]) cnt++;
  // cout<<w-cnt<<endl;
  
  rep(i,h){
    if(tate[i]) continue;
    rep(j,w){
      if(yoko[j]) continue;
      cout<<G[i][j];
    }
    cout<<endl;
  }
  
}

Measured memory_bytes: 256
using System;
using static System.Console;
using static System.Math;
using System.IO;
using System.Collections.Generic;
namespace I_am_the_green_coder{
    class Inonoa{
        // なんか入力用の関数作ったけどまだテストしてないので使う前に確かめて
        static void Main(){
            long[] lr = ILongs();

            if(lr[1]-lr[0]>=2018){
                Console.WriteLine(0);
                return;
            }else{
                long l = lr[0]%2019;
                long r = lr[1]%2019;

                long ans = 2019;

                if(r>l){
                    for(long i=l;i<=r-1;i++){
                        for(long j=i+1;j<=r;j++){
                            if((i*j)%2019<ans)ans = i*j%2019;
                        }
                    }
                    Console.WriteLine(ans);
                    return;
                }else{
                    for(long i=l;i<=r-1+2019;i++){
                        for(long j=l+1;j<=r+2019;j++){
                            if(i*j%2019<ans)ans = i*j%2019;
                        }
                    }
                    Console.WriteLine(ans);
                    return;
                }
            }
        }

        static readonly long MOD = 1000000007;

        ///<summary>a_1, a_2, a_3, ...みたいなの</summary>
        static long[] ILongs(){
            string[] s = ReadLine().Split();
            long[] re = new long[s.Length];
            for(long i=0;i<s.Length;i++){
                re[i] = long.Parse(s[i]);
            }
            return re;
        }

        ///<summary>xooxoxoxxoxo...みたいなの</summary>
        static char[] IChars(){
            return ReadLine().ToCharArray();
        }

        ///<summary>n m とかをちょっとはやくかくだけ</summary>
        static string[] IStrings(){
            return ReadLine().Split();
        }

        ///<summary>n行の入力を取ったり</summary>
        static long[][] ILongLongs(long n){
            long[][] re = new long[n][];
            for(long i=0;i<n;i++){
                string[] s = ReadLine().Split();
                re[i] = new long[s.Length];
                for(long j=0;j<s.Length;j++){
                    re[i][j] = long.Parse(s[j]);
                }
            }
            return re;
        }

        ///<summary>n行の文字列を取ったり</summary>
        static char[][] ICharsChars(long n){
            char[][] re = new char[n][];
            for(long i=0;i<n;i++){
                re[i] = ReadLine().ToCharArray();
            }
            return re;
        }
    }
}

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

int main(){
  string a,b,c;
  cin >> a >> b >>c;
  int count = 0;
  if(a == b && b == c)
    cout << "No" << endl;
  else if (a != b && b != c && a != c)
    cout << "No" << endl;
  else 
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cstdio>
#include<ctype.h>
#include<stdio.h>
#include<set>
#include<vector>
#include<map>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<numeric>
#include<string>
typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) {
	if (a<b) { return gcd(b, a); }
	else if (a%b) { return gcd(b, a%b); }
	else { return b; }
}
int main() {
	ll N;
	ll ans = 0;
	ll cnt = 1;
	cin >> N;
	ll a[N + 100];
	for (ll i = 0; i < N; i++) {
		cin >> a[i];
	}
	sort(a, a + N);
  	a[N]=0;
	for (ll i = 0; i < N; i++) {
		if (a[i] == a[i + 1])cnt++;
		else {
			if (a[i] > cnt)ans += cnt;
			else ans += cnt - a[i];
			cnt = 1;
		}
	}
	cout << ans << endl;
}


 

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long int
#define mod 1000000007
#define pb push_back
//#define mp make_pair
#define eps 1e-9
#define pp pair < pair<ll,ll> , ll> 
#define fo(i,j,k) for(int i=j;i<=k;i++)
#define foll(i,j,k) for(ll i=j;i<=k;i++)
#define clr(a) memset(a,0,sizeof(a))
#define vi vector<int>
#define vll vector<ll>
#define sz(a) a.size()
#define len(a) a.length()
#define all(a) a.begin(),a.end()
#define io_file freopen("Contest/input_file.in", "r", stdin); freopen("Contest/output_file.in", "w", stdout)

const ll INF = 1e18 + 5;
const int MAXN = 2e5+5;
using namespace std;
ll power(ll x, ll y)
{
  ll res = 1;
  while(y>0)
  {
    if(y&1)
       {
         res = (res*x)%mod;
        }
     x = (x*x)%mod;
     y = y>>1;
  }
    return res;
}
std::vector<ll> divi[1000004];

void divisor(int n)
{
   for(ll i=1;i<=n;i++)
   {
     for(ll j=i;j<=n;j+=i)
     {
       divi[j].pb(i);
     }
   }
}

int n;
ll m;
ll a[300005];

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

    ll x,y,z,k;
    cin>>x>>y>>z>>k;
    if(k%2==1)
    {
    	cout<<y-x<<endl;
    }
    else cout<<x-y<<endl;

    
   	return 0;


}


Measured memory_bytes: 24064
import java.util.*;
import java.math.*;
import java.text.*;

public class Main {
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		for(int i=0; i<n; i++){
			int a = trans(in.next());
			int b = trans(in.next());
			int c = a+b;
			output(c);
		}
	}
	
	public static int trans(String str){
		char[] ch = str.toCharArray();
		int flag = 0;
		int num = 0;
		for(int i=0; i<str.length(); i++){
			String tmp = String.valueOf(ch[i]);
			if(tmp.equals("m")){
				if(flag == 0) num = num+1000;
				else num = num+flag*1000;
				flag = 0;
			}
			else if(tmp.equals("c")){
				if(flag == 0) num = num+100;
				else num = num+flag*100;
				flag = 0;
			}
			else if(tmp.equals("x")){
				if(flag == 0) num = num+10;
				else num = num+flag*10;
				flag = 0;
			}
			else if(tmp.equals("i")){
				if(flag == 0) num = num+1;
				else num = num+flag;
				flag = 0;
			}
			else{
				flag = Integer.valueOf(tmp);
			}
		}
		return num;
	}
	
	public static void output(int c){
		int d1,d2,d3,d4;
		d1 = c/1000;
		c = c-d1*1000;
		d2 = c/100;
		c = c-d2*100;
		d3 = c/10;
		d4 = c-d3*10;
		if(d1==1){
			System.out.print("m");
		}else if(d1>1){
			System.out.print(d1+"m");
		}
		if(d2==1){
			System.out.print("c");
		}else if(d2>1){
			System.out.print(d2+"c");
		}
		if(d3==1){
			System.out.print("x");
		}else if(d3>1){
			System.out.print(d3+"x");
		}
		if(d4==1){
			System.out.print("i");
		}else if(d4>1){
			System.out.print(d4+"i");
		}
		System.out.println();
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <string>
#include <map>
#include <set>
#include <stdlib.h>
#include <cmath>
#include <math.h>
#include <fstream>
#include <bitset>
#include <time.h>
#include <queue>
#define int long long
using namespace std;
int32_t main(){
    int n, ai;
    cin >> n;
    vector<int> v;
    for (int i=0; i < n; i++){
        cin >> ai;
        v.push_back(ai);
    }
    int ans = 0;
    while (true){
        int it = 0;
        vector<int> ops;
        for (int i=0; i < n; i++){
            int op = (v[i] - (n - 1)) / n;
            if ((v[i] - (n - 1)) % n != 0) op ++;
            if (v[i] <= n - 1) op = 0;
            ops.push_back(op);
            it += op;
        }
        ans += it;
        bool vv = true;
        for (int i=0; i < n; i++){
            v[i] -= n * ops[i];
            v[i] += (it - ops[i]);
            if (v[i] >= n) vv = false;
        }
        if (vv) break;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		int x = scan.nextInt();

		int count =0;

		for(int i=0;i<=a;i++) {
			for(int l=0;l<=b;l++) {
				for(int m=0;m<=c;m++) {
					if(x==500*i+100*l+50*m) {
						count++;
					}
				}
			}
		}
		/*
		//xを50円玉で構成した場合
		int only50 = x/50;

		//50円玉のみで作った場合
		if(only50<=c) {
			count++;
		}

		//100円も混ぜる場合
		int use100=only50/2;
		if(use100>=b) {

			count= count + b+(x-use100)/c;
		}else {
			count = count + use100;
		}

		int use500=only50/10;
		if(use500>=a) {
			count= count + a;
		}else {
			count = count + use500;
		}
		*/

		System.out.println(count);
	}

}


Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<ll,ll> P;
#define pb push_back
#define ft first
#define sd second
#define mp make_pair
#define fr(i,n) for(int i=0;i<(n);i++)
#define Fr(i,n) for(int i=0;i++<(n);)
#define ifr(i,n) for(int i=(n)-1;i>=0;i--)
#define iFr(i,n) for(int i=(n);i>0;i--)

template<class T,class E> struct LSeg{
    typedef function<T(T,T)> F;
    typedef function<T(T,E)> G;
    typedef function<E(E,E)> H;
    typedef function<E(E,int)> P;
    int n;F f;G g;H h;T et;E ee;P p;
    vector<T> dat;
    vector<E> lazy;
    LSeg(int n_,F f_,G g_,H h_,T et_,E ee_,P p_=[](E a,int b){return a;}){
        f=f_;g=g_;h=h_;et=et_;ee=ee_;p=p_;
        n=1;
        while(n<n_) n*=2;
        dat.resize(2*n-1,et);
        lazy.resize(2*n-1,ee);
    }
    inline void prop(int k,int l,int r){
        if(lazy[k]==ee) return;
        dat[k]=g(dat[k],lazy[k]);
        if(r-l>1){
            lazy[k*2+1]=h(lazy[k*2+1],p(lazy[k],-1));
            lazy[k*2+2]=h(lazy[k*2+2],p(lazy[k],-1));
        }
        lazy[k]=ee;
    }
    void ud(int be,int en,E t,int k,int l,int r){
        prop(k,l,r);
        if(r<=be||en<=l) return;
        if(be<=l&&r<=en){
            lazy[k]=h(lazy[k],p(t,r-l));
            prop(k,l,r);
            return;
        }
        ud(be,en,t,k*2+1,l,(l+r)/2);
        ud(be,en,t,k*2+2,(l+r)/2,r);
        dat[k]=f(dat[2*k+1],dat[k*2+2]);
    }
    void ud(int be,int en,E t){
        ud(be,en,t,0,0,n);
    }
    T gt(int be,int en,int k,int l,int r){
        prop(k,l,r);
        if(r<=be||en<=l) return et;
        if(be<=l&&r<=en) return dat[k];
        return f(gt(be,en,k*2+1,l,(l+r)/2),gt(be,en,k*2+2,(l+r)/2,r));
    }
    T gt(int be,int en){
        return gt(be,en,0,0,n);
    }
};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,q,s,t,x;
    bool f;
    cin>>n>>q;
    auto ad=[](ll a,ll b){return a+b;};
    auto pr=[](ll a,ll b){return b<0?a/2:a*b;};
    LSeg<ll,ll> sg(n,ad,ad,ad,0,0,pr);
    fr(i,q){
        cin>>f;
        if(f){
            cin>>s>>t;
            cout<<sg.gt(s-1,t)<<endl;
        }
        else{
            cin>>s>>t>>x;
            sg.ud(s-1,t,x);
        }
    }
}


Measured memory_bytes: 7064
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll, vl/*, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); ++i)
#define rep2(i, n) for(ll i = 1; i <= ll(n); ++i)
//#define rep(i, k, n) for(ll i = k-1; i < ll(n); ++i)
//#define rep2(i, k, n) for(ll i = k; i <= ll(n); ++i)
#define all(v) (v).begin(), (v).end()
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 1e9;
const char newl = '\n';

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

  ll n, k;
  cin >> n >> k;
  cout << ((n+1)/2>=k ? "YES" : "NO") << newl;
  return 0;
}

Measured memory_bytes: 256
s = input()
if s[0] == "M":
    print(6)
elif s[0] == "T":
    if s[1] == "U":
        print(5)
    else:
        print(3)
elif s[0] == "W":
    print(4)
elif s[0] == "F":
    print(2)
else:
    if s[1] == "A":
        print(1)
    else:
        print(7)

Measured memory_bytes: 3060
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int64_t>>;

typedef int64_t Int;
const double pi = M_PI;

int main() {
    int a, b, k;
    cin >> a >> b >> k;
    vector<int> c(0);

    for (int i = 1; i < min(a, b) + 1; i++) {
        if (a % i == 0 && b % i == 0) {
            c.push_back(i);
        }
    }

    reverse(c.begin(), c.end());

    cout << c[k - 1] << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
 
int main()
{
    int a,b,c;
    int max,mid,min;
    int work;
    scanf("%d %d %d", &a, &b, &c);
    if(a<b){
        if(b<c){
            min=a;
            mid=b;
            max=c;
        }
        else{
            if(a<c){
                min=a;
                mid=c;
                max=b;
            }
            else{
                min=c;
                mid=a;
                max=b;
            }
        }
    }
    else{
        if(a<c){
            min=b;
            mid=a;
            max=c;
        }
        else{
            if(b<c){
                min=b;
                mid=c;
                max=a;
            }
            else{
                min=c;
                mid=b;
                max=a;
            }
        }
    }
    printf("%d %d %d\n", min,mid,max);
    return 0;
}

Measured memory_bytes: 596
#include <iostream>

using namespace std;

int main()
{
	int S,h,m,s;
	cin >> S;
	h = S / 3600;
	m = (S - h * 3600) / 60;
	s = (S - h * 3600) - m * 60;
	cout << h <<":"<< m << ":" << s << endl;

	//system("PAUSE");
	return 0;
}

Measured memory_bytes: 1168
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];
    deque<int> dq;
    rep(i, n) {
        if (i % 2 == 0) {
            dq.push_back(a[i]);
        } else {
            dq.push_front(a[i]);
        }
    }
    rep(i, n) {
        if (n % 2 == 0) {
            cout << dq.front() << (i == n-1 ? '\n' : ' ');
            dq.pop_front();
        } else {
            cout << dq.back() << (i == n-1 ? '\n' : ' ');
            dq.pop_back();
        }
    }
}

Measured memory_bytes: 3840
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstdio>
#include <cstring>
#include <cinttypes>
using namespace std;
 
using ll=int64_t;
#define int ll
 
#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DMP(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define ZERO(x) memset(x,0,sizeof(x))

using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;
 
void printSpace(){
	printf(" ");
}
 
void printEoln(){
	printf("\n");
}

int read(){
	int i;
	scanf("%" SCNd64,&i);
	return i;
}
void print(const string& s) {
	printf("%s", s.c_str());
}
void println(const string& s) {
	printf("%s\n", s.c_str());
}
void print(int x,int suc=1){
	printf("%" PRId64,x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}
 
string readString(){
	static char buf[3341919];
	scanf("%s",buf);
	return string(buf);
}
 
char* readCharArray(){
	static char buf[3341919];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template <typename T>
vector<T> readVec(int size) {
	using namespace std;
	vector<T> vec(size);
	for (int i = 0; i < size; ++i) {
		cin >> vec[i];
	}
	return vec;
}
template <typename T>
void printVec(const vector<T> &vec, int size, const string &sep = " ") {
	using namespace std;
	if (vec.empty()) return;
	cout << vec[0];
	for (int i = 1; i < size; ++i) {
		cout << sep << vec[i];
	}
	cout << endl;
	return;
}
#define printAll(vec) PrintSize(vec, vec.size())

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

	auto n = read();
	auto a = read();
	auto b = read();
	if ((b - a - 1) % 2 == 0) {
		cout << "Borys" << endl;
	} else {
		cout << "Alice" << endl;
	}
	return 0;
}

Measured memory_bytes: 888
#include <stdio.h>
int main(void){
    int a,b;
    scanf("%d %d",&a,&b);
    if(a<b){
        printf("a < b\n");
    }else if(a > b){
        printf("a > b\n");
    }else{
        printf("a == b\n");
    }
    return 0;
}



Measured memory_bytes: 2072
#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<vector>
#include<array>
#include<string>
#include<stack>
#include<queue>
#include<algorithm>
#include<cassert>
#include<functional>
#include<random>
#include<complex>
#include<bitset>
#include<chrono>

using namespace std;


int main() {

	int64_t N, K;
	cin >> N >> K;
	vector<int64_t>A(N);
	for (int64_t i = 0; i < N; ++i) {
		cin >> A[i];
		A[i] = (A[i] - 1) % K;
	}

	vector<int64_t>sum(N);
	sum[0] = A[0];
	for (int64_t i = 1; i < N; ++i)sum[i] = (sum[i - 1] + A[i]) % K;

	map<int, int>p;

	int64_t ans = 0;

	p[0] = 1;

	for (int64_t i = 0; i < N; ++i) {
		if (p.find(sum[i]) == p.end())p[sum[i]] = 1;
		else {
			p[sum[i]] = p[sum[i]] + 1;
		}
		if (K == i + 1) {
			if (p[0] == 1)p.erase(0);
			else {
				p[0] = p[0] - 1;
			}
		}
		if (K <= i) {
			if (p[sum[i - K]] == 1)p.erase(sum[i - K]);
			else {
				p[sum[i - K]] = p[sum[i - K]] - 1;
			}
		}
		ans += p[sum[i]] - 1;
	}
	cout << ans << endl;

	return 0;
}

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

void solve(long long A, long long B, long long C, long long X, long long Y)
{
    cout << min(min(A * X + B * Y, A * X + B * Y - min(X, Y) * (A + B - 2 * C)), max(X, Y) * (2 * C)) << endl;
}

// 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)
int main()
{
    long long A;
    scanf("%lld", &A);
    long long B;
    scanf("%lld", &B);
    long long C;
    scanf("%lld", &C);
    long long X;
    scanf("%lld", &X);
    long long Y;
    scanf("%lld", &Y);
    solve(A, B, C, X, Y);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	int a, b, c;
  cin >> a >> b >> c;
  int red = a*100;
  int green = b*10;
  int blue = c;
  int num = red + green + blue;
  if(num % 4 == 0){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
	
}

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

using namespace std;

// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);

void solve()
{
    int c;
    cin >> c;
    if (c >= 30)
        cout << "Yes\n";
    else
        cout << "No\n";

}

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

    int nCases = 1;
    // cin >> nCases;

    while(nCases--)
        solve();

    return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
long long INF = numeric_limits<long long>::max();

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n; cin >> n;
  vector<long long> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n - 1; i++) a[i+1] += a[i];
  long long res = INF;
  for (int i = 0; i < n - 1; i++) {
    res = min(res, abs(a[n-1] - a[i] * 2));
  }
  cout << res << '\n';
  return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
int main(void){
     char s[3],t[3];
     int m=0;
     for(int i=0;i<7;i++){
         scanf("%c",&s[i]);
     }
   
     for(int i=0;i<3;i++){
         if(s[i]==s[i+4])
             m++;
     }
     printf("%d",m);
}

Measured memory_bytes: 128
from pprint import pprint
from collections import deque, defaultdict
 
import sys
 
# n, q = map(int, input().strip().split(" "))
n, q = map(int, sys.stdin.readline().strip().split(" "))
edges = [[] for _ in range(n)]
for _ in range(n-1):
    # a_i, b_i = map(int, input().strip().split(" "))
    a_i, b_i = map(int, sys.stdin.readline().strip().split(" "))
    edges[a_i-1].append(b_i-1)
    edges[b_i-1].append(a_i-1)
 
counter = [0] * n
p = [0] * n
for _ in range(q):
    # p_i, x_i = map(int, input().strip().split(" "))
    p_i, x_i = map(int, sys.stdin.readline().strip().split(" "))
    p[p_i-1] += x_i
    # counter[p_i-1] += x_i
 
 
parents = deque()
parents.append(0)
visited = set()
while parents:
    parent = parents.popleft()
    if parent in visited:
        continue
    counter[parent] += p[parent]
    visited.add(parent)
    for child in edges[parent]:
        if child in visited:
            continue
        counter[child] += counter[parent]
        # print("child")
        # print(child, counter[child])
        parents.append(child)
 
print(" ".join(list(map(str, counter))))

Measured memory_bytes: 81568
while True:
    m, f, r = map(int, input().split())
    if m==-1 and f==-1 and r==-1:break
    sum = m +f
    if m==-1 or f==-1:print('F')
    elif sum >= 80:print('A')
    elif sum >= 65 :print('B')
    elif sum >= 50 :print('C')
    elif sum >= 30 :
        if r >= 50:
            print('C')
        else:
            print('D')
    else : print('F')


Measured memory_bytes: 5592
package main

import (
	"fmt"
)

func main() {
	var H, W int64
	fmt.Scan(&H, &W)
	var res int64
	if H == 1 || W == 1 {
		res = 1
	} else {
		if H%2 == 0 {
			res = W * (H / 2)
		} else {
			res = W * (H - 1) / 2
			if W%2 == 0 {
				res += W / 2
			} else {
				res += (W + 1) / 2
			}
		}
	}

	fmt.Println(res)
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define int int64_t
#define pii pair<int,int>
#define rep(i,n) for(int i = 0;i < (n);++i)
#define reps(i,n) for(int i = 1;i <= (n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(10)
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr long long mod = 1000000007;
 
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> vec;
    unordered_map<int,int> cnt;
    rep(i,n){
        int a;
        cin >> a;
        ++cnt[a];
        if(cnt[a] == 2){
            cnt[a] = 0;
            vec.emplace_back(a);
        }
    }
    sort(all(vec),greater<int>());
    cout << (vec.size() < 2 ? 0 : vec[0] * vec[1]) << '\n';
    return 0;
}

Measured memory_bytes: 4388
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int y = Integer.parseInt(sc.next());
        for (int i = 0; i <= n; i++) {
            for (int j = 0; j <= n - i; j++) {
                if (10000 * i + 5000 * j + 1000 * (n - i - j) == y) {
                    System.out.println(i + " " + j + " " + (n - i - j));
                    return;
                }
            }
        }
        System.out.println("-1 -1 -1");
    }
}

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

#define DEBUG 0
#define fi first
#define se second
#define pb push_back
#define INF 1000000000
#define fore(i,a,b) for (int i = (a), _b = (b); i < (_b); ++i)
#define fort(i,a,b) for (int i = (a), _b = (b); i <= (_b); ++i)
#define ford(i,a,b) for (int i = (a), _b = (b); i >= (_b); --i)

using namespace std;

typedef long long LL;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef vector<int> vi;
typedef vector<vi> vvi;

int main() {
    if (DEBUG) {
        freopen("CP.inp", "r", stdin);
        //freopen("CP.out", "w", stdout);
    }
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n, k; cin >> n >> k;
    vi a(n);
    for (int &x : a) cin >> x;
    vi f(n, INF);
    f[0] = 0;
    fore(i, 0, n) {
        fore(j, i + 1, min(n, i + k + 1)) {
            if (j < n) f[j] = min(f[j], f[i] + abs(a[i] - a[j]));
        }
    }
    cout << f[n - 1] << '\n';
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstring>
using namespace std;
int x,y;
char a[200][200];
int main(){
	cin>>x>>y;
	memset(a,'#',sizeof(a));
	for(int i = 1;i <= x;i++)
		for(int j = 1;j <= y;j++)
			cin>>a[i][j];
	for(int i = 0;i <= x + 1;i++){
		for(int j = 0;j <= y + 1;j++)
			cout<<a[i][j];
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 256