akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;
int main(){
	int a[50];
	int n,b,p;
	while(1){
		cin >> n >>p;
		if((n==0)&&(p==0)) break;
		for (int i=0;i<n;i++){
			a[i]=0;
		}
		int i = 0;
		b = p;
		while(1){
		if(b!=0){
			a[i] +=1;
			b -=1;
			if(a[i] == p){
					cout << i <<endl;
					break;
				}
			if(i != n-1) i++;
			else i= 0;
		}
		else {
					b +=a[i] ;
					a[i] = 0;
					if(a[i] == p){
					cout << i <<endl;
					break;
				}
			if(i != n-1) i++;
			else i= 0;

		}
		}
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n;
    cin >> n;
    
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
      cin >> a[i];
    }
    
    int max = a[0];
    int min = a[0];
    for (int i = 1; i < n; i++) {
        
        if (a[i] > max) {
            max = a[i];
        }
        if (a[i] < min) {
            min = a[i];
        }
    }
    
    long long sum = 0;
    for (int i = 0; i < n; i++) {
        sum += a[i];
    }
    
    cout << min << ' ' << max << ' ' << sum << endl;
}


Measured memory_bytes: 3152
N , W = map(int,input().split())
wv = [list(map(int,input().split())) for _ in range(N)]
dp = [[0] * (W+1)  for _ in range(N+1)]
for i in range(0,N):
    for j in range(1,W+1):
        if j >= wv[i][0]:
            dp[i+1][j] = max(dp[i][j-wv[i][0]]+ wv[i][1], dp[i][j])
        else:
            dp[i+1][j] = dp[i][j]

print(dp[N][W])
#print(dp)

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

int main() {
    //変数宣言
    int a, b;

    //入力受付
    cin >> a >> b;
    
    //切り上げ
    int x = (a + b + 1) / 2;

    //出力
    cout << x << endl;
}

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

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

int main(){
    ll n,k;
    cin >> n >> k;
    mint res = 0;
    for(ll i=k; i<=n;++i){
        ll ma,mi;
        //cout << "i " << i;
        mi = i*(i-1)/2;
        ma = n*i-mi;
        res +=ma;
        res -=mi;
        res +=1;
        //cout << "mami " << ma << " "<< mi << endl;
    }
    res +=1;
    cout << res.x << endl;
}

Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int INF = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

int main() {
    ll n, m;
    cin >> n >> m;
    ll ans = min(n, m/2);
    n-=ans; m-=ans*2;
    ans += m/4;
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde) FUNC(printdu);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ in >> p.first >> p.second; return in; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    cout << bool(n % k) << '\n';
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <random>
#define REP(i, n) for (ll i = 0; i < ll(n); ++i)
#define RREP(i, n) for (ll i = ll(n) - 1; i >= 0; --i)
#define FOR(i, m, n) for (ll i = m; i < ll(n); ++i)
#define RFOR(i, m, n) for (ll i = ll(n) - 1; i >= ll(m); --i)
#define ALL(v) (v).begin(), (v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  REP(i, n+1) {
    if (int(i * 1.08) == n) {
      cout << i << endl;
      return 0;
    }
  }
  cout << ":(" << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

	int p,q,r,pos;
	String str;

	void run(){
		Scanner in = new Scanner(System.in);
		for(;;){
			str = in.next();
			if(str.equals(".")) return ;
			System.out.println(solve());
		}
	}

	int formula(){
		char c = str.charAt(pos);
		pos++;
		if(c=='0') return 0;
		if(c=='1') return 1;
		if(c=='2') return 2;
		if(c=='P') return p;
		if(c=='Q') return q;
		if(c=='R') return r;
		if(c=='-'){
			int a = formula();
			return 2-a;
		}
		if(c=='('){
			int a = formula();
			boolean multi = str.charAt(pos)=='*';
			pos++;
			int b = formula();
			pos++;
			if(multi){
				if(a==0||b==0) return 0;
				if(a==2&&b==2) return 2;
				return 1;
			}
			else{
				if(a==2||b==2) return 2;
				if(a==0&&b==0) return 0;
				return 1;
			}
		}
		return -1;
	}

	int solve(){
		int ans = 0;
		for(p=0;p<3;p++){
			for(q=0;q<3;q++){
				for(r=0;r<3;r++){
					pos=0;
					if(formula() == 2) ans++;
				}
			}
		}
		return ans;
	}

	public static void main(String args[]){
		new Main().run();
	}
}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
using namespace std ; 
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fast ios_base:: sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long int
#define endl "\n"
#define pb push_back
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define f first
#define s second
#define pii pair<int,int> 
long long M  = 1e9+7;
 
 
signed main(){
    fast;
    int n,k; cin >> n >> k;
    int p = n/k;
    int ans = 1e18;
    ans = min(ans , abs(n - p*k));
    ans = min(ans , abs(n - (p-1)*k));
    ans = min(ans , abs(n - (p+1)*k));
    cout << ans << endl;
}


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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

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

  int n, m; cin >> n >> m;

  map<int, int> wa;
  map<int, bool> ac;
  int cnt = 0, pena = 0;
  for(int i=0;i<m;++i) {
    int p; string s; cin >> p >> s;
    if(s == "WA") {
      wa[p]++;
    } else {
      if(!ac[p]) {
        ac[p] = true;
        cnt++;
        pena += wa[p];
      }
    }
  }
  cout << cnt << " " << pena << endl;

}


Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    
    string s;
    getline(cin,s);
    ll c=0,m=0;
    for(ll i=0;i<3;i++){
    	if(s[i]=='R'){
    		c++;
    		if(i==2){
    			m=max(c,m);
			}
			else{
				for(ll j=i+1;j<3;j++){
    			if(s[j]=='R'){
    				c++;i=j;m=max(m,c);
				}
				else{m=max(m,c);c=0;
					i=j;break;
				}
			}
			}
		}
	}
	cout<<m<<"\n";
	
	    return 0;
	    
	}


