akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i = 0;i<((ll)(n));i++)
#define reg(i,a,b) for(ll i = ((ll)(a));i<=((ll)(b));i++)
#define irep(i,n) for(ll i = ((ll)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(ll i = ((ll)(b));i>=((ll)(a));i--)
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T = int> void print(vector<T> v){for(auto a:v)cout<<a<<" ";cout<<endl;}

/*
*/

bool ok=true;
ll n,a[100010],sum=0,c=1,ans=1;

int main(void){
	cin>>n;
	rep(i,n+1)cin>>a[i];
	rep(i,n+1)sum+=a[i];
	if(a[0]>1)ok=false;
	if(a[0]==1 && n!=0)ok=false;
	reg(i,1,n){
		sum-=a[i];
		ll yoyuu = min(c*2 - a[i], sum);  // 何個下に伸ばせるか
		if(yoyuu<0)ok = false;
		c = yoyuu;
		ans += c+a[i];
	}
	cout<<(ok ? ans : -1)<<endl;
	return 0;
}

Measured memory_bytes: 4420
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<string>
#include<cstdlib>
#include<cctype>
#include<unordered_map>
#include<sstream>
#include<numeric>
#include<stack>
// #include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1LL<<60;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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やllをstringに変換
template<typename T> inline string toString(const T &a){
  ostringstream oss;
  oss << a;
  return oss.str();
};
// ----------------------------------------------------------------------------

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

int main(){
  int x,y;
  cin >> x >> y;
  int g = gcd(x,y);
  cout << (x/g-1+y/g-1+1)*g+1 << endl;
  return 0;
}



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

int main () {
  int N;
  cin >> N;
  vector <double> num(N);
  for (int i = 0; i < N; i++) cin >> num.at(i);
  sort (num.begin(),num.end());
  double ans = 0;
  for (int i = N; i > 1; i--) {
    for (int j = 0; j < i; j++){
      num.at(j) /= 2;
    }
  }
  for (int i = 0; i < N; i++) ans += num.at(i);
  cout << fixed << setprecision(6);
  cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())
S = [input() for i in range(2)]

c = 0
if S[0][0] == S[1][0]:
    n = 3
    s = 'tate'
    c += 1
else:
    n = 6
    s = 'yoko'
    c += 2

while c < N:
    if S[0][c] == S[1][c]:
        if s == 'tate':
            n *= 2
            c += 1
        else:
            s = 'tate'
            c += 1
    else:
        if s == 'tate':
            n *= 2
            s = 'yoko'
            c += 2
        else:
            n *= 3
            c += 2

print(n % 1000000007)

