akhauriyash/Code-Regression huggingface dataset:
/*input
1 1
*/

#include <bits/stdc++.h>

using namespace std;

int main() {
	int a, b;
	scanf("%d%d", &a, &b);
	if (b % a == 0) {
		printf("%d\n", a + b);
		return 0;
	}
	printf("%d\n", b - a);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma warning(disable:4996)
#ifdef _MSC_VER
#  define __builtin_popcountll __popcnt
#endif
#define int long long
using namespace std;
using ll = long long;
using ld = long double;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
inline void my_io() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	std::cout << fixed << setprecision(10);
}
typedef unsigned long long ull;

struct RollingHash
{
	vector<ull> hash, pow;
	RollingHash(string s, ull _b = 1000000007)
	{
		_b = _b;
		int sz = s.length();
		hash.assign(sz + 1, 0);
		pow.assign(sz + 1, 0);

		pow[0] = 1;
		for (int i = 0; i<sz; i++) {
			pow[i + 1] = pow[i] * _b;
		}
		for (int i = 0; i<sz; i++) {
			hash[i + 1] = (hash[i] + s[i])*_b;
		}
	}
	// s[l]s[l+1]....s[r-1]のハッシュ値を取得する
	// 半開区間
	ull get(int l, int r) {
		return (hash[r] - hash[l] * pow[r - l]);
	}
};
signed main() {
	my_io();
	vector<int>ans;
	string t, s;
	cin >> t >> s;
	RollingHash t_Roll(t);
	RollingHash s_Roll(s);
	int s_hash=s_Roll.get(0, (int)s.size());
	for (int i = 0; i <=(int)t.size()-(int)s.size(); i++) {
		if (s_hash == t_Roll.get(i, i + s.size())) {
			ans.push_back(i);
		}
	}
	for (int i = 0; i < (int)ans.size(); i++) {
		cout << ans[i] << endl;
	}
	return 0;
}




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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define ALL(a) a.begin(),a.end()
#define INIT(a,b) memset(a,b,sizeof(a))
using lint = long long int;

template< typename DATA >
class FenwickTree {
private:
	int size__;
	vector< DATA > data;
	
public:
	FenwickTree(int n) : size__(n), data(n + 1, DATA()) {}
	
	DATA sum(int i) {
		DATA res = DATA();
		
		while (i > 0) {
			res += data[i];
			i -= i & -i;
		}
		
		return res;
	}
	
	void add(int i, DATA x) {
		while (i <= size__) {
			data[i] += x;
			i += i & -i;
		}
	}
};

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

    vector<int> c(N);
    for_(i,0,N) cin >> c[i];

    vector<int> L(Q), R(Q);
    for_(i,0,Q) cin >> L[i] >> R[i];

    vector<int> idx(Q);
    iota(ALL(idx), 0);

    sort(ALL(idx), [&](int i, int j) { return R[i] < R[j]; });

    vector<int> ans(Q);
    vector<int> last(N + 1, -1);

    FenwickTree<int> BIT(N + 1);
    int P = 0;
    for (int i : idx) {
        for_(j,P,R[i]) {
            int x = c[j];
            if (last[x] != -1) BIT.add(last[x], -1);
            BIT.add(j + 1, 1);
            last[x] = j + 1;
        }

        ans[i] = BIT.sum(R[i]) - BIT.sum(L[i] - 1);

        P = R[i];
    }

    for_(i,0,Q) cout << ans[i] << endl;
}

Measured memory_bytes: 17372
#include<stdio.h>

int main(void){
  
  int a,b,c;
  int rec,loz;

  rec = 0;
  loz = 0;
  while(scanf("%d,%d,%d",&a,&b,&c) != EOF){
    if(a*a + b*b == c*c)rec++;
    if(a == b)loz++;
  }

  printf("%d\n",rec);
  printf("%d\n",loz);

  return 0;
}

Measured memory_bytes: 0
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var NK = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            int n = NK[0];
            var dislike = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            var usable = new List<int>();

            for (int i = 1; i < 100000; i++)
            {
                for (int j = 0; j < i.ToString().Length; j++)
                {
                    if (dislike.Contains(int.Parse(i.ToString()[j].ToString()))) break;
                    else if (j == i.ToString().Length - 1) usable.Add(i);
                }
            }
            usable = usable.Where(i => i >= n).ToList();
            Console.WriteLine(usable.Min());
        }
    }
}

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

using namespace std;

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

const ll INF = 1e15;

inline ld calc(ll vmax, ll vmin, ll vmax_r, ll vmin_r, ll vmax_l, ll vmin_l, ld t) {
    return max({(ld)vmax, vmax_r + t, vmax_l - t}) - min({(ld)vmin, vmin_r + t, vmin_l - t});
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<ll> x(n), y(n);
    vector<char> d(n);

    ll xmax = -INF, xmin = INF, ymax = -INF, ymin = INF;
    ll ymax_u = -INF, ymin_u = INF, ymax_d = -INF, ymin_d = INF;
    ll xmax_l = -INF, xmin_l = INF, xmax_r = -INF, xmin_r = INF;
    for (int i = 0; i < n; i++) {
        cin >> x[i] >> y[i] >> d[i];
        if (d[i] == 'U') {
            xmax = max(xmax, x[i]);
            xmin = min(xmin, x[i]);
            ymax_u = max(ymax_u, y[i]);
            ymin_u = min(ymin_u, y[i]);
        } else if (d[i] == 'D') {
            xmax = max(xmax, x[i]);
            xmin = min(xmin, x[i]);
            ymax_d = max(ymax_d, y[i]);
            ymin_d = min(ymin_d, y[i]);
        } else if (d[i] == 'L') {
            ymax = max(ymax, y[i]);
            ymin = min(ymin, y[i]);
            xmax_l = max(xmax_l, x[i]);
            xmin_l = min(xmin_l, x[i]);
        } else {
            ymax = max(ymax, y[i]);
            ymin = min(ymin, y[i]);
            xmax_r = max(xmax_r, x[i]);
            xmin_r = min(xmin_r, x[i]);
        }
    }

    ld L = 0, R = 2e8;
    for (int i = 0; i <= 1000; i++) {
        ld mid1 = (L * 2 + R) / 3;
        ld x1 = calc(xmax, xmin, xmax_r, xmin_r, xmax_l, xmin_l, mid1);
        ld y1 = calc(ymax, ymin, ymax_u, ymin_u, ymax_d, ymin_d, mid1);
        ld val1 = x1 * y1;

        ld mid2 = (L + R * 2) / 3;
        ld x2 = calc(xmax, xmin, xmax_r, xmin_r, xmax_l, xmin_l, mid2);
        ld y2 = calc(ymax, ymin, ymax_u, ymin_u, ymax_d, ymin_d, mid2);
        ld val2 = x2 * y2;

        if (val1 < val2) R = mid2;
        else L = mid1;    
    }

    ld x1 = calc(xmax, xmin, xmax_r, xmin_r, xmax_l, xmin_l, L);
    ld y1 = calc(ymax, ymin, ymax_u, ymin_u, ymax_d, ymin_d, L);
    ld val1 = x1 * y1;

    ld x2 = calc(xmax, xmin, xmax_r, xmin_r, xmax_l, xmin_l, R);
    ld y2 = calc(ymax, ymin, ymax_u, ymin_u, ymax_d, ymin_d, R);
    ld val2 = x2 * y2;    
    cout << fixed << setprecision(15) << min(val1, val2) << "\n";
    return 0;
}

