akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll          long long int
#define uu          first
#define vv          second
#define pii         pair<int,int>
#define pll         pair<ll,ll>
#define INF         1e9
#define fastRead    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;

const int MAX = 1e6 + 6;
int main()
{
    fastRead;
    int n;
    cin>>n;
    
    int tgt = n;
    if(n %2 ==0) tgt++;
    
    
    vector<pii>vec;
    
    for(int i = 1 ; i <=n ; i++ ) {
        
        for(int j = i+1 ; j<=n ; j++ ) {
            
            if(i + j == tgt ) continue;
            vec.push_back({i,j});
        }
    }
    cout<<vec.size()<<'\n';
    for(auto x : vec) cout<<x.uu<<" "<<x.vv<<'\n';
    return 0;
    
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define Rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;

int main(){
    stack<long> long_stack;
    long a,b;
    char s[100];
    while( scanf("%s", s) != EOF ){
        if ( s[0] == '+' ){
            a = long_stack.top();
            long_stack.pop();
            b = long_stack.top();
            long_stack.pop();
            long_stack.push(a+b);
        } else if ( s[0] == '-' ){
            a = long_stack.top();
            long_stack.pop();
            b = long_stack.top();
            long_stack.pop();
            long_stack.push(b-a);
        } else if ( s[0] == '*' ){
            a = long_stack.top();
            long_stack.pop();
            b = long_stack.top();
            long_stack.pop();
            long_stack.push(a*b);
        } else {
            long x = atoi(s);
            long_stack.push(x);
        }
  }
    cout << long_stack.top() << "\n";
    return 0;   
}


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

int dfs(int n,int point);

int main(){
  int d,g;
  cin >>d >>g;
  int p[d],c[d];
  for(int i=0;i<d;i++)
    cin >> p[i] >>c[i];
  
  int a=10000007;
  
  for(int b=0;b<(1<<d);b++){
    
    int point=0,count=0,e=-1;
    
    for(int j=0;j<d;j++){
      if(b&(1<<j)){
        point+=p[j]*(j+1)*100+c[j];
        count+=p[j];
      }
      else e=j;
    }
    if(e!=-1 && point<g && point+p[e]*(e+1)*100>=g){
      while(point<g){
        point+=(e+1)*100;
        count++;
      }
    }
    if(point>=g)a=min(a,count);
  }
  cout << a <<endl;
}


Measured memory_bytes: 256
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
while(true){
   var Q=Arr.shift()-0;
   if(Q==-1)break;
   var x=Q/2;
   while(Math.abs(Math.pow(x,3)-Q)>=0.00001*Q){
      x=x-(Math.pow(x,3)-Q)/(3*Math.pow(x,2));
   }
   console.log(x.toFixed(6));
}

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

typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)

int main() {
  string s,car;
  cin >> s;
  vint num(4);
  rep(i,4) num.at(i)=stoi(s.substr(i,1));
  int sum,i;
  int anser=0;
 for (i=0; i<8;i++){
    sum=num.at(0);
    rep(j,3){
      if (i & 1 << j){
        sum+=num.at(j+1);
      }
      if (!(i & 1 << j)){
        sum-=num.at(j+1);
      }
    }
    if (sum==7){
      anser=i;
    }
  }
  car+=s.at(0);
  
 rep(j,3){
    if (anser & 1 << j){
        car+='+';
    }
    if (!(anser & 1 << j)){
    car+='-';
    }
    car+=s.at(j+1);
 }
  cout << car << "=7" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>

#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007
#define inf 1e18+42
#define endl "\n"
#define pi 3.1415926535897932384626433832795028841971693993751058
#define maxn 100005

#define out1(a) cout<<#a<<" "<<a<<endl
#define out2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define out3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl

#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define fori(it,A) for(auto it=A.begin();it!=A.end();it++)

#define ft first
#define sd second
#define pb push_back
#define mp make_pair
#define pq priority_queue
#define all(x) (x).begin(),(x).end()
#define zero(x) memset(x,0,sizeof(x));
#define ceil(a,b) (a+b-1)/b
 
using namespace std;

int binpow(int a, int b) {
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

//START OF CODE ->->->->->->->

void solve()
{
    int a,b;
    cin>>a>>b;

    cout<<a*b<<endl;
}

//END OF CODE ->->->->->->->->

signed main()
{
    fast;
    int t = 1;
    // cin>>t;

    while(t--)
    {
        solve();
    }
    return 0;
}



Measured memory_bytes: 3640
import java.util.Scanner;


public class Main{

	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);
        int r = sc.nextInt();
        int g = sc.nextInt();
        int b = sc.nextInt();
        
        int result = (10*g + b);
        
        if(result % 4 == 0) {
        	System.out.println("YES");
        }else {
        	System.out.println("NO");
        }
	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <stack>
#include <stdio.h>
using namespace std;
double a,b,c;//ax+by+c=0
double x[4],y[4];//p,1,2,3
void make_line(double x1,double y1,double x2,double y2){
	if(x1!=x2&&y1!=y2){
		a=(y1-y2)/(x1-x2);
		b=-1;
		c=-a*x1+y1;
	}else if(x1==x2){
		a=1;
		b=0;
		c=-x1;
	}else if(y1==y2){
		a=0;
		b=1;
		c=-y1;
	}
	return;
}
bool check(int p,int q,int r){
	make_line(x[p],y[p],x[q],y[q]);//line pq
	if((a*x[r]+b*y[r]+c)*(a*x[0]+b*y[0]+c)<=0)return false;
	return true;
}

int main()
{
	while(cin>>x[1]>>y[1]>>x[2]>>y[2]>>x[3]>>y[3]>>x[0]>>y[0]){
		bool ans=true;
		ans&=check(1,2,3);
		ans&=check(2,3,1);
		ans&=check(3,1,2);
		printf(ans?"YES\n":"NO\n");
	}
    return 0;
}

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

using namespace std;
using ll = long long int;
#define long ll

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

    auto f = [&](char x, const string &s) {
        string r = s;
        ll i = 150 - 1;
        while(r[i] != ' ') i--;
        r[i] = x;
        return r;
    };
    while(1) {
        ll w, h;
        cin >> w >> h;
        if(!w) break;

        vector<string> c(h);
        for(auto &l: c) cin >> l;

        vector<vector<string>> dp(h+1, vector<string>(w+1, string(150, ' ')));

        for(ll i=h-1; i>=0; i--)
        for(ll j=w-1; j>=0; j--)
            if('0' <= c[i][j] && c[i][j] <= '9')
                dp[i][j] = f(c[i][j], max(dp[i+1][j], dp[i][j+1]));

        string m = "";
        for(ll i=0; i<h; i++)
        for(ll j=0; j<w; j++) {
            ll k = 0;
            while(dp[i][j][k] == ' ' || dp[i][j][k] == '0') dp[i][j][k++] = ' ';
            m = max(m, dp[i][j]);
        }
        {
            ll i = 0;
            while(m[i] == ' ' || m[i] == '0') i++;
            for(; i<150; i++)
                cout << m[i];
            cout << endl;
        }

    }
}



Measured memory_bytes: 3248
// by Balloons
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define mpr make_pair
#define debug() puts("okkkkkkkk")
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)