Measured memory_bytes: 3524
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>

typedef  long long ll;

using namespace std;

ll str_to_int(string s){ //数字に変換しちゃうよ
    ll res = 0;
    int digits = s.length();
    for(int i = 0; i < digits; i++)
    {
        res += (s[i] - '0') * pow(10, digits - 1 - i);
    }
    return res;
}

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

    int l = s.length() - 1;

    int n = 1 << l; //+の入れかた何通り？

    ll ans = 0;

    //flags変数で'+'を入れるところを決める
    for(int flags = 0; flags < n; flags++){
        string tmp = "";
        for(int j = 0; j < l; j++){
            tmp += s[j];
            
            //flagsの右からj番目が1のとき，左からj文字目とj+1文字目の間に+が入る
            if((flags >> j & 1) == 1){
                ans += str_to_int(tmp);
                tmp = "";
            }
        }
        tmp += s[l];
        ans += str_to_int(tmp);
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long int
#define mod 1000000007
#define string_mod 2549536629329_base_255
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define ss second
#define all(v) v.begin(), v.end()
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int power(int x, unsigned int y, int p)
{
    int res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res % p;
}
int lcm(int a, int b)
{
    return a / __gcd(a, b) * b;
}
#define MAXN 1000005
int spf[MAXN];
void sieve()
{
    spf[1] = 1;
    for (int i = 2; i < MAXN; i++)
        spf[i] = i;
    for (int i = 4; i < MAXN; i += 2)
        spf[i] = 2;

    for (int i = 3; i * i < MAXN; i++)
    { 
        if (spf[i] == i)
        { 
            for (int j = i * i; j < MAXN; j += i)

                if (spf[j] == j)
                    spf[j] = i;
        }
    }
}
void solve()
{
    sieve();
    int n;
    cin >> n;
    int ans = 0;
    for (int i = 1; i <= n - 1;i++){
        int j = i;
        int g = 1;
        while(j!=1){
            int c=0;
            int k = j;
            while(j%spf[k]==0){
                j /= spf[k];
                c++;
            }
            g *= (c + 1);
        }
        ans += g;
    }
    cout << ans << endl;
}
int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int tc;
    tc = 1;
    //cin >> tc;
    while (tc--)
    {
        solve();
    }

    return 0;
}

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

int main()
{
	int n, m, accnt = 0, wacnt=0;
	cin>>n>>m;
	vector<bool> prob(n);
	vector<int> wacntprob(n);
	for(int i=0;i<n;i++) prob[i] = false;
	for(int i=0;i<m;i++){
		int p;
		string s;
		cin>>p>>s;
		if(s == "AC"){
			if(!prob[p-1]){
				accnt++;
				prob[p-1] = true;
			}
		}
		if(s == "WA"){
			if(!prob[p-1]) wacntprob[p-1]++;
		}
	}
	for(int i=0;i<n;i++){
		if(prob[i]) wacnt += wacntprob[i];
	}
	cout<<accnt<<" "<<wacnt<<endl;
}


Measured memory_bytes: 640
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int[] d = new int[N];
        
        for(int i = 0; i < N; i++) {
            d[i] = Integer.parseInt(sc.next());
        }

        Arrays.sort(d);
        
        int ans = 0;
        if(d[N/2-1] == d[N/2]) {
            System.out.println(ans);
        }else {
            System.out.println(d[N/2] - d[N/2-1]);
        }
    }
}

Measured memory_bytes: 48952
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

T1,T2 = inpl()
A1,A2 = inpl()
B1,B2 = inpl()


d1 = (B1-A1)*T1
d2 = (B2-A2)*T2

if d1+d2 == 0:
    print("infinity")
    sys.exit()
else:
    if d1 > 0 and d2 > 0:
        print(0)
        sys.exit()
    elif d1 < 0 and d2 < 0:
        print(0)
        sys.exit()

    if abs(d1) < abs(d2):
        S = d1 # 初期位置
        d1,d2 = d2,d1
    else:
        S = 0

    if d1 < 0:
        d1 *= -1
        d2 *= -1
        S  *= -1

    # print(S,d1,d2)

    d = d1 + d2
    OK = 0
    NG = 10**100
    while NG-OK > 1:
        mid = (NG+OK)//2
        if mid*d + S <= 0:
            OK = mid
        else:
            NG = mid

    if d*OK + S == 0:
        print(OK*2)
    else:
        print(OK*2+1)