Measured memory_bytes: 3064
#include<stdio.h>
main(){
  int n;
  int m,e,j,i;
  char a;
  while(1){
    scanf("%d",&n);
    if(n==0)break;
    for(i=0;i<n;i++){
      scanf("%d %d %d",&m,&e,&j);
      if((m==100||e==100||j==100)||((m+e)/2>=90)||((m+e+j)/3>=80))a='A';
      else if((m+e+j)/3>=70||((m+e+j)/3>=50&&(m>=80||e>=80)))a='B';
      else a='C';
      printf("%c\n",a);
    }
  }
  return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <algorithm>
using namespace std;
 
int main(){
    int i;
    int list[10];
    for(i=0;i<10;i++){
        cin >> list[i];
    }
    sort(list,list+10);
    for(i=0;i<3;i++){
        cout << list[9-i] << endl;
    }
    return 0;
}


Measured memory_bytes: 3132
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t A,B,C,K;
  cin >> A >> B >> C >> K;
  int ans = 0;
  if(K %2 == 0){
    ans = A-B;
  }
  else{
    ans = B-A;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>//数据输入输出流
#include <cstring>//字符串操作函数
#include <cstdio>//C的输入输出
#include <cstdlib>//定义杂项函数及内存分配函数
#include <cmath>//C中的数学函数
#include <string>//c++中的string类 他不能用strcpy等c函数去操作
#include <vector>//STL vetor
#include <list>//STL list
#include <map>// STL map
#include <queue>// STL queue
#include <stack>//sTL stack
#include <bitset>//bitset可按位定义串
//比如：bitset <1000> all;定义一个1000位的串
#include <algorithm>//STL各种算法 比如 swap sort merge max min 比较
#include <numeric>//常用数字操作 一般和algorithm搭配使用
#include <functional>//STL定义运算函数（代替运算符）
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
#define LOCAL
#define zeros(a,n) memset(a,0,(n)*sizeof(a[0]))
const int modn = 1e9+7;
int mod(int x) { return x<0?x+modn:x<modn?x:x-modn; }
//inv [ i ] = (modn - modn/i)*inv[ modn%i ] %modn;

int main()
{
    ios::sync_with_stdio(false); cin.tie(0);
    int n;
    cin>> n;
    bool f = false;
    while(n){
        int t = n % 10;
        n /= 10;
        if(t == 7) f = true;
    }
    if(f) puts("Yes");
    else puts("No");
    return 0;
}



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

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

int main()
{
    ll a,b;scanf("%lld %ld",&a,&b);
    cout<<(a*b)/gcd(a,b);
    return 0;
}

Measured memory_bytes: 256
H, W = map(int,input().split())
B = []
for _ in range(H):
    line = input()
    for l in line:
        if l == "#":
            B.append(line)
            break;

White = []
for i in range(W):
    flag = True
    for j in range(len(B)):
        if B[j][i] == "#":
            flag = False
    if flag:
        White.append(i)

for i in range(len(B)):
    line = B[i]
    for i, l in enumerate(line):
        if i not in White:
            print(l,end="")
    print()


Measured memory_bytes: 44520
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <climits>
#include <cmath>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define FOR(i, m, n) for (int i = (int)m; i < (int)n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.end(); itr++)
#define REPe(e, mp) for (auto& e : mp)
#define all(x) x.begin(), x.end()
#define MOD 1000000007  // 1e9+7
using namespace std;
using ll = long long int;
using vecint = vector<int>;
using vecll = vector<ll>;
using vec2int = vector<vector<int>>;
using P = pair<int, int>;
////////////////////////////////////////////////
////////////////////////////////////////////////
int main() {
  ////////////////////////////////////////////////
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ////////////////////////////////////////////////
  int n;
  cin >> n;
  int m = 0;
  FOR(i, 1, 1e4) {
    if (i * (i + 1) / 2 >= n) {
      m = i;
      break;
    }
  }
  vecint ans;
  int sum = 0;
  for (int i = m; i > 0; i--) {
    // cout << i << " " << sum << endl;
    if (sum + i <= n) {
      sum += i;
      ans.push_back(i);
    } else {
    }
    if (sum == n) {
      break;
    }
  }
  sort(all(ans));
  REPe(e, ans) cout << e << endl;
}
//////////////////////////////////////////////


Measured memory_bytes: 384
#include<iostream>
using namespace std;
int ans;
int a,b;
int main()
{
	cin>>a>>b;
	if(b==1)
	{
		cout<<0<<endl;
		return 0;
	}
	b--,a--;
	if(b%a==0)
		cout<<b/a<<endl;
	else
		cout<<b/a+1<<endl;
	return 0;
}

Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby
    #from itertools import product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    n,a,b = map(int, input().split())
    h = [int(input()) for _ in range(n)]

    # x回で出来るか
    def check(x):
        cnt = 0
        for i in h:
            nokori = i - b*x
            if nokori > 0:
                cnt += nokori // (a-b)
                if nokori % (a-b) != 0:
                    cnt += 1
            if cnt > x:
                return False
        return True

    l = 0
    r = 10**10
    while r-l > 1:
        mid = (l+r) // 2
        if check(mid):
            r = mid
        else:
            l = mid

    print(r)

if __name__ == '__main__':
    main()

Measured memory_bytes: 7420
#include<stdio.h>
#include<stdlib.h>
 
typedef struct{
    int p;
    int l;
    int r;
}Node;
 
void Preorder(int);
void Inorder(int);
void Postorder(int);
 
Node *node;
 
int main(void){
    int n,id,root;
    int i;
 
    scanf("%d",&n);
 
    node=(Node*)malloc(n*sizeof(Node));
 
    for(i=0;i<n;i++){
        node[i].p=-1;
        node[i].l=-1;
        node[i].r=-1;
    }
 
    for(i=0;i<n;i++){
        scanf("%d",&id);
 
        scanf("%d",&node[id].l);
        if(node[id].l != -1) node[node[id].l].p=id;
 
        scanf("%d",&node[id].r);
        if(node[id].r != -1) node[node[id].r].p=id;
    }
 
    for(i=0;i<n;i++){
        if(node[i].p==-1) root=i;
    }
 
    printf("Preorder\n");
    Preorder(root);
    printf("\n");
 
    printf("Inorder\n");
    Inorder(root);
    printf("\n");
 
    printf("Postorder\n");
    Postorder(root);
    printf("\n");
 
    free(node);
 
    return 0;
}
 
void Preorder(int id){
    printf(" %d",id);
    if(node[id].l != -1) Preorder(node[id].l);
    if(node[id].r != -1) Preorder(node[id].r);
}
 
void Inorder(int id){
    if(node[id].l != -1) Inorder(node[id].l);
    printf(" %d",id);
    if(node[id].r != -1) Inorder(node[id].r);
}
 
void Postorder(int id){
    if(node[id].l != -1) Postorder(node[id].l);
    if(node[id].r != -1) Postorder(node[id].r);
    printf(" %d",id);
}

Measured memory_bytes: 616
S = input()
n = len(S)
 
def dfs(i, k):
    
    if i == n-1:
        return sum(list(map(int,k.split("+"))))
    
    return dfs(i+1,k+S[i+1])+dfs(i+1,k+"+"+S[i+1])
 
print(dfs(0,S[0]))

Measured memory_bytes: 3064
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
using namespace std;
typedef long long ll;
string s;
int main(void){
  cin >> s;
  for(int i = 0; i < (int)s.size(); i++)
    cout << (s[i]==','?' ':s[i]);
  cout << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<fstream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cassert>
#include<cctype>
#include<ctime>
#include<cstdlib>
#include<map>
#include<set>
#include<bitset>
#include<queue>
#include<deque>
#include<stack>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
using namespace std;
#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define il inline
#define rg register
#define lch(x) ((x)<<1)
#define rch(x) ((x)<<1^1)
#define rep(i,st,ed) for(rg int i=(st);i<=(ed);++i)
#define per(i,ed,st) for(rg int i=(ed);i>=(st);--i)
#define rep0(i,n) for(rg int i=0;i<(n);++i)
#define per0(i,n) for(rg int i=(n)-1;i>=0;--i)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef double dbl;
typedef long double ldb;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<typename T> il T qmin(const T &x,const T &y){return x<y?x:y;}
template<typename T> il T qmax(const T &x,const T &y){return x>y?x:y;}
template<typename T> il void getmin(T &x,const T &y){if(y<x) x=y;}
template<typename T> il void getmax(T &x,const T &y){if(y>x) x=y;}
il void fileio(const string &s){
	freopen((s+".in").c_str(),"r",stdin);
	freopen((s+".out").c_str(),"w",stdout);
}

const int inf=(int)1e9+7;
const ll linf=(ll)1e18+7;

int a,b,c;
ll k;

int main(){
	scanf("%d%d%d%lld",&a,&b,&c,&k);
	printf("%d\n",k&1?b-a:a-b);
	return 0;
}


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

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
#define loop(i, a) for (int i = 0; i < a; i++)
#define revloop(i, a) for (int i = a-1; i > -1; i--)
#define show(a) cout << a << "\n"
#define MOD 1000000007
#define V vector
#define S set
#define P pair
#define M map
#define PQ priority_queue

V< P<int, LL> > v[100000];
LL cost[100000];
void shortest_path (int ver) {
    loop(i, v[ver].size()) {
        if (cost[v[ver][i].first] == -1) {
            cost[v[ver][i].first] = cost[ver] + v[ver][i].second;
            shortest_path(v[ver][i].first);
        }
    }
}
int main() {
    //freopen("inputs.txt", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin >> n;
    loop(i, n-1) {
        int a, b;
        LL c;
        cin >> a >> b >> c;
        v[a-1].push_back(make_pair(b-1, c));
        v[b-1].push_back(make_pair(a-1, c));
    }
    int q, k;
    cin >> q >> k;
    memset(cost, -1, sizeof(cost));
    cost[k-1] = 0;
    shortest_path(k-1);
    loop(i, q) {
        int x, y;
        cin >> x >> y;
        show(cost[x-1]+cost[y-1]);
    }

    return 0;
}


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

#define hell                         1000000007
#define lcm(a,b)                     (a*b)/__gcd(a,b)
#define ll                           long long
#define vll                          vector<ll>
#define vi                           vector<int>
#define pll                          vector< pair<ll,ll> >
#define pb                           push_back
#define mp                           make_pair
#define all(v)                       v.begin(),v.end()
#define lbnd                         lower_bound
#define ubnd                         upper_bound
#define bs                           binary_search
#define F                            first
#define S                            second
#define rep(i,a,b)                   for(i=a;i<b;i++)
#define parr(a,n)                    for(ll it=0;it<n;it++) cout<<a[it]<<" ";cout<<endl;
#define pcont(a)                     for(auto it:a) cout<<it<<" ";cout<<endl;
#define ret(x)                       return cout<<x,0;
#define endl                           '\n'

/*constants*/
#define MAXN                         100005
#define PI                           3.14159265358979323846

/*debug*/
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>void __f(const char* name, Arg1&& arg1){ std::cout << name << " : " << arg1 << '\n';}
    template <typename Arg1, typename... Args>void __f(const char* names, Arg1&& arg1, Args&&... args){const char* comma = strchr(names + 1, ','); std::cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);}
#else
#define trace(...)
#endif

using namespace std;


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	
	ll i,j,n,m,k,cnt=0,ans=0,t=1;
	cin>>n;
	ll a[n];
	rep(i,0,n) cin>>a[i];
	ll p[n+1],s[n+1];
	p[0]=a[0],s[n-1]=a[n-1];
	rep(i,1,n) p[i]=__gcd(p[i-1],a[i]);
	for(i=n-2;i>=0;i--) s[i]=__gcd(s[i+1],a[i]);
	ans=max(s[1],p[n-2]);
	rep(i,1,n-1) ans=max(ans,__gcd(p[i-1],s[i+1]));
	ret(ans)
	
	return 0;
}

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

int main() {
  int64_t n, x;
  cin >> n >> x;
  vector<int64_t> vec(n);
  for (int i = 0; i < n; i++) {
    cin >> vec.at(i);
  }
  vec.push_back(x);
  sort(vec.begin(), vec.end());
  int64_t ans = 0;
  for (int i = 1; i < n+1; i++) {
    int64_t a = abs(vec.at(i) - vec.at(i-1));
    ans = __gcd(ans, a);
  }
  cout << ans << endl;
}




Measured memory_bytes: 1792
import java.util.*;

public class Main{
	public static void main(String[] $){
		Scanner s=new Scanner(System.in);
		int[]c={0,0};
		s.next().chars().forEach(i->++c[i-'0']);
		System.err.println(Arrays.toString(c));
		System.out.println(Math.min(c[0],c[1])*2);
	}
}


Measured memory_bytes: 28696
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define endl '\n'
int mod=1e9+7;
int mod2=998244353;

signed main(){
  while(true){
    int n;
    cin>>n;
    if(!n)break;
    vector<int> a(n);
    for(int i=0;i<n;i++)cin>>a[i];
    sort(a.begin(),a.end());
    int ans=1e9;
    for(int i=0;i<n-1;i++){
      ans=min(ans,abs(a[i]-a[i+1]));
    }
    cout<<ans<<endl;
  }
}



Measured memory_bytes: 3064
#include <stdio.h>
#include <iostream>
#include <queue>
#include <cstdio>
#include <stack>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string.h>
#include <limits.h>
using namespace std;
int main() {
    int n;
    cin>>n;
    int t=n%10;
    if(t==2||t==4||t==5||t==7||t==9) cout<<"hon"<<endl;
    if(t==0||t==1||t==6||t==8) cout<<"pon"<<endl;
    if(t==3) cout<<"bon"<<endl;
    return 0;
}

Measured memory_bytes: 3636
// ░░░░░░░░( •̪●)░░░░░░░░░░░░░░░░░░░░░░░░
// ░░░░░░███████ ]▄▄▄▄▄▄▄▄▃░░░▃░░░░ ▃░
// ▂▄▅█████████▅▄▃▂░░░░░░░░░░░░░░░░░
// [███████████████████].░░░░░░░░░░░░░░
// ◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤...░░░░░░░░░░░░

//PointBlank's code (⌐■_■)

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
#define repp(I, A, B) for(int I = A; I <= B; I++)
#define rep(I, A, B) for(int I = A; I < B; I++)
#define rrep(I, B, A) for(int I = B; I >= A; I--)
#define pb emplace_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define LB lower_bound
#define UB upper_bound
#define MP make_pair
#define mem(A, B) memset(A, B, sizeof(A));
#define mem0(A) memset(A, 0, sizeof(A));
#define quickio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define in_edges(M) repp(I, 1, M){ll A, B; cin >> A >> B; v[A].pb(B), v[B].pb(A);}
#define in_edges2(M) repp(I, 1, M){ll A, B; cin >> A >> B; v[A].pb(B);}
#define endl "\n"
#define debug(this) cerr<<"> "<<#this<<" : "<<this<<"\n"
#define bitsf(n) __builtin_popcount(n)
ll power(ll x, ll y); 

const ll MOD = 1000000007;
 
int main() //PointBlank's code ¯\_(ツ)_/¯
{
    string s;
    cin >> s;
    int n = s.size() - 2;
    while(n > 0){
        int flag = 1;
        rep(i, 0, n/2) if(s[i] != s[i + n/2]) flag = 0;
        if(flag) break;
        n -= 2;
    }

    cout << n;
}
 
ll power(ll x, ll y)
{ 
    ll res = 1; x %= MOD;
    while(y > 0){if(y & 1) res = (res*x) % MOD; y = y>>1, x = (x*x) % MOD;} 
    return res; 
}


Measured memory_bytes: 256
S = input()

l = ['dream', 'dreamer', 'erase', 'eraser']

while S:
    if len(S) < 5:
        print('NO')
        exit()
    elif S[-5:] in l:
        S = S[:-5]
    elif S[-6:] in l:
        S = S[:-6]
    elif S[-7:] in l:
        S = S[:-7]
    else:
        print('NO')
        exit()
print('YES')

Measured memory_bytes: 3188
c500 = int(input())
c100 = int(input())
c50 = int(input())
t = int(input())
s = 0

for a in range(0, c500 + 1):
    for b in range(0, c100 + 1):
        for c in range(0, c50 + 1):
            if 500*a + 100*b + 50*c == t:
                s = s + 1
print(s)


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();
		int q = sc.nextInt();
		long[][] alpha = new long[26][s.length()];
		Segment[] seg = new Segment[26];
		for (int i = 0; i < n; i++) alpha[s.charAt(i)-'a'][i]++;
		for (int i = 0; i < 26; i++) seg[i] = new Segment(alpha[i]);
		int t,b,c,l,r,count;
		char[] S = s.toCharArray();
		for (int i = 0; i < q; i++) {
			t = sc.nextInt();
			if(t==1) {
				b = sc.nextInt()-1;
				c = sc.next().charAt(0)-'a';
				if(S[b]-'a'!=c) {
					seg[S[b]-'a'].update(b, 0);
					seg[c].update(b, 1);
					S[b] = (char)(c+'a');
				}
			}else if(t==2) {
				l = sc.nextInt()-1;
				r = sc.nextInt();
				count = 0;
				for (int j = 0; j < 26; j++) {
					if(seg[j].query(l,r)>0) {
						count++;
					}
				}
				System.out.println(count);
			}
		}
		sc.close();
	}
	public static class Segment {
		int n; long[] dat; int e = 0;
		public Segment(long[] a){
			n = 1;
			while(n < a.length) n *= 2;
			dat = new long[(n<<1)-1];
			for (int i = 0; i < n; i++) dat[i+n-1] = (i<a.length)?a[i]:e;
			for (int i = n-2; i >= 0; i--) dat[i] = dat[(i<<1)+1] + dat[(i<<1)+2];
		}
		public void update(int k, long a){
			k += n-1;
			long b = dat[k];
			dat[k] = a;
			while(k>0) {
				k = (k-1)/2;
				dat[k] += a-b;
			}
		}
		private long query(int a, int b, int k, int l, int r) {
			if(r<=a||b<=l) return 0;
			if(a<=l&&r<=b) return dat[k];
			else {
				long vl = query(a,b,(k<<1)+1,l,(l+r)/2);
				long vr = query(a,b,(k<<1)+2,(l+r)/2,r);
				return vl+vr;
			}
		}
		public long query(int a, int b) {
			return query(a,b,0,0,n);
		}
		public long query() {
			return query(0,n,0,0,n);
		}
	}
}