using namespace std;

typedef long long LL;

const int inf = 1 << 30;
const int mod=1e9+7,base=2001;
int n;
int a[200005],b[200005],dp[4005][4005];
int fac[200005],inv[200005]; 

int pw(int x,int y){
	if(!y)return 1;if(y==1)return x;
	int mid=pw(x,y>>1);
	if(y&1)return 1ll*mid*mid%mod*x%mod;
	return 1ll*mid*mid%mod;
}

int C(int x,int y){
	return 1ll*fac[x]*inv[x-y]%mod*inv[y]%mod;
}

int main(){
	fac[0]=inv[0]=1;for(int i=1;i<=200000;i++)fac[i]=1ll*fac[i-1]*i%mod;
	inv[200000]=pw(fac[200000],mod-2);
	for(int i=199999;i>=1;i--)inv[i]=1ll*inv[i+1]*(i+1)%mod;
	
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d%d",&a[i],&b[i]),++ dp[base-a[i]][base-b[i]];
	for(int i=1;i<=4001;i++)
		for(int j=1;j<=4001;j++)
			dp[i][j]+=(dp[i-1][j]+dp[i][j-1])%mod,
			dp[i][j]%=mod;
	
	int ans=0;
	for(int i=1;i<=n;i++){
		ans+=dp[a[i]+base][b[i]+base];
		ans-=C((a[i]+b[i])<<1,a[i]<<1);
		ans=(ans%mod+mod)%mod;
	}
	printf("%d\n",1ll*ans*pw(2,mod-2)%mod);

	return 0;
}


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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
template <typename T> bool chmax(T &a, const T& b){if(a < b){a = b;return true;}return false;}
template <typename T> bool chmin(T &a, const T& b){if(a > b){a = b;return true;}return false;}
using ll = long long;

int main()
{
    ll i,j;
    ll n;
    cin >> n;
    vector<ll> d(n+1,0);
    for(i = 1;i <= n;++i){
        cin >> d.at(i);
    }
    sort(all(d));
    vector<ll> tmp;
    for(i = 0;i <= n;++i){
        if(i%2){
            tmp.push_back(d.at(i));
        }else{
            tmp.push_back((24-d.at(i))%24);
        }
    }
    sort(all(tmp));
    ll ans = 1e9;
    for(i = 0;i < n;++i){
        ll t = tmp.at(i+1) - tmp.at(i);
        ans = min(ans, t);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<math.h>
#include<queue>
#include<deque>
#include<map>
#include<bitset>

#define rep(i, n) for(int i = 0;i < (n);i++)
#define rrep(i, n) for(int i = (n);i >= 0;i--)
#define FOR(i, m, n) for(int i = (m);i < (n);i++)

using namespace std;
using ll = long long;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;} return 0;}

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


//////////////////////////////////////////////////


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

    map<ll, ll> m;
    for (int i = 0; i < n+1; i++)
    {
        m[sum[i]]++;
    }

    ll ans = 0;
    for (auto v : m) {
        ans += v.second*(v.second-1)/2;
    }
    
    
    cout << ans << endl;
        
    return 0;
}


Measured memory_bytes: 15104
x = int(input())

dp = [False] * (x+1)
dp[0] = True
for i in range(1,x+1):
    if i < 99:
        continue
    else:
        if dp[i-100]:
            dp[i] = True
        elif dp[i-101]:
            dp[i] = True
        elif dp[i-102]:
            dp[i] = True
        elif dp[i-103]:
            dp[i] = True
        elif dp[i-104]:
            dp[i] = True
        elif dp[i-105]:
            dp[i] = True

if dp[x]:
    print(1)
else:
    print(0)

Measured memory_bytes: 39408
#include <stdio.h>

#define TRAIN_STACK 10

// int[0] is array size
// int[1~] is data itself
// int[n] = 0 ; out of range

int pop ( int* array )
{
    if ( array[0] <= 0 )
    {
        return 0;
    }

    array[0] -= 1;
    return array[array[0] + 1];
}

int push ( int* array, int input )
{
    if ( array[0] >= TRAIN_STACK )
    {
        return 0;
    }

    array[0] += 1;
    array[array[0]] = input;

    return input;
}