Measured memory_bytes: 4840
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>
#include <cstdio>
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep3(i,a,b) for(int i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>()>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define bs binary_search
#define All(c) (c).begin(),(c).end()
#define mp make_pair
using namespace std;
int in(){int x;scanf("%d",&x);return x;}
string stin(){string s;cin>>s;return s;}
ll lin(){ll x;scanf("%lld",&x);return x;}
int main(){
    int n=in();
    vecll a(n+1),sum(n+1),xsum(n+1);
    sum[0]=xsum[0]=0;
    rep(i,n){
        a[i+1]=lin();
        sum[i+1]=sum[i]+a[i+1];
        xsum[i+1]=xsum[i]^a[i+1];
    }
    ll ans=0,tmp=a[1],xtmp=a[1];
    int l=1,r=1;
    while(l<=n){
        if(tmp==xtmp&r<=n){
                r++;
                tmp+=a[r];
                xtmp^=a[r];
        }else{
            ans+=r-l;
            tmp-=a[l];
            xtmp^=a[l];
            l++;
        }
    }
    cout<<ans<<endl;
}

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

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

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

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

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

int N, A;
int x[111];
ll dp[111][111][5555];

int main() {
   cin >> N >> A;
   rep (i, N) cin >> x[i];

   dp[0][0][0] = 1;
   for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
         for (int k = 0; k <= 5000; k++) {
            dp[i+1][j][k] += dp[i][j][k];
            if (k >= x[i]) {
               dp[i+1][j+1][k] += dp[i][j][k-x[i]];
            }
         }
      }
   }

   ll ans = 0;
   for (int j = 1; j <= N; j++) {
      ans += dp[N][j][j*A];
   }
   cout << ans << endl;

   return 0;
}

Measured memory_bytes: 211200
s = input()
a = [int(s[i]) for i in range(4)]
for i in range(8):
    cur = a[0]
    for j in range(3):
        if (i >> j) & 1:
            cur += a[j + 1]
        else:
            cur -= a[j + 1]
    if cur == 7:
        s = str(a[0])
        for j in range(3):
            if (i >> j) & 1:
                s += "+"
            else:
                s += "-"
            s += str(a[j + 1])
        s += "=7"
        print(s)
        break



Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define REPD(i,a,b) for (int i=(a);i<(b);i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef vector<string> vs;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef set<int> si;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> pi;
typedef queue<pi> qpi;
typedef pair<ll, ll> pll;
typedef queue<pll> qpll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
const int mod = 1000000007;
const int INF = 1001001001;
// 小数点　<< fixed << setprecision(0) <<
// sort降順　sort(ALL(),greater<int>());
// 円周率　M_PI
// 文字判定　isupper islower
// 順列　do {} while(next_permutation(ALL(X)));
// 最大値　LLONG_MAX
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
struct edge {
    int from; //出発点
    int to;   //到達点
    int cost; //移動コスト
};
typedef struct edge se;
typedef vector<edge> ve;
unsigned euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) return euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
int main() {
    int n,k;
    cin >> n >> k;
    vi check(n,0);
    REP(i,k) {
        int d;
        cin >> d;
        REP(j,d) {
            int x;
            cin >> x;
            check[x-1]++;
        }
    }
    int ans=0;
    REP(i,n) {
        if(check[i]==0) ans++;
    }
    cout << ans << endl;
  return 0;
}


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

using namespace std;


int main(){
 long n;
  cin >> n;
   
   if(!n) {cout << 0 << endl;
           return 0;
          }
  
  string res="";
 long pow=1;
  while(n){
    if(n%(2*abs(pow))) {
      res+='1';
      n-=pow;
    }   
    else {
      res+='0';
    }
    pow*=(-2);
    
  }
 
  reverse(res.begin(),res.end());
  
 cout << res << endl;
}  

Measured memory_bytes: 256
#include<iostream>
 
typedef long long ll; 
using namespace std;
 
int main(){
    ll w, h, x, y; cin >> w >> h >> x >> y;
    bool b = (w / 2.0 == x) && (h / 2.0 == y); 
 
    cout << w * h / 2.0 << ' ' << b;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) \
  SORT(var);       \
  REVERSE(var)
#define OPTIMIZE_STDIO         \
  ios::sync_with_stdio(false); \
  cin.tie(0);                  \
  cout.precision(10);          \
  cout << fixed
#define endl '\n'

const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
struct mint {
  ll x;
  mint() : x(0) {
  }
  mint(ll x) : x((x % MOD + MOD) % MOD) {
  }
  mint& operator+=(const mint& r) {
    if ((x += r.x) >= MOD) {
      x -= MOD;
    }
    return *this;
  }
  mint& operator-=(const mint& r) {
    if ((x -= r.x) < 0) {
      x += MOD;
    }
    return *this;
  }
  mint& operator*=(const mint& r) {
    if ((x *= r.x) > MOD) {
      x %= MOD;
    }
    return *this;
  }
  mint& operator++() {
    if ((++x) >= MOD) {
      x -= MOD;
    }
    return *this;
  }
  mint operator++(int) {
    mint ret = x;
    if ((++x) >= MOD) {
      x -= MOD;
    }
    return ret;
  }
  mint& operator--() {
    if ((--x) < 0) {
      x += MOD;
    }
    return *this;
  }
  mint operator--(int) {
    mint ret = x;
    if ((--x) < 0) {
      x += MOD;
    }
    return ret;
  }
  mint operator+(const mint& r) {
    mint ret;
    return ret = x + r.x;
  }
  mint operator-(const mint& r) {
    mint ret;
    return ret = x - r.x;
  }
  mint operator*(const mint& r) {
    mint ret;
    return ret = x * r.x;
  }
  mint operator-() {
    return mint() - *this;
  }
  bool operator<(const mint& a) {
    return x < a.x;
  }
  bool operator>(const mint& a) {
    return x > a.x;
  }
  bool operator<=(const mint& a) {
    return x <= a.x;
  }
  bool operator>=(const mint& a) {
    return x >= a.x;
  }
  bool operator==(const mint& a) {
    return x == a.x;
  }
  bool operator!=(const mint& a) {
    return x != a.x;
  }
};
ostream& operator<<(ostream& os, const mint& r) {
  os << r.x;
  return os;
}
ostream& operator>>(ostream& os, const mint& r) {
  os >> r.x;
  return os;
}