Measured memory_bytes: 445520
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using P = pair<int,int>;
using vl = vector<ll>; using vvl = vector<vl>;
#define mp make_pair
#define pb push_back
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,n) for (int i=(n-1);i >= 0;i--)
#define all(v) v.begin(),v.end()
#define sz(v) (int)((v).size())
#define MAX(v) *max_element(all(v))
#define MIN(v) *min_element(all(v))
#define Sort(v) sort(all(v))
#define Rev(v) reverse(all(v))
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);in(name)
#define vv(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define VV(type,name,h,w) vector<vector<type>>name(h,vector<type>(w));in(name)
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cout << H << " ";
    debug_out(T...);
}
#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
    for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
    return os;
}
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
template<class T>bool chmax(T &a, const T &b) {if(a<b){a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if(b<a){a=b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll mod = 1000000007;
const int dx[8] = {1,0,-1,0,1,1,-1,-1}; const int dy[8] = {0,1,0,-1,1,1,-1,-1};

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    int d; cin >> d;
    vector<int> c(26);
    vector<vector<int>> s(d,vector<int>(26));
    
    rep(i,26) cin >> c[i];
    rep(i,d){
        rep(j,26){
            cin >> s[i][j];
        }
    }

    vector<int> t(d);
    rep(i,d){
        cin >> t[i];
        t[i]--;
    }

    ll v = 0;
    vector<int> last(26,-1);

    rep(i,d){
        v += s[i][t[i]];
        last[t[i]] = i;

        rep(j,26) v -= c[j]*(i-last[j]);
        cout << v << endl;
    }
}

Measured memory_bytes: 3688
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<queue>
#include<cmath>
#include<algorithm>
#include<iomanip>
#include<functional>
#include<set>
#include<map>
#include<climits>
#include<utility>
#define ul unsigned long long int
#define ll long long int
#define MAX 1000000+1
using namespace std;
#define F first
#define S second
#define pi 2*acos(0.0)
#define PB push_back
#define CL clear()







int main()
{

  string s;
  ll n;
  cin >> s >> n;
  ll one = 0;

  while(s[one]=='1') one++;
  if(one>= n) cout << 1;
  else cout<< s[one];


    return 0;
}



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

int pow(int A, int P){
	int a = A, p = P;
	if(p == 0) return 1;
	if(p == 1) return a;
	int adash = a * a;
	if(p % 2) return pow(adash, p / 2) * a;
	else return pow(adash, p / 2);
}

int main(){
	string S;
	cin >> S;
	int N = (int)S.size();
	int num = pow(2, N-1);
	long ans = 0;
	for(int i = 0;i<num;i++){
		int numdash = i;
		long plus = S[0] - '0';
		for(int j=1;j<N;j++){
			if(numdash % 2){
				ans += plus;
				plus = S[j] - '0';
			}
			else{
				plus *= 10;
				plus += S[j] - '0';
			}
			numdash /= 2;
		}
		ans += plus;
	}
	cout << ans << endl;
}





Measured memory_bytes: 256
x, k, d = map(int, input().split())  # x現在地,k 移動回数,D移動できる距離
x = abs(x)
a = x // d  # 移動できる回数
b = x % d  # 移動した特のあまり
if k <= a:  # 移動する回数がkより大きいとき
    x = x - (k*d)
else:
    k = k - a  # ここで最短
    if k % 2 == 0:
        x = x - (a * d)
    else:
        x = x - (a * d)
        if x > 0:
            x = x - abs(d)
        else:
            x = x + abs(d)

print(abs(x))


Measured memory_bytes: 9092
import itertools

N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
num_p = 0
num_q = 0
num = [0]*N

for i in range(N):
  num[i] = i+1

seq = list(itertools.permutations(num))

for j in range(len(seq)):
  if list(seq[j]) == P:
    num_p = j+1
  if list(seq[j]) == Q:
    num_q = j+1
    
print(abs(num_p - num_q))

Measured memory_bytes: 8052
/* ***********************************************
Author        :axp
Created Time  :2017/2/4 22:24:36
TASK		  :D.cpp
LANG          :C++
************************************************ */

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;

typedef long long ll;
const int inf = 1<<30;
const int md = 1e9+7;
const int N = 1e5+10;
int n,m;
int T;
map<int,int> mp;
int ar[N];
int l[N],r[N];

bool solve()
{
	if(n==1)return ar[1]!=1;
	ll sum=0;
	int now=0;
	int v;
	for(int i=1;i<=n;i++)
	{
		sum+=ar[i];
		if(ar[i]&1)
			now++,v=i;
	}
	if((sum-n)%2)return 1;
	if(now!=1 || ar[v]==1)return 0;
	ar[v]--;
	int t=ar[v];
	for(int i=1;i<=n;i++)t=__gcd(t,ar[i]);
	for(int i=1;i<=n;i++)ar[i]/=t;
	return 1-solve();
}

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&ar[i]);
	bool ans=solve();
	puts(ans?"First":"Second");
    return 0;
}