int unshift ( int* array, int input )
{
    if ( array[0] >= TRAIN_STACK )
    {
        return 0;
    }

    int i;
    array[0] += 1;
    for ( i = array[0]; i > 1; i-- )
    {
        array[i] = array[i - 1];
    }
    array[1] = input;

    return input;
}

int shift ( int* array )
{
    if ( array[0] <= 0 )
    {
        return 0;
    }

    int i, retval = array[1];

    for ( i = 2; i <= array[0]; i++ )
    {
        array[i - 1] = array[i];
    }
    array[0] -= 1;

    return retval;
}

int main ( void )
{
    int stdinput, i;
    int instack[TRAIN_STACK + 1] = { 0 };
//    int outstack[TRAIN_STACK + 1] = { 0 };

    while ( scanf( "%d", &stdinput ) != EOF )
    {
        if ( stdinput <= 0 )
        {
//            push( outstack, pop( instack ) );
            printf( "%d\n", pop( instack ) );
        }
        else
        {
            push( instack, stdinput );
        }
    }

    /* 出力は同じなのに Wrong Answer になる
    for ( i = 1; i <= outstack[0]; i++ )
    {
        if ( outstack[i] != 0 )
        {
            printf( "%d\n", outstack[i] );
        }
    }
    */

    return 0;
}

Measured memory_bytes: 600
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		int[] a = new int[10];
		for (int i = 0; i < 4; i++) {
			a[sc.nextInt()] = 1;
		}
		if (a[1] == 1 && a[7] == 1 && a[9] == 1 && a[4] == 1) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
}