void solve(istream& cin, ostream& cout) {
  int n;
  cin >> n;
  vector<int> a(n);
  REP(i, n) cin >> a[i];
  map<int, int> mp;
  ll ans = 0;
  REP(i, n) {
    int jx = i - a[i];
    ans += mp[jx];
    int ix = a[i] + i;
    mp[ix]++;
  }
  cout << ans << endl;
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
  return 0;
}
#endif


Measured memory_bytes: 20940
while true
  a,op,b = gets.split(" ")
  a = a.to_i
  b = b.to_i
  case op
    when "+"
      puts a + b
    when "-"
      puts a - b
    when "*"
      puts a * b
    when "/"
      puts a / b
    else
      break
  end
end

Measured memory_bytes: 8712
#include <stdio.h>
using namespace std;
int main ()
{
    double v,t,y,n,i;
    while(scanf("%lf",&v)!=EOF){
        y=4.9*(v/9.8)*(v/9.8);
        for(i=1;;i++){
            if(y-5>0) y=y-5;
            else if(y-5<=0)break;
        }
        printf("%d\n",(int)i+1);
    }
    return 0;
}

Measured memory_bytes: 1052
import java.io.*;
import java.util.*;

public class Main {
  public static void main(String... args) {
    BufferedReader br = new BufferedReader(
      new InputStreamReader(System.in));

    try {
      int n = Integer.parseInt(br.readLine());
      System.out.println((int)Math.pow(n, 3));
    } catch(IOException e) {
      e.printStackTrace();
    }
  }
}

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

int main(int argc, const char * argv[]) {
    int N;
    cin>>N;
    int maxZ=0,minZ=0,maxW=0,minW=0;
    for(int i=0;i<N;++i){
        int x,y;
        cin>>x;
        cin>>y;
        int z=x+y;
        int w=x-y;
        if(i==0){
            maxZ=minZ=z;
            maxW=minW=w;
        }else{
            if(maxZ<z){
                maxZ=z;
            }else if(z<minZ){
                minZ=z;
            }
            if(maxW<w){
                maxW=w;
            }else if(w<minW){
                minW=w;
            }
        }
    }
    long dz=(long)maxZ-minZ,dw=(long)maxW-minW;
    cout<<((dz<dw)?dw:dz)<<endl;
    
    return 0;
}


Measured memory_bytes: 3188
#include<iostream>
#include<algorithm>
#include<numeric>
#include<iomanip>
using namespace std;

int main()
{
	int a, b, c, temp;
	cin >> a >> b >> c;
	temp = a;
	a = b;
	b = temp;
	temp = a;
	a = c;
	c = temp;
	cout << a << " " << b << " " << c << endl;
}






Measured memory_bytes: 256
n, t = map(int, input().split(' '))
tlist = list(map(int, input().split(' ')))

sum_time = 0
for i in range(1, len(tlist)):
    delta = tlist[i] - tlist[i-1]
    shower = delta if delta <= t else t
    sum_time += shower
sum_time += t
print(sum_time)


Measured memory_bytes: 25200
N = int(input())
num = []
while N != 0:
  num.append(N%10)
  N -= N%10
  N /= 10
a=num[2]
b=num[1]
c=num[0]
if a==b>=c:
  print(int(100*a+11*b))
if a==b<c or a<b:
  print(int((a+1)*111))
if a>b:
  print(int(a*111))

Measured memory_bytes: 3064
#include<stdio.h>
#include<algorithm>
using namespace std;
int b[110];
int dp[110][350];
int main(){
	int T;scanf("%d",&T);
	while(T--){
		int a;scanf("%d",&a);
		for(int i=0;i<a;i++)scanf("%d",b+i);
		if(a==1){
			printf("%d\n",b[0]);continue;
		}
		for(int i=0;i<110;i++)for(int j=0;j<350;j++)
			dp[i][j]=-999999999;
		dp[1][b[0]]=b[1];
		for(int i=1;i<a-1;i++){
			for(int j=0;j<350;j++){
				if(dp[i][j]<0)continue;
				if(dp[i][j]){
					dp[i+1][dp[i][j]-1]=max(dp[i+1][dp[i][j]-1],b[i+1]+j);
				}
				dp[i+1][dp[i][j]]=max(dp[i+1][dp[i][j]],b[i+1]);
			}
		}
		int ret=0;
		for(int i=0;i<350;i++)ret=max(ret,dp[a-1][i]);
		printf("%d\n",ret);
	}
}

Measured memory_bytes: 1176
#include <iostream>
#include <string>

int main(void)
{
    std::string S;
    std::cin >> S;

    if(S[0] == S[1] && S[2] == S[3] && S[0] != S[3])
    {
        std::cout << "Yes" << std::endl;
    }

    else if(S[0] == S[2] && S[1] == S[3] && S[0] != S[1])
    {
        std::cout << "Yes" << std::endl;
    }

    else if(S[0] == S[3] && S[1] == S[2] && S[0] != S[1])
    {
        std::cout << "Yes" << std::endl;
    }

    else
    {
        std::cout << "No" << std::endl;
    }

    return 0;
}

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

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> A(M), B(M);
    vector<int> G[N];
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        A[i] = a; B[i] = b;
        G[a].push_back(b); G[b].push_back(a);
    }

    int res = 0;
    for (int i = 0; i < M; i++) {
        vector<bool> visited(N, false);

        queue<int> que;
        que.push(0);
        visited[0] = true;

        while (!que.empty()) {
            int u = que.front(); que.pop();
            for (int j = 0; j < G[u].size(); j++) {
                int v = G[u][j];
                if (!visited[v] && ((u != A[i] && u != B[i]) || (v != A[i] && v != B[i]))) {
                    que.push(v);
                    visited[v] = true;
                }
            }
        }

        for (int j = 0; j < N; j++) {
            if (!visited[j]) {
                res++;
                break;
            }
        }
    }
    cout << res << endl;
    return 0;
}

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

