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

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

#define MOD 1000000007LL

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

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

int main(void) {
    ll N;
    cin >> N;
    ll a = N % 10;
    N /= 10;
    ll b = N % 10;
    N /= 10;
    ll c = N % 10;
    cout << (1000 - c * 100 - 10 * b - a) % 1000 << endl;
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <cmath>
#include <string>
#include <cstdlib>
using namespace std;

int main(){

  int K, N, H, W;
  string S;

  cin >> N;
  cin >> H;
  cin >> W;

  cout << (N-H+1)*(N-W+1) << endl; 


  return 0;
}


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

int main(){
  int N;
  cin >> N;
  int a=0;
  for(int i=0;i<N;i++){
    long long int input;
    cin >> input;
    for(int i=0;i<30;i++){
      if(input%2==0){
        input/=2;
      }else{
        a+=i;
        break;
      }
    }
  }
  cout << a << endl;
}


Measured memory_bytes: 256
import math

def plot(x,y):
    print(f'{x:.8f} {y:.8f}')

def Koch(n,x1, y1, x2, y2):
    if n == 0:
        plot(x1,y1)
        return
    sx = (2 * x1 + x2) / 3
    sy = (2 * y1 + y2) / 3
    tx = (x1 + 2 * x2) / 3
    ty = (y1 + 2 * y2) / 3
    ux = (tx - sx) * (1/2)-(ty-sy)*(math.sqrt(3)/2)+sx
    uy = (tx - sx) * (math.sqrt(3)/2)+(ty-sy)*(1/2)+sy
    Koch(n-1, x1, y1, sx, sy)
    Koch(n-1, sx, sy, ux, uy)
    Koch(n-1, ux, uy, tx, ty)
    Koch(n-1, tx, ty, x2, y2)

n = int(input())    
Koch(n,0,0,100,0)
plot(100,0)


Measured memory_bytes: 5748
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>

#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long



using namespace std;

void file(){
	#ifndef ONLINE_JUDGE
    	freopen("in.txt", "r", stdin);
	#endif
}
int tc;
const int N=2e5+5,M=2e6+5,MOD=1e9+7,OO=1e9;

int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	//file();	
 	
 	int n,k;

 	scanf("%d %d",&n,&k);
 	int ans = 0;
 	while(n)n/=k,ans++;
 	printf("%d\n",ans );
}		


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

int main() {
  string str; 
  cin>>str;
  ll bc=0,result=0;
  rep(i,str.size()) {
    if (str[i]=='B') 
      bc++;
    else 
      result+=bc;
  }
  cout<<result;
  return 0;
}


Measured memory_bytes: 3700
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

m = min(a, b, c, d, e)
M = max(a, b, c, d, e)

if M - m > k:
    print(":(")
else:
    print("Yay!")


Measured memory_bytes: 3060
#include <stdio.h>

int main(void){

	int NumOfWeeks;
	int CurrentDebt = 100000;
	scanf("%d", &NumOfWeeks);

	int i;
	for(i = 0; i < NumOfWeeks; i++){
		CurrentDebt = (CurrentDebt/20 + CurrentDebt + 999)/1000*1000;
	}
	
	printf("%d\n", CurrentDebt);
	return 0;
}

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

int main(){
  int n,x,y;cin>>n>>x>>y;
  map<int, int> m;
  rep1(i, n-1)for(int j=i+1; j<=n; j++){
    int k = min(j-i, abs(y-j)+abs(x-i)+1);
    m[k]++;
  }
  rep1(i, n-1)cout<<m[i]<<endl;

  return 0;
}


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


#define ll long long
#define MOD 1000000007



int main(){
    int k,a,b;
    cin>>k>>a>>b;
    
    
    int j=0;
    for(int i=a;i<=b;i++){
        if(i%k==0)j=1;
    }
    
    if(j==1){
        cout<<"OK"<<endl;
    }else{
        cout<<"NG"<<endl;
    }
}


Measured memory_bytes: 3580
import itertools
import decimal
import math
import collections
import sys
input = sys.stdin.readline

A,B,C,D,E=map(int,input().split())

#ListA=list(map(int,input().split()))

ans=0
if(A==0):
    ans=1
if(B==0):
    ans=2
if(C==0):
    ans=3
if(D==0):
    ans=4
if(E==0):
    ans=5
print(ans)

Measured memory_bytes: 9820
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef string str;
typedef std::pair<ll,ll> pl;
typedef std::map<str, ll> msl;
typedef std::map<char, ll> mcl;
typedef std::map<ll, ll> mll;
typedef std::vector<ll> vl;
const long double EPS = 1e-9;

#define rep(i, n) for(ll (i) = 0; (i) < (n) ; (i)++ )
#define For(i, a, b) for(ll (i) = (a); (i) < (b) ; (i)++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define tol(c) char((c)+0x20)
#define tou(c) char((c)-0x20)
#define pb push_back
#define mp make_pair
#define pr(a) cout << (a)
#define prl(a) cout << (a) << endl
#define prs(a) cout << (a) << " "
#define yn(condition) if ((condition)) prl("Yes"); else prl("No");
#define YN(condition) if ((condition)) prl("YES"); else prl("NO");
#define rpr(i,n,ans) rep((i),(n)) prs((ans[(i)]))
#define cpr(i,n,ans) rep((i),(n)) prl((ans[(i)]))
#define in1(a) cin >> (a)
#define in2(a,b) cin >> (a) >> (b)
#define in3(a,b,c) cin >> (a) >> (b) >> (c)
#define in4(a,b,c,d) cin >> (a) >> (b) >> (c) >> (d)
#define rin1(i,n,a) rep((i),(n)) cin >> (a[(i)])
#define rin2(i,n,a,b) rep((i),(n)) cin >> (a[(i)]) >> (b[(i)])
#define rin3(i,n,a,b,c) rep((i),(n)) cin >> (a[(i)]) >> (b[(i)]) >> (c[(i)])
#define e1 first
#define e2 second
#define ctol(c) ll((c)) - ll('0')
#define ltos(n) to_string((n))
#define items(kv, v) for(auto &(kv): (v))
#define ndig(N, n) ctol(ll(ltos((N))[ll(ltos((N)).length()) - (n)]))

