akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_set>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>

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

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

typedef long long ll;

using namespace std;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int x,y,z,k;
  cin>>x>>y>>z>>k;
  vector<ll>a(x),b(y),c(z);
  rep(i,x)cin>>a[i];
  rep(i,y)cin>>b[i];
  rep(i,z)cin>>c[i];
  a.push_back(-(ll)1e17);
  b.push_back(-(ll)1e17);
  c.push_back(-(ll)1e17);
  sort(all(a),greater<ll>());
  sort(all(b),greater<ll>());
  sort(all(c),greater<ll>());
  priority_queue<pair<ll,ll>>q;
  unordered_set<ll> ma;
  q.push({a[0]+b[0]+c[0],0});
  rep(i,k)
  {
    auto tq=q.top();q.pop();
    if(ma.count(tq.second)){i--;continue;}
    ma.insert(tq.second);
    ll x[3]={tq.second>>20&1023,tq.second>>10&1023,tq.second&1023};
    rep(j,3)
    {
      x[j]++;
      q.push({a[x[0]]+b[x[1]]+c[x[2]],(x[0]<<20)+(x[1]<<10)+x[2]});
      x[j]--;
    }
    cout<<tq.first<<"\n";
  }
  cout<<flush;
  return 0;

}


Measured memory_bytes: 640
<?php
fscanf(STDIN,'%d',$A);
fscanf(STDIN,'%d',$B);
fscanf(STDIN,'%d',$C);
fscanf(STDIN,'%d',$D);
fscanf(STDIN,'%d',$E);
fscanf(STDIN,'%d',$K);
$L=max($A,$B,$C,$D,$E)-min($A,$B,$C,$D,$E);
if($L<=$K){
  echo "Yay!";
}else{
  echo ":(";
}
echo "\n";

 ?>


Measured memory_bytes: 3700
fn read_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim_right().to_owned()
}

fn main() {
    read_line();
    let v = read_line().split_whitespace().map(|x| x.parse::<i32>().unwrap()).collect::<Vec<_>>();
    
    println!("{}", 1_f64 / v.into_iter().map(|x| 1_f64 / x as f64).sum::<f64>());
}

Measured memory_bytes: 4352
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;


public class Test
{	
    public static void Main()
	{
	    int[] time = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
	    
	    int ans = (time[0] + time[1])%24;
	    Console.WriteLine(ans);
	    
	} 
}

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

vector<vector<int> >adj;

signed main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);  
  cout.tie(0);   
#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif

  int n;
  cin>>n;
  int a[n+1];
  map<int,int>mm;
  int ans=0;
  for(int i=1;i<=n;i++)
  {
    cin>>a[i];
    ans+=mm[i-a[i]];
    mm[i+a[i]]++;
  }
  cout<<ans;
}

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

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

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

using namespace __gnu_pbds;
using namespace std ;

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


class numberTheory{

public:
    numberTheory(){}

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

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

    }

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


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

const i64 N = 200000 ;

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

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