int main(void){
    // Your code here!
    int H,W,D;
    cin>>H>>W>>D;
    int a;
    vector<complex<int>> v(W*H,complex<int>(0,0));
    vector<int> ans(W*H,0);
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin>>a;
            v[a-1]=complex<int>(i,j);
        }
    }
    for(int i=D;i<H*W;i++){
        ans[i]+=(ans[i-D]+fabs(v[i].real()-v[i-D].real())+fabs(v[i].imag()-v[i-D].imag()));
    }
    int Q;
    cin>>Q;
    int L,R;
    for(int i=0;i<Q;i++){
        cin>>L>>R;
        cout<<ans[R-1]-ans[L-1]<<endl;
    }
}


Measured memory_bytes: 2176
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <complex>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;

int main() {
    ll n, q;
    cin >> n >> q;

    string str;
    cin >> str;

    int sum[n], ac[n];
    sum[0] = 0;
    ac[0] = 0;

    for (ll i = 1; i < n; i++) {
        if (str[i - 1] == 'A' && str[i] == 'C') ac[i] = 1;
        else ac[i] = 0;
        sum[i] = sum[i - 1] + ac[i];
    }

    ll l, r;
    for (ll i = 0; i < q; i++) {
        cin >> l >> r;
        cout << sum[r - 1] - sum[l - 1] << endl;
    }
}


Measured memory_bytes: 1792
import qualified Data.Map.Strict as M
import Control.Monad
import Data.Maybe

keys :: [String]
keys = ["AC", "WA", "TLE", "RE"]

defaultDict :: M.Map String Int
defaultDict = M.fromList . zip keys $ repeat 0

count :: M.Map String Int -> [String] -> M.Map String Int
count = let inc = M.update (\x -> Just (x + 1))
        in foldl (flip inc)

formatLn :: M.Map String Int -> String -> String
formatLn m k = let c = fromMaybe 0 (m M.!? k)
               in k ++ " x " ++ show c

main :: IO ()
main = do
  n <- readLn
  xs <- replicateM n getLine
  let dict = count defaultDict xs
  mapM_ (putStrLn . formatLn dict) keys


Measured memory_bytes: 32360
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double PI = acos(-1);
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;

int main() {
  int H,W,A,B; cin >> H >> W >> A >> B;
  Graph Data(H, vector<int>(W));
  
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (i < B && j < A) Data[i][j] = 1;
      else if (i >= B && j >= A) Data[i][j] = 1;
      else Data[i][j] = 0;
    }
  }
  
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) cout << Data[i][j];
    cout << endl;
  }
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
int main()	{
  int n;
  cin>>n;
  vector<int>a(n);
  rep(i,n) cin>>a[i];
  vector<int>t(n);
  rep(i,n) t[a[i]-1]=i+1;
  rep(i,n) cout<<t[i]<<" ";
  cout<<endl;
  
}

Measured memory_bytes: 1664
from itertools import accumulate

N,M,K = map(int, input().split())
A = [0] + list(map(int, input().split()))
B = [0] + list(map(int, input().split()))

accA = list(accumulate(A))
accB = list(accumulate(B))

maxbook = 0
idx_B = M
for idx_A in range(N+1):
    time = accA[idx_A]
    for j in range(idx_B, -1, -1):
        if time + accB[j] <= K:
            idx_B = j
            break
    if time + accB[idx_B] <= K:
        maxbook = max(maxbook, idx_A + idx_B)

print(maxbook)

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

#define ll unsigned long long
ll n;
ll sum(ll n)
{
    ll ans = 0;
    while(n)
    {
        ans += (n % 10);
        n /= 10;
    }
    return ans+n;
}
int main()
{
    scanf("%lld",&n);
    if(n == 0)
        printf("Yes");
    else
    {
        ll ans = sum(n);
        if(!(n%ans))
            cout << "Yes";
        else
            cout << "No";
    }
    return 0;
}



Measured memory_bytes: 3712
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <iomanip>
#include <iostream>
#include <limits>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;

template<typename T>
vector<T> make_vec_nd(T init, size_t size) {
    return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, size_t size, Args... rest) {
    auto inner = make_vec_nd(init, rest...);
    return vector<decltype(inner)>(size, inner);
}

template<typename INT>
struct ListCostGraph {
    struct Edge {
        size_t from;
        size_t to;
        INT cost;
    };
    vector<vector<Edge>> edges;
    
    ListCostGraph(size_t size) { edges.resize(size); }
    
    void add_edge(size_t from, size_t to, INT cost) {
        edges[from].push_back(Edge{from, to, cost});
    }
    
    void add_edge_bidir(size_t a, size_t b, INT cost) {
        add_edge(a, b, cost);
        add_edge(b, a, cost);
    }
    
    vector<INT> topological_sort_if_dag() {
        vector<INT> ans;
        vector<uint8_t> visit_flag(edges.size(), 0);
        for (INT i = 0; i < edges.size(); i++) {
            topological_sort_visit(i, visit_flag, ans);
        }
        reverse(ans.begin(), ans.end());
        return ans;
    }
    