const ll mod = 1e9 + 7;
const ll INF = mod * mod;
const ll MAX_N = 100;

int main(void){
    ll n,m,x;
    ll a[MAX_N];
    ll c1 = 0;
    ll c2 = 0;

    in3(n,m,x);
    rin1(i,m,a);
    rep(i,m) if (a[i] < x) c1 ++; else c2 ++;
    prl(min(c1,c2)); 

    return 0;
}

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

bool isP(string s) {
    int n = s.size();
    for(auto i = 0; i < n; ++i)
    {
        if(s[i] != s[n - 1 - i])
            return false;
    }

    return true;
}

void solve(int TestCase) {
    string s;
    cin >> s;
    
    int n = s.size();
    if(isP(s) && isP(s.substr(0, n / 2)) && isP(s.substr(n / 2 + 1)))
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
 
    int t = 1;
    //cin >> t;
    for(auto i = 1; i <= t; ++i) {
        //cout << "Case #"<< i << ": ";
        solve(i);
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <functional>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl;
int sum[80001];
int main(){
	while(true){
		string s;
		cin >> s;
		if(s=="0") break;
		int n=s.size();
		sum[n]=0;
		for(int i=n;i>0;i--) sum[i-1]=(sum[i]+(i%2==1 ? -1 : 1)*(s[i-1]-'0')+11)%11;
		int cnt[11]={},ans=0;
		cnt[0]=1;
		for(int i=n-1;i>=0;i--){
			if(s[i]!='0') ans+=cnt[sum[i]];
			cnt[sum[i]]++;
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1628
#include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define inf (1<<29)
#define eps (1e-10)
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;

int h,w,d,n;

int extgcd(int a,int b,int& x,int& y)
{
  int d = a;
  if(b != 0){
    d = extgcd(b,a%b,y,x);
    y -= (a/b)*x;
  }
  else
    x = 1,y = 0;
  return d;
}

int mod_inv(int a,int m)
{
  int x,y;
  extgcd(a,m,x,y);
  return (m+x%m)%m;
}


int rank(vector<vector<int> > A,int mod)
{
  int H = A.size(), W = A[0].size();
  int r = 0;
  rep(x,W)
    {  
      int pivot = inf;
      REP(y,r,H)
	if(A[y][x])
	  {
	    pivot = y;
	    break;
	  }
      if(pivot == inf)continue;
      swap(A[r],A[pivot]);

      REP(y,r+1,H)
	{
	  int value = A[y][x] * mod_inv(A[r][x],mod) % mod;
	  if(value)REP(x2,x,W)
		     A[y][x2] = ((A[y][x2] - A[r][x2] * value)%mod + mod ) % mod; 
	}
      r++;
    }
  return r;
}


int main()
{
  while(cin >> w >> h >> d,w|h|d)
    {
      n = h*w;
      vi b(n);
      vvi mat(n,vi(n+1,0)),mat2(n,vi(n,0));
      rep(y,h)rep(x,w)
	{
	  bool boo;
	  cin >> boo;
	  b[y*w+x] = boo;
	  mat[y*w+x][y*w+x] = mat2[y*w+x][y*w+x] = 1;
	  rep(i,h)rep(j,w)
	    if(abs(x-j)+abs(y-i) == d)
	      mat[y*w+x][i*w+j] = mat2[y*w+x][i*w+j] = 1;
	  mat[y*w+x][n] = boo;
	}
      /*
      rep(i,n)
	{
	  rep(j,n+1)
	    cout << mat[i][j] << " ";
	  cout << endl;
	}	
      */
      cout << (rank(mat,2)==rank(mat2,2)?1:0) << endl;

    }
  return 0;
}

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

using namespace std;




int main(){
  
  #ifndef ONLINE_JUDGE
  freopen ("input.txt", "r", stdin);
  freopen ("outt.txt", "w", stdout);
#endif
 
 int n;
 cin>>n;
 if(n>= 400 && n<=599){
   cout<<8<<endl;
 }
if(n>= 600 && n<=799){
  cout<<7;
 }
 if(n>= 800 && n<=999){
  cout<<6;
 }
 if(n>= 1000 && n<=1199){
  cout<<5;
 }
 if(n>= 1200 && n<=1399){
  cout<<4;
 }
 if(n>= 1400 && n<=1599){
  cout<<3;
 }
if(n>= 1600 && n<=1799){
  cout<<2;
 }
 if(n>= 1800 && n<=1999){
  cout<<1;
 }









}






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

int main(){
    int a,b;
    cin>>a>>b;
    if(a>=13) cout<<b<<endl;
    else if(6<=a) cout<<b/2<<endl;
    else cout<<0<<endl;
   
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#define mod 998244353
#define ll long long
#define N 1000005
#define inv 499122177

using namespace std;

int n, m;
ll fac[N], ifac[N];
ll ans;

void init();
ll quick_pow(ll ,int);
ll C(int ,int);

int main(){
	cin >> n >> m;init();
	if(n < m) swap(n, m);
	for(int i = 1; i <= m; ++i){
		int x = n - i, y = m - i;
		(ans += C(i, 2 * i) * C(x, x + y) % mod) %= mod;
	}
	(ans *= quick_pow(C(n, n + m), mod - 2) * inv % mod) %= mod;
	(ans += n) %= mod;
	cout << ans << endl;
}

void init(){
	fac[0] = 1;ifac[0] = 1;
	for(int i = 1; i <= 1e6; ++i)
		fac[i] = fac[i - 1] * i % mod, ifac[i] = quick_pow(fac[i], mod - 2);
	return ;
}

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

ll quick_pow(ll x,int y){
	ll sum = 1, a = x;
	while(y){
		if(y & 1) (sum *= a) %= mod;
		(a *= a) %= mod;
		y >>= 1;
	}
	return sum;
}


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

long long N, M;
//            right   , left
vector<pair<long long ,long long> >vec;

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

	for(long long i = 0; i < M; i++){
		long long a, b;
		cin >> a >> b;
		vec.push_back(make_pair(b, a));
	}
	sort(vec.begin(), vec.end());

	long long num = 0;
	long long cur = -1;

	for(long long i = 0; i < vec.size(); i++){
		long long right = vec[i].first;
		long long left = vec[i].second;

		if(left <= cur){
			continue;
		}
		cur = right - 1;
		num++;
	}
	cout << num << endl;
}

Measured memory_bytes: 2420
#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];

    set<int> ans;
    for(int i = 0; i < N; i++){
        if(ans.find(A[i]) != ans.end()) ans.erase(A[i]);
        else ans.insert(A[i]);
    }

    cout << ans.size() << endl;

    return 0;
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
#include <stdio.h>
#include <numeric>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define INF 9223372036854775807
#define pairint pair<int,int>
int num[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
bool uru(int checkyear){if(checkyear%4==0){if(checkyear%100!=0||checkyear%400==0)return true;}return false;}
int gcd( int x, int y ){return y ? gcd(y, x%y) : x;}
signed main() {
int x=0,y=2,z=0,w=0,n=0,m=0;
string s;
std::cin >>s;
if(s[0]==s[1]&&s[1]==s[2])cout <<"Yes";
else if(s[1]==s[2]&&s[2]==s[3]) cout <<"Yes";
else cout <<"No";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const int mINF = -1001001001;

int main() {
int n,x,y;
cin >> n >> x >> y;
int g[n][n]={INF};
REP(i,n-1) {
  g[i][i+1]=1;
  g[i+1][i]=1;
}
g[x-1][y-1]=1;
g[y-1][x-1]=1;
int temp;
REP(i,n) {
  REP(j,n) {
    temp=abs(i-x+1)+abs(j-y+1)+1;
    temp = min(temp,abs(j-i));
    g[i][j] = temp;
  }
}
int ans[n-1]={0};
REP(i,n-1) {
  for(int j=i+1;j<n;j++) {
    ans[g[i][j]-1]++;
  }
}
REP(i,n-1) cout << ans[i] << endl;
return 0;
}


Measured memory_bytes: 15872
#include <iostream>
#include <cstdio>
#include <map>
#include <algorithm>
#include <set>
#include <vector>
#include <queue>
#include <assert.h>

using namespace std;

typedef long long ll;

int Q, psum[100005];
bool prime[100005];
int main() {
  fill(prime, prime + 100001, true);
  prime[1] = false;
  for (int i = 2; i * i <= 100000; i++) {
    if (!prime[i]) continue;
    for (int j = 2 * i; j <= 100000; j += i) {
      prime[j] = false;
    }
  }
  for (int i = 3; i <= 100000; i++) {
    psum[i] = psum[i - 1];
    if (prime[i] && prime[(i + 1) / 2]) {
      psum[i]++;
    }
  }
  scanf("%d", &Q);
  for (int i = 0; i < Q; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    printf("%d\n", psum[b] - psum[a - 1]);
  }
  return 0;
}

Measured memory_bytes: 1152
use strict;
my $N=<>;
my $s = <>; chomp $s;
my @L = split(/ /,$s);
my $count=0;
my $a=0;
while($L[$a+1]>0){if($L[$a]>$L[$a+1]){$count=$count+($L[$a]-$L[$a+1]);$L[$a+1]=$L[$a];}$a=$a+1;}
print "$count";

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

int main(){
  int n,k;
  cin >>n >>k;
  string s;
  cin >>s;
  s[k-1] = s[k-1] + 32;
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 256
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>

constexpr int64_t DIV1097 = 1000000007LL;

using namespace std;

int main()
{
    int64_t N, M;
    std::cin >> N >> M;

    auto base_count = std::min(N, M/2);

    N -= base_count;
    M -= base_count*2;

    if (N == 0) {
        // c をSに割り振る
        std::cout << base_count + M/4 << std::endl;
    }
    else {
        // cが足りないからこれ以上どうしようもない
        std::cout << base_count << std::endl;
    }
    return 0;
}


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

#define MAX 1000000

struct Node {
    int parent, left, right;
};

struct Node T[MAX];
int D[MAX];
int get_depth(int);
void setDepth(int, int);

int main() {
    int n;
    int n2;
    int n3;
    int node;

    cin >> n;
    for (int i = 0; i < n; i++) { T[i].parent = T[i].left = T[i].right = -1;}
    
    for (int i = 0; i < n; i++) {
        int prev_node = -1;
        cin >> n2 >> n3;
        //cout << "n2: " << n2 << ", n3:" << n3 << endl;
        for (int i2 = 0; i2 < n3; i2++) {
            cin >> node;
            if (i2 == 0) T[n2].left = node;
            T[node].parent = n2;
            if (prev_node != -1) T[prev_node].right = node;
            prev_node = node; 
        }
    }

    //for (int i = 0; i < n; i++){
    //    cout << "Node:" << i << ", " << T[i].parent << ", " << T[i].left << ", " << T[i].right << ", " << endl;
    //}
    //
    int r;
    for (int i = 0; i < n; i++){
        if (T[i].parent == -1) r = i;
    }

    setDepth(r, 0);
    int c;
    int a[100];
    int parent;
    for (int i = 0; i < n; i++){
        cout << "node " << i << ": parent = " << T[i].parent << ", depth = " ;
        //cout << get_depth(i) << ", " ;
        cout << D[i] << ", " ;
        c = T[i].left;
        int depth = 0;
        if (T[i].parent == -1) cout << "root, " ;
        else if (T[i].left == -1) cout << "leaf, ";
        else cout << "internal node, ";
        cout << "[";
        int is_first = -1;
        while (c != -1) {
         if (is_first != -1) cout << ", ";
         cout << c;
        c = T[c].right;
        is_first = 1;
        }
        cout << "]";
        cout << endl;
    }
    return 0;

}

int get_depth(int node_id){
    int depth = 0;
    int c;
    c = T[node_id].parent;
        
    while (c != -1) {
        depth++;
        c = T[c].parent;
    }
    return depth;
}

int p;
int u;
void setDepth(int u, int p) {
    D[u] = p;
        if (T[u].right != -1)
            setDepth(T[u].right, p);
        if (T[u].left != -1)
            setDepth(T[u].left, p + 1);
}

Measured memory_bytes: 8768
#include <algorithm>
#include <iostream>
using namespace std;
#define repl(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)
using ll = long long;
int main() {
	int n, k;
	cin >> n >> k;
	int a[n];
	rep(i, n) cin >> a[i];
	int p = a[0];
	rep(i, n) p = __gcd(p, a[i]);
	bool ch = 0;
	rep(i, n) {
		if (k > a[i]) continue;
		if ((a[i] - k) % p == 0) ch = 1;
	}
	cout << (ch ? "POSSIBLE" : "IMPOSSIBLE") << endl;
	return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>

#include <algorithm>
#include <random>
#include <bitset>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <chrono>
#include <iostream>
#include <limits>
#include <numeric>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main() {
#ifdef LBT
  freopen("test.in", "r", stdin);
  int nol_cl = clock();
#endif

  int n;
  scanf("%d", &n);
  vector<pair<int, int>> ed;
  if (n & 1) {
    for (int i = 1; i <= n; ++i)
      for (int j = n; j > i; --j)
        if (i + j != n)
          ed.emplace_back(i, j);
  } else {
    for (int i = 1; i <= n; ++i)
      for (int j = n; j > i; --j)
        if (i + j != n + 1)
          ed.emplace_back(i, j);
  }
  printf("%lu\n", ed.size());
  for (auto e : ed)
    printf("%d %d\n", e.first, e.second);

#ifdef LBT
  LOG("Time: %dms\n", int ((clock()
          -nol_cl) / (double)CLOCKS_PER_SEC * 1000));
#endif
  return 0;
}


Measured memory_bytes: 384
fun main(args: Array<String>) {
  val w = readLine()!!
  var ls = mutableMapOf(' ' to 0)
  for(s in w){
    ls[s] = 1+if(ls.containsKey(s)) ls[s]!! else 0
  }
  var f = true
  ls.forEach{
      if(it.value%2 != 0){f = false}
  }
  println(if(f) "Yes" else "No")
}

Measured memory_bytes: 33668
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int N;
  cin >> N;
  int h[N];
  for(int i=0; i<N; i++) cin >> h[i];
  int dp[N+2];
  const int INF = 1e9;
  for(int i=0; i<N+2; i++) dp[i] = INF;
  dp[0] = 0;
  
  for(int i=0; i<N; i++){
    dp[i+1] = min(dp[i+1], dp[i] + abs(h[i+1]-h[i]));
    if(i < N-1) dp[i+2] = min(dp[i+2], dp[i] + abs(h[i+2]-h[i]));
  }
  cout << dp[N-1] << endl;
  return 0;
}


Measured memory_bytes: 1024
from collections import deque
S = deque(input())
Q = int(input())
reverse = 0
Tlist = []
for i in range(Q):
    Tlist.append(list(input().split()))
    if Tlist[i][0] == str(2):
        if (int(Tlist[i][1])+reverse) % 2 == 0:
            S.append(Tlist[i][2])
        else:
            S.appendleft(Tlist[i][2])
    else:
        if reverse == 1:
            reverse = 0
        else:
            reverse = 1
if reverse == 0:
    print(''.join(S))
else:
    S.reverse()
    print(''.join(S))


Measured memory_bytes: 34684
#include<iostream>
#include<map>
using namespace std;
#define ll long long

ll gcd(ll a, ll b) {
  ll c;
  if (a>b) { c=a; a=b; b=c; }
  while(a>0) { c=a; a=b%a; b=c; }
  return b;
}

map<ll, ll> factorize(ll a) {
  map<ll, ll> factors;
  ll v = a;
  for(ll p=2; p*p<=a; ++p){
    if(v%p==0) factors[p]=0;
    while(v%p==0) { v/=p; ++factors[p]; }
  }
  if(v>1) factors[v]=1;
  return factors;
}


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

  ll ans = 0;
  for(ll n=1; n<=N; n+=2) {
    map<ll, ll> f = factorize(n);
    ll d=1;
    for(auto itr=f.begin(); itr!=f.end(); ++itr) d*=(1+itr->second);
    if(d==8) ++ans;
  }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
 
template<typename T>
struct lca {
  int n, root, l;
  vector<vector<int>> to;
  vector<vector<T>> co;
  vector<int> dep;
  vector<T> costs;
  vector<vector<int>> par;
  lca(int n):n(n),to(n),co(n),dep(n),costs(n) {
    l = 0;
    while ((1<<l) < n) ++l;
    par = vector<vector<int>>(n+1,vector<int>(l,n));
  }
  void addEdge(int a, int b, T c=0) {
    to[a].push_back(b); co[a].push_back(c);
    to[b].push_back(a); co[b].push_back(c);
  }
  void dfs(int v, int d=0, T c=0, int p=-1) {
    if (p != -1) par[v][0] = p;
    dep[v] = d;
    costs[v] = c;
    for (int i = 0; i < to[v].size(); ++i) {
      int u = to[v][i];
      if (u == p) continue;
      dfs(u, d+1, c+co[v][i], v);
    }
  }
 
  void init(int _root=0) {
    root = _root;
    dfs(root);
    for (int i = 0; i < l-1; ++i) {
      for (int v = 0; v < n; ++v) {
        par[v][i+1] = par[par[v][i]][i];
      }
    }
  }
  // LCA
  int operator()(int a, int b) {
    if (dep[a] > dep[b]) swap(a,b);
    int gap = dep[b]-dep[a];
    for (int i = l-1; i >= 0; --i) {
      int len = 1<<i;
      if (gap >= len) {
        gap -= len;
        b = par[b][i];
      }
    }
    if (a == b) return a;
    for (int i = l-1; i >= 0; --i) {
      int na = par[a][i];
      int nb = par[b][i];
      if (na != nb) a = na, b = nb;
    }
    return par[a][0];
  }
  int length(int a, int b) {
    int c = lca(a,b);
    return dep[a]+dep[b]-dep[c]*2;
  }
  T dist(int a, int b) {
    int c = lca(a,b);
    return costs[a]+costs[b]-costs[c]*2;
  }
};
 
 
const int MX = 100005;
struct Edge {
  int to, co, col;
  Edge(int to, int co, int col):to(to),co(co),col(col) {}
};
vector<Edge> es[MX];
 
vector<ll> ans;
struct Query {
  int col, qid, coeff, y;
  Query(int col, int qid, int coeff, int y):col(col),qid(qid),coeff(coeff),y(y) {}
};
vector<Query> qs[MX];
int cnt[MX];
ll sum[MX];
 
void dfs2(int v, int p=-1) {
  for (auto q : qs[v]) {
    ll x = -sum[q.col];
    x += (ll)q.y*cnt[q.col];
    ans[q.qid] += x*q.coeff;
  }
  for (auto e : es[v]) {
    if (e.to == p) continue;
    cnt[e.col]++; sum[e.col] += e.co;
    dfs2(e.to, v);
    cnt[e.col]--; sum[e.col] -= e.co;
  }
}
 
int main() {
  int n, q;
  cin >> n >> q;
  lca<ll> g(n);
  rep(i,n-1) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    --a; --b;
    es[a].emplace_back(b,d,c);
    es[b].emplace_back(a,d,c);
    g.addEdge(a,b,d);
  }
  g.init();
  ans = vector<ll>(q);
  rep(i,q) {
    int x, y, a, b;
    cin >> x >> y >> a >> b;
    --a; --b;
    int c = g(a,b);
    ans[i] = g.costs[a]+g.costs[b]-g.costs[c]*2;
    qs[a].emplace_back(x,i,1,y);
    qs[b].emplace_back(x,i,1,y);
    qs[c].emplace_back(x,i,-2,y);
  }
  dfs2(0);
  rep(i,q) {
    printf("%lld\n",ans[i]);
  }
  return 0;
}

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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define RREP(i,s,n) for(lli i=s;i>=n;i--)
#define MOD 1000000007
#define NUM 2520
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define INF (1LL<<50)

signed main(){

	string s;
	string pre[2]={""};

	cin>>s;

	int cnt=0;
	lli q;
	cin>>q;
	REP(i,0,q){
		lli Q;
		cin>>Q;
		if(Q==1)cnt++;
		else{
			lli f;
			char c;
			cin>>f>>c;
			f--;
			pre[(cnt+f)%2].push_back(c);
		}
	}
	if(cnt%2){
		reverse(s.begin(),s.end());
	}
	reverse(pre[cnt%2].begin(),pre[cnt%2].end());
	cout<<pre[cnt%2]<<s<<pre[(cnt+1)%2]<<endl;

	return 0;
}

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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;

  while(1) {
    c -= b;
    if (c <= 0) {
      cout << "Yes" << endl;
      break;
    }

    a -= d;
    if (a <= 0) {
      cout << "No" << endl;
      break;
    }
  }
}

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

int main() {
    int n;
    cin >> n;
    vector<ll>a(n);
    ll sum = 0;
    int cnt = 0;
    bool ok = false;
    ll minv = 1001001001;
    rep(i,n) {
        cin >> a[i];
        sum += abs(a[i]);
        if(a[i] < 0) cnt++;
        if(a[i] == 0) ok = true;
        minv = min(minv,abs(a[i]));
    }
    if(ok || cnt%2==0) {
        cout << sum << endl;
        return 0;
    } else {
        sum -= 2*abs(minv);
        cout << sum << endl;
    }

}

Measured memory_bytes: 4040
#include<iostream>
//#include<algorithm>
//#include<cmath>
//#include<string>
//#include<cctype>
//#include <vector>
using namespace std;
int main() {
	int n;
	cin>>n;
	while (n--) {
		int r, t;
		cin>>r>>t;
		int a = 5 * (t / 30) + (r / 100 + 1),
			b = 5 * (t / 30 + 1) + (r / 100),
			c = 5 * (t / 30 + 1) + (r / 100 + 1);
		cout << 5 * (t / 30) + (r / 100);
		if (!(r % 100) && !(t % 30)); 
		else if (!(t % 30)) cout <<" " << a;
		else if (!(r % 100)) cout <<" "<< b;
		else cout << " " << a << " " << b << " " << c;
		cout << endl;
	}
	return 0;
}

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

using namespace std;
#define  ll long long
#define ld long double
#define f first
#define s second
//#define x real()
//#define y imag()
#define length(a) (hypot((a).imag() , (a).real()))
#define point complex<ld>
#define perp(a) point((-(a).Y,(a).X))
#define dot(a,b) ( (conj(a)*(b)).real() )
#define cross(a,b) ( (conj(a)*(b)).imag() )
#define rotate0(p,ang) (p * exp(point(0,ang)) )

deque<int> red,white;
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int n;
    cin >> n;

    string s;
    cin >> s;
    for(int i=0; i<s.size(); i++)
    {
        if (s[i] == 'R') red.push_back(i);
        else white.push_back(i);
    }

    if (!white.size())
        return cout << "0\n" , 0;

    int ans=0;
    for(int i=0; i<=s.size(); i++)
    {
        if (white.size() && red.size() && white.front() < red.back())
        {
            ans++;
            red.pop_back() , white.pop_front();
        }
        else break;
    }

    cout << ans << '\n';

    return 0;
}


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

int main() {
    int N, K, Q; cin >> N >> K >> Q;
    vector<int> v(N, 0);
    for (int i = 0; i < Q; i++)
    {
        int A; cin >> A;
        A--;
        v[A]++;
    }
    for (int i = 0; i < N; i++)
    {
        if(Q-v[i]<K) cout << "Yes" << endl;
        else cout << "No" << endl; 
    }
    
}

Measured memory_bytes: 1024
import bisect
from math import ceil

N, H = map(int, input().strip().split())

a = [0]*N
b = [0]*N

for i in range(N):
  a[i], b[i] = map(int, input().strip().split())

a_max = max(a)

ans = 0
b.sort()
a.sort()
damage = 0
while damage < H:
  if len(b) >= 1 and b[-1] > a_max:
    damage += b.pop()
    ans += 1
  else:
    ans += ceil((H-damage)/a[-1])
    damage = H
print(ans)


Measured memory_bytes: 11312
#include <bits/stdc++.h>
#define ll long long
#define sz(x) (int)(x).size()
using namespace std;

const int mod=1e9+7;
int dp[667][2001];

int add(int a, int b)
{
    a+=b;
    if (a>=mod)
        a-=mod;
    return a;
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n,pre,ans=0;
    cin>>n;
    dp[0][0]=1;
    for (int i=1;i<667;++i)
    {
        pre=0;
        for (int j=0;j<=n;++j)
        {
            if (j-3>=0)
                pre=add(pre,dp[i-1][j-3]);
            dp[i][j]=pre;
            //cout<<"dp["<<i<<"]["<<j<<"] = "<<dp[i][j]<<"\n";
        }
        ans=add(ans,dp[i][n]);
    }
    cout<<ans;
    return 0;
}

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

using namespace std;

using ll = long long;

using vi = vector<int>;
using vll = vector<ll>;

using pi = pair<int, int>;
using pll = pair<ll, ll>;

constexpr auto MOD = 1e9 + 7;
constexpr auto INF = 0x3f3f3f3f;

#define rep(i, a, b) for (auto i = a; i < b; ++i)

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

template <class T> void print(const T &val) { cout << val << '\n'; }

template <class Iterator> void print(Iterator begin, Iterator end) {
  for (auto it = begin; it != end; ++it) {
    cout << *it << ' ';
  }

  cout << '\n';
}

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

  char x;
  cin >> x;

  if (x == 'A') {
    print('T');
  }
  if (x == 'T') {
    print('A');
  }
  if (x == 'C') {
    print('G');
  }
  if (x == 'G') {
    print('C');
  }
}


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

#define int long long
#define uint unsigned int
#define pii pair<int, int>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORR(i,a,b) for(int i=(a);i>=(b);--i)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) FORR(i,n,0)
#define ALL(c) ((c).begin()), ((c).end())

#define PB(a) push_back(a)
#define EMPB(...) emplace_back(__VA_ARGS__)
#define EMP(...) emplace(__VA_ARGS__)
#define MP(a,b) make_pair(a,b)
#define MT(...) make_tuple(__VA_ARGS__)

#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))

#define PW(n) (1LL << (n))

using namespace std;

template <class T> inline bool CHMIN(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template <class T> inline bool CHMAX(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> inline void SORT(T &a) { sort(a.begin(), a.end()); }
template <class T> inline void REV(T &a) { reverse(a.begin(), a.end()); }
template <class T> inline void UNI(T &a) { sort(a.begin(), a.end()); a.erase(unique(a.begin(), a.end()), a.end()); }

template <class S, class T> ostream& operator << (ostream& os, const pair<S, T> v) {
  os << "(" << v.first << ", " << v.second << ")"; return os;
}

const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;

/* ---------------------------------------------------------------------------------------------------- */

int n, m;
int x[100010];
int y[100010];

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> n >> m;
  REP(i, n) cin >> x[i];
  REP(i, m) cin >> y[i];
  int sx = 0, sy = 0;
  REP(i, n) (sx += (i-(n-i-1))*x[i]%MOD) %= MOD;
  REP(i, m) (sy += (i-(m-i-1))*y[i]%MOD) %= MOD;
  cout << sx*sy%MOD << endl;

  return 0;
}

Measured memory_bytes: 1792
//  Created by conan1024hao in 2020.
//  Copyright © 2020 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao Twitter/QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 10e16
#define MOD 1000000007
#define mod 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef long long int LL;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}

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

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????统一类型        memset()!!!!!!!!!!!!       ペナを減らせ!!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int w,h,n;cin>>w>>h>>n;
    bool color[100][100];
    memset(color,0,sizeof(color));
    for(int i=0;i<n;i++){
        int x,y,a;
        cin>>x>>y>>a;x--;y--;
        if(a==1){
            for(int p=0;p<=x;p++){
                for(int q=0;q<h;q++){
                    color[p][q]=1;
                }
            }
        }
        else if(a==2){
            for(int p=x+1;p<w;p++){
                for(int q=0;q<h;q++){
                    color[p][q]=1;
                }
            }
        }
        else if(a==3){
            for(int p=0;p<w;p++){
                for(int q=0;q<=y;q++){
                    color[p][q]=1;
                }
            }
        }
        else{
            for(int p=0;p<w;p++){
                for(int q=y+1;q<h;q++){
                    color[p][q]=1;
                }
            }
        }
    }
    int ans=0;
    for(int i=0;i<w;i++){
        for(int j=0;j<h;j++){
            if(color[i][j]==0)ans++;
        }
    }
    cout<<ans<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------








Measured memory_bytes: 896
#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 K, X;
    cin >> K >> X;
    REP(i, K + (K - 1)) { cout << X - K + 1 + i << endl; }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i= 0; i < (n); i++)
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int> l(n);
    for(int i =0; i < n; i++){
        cin >> l[i];
    }
    sort(l.begin(), l.end());
    int ans = 0;
    rep(b, n)rep(a, b){
        int ab = l[a]+l[b];
        int r = lower_bound(l.begin(), l.end(), ab) - l.begin();
        int L = b+1;
        ans += max(0, r-L);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define I_O		ios::sync_with_stdio(false),cin.tie(0)
#define ll		long long
#define ff		first
#define ss		second
#define mod 		1000000007
#define rep(i,n)	for(ll i=1;i<=n;i++)
#define repv(i,a,n)	for(ll i=a;i<=n;i++)
#define pb 		push_back
#define newl		'\n'
#define deb(x)		cout<<x<<" "
int main() 
{  
	I_O;
	int n,k;	cin>>n>>k;
	int a[n+1],sum = 0;	rep(i,n)	cin>>a[i];
	sort(a+1,a+n+1);
	rep(i,k)	sum+=a[i];
	cout<<sum;
} 


Measured memory_bytes: 3612
n = gets.to_i
acts = Array.new
n.times do
  acts << gets.chomp.split(" ").map(&:to_i)
end

# [Aを選んだ幸福度, Bを選んだ幸福度, Cを選んだ幸福度]を格納するdp用配列
dp = Array.new(n)
dp.length.times do |index|
  dp[index] = Array.new(3, 0)
end

# 初日の幸福度を格納する
3.times do |index|
  dp[0][index] = acts[0][index]
end

# 2日目〜最終日まで、それぞれの幸福度を格納する
1.upto(n - 1) do |day|
  # 前日Bの幸福度、前日Cの幸福度のうち、高い方と当日Aの幸福度を足して格納する
  dp[day][0] = [dp[day - 1][1], dp[day - 1][2]].max + acts[day][0]
  # 前日Aの幸福度、前日Cの幸福度のうち、高い方と当日Bの幸福度を足して格納する
  dp[day][1] = [dp[day - 1][0], dp[day - 1][2]].max + acts[day][1]
  # 前日Aの幸福度、前日Bの幸福度のうち、高い方と当日Cの幸福度を足して格納する
  dp[day][2] = [dp[day - 1][0], dp[day - 1][1]].max + acts[day][2]
end

# 最終日に最も高い幸福度を出力する
puts [dp[n - 1][0], dp[n - 1][1], dp[n - 1][2]].max

Measured memory_bytes: 18172
#include <map>
#include <string>
#include <vector>
#include <iostream>
using namespace std;
typedef unsigned long long ull;
const ull verse = 259;
const ull inverse = 213668850274628011;
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	int n; string s;
	cin >> n >> s;
	vector<ull> pw(2 * n + 1); pw[n] = 1;
	for (int i = n + 1; i <= 2 * n; ++i) pw[i] = verse * pw[i - 1];
	for (int i = n - 1; i >= 0; --i) pw[i] = inverse * pw[i + 1];
	vector<ull> hs(n + 1);
	vector<int> dep(n + 1);
	for (int i = 0; i < n; ++i) {
		dep[i + 1] = dep[i];
		if (s[i] == '>') ++dep[i + 1];
		if (s[i] == '<') --dep[i + 1];
		hs[i + 1] = hs[i];
		if (s[i] == '+') hs[i + 1] += pw[n + dep[i + 1]];
		if (s[i] == '-') hs[i + 1] -= pw[n + dep[i + 1]];
	}
	map<ull, int> cnt;
	long long ret = 0;
	for (int i = n; i >= 0; --i) {
		ull tar = hs[n] * pw[n + dep[i]] + hs[i];
		ret += cnt[tar];
		++cnt[hs[i]];
	}
	cout << ret << '\n';
	return 0;
}

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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<int,int>;

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

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

    int N, M, T;
    std::cin >> N >> M >> T;

    int A[110];
    for(int i=1;i<=N;++i){
        std::cin >> A[i];
    }

    A[0] = 0;
    A[N+1] = T;

    int res = 0;
    for(int i=0;i<=N;++i){
        int pathLength = (i == 0 || i == N) ? M : 2 * M;
        if(A[i+1] - A[i] < pathLength){

        }else{
            res += A[i+1] - A[i] - pathLength;
        }
    }

    std::cout << res << std::endl;
}



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

int main(){
  ll a, b, c;
  cin >> a >> b >> c;
  for(int i=1; i<=b; ++i){
    if(a*i % b == c){
      cout << "YES";
      return 0;
    }
  }

  cout << "NO";

  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt" > "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\b.answer"
struct bill {
	int id;
	ld x;
	ld y;
};
typedef ld Weight;
struct Edge {
	int src, dst;
	Weight weight;
	int id;
	Edge(int src_, int dst_, Weight weight_, const int id_) :
		src(src_), dst(dst_), weight(weight_), id(id_) { }
	Edge(int src, int dst, Weight weight) :
		src(src), dst(dst), weight(weight) { }
	Edge() :src(0), dst(0), weight(0) {

	}
};
vector<int>from;
pair<bool, vector<Weight>> spfa(const int v_num, const vector<vector<Edge>>&es, const int start) {
	vector<Weight>diss(v_num, INT_MAX);
	from = vector<int>(v_num, -1);
	queue<int>que;
	vector<bool>use(v_num);
	vector<int>count(v_num);
	que.emplace(start);
	diss[start] = 0;
	while (!que.empty()) {
		int src(que.front());
		que.pop();
		use[src] = false;
		for (auto e : es[src]) {
			const int d = e.dst;
			if (diss[src] + e.weight < diss[d]) {
				diss[d] = diss[src] + e.weight;
				from[d] = src;
				if (!use[d]) {
					use[d] = true;
					count[d]++;
					if (count[d] >= v_num)return make_pair(false, vector<Weight>());
					que.emplace(d);
				}
			}
		}
	}
	return make_pair(true, diss);
}
int main() {
	while (1) {
		int N; cin >> N;
		if (!N)break;
		vector<bill>bs;
		for (int i = 0; i < N; ++i) {
			int b; ld x, y; cin >> b >> x >> y;
			bs.push_back(bill{ b,x,y });
		}
		vector<vector<Edge>>es(N);
		for (int i = 0; i < N; ++i) {
			for (int j = 0; j < N; ++j) {
				if (i == j)continue;
				ld dx = bs[i].x - bs[j].x;
				ld dy = bs[i].y - bs[j].y;
				ld dis = sqrt((dx*dx) + (dy*dy));
				if (dis- eps <= 50) {
					es[i].push_back(Edge(i, j, dis));
				}
			}
		}
		int M; cin >> M;
		while (M--) {
			int sid, gid;
			{
				int s, g; cin >> s >> g;
				for (int i = 0; i < N; ++i) {
					if (bs[i].id == s)sid = i;
					if (bs[i].id == g)gid = i;
				}
			}
			
			auto p(spfa(N, es, sid));
			if (p.second[gid] < 1e8) {
				vector<int>roots;
				roots.push_back(bs[gid].id);
				int now = gid;
				while (now != sid) {
					now = from[now];
					roots.push_back(bs[now].id);
				}
				reverse(roots.begin(), roots.end());
				for (int i = 0; i < roots.size(); ++i) {
					cout << roots[i];
					if (i == roots.size() - 1) {
						cout << endl;
					}
					else {
						cout << " ";
					}
				}
			}
			else {
				cout << "NA" << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3064
function readInt(str) {
  return parseInt(str, 10);
}
function calc(b, N, memo){
  return memo[b-1]+
  (N-1)-b+1-memo[N-1]+memo[b-1];
}
function Main(raw: string) {
  const input = raw.split("\n");
  const N = readInt(input[0]);
  const S = input[1];
  if(S.length!==N)throw 'false';
  let memo=[];
  memo[-1]=0;
  for(let i=0;i<N;i++){
    if(S[i]==='#')
    memo[i] = memo[i-1]+1;
    else
    memo[i] = memo[i-1];
  }
  let min=10000000000;
  // console.log(memo);
  for(let b=0;b<=N;b++){
    min = Math.min(min, calc(b, N, memo));
  }
  //出力
  console.log(min);
}

//DO NOT EDIT
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

int N;
vector<vector<int>> Graph;
vector<int> sets;
vector<int> ans;
int counts = 0;

void dfs(int v, int p) {
  ans[v] = sets[counts];
  counts++;
  for (auto nv : Graph[v]) {
    if (nv == p) continue;
    dfs(nv, v);
  }
}

int main() {
  cin >> N;
  Graph.assign(N, vector<int>());
  for(int i = 0; i < N - 1; i++) {
    int u, v;
    cin >> u >> v;
    u--, v--;
    Graph[u].push_back(v);
    Graph[v].push_back(u);
  }
  sets.assign(N, 0);
  for(int i = 0; i < N; i++) cin >> sets[i];
  sort(sets.begin(), sets.end(), greater<int>());
  ans.assign(N, 0);
  dfs(0, -1);
  int sum = 0;
  for(int i = 1; i < N; i++) sum += sets[i];
  cout << sum << endl;
  for(int i = 0; i < N - 1; i++) {
    cout << ans[i] << " ";
  }
  cout << ans[N - 1] << endl;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int main(){
    int a,b,c;
    cin>>a>>b>>c;

    uint64_t ans=0;
    while(1){
        if(a%2 || b%2 || c%2) break;

        int _a,_b,_c;
        _a=(b+c)/2; _b=(c+a)/2; _c=(a+b)/2;
        if(a==_a && b==_b && c==_c){
            cout<<-1<<endl;
            return 0;
        }

        a=_a; b=_b; c=_c;
        ans++;
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
 
using ll = long long;
using namespace std;

int sum(int x) {
   if(x < 10) return x;
   return x % 10 + sum(x / 10);
}

void solveCase() {
   int n;
   cin >> n;

   int ans = 123456;
   for(int i = 1; i < n; i++) {
      int a = i;
      int b = n - a;
      int s = sum(a) + sum(b);
      if(s < ans) ans = s;
   }
   cout << ans << endl;

}

 
int main() {
   cin.tie(0);
   cin.sync_with_stdio(0);
   
   int testcase = 1;
   // cin >> testcase;
 
   for(int i = 0; i < testcase; i++) {
      solveCase();
   }
 
   return 0;
}

Measured memory_bytes: 3500
n = int(input())
s = input()
ans = 0
find = []
for i in range(1, n):
    left  = s[:i]
    right = s[i:]
    cnt = 0
    find = []
    for c in left:
        if c in right and c not in find:
            cnt += 1
            find.append(c)
    if cnt > ans:
        ans = cnt
print(ans)     

Measured memory_bytes: 3064