Measured memory_bytes: 768
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<ll>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

struct UnionFind {
    vector<int> par; // 親を指すvector,-par[親]は木のサイズ
    UnionFind(int n):par(n, -1) {} // uniteで親を埋め込んでいく必要あり
    int root(int x) { // 親をたどる&データの整理
        if(par[x] < 0) return x;
        return par[x] = root(par[x]);
    }
    bool unite(int x, int y) { // データの結合
        x = root(x);
        y = root(y);
        if(x == y) return false;
        if(par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    bool same(int x, int y) {return root(x) == root(y);} // 所属判定
    int size(int x) {return -par[root(x)];} // 木のサイズ
};

struct edge {
    int u, v;
    int64_t cost;
    edge(int u=0, int v=0, int64_t cost=0):u(u), v(v), cost(cost) {} 
};

bool comp(const edge& e1, const edge& e2) {
    return e1.cost < e2.cost;
}

vector<P> pp;

// 辺の数でresize & 入力
vector<edge> es;
//最小全域木, Vは頂点数
int64_t kruskal(int V) {
    int E = es.size();
    sort(es.begin(), es.end(), comp);
    UnionFind uft(V);
    rep(i, pp.size()){
        uft.unite(pp[i].first, pp[i].second);
    }
    int64_t res = 0;
    for(int i = 0; i < E; ++i) {
        edge e = es[i];
        if(!uft.same(e.u, e.v)) {
            uft.unite(e.u, e.v);
            res += e.cost;
        }
    }
    return res;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vvi a(n, vi(n));
    rep(i, n) {
        rep(j, n) {
            cin >> a[i][j];
            if(i != j) {
                es.emplace_back(i, j, a[i][j]);
            }
        }
    }

    ll ans = 0;
    rep(i, n) {
        rep(j, i) {
            bool x = true;
            rep(k, n) {
                if(abs(a[i][k] + a[k][j]) < a[i][j]) {
                    cout << -1 << endl;
                    return 0;
                }
                if(i != k and j != k and a[i][k] + a[k][j] == a[i][j]) x = false;
            }
            if(x) {
                pp.emplace_back(i, j);
                ans += a[i][j];
            }
        }
    }


    cout << ans << endl;
}

Measured memory_bytes: 3196
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

int N,K;
vector<int> V;
int main(void) {
    cin>>N>>K;
    for(int i = 0;i < N;i++) {
        int a;
        cin>>a;
        V.push_back(a);
    }

    int max_ans = 0;
    for(int take = 0;take <= min(N,K);take++) {
        for(int l = 0;l <= take;l++) {
            int ans = 0;
            vector<int> temp;
            for(int r = take-l;r > 0;r--) {
                ans += V[N-r];
                temp.push_back(V[N-r]);
            }
            int tl = 0;
            while(tl < l) {
                ans += V[tl];
                temp.push_back(V[tl]);
                tl++;
            }

            //cout<<ans<<" "<<take<<" "<<l<<endl;
            
            sort(temp.begin(),temp.end());
            int left = 0;
            int right = temp.size()-1;
            
            for(int m = K-take;m > 0 && left <= right;m--) {
                if(temp[left] < 0) {
                    ans -= temp[left];
                    left++;
                } else {
                    break;
                }
            }
            //cout<<ans<<endl;
            
            max_ans = max(max_ans,ans);
        }
    }

    cout<<max_ans<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define int ll
#define pb push_back
#define setbits(x)          __builtin_popcountll(x)
#define endl "\n"
typedef long long ll;
int find(int a,int b,int c)
{
    int ans=0;
    ans+=a*a+b*b+c*c;
    ans+=a*b+b*c+c*a;
    return ans;
}
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int mx=101;
map<int,int> mp;
for(int i=1;i<mx;i++)
{
    for(int j=1;j<mx;j++)
    {
        for(int k=1;k<mx;k++)
        {
            int val=find(i,j,k);
            mp[val]+=1;
        }
    }
}
int n;
cin>>n;
for(int i=1;i<=n;i++)
{
    cout<<mp[i]<<endl;
}
    return 0;
}


Measured memory_bytes: 6040
#include <bits/stdc++.h>
#define double long double
#define int long long
#define mii map<int,int>
#define pii pair<int,int>
#define low lower_bound
#define upp upper_bound
#define mod 1000000007 //10^9+7
#define inf (int)50000000000000000 //5･10^16
#define rep(i,n) for(int i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define vsort(vec) sort(all(vec))
#define vrever(vec) reverse(all(vec));
#define vunsort(vec) vsort(vec); vrever(vec);
#define bisea binary_search
#define cend cout<<endl;
#define F first
#define S second
using namespace std;
int n;
int a[200010],b[200010];
signed main() {
  cin>>n;
  rep(i,n) {
    cin>>a[i];
    b[i]=a[i];
  }
  sort(a,a+n);
  int l=a[n/2-1],r=a[n/2];
  rep(i,n) {
    if(b[i]==l) {
      cout<<r<<endl;
    }
    else if(b[i]==r) {
      cout<<l<<endl;
    }
    else if(b[i]<l) {
      cout<<r<<endl;
    }
    else {
      cout<<l<<endl;
    }
  }
}

Measured memory_bytes: 5376
#include <stdio.h>
int main(void)
{
    int n,d,x;
    int a[101]={};
    scanf("%d\n%d %d",&n,&d,&x);
    int num=0;
    for(int p=0;p<n;p++)
    {
        scanf("%d",&a[p]);
        int nnn=(d-1)/a[p]+1;
        num+=nnn;
    }
    int ans=num+x;
    printf("%d",ans);
}


Measured memory_bytes: 128
#include<iostream>
#include<stdio.h>
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const int maxx = 1e5;

int main()
{
	int n, k;
	cin >> n >> k;
	cout << n-k+1 << '\n'; 

	return 0;
}

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

using namespace std;

#define x first
#define y second
#define mp make_pair
#define pb push_back

typedef long long ll;

const ll MOD = 1e9+7;

vector <int> v[100005];
int p[100005];

vector <int> a;
int sol[100005];

void dfs(int node, int par) {
	p[node] = par;
	for (int i=0 ; i<v[node].size() ; i++) {
		if (v[node][i] != par) dfs(v[node][i], node);
	}
	a.pb(node);
}

int main() {
	int n;
	scanf("%d", &n);
	for (int i=2 ; i<=n ; i++) {
		int x;
		scanf("%d", &x);
		v[i].pb(x);
		v[x].pb(i);
	}
	dfs(1, 0);
	for (int i=0 ; i<n ; i++) {
		int x = a[i];
		vector <int> deca;
		for (int j=0 ; j<v[x].size() ; j++) {
			if (v[x][j] == p[x]) continue;
			deca.pb(sol[v[x][j]]);
		}
		sort(deca.begin(), deca.end());
//		reverse(deca.begin(), deca.end());
		int ut = 0;
		for (int j=0 ; j<deca.size() ; j++) {
			ut = max(ut+1, deca[j]+1);
			/*if (x == 1) {
				cout <<"deca["<<j<<"] = "<<deca[j]<<endl;
				cout <<"ut = "<<ut<<endl;
			}*/
			sol[x] = max(sol[x], ut);
		}
	}
	//for (int i=1 ; i<=n ; i++) printf("%d ", sol[i]);
	printf("%d\n", sol[1]);
	return 0;
}

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

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

Measured memory_bytes: 256
package main

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

func main() {
	stdin := bufio.NewScanner(os.Stdin)
	stdin.Scan()
	text := stdin.Text()
	inputtext := strings.Split(text, " ")

	a, _ := strconv.Atoi(inputtext[0])
	b, _ := strconv.Atoi(inputtext[1])
	k, _ := strconv.Atoi(inputtext[2])
	takahashi := a - k
	aoki := b
	if takahashi < 0 {
		aoki = b + takahashi
		takahashi = 0
	} else if aoki < 0 {
		aoki = 0
	}
	if aoki < 0 {
		aoki = 0
	}
	fmt.Println(strconv.Itoa(takahashi) + " " + strconv.Itoa(aoki))

}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <random>
#include <iomanip>

using namespace std;
using P = pair<long, long>;

typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvinv(xs) sort(xs.begin(), xs.end(), std::greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)

#define rep(i,n) for(auto i=0; i<(n); i++)

const int mod = 1000000007;

int color[405][405];
int state[405][405];
int h, w;
int bcnt = 0;
int wcnt = 0; 

void dfs(int h_, int w_, int c) {
  if (h_ < 0 || w_ < 0 || state[h_][w_] || color[h_][w_] != c) return;
  state[h_][w_] = 1;
  if(color[h_][w_] == 1) {
    bcnt++;
  } else {
    wcnt++;
  }
  dfs(h_-1,w_,-c);
  dfs(h_,w_-1,-c);
  dfs(h_+1,w_,-c);
  dfs(h_,w_+1,-c);
}

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

  cin >> h >> w;

  rep(i, h) {
    string s;
    cin >> s;
    rep(j, s.length()) {
      if (s[j] == '#') {
        color[i][j] = 1;
      } else {
        color[i][j] = -1;
      }
    }
  }

  long res = 0;
  rep(i, h) {
    rep(j, w) {
      if (!state[i][j]) {
        bcnt = 0;
        wcnt = 0;
        dfs(i, j, color[i][j]);
        res += bcnt*wcnt;
      }
    }
  }

  cout << res << endl;
}


Measured memory_bytes: 13952
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <utility>
#define ll long long
#define INF 1000000000
#define mod 1000000007
#define rep(i,n) for(int i=0;i<int(n);i++)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
using namespace std;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;

int main(){
  string s;
  cin>>s;
  //cout<<s<<endl;;
  rep(i,s.size()){
    if(s[i]!=',')cout<<s[i];
    else cout<<" ";
  }
  cout<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int ans;
char stdstr[]="CODEFESTIVAL2016",st[16];
int main(){
	gets(st);
	for(int i=0;i<=15;i++) if(stdstr[i]!=st[i]) ans++;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
const int maxn = 200200;
long long arr[maxn];
int M(){
    int n;
    if(!~scanf("%d", &n)) return 0;
    for(int e = 0; e < n; e++) scanf("%lld", arr + e);
    for(int e = 1; e < n; e++) arr[e] += arr[e-1];
    long long res = 1ll<<55;
    long long sum = arr[n-1];
    for(int e = 0; e < n - 1; e++)
        res = min(res, abs((sum - arr[e]) - arr[e]));
    printf("%lld\n", res);
    return 1;
}
int main(){
    while(M());
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c,d,e;
  cin >> a;
  b = a / 1000;
  c = (a - (b * 1000)) / 100;
  d = (a - (b * 1000 + c * 100)) / 10;
  e = (a - (b * 1000 + c * 100 + d * 10));
  if((b == c && c == d)||(d == c && e == d)){
  cout << "Yes" << endl;
 
  }
  else{
  cout << "No" << endl;
  }
  
  // ここにプログラムを追記
}

Measured memory_bytes: 256
S = list(input())
YYMM = False
MMYY = False
if 0<int(S[0]+S[1]) and int(S[0]+S[1])<13:
    MMYY = True
if 0<int(S[2]+S[3]) and int(S[2]+S[3])<13:
    YYMM = True
if YYMM:
    if MMYY:
        print('AMBIGUOUS')
    else:
        print('YYMM')
elif MMYY:
    print('MMYY')
else:
    print('NA')

Measured memory_bytes: 3064
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
#include<fstream>
#include<set>
#include<queue>
using namespace std;
typedef long long ll;

const ll MOD = 1e9 + 7; 

#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 out(str) cout << str << endl
#define ALL(a) (a).begin(),(a).end()
#define INF_INT (1<<30)
#define INF_LL (1ll<<62)

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

ll dp[1010][101000],H,N;

ll min(ll a, ll b){
    if(a>b) return b;
    else return a;
}

int main(){
    cin>>H>>N;
    ll A[N],B[N];
    rep(i,N){
        cin>>A[i]>>B[i];
    }
    rep(i,N)rep(j,30000)if(j)dp[i][j]=10000000;
    ll now=0;
    ll to=0;
    rep(j,H+1){
        if(to<j){
            to+=A[0];
            now+=B[0];
        }
        dp[0][j]=now;
    }

    repi(i,1,N){
        rep(j,H+1){
            if(j<A[i])dp[i][j]=min(dp[i-1][j],B[i]);
            else dp[i][j] = min(min(dp[i-1][j],dp[i-1][j-A[i]]+B[i]),dp[i][j-A[i]]+B[i]);
        }
    }
    
    out(dp[N-1][H]);
    
    
}

Measured memory_bytes: 789504
N=gets.to_i
A=gets.split.map(&:to_i)
ans=[]
while !A.empty?
  target=(A.size-1).downto(0){|i| break i if A[i]==i+1}
  if A[target]!=target+1
    puts -1
    exit
  end
  A.delete_at(target)
  ans << target+1
end
puts ans.reverse

Measured memory_bytes: 1788
#include <iostream>
#include <math.h>
#include <string>

using namespace std;

int main()
{
	int N;
	cin >> N;
	string S,T,X;
	cin >> S >> T;
//	cout << S << T << endl;
	for (int i = 0; i < N; i++)
	{
		X+= S[i];
		X+= T[i];
	}
	for (int i = 0; i < 2 * N; i++)
	{
		cout << X[i];
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

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

    char c1 = s[0];
    char c2 = '*';
    int cnt1 = 1;
    int cnt2 = 0;
    for (int i = 1; i < 4; i++)
    {
        char c = s[i];
        if (c1 == c)
        {
            cnt1++;
        }
        else if (c2 == c)
        {
            cnt2++;
        }
        else
        {
            c2 = c;
            cnt2 = 1;
        }
    }

    if (cnt1 == 2 && cnt2 == 2)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
package main
import "fmt"
func main() {
  var a string
  fmt.Scan(&a)
  m := map[string]int{}
  n := len(a)
  for i:=0;i<n;i++ { m[a[i:i+1]]++ }
  s := (int64(n)*int64(n-1))/2
  for _,v := range m { s -= (int64(v)*int64(v-1))/2 }
  fmt.Println(s+1)
}

Measured memory_bytes: 1920
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int[] hight = new int [10];
        for(int i=0;i<10;i++){
            hight[i] = sc.nextInt();
        }
        for(int i=0;i<10;i++){
            for(int j=i+1;j<10;j++){
                if(hight[i]>hight[j]){
                    int temp = hight[i];
                    hight[i] = hight[j];
                    hight[j] = temp;
                }
            }
        }
        System.out.println(hight[9]);
        System.out.println(hight[8]);
        System.out.println(hight[7]);
    }
}


Measured memory_bytes: 26028
import queue

n = int(input())

connect = [ [] for _ in range(n)]
distances = dict()

for i in range(n - 1):
    u, v, w = map(int, input().split())
    u -= 1
    v -= 1

    connect[u].append(v)
    connect[v].append(u)
    distances[(u, v)] = w
    distances[(v, u)] = w

colors = [-1] * n
colors[0] = 0
q = queue.Queue()
q.put(0)

while not q.empty():
    x = q.get()

    for y in connect[x]:
        if colors[y] != -1:
            continue
        colors[y] = (colors[x] + distances[(x, y)]) % 2
        q.put(y)

print(*colors, sep='\n')


Measured memory_bytes: 100508
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            var s = cin.next();
            var ans = 0;
            var st = -1;
            var ed = -1;
            for (int i = 0; i < s.Length; i++)
                if (s[i] == 'A' && st == -1) st = i;

            for (int i = s.Length-1; 0 <= i; i--)
                if (s[i] == 'Z' && ed == -1) ed = i;

            Console.WriteLine(ed-st+1);
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public long[] DPArrayLong(int N, int ex)
        {
            long[] Array = new long[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong();
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }

    class Program
    {
        static void Main(string[] s) => new Solver().Solve();
    }
}


Measured memory_bytes: 12512
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i<(n);i++)
#define fore(i,a) for(auto &i:a)
#define debug(a,b) cout << "debug : " << a << " , "<< b << endl
using ll=long long;
const ll INF=1LL<<60;
const ll mod=1E9+7;


int main(){
	double a,b,h,m,temp,H,M;
	cin >> a >> b >> h >> m;
	M=m*M_PI/30;
	H=(h+m/60)*M_PI/6;
	temp=abs(H-M);
	double theta=min(temp,2*M_PI-temp);
	double c=a*a+b*b-2*a*b*cos(theta);
	cout << fixed << setprecision(10) << sqrt(c);
}


Measured memory_bytes: 4088
N, M = map(int, input().split())
L = []
R = []
for _ in range(M):
	l, r = map(int, input().split())
	L.append(l)
	R.append(r)

L_max = 0
R_min = 100000

for i in range(M):
	L_max = max(L_max, L[i])
	R_min = min(R_min, R[i])

cnt = R_min - L_max + 1

if cnt < 0:
	print("0")
else:
	print(cnt)


Measured memory_bytes: 16796
import std.stdio, std.conv, std.algorithm, std.string, std.array, std.numeric;

long seq(int a, int m) {
  int cnt = 1;
  int x = 1;
  while(true) {
    x = (a * x) % m;
    if (x == 1) break;
    else
      cnt++;
  }
  return cnt.to!long;
}

long lcm(long a, long b) {
  return a * b / gcd(a, b);
}

long lcms(long[] arr) {
  long res = arr[0];
  for(int i = 1; i < arr.length; i++) {
    res = lcm(res, arr[i]);
  }
  return res;
}

void main() {
  while(true) {
    int[] a = readln.chomp.split(" ").map!(to!int).array;
    if (a[0] == 0) break;
    lcms([seq(a[0], a[1]), seq(a[2], a[3]), seq(a[4], a[5])]).writeln;
  }
}

Measured memory_bytes: 1068
#include <bits/stdc++.h>
#define all(a) (a).begin(), (a).end()
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
ll const MOD = 1e9+7;
ll const INF = 1e18;
using namespace std;

int main(){
    string s;
    cin >> s;
    cout << s.substr(0,5) << " " << s.substr(6,7) << " " << s.substr(14,5) << endl;
    return 0;
}

Measured memory_bytes: 256