    void topological_sort_visit(INT v, vector<uint8_t>& visit_flag, vector<INT>& out_sorted) {
        if (visit_flag[v] == 1) {
            throw "Not DAG";
        }
        if (visit_flag[v] == 2) {
            return;
        }
        visit_flag[v] = 1;
        for (Edge e : edges[v]) {
            topological_sort_visit(e.to, visit_flag, out_sorted);
        }
        visit_flag[v] = 2;
        out_sorted.push_back(v);
    }
};

int main() {
    ll N, M;
    cin >> N >> M;
    ListCostGraph<ll> graph(N);
    for (ll i = 0; i < M; i++) {
        ll xi, yi;
        cin >> xi >> yi;
        xi--;
        yi--;
        graph.add_edge(xi, yi, 0);
    }
    vector<ll> sorted = graph.topological_sort_if_dag();
    vector<ll> inv_sorted(N);
    for (ll i = 0; i < N; i++) {
        inv_sorted[sorted[i]] = i;
    }
    vector<ll> dp(N, 0);
    for (ll i = 0; i < N; i++) {
        for (ListCostGraph<ll>::Edge e : graph.edges[sorted[i]]) {
            dp[inv_sorted[e.to]] = max(dp[inv_sorted[e.to]], dp[i] + 1);
        }
    }
    cout << *max_element(dp.begin(), dp.end()) << endl;
}



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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

map<ll, ll> M;