Measured memory_bytes: 21844
import java.util.Scanner;
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner stdIn= new Scanner(System.in);
        int x = stdIn.nextInt();
        boolean [] xx=new boolean[x];
        int y = stdIn.nextInt();
        for(int i=0;i<y;i++){
            int z = stdIn.nextInt();
            for(int t=0;t<z;t++){
               int a = stdIn.nextInt();
               xx[a-1]=true;
            }
        }
        int count=0;
        for(int i=0;i<xx.length;i++){
            if(!xx[i]){
                count++;
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 46292
n = int(input())

if n == 1:
    print(1)
    print(0)
    exit()
if n == 2:
    print(2)
    print(0)
    print(11)
    exit()

print(n-1)
for i in range(n-1):
    print("1" + "0"*i + "1")
    



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

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

using namespace __gnu_pbds; 
using namespace std;

template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; 
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
typedef long long  ll;
typedef vector<ll> VL;
typedef vector<int> VI;
typedef pair<ll,ll> PLL;
typedef pair<int,int> PII;
#define pb push_back

#define F first
#define S second
#define SZ(a) int((a).size())
#define ALL(a) a.begin(),a.end()
#define fr(i,x,y) for(int i=x;i<y;i++)
#define frr(i,x,y) for(int i=x-1;i>=y;i--)
#define inf 1e18+1
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int mod=1000000007;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll power(ll a,ll b){ll ans=1;while(b!=0){if(b&1){ans*=a;}a=a*a;b>>=1;}return ans;}
ll powerm(ll a,ll b){ll ans=1;while(b!=0){if(b&1){ans*=a;ans%=mod;}a=a*a;a%=mod;b>>=1;}return ans%mod;}
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

void solve()
{
    string str;
    cin>>str;
    ll k;
    cin>>k;
    //vector<string> arr;
    map<string,ll> mp;
    ll n=SZ(str);
    fr(i,0,n)
    {
        string tmp="";
        ll fuck=min(n,(ll)i+6);
        fr(j,i,fuck)
        {
            tmp.pb(str[j]);
            //arr.pb(tmp);
            mp[tmp]=1;
        }
    }
    for(auto i: mp)
    {
        k--;
        if(k==0)
        {
            cout<<i.F<<endl;
            return;
        }
    }
    // sort(ALL(arr));
    // fr(i,0,SZ(arr))
    //     cout<<arr[i]<<endl;
    // cout<<arr[k-1]<<endl;
    return;
}
int main()
{
    IOS;
    ll t=1;
    //cin>>t;
    while(t--)
    {
        //cout<<"Case #"<<pp-t<<":\n";
        solve();
    }
    return 0;
}
/* stuff you should look for
        * int overflow, array bounds
        * special cases (n=1?)
        * do smth instead of nothing and stay organized
        * WRITE STUFF DOWN
*/
/*
recursion - matrix exponential

*/
// BITMASK:
// 1)When some constrall is of the order of 15-20, think of bitmask DP.
// 2)When some constrall is around 40, try out meet in the middle
// 3) See Strings,palindromes,prefix,suffix etc -> KMP,Z algorithm


Measured memory_bytes: 5088
#include <stdio.h>
int main(){
  int H,W,i,j;
  while(1){
    scanf("%d%d",&H,&W);
    if(H==0&&W==0) break;
    for(i=0;i<H;i++){
      for(j=0;j<W;j++){
        printf("#");
      }
      printf("\n");
    }
    printf("\n");
  }
  return 0;
}

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

#define ll long long
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;


int main() {
    int H,W;
    cin >> H >> W;
    string S[60];
    S[0] = '.';
    S[H+1] = '.';
    for(int i=1;i<H+1;i++){
        cin >> S[i];
        S[i] = '.' + S[i] +'.';
    }
    for(int j=0;j<W+1;j++){
        S[0] += '.';
    }
    for(int j=0;j<W+1;j++){
        S[H+1] += '.';
    }
    /*for(int i=0;i<H+2;i++){
    cout << S[i] <<endl;
    }*/
    
    for(int i=1;i<H+1;i++){
        for(int j=1;j<W+1;j++){
            
            int cnt=0;
            
            if(S[i].at(j) != '#'){
            for(int k=-1;k<=1;k++){
                for(int h=-1;h<=1;h++){
                    if(S[i+k].at(j+h) == '#' && S[i].at(j) != '#') cnt++;
                }
            }
            
            
        if(cnt != 0) cout << cnt;
        else if (cnt == 0) cout << 0;
        }
        else cout << '#';
        }
        cout <<endl;
    }
    
    
    
}

Measured memory_bytes: 256
import java.io.*
import java.util.*

const val YES = "Yes"
const val NO = "No"
// 141414...1422222...4141
fun solve(N: Int, a: IntArray){
    val fours = a.count{ it % 4 == 0 }
    val twos = a.count{ it % 2 == 0 && it % 4 != 0 }
    val odds = a.count{ it % 2 != 0}
    val ret = if(twos == 0) fours + 1 else fours
    if(odds > ret) println(NO)
    else println(YES)
    return
}


fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val N = sc.next().toInt()
    val a = IntArray(N)
    for (i in 0 until N) {
        a[i] = sc.next().toInt()
    }
    solve(N, a)
}



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

#ifdef DEBUG
#define PRINT(x)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#x<<" = "<<(x)<<endl;
#define PRINTA(a,first,last)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<(first)<<", "<<(last)<<")"<<endl;\
    for (int _i=(first);_i<(last);++_i){cout<<#a<<"["<<_i<<"] = "<<(a)[_i]<<endl;}
#define PRINTP(p)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#p<<" = ("<<(p.first)<<", "<<(p.second)<<")"<<endl;
#define PRINTI(a,i)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<#i<<"] = "<<#a<<"["<<(i)<<"] = "<<(a)[i]<<endl;
#else
#define PRINT(x)
#define PRINTA(a,first,last)
#define PRINTP(p)
#define PRINTI(a,i)
#endif

#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define MOD 1000000007
//#define MOD 998244353

using namespace std;

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

template <class T, class U> void amax(T& x, U y) {if (x < y) x = y;}
template <class T, class U> void amin(T& x, U y) {if (x > y) x = y;}

template <class T>
using vec2 = vector<vector<T>>;

template <class T>
using vec3 = vector<vector<vector<T>>>;

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

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

    int N;
    cin >> N;
    map<string, int> cnt;
    REP(_, N) {
        string S;
        cin >> S;
        ++cnt[S];
    }

    for (string s: {"AC", "WA", "TLE", "RE"}) {
        cout << s << " x " << cnt[s] << endl;
    }

    return 0;
}



Measured memory_bytes: 3668
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<iomanip>
using namespace std;

long long int gcd(long long int x, long long int y)
{
	if (y == 0) { return x; }
	return gcd(y, x % y);
}

int main(void)
{
	string s;
	cin >> s;
	if (s[2] == s[3] && s[4] == s[5]) { cout << "Yes" << endl; }
	else { cout << "No" << endl; }
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<queue>

using namespace std;
typedef pair<int, int> P;
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)

int W, H;
int sx, sy;
int dx[] = { 0,1,0,-1 };
int dy[] = { 1,0,-1,0 };

int main() {
	while (true) {
		int ans = 0;
		char map[20][20];
		bool d[20][20];
		cin >> W >> H;

		if (W == 0)return 0;

		rep(i, 0, H)rep(j, 0, W) {
			cin >> map[i][j];
			if (map[i][j] == '@') { sy = i; sx = j; }
		}

		queue<P> que;
		rep(i, 0, 20)rep(j, 0, 20)d[i][j] = false;
		que.push(P(sy, sx));
		d[sy][sx] = true;

		while (!que.empty()) {
			P p = que.front();
			que.pop();
			rep(i, 0, 4) {
				int ny = p.first + dy[i];
				int nx = p.second + dx[i];
				if (!(0 <= nx && 0 <= ny && ny < H && nx < W))continue;
				if (map[ny][nx] != '#' && d[ny][nx] != true) {
					d[ny][nx] = true;
					que.push(P(ny, nx));
				}
			}
		}

		rep(i, 0, 20)rep(j, 0, 20) {
			if (d[i][j] == true)ans++;
		}
		cout << ans << endl;
	}
}

//BFSでやってみる


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
#define F first
#define S second
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int main() {
  cout << fixed << setprecision(10);
  ll x,k,d;
  cin >> x >> k >> d;
  x = abs(x);
  ll a = x%d; ll c = x/d;
  ll b = x%d-d; ll e = x/d+1;
  if(k<c){
    cout << x-k*d << endl;
    return 0;
  }else if(k<e){
    cout << x-k*d<< endl;
    return 0;
  }
  if((k-c)%2==0){
    cout << abs(a) << endl;
  }else{
    cout << abs(b) << endl;
  }
}


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

int main()
{


    int n;
    cin >> n;
    vector <pair<long int,int>> a(n+1);
    for (int i=1; i<=n; i++) cin >> a[i].first, a[i].second = i;
    sort(a.rbegin(),a.rend());
    vector <vector <long long int>> dp(n+1,vector <long long int>(n+1));
    dp[0][0] = 0;

    //for (int i=1; i<=n; i++) dp


    for (int i=1; i<=n; i++)
    {
        long long now = a[i-1].first;
        long long pos = a[i-1].second;

            for (int j=0; j<=i; j++)
                {
                    if (j!=i)
                    dp[i][j] = max(dp[i][j], dp[i-1][j] + now * (long long)abs(n-(i-1-j)-pos));
                    if (j)
                    dp[i][j] = max (dp[i][j],dp[i-1][j-1]+now * (long long)abs(j-pos));
                }
    }

                long long res = 0;
            for (int i=0; i<=n; i++) res = max(res,dp[n][i]);

            cout << res;
}




// dp[i][j]


Measured memory_bytes: 34668
N, X = map(int, input().split())

num = [1]
pati = [1]
for i in range(1, N+1):
    num.append(num[i-1]*2 + 3)
    pati.append(pati[i-1]*2 + 1)

def f(N, X): ## レベルＮバーガーのＸ層目までのパティの数
    if N==0:
        return 1
    
    if X==1:
        return 0
    elif 2<=X<=num[N-1]+1:
        return f(N-1, X-1)
    elif X==num[N-1]+2:
        return pati[N-1]+1
    elif num[N-1]+3<=X<=2*num[N-1]+2:
        return pati[N-1]+1 + f(N-1, X-num[N-1]-2)
    else:
        return pati[N]
print(f(N, X))

Measured memory_bytes: 38384
def insertion_sort(a, n, g):
    ct = 0
    for i in range(g, n):
        v = a[i]
        j = i-g
        while j >= 0 and a[j] > v:
            a[j+g] = a[j]
            j -= g
            ct += 1
        a[j+g] = v
    return ct

def interval_list(n):
    m = 0
    gi= 1
    g = []
    while gi <= n:
        m += 1
        g.append(gi)
        gi = 4**m + 3 * 2**(m-1) + 1
        # good convergence
        # http://www.programming-magic.com/20100507074241/
    g.reverse()
    return g


if __name__ == "__main__":
    n = int(input())
    A = list(int(input()) for _ in range(n))
    G = interval_list(n)
    print(len(G))
    print(*G)
    
    ct= 0
    for i in G:
        ct += insertion_sort(A, n, i)
    print(ct)
    print(*A, sep="\n")

Measured memory_bytes: 63096
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

int main() {
  int a, b, t;
  scanf("%d %d %d", &a, &b, &t);

  int s = b * int((t + 0.5) / a);

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

  return 0;
}


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll A, B, K;
    cin >> A >> B >> K;
    ll temp = min(A, K);
    A -= temp;
    B = max(0LL, B - (K - temp));
    cout << A << ' ' << B << endl;
    return 0;
}