void preprocess()
{
    numberTheory nt ;

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

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

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

int mulFact[N+5] , num[N+5] ;
vector <int> p ;

void sieve()
{
    int i , j ;
    for(i=2 ; i*i<=N ;i++)
    {
        if(num[i]==0) for(j=i+i ; j<=N ; j+=i) num[j] = 1 ;
    }
    for(i=2 ; i<=N ; i++) if(num[i]==0) p.pb(i) ;
}

i64 dp[2005] ;

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

int main()
{
//    preprocess() ;

    i64 a , b , c , d , tc ;

    scanf("%lld",&tc) ;

    while( tc-- )
    {
        scanf("%lld %lld %lld %lld",&a,&b,&c,&d) ;

        if( b > d || a < b )
        {
            printf("No\n") ;
            continue ;
        }
        if( c >= b-1 )
        {
            printf("Yes\n") ;
            continue ;
        }

//        DBG ;

        i64 g = gcd(b,d) ;

        i64 Next = (a-b)/g ;
        Next++ ;

        i64 check = a - Next*g ;

        if( check <= c ) printf("Yes\n") ;
        else printf("No\n") ;
    }

    return 0 ;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main()
{
	int h,w;
	cin>>h>>w;
	
	for(int i=1;i<=h;i++)
	{
		string m;
		cin>>m;
		if(i==h)
		{
			cout<<m<<endl;
			cout<<m;
			break;
		}
		cout<<m<<endl;
		cout<<m<<endl;
	}
	
	return 0;
} 

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    ll N;
    cin >> N;
    vec p(N);
    REP(i,0,N) {
        cin >> p[i];
        --p[i];
    }

    ll c = 0, cnt = 0;
    REP(i,0,N) {
        if(p[i] == i) ++c;
        else {
            cnt += (c+1)/2;
            c = 0;
        }
    }
    cnt += (c+1)/2;
    
    PR(cnt);

    return 0;
}

/*



*/

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  string s;
  cin >> s;
  rep(i, s.size()) {
    if (s[i] == '?')
      cout << 'D';
    else
      cout << s[i];
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 3700
import sys
n=int(input())
t=list(map(int,input().split()))
a=list(map(int,input().split()))
m=[0]*n
MOD=10**9+7
m[0]=t[0]
for i in range(1,n):
  if t[i-1]<t[i]:
    m[i]=t[i]
  else:
    m[i]=-1*t[i]
if m[n-1]>0 and m[n-1]!=a[n-1]:
  print(0)
  sys.exit()
if m[n-1]<0 and -1*m[n-1]<a[n-1]:
  print(0)
  sys.exit()
m[n-1]=a[n-1]
for i in range(n-2,-1,-1):
  if a[i+1]<a[i]:
    if (m[i]>0 and m[i]!=a[i]) or (m[i]<0 and -1*m[i]<a[i]):
      print(0)
      sys.exit()
    m[i]=a[i]
  else:
    m[i]=max(m[i],-1*a[i])
ans=1
for i in range(n):
  if m[i]<0:
    ans=(ans*-1*m[i])%MOD
print(ans)


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

int main() {
    pair<ll, ll> A[6];
    rep(i, 6) {
        cin >> A[i].first >> A[i].second;
        if (A[i].first > A[i].second) {
            swap(A[i].first, A[i].second);
        }
    }
    sort(A, A + 6);
    rep(i, 6) if (i & 1) {
        if (A[i].first != A[i - 1].first || A[i].second != A[i - 1].second) {
            return puts("no") & 0;
        }
    }
    vector<pair<ll, ll>> B = {A[0], A[2], A[4]};
    bool flag = 0;
    flag = B[0].first==B[1].first&&B[0].second==B[2].first&&B[1].second==B[2].second;
    cout << (flag ? "yes" : "no") << endl;
}



Measured memory_bytes: 3076
#include<bits/stdc++.h>
#include<math.h>
#include <numeric> 
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<vector>
using namespace std;
#define ll long long
#define f(i,m,n) for(ll i=m;i<n;i++)
#define fo(j,n,m) for(ll j=n;i>=m;i--)
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
int gcd(ll a,ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
int main()
{
    ll c=0;
ll n;
cin>>n;
vi a(n);
f(i,0,n)
cin>>a[i];
f(i,0,n)
{
    f(j,i+1,n)
    {
        f(k,j+1,n)
        {
            if((a[i]+a[j]>a[k])&&((a[i]+a[k])>a[j])&&(a[k]+a[j]>a[i])&&((a[i]!=a[j])&&(a[j]!=a[k])&&(a[i]!=a[k])))
            c++;
        }
    }
}
  cout<<c;
    return 0;
}
    
    


Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <map>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	string s; cin >> s;
	string t[2];
	t[0]=t[1]="";
	int q; cin >> q;
	int now=0;
	while(q--){
		int tt; cin >> tt;
		if(tt==1){
			now^=1;
		}
		else{
			int f; cin >> f;
			char c; cin >> c;
			if(f==1){
				t[now].push_back(c);
			}else{
				t[now^1].push_back(c);
			}
		}
	}
	if(now){
		reverse(s.begin(),s.end());
		reverse(t[1].begin(),t[1].end());
		s=t[1]+s+t[0];
	}else{
		reverse(t[0].begin(),t[0].end());
		s=t[0]+s+t[1];
	}
	cout << s << endl;
}

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

int main(){
    int k,s;
    cin >> k >> s;
    long long ans = 0;
    for (int i = 0; i<=k; i++){
        for (int j = 0; j<=k; j++){
            if (s-i-j>=0 && s-i-j<=k){
                ans++;
            }
        }
    }
    cout << ans << endl;
}

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

#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define INF  (1<<30)
#define INFL (1LL<<60)
#define MOD 1000000007
#define EPS ((ld)(1e-9))

#define sz(x) ((int)(x).size())
#define setz(x) memset(x, 0, sizeof(x))
#define all(x) (x).begin(), (x).end()
#define rep(i, x)  for (int i = 0, _##i = (x); i < _##i; i++)
#define repp(i, s, e) for (int i = (s), _##i = (e); i < _##i; i++)
#define repr(i, s, e) for (int i = (s)-1, _##i = (e); i >= _##i; i--)
#define repi(i, x) for (auto &i : (x))


using namespace std;

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

template<typename T, typename V>
ostream &operator<<(ostream &os, const pair<T, V> pai) { 
    return os << '(' << pai.first << ' ' << pai.second << ')';
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> v) {
    cout << '[';
    rep(i, sz(v)) cout << v[i] << ",";
    cout << "]";
    return os;
}

template<typename T>
ostream &operator<<(ostream &os, const set<T> v) {
    cout << "{";
    for (auto p : v) cout << p << ",";
    cout << "}";
    return os;
}

template<typename T, typename V>
ostream &operator<<(ostream &os, const map<T, V> v) {
    cout << "{";
    for (auto p : v) cout << p << ",";
    cout << "}";
    return os;
}

#ifndef __SOULTCH
#define debug(...) 0
#define endl '\n'
#else
#define debug(...) cout << " [-] ", _dbg(#__VA_ARGS__, __VA_ARGS__)
template<class TH> void _dbg(const char *sdbg, TH h){ cout << sdbg << '=' << h << endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
    while(*sdbg != ',') cout << *sdbg++;
    cout << '=' << (h) << ','; 
    _dbg(sdbg+1, a...);
}
#endif

template<typename T> void get_max(T &a, T b) {a = max(a, b);}
template<typename T> void get_min(T &a, T b) {a = min(a, b);}


int main(void) {
    iostream::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);

    int A, B; cin >> A >> B;
    if (A < B) cout << 0;
    else cout << 10;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<queue>
#include<algorithm>
#include<vector>
using namespace std;

typedef stack<int> IntStack;
typedef queue<int> IntQueue;

/*ここまでテンプレ*/



/*ここからmain関数*/

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

	char c[10000][10];
	int sB = 0, lA = 0, BtA = 0, ans = 0;
	for (int i = 0; i < N; i++)
	{
		cin >> c[i];
		int l = strlen(c[i]);

		if (c[i][0] == 'B'&&c[i][l - 1] == 'A') BtA++;
		else if (c[i][0] == 'B') sB++;
		else if (c[i][l - 1] == 'A') lA++;

		for (int j = 0; j < l-1; j++)
			if (c[i][j] == 'A'&&c[i][j + 1] == 'B') ans++;
	}

	if (BtA > 0)
	{
		ans += BtA - 1;
		if (sB > 0)
		{
			ans++;
			sB--;
		}
		if (lA > 0)
		{
			ans++;
			lA--;
		}
	}

	ans += min(sB, lA);

	cout << ans;

	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <float.h>
#include <iomanip>
#include <iostream>
using namespace std;
 
int main(){

    int ans=0;
    string S;

    cin>>S;

    for(int i=0;i<(S.length()/2);i++){
        if(S[i]!=S[S.length()-1-i])ans++;
    }

    cout << ans<<endl;

    return 0;

}

Measured memory_bytes: 384
#include <stdio.h>

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }

template <typename T, typename V>
void __print(const pair<T, V> &x) {
    cerr << '{';
    __print(x.first);
    cerr << ',';
    __print(x.second);
    cerr << '}';
}
template <typename T>
void __print(const T &x) {
    int f = 0;
    cerr << '{';
    for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
    cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
    __print(t);
    if (sizeof...(v)) cerr << ", ";
    _print(v...);
}
#ifdef LOCAL
#define debug(x...)               \
    cerr << "[" << #x << "] = ["; \
    _print(x)
#else
#define debug(x...)
#endif

#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)

typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N;
    cin >> N;
    cout << N * N * N << endl;

    return 0;
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    int x1,y1,x2,y2;
    cin>>x1>>y1>>x2>>y2;

    int dx=x2-x1;
    int dy=y2-y1;

    int x3=x2-dy;
    int y3=y2+dx;

    int x4=x3-dx;
    int y4=y3-dy;

    cout<<x3<<" "<<y3<<" "<<x4<<" "<<y4<<endl;
    return 0;
}