int main()
{
    ll N;
    cin >> N;
    ll ans = 0;
    ll s = 0;
    M[s]++;
    REP(i, N)
    {
        ll a;
        cin >> a;
        s += a;
        ans += M[s];
        M[s]++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 12800
#include<stdio.h>
#include<stdlib.h>

int main()
{
    int n,i;
    char s[256]={0};
    char t[256]={0};
    char u[256]={0};
    scanf("%d",&n);
    scanf("%s",s);
    scanf("%s",t);
    for(i=0;i<n;i++)
    {
        u[i*2]=s[i];
        u[i*2+1]=t[i];
    }
    printf("%s\n",u);
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long n;
  cin >> n;

  int result=11;
  long long loopMax = (long long)sqrt(n) + 1;
  for (long long a=1;a<loopMax;a++){
    if (n%a!=0)continue;

    long long b = n / a;
    int len=0;
    for (long long ab = max(a,b);;){
      ab /= 10;
      len++;
      if (ab==0)break;
    }
    result=min(len,result);
  }

  cout << result << endl;
  
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[]args) {
		Scanner sc = new Scanner(System.in);

		int A = 0,B = 0,x = 0;

		A = sc.nextInt();
		B = sc.nextInt();
		x = A * B * 3;
		x = x % 2;

		if(x != 0) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <algorithm>

constexpr int NUM = 100001;
int dp[NUM] = { 0 };

int main() {
	int n, d, money;
	std::cin >> n >> d >> money;

	std::vector<std::vector<int>> p;
	for (int i = 0; i < d; i++) {
		p.push_back(std::vector<int>());
		for (int j = 0; j < n; j++) {
			int dd = 0;
			std::cin >> dd;
			p.back().push_back(dd);
		}
	}

	int y = money;
	for (int i = 0; i < NUM; i++) dp[i] = i;

	for (int i = 0; i < d - 1; i++) {
		int m = 0;
		for (int j = 0; j <= y; j++) dp[j] = j;
		for (int j = 0; j < n; j++) {
			for (int k = 1; k <= y; k++) {
				if (k - p[i][j] >= 0) dp[k] = std::max(dp[k], dp[k - p[i][j]] + p[i + 1][j]);
			}
		}
		y = dp[y];
	}
	std::cout << y << std::endl;
	return 0;
}

Measured memory_bytes: 3500
#include <bits/stdc++.h>
#define inchar			getchar
#define outchar(x)		putchar(x)
#define ll long long 
#define int long long //
#define all(v) v.begin(), v.end()
#define SP outchar(' ')
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl;
#define LN outchar('\n')
using namespace std;

template<typename T> void inpos(T &x){x=0;register T c=inchar();while(((c<48)||(c>57))&&(c!='-'))c=inchar();bool neg=0; if(c=='-')neg=1;for(;c<48||c>57;c=inchar());for(;c>47&&c<58;c=inchar())x=(x<<3)+(x<<1)+(c&15);if(neg)x=-x;}
template<typename T> void outpos(T n){if(n<0){outchar('-');n*=-1;}char snum[65];int i=0;do{snum[i++]=n%10+'0';n/=10;}while(n);i=i-1;while(i>=0)outchar(snum[i--]);}
inline void instr(char *str){register char c=0;register int i=0;while(c<33)c=inchar();while(c!='\n'&&c!=' '&&c!=EOF){str[i]=c;c=inchar();++i;}str[i]='\0';}


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

	int n;cin>> n;int k ; cin >> k;vector <int> arr(n);
	for(int i = 0; i<n;i++) {
		cin >> arr[i];
	}
	vector <int> minCost(n);
	minCost[0] = 0;
	// minCost[1] = abs(arr[1] - arr[0]);
	for(int i = 1; i<n;i++) {
		int j = i-1;
		int minC = INT_MAX;
		while (j>=0 && i-j<=k) {
			minC = min(minC,minCost[j] + abs(arr[j] - arr[i]) )
			;j--;
		}

		
		minCost[i] = minC;
	}
	cout << minCost.back() <<endl; 
	
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

int main() {
	long long a, b, x;
	cin >> a >> b >> x;

	long long ans = 0;
	if (a == 0) {
		ans = b / x + 1;
	} else {
		ans = b / x - (a - 1) / x;
	}

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


Measured memory_bytes: 256
from collections import deque, Counter as cnt
from collections import defaultdict as dd
from operator import itemgetter as ig
from bisect import bisect_right as bsr
from math import factorial, ceil, floor
import sys
sys.setrecursionlimit(1000000)

# お約束
args = None
INF = float("inf")
MOD = int(1e9 + 7)


def input(*ps):
    if type(ps[0]) is list:
        return [input(*ps[0][:-1]) for _ in range(ps[0][-1])]
    elif len(ps) == 1:
        return ps[0](next(args))
    else:
        return [p(next(args)) for p in ps]


def nlist(n, v):
    if not n:
        return [] if type(v) is list else v
    return [nlist(n[1:], v) for _ in range(n[0])]


def yesno(v):
    print(["Yes", "No"][not v])


# エントリーポイント
def main():
    S, Q = input(str, int)
    front, end, state = "", "", 0
    for _ in range(Q):
        t = int(next(args))
        if t == 1:
            state = (state + 1) % 2
            continue
        F, C = int(next(args)), str(next(args))
        if state == 0:
            if F == 1:
                front = C + front
            else:
                end = end + C
        else:
            if F == 1:
                end = end + C
            else:
                front = C + front
    ans = front + S + end
    if state == 1:
        ans = end[::-1] + S[::-1] + front[::-1]
    print(ans)


if __name__ == '__main__':
    args = iter(sys.stdin.read().split())
    main()


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

int main() {
    string s;
    cin>>s;
    if(s=="ABC"){
        cout<<"ARC"<<endl;
    }else{
        cout<<"ABC"<<endl;
    }
}

Measured memory_bytes: 3588
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {
	private	static	BufferedReader	br = null;

	static {
		br = new BufferedReader(new InputStreamReader(System.in));
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		double[][]	point = null;

		while ((point = parsePoint()) != null) {
			System.out.printf("%.6f %.6f\n", point[3][0], point[3][1]);
		}
	}

	private static double[][] parsePoint() {
		String		line  = null;
		String[]	split = null;
		double[][]	point = null;

		if ((line = parseStdin()) != null) {
			if (!line.isEmpty()) {
				split       = line.split(",");
				point       = new double[4][3];
				point[0][0] = Double.parseDouble(split[2]) - Double.parseDouble(split[0]);
				point[0][1] = Double.parseDouble(split[3]) - Double.parseDouble(split[1]);
				point[0][2] = distance(point[0]);
				point[1][0] = Double.parseDouble(split[4]) - Double.parseDouble(split[0]);
				point[1][1] = Double.parseDouble(split[5]) - Double.parseDouble(split[1]);
				point[1][2] = distance(point[1]);
				point[2][0] = product(point[0], point[1]);
				point[2][1] = cross(point[0], point[1]);
				point[2][2] = -Math.atan2(point[2][1], point[2][0]);
				point[3][0] = (point[0][0] * Math.cos(point[2][2]) - point[0][1] * Math.sin(point[2][2]));
				point[3][0] = point[3][0] / point[0][2] * point[1][2];
				point[3][0] = point[3][0] + Double.parseDouble(split[0]);
				point[3][1] = (point[0][0] * Math.sin(point[2][2]) + point[0][1] * Math.cos(point[2][2]));
				point[3][1] = point[3][1] / point[0][2] * point[1][2];
				point[3][1] = point[3][1] + Double.parseDouble(split[1]);
			}
		}

		return point;
	}

	// ベクトルの内積
	private static double product(double[] v1, double[] v2) {
		return (v1[0] * v2[0] + v1[1] * v2[1]);
	}

	// ベクトルの外積
	private static double cross(double[] v1, double[] v2) {
		return v1[0] * v2[1] - v1[1] * v2[0];
	}

	// ベクトル距離
	private static double distance(double[] v) {
		return Math.sqrt(v[0] * v[0] + v[1] * v[1]);
	}

	private static String parseStdin() {
		String	stdin = null;

		try {
			stdin = br.readLine();
		}
		catch (IOException e) {}

		return stdin;
	}
}

Measured memory_bytes: 15136
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vector<vector<int>>;
const int INF = 1e9 + 1;
const ll LLINF = 1e18;
const int MOD = 1e9 + 7;

int main() {
    int N, K;
    cin >> N >> K;
    cout << (N % K ? 1 : 0) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace __gnu_pbds; 
using namespace std;

using   ll=long long;
using   ld=long double;

#define fast        	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ordered_set 	tree<pll, null_type,less<pll>, rb_tree_tag,tree_order_statistics_node_update>
#define endl        	"\n"
#define int         	long long int  
#define pb          	push_back
#define mp          	make_pair
#define F           	first
#define S           	second
#define pll         	pair<ll,ll>
#define vec     		vector<ll>
#define ALL(v)      	v.begin(),v.end()
#define ALLR(v)     	v.rbegin(),v.rend()
#define pii         	3.14159265358979323
#define inf     		LLONG_MAX
#define ones(x)     	__builtin_popcount(x)
#define fill(a,b)   	memset(a,b,sizeof(a))
#define mod     		1000000007

ll mod_pow(ll a,ll b)
{
    ll res = 1;
    
    while(b)
    {
        if(b&1) res=(res*a)%mod;
        a=(a*a)%mod;
        b>>=1;
    }
    
    return res;
}

void solve()
{
	ll n;
	
	cin>>n;
	
	vector<ll> a(n);
	
	map<ll,ll> frq;
	
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		
		frq[a[i]]++;
	}
	
	ll cnt = 0;
	
	for(auto u:frq)
	{
		cnt = cnt + (u.S*(u.S-1))/2;
	}
	
	for(int i=0;i<n;i++)
	{
		cout<<cnt-frq[a[i]]+1<<endl;
	}
}
 
signed main()
{
 
    fast;
 
    ll t;
    
    t=1;
    
    //cin>>t;
    
    while(t--)
    {
        solve();
    }
 
    return 0;
}


Measured memory_bytes: 11136
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)x.size())
#define ref(i,x,y)for(int i=x;i<=y;++i)
using namespace std;
typedef long long LL;
char a[300010];int f[300010][2];
void upd(int&a,int b){if(b>a)a=b;}
int main(){
	scanf("%s",a+1);
	f[0][0]=1;
	ref(i,0,strlen(a+1)-1)ref(j,0,1)if(f[i][j]){
		upd(f[i+(j^1)+1][j^1],f[i][j]+1);
		if(j==0&&a[i]!=a[i+1])upd(f[i+(j)+1][j],f[i][j]+1);
		if(j==1&&(a[i]!=a[i+2]||a[i-1]!=a[i+1]))upd(f[i+(j)+1][j],f[i][j]+1);
	}
	cout<<max(f[strlen(a+1)][0],f[strlen(a+1)][1])-1<<endl;
}

Measured memory_bytes: 2048
#include <iostream>
#include <utility>
#include <string>
#include <algorithm>

using namespace std;

int main(int argc, char const *argv[])
{
    int N;
    cin >> N;
    string S;
    int P;
    pair<pair<string, int>, int> memo[100];
    for (int i = 0; i < N; i++)
    {
        cin >> S >> P;
        memo[i] = make_pair(make_pair(S, -1 * P), i + 1);
    }
    
    sort(memo, memo + N);

    for (int i = 0; i < N; i++)
    {
        cout << memo[i].second << endl;
    }

    return 0;
}

Measured memory_bytes: 256
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

# Aでxの根を求める
def find(A,x):
    p = A[x]
    if p == x: return x
    a = find(A,p)
    A[x] = a
    return a
# Aでxとyの属する集合の併合
def union(A, x, y):
    if find(A,x) > find(A,y):
        bx, by = find(A,y), find(A,x)
    else:
        bx, by = find(A,x), find(A,y)
    A[by] = bx # 根をbxに統一

N, M = lr()
V = [x for x in range(N+1)]
for _ in range(M):
    x, y, z = lr()
    if find(V, x) != find(V, y):
        union(V, x, y)

V = [find(V, x) for x in V]
s = set(V[1:])
answer = len(s)
print(answer)
# 55


Measured memory_bytes: 14616
// abc135_c
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N;
    cin >> N;
    vector<ll> A(N+1), B(N);
    REP(i, N+1) cin >> A[i];
    REP(i, N) cin >> B[i];

    ll before = accumulate(ALL(A), 0ll);

    REP(i, N){
        if (B[i] >= A[i]) {
            B[i] -= A[i];
            A[i] = 0;

            A[i+1] = max(0ll, A[i+1] - B[i]);
        } else {
            A[i] -= B[i];
        }
    }
    ll after = accumulate(ALL(A), 0ll);

    print(before - after);

    return 0;
}


Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

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

		String s = br.readLine();
		String[] array = s.split(" ");

		int count1 = 0;
		int count2 = 0;
		for (int i = 0; i < 3; i++) {
			if (Integer.parseInt(array[i]) == 5) {
				count1 += 1;
			} else if (Integer.parseInt(array[i]) == 7) {
				count2 += 1;
			}
		}
		if (count1 == 2 && count2 == 1) {
			System.out.println("YES");
		} else {
			System.out.print("NO");
		}
	}
}


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