Measured memory_bytes: 3656
from itertools import accumulate

N, K = map(int, input().split())
al = list(map(int, input().split()))
syusoku = [N] * N

for _ in range(K):
    s = [0] * N
    for i in range(N):
        left = i - al[i]
        right = i + al[i]
        if left < 0:
            left = 0
        s[left] += 1
        if right + 1 <= N - 1:
            s[right + 1] -= 1
        # print(left,right)
    al = list(accumulate(s))
    # print(al)
    if al == syusoku:
        print(*al)
        #print('end')
        exit()

print(*al)


Measured memory_bytes: 178120
N,K=map(int,input().split())
R,S,P=map(int,input().split())
T=input()
idx={"r":[],"s":[],"p":[]}

pt={"r":P,"s":R,"p":S}
for i in range(N):
    idx[T[i]].append(i)
idxlst={"r":set(idx["r"]),"s":set(idx["s"]),"p":set(idx["p"])}
#print(idx)
value=0
for t in idx:
    for i in range(len(idx[t])-1,-1,-1):
        if idx[t][i] in idxlst[t]:
            a=idx[t][i]-K
            if a in idxlst[t]:
                idxlst[t].remove(a)
    value+=pt[t]*len(idxlst[t])
print(value)


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

using namespace std;

#define ll long long
#define pi pair<int, int>
#define mkp make_pair
#define pb push_back
#define fr first
#define sc second
#define endl '\n'

const int mxn = 1e6 + 5;
const ll MOD = 1e9 + 7;
int arr[mxn];
int n, m, k;
string s;

ll POW(ll A,ll B,ll R=1)
{while(B){if(B&1)R=R*A%MOD;A=A*A%MOD;B>>=1;}return R;}


void read(){
    cin >> n >> m;
//    for(int i = 0, u, v; i < n; i++){
//        cin >> arr[i];
//    }
}

void solve(){
    if(m >= n){
        cout << "unsafe" << endl;
    }else{
        cout << "safe" << endl;
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    int T = 1;
    //cin >> T;
    while(T--) read(), solve();
    return 0;
}


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

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

  int x; cin >> x;

  int res = 1;
  for (int b = 2; b < x / 2; ++b) {
    int tmp = b;
    while (tmp <= x) {
      res = max(res, tmp);
      tmp *= b;
    }
  }

  cout << res << "\n";
}


Measured memory_bytes: 3644
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>
#include <chrono>
#include <random>
#include <bitset>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs
#define tm aklsjdasjdasjdkdjjf
#define lcm hddalkwjeidjjhasda
#define random_shuffle asdasdd

string s;
long long p;