Measured memory_bytes: 256
temp=input().split()
N=int(temp[0])
L=int(temp[1])

edge=[L, L+N-1]
if edge[0]*edge[1]<=0:
  ans=sum(edge)*N/2
elif edge[0]>0:
  ans=(L+1+L+N-1)*(N-1)/2
else:
  ans=(L+L+N-2)*(N-1)/2
  
print(int(ans))

Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int MAX_N = 100010;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}

/*------------------------------------------------------------------*/
const int MAX = 1000010;
/*  nCk = (n!) * (k!)^-1 * (n - k)^-1
    fac[n] : (n!)
    finv[n] : (n!)^-1 
*/

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

// preparation
void COMinit(){
    fac[0] = 1, fac[1] = 1;
    finv[0] = 1, finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}
// nCk calculation
ll COM(ll n, ll k){
    if(n < k) return 0;
    if(n < 0 or k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}


int main(){
    ll x, y; cin >> x >> y;
    if(y > 2 * x or 2 * y < x or (x + y) % 3 != 0){
        cout << 0 << endl;
        return 0;
    }
    COMinit();
    cout << COM((x + y) / 3, x - (x + y) / 3) << endl; 
}

Measured memory_bytes: 27072
#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<ll,ll>;
//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define inf 2147483647 //int値の最大値
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定
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 gcd(int a, int b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int two(int n){
	ll ans=1;
	rep(i,n){
		ans*=2;
	}
	return ans;
}
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);

   string s;
   cin>>s;
   int sum=700;
rep(i,3) if(s[i]=='o')sum +=100;

cout<<sum<<endl;


   
}

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

int main()
{
  int A,B,C,K,ans=0;
  cin >> A >> B >> C >> K;
  if (K<=A)
  {
    cout << K;
  }
  else if (A<K && K<=A+B)
  {
    cout << A;
  }
  else if (A+B<K && K<=A+B+C)
  {
    cout << A + (K-A-B)*(-1);
  }
  else
  {
    cout << A - C;
  }
  
  
  
  
}


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

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