int main(){
  	int A, B, C, D;
  	cin >> A >> B >> C >>D;
  	
  	while(A>0 || C>0){
    	C-=B;
      	if(C<=0){
        	cout << "Yes" << endl;
          	return 0;
        }
      	A-=D;
      	if(A<=0){
        	cout << "No" << endl;
          	return 0;
        }
    }
}

Measured memory_bytes: 3640
// C Vacation

#include <algorithm>
#include <iostream>
#include <limits>
#include <vector>

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  vector<int> b(N);
  vector<int> c(N);

  for (int i = 0; i < N; ++i) {
    cin >> a[i] >> b[i] >> c[i];
  }
  vector<int> dp_a(N + 1, numeric_limits<int>::max());
  vector<int> dp_b(N + 1, numeric_limits<int>::max());
  vector<int> dp_c(N + 1, numeric_limits<int>::max());
  dp_a[0] = 0;
  dp_b[0] = 0;
  dp_c[0] = 0;

  for (int i = 1; i <= N; ++i) {
    dp_a[i] = a[i - 1] + max(dp_b[i - 1], dp_c[i - 1]);
    dp_b[i] = b[i - 1] + max(dp_a[i - 1], dp_c[i - 1]);
    dp_c[i] = c[i - 1] + max(dp_a[i - 1], dp_b[i - 1]);
  }
  cout << max({dp_a[N], dp_b[N], dp_c[N]}) << endl;
  return 0;
}



Measured memory_bytes: 2560