int main() {

  getline(cin, s);
  cin >> p;

  long long sum = 0;
  for (int i = 0; i < sz(s); i++) {
    if (s[i] == '1') {
      sum++;
      if (sum == p) {
        cout << 1 << endl;
        return 0;
      }
    } else {
      cout << s[i] << endl;
      return 0;
    }
  } 

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main() {
	int ans = 0;
	string s; cin >> s;
	for (int i = 0; i < 4; i++) {
		if (s[i] == '+')ans++;
		else ans--;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>

#define isNum(a) (a >= '0' && a <= '9')
#define SP putchar(' ')
#define EL putchar('\n')
#define File(a) freopen(a ".in", "r", stdin), freopen(a ".out", "w", stdout)

template<class T>
inline void read(T&);
template<class T>
inline void write(const T&);

typedef long long ll;
typedef const long long & cll;
typedef const int & ci;
const int iinf = 2147483647;
const ll llinf = 9223372036854775807ll;
ll work(ll, ll);

int main () {
    ll a, b;
    read(a), read(b);
    ll ans = 0;
    for (ll i = 1; i <= b; i <<= 1) {
        if ( (work(b, i) - work(a - 1, i)) & 1) {
            ans |= i;
        }
    }
    write(ans), EL;
    return 0;
}

template<class T>
void read(T &Re) {
    T k = 0;
    char ch = getchar();
    int flag = 1;
    while (!isNum(ch)) {
        if (ch == '-') {
            flag = -1;
        }
        ch = getchar();
    }
    while (isNum(ch)) {
        k = (k << 1) + (k << 3) + ch - '0';
        ch = getchar();
    }
    Re = flag * k;
}
template<class T>
void write(const T &Wr) {
    if (Wr < 0) {
        putchar('-');
        write(-Wr);
    } else {
        if (Wr < 10) {
            putchar(Wr + '0');
        } else {
            write(Wr / 10);
            putchar((Wr % 10) + '0');
        }
    }
}

ll work(ll n, ll i) {
    return (n / (i << 1)) * i + std::max(n % (i << 1) - i + 1, 0ll);
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void push(int);
int pop(void);
int top,S[100];

int main(){
  int a,b;
  char x[100];
 
  top=0;
  while(scanf("%s",x)!=EOF){
    if(x[0]=='+'){
      a=pop();
      b=pop();
      push(a+b);
    }
    else if(x[0]=='-'){
      b=pop();
      a=pop();
      push(a-b);
    }
    else if(x[0]=='*'){
      a=pop();
      b=pop();
      push(a*b);
    }
    else{
      push(atoi(x));
    }
  }
 
  printf("%d\n",pop());
  
  return 0;
}

void push(int x){
  top++;
  S[top]=x;
}

int pop(void){
  top--;
  return S[top+1];
}

Measured memory_bytes: 548
from heapq import heappush, heappop
from itertools import permutations, accumulate, combinations
import math
import bisect
import numpy as np
from collections import defaultdict, deque
from operator import itemgetter
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 6)
# MOD = 10 ** 9 + 7
# INF = float("inf")


def main():
    n = int(input())
    pi = math.pi
    print(2 * n * pi)


if __name__ == '__main__':
    main()

Measured memory_bytes: 27116
#include <stdio.h>

int main()
{
  int x, y, i, a, b, d;
  
  scanf("%d %d", &x, &y);
  
  i = x;
  
  while (i != 0)
  {
    if (x >= y)
    {
      x = x % y;
      
      if( x == 0 )
      {
        d = y;
        i = 0;
      }
    } else {
      y = y % x;
      
      if ( y == 0 )
      {
        d = x;
        i = 0;
      }
    }
  
  }

  
  printf("%d\n", d);
  
  return 0;
}
  

Measured memory_bytes: 592
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int cnt[3] = {};
	string s; cin >> s;
	rep(i, 0, s.size()) {
		cnt[s[i] - 'a']++;
	}
	bool ok = true;
	rep(i, 0, 3)rep(j, 0, 3) {
		if (abs(cnt[i] - cnt[j]) > 1) {
			ok = false;
		}
	}
	if (ok)cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 512
rekkyo :: Integer -> Integer -> [(Integer,Integer)]
rekkyo n k = [(x,y)|(x,y) <- doubles n,check(x,y,k,n)]

doubles :: Integer -> [(Integer,Integer)]
doubles n = [(x,y)|x <- [0..n],y <- [0..n]]

check :: (Integer,Integer,Integer,Integer) -> Bool
check(x,y,k,n) =((0 <= k-x-y) && (k-x-y <= n))

main = do
    [n,k] <- map read . words <$> getLine
    let res = rekkyo n k 
    print (length res)

Measured memory_bytes: 1148
def main():
    N, L = map(int, input().split())
    apple = [ L + i - 1 for i in range(1, N + 1)]
    taste = 0
    tmin = 10**9
    t = sum(apple)
    for i in range(N):
        eat = 0
        for j in range(N):
            if j != i:
                eat += apple[j]
        if abs(eat - t) < tmin:
            tmin = abs(eat - t)
            taste = eat
    print(taste)
main()

Measured memory_bytes: 3060
#include<stdio.h>
int main(void) {
	int n;
	int b[100];
	int max;
	int i;
	max = 0;

	scanf("%d", &n);
	for (i = 1; i < n; i++) {
		scanf("%d", &b[i]);
	}

	for (i = 1; i < n-1; i++) {
		if (b[i] > b[i + 1]) {
			max = max + b[i + 1];
		}
		else {
			max = max + b[i];
		}
	}
	max = max + b[1] + b[n - 1];
	
	printf("%d", max);

	return 0;
}

Measured memory_bytes: 128
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS

main = do
  [a, b] <- getIntList
  putStrLn $ if a == b then "Yes" else "No"


readInt = fst . fromJust . BS.readInteger
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine
getIntNList n = map readIntList <$> replicateM (fromIntegral n ) BS.getLine





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

using namespace std;

#define REP(i,x,y) for (int i=x;i<y;i++)
vector<pair<long long ,long long>> a;
int main()
{
    int n,m;
    cin >> n >> m;
    for (int i=0;i<n;i++)
    {
        int x,y;
        cin >> x>> y;
        a.push_back(make_pair(x,y));
    }
    sort(a.begin(),a.end());
    long long ans=0;
    for (int i=0;i<n&&m;i++)
    {
        if (a[i].second<=m)
        {
            m-=a[i].second;
            ans+=a[i].second*a[i].first;
        }else
        {
            ans+=m*a[i].first;
            m=0;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 100005;

int n, m;
int pre[N];

int main() {
    cin.sync_with_stdio(0); cin.tie(0);
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int a, b; cin >> a >> b;
        pre[a]++; pre[b]--;
    }
    
    int tot = 0;
    for (int i = 1; i <= n; i++) {
        tot += pre[i];
        if (tot % 2) {
            cout << "NO";
            return 0;
        }
    }
    cout << "YES";
}



Measured memory_bytes: 640
H = list(map(int, input().split()))
count = 0

for i in range(1, H[0]+1):
    for k in range(1, H[1]+1):
        if k > 9:
            p = str(k)
            if int(p[-1]) >= 2 and int(p[-2]) >= 2 and int(p[-1]) * int(p[-2]) == i:
                count += 1

print(count)


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

//const int INF=1e9+5;

int main()
{
    int n,W;
    cin>>n>>W;
    vector<long long> dp(W+1);

    for(int i=0;i<n;i++)
    {
        int w,v;
        cin>>w>>v;
        for(int u=W-w;u>=0;u--)
            dp[u+w]=max(dp[u+w],dp[u]+v);
    }
    long long ans=0;
    for(int i=0;i<=W;i++)
    {
        ans=max(ans,dp[i]);

    }
    cout<<ans;
    return 0;
}


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

using namespace std;

#define int long long
#define pb push_back
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)

int path(int now, map<int, bool> pre, vector<vector<int>> gr) {
  pre[now] = true;
  int count = 0;
  bool update = false;
  REP(i, gr[now].size()) {
    if(pre[gr[now][i]] == false) {
      count += path(gr[now][i], pre, gr);
      update = true;
    }
  }

  if(!update) {
    FOR(i, 1, gr.size()) {
      if(pre[i] == false) return 0;
    }
    return 1;
  }

  return count;
}

signed main () {
  cin.tie(0);
  cout << setprecision(10);

  int n, m; cin >> n >> m;
  vector<vector<int>> gr(n+1);
  int a, b;
  REP(i, m) {
    cin >> a >> b;
    gr[a].pb(b);
    gr[b].pb(a);
  }

  map<int, bool> pre;
  int now = 1;
  int count = path(now, pre, gr);

  cout << count << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mp make_pair
#define pii pair<int,int>
#define pdd pair<double,double>
#define pll pair<ll,ll>
#define mst(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const double eps = 1e-9;
const int maxn = 1e6+9;
const double pi=3.14159265358979323846264;
const int inf = 1e9;
const ll mod = 998244353;
string op[maxn];
pii pq[maxn],ui[maxn*3];
void ch(int pos,int x,int k,int l,int r){
    if(l==r-1){
        ui[k]=mp(x,pos);
        return;
    }
    int mid=(l+r)/2,cl=2*k+1,cr=2*k+2;
    if(pos<mid) ch(pos,x,cl,l,mid);
    if(pos>=mid) ch(pos,x,cr,mid,r);
    ui[k]=max(ui[cr],ui[cl]);
}
pii sol(int a,int b,int k,int l,int r){
    if(a>=b) return mp(-inf,0);
    if(a<=l&&b>=r) return ui[k];
    int mid=(l+r)/2,cl=2*k+1,cr=2*k+2;
    pii p1(-inf,0),p2(-inf,0);
    if(a<mid) p1=sol(a,b,cl,l,mid);
    if(b>mid) p2=sol(a,b,cr,mid,r);
    return max(p1,p2);
}
/*
4
(((((
)))))((((((((
))))))((((((((((
))))))))))))
*/
int main()
{
    ios::sync_with_stdio(false);
    int n,num=0,a=0,b=0;
    cin>>n;
    for(int i=0;i<n;++i) cin>>op[i];
    for(int i=0;i<n;++i){
        vector<int> tmp;
        tmp.clear();
        int jk=0,pos=0,kl=op[i].length();
        while(pos<kl){
            if(op[i][pos++]=='(') ++jk;
            else --jk;
            while(jk<0&&pos<kl&&op[i][pos]==')') --jk,++pos;
            if(jk<0){
                tmp.push_back(-jk);
                jk=0;
            }
        }
        int io=0;
        for(int j=0;j<tmp.size();++j) io+=tmp[j];
        jk=max(jk,0);
//        cout<<io<<","<<jk<<endl;
        if(!io) a+=jk;
        else if(!jk) b+=io;
        else pq[num++]=mp(io,jk);
    }
    sort(pq,pq+num);
    for(int i=0;i<num;++i) ch(i,pq[i].second-pq[i].first,0,0,num);
//    for(int i=0;i<num;++i) cout<<pq[i].first<<","<<pq[i].second<<endl;
    int cnt=0,fg=1;
//    cout<<a<<","<<b<<endl;
    while(cnt<num){
        int pos=lower_bound(pq,pq+num,mp(a+1,-inf))-pq;
        pii tmp=sol(0,pos,0,0,num);
//        cout<<a<<","<<pos<<","<<tmp.first<<","<<tmp.second<<endl;
        if(tmp.first==-inf||a+tmp.first<0){
            fg=0;
            break;
        }
        a+=tmp.first;
        ch(tmp.second,-inf,0,0,num);
        ++cnt;
    }
    if(fg&&a-b==0) cout<<"Yes";
    else cout<<"No";
    return 0;
}


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

using namespace std;

//int dirs[4][2]={{-1,0},{1,0},{0,-1},{0,1}};
//int dirs[8][2]={{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};

map<int, int> wa_count;
set<int> accepted;

int main()
{
    ios::sync_with_stdio(false);
    //freopen("inp.in","r",stdin);
    //freopen("outp.out","w",stdout);
    int n, m;
    //scanf("%d %d", &n, &m);
    cin >> n >> m;
    int tot_ac=0;
    int tot_penalty=0;
    for(int i=0; i<m; i++)
    {
        int prob;
        string verdict;
        cin >> prob >> verdict;
        if(verdict=="WA")
        {
            wa_count[prob]++;
        }
        else
        {
            if(accepted.find(prob)!=accepted.end()) continue;
            tot_ac++;
            accepted.insert(prob);
            tot_penalty+=wa_count[prob];
        }
    }
    cout << tot_ac << " " << tot_penalty << endl;
    return 0;
}


Measured memory_bytes: 9600
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;


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

  int a,b;
  cin>>a>>b;
  if(a % 3 == 0 || b % 3 == 0 || (a+b) % 3 == 0) {
    cout<<"Possible"<<endl;
  } else {
    cout<<"Impossible"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
  int N;
  long T;
  long* t;
  cin >> N;
  cin >> T;

  t = (long*)malloc(sizeof(long) * N);
  for (int i = 0; i < N; i++) {
    cin >> t[i];
  }


  long shower = 0;
  for (int i = 1; i < N; i++) {
    shower += min(t[i] - t[i - 1], T);
  }
  shower += T;
  cout << shower << endl;
  return 0;
}


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

int main() {
	int N;
    cin >> N;
    string ans = "No";
    int a = N/100000000;
    int b = N/10000000 - a*10;
    int c = N/1000000 - a*100 - b*10;
    int d = N/100000 - a*1000 - b*100 - c*10;
    int e = N/10000 -a*10000 - b*1000 - c*100 - d*10;
    int f = N/1000 - a*100000 - b*10000 - c*1000 - d*100 - e*10;
    int g = N/100 - a*1000000 - b*100000 - c*10000 - d*1000 - e*100 - f*10;
    int h = N/10 - a*10000000 - b*1000000 - c*100000 - d*10000 - e*1000 - f*100 - g*10;
    int i = N%10;
    int sum = a + b + c + d + e + f + g + h + i;
    if(N%sum == 0){
      ans = "Yes";
    }
    cout << ans << endl;
}

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

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

const ll mod =  1000000007;  //出力は (ans % mod + mod) % mod  (負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL << 60;   // INF = 1152921504606846976

ll pow_k(ll x,ll n){  // xのn乗 (mod m)
    ll res = 1;
    if(n > 0){
        res = pow(x,n / 2);
        if(n % 2 == 0){
            res = (res * res);
        }else{
            res = (((res * res)) * x);
        }
    }
    return res;
}

int main()
{
    string s; cin >> s;
    ll n = s.size();
    ll a[n];
    reverse(s.begin(),s.end());
    int tmp = 10;
    a[0] = s[0] - '0';
    rep(i,n-1){
        a[i+1] = (s[i+1] - '0') * tmp + a[i];
        a[i+1] %= 2019;
        tmp *= 10;
        tmp %= 2019;
    }
    //rep(i,n) cout << a[i] << ' ';
    map<ll,ll> m;
    m[0] = 1;
    rep(i,n){
        m[a[i]]++;
    }
    ll ans = 0;
    rep(i,m.size()){
        int k = m[i];
        ans += (k*(k-1))/2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 5404
#include <bits/stdc++.h>
#define endl '\n';

typedef long long ll;

using namespace std;

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

    int a, b, c;

    cin >> a >> b >> c;

    if (b - a == c - b) {
        cout << "YES";
    } else {
        cout << "NO";
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
package main

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

// func main() {
// 	scanner := makeWordScanner()
// 	n := eGetInt(scanner)
// 	ds := make([]int, n)
// 	for i := 0; i < n; i++ {
// 		ds[i] = eGetInt(scanner)
// 	}
// 	sum := 0
// 	for i := 0; i < n; i++ {
// 		for j := i + 1; j < n; j++ {
// 			sum += ds[i] * ds[j]
// 		}
// 	}
// 	fmt.Println(sum)
// }
func main() {
	scanner := makeWordScanner()
	n := eGetInt(scanner)
	sum, square := 0, 0
	for i := 0; i < n; i++ {
		d := eGetInt(scanner)
		sum += d
		square += d * d
	}
	fmt.Println(((sum * sum) - square) / 2)
}

////////////////////////////////////////////////////////////////////////////////
// ライブラリ
////////////////////////////////////////////////////////////////////////////////
func makeScanner(maxByte int) *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]uint8, 0, 8192), maxByte)
	return scanner
}
func makeWordScanner() *bufio.Scanner {
	scanner := makeScanner(8192)
	scanner.Split(bufio.ScanWords)
	return scanner
}
func eGetLine(r *bufio.Scanner) string {
	if r.Scan() {
		return r.Text()
	}
	err := r.Err()
	if err != nil {
		log.Fatal(err)
	}
	// EOF
	return ""
}
func eGetInt(r *bufio.Scanner) int {
	line := eGetLine(r)
	return eAtoi(line)
}
func eGetInt64(r *bufio.Scanner) int64 {
	line := eGetLine(r)
	return eAtoInt64(line)
}
func eGetFields(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Fields(line)
}
func eGetInts(r *bufio.Scanner) []int {
	fields := eGetFields(r)
	ints := make([]int, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoi(fields[i])
	}
	return ints
}
func eGetInt64s(r *bufio.Scanner) []int64 {
	fields := eGetFields(r)
	ints := make([]int64, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoInt64(fields[i])
	}
	return ints
}
func eGetChars(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Split(line, "")
}
func eAtoi(s string) int {
	n, err := strconv.Atoi(s)
	if err != nil {
		log.Fatal(err)
	}
	return n
}
func eAtoInt64(s string) int64 {
	n, err := strconv.ParseInt(s, 10, 64)
	if err != nil {
		log.Fatal(err)
	}
	return n
}


Measured memory_bytes: 640