int main()
{
    int H, W;
    cin >> H >> W;
    vector<string> field(H);
    rep(i, H) cin >> field[i];

    vector<vector<int>> dist(H, vector<int>(W, -1));
    vector<vector<P>> prev(H, vector<P>(W, P(-1, -1)));

    int sy, sx = 0;
    queue<P> que;
    que.push(P(sy, sx));
    dist[sy][sx] = 0;
    prev[0][0] = P(-1, -1);
    while (!que.empty())
    {
        int y, x;
        tie(y, x) = que.front();
        que.pop();

        int ny, nx;
        for (int i = 0; i < 4; i++)
        {
            ny = dy[i] + y;
            nx = dx[i] + x;

            if (ny < 0 || ny >= H || nx < 0 || nx >= W || field[ny][nx] == '#')
                continue;

            if (dist[ny][nx] == -1)
            {
                dist[ny][nx] = dist[y][x] + 1;
                que.push(P(ny, nx));
                prev[ny][nx] = P(y, x);
            }
        }
    }

    int wall_count = 0;
    for (int y = 0; y < H; y++)
    {

        for (int x = 0; x < W; x++)
        {
            if (field[y][x] == '#')
            {
                wall_count++;
            }
        }
    }

    if (dist[H - 1][W - 1] == -1)
    {
        cout << -1 << endl;
    }
    else
    {

        cout << H * W - wall_count - dist[H - 1][W - 1] - 1 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#define r return
#define a a;
i,j,n,f[6];
w[8]={1,1,0,-1,-1,-1,0,1};
h[8]={0,1,1,1,0,-1,-1,-1};
char t[10][10],mark[2]={'o','x'};
 
int l(int dx,int dy,int x,int y,char m,int c){
if(t[x][y]=='.'||t[x][y]=='0')r 0;if(t[x][y]==m)r c;r l(dx,dy,x+dx,y+dy,m,c+1);}
int s(int dx,int dy,int x,int y,char m,int c){
  int k,d;d=0;if(t[x][y]!='.')r 0;
  for(k=0;k<8;k++)d+=l(w[k],h[k],x+w[k],y+h[k],m,0);
  r d;
}
int p(int dx,int dy,int x,int y,char m,int c){
  if(t[x][y]=='0'||t[x][y]=='.')r 0;if(t[x][y]==m)r 1;
  if(p(dx,dy,x+dx,y+dy,m,0)){t[x][y]=m;r 1;}
  else r 0;
}
int o(int dx,int dy,int x,int y,char m,int c){
  int k;
  t[x][y]=m;for(k=0;k<8;k++)p(w[k],h[k],x+w[k],y+h[k],m,0);
  r 0;
}
 
int main(){
  for(i=0;i<10;i++)t[0][i]=t[9][i]='0';
  for(i=1;i<9;i++){
    scanf("%s",&t[i][1]);
    t[i][0]='0';
    t[i][9]='0';
  }
  f[1]=-1;
  for(n=0;;n=(n+1)%2){
    f[n]=-1;
    for(i=n?8:1;n?i>-1:i<9;n?i--:i++){
      for(j=n?8:1;n?j>-1:j<9;n?j--:j++){
        if(f[n]<s(0,0,i,j,mark[n],0)){
          f[2+n]=i;
          f[4+n]=j;
          f[n]=s(0,0,i,j,mark[n],0);
        }
      }
    }
    if(f[n]!=0)o(0,0,f[2+n],f[4+n],mark[n],0);
    if(f[0]==0&&f[1]==0)break;
  }
  for(i=1;i<9;i++){
    for(j=1;j<9;j++){
      printf("%c",t[i][j]);
    }
    puts("");
  }
  r 0;
}

Measured memory_bytes: 524
//* AuThOr GaRyMr *//
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define niv vector<int>
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define ff fflush(stdout)
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int n;
LL res;
int dp[20][20];
// dp[i][j] 前i个组成长度为j的B的前缀 
string r_s="";
int check(string A,string B){
//	cout<<A<<" "<<B<<" "<<r_s<<endl;
	
	A='$'+A;
	B='^'+B;
	rb(i,0,19)
		rb(j,0,19) dp[i][j]=0;
	dp[0][0]=1;
	rb(i,1,n/2){
		rb(j,1,min((int)(B.length()-1),i)){
			if(r_s[i]==B[j]){
				dp[i][j]+=dp[i-1][j-1];
			}
			if(r_s[i]==A[i-j]){ 
				dp[i][j]+=dp[i-1][j];
			}
		}
	}
	return dp[n/2][B.length()-1];
}	string s;
void dfs1(string A,string B,int now){
	if(now>(n>>1)){
		res+=check(A,B);
	}
	else{
		dfs1(A+s[now],B,now+1);
		dfs1(A,B+s[now],now+1);
	}
}
int main(){
	cin>>n;
	n=n+n;
	cin>>s;
	s='$'+s;
	rl(i,n,n/2+1) r_s+=s[i];r_s='%'+r_s;
	dfs1("","",1);
	cout<<res+res<<endl;
	return 0;	
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>
#include <cstdint>



#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 repi(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rrepi(i,a,b) for(ll i=(ll)(b-1);i>=(ll)(a);i--)

#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  string a,b;
  cin>>a>>b;
  cout<<b<<a<<endl;

  return 0;

}


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

#define MOD (1000 * 1000 * 1000 + 7)
#define INF (1LL << 60)
#define pb push_back
#define po pop_back
#define fi first
#define se second

typedef long long ll;
typedef long double ld;

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

    vector<int> casi(n);
    for (auto &i : casi)
        cin >> i;

    int m;
    cin >> m;

    vector<pair<int, int>> drinks(m);
    for (auto &i : drinks) {
        cin >> i.fi;
        cin >> i.se;
    }

    ll sum = 0;
    for (auto &i : casi)
        sum += i;

    for (int i = 0; i < drinks.size(); ++i)
        cout << (sum - casi[drinks[i].fi - 1] + drinks[i].se) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>

using namespace std;

const int MAX_N = 101;


int numnum[MAX_N];
int N, R;

long memo[101][21];

long first_grader(int p, int r){
	if (r < 0 || 20 < r) return 0;
	if (p == N) return r == R;
	if (memo[p][r] != -1) return memo[p][r];
	long res = 0;
	if (p == 0) res = first_grader(p + 1, numnum[p]);
	else res += first_grader(p + 1, r + numnum[p]) + first_grader(p + 1, r - numnum[p]);
	return memo[p][r] = res;
}

int main()
{
	memset(memo, -1, sizeof(memo));

	scanf("%d", &N);
	N--;
	for (int i = 0; i < N; i++){
		scanf("%d", &numnum[i]);
	}
	scanf("%d", &R);
	cout << first_grader(0, 0) << endl;
}

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

int main() {
	map<string, int> plus;
	map<string, int>minus;
	int n, m, max;
	string s;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> s;
		plus[s]++;
	}
	cin >> m;
	for (int i = 0; i < m; i++) {
		cin >> s;
		minus[s]++;
	}
	int hoge;
	max = 0;
	auto itr = plus.begin();
	for (int i = 0; i < plus.size(); i++) {
		hoge = itr->second - minus[itr->first];
		if (hoge > max)max = hoge;
		++itr;
	}
	cout << max << endl;

	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

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

//二部グラフ判定。頂点をc(1か-1(黒か白))で塗る
bool dfs(vector<vector<int>> &graph, vector<int> &color, int v, int c)
{
    color[v] = c; //まず頂点vをcで塗る
    for (int i = 0; i < (int)graph[v].size(); i++)
    {
        // 隣り合う頂点が同じ色ならダメ
        if (color[graph[v][i]] == c)
        {
            return false;
        }
        // 隣り合う頂点がまだ塗られてないなら塗る
        if (color[graph[v][i]] == 0 && !dfs(graph, color, graph[v][i], -c))
        {
            return false;
        }
    }
    return true;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<vector<int>> graph(n); //隣接リスト
    vector<int> color(n, 0);      //各頂点が何色か。黒=1, 白=-1、まだ塗られてない=0
    int a, b;
    for (int i = 0; i < m; i++)
    {
        cin >> a >> b;
        graph[a - 1].push_back(b - 1);
        graph[b - 1].push_back(a - 1);
    }

    if (dfs(graph, color, 0, 1))
    {
        ll b = count(ALL(color), 1);
        ll w = n - b;
        cout << b * w - m << endl;
    }
    else
    {
        ll a = (ll)n * (n - 1) / 2;
        cout << a - m << endl;
    }
}

Measured memory_bytes: 6784
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  string s;
  cin >> s;
  if(s.size()==2)cout << s << endl;
  else{
    reverse(s.begin(),s.end());
    cout << s << endl;
  }
return 0;}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;

int n;
vector<pair<int, int>> v;
vector<vector<int>> lst;
bool ch[105] = {0};
int chlst[105] = {0};

void solve();

int main() {
  /*for(int i = 3; i <= 100; ++i) {
    n = i;
    solve();
    sort(lst.begin(), lst.end());
    for(int j = 1; j < v.size(); ++j)
      if(v[j] == v[j - 1]) cout << i << endl;
    lst.erase(lst.begin(), lst.end());
    v.erase(v.begin(), v.end());

    for(int j = 1; j <= n; ++j) { ch[j] = 0; }
  }*/
  cin >> n;
  solve();
  cout << v.size() << endl;
  sort(v.begin(), v.end());
  for(int i = 0; i < v.size(); ++i) {
    if(v[i].fi > v[i].se) swap(v[i].fi, v[i].se);
    cout << v[i].fi + 1 << " " << v[i].se + 1 << endl;
  }
  return 0;
}

void solve() {
  int sum = 0, num = 0;
  for(int i = 1; i <= n; ++i) sum += i;
  for(int i = 2; i < sum; ++i)
    if(sum % i == 0) {
      num = i;
      break;
    }
  sum /= num;
  for(int t = 0; t < num; ++t) {
    vector<int> nv;
    int now = 0;
    for(int i = n; i > 0; --i)
      if(now + i <= sum && !ch[i]) {
        ch[i] = 1;
        nv.push_back(i - 1);
        now += i;
      }
    lst.push_back(nv);
  }
  for(int i = 0; i < lst.size(); ++i) {
    int nownum = (i + 1) % lst.size();
    int size1 = lst[i].size(), size2 = lst[nownum].size();
    for(int j = 0; j < size1; ++j)
      for(int k = 0; k < size2; ++k)
        v.push_back({lst[i][j], lst[nownum][k]});
    if(lst.size() == 2) break;
  }
}

Measured memory_bytes: 384
import os, sys, re, math

def doit(N):
    if N == 0:
        return ''
    if N % 2 == 0:
        return doit(N // -2) + '0'
    else:
        return doit((N-1) // -2) + '1'

N = int(input())
if N == 0:
    print('0')
else:
    print(doit(N))


Measured memory_bytes: 38384
#pragma GCC optimize("Ofast,inline,unroll-loops,fast-math")
#include <iostream>
#include <algorithm>
#include <cstdio>
#define N 50
using namespace std;

int a[N], b[N], c[N];

int main(void)
{
    int n;
    int i, o;

    cin >> n;
    for(i = 1; i <= n; i ++)
        cin >> a[i];
    for(i = 1; i <= n; i ++)
        cin >> b[i];
    for(i = 1; i < n; i ++)
        cin >> c[i];

    for(i = 1, o = 0; i <= n; i ++)
    {
        o += b[a[i]];
        if(i > 1 && a[i - 1] == a[i] - 1)
            o += c[a[i] - 1];
    }
    cout << o << endl;

    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
//#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stdio.h>
#include <cstdio>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <random>
#include <iomanip>
#include <bitset>
 
using namespace std;
                        
template<typename T> void uin(T &a, T b) {
    if (b < a) {
        a = b;
    }
}
                        
template<typename T> void uax(T &a, T b) {
    if (b > a) {
        a = b;
    }
}

#define int long long
#define ghost signed
#define left left228
#define right right228
#define complex complex228
#define count count228
#define sin sin228
#define list list228

const int N = 100 * 1000 + 228;
const int INF = 1e18 + 228;

int n, k;
int a[N], V[N], P[N], need[N];
bool in[N];
vector<int> g[N];
int mx[N], h[N];

void dfs(int v, int par = -1) {
	h[v] = (par == -1 ? 0 : h[par] + 1);
	mx[v] = -INF;
	if (in[v]) mx[v] = a[v] - h[v];
	for (int to : g[v]) {
		if (to == par) continue;
		dfs(to, v);
		uax(mx[v], mx[to]);
	}
}

void color(int v, int value, int par = -1) {
	vector<int> sons;
	for (int to : g[v]) {
		if (to == par) continue;
		sons.push_back(to);
	}
	if (!in[v]) {
		if (mx[v] - (value - 1 - h[v]) > 0) {
			a[v] = value + 1;
		} else {
			a[v] = value - 1;
		}
	}
	for (int to : sons) {
		color(to, a[v], v);
	}
}

ghost main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
	cin >> n;
	vector< pair<int, int> > edges;
	for (int i = 0; i < n - 1; ++i) {
		int u, v;
		cin >> u >> v;
		g[u].push_back(v);
		g[v].push_back(u);
		edges.emplace_back(u, v);
	}
	cin >> k;
	int root = 0;
	for (int i = 1; i <= k; ++i) {
		cin >> V[i] >> P[i];
		in[V[i]] = 1;
		a[V[i]] = need[V[i]] = P[i];
		root = V[i];
	}
	dfs(root);
	color(root, a[root]);
	for (int i = 1; i <= n; ++i) {
		if (in[i] && need[i] != a[i]) {
			cout << "No\n";
			return 0;
		}
	}
	for (auto p : edges) {
		if (abs(a[p.first] - a[p.second]) != 1) {
			cout << "No\n";
			return 0;
		}
	}
	cout << "Yes\n";
	for (int i = 1; i <= n; ++i) cout << a[i] << '\n';
    return 0;
}
// kek ;
// Ого! Кажетсья это $#@!
 
 
 


Measured memory_bytes: 26608
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<set>
#include<cstdio>
using namespace std;

int main(){
    int a,b;cin>>a>>b;
    int d=b-a;
    cout<<d*(d+1)/2-b<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define maxn 100050
using namespace std;
int n,m;
int deg[maxn];
vector<int> G[maxn];
int fa[maxn];
bool flag,vis[maxn];
set<int> aban[maxn];
bool dfs(int i)    {
    vis[i]=1;
    for (int j:G[i]) {
        if (fa[i]==j||aban[i].count(j))   continue;
        if (!vis[j])
            fa[j]=i,dfs(j);
        else
        if (!flag)  {
            flag=1;
            aban[i].insert(j);
            aban[j].insert(i);
            for (int k=i;k!=fa[j];k=fa[k])  {
                deg[k]-=2;
                if (k==j)   continue;
                aban[k].insert(fa[k]);
                aban[fa[k]].insert(k);
            }
        }
    }
}
int main()  {
    scanf("%d%d",&n,&m);
    while (m--) {
        int u,v;
        scanf("%d%d",&u,&v);
        G[u].push_back(v),G[v].push_back(u);
        ++deg[u],++deg[v];
    }
    for (int i=1;i<=n;++i)  {
        if (deg[i]&1) 
            return puts("No"),0;
    }
    for (int i=1;i<=n;++i)  
        if (deg[i]>=6)
            return puts("Yes"),0;
    int c=0;
    for (int i=1;i<=n;++i)
        if (deg[i]>2)   ++c;
    if (c>2) return puts("Yes"),0;
    for (int c=0;c<3;++c)   {
        memset(vis,0,sizeof(vis));
        flag=0;
        for (int i=1;i<=n;++i)
            if (deg[i]) {
                dfs(i);
                break;
            }
        if (!flag) return puts("No"),0;
    }
 
    puts("Yes");
    return 0;
}

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

int cnt(int n)
{
    int de = 0;
    while(n)
    {
        de++;
        n/=10;
    }
    return de;
}
main()
{
    int n;
    cin >> n;
    int kq = 0;
    for(int i = 1; i <= n; ++i) if(cnt(i) & 1) kq++;
    cout << kq;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MODNum 1000000007
#define REP(type, i, a, b) for( type i = a; i < b; i++ )
typedef long long ll;

using namespace std;

int main (void) {
    int N;
    cin >> N;
    int a[N];
    int Num;
    REP(int,i,0,N) a[i] = 0;
    REP(int,i,0,N-1){
        cin >> Num;
        a[Num-1]++;
    }
    REP(int,i,0,N) cout << a[i] << endl;
    return 0;
}

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

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

  if(N%10 == 2 || N%10 == 4 ||N%10 == 5||N%10 == 7 ||N%10 == 9){
    cout <<"hon";
  }

  if(N%10 == 0 || N%10 == 1 ||N%10 == 6||N%10 == 8){
    cout <<"pon";
  }

  if(N%10 == 3){
    cout <<"bon";
  }

  return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define ll long long
#define vi vector <int>
#define vl vector <ll>
#define dl pair <ll, ll>
#define ii pair <ll, ll>
#define vii vector <ii>
#define F first
#define S second
#define tipo pair <ll, pair <ll, set <int> > >
#define REP(a, b) for (int i = a; i < b; i++)
#define REP2(a, b) for (int j = a; j < b; j++)
#define REPS(a, b, c) for (int i = a; i < b; i += c)

using namespace std;

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

	string s;
	cin >> s;
	cout << s;
	if (s.back() == 's') {
		cout << "es";
	} else {
		cout << "s";
	}
	cout << "\n";
	return 0;
}

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

int main(){
    int n,m;
    int sum =0;
    int count =0;

    cin >> n >> m;
    int A[n];
    for (int i = 0; i < n; i++) cin >> A[i];
    for (int i = 0; i < n; i++)
        sum +=A[i];
    float border = sum /(float)(4*m);
    for (int i = 0; i < n; i++)
           if (A[i]>=border) count++;
    
    cout << ((count >= m) ? "Yes" :"No" )<< endl;
}

Measured memory_bytes: 256
N, Q = map(int, input().split())
S = input()
count_AC = [0]
tmp = 0
for i in range(1, len(S)):
    if S[i - 1] + S[i] == 'AC':
        tmp += 1
    count_AC.append(tmp)
for i in range(Q):
    l, r = map(int, input().split())
    print(count_AC[r-1] - count_AC[l-1])

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

struct Data{
	char name[24];
	int w,s;
}t[10],now[10],ans[10];

int n;
double min;
char used[10];

void solve(int idx,int rem,int sum,int G){
	int i,j;

	if(t[idx].s < sum) return;

	now[rem] = t[idx];
	sum += t[idx].w;
	G += t[idx].w * (rem + 1);

	if(rem == 0){
		double tmp = (double)G / sum;
		if(min > tmp){
			min = tmp;
			for(i=0;i<n;i++) ans[i] = now[i];
		}
		return;
	}
	if(rem < 0) return;

	used[idx] = 1;
	for(i=0;i<n;i++){
		if(!used[i]){
			solve(i,rem-1,sum,G);
		}
	}
	used[idx] = 0;
}

int main(void){
	int i;

	while(scanf("%d",&n) && n){
		for(i=0;i<n;i++){
			scanf("%s%d%d",t[i].name,&t[i].w,&t[i].s);
		}

		min = 999999999;
		memset(used,0,sizeof(used));

		for(i=0;i<n;i++){
			solve(i,n-1,0,0);
		}

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

	return 0;
}

Measured memory_bytes: 384
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int N = stdIn.nextInt();
		int[] A = new int[N];
		long[] B = new long[N];
		long S = 0;
		long S1 = 0;
		
		for(int i = 0; i < N; i++) {
			A[i] = stdIn.nextInt();
			S += A[i];
			if(i%2 == 1) {
				S1 += A[i];
			}
		}
		B[0] = S - 2*S1;
		
		for(int i = 1; i < N; i++) {
			B[i] = 2*A[i-1] - B[i-1];
		}
		
		for(int i = 0; i < N; i++) {
			System.out.println(B[i]);
		}

	}

}

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

int main()
{
    while (true) {
        int N;
        cin >> N;

        if (N == 0) {
            break;
        }

        char winner = -1;
        int d = -1;
        vector<int> count(256, 0); //得票数
        vector<char> c(N, 0);

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

        for (int i=0; i<N; i++) {

            count[c[i]]++;
            char first = -1;
            char second = -1;

            //現時点での一番と二番を調べる
            for (char j = 'A'; j <= 'Z'; j++) {
                if (first == -1 || count[j] > count[first]) {
                    second = first;
                    first = j;
                } else if (second == -1 || count[j] > count[second]) {
                    second = j;
                }
            }

            //残り全ての票が現時点で二番の人に投じられていても一番の人の得票数を超えられないなら誰も超えられない
            if (count[first] > count[second] + (N - 1 - i)) {
                winner = first;
                d = i+1;
                break;
            }
        }

        if (d == -1) {
            cout << "TIE" << endl;
        } else {
            cout << winner << " " << d << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3016
using System;
using System.Collections.Generic;
using System.Linq;

class Progaram
{
    static void Main(String[] args)
    {
        var l = Console.ReadLine().Split(' ').Select(x => Int64.Parse(x)).ToArray();
        var a = l[0]; var b = l[1]; var c = l[2]; var k = l[3];
        var res = 0L;
        if (k <= a)
        {
            res += k;
            Console.WriteLine(res);
            return;
        }
        res += a;
        k -= a;
        if (k - b <= 0)
        {
            Console.WriteLine(res);
            return;
        }
        k -= b;
        if (k <= c)
        {
            res -= k;
        }
        else
        {
            res -= c;
        }
        Console.WriteLine(res);
    }
}

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

vector<int> divisor(int n) {
	vector<int>divisor;
	for (int i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			divisor.push_back(i);
			if (i * i != n) divisor.push_back(n / i);
		}
	}
	sort(begin(divisor), end(divisor));
	return divisor;
}

int main() {
	int n, m;
	cin >> n >> m;
	vector<int>d = divisor(m);
	int ans = 0;
	for (int i = 0; i < d.size(); i++) {
		if (m / d[i] >= n)ans = d[i];
	}
	cout << ans << endl;
}

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

using namespace std;

int main(void){
    string s;
    cin >> s;
    
    int n = stoi(s);
    
    int lastTwo = 10 * (n / 10 % 10) + n % 10; 
    int firstTwo = 10 * (n / 1000 % 10) + (n / 100 % 10);
    
    
    if (1 <= firstTwo && firstTwo <= 12 && 1 <= lastTwo && lastTwo <= 12){
        cout << "AMBIGUOUS" << endl;
        return 0;
    }
    else if (1 <= lastTwo && lastTwo <= 12){
        cout << "YYMM" << endl;
        return 0;
    }
    else if (1 <= firstTwo && firstTwo <= 12){
        cout << "MMYY" << endl;
        return 0;
    }
    else{
        cout << "NA" << endl;
        return 0;
    }
}


Measured memory_bytes: 256
n = int(input())
k = int(input())
thr = k // 2
x = list(map(int,input().split()))
ans = 0
for i in range(n):
    if x[i] > thr:
        ans += 2 * (k - x[i])
    else:
        ans += x[i] * 2
print(ans)

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main()
{
	long long int a,b,c;
	cin>>a>>b;
	if(b%a==0)
	{
		c=a+b;
	}
	if(b%a!=0)
	{
		c=b-a;
	}
	cout<<c<<endl;
} 

Measured memory_bytes: 256
import java.time.LocalDate;
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		while (true) {
			String[] line = sc.nextLine().split(
					" ");

			if ("0".equals(line[0])) {
				System.exit(0);
			}

			int month = Integer.parseInt(line[0]);
			int day = Integer.parseInt(line[1]);

			LocalDate ld = LocalDate.of(2004,
					month, day);

			String outString = ld.getDayOfWeek()
					.toString();

			System.out.println(Character
					.toTitleCase(outString.charAt(
							0)) + outString
									.substring(1)
									.toLowerCase());

		}
	}
}

Measured memory_bytes: 31604
#include <iostream>
#include <stdio.h>

#include <vector>
#include <cctype>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <string>

using namespace std;


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

    vector<long long> x(n);
    vector<long long> y(n);

    for (int i = 0; i < n; i++)
        cin >> x[i] >> y[i];

    int count = 0;
    for (int i = 0; i < n; i++) {
        double s = sqrt(x[i] * x[i] + y[i] * y[i]);
        if (s <= d)count++;
    }

    cout << count << endl;

    return 0;
}

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

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

    auto lengths = std::vector<int>();
    lengths.reserve(n);

    for(int i = 0; i < n; ++i) {
        int l;
        std::cin >> l;
        lengths.push_back(l);
    }

    std::sort(lengths.begin(), lengths.end());

    int answer = 0;

    const auto a_end = lengths.end() - 1;

    for(auto a = lengths.begin(); a != a_end; ++a) {
        for(auto b = a + 1; b != lengths.end(); ++b) {
            const auto lower = *b - *a + 1;
            const auto upper = *a + *b - 1;

            const auto lower_it = std::lower_bound(b + 1, lengths.end(), lower);
            const auto upper_it = std::upper_bound(b + 1, lengths.end(), upper);

            int c = upper_it - lower_it;

            if(a >= lower_it && a < upper_it) {
                --c;
            }
            if(b >= lower_it && b < upper_it) {
                --c;
            }

            answer += c;
        }
    }

    std::cout << answer;

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <cmath>
#include <sstream>
#include <string>
#define ll long long
#define mod 1000000007
const int INF=0x3f3f3f3f;
const int N=4e3+5;
using namespace std;


int t,n,m,flag,s=0;


int main(){
	cin>>n>>m;
	if(n<10) m+=(10-n)*100;
	cout<<m<<endl;
	
	
    return 0;
}

Measured memory_bytes: 256
N,M=[int(i) for i in input().split()]
bridge=[]
for i in range(M):
  bridge.append([int(i)-1 for i in input().split()])
nod=[[i,[i]] for i in range(N)]
e=0
totale=int(N*(N-1)/2)


def joint(a,b,e):
  na=nod[a][0]
  nb=nod[b][0]
  if na==nb:
    return e
  else:
    e+=len(nod[na][1])*len(nod[nb][1])
    if na<nb:
      nod[na][1].extend(nod[nb][1])
      for i in nod[nb][1]:
        nod[i][0]=na
    else:
      nod[nb][1].extend(nod[na][1])
      for i in nod[na][1]:
        nod[i][0]=nb
    return e
  


ans=[]
for i in range(M-1,-1,-1):
  ans.append(totale-e)
  e=joint(bridge[i][0],bridge[i][1],e)
  
for i in range(M-1,-1,-1):
  print(ans[i])

Measured memory_bytes: 58564
#include <bits/stdc++.h>
#define rep(i,n)    for (decay_t <decltype (n)> i = 0, i ## __len = (n); i < i ## __len; ++ i)
#define _for(i,b,e) for (common_type_t <decltype (b), decltype (e)> i = (b), i ## __end = (e); i < i ## __end; ++ i)
#define FORR(i,b,e) for (common_type_t <decltype (b), decltype (e)> i = (e), i ## __begin = (b); i -- > i ## __begin;)
#define ALL(x)      begin (x), end (x)
#define FOR(...)    _for (__VA_ARGS__)
using namespace std;

auto main () -> int
{
  cin.tie (nullptr);
  ios::sync_with_stdio (false);

  size_t n;
  cin >> n;

  auto ans = 0.0;
  rep (i, n)
  {
    double x;
    string s;
    cin >> x >> s;
    if (s == "JPY")
    {
      ans += x;
    }
    else
    {
      ans += x * 380000.0;
    }
  }
  cout << fixed << setprecision (15) << ans << endl;
}


Measured memory_bytes: 384
import sys

lines = [l.rstrip() for l in sys.stdin.readlines()]
d = {}

n = int(lines[0])
for l in lines[1:]:
    if l in d.keys():
        d[l] += 1
    else:
        d[l] = 1

s = sorted(d.items(), key=lambda x: -x[1])
l = sorted([e for e in s if e[1] == s[0][1]], key=lambda x: x[0])

for k, _ in l:
    print(k)


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

int N;
vector<int> A(10);

int calc(int n, int sum) {
    if (n == N) {
        if (sum % 2 == 0) {
            return 1;
        } else {
            return 0;
        }
    }
    int res = 0;
    res += calc(n + 1, (n != 0 ? sum * (A[n]) : A[n]));
    res += calc(n + 1, (n != 0 ? sum * (A[n] + 1) : A[n] + 1));
    res += calc(n + 1, (n != 0 ? sum * (A[n] - 1) : A[n] - 1));
    return res;
}

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    cout << calc(0, 0) << endl;
}

Measured memory_bytes: 256