Measured memory_bytes: 1920
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


int main(){
    ll A, B;
    char op;
    cin >> A >> op >> B;

    if(op == '+'){
        cout << A + B << endl;
    }else{
        cout << A - B << endl;
    }

    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <iomanip>

int main() {
  int d,r,a,b;
  double f;

  std::cin >> a >> b;

  d = a / b;
  r = a % b;
  f = 1.0 * a / b;

  std::cout << std::fixed;
  std::cout << d << " " << r << " " << std::setprecision(5) << f << '\n';

  return 0;
}


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

int main(){
int r,d,x;
  cin>>r>>d>>x;
  
  int ans[11];
  ans[0]=x;
  for(int i=1;i<11;i++)
    ans[i]= r*ans[i-1]-d;
  for(int i=1;i<11;i++)
    cout<<ans[i]<<"\n";

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=j;i<(int)n;i++)
#define rrep(i,j,n) for(int i=j;i>(int)n;i++)
#define ll long long
int main(){
  int N,i,j;
  cin >> N;
  bool flag=false;
  vector<int> p(N);
  rep(i,0,N){
    cin >> p[i];
    p[i]-=i+1;
  }
  rep(i,0,N){
    if(p[i]!=0){
      if(!flag){
        rep(j,i+1,N){
          if(p[i]+p[j]==0){
            p[i]=0;
            p[j]=0;
            flag=true;
            break;
          }
        }
      }
    }
  }
  rep(i,0,N){
    if(p[i]!=0){
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}


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

using namespace std;

const int MAX_N = 1e5 + 1;
vector<int> edges[MAX_N];
bool check[MAX_N];

int dfs( int u ) {
    check[u] = 1;
    int ans = 0;
    for ( int v : edges[u] )
        if ( !check[v] ) {
            ans ^= 1 + dfs( v );
        }
    return ans;
}

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

    for ( int i = 0; i < n - 1; i++ ) {
        int x, y;
        cin >> x >> y;
        edges[x].push_back( y );
        edges[y].push_back( x );
    }

//    cout << dfs(1);
    cout << ( dfs( 1 ) ? "Alice" : "Bob" );

    return 0;
}


Measured memory_bytes: 8960
#include <iostream>
#include <vector>
#include <map>
#include <tuple>
#include <queue>
using namespace std;

const long MAXV=1000000;

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

    vector<int> A(N,0);
    map<int,int> data{};
    long sumA = 0;
    for(int i=0;i<N;i++){
        cin >> A[i];
        sumA += A[i];
        if(data.count(A[i])==0){
            data[A[i]] = 1;
        }else{
            data[A[i]] = data[A[i]] + 1;
        }
    }

    int Q;
    cin >> Q;

    for(int i=0;i<Q;i++){
        int B,C;
        cin >> B >> C;

        sumA += (C-B)*data[B];
        cout << sumA << endl;

        data[C] = data[C] + data[B];
        data[B] = 0;
    }

    return 0;
}


Measured memory_bytes: 7912
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
struct edge {
	int a, b, cost;
};
bool operator<(const edge& e1, const edge& e2) {
	return e1.cost < e2.cost;
}
int N; vector<int> par;
int root(int x) {
	if (x == par[x]) return x;
	return par[x] = root(par[x]);
}
int main() {
	ios::sync_with_stdio(false);
	cin >> N;
	vector<int> x(N), y(N), px(N), py(N); par = vector<int>(N);
	for (int i = 0; i < N; i++) cin >> x[i] >> y[i], px[i] = py[i] = par[i] = i;
	sort(px.begin(), px.end(), [&](int i, int j) { return x[i] < x[j]; });
	sort(py.begin(), py.end(), [&](int i, int j) { return y[i] < y[j]; });
	vector<edge> v;
	for (int i = 1; i < N; i++) {
		v.push_back(edge{ px[i - 1], px[i], x[px[i]] - x[px[i - 1]] });
		v.push_back(edge{ py[i - 1], py[i], y[py[i]] - y[py[i - 1]] });
	}
	sort(v.begin(), v.end());
	int ret = 0;
	for (int i = 0; i < 2 * N - 2; i++) {
		int ax = root(v[i].a), bx = root(v[i].b);
		if (ax != bx) par[ax] = bx, ret += v[i].cost;
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 6900
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <queue>
#include <string>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int> ;
using vl = vector<ll>;

int main(){
    string s;
    vector<bool> flag(26,false);
    cin >> s;
    string al = "abcdefghijklmnopqrstuvwxyz";
    int len = s.length();
    if(len < 26){
        rep(i,len){
            flag[(int)s[i]-'a']=true;
        }
        cout << s;
        rep(i,26){
            if(!flag[i]){
                cout << al[i] << endl;
                return 0;
            }
        }
    }else{

        if (s == "zyxwvutsrqponmlkjihgfedcba") {
			cout << -1 << endl;
			return 0;
		}
        
		map<char, int> mp;
		for (int i = 25; i > 0; i--) {
			mp[s[i]] = 1;
			s.pop_back();
			for (auto x: mp) {
				if (x.first > s[i - 1]) {
					s[i - 1] = x.first;
					cout << s << endl;
					return 0;
				}
			}
		}
    }

    return 0;
}


Measured memory_bytes: 3624
L,R=map(int,input().split())
flag=False
for amari in range(2019):
    for i in range(L,R):
        for j in range(i+1,R+1):
            if (i*j-amari)%2019==0:
                print(amari)
                flag=True
            if flag:break
        if flag:break
    if flag:break            

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

double eps = 1e-10;

int main() {
	string s[16];
	while(cin >> s[0]){
		for(int i = 1; i < 8; ++i){
			cin >> s[i];
		}
		int h, w;
		for(int i = 0; i < 8; ++i){
			for(int j = 0; j < 8; ++j){
				if(s[i][j] == '1'){
					h = i;
					w = j;
					goto next;
				}
			}
		}
		next:;
		if(s[h + 1][w] == '1' && s[h][w + 1] == '1' && s[h + 1][w + 1] == '1'){
			cout << "A" << endl;
		}
		else if(s[h + 1][w] == '1' && s[h + 2][w] == '1' && s[h + 3][w] == '1'){
			cout << "B" << endl;
		}
		else if(s[h][w + 1] == '1' && s[h][w + 2] == '1' && s[h][w + 3] == '1'){
			cout << "C" << endl;
		}
		else if(s[h + 1][w - 1] == '1' && s[h + 1][w] == '1' && s[h + 2][w - 1] == '1'){
			cout << "D" << endl;
		}
		else if(s[h][w + 1] == '1' && s[h + 1][w + 1] == '1' && s[h + 1][w + 2] == '1'){
			cout << "E" << endl;
		}
		else if(s[h + 1][w] == '1' && s[h + 1][w + 1] == '1' && s[h + 2][w + 1] == '1'){
			cout << "F" << endl;
		}
		else if(s[h][w + 1] == '1' && s[h + 1][w] == '1' && s[h + 1][w - 1] == '1'){
			cout << "G" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1184
#include<stdio.h>
 
int main (void){
     
    int dice[7]={0};
    int d1,d2,d3,d4,d5,d6;
    int i;
    char d;
     
    for(i=1;i<=6;i++){
        scanf("%d",&dice[i]);
    }
    getchar();
    while(1){
         
        scanf("%c",&d);
        if(d == '\n')break;
        d1=dice[1];d2=dice[2];d3=dice[3];d4=dice[4];d5=dice[5];d6=dice[6];
        if(d=='N'){
            dice[1]=d2;dice[2]=d6;dice[6]=d5;dice[5]=d1;
        }else if(d=='E'){
            dice[1]=d4;dice[4]=d6;dice[6]=d3;dice[3]=d1;
        }else if(d=='S'){
            dice[1]=d5;dice[2]=d1;dice[6]=d2;dice[5]=d6;
        }else if(d=='W'){
            dice[1]=d3;dice[4]=d1;dice[6]=d4;dice[3]=d6;
        }
    }
     
    printf("%d\n",dice[1]);
     
return 0;
}


Measured memory_bytes: 2100
from math import *

s = input()
s += "?"

count = 0
ans = [0] * len(s)
cur = "R"

for i in range(len(s)):
    if cur == s[i]:
        count += 1
    else:
        temp = ceil(count/2)

        if cur == "R":
            ans[i-1] += temp
            ans[i] += count - temp
        if cur == "L":
            ans[i-count] += temp
            ans[i-count-1] += count - temp

        cur = s[i]
        count = 1

print(*ans[:-1])

Measured memory_bytes: 6376
#include<bits/stdc++.h>
using namespace std;
#define se second
#define fi first
#define ll long long
#define ld long double
#define pll pair<ll ,ll >
#define ppll pair<ll, pll>
#define pii pair<int, int> 
#define mod 1000000007
ll power(ll a,ll b){
    ll res=1;
    while(b>0){
        if(b%2!=0) res=(res*a)%mod;
        a=(a*a)%mod;
        b/=2;
    }
    return res;
}
ll ncr(ll n,ll k){
    if(k==0||k==n) return 1ll;
    if(k>n-k) k=n-k;
    ll pro=1;
    for(ll i=0;i<k;i++){
        pro=(pro*(n-i))%mod;
        pro/=(i+1);
    }
    return (pro%mod);
}
vector<int> prime;
void seive(){
    vector<bool > isprime(1000001,true);
    for(int i=2;i*i<=1000000;i++){
        if(isprime[i]){
            for(int j=i*i;j<=1000000;j+=i){
                isprime[j]=false;
            }
        }
    }
    for(int i=2;i<=1000000;i++){
        if(isprime[i]) prime.push_back(i);
    }
}
ll bsearch(vector<ll> &arr,ll sum,ll j){
    ll n=arr.size();
    ll l=j+1;
    ll u=n-1,ans=0;
    while(l<=u){
        ll mid=(l+u)/2;
        if(arr[mid]>=sum){
            u=mid-1;
        }
        else{
            l=mid+1;
            ans=mid;
        }
    }
    if(ans-j>0) return ans-j;
    return 0;
}
int main(void){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    vector<ll> arr(n);
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    sort(arr.begin(),arr.end());
    ll cnt=0;
    for(ll i=0;i<n-2;i++){
        for(ll j=i+1;j<n-1;j++){
            ll sum=arr[i]+arr[j];
            cnt+=bsearch(arr,sum,j);
        }
    }
    cout<<cnt;
    return 0;
}


Measured memory_bytes: 256
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; input_inner ! { iter , $ ( $ r ) * } } ; ( iter = $ iter : ident , $ ( $ r : tt ) * ) => { let s = { use std :: io :: Read ; let mut s = String :: new ( ) ; std :: io :: stdin ( ) . read_to_string ( & mut s ) . unwrap ( ) ; s } ; let mut $ iter = s . split_whitespace ( ) ; input_inner ! { $ iter , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let s = { use std :: io :: Read ; let mut s = String :: new ( ) ; std :: io :: stdin ( ) . read_to_string ( & mut s ) . unwrap ( ) ; s } ; let mut iter = s . split_whitespace ( ) ; input_inner ! { iter , $ ( $ r ) * } } ; }
macro_rules ! input_inner { ( $ iter : expr ) => { } ; ( $ iter : expr , ) => { } ; ( $ iter : expr , mut $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let mut $ var = read_value ! ( $ iter , $ t ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , mut $ var : ident $ ( $ r : tt ) * ) => { input_inner ! { $ iter , mut $ var : usize $ ( $ r ) * } } ; ( $ iter : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ iter , $ t ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , $ var : ident $ ( $ r : tt ) * ) => { input_inner ! { $ iter , $ var : usize $ ( $ r ) * } } ; }
macro_rules ! read_value { ( $ iter : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ iter , $ t ) ) ,* ) } ; ( $ iter : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ iter , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ iter : expr , { chars : $ base : expr } ) => { read_value ! ( $ iter , String ) . chars ( ) . map ( | c | ( c as u8 - $ base as u8 ) as usize ) . collect ::< Vec < usize >> ( ) } ; ( $ iter : expr , { char : $ base : expr } ) => { read_value ! ( $ iter , { chars : $ base } ) [ 0 ] } ; ( $ iter : expr , chars ) => { read_value ! ( $ iter , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ iter : expr , char ) => { read_value ! ( $ iter , chars ) [ 0 ] } ; ( $ iter : expr , usize1 ) => { read_value ! ( $ iter , usize ) - 1 } ; ( $ iter : expr , $ t : ty ) => { $ iter . next ( ) . unwrap ( ) . parse ::<$ t > ( ) . unwrap ( ) } ; }
use std::cmp::min;
fn main() {
    input! { n, a, b };
    if a + b > n + 1 {
        println!("{}", -1);
        return;
    }
    let mut v = (1..b + 1).rev().chain(b + 1..n + 1).collect::<Vec<_>>();
    let mut x = n + 1 - b;
    let mut s = b;
    while a < x {
        let t = min(x - a + 1, min(b, n - s));
        (&mut v[s..s + t]).reverse();
        s += t;
        x -= t - 1;
        if s >= n {
            break;
        }
    }
    if x != a {
        println!("{}", -1);
    } else {
        for &x in &v {
            print!("{} ", x);
        }
        println!("");
    }
}


Measured memory_bytes: 10364
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String a = sc.next();
    String b = sc.next();
    String c = sc.next();
    System.out.print("A" + b.substring(0, 1) + "C");
  }
}


Measured memory_bytes: 21844
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	n := nextInt()
	a := make([]int, n+1)
	a[0] = 201

	money := 1000
	addkabu := 0
	for i := 1; i < n+1; i++ {
		a[i] = nextInt()

		// 上昇検知なら買えるだけ買って、うる
		if a[i-1] < a[i] {
			addkabu = money / a[i-1]
			money -= addkabu * a[i-1]

			money += addkabu * a[i]
		}

	}

	fmt.Println(money)

}

// ---- readfunc
func scanInit() {
	const cap = 64 * 1024
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


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

using namespace std;

const int md = (int) 1e9 + 7;

inline int mul(int a, int b) {
  int res = (long long) a * b % md;
  if (res < 0) res += md;
  return res;
}

int main() {
  ios_base::sync_with_stdio(false);

  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());

  if (a.back() < 0 && k % 2 == 1 || n == k) { // neg and all
    int res = 1;
    for (int i = 0; i < k; i++) {
      res = mul(res, a[n - 1 - i]);
    }
    cout << res << '\n';
    return 0;
  }

  auto kmul = [&]() {
    int res = 1;
    for (int i = 0; i < k; i++) {
      res = mul(res, a[i]);
    }
    return res;
  };

  sort(a.begin(), a.end(), [&](int i, int j) { return abs(i) > abs(j); });
  int sign = 1;
  for (int i = 0; i < k; i++) {
    if (a[i] < 0) sign *= -1;
  }
  if (sign >= 0) {
    cout << kmul() << '\n';
    return 0;
  }

  int optl = -1, optr = -1;
  { // pos -> neg
    int pos = -1, neg = -1;
    for (int i = 0; i < k; i++) {
      if (a[i] >= 0) pos = i;
    }
    for (int i = n - 1; i >= k; i--) {
      if (a[i] < 0) neg = i;
    }
    if (pos != -1 && neg != -1) {
      optl = pos;
      optr = neg;
    }
  }
  { // neg -> pos
    int pos = -1, neg = -1;
    for (int i = 0; i < k; i++) {
      if (a[i] < 0) neg = i;
    }
    for (int i = n - 1; i >= k; i--) {
      if (a[i] >= 0) pos = i;
    }
    if (pos != -1 && neg != -1) {
      if (optl == -1 || 1LL * a[pos] * a[optl] > 1LL * a[neg] * a[optr]) {
        optl = pos;
        optr = neg;
      }
    }
  }

  swap(a[optl], a[optr]);  
  cout << kmul() << '\n';

  return 0;
}


Measured memory_bytes: 3976
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
ll N,M;
vector<ll> A;
vector<ll> idx;
ll sum;
bool f(ll mid){
    sum=0;
    rep(0,i,N){
        idx[i]=lower_bound(A.begin(),A.end(),mid-A[i])-A.begin();//左手をiとしてmid1より少ない握手した時の組み合わせの数。
        sum+=N-idx[i];//sum=(すべての組み合わせの数)
    }
    return sum>=M;
}
int main(void){
    // Your code here!
    cin>>N>>M;
    A.resize(N);
    idx.resize(N);
    rep(0,i,N)cin>>A[i];
    sort(A.begin(),A.end());
    ll left=-1,right=1e6;
    while(left+1<right){
        ll mid=(left+right)/2;
        if(f(mid))left=mid;
        else right=mid;
    }
    f(left);
    ll ans=0;
    rep(0,i,N)ans+=(N-idx[i])*A[i]*2;
    ans-=(sum-M)*left;
    cout<<ans<<endl;
}


Measured memory_bytes: 1792
#include <iostream>

int main(void)
{
    int a, b;
    std::cin >> a >> b;
    if(a < b) {
        std::cout << "a < b" << std::endl;
    } else if (a > b) {
        std::cout << "a > b" << std::endl;
    } else {
	std::cout << "a == b" << std::endl;
    }
    return 0;
}

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

int main(){

    int a,b,x;

    cin >> x >> a >> b;

    if(abs(a-x)>abs(b-x)){
        cout << "B" << endl;
    }else{
        cout << "A" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
public class Hello
{
    public static void Main()
    {
        //テストケース数を保持する
        var cases = int.Parse(Console.ReadLine());
        //回答用配列を用意
        var ans = new int[4];
        //テストケース数分ループする
        for (var cnt = 0; cnt < cases; cnt++)
        {
            //テストケースによって配列をカウントアップする
            var rslt = Console.ReadLine();
            switch (rslt)
            {
                case "AC":
                    ans[0] += 1;
                    break;
                case "WA":
                    ans[1] += 1;
                    break;
                case "TLE":
                    ans[2] += 1;
                    break;
                case "RE":
                    ans[3] += 1;
                    break;
            }

        }
        Console.WriteLine("AC x " + ans[0]);
        Console.WriteLine("WA x " + ans[1]);
        Console.WriteLine("TLE x " + ans[2]);
        Console.WriteLine("RE x " + ans[3]);
    }
}


Measured memory_bytes: 30624
import sys
import math
import itertools

def solve(n, p):
    s = 0
    patterns = list(itertools.permutations(range(n)))
    for pattern in patterns:
        # print(pattern)
        for i in range(n-1):
            s += math.sqrt((p[pattern[i]][0] - p[pattern[i+1]][0])**2 + (p[pattern[i]][1] - p[pattern[i+1]][1])**2)
    print(s / len(patterns))


if __name__ == '__main__':
    n = int(sys.stdin.readline().strip())
    p = []
    for _ in range(n):
        p.append(list((map(int, sys.stdin.readline().strip().split(" ")))))
    solve(n, p)

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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll n;
    cin >> n;
    ll m = n;
    if(n%2) --m;
    map<pair<ll,ll>, ll> muda;
    for(i = 1;i <= m/2;++i){
        muda[make_pair(i,m+1-i)] = 0;
    }
    ll ans = n*(n-1)/2 - muda.size();
    cout << ans << endl;
    for(i = 1;i <= n-1;++i){
        for(j = i+1;j <= n;++j){
            if(!muda.count(make_pair(i,j))){
                cout << i << " " << j << endl;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define all(x) (x).begin(),(x).end()
typedef long long int ll;
using namespace std;
int main()
{
  char a;
  cin >> a;
  if(a == 'A')cout << 'T' << endl;
  else if(a == 'T')cout << 'A' << endl;
  else if(a == 'C')cout << 'G' << endl;
  else if(a == 'G')cout << 'C' << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
using namespace std;

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

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> A;
    for (int i = 0; i < N; i++) {
        int temp;
        cin >> temp;
        A.push_back(temp);
    }
    long long count_all, count_reverse;
    count_all = 0;
    count_reverse = 0;
    for (int i = 0; i < N; i++){
        for (int j = 0; j < N; j++) {
            if (i == j) continue;
            if (A[i] > A[j]) {
                if (i < j) {
                    count_all++;
                    count_reverse++;
                } else {
                    count_all++;
                }
            }
        }
    }
    long long answer = 0;
    answer += count_reverse * K % MOD;
    answer = (answer + count_all * K % MOD * (K - 1) % MOD * modinv(2, MOD) % MOD) % MOD;
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq 
from itertools import *
import math
import random
import re
import string
import sys

A, B = map(int, input().split())
if (A * B) % 2:
    print('Yes')
else:
    print('No')



Measured memory_bytes: 7880
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
const int MOD = 1000000007;

// vector<p> cut(M);
// cut[i].second
// cut[i].first;
// REP(i,M){
//     int a,b;cin>>a>>b;
//     cut[i] = make_pair(b,a);//last first の順番
// }
// for(int i=0; i<N;i++){
// }
// sort(cut.begin(),cut.end()); //sort
// char '' str ""
int main(void)
{
    str s;cin>>s;

    int l = s.size();
    int ans=1;
    int i=0;bool flag=false;
    while(i < l){
      if(s[i]=='A'){
          for(int j=i+1; j<l;j++){
            if(s[j]=='Z') ans = max(ans, j-i+1);
          }
        flag = true;
      }
      if(flag) break;
      i++;
    }

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


Measured memory_bytes: 640
S = list(input())
N = len(S)
old = S[0]
T = ''
ans = 1
for i in range(1, N):
    if T == '':
        T = S[i]
        if T != old:
            ans += 1
            old = T
            T = ''        
    else:
        T += S[i]
        old = T
        ans += 1 
        T = ''
print(ans)

Measured memory_bytes: 10588
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

int max(int a, int b){
  return a >= b ? a : b;
}
int min(int a, int b){
  return b >= a ? a : b;
}
int sei(int a){
  return a>0 ? a : 0;
}
int factorial(int n) {
    if (n > 0) return n*factorial(n - 1);
		else return 1;
}
int compare_up_int(const void *a, const void *b){
   return *(int*)a - *(int*)b;
}
int compare_down_int(const void *a, const void *b){
   return *(int*)b - *(int*)a;
}
int euclid(int a, int b){
  if(a < b){int tmp = a;a = b;b = tmp;}
  int r = a % b;
  if(r < 0) r += b;
  while(r != 0){
    a = b;b = r;r = a % b;
    if(r < 0) r += b;
  }
  return b;
}

int main(){
  int N,ans=0;
  scanf("%d",&N);
  int a[N],b[N];
  for(int i=0;i<N;i++) scanf("%d ",&a[i]);
  for(int i=0;i<N;i++) scanf("%d ",&b[i]);
  int wa[N],wb[N];
  for(int i=0;i<N;i++){
    if(i==0){
      wa[i]=a[0];
    }
    else{
      wa[i]=wa[i-1]+a[i];
    }
  }
  for(int i=N-1;i>=0;i--){
    if(i==N-1){
      wb[i]=b[N-1];
    }
    else{
      wb[i]=wb[i+1]+b[i];
    }
  }
  for(int i=0;i<N;i++)ans=max(ans,wa[i]+wb[i]);
  printf("%d",ans);
  //for(int i=0;i<N;i++)printf("%d %d\n",wa[i],wb[i]);
  return 0;
}


Measured memory_bytes: 128
package main

import (
	"fmt"
)

func main() {
	var (
		n     int
		color string
	)

	fmt.Scan(&n)
	table := make(map[string]int)
	for i := 0; i < n; i++ {
		fmt.Scan(&color)
		table[color] += 1
	}

	if len(table) == 3 {
		fmt.Println("Three")
	} else {
		fmt.Println("Four")
	}
}


Measured memory_bytes: 512
# abc110_b.py
# https://atcoder.jp/contests/abc110/tasks/abc110_b

# B - 1 Dimensional World's Tale /
# 実行時間制限: 2 sec / メモリ制限: 1024 MB
# 配点 : 200点

# 問題文
# この世界は 1次元世界であり、世界を治める 2つの帝国はそれぞれ A 帝国、B 帝国と呼ばれています。
# A 帝国の首都は座標 X、B 帝国の首都は座標 Yに位置しています。
# ある日、A 帝国は座標 x1,x2,...,xN、B 帝国は座標 y1,y2,...,yMの都市を支配下に置きたくなりました。
# このとき、以下の 3つの条件をすべて満たす整数 Zが存在すれば、合意が成立して戦争は起きませんが、存在しない場合には戦争が起こります。
#     X<Z≤Y
#     x1,x2,...,xN<Z
#     y1,y2,...,yM≥Z
# 戦争が起こるかどうか判定してください。

# 制約
#     入力はすべて整数である
#     1≤N,M≤100
#     −100≤X<Y≤100
#     −100≤xi,yi≤100
#     x1,x2,...,xN≠X
#     xiはすべて異なる
#     y1,y2,...,yM≠Y
#     yiはすべて異なる

# 入力
# 入力は以下の形式で標準入力から与えられる。
# N M X Y
# x1 x2 ... xN
# y1 y2 ... yM

# 出力
# 戦争が起こるなら War、そうでないなら No War を出力せよ。

# 入力例 1
# 3 2 10 20
# 8 15 13
# 16 22

# 出力例 1
# No War

# Z=16とすれば、次のように 3つの条件をすべて満たすので合意が成立し、戦争は起きません。
#     X=10<16≤20=Y
#     8,15,13<16
#     16,22≥16

# 入力例 2
# 4 2 -48 -1
# -20 -35 -91 -23
# -22 66

# 出力例 2
# War

# 入力例 3
# 5 3 6 8
# -10 3 1 5 -100
# 100 6 14

# 出力例 3
# War


def calculation(lines):
    # N = int(lines[0])
    N, M, X, Y = list(map(int, lines[0].split()))
    xs = list(map(int, lines[1].split()))
    ys = list(map(int, lines[2].split()))
    xs.append(X)
    ys.append(Y)
    max_x = max(xs)
    min_y = min(ys)
    if max_x < min_y:
        return ['No War']
    else:
        return ['War']


# 引数を取得
def get_input_lines(lines_count):
    lines = list()
    for _ in range(lines_count):
        lines.append(input())
    return lines


# テストデータ
def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['3 2 10 20', '8 15 13', '16 22']
        lines_export = ['No War']
    if pattern == 2:
        lines_input = ['4 2 -48 -1', '-20 -35 -91 -23', '-22 66']
        lines_export = ['War']
    if pattern == 3:
        lines_input = ['5 3 6 8', '-10 3 1 5 -100', '100 6 14']
        lines_export = ['War']
    return lines_input, lines_export


# 動作モード判別
def get_mode():
    import sys
    args = sys.argv
    if len(args) == 1:
        mode = 0
    else:
        mode = int(args[1])
    return mode


# 主処理
def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines(3)
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    # if mode > 0:
    #     print(f'lines_input=[{lines_input}]')
    #     print(f'lines_export=[{lines_export}]')
    #     print(f'lines_result=[{lines_result}]')
    #     if lines_result == lines_export:
    #         print('OK')
    #     else:
    #         print('NG')
    # finished = time.time()
    # duration = finished - started
    # print(f'duration=[{duration}]')


# 起動処理
if __name__ == '__main__':
    main()


Measured memory_bytes: 9084
#include<bits/stdc++.h>
#define inf (1ll<<60)
using namespace std;
typedef long long LL;
LL read()
{
    char c=getchar();LL f=1,sum=0;
    while(c<'0' || c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0' && c<='9'){sum=sum*10+c-'0';c=getchar();}
    return sum*f;
}
int n,m,top;
LL dis[5005],b[5005][205];
int s[5005],l[5005],r[5005];
LL sum[5005][5005],ans=-inf;
int main()
{
	n=read();m=read();
	for(int i=2;i<=n;i++) dis[i]=dis[i-1]+read();
	for(int i=1;i<=n;i++)
	for(int j=1;j<=m;j++) b[i][j]=read();
	for(int i=1;i<=m;i++)
	{
		top=0;s[top]=0;
		for(int j=1;j<=n;j++) l[j]=r[j]=0;
		for(int j=1;j<=n;j++)
		{
			while(top && b[j][i]>b[s[top]][i]) top--;
			l[j]=s[top]+1;s[++top]=j;
		}
		top=0;s[top]=n+1;
		for(int j=n;j>=1;j--)
		{
			while(top && b[j][i]>b[s[top]][i]) top--;
			r[j]=s[top]-1;s[++top]=j;
		}
		for(int j=1;j<=n;j++)
		{
			//printf("m=%d %d %d %d\n",i,j,l[j],r[j]);
			sum[l[j]][j]+=b[j][i];
		    sum[j+1][j]-=b[j][i] ;
		    sum[l[j]][r[j]+1]-=b[j][i];
		    sum[j+1][r[j]+1]+=b[j][i];
		}
	}
	for(int i=1;i<=n;i++)
	for(int j=1;j<=n;j++)
	{
		sum[i][j]=sum[i][j]+sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1];
		if(i<=j) ans=max(ans,sum[i][j]-dis[j]+dis[i]);
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 204032
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define cool ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) 
#define ll long long
#define MAX 1000001
#define mod 1000000007
#define pie 3.14159265358979323846
double min(double x, double y)  
{  
    return (x < y)? x: y;  
      
}  
double calcAngle(double h, double m)  
{  
    if (h == 12) h = 0;  
    if (m == 60) m = 0;  
  	double hour_angle = 0.5 * (h * 60 + m);  
    double minute_angle = 6 * m;  
  	double angle = abs(hour_angle - minute_angle);  
  	angle = min(360 - angle, angle);  
    return angle;  
}  
void solve()
{
	double a,b,h,m;
	cin>>a>>b>>h>>m;
	double A=(double)(calcAngle(h,m));
	//cout<<A;
	double val=pie/180.0;
	double cos_val=cos(A*val);
	//printf("%.20lf",cos_val);
	//if(A==0)
	//printf("0.00000000000000");
	//else{
	double ans=sqrt((a*a)+(b*b)-(2.0*a*b*cos_val));
	printf("%.20lf",ans);
//}
}
int main()
{ 
    cool;
    int t;
    //cin>>t;
    t=1;
    while(t--){
    	solve();
	}
    return 0;
}


Measured memory_bytes: 4112
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] s1 = sc.nextLine().split(" ");
        int N = Integer.parseInt(s1[0]);
        int Q = Integer.parseInt(s1[1]);
        String S = sc.nextLine();

        // a[]の生成

        StringBuilder sb = new StringBuilder();

        int ss = 0;
        int[] s = new int[N + 1];
        for (int i = 1; i <= N; i++) {
            if (i - 2 < 0) {
                sb.append("");
            } else {
                sb.append(S.charAt(i - 2));
            }
            sb.append(S.charAt(i - 1));

            if (sb.toString().equals("AC")) {
                ss++;
            }
            s[i] = ss;
            sb.setLength(0);
        }

        // queryの処理
        for (int i = 0; i < Q; i++) {
            int l = sc.nextInt();
            int r = sc.nextInt();
            System.out.println(s[r] - s[l]);
        }

        sc.close();
    }

}


Measured memory_bytes: 90264
//ex3_3
//TKC001
 
#include<stdio.h>
#include<math.h>
 
int main(void){
	//exactを真数, baseを底として対数を求める。
    double exact, base, logkn;
    int digits;
 
    scanf("%lf", &exact);
    scanf("%lf", &base);
 
    logkn = log(exact) / log(base);
	//ここまで
 
	//logknの小数点を切り捨て
	digits = logkn;
 
	//桁数を表示
    printf("%d", digits+1);
 
    return 0;
 
}

Measured memory_bytes: 128
//Relive your past life.
//Face your demons.
//The past is never dead,it is not even past.
//The memories are not only the key to the past but...also to the future.
//coded in Rusty Lake
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define ll   long long
#define pb   push_back
#define mp   make_pair
#define orz  1000000007
#define X    first
#define Y    second
using namespace std;
int x,y,z;
ll ans,f[100005],g[100005],o,res;
pair<int,pair<int,int> >p[100005];
priority_queue<int> q;
int main(){
    scanf("%d%d%d",&x,&y,&z);
    for(int i=1;i<=x+y+z;++i){
        int a,b,c;
        scanf("%d%d%d",&a,&b,&c);
        p[i]=mp(b-a,mp(a-c,b-c));
        ans+=c;
    }
    sort(p+1,p+x+y+z+1);
    for(int i=1;i<=x;++i){
        o+=p[i].Y.X;
        q.push(-p[i].Y.X);
    }
    f[x]=o;
    for(int i=x+1;i<=x+z;++i){
        o+=p[i].Y.X;
        q.push(-p[i].Y.X);
        o+=q.top();
        q.pop();
        f[i]=o;
    }
    while(!q.empty())q.pop();
    o=0;
    for(int i=x+y+z;i>x+z;--i){
        o+=p[i].Y.Y;
        q.push(-p[i].Y.Y);
    }
    g[x+z+1]=o;
    for(int i=x+z;i>x;--i){
        o+=p[i].Y.Y;
        q.push(-p[i].Y.Y);
        o+=q.top();
        q.pop();
        g[i]=o;
    }
    res=f[x]+g[x+1];
    for(int i=x+1;i<=x+z;++i)res=max(res,f[i]+g[i+1]);
    printf("%lld\n",ans+res);
    //system("pause");
    return 0;
}


Measured memory_bytes: 2688
#include <iostream>
#include <vector>
#include <queue>
#include <sstream>
#include <algorithm>
#include <bitset>
#include <limits>
#include <map>
#include <set>
#include <iomanip>
#include <cmath>

using namespace std;

typedef long long int ll;
typedef std::numeric_limits<double> dbl;
const long long int LL_INF=1LL<<60;

vector<string> split(const string& input, char delimiter)
{
    stringstream stream(input);
    
    string field;
    vector<string> result;
    while (getline(stream, field, delimiter)) {
        result.push_back(field);
    }
    return result;
}

//#define DEBUG

ll A, B, C, D, E, M, N, K, Q, W, H, T, X, Y;

int main()
{
    cin >> N;

    int cnt = 0;
    vector<bool> color(8);
    for (int i = 0; i < N; ++i) {
        int in;
        cin >> in;
        if (1 <= in && in < 400)
            color[0] = true;
        else if (400 <= in && in < 800)
            color[1] = true;
        else if (800 <= in && in < 1200)
            color[2] = true;
        else if (1200 <= in && in < 1600)
            color[3] = true;
        else if (1600 <= in && in < 2000)
            color[4] = true;
        else if (2000 <= in && in < 2400)
            color[5] = true;
        else if (2400 <= in && in < 2800)
            color[6] = true;
        else if (2800 <= in && in < 3200)
            color[7] = true;
        else
            cnt++;
    }

    int cNum = 0;
    for (auto c : color)
        if (c) cNum++;

    cout << max(cNum, 1) << " " << cNum + cnt << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1e9;
int MOD = 1e9+7;
bool used[100010];
main(){
    int N,A[100000],a;
    cin >> N;
    for(int i = 0;i < N;i++){
        cin >> a;
        A[i] = a-1;
    }
    int next = 0,cnt = 0;
    while(next != 1){
        if(used[next]){
            cout << -1 << endl;
            return 0;
        }
        used[next] = 1;
        next = A[next];
        cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 768
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

#define REP(i, a, b) for (int i = (a); i < (b); i++)

using namespace std;

int main() {
  int n, l, r;
  while(cin >> n >> l >> r, n + l + r) {
    vector<int> A(n);
    REP (i, 0, n) {
      cin >> A[i];
    }
    int ans = 0;
    REP (i, l, r + 1) {
      bool ok = false;
      REP (j, 0, n) {
	if (i % A[j] == 0) {
	  ok = true;
	  if ((j + 1) % 2 == 1) {
	    ans++;
	    //cout << i << endl;
	  }
	  break;
	}
      }
      if ((!ok) && n % 2 == 0) {
	//cout << "!" << ok << " " << n % 2 << " " << i << endl;
	ans++;
      }
    }
    cout << ans << endl;
  }
  return 0;
}



Measured memory_bytes: 3068
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e18;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 200005;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
ll fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    COMinit();
    ll n,k,c = 0;
    cin >> n >> k;
    rep(i,k,n+1){
        c += n*(n+1)/2-(n-i+1)*(n-i)/2-i*(i-1)/2+1;
        c %= MOD;
    }
    c++;
    c %= MOD;
    PRINT(c);
}


Measured memory_bytes: 8324
N, M, X, Y = map(int,input().split())
x = list(map(int,input().split()))
y = list(map(int,input().split()))
amax, bmin = max(x), min(y)
OK = False
for Z in range(amax+1,bmin+1):
    if X < Z and Z <= Y:
        OK = True
if OK:
    print("No War")
else:
    print("War")


Measured memory_bytes: 39280
#include <bits/stdc++.h>
#define        ll     long long int
using namespace std;
ll mod=1e9+7;
int add(ll x,ll y)
{
    return ((x%mod)+(y%mod))%mod;
}
int minu(ll x,ll y)
{
    return (((x-y)%mod)+mod)%mod;
}
int nine(ll n)
{
    ll ans=1;
    while(n>0)
    {
        ans=((ans%mod)*(9%mod))%mod;
        n--;
    }
    return ans;
}
int ten(ll n)
{
    ll ans=1;
    while(n>0)
    {
        ans=((ans%mod)*(10%mod))%mod;
        n--;
    }
    return ans;
}
int eight(ll n)
{
    ll ans=1;
    while(n>0)
    {
        ans=((ans%mod)*(8%mod))%mod;
        n--;
    }
    return ans;
}
int solve(ll n)
{
    ll m=ten(n);
    ll z=nine(n);
    ll l=eight(n);
    return minu(add(m,l),add(z,z));
}
int main()
{
    ll n;
        cin>>n;
        ll x=solve(n);
        cout<<x<<endl;
    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,a,b) for (int i = (b-1); i >= (a); i--)
#define REP(i,n) FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1e9+7;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main () {
  int N; cin >> N;
  vi X(N); REP(i,N) cin >> X[i];

  vi Y = X;
  SORT(Y);
  REP(i,N) {
    cout << (X[i]<Y[N/2]?Y[N/2]:Y[N/2-1]) << endl;
  }
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define endl "\n"

const int timeLimit = 1980;

i64 xor128()
{
  static i64 x = 123456789, y = 362436069, z = 521288629, w = 88675123;
  i64 t = (x ^ (x << 11));
  x = y;
  y = z;
  z = w;
  return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

i64 D;
i64 c[26];
i64 s[365][26];
vector<i64> ans;

i64 eval(vector<i64> &ans)
{
  i64 score = 0;
  i64 last[26] = {};
  for (i64 i = 0; i < D; i++)
  {
    score += s[i][ans[i]];
    last[ans[i]] = i + 1;
    for (i64 j = 0; j < 26; j++)
      score -= c[j] * (i + 1 - last[j]);
  }
  return score;
}

void solve()
{
  chrono::system_clock::time_point start = chrono::system_clock::now();
  chrono::system_clock::time_point end = start + chrono::milliseconds(timeLimit);
  i64 bestScore = 0, loop = 0;
  while (chrono::system_clock::now() < end)
  {
    i64 t[3] = {xor128() % D, xor128() % 26};
    t[0]--;
    t[1]--;
    t[2] = ans[t[0]];
    ans[t[0]] = t[1];
    i64 score = eval(ans);
    if (bestScore < score)
    {
      bestScore = score;
    }
    else
    {
      ans[t[0]] = t[2];
    }
    loop++;
  }
  cerr << "score: " << bestScore + (i64)(1e6) << endl
       << "loop: " << loop << endl;
}

void input()
{
  cin >> D;
  for (i64 i = 0; i < 26; i++)
    cin >> c[i];
  for (i64 i = 0; i < D; i++)
    for (i64 j = 0; j < 26; j++)
      cin >> s[i][j];
  ans.resize(D);
}

void output()
{
  for (i64 i = 0; i < D; i++)
    cout << ans[i] + 1 << endl;
}

int main()
{
  input();
  solve();
  output();
  return 0;
}


Measured memory_bytes: 3716