akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define SORT(x) sort(x.begin(),x.end())
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
#define No cout<<"No"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
    ll n;cin>>n;
    vector<ll> a(n);
    rep(i,n){cin>>a[i];}
    sort(ALL(a));
    ll ans=0,right=0,sum=0,num=a[0];
    for(int left=0;left<n;left++){
        num=a[left];
        while(right<n&&a[right]<=num+2){
            right++;
            sum++;
        }
        ans=max(sum,ans);
        if(right==left)right++;
        else{
            while(a[left]==num){
                left++;
                sum--;
            }
            left--;
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

int main(){

    string a;

    cin >> a;

    vector<char>g,h;

    for(int i=0;i<a.size()/2;i++){
        g.push_back(a[i]);
        h.push_back(a[i+a.size()/2]);
    }

    if(a.size()%2==1){
        g.push_back(a[a.size()/2]);
        h.push_back(a[a.size()-1]);
    }

    reverse(h.begin(),h.end());
    //cout << g.size() << ' ' << h.size() << endl;
    int ans=0;

    for(int i=0;i<g.size();i++){
        if(g[i]!=h[i]) ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <bits/stdc++.h>
#include <math.h>
#include <string>
#include <sstream>
#define ll long long
#define F first
#define S second
#define pb push_back
#define ld long double
#define pll pair<long long,long long>
#define pld pair<long double,long double>
#define ios     ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
ll mod=1000000007;
ll gcd (ll a,ll b)
{
    if(b==0)
        return a;
    else
        return gcd(b,a%b);
}
ll fastexp(ll x ,ll n)
{
    ll result =1;
    while(n>0)
    {
        if(n%2==1)
            result*=x;
        x*=x;
        n=n/2;
    }
    return result;
}

ll modularExp(ll x,ll n,ll mod)
{
    ll result=1;
    while(n>0)
    {
        if(n%2==1)
            result=(result*x)%mod;
        x=((x%mod)*(x%mod))%mod;
        n=n/2;
    }
    return (result)%mod;
}
bool isPrime(ll n)
{
    for(ll i=2;i*i<=n;i++)
        if(n%i==0)
            return false;
    return true;
}
bool mycomp(pll &a,pll &b)
{
    if(a.F!=b.F)
        return a.F < b.F;
    else
        return a.S < b.S;
}

void solve()
{
     ll n,k;
     cin>>n>>k;
     vector<ll> v(n+1),w(n+1);
     ll i,j;
     for(i=1;i<=n;i++)
          cin>>w[i]>>v[i];
     vector<ll> dp(k+1);
     for(i=1;i<=n;i++)
     {
          for(j=k;j>=w[i];j--)
               dp[j]=max(dp[j],dp[j-w[i]]+v[i]);
     }
     cout<<dp[k];
     
     
     
}

int main()
{
    ios;
    ll t;
//    cin>>t;
  t=1;
    while(t--)
        solve();
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    //*
    int a;
    cin >> a ;
    //*/

    /*
    vector<int> vec(3);
    cin >> vec.at(0) >> vec.at(1) >> vec.at(2) ;

    sort(vec.begin(), vec.end());
    //*/
    
    /*
    if( vec.at(0) == vec.at(1) || vec.at(1) == vec.at(2) || vec.at(2) == vec.at(3) ){
        cout << "Bad" << endl;
    } else {
        cout << "Good" << endl;
    }
    //*/
    
    cout << pow(a, 3) << endl;

    return 0; 
}


Measured memory_bytes: 4228
from sys import setrecursionlimit
#setrecursionlimit(10**5)
class UnionFind:
    def __init__(self, n):
        # 親要素のノード番号を格納
        # par[x]=xの時そのノードは根　
        self.par = [i for i in range(n + 1)]
        # rank
        self.rank = [0] * (n + 1)
        self.size = [1] * (n + 1)

    def find(self, x):
        # 根の番号を返す(所属する集合を確認する)
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def check(self, x, y):
        # x,yが同じ集合に属するかどうか調べる
        return self.find(x) == self.find(y)


    def union(self, x, y):
        # 根を探す
        x = self.find(x)
        y = self.find(y)
        if x == y:return
        # rankの小さいものを大きいほうにくっつける
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self.size[y] += self.size[x]
        else:
            self.par[y] = x
            self.size[x] += self.size[y]
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def count_group(self):
        return len({self.find(x) for x in range(1, n + 1)})

n, m = map(int,input().split())
ab = [list(map(int,input().split())) for i in range(m)]

cnt = 0
for i in range(m):
    uf = UnionFind(n)
    for j in range(m):
        if i == j:continue
        a, b = ab[j]
        uf.union(a, b)

    if uf.count_group() > 1:cnt += 1
print(cnt)

Measured memory_bytes: 42608
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()
#define all(v) (v).begin(), (v).end()
#define sz(v) (int)(v).size()

using namespace std;

typedef long long ll;
typedef long double ld;

using P = pair<int, int>;

static const long long MOD = 1000000007;
static const long long LINF = (ll)(1e18+99);
static const int INF = 1e9+99;

int dist[105][105];
int A[1005], B[1005], C[1005];
int ans;

int main(void) {
  int n, m;
  cin >> n >> m;
  rep(i, 0, 105) rep(j, 0, 105) {
    if (i==j) dist[i][j] = 0;
    else dist[i][j] = INF;
  }
  rep(i, 0, m) {
    int a, b, c;
    cin >> a >> b >> c;
    a--; b--;
    dist[a][b] = dist[b][a] = c;
    A[i] = a;
    B[i] = b;
    C[i] = c;
  }

  for (int k=0; k<n; k++) {
    for (int i=0; i<n; i++) {
      for (int j=0; j<n; j++) {
        dist[i][j] = min(dist[i][j], dist[i][k]+dist[k][j]);
      }
    }
  }

  for (int k=0; k<m; k++) {
    bool flag = false;
    int a = A[k], b = B[k], c = C[k];
    for (int i=0; i<n; i++) {
      for (int j=0; j<n; j++) {
        if (dist[i][j]==dist[i][a]+dist[b][j]+c) flag = true;
      }
    }
    if (!flag) ans++;
  }
  

  
  cout << ans << endl;

    return 0;
}



Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
int64_t N,D,Q;
int main(){
  cin>>N>>D;
  vector<int64_t>d(N);
  for(int i=0;i<N;i++)
    cin>>d.at(i);
  vector<int64_t>a(N);
  a[N-1]=1;
  for(int i=N-2;0<=i;i--)
    if(2*a[i+1]<=d[i+1])
      a[i]=a[i+1];
  else
    a[i]=a[i+1]+d[i+1];
  vector<int64_t>b(N);
  b[0]=D;
  for(int i=1;i<N;i++)
    b[i]=min(b[i-1],abs(b[i-1]-d[i-1]));
        cin>>Q;
  for(int i=0;i<Q;i++){
  int64_t q;cin>>q;q--;
    if(a[q]<=b[q])
      cout<<"YES"<<endl;
    else
      cout<<"NO"<<endl;
  
  }
  return 0;
}

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

#define i64 long long int

int main() {
	i64 n; cin>>n;
	
	i64 mi = (i64)1e17, id;
	for(int i=0;i<5;i++) {
		i64 x; cin>>x;
		if (x<mi) { mi = x; id = i; }
	}
	
	i64 ans = (n-1)/mi+1 + id;
	ans += (4-id);
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 256
s1 = $stdin.gets.chop
q = $stdin.gets.to_i
fwd = true
s0 = ''; s2 = ''
q.times do |i|
  case $stdin.gets
  when /^1/
    fwd = !fwd
  when /^2 (1|2) (.)/
    if (($1 == "1") ^ !fwd) then
      s0 << $2
    else
      s2 << $2
    end
  end
end
if fwd then
  s0.reverse!
  print s0, s1, s2, "\n"
else
  s1.reverse!
  s2.reverse!
  print s2, s1, s0, "\n"
end

Measured memory_bytes: 3196
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
#include <bitset>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;
void dfs(ll now, ll use, ll &n, ll &cnt)
{
    if (now > n)
    {
        return;
    }
    if (use == 7)
    {
        cnt++;
    }
    dfs(now * 10 + 3, use | 0b100, n, cnt);
    dfs(now * 10 + 5, use | 0b010, n, cnt);
    dfs(now * 10 + 7, use | 0b001, n, cnt);
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    ll cnt = 0;
    dfs(0, 0, n, cnt);
    cout << cnt << endl;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define INF 1000000000

ll t[100001];
ll ch[100001];

void solve_abc_d() {
    ll n, c;
	ll ans = 0;

	cin >> n >> c;
	vector<P> s;
	ll p, q, r;
	rep(i, n) {
		cin >> p >> q >> r;
		s.push_back(make_pair(p, i));
		t[i] = q;
		ch[i] = r;
	}

	sort(ALL(s));

	ll idx, st, et, ec, nt, nc;
	priority_queue<P> pq;
	priority_queue<P> tmp;

	rep(i, n) {
		idx = s[i].second;
		st = s[i].first;
		et = t[idx];
		ec = ch[idx];

		if (pq.size() == 0) {
			pq.push(make_pair(-et, ec));
		}
		else {
			nt = -pq.top().first;
			nc = pq.top().second;
			if (nt < st) {
				pq.pop();
			}
			else if (st == nt) {
				if (ec == nc) {
					pq.pop();
				}
				else {
					while (st == -pq.top().first) {
						tmp.push(make_pair(pq.top().first, pq.top().second));
						pq.pop();
						if (pq.size() == 0) {
							break;
						}
						else  if (st == -pq.top().first) {
							if (ec == pq.top().second) {
								pq.pop();
								break;
							}
						}
					}
					while (tmp.size()>0) {
						pq.push(make_pair(tmp.top().first, tmp.top().second));
						tmp.pop();
					}
				}
			}

			pq.push(make_pair(-et, ec));
		}
	}

	ans = pq.size();

	cout << ans << "\n";
}

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

	solve_abc_d();

	return 0;
}


Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
vector<string> v;
void permute(string a, int l, int r)
{
	if (l == r)
		v.push_back(a);
	else
	{
		for (int i = l; i <= r; i++)
		{

			swap(a[l], a[i]);

			permute(a, l+1, r);

			swap(a[l], a[i]);
		}
	}
}
int main()
{
    int n ;
    cin >> n ;
    string a = "" , b = "";
    string str = "";
    for(int i = 0 ; i < n ; i++){
        char p ;
        cin >> p ;
        a+=p;
        str+=p;
    }
    for(int i = 0 ; i < n ; i++){
        char p ;
        cin >> p ;
        b+=p;
    }
    sort(str.begin(),str.end());
	int r = str.size();
	permute(str, 0, r-1);
	int ind1  = 0 , ind2 = 0 ;
	sort(v.begin(),v.end());

	for(int i = 0 ; i < v.size() ;i++){
        if(a == v[i]){
            ind1 = i+1 ;
            break;
        }
	}
	for(int i = 0 ; i < v.size() ;i++){
        if(b == v[i]){
            ind2 = i+1 ;
            break;
        }
	}
	int ans = abs(ind1-ind2);
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 2424
#include <iostream>
#include <vector>
#include <string>
using namespace std;

int main(){
	int n, m;
	cin >> n >> m;
	
	vector<bool> ac_flg(n,false);
	vector<int> count_pen(n, 0);
	
	int ac = 0, pen = 0;
	
	for(int i = 0; i < m; i++){
		int prob_num;
		string result = (char*)calloc(3, sizeof(char));
		cin >> prob_num >> result;
		
		if(!ac_flg.at(prob_num-1)){//一度もACしてない
			if(result == "AC"){
				ac++;
				ac_flg.at(prob_num-1) = true;
			}
			else{
				count_pen.at(prob_num-1)++;
			}
		}
	}
	for(int i = 0; i < n; i++){
		if(ac_flg.at(i)) pen += count_pen.at(i);
	}
	
	cout << ac << " " << pen << endl;
	
}

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

using namespace std;

#define rep(i, n) REP(i, 0, (n))
#define REP(i, a, n) for(int i=(a); i<(n); i++)

int main() {
    int m, n, x; cin >> n >> m >> x;
    int ansz = 0, ansn = 0;
    rep(i, m) {
        int a; cin >> a;
        if(a>x) ansn++;
        if(a<x) ansz++;
    }
    cout << min(ansz, ansn) << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int n,m;
	for(;scanf("%d %d",&m,&n)!=EOF;){
		while(m!=n){
			if(m>n)m=m-n;
			else n=n-m;
		}
		printf("%d\n",n);
	}
	exit(0);
}

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

int main() {
    int h, w;
    cin >> h >> w;
    int a[h][w];
    rep(i, h) rep(j, w) cin >> a[i][j];
    bool has = false;
    if (a[0][0] % 2 == 1) {
        has = true;
    }
    int x = 1, y = 0, ox = 0, oy = 0;
    int ax[250000], ay[250000], adx[250000], ady[250000], i = 0;

    while(true) {
        if (x >= w) {
            x = w-1;
            y++;
        } else if (x < 0) {
            x = 0;
            y++;
        }
        if (y >= h) break;

        if (has) {
            ax[i] = ox;
            ay[i] = oy;
            adx[i] = x;
            ady[i] = y;
            oy = y;
            ox = x;
            a[y][x]++;
            i++;
            if (a[y][x] % 2 == 0) {
                has = false;
            }
        } else if (a[y][x] % 2 == 1) {
            oy = y;
            ox = x;
            has = true;
        }

        // update
        if (y % 2 == 0) x++;
        else x--;
    }
    // output
    cout << i << endl;
    rep(j, i) {
        printf("%d %d %d %d\n", ay[j]+1, ax[j]+1, ady[j]+1, adx[j]+1);
    }
    return 0;
}

Measured memory_bytes: 6144
K, N = map(int, input().split())
A = [int(a) for a in input().split()] 
max = 0
for i in range(N):
    if i > 1:
        if A[i] - A[i-1] > max:
            max = A[i] - A[i-1]
    else: 
        if A[0] + K - A[N-1] > max:
            max = A[0] + K - A[N-1]
print(K - max)

Measured memory_bytes: 24908
import scala.io.StdIn._

object Main extends App {

  def selectionSort(a: Array[Int], n: Int) {
    var cnt = 0
    for (i <- (0 until n-1)) {
      val tmp_a = a.takeRight(n - i)
      val min_v_index = tmp_a.indexOf(tmp_a.min) + i
      val tmp_v = a(i)
      a(i) = a(min_v_index)
      a(min_v_index) = tmp_v
      if (i != min_v_index) cnt += 1
    }
    println(a.mkString(" "))
    println(cnt)
  }

  val n: Int = readLine.toInt
  val a: Array[Int] = readLine.split(" ")
                              .map(s => s.toInt)
                              .toArray
  selectionSort(a, n)
}


Measured memory_bytes: 44056
IDENTIFICATION DIVISION.
PROGRAM-ID. PROGRAM_ID.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 LN             PIC X(3).
01 a              PIC 9(1).
01 b              PIC 9(1).
01 i              PIC 9(2).
01 ans            PIC X(9).

PROCEDURE DIVISION.
  ACCEPT LN.
  UNSTRING LN DELIMITED BY SPACE INTO a b.
  IF a < b
      PERFORM VARYING i FROM 1 BY 1 UNTIL b < i
          STRING ans(1:FUNCTION STORED-CHAR-LENGTH(ans)) a
          INTO ans
      END-PERFORM
  ELSE
      PERFORM VARYING i FROM 1 BY 1 UNTIL a < i
          STRING ans(1:FUNCTION STORED-CHAR-LENGTH(ans)) b
          INTO ans
      END-PERFORM
  END-IF.
  DISPLAY ans(1:FUNCTION STORED-CHAR-LENGTH(ans)).
  STOP RUN.


Measured memory_bytes: 636
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;

#define BIG_NUM 2000000000

using namespace std;


int main(){

	int table[128] = {0};
	char buf[301];

	scanf("%s",buf);

	for(int i = 0; buf[i] != '\0'; i++){
		table[buf[i]]++;
	}

	printf("%d\n",min(min(table['K'],table['U']),min(table['P'],table['C'])));

	return 0;
}

Measured memory_bytes: 2752
n=int(input())
a=list(map(int,input().split()))

a.reverse()

for i in range(n-1):
  if a[i]+1==a[i+1]:
    a[i+1]-=1
  elif a[i]+1<a[i+1]:
    print("No")
    exit()
  else:
    pass
print("Yes")

Measured memory_bytes: 14396
N = int(input())
l = [[int(x) for x in input().split()] for _ in range(N)]
l.insert(0, [0, 0, 0])
judge = True
 
for i in range(N):
    if (l[i+1][0]-l[i][0]) < ((l[i+1][1]-l[i][1])+(l[i+1][2]-l[i][2])):
        judge = False
        break
    
    if (l[i+1][0]-l[i][0]) % 2 != ((l[i+1][1]-l[i][1])+(l[i+1][2]-l[i][2])) % 2:
        judge = False
        break
    
if judge == True:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 21180
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
#define endl '\n'
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9 + 7 ;
const ll N = 1e5 + 10 ;

int main(){
    fastio
   int a,b,c; 
   cin>>a>>b>>c;
   if(b/a>=c)
   cout<<c<<endl;
   else cout<<b/a<<endl;
    return 0 ;
}

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

int main()
{
	int H, W;
	while (1) {
		std::cin >> H >> W;
		std::vector<int> v1(H);
		std::vector<int> v2(W);
		if (H == 0 && W == 0)break;
		for (auto i = v1.begin(); i != v1.end(); i++) {
			for (auto j = v2.begin(); j != v2.end(); j++) {
				std::cout << '#';
			}
			std::cout << std::endl;
		}
		std::cout << std::endl;
	}
}

Measured memory_bytes: 3084
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int tako = scan.nextInt();
		int[] oisi = new int[tako];
		int sum = 0;

		for(int i=0;i<tako;i++) {
			oisi[i] = scan.nextInt();
		}

		for(int a=0;a<tako;a++) {
			for(int b=a+1;b<tako;b++) {
				sum += oisi[a]*oisi[b];
			}
		}

		System.out.println(sum);

		scan.close();
	}

}


Measured memory_bytes: 23252
using System;
using System.Collections.Generic;
using System.Linq;
public class Hello{
    public static void Main()
    {
        var NK = Console.ReadLine().Split().Select(e=>long.Parse(e)).ToArray();
        var next = Console.ReadLine().Split().Select(e=>int.Parse(e)).ToArray();
        //町の数
        var N = NK[0];
        //移動回数
        var K = NK[1];
        var comb = new Dictionary<long,Tuple<long,bool,long>>();
        for(long n=1;n<N+1;n++)
        {
            comb.Add(n,new Tuple<long,bool,long>(next[n-1],false,0L));
        }
        var ans =0;
        var nextT = 1L;
        var roopCnt = 1L;
        for(long visitCnt=K;0<visitCnt;visitCnt--)
        {
            if(comb[nextT].Item2==true)
            {
                var remain = visitCnt%(roopCnt-comb[nextT].Item3);
                //Console.WriteLine("remain : "+remain);
                for(long r=0;r<remain;r++)
                {
                    nextT =comb[nextT].Item1; 
                }
                Console.WriteLine(nextT);
                return;
            
            }
            else
            {
                long n = comb[nextT].Item1;
                comb.Remove(nextT);
                comb.Add(nextT,new Tuple<long,bool,long>(n,true,roopCnt));
                //comb[nextT].Item2=true;
                //comb[nextT].Item3=roopCnt;
            }
            roopCnt = roopCnt +1;
            nextT = comb[nextT].Item1;
            //Console.WriteLine(nextT);
        }
        Console.WriteLine(nextT);
    }
}


Measured memory_bytes: 64640
#include "stdio.h"

int main()
{
	int i = 0;
	int j = 0;
	for (i = 1; i < 10; i++)
	{
		for (j = 1; j < 10; j++)
		{
			printf("%dx%d=%d\n",i,j,i*j);
		}
	}

	return 0;
}

Measured memory_bytes: 524
<?php
# 数値の入力
fscanf(STDIN, "%d", $data1);
$data2 = fgets(STDIN);
$data2 = explode(" ", $data2);
$data3 = fgets(STDIN);
$data3 = explode(" ", $data3);
$data4 = fgets(STDIN);
$data4 = explode(" ", $data4);

$anser = 0;
$number = 0;
for($i = 0; $i < $data1; $i++){
    $anser += $data3[$data2[$i]-1];
   # echo $data2[$i]."\n";
   # echo $number."\n";
   if($data2[$i] == $number){
       $anser += $data4[$number-2];
   }
   $number = $data2[$i]+1;
}
echo $anser;
?>

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

using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    for (int i = 0; i < n; i++) {
        cin >> p[i];
    }

    sort(p.begin(), p.end());

    int sum = 0;
    for (int i = 0; i < k; i++) {
        sum += p[i];
    }

    cout << sum << endl;
}

Measured memory_bytes: 3580
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	int A, B, C;
	cin >> A >> B >> C;
	cout << C << " " << A << " " << B << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt(), b = sc.nextInt();
		sc.close();
		int max = a + b;
		max = Math.max(max,  a - b);
		max = Math.max(max,  a * b);
		System.out.println(max);

	}

}


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

main(){
  int N;
  cin >> N;
  int K;
  cin >> K;
  int h[N];
  for(int ii=0;ii<N;ii++){
    cin >> h[ii];
  }
  int cnt=0;
  for(int ii=0;ii<N;ii++){
    if(h[ii]>=K)cnt++;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 640
#include <stdio.h>
int main(void){
	
	int h,w,i,j;
	while(1){
		scanf("%d %d",&h,&w);
		if(h==0 && w==0)break;
		for(i=0;i<h;i++){
			for(j=0;j<w;j++){
				if(i==0 || j==0 || i==(h-1) || j==(w-1)){
					printf("#");
				}
				else printf(".");
			}
			printf("\n");
		}
		printf("\n");
	}
	
	return 0;
}


Measured memory_bytes: 2056
S = gets.chomp.chars.map(&:to_i)
N = S.length
ans = Array.new
array_0 = [0]
(N-1).times do |i|
  if array_0[i] == 0
    array_0.push(1)
  else
    array_0.push(0)
  end
end
array_1 = [1]
(N-1).times do |i|
  if array_1[i] == 1
    array_1.push(0)
  else
    array_1.push(1)
  end
end
cnt_0 = 0
(0..N-1).each do |i|
  cnt_0 += 1 unless S[i] == array_0[i]
end
ans.push(cnt_0)
cnt_1 = 0
(0..N-1).each do |i|
  cnt_1 += 1 unless S[i] == array_1[i]
end
ans.push(cnt_1)
puts ans.min


Measured memory_bytes: 9396
#[allow(unused_imports)]
use itertools::Itertools;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;

fn main() {
    input! {
        n: usize,
        mut a: [i64; n],
    }

    a.sort();

    let mut mx = std::collections::BinaryHeap::new();
    let mut mn = std::collections::BinaryHeap::new();
    use std::cmp::Reverse;
    let mut res = 0;
    while let Some(a) = a.pop() {
        if mx.is_empty() {
            mn.push(Reverse(a));
            mx.push(a);
            continue;
        }
        if mn.peek().unwrap().0 < *mx.peek().unwrap() {
            let x = mn.pop().unwrap().0;
            let y = mx.pop().unwrap();
            mn.push(Reverse(y));
            mx.push(x);
        }
        res += mx.peek().unwrap();
        mn.push(Reverse(a));
        mx.push(a);
    }
    println!("{}", res);
}


Measured memory_bytes: 10068
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
use std::io::*;
use std::str::FromStr;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);

impl<T: PartialEq> Eq for Total<T> {}

impl<T: PartialOrd> Ord for Total<T> {
    fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering {
        self.0.partial_cmp(&other.0).unwrap()
    }
}

//const MAX:usize = 100006;
//const INF:u64 = u64::max_value();

fn main() {
    let n:usize = read();
    let h:u32 = read();
    let w:u32 = read();
    let p:Vec<(u32,u32)> = (0..n).map(|_| (read(), read())).collect();

    let mut ans:i32 = 0;
    for &el in p.iter() {
        if el.0 >= h && el.1 >= w {
            ans += 1;
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<queue>
#include<stack>
#include<vector>
#include<map>
#include<set>
#define MAX 300005
using namespace std;

typedef long long ll;
int a[MAX];
int vis[MAX];
int main()
{
	int n,m;
	cin>>n>>m;
	int x;
	for(int t=0;t<n;t++) 
	{
		int k;
		scanf("%d",&k);
		for(int j=0;j<k;j++)
		{
			scanf("%d",&x);
			vis[x]++;
		}
	}
	int s=0;
	for(int t=0;t<=30;t++)
	{
		if(vis[t]==n)
		{
			s++;
		}
	}
	cout<<s<<endl;
	return 0;
 } 

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

using ll = long long;
#define int long long
using P = pair<int, int>;

#define LOG(variable) cerr << #variable":\t" << (variable) << "\n"
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cerr << (i) << ":\t" << (container)[(i)] << "\n"
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, n, r) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
template<typename T = int>
T in() {T a; cin >> a; return a;}
/***** MAIN *****/
signed main() {
  int n, m, k; cin >> n >> m >> k;
  vector<int> a_cum_sum(n+1, 0LL), b_cum_sum(m+1, 0LL);
  for(int i = 0; i < n; ++i) {
    int a; cin >> a;
    a_cum_sum[i+1] = a_cum_sum[i] + a;
  }
  for(int i = 0; i < m; ++i) {
    int b; cin >> b;
    b_cum_sum[i+1] = b_cum_sum[i] + b;
  }
  int ans = 0;
  for(int i = 0; i < n+1; ++i) {
    if(a_cum_sum[i] > k) break;
    int rest = k - a_cum_sum[i];
    int index = upper_bound(ALL(b_cum_sum), rest) - b_cum_sum.begin();
    // index:5のとき、index:4までrestをこしてないっていうことになるので[0,4)の範囲で本を読める。→0,1,2,3の4冊→index-1が答え
    ans = max(ans, i+index-1);
  }
  cout << ans;

  cout << "\n";
  return 0;
}
/***** MAIN *****/

Measured memory_bytes: 6372
s = input()
n = len(s)

def dfs(i, l):
    if i == n-1:
        return sum(list(map(int, l.split("+"))))
    return dfs(i+1, l+s[i+1]) + dfs(i+1, l+"+"+s[i+1])

print(dfs(0, s[0]))

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

int main() {
  int N, M;
  cin >> N >> M;
  
  vector< vector <int> > S;
  S.reserve(M);
  for (int i = 0; i < M; i++) {
    int k;
    cin >> k;
    vector<int> t;
    t.reserve(k);
    for (int j = 0; j < k; j++) {
      int s;
      cin >> s;
      t.push_back(s);
    }
    S.push_back(t);
  }
  
  vector<int> P;
  P.reserve(M);
  for (int i = 0; i < M; i++) {
    int p;
    cin >> p;
    P.push_back(p);
  }
  
  vector<vector<int>> states;
  for (int i0 = 0; i0 < 2; i0++) {
    if (N == 1) {
      vector<int> state = {i0};
      states.push_back(state);
    }
  for (int i1 = 0; i1 < 2; i1++) {
    if (N == 2) {
      vector<int> state = {i0, i1};
      states.push_back(state);
    }
  for (int i2 = 0; i2 < 2; i2++) {
    if (N == 3) {
      vector<int> state = {i0, i1, i2};
      states.push_back(state);
    }
  for (int i3 = 0; i3 < 2; i3++) {
    if (N == 4) {
      vector<int> state = {i0, i1, i2, i3};
      states.push_back(state);
    }
  for (int i4 = 0; i4 < 2; i4++) {
    if (N == 5) {
      vector<int> state = {i0, i1, i2, i3, i4};
      states.push_back(state);
    }
  for (int i5 = 0; i5 < 2; i5++) {
    if (N == 6) {
      vector<int> state = {i0, i1, i2, i3, i4, i5};
      states.push_back(state);
    }
  for (int i6 = 0; i6 < 2; i6++) {
    if (N == 7) {
      vector<int> state = {i0, i1, i2, i3, i4, i5, i6};
      states.push_back(state);
    }
  for (int i7 = 0; i7 < 2; i7++) {
    if (N == 8) {
      vector<int> state = {i0, i1, i2, i3, i4, i5, i6, i7};
      states.push_back(state);
    }
  for (int i8 = 0; i8 < 2; i8++) {
    if (N == 9) {
      vector<int> state = {i0, i1, i2, i3, i4, i5, i6, i7, i8};
      states.push_back(state);
    }
  for (int i9 = 0; i9 < 2; i9++) {
    if (N == 10) {
      vector<int> state = {i0, i1, i2, i3, i4, i5, i6, i7, i8, i9};
      states.push_back(state);
    }
  }}}}}}}}}}

  int ans = 0;
  for (state : states) {
    cerr << "state: ";
    for(s : state) cerr << s << ' ';
    cerr << endl;
    
    int pattern = 0;
    for (int j = 0; j < M; j++) {
      int st = 0;
      for (int k = 0; k < S[j].size(); k++) {
        int idx = S[j][k];
        st += state[idx-1];
      }
      if (P[j] == 0 && st % 2 == 0) {
        cerr << "light " << j << ' ' << 1 << endl;
		pattern++;
      } else if (P[j] == 1 && st % 2 == 1) {
        cerr << "light " << j << ' ' << 1 << endl;
		pattern++;
      } else {
        cerr << "light " << j << ' ' << 0 << endl;
      }
    }
    cerr << pattern << endl;
    if (pattern == M) ans++;
  }

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




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define get(c,x) (upper_bound(c.begin(),c.end(),x)-c.begin())
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;
ll ans;
void solve() {
	int n;
	cin >> n;
	VI a(n), b(n), c(n);
	rep(i, 0, n)cin >> a[i];
	rep(i, 0, n)cin >> b[i];
	rep(i, 0, n)cin >> c[i];
	sort(all(b));
	sort(all(c));
	vector<ll> suf_b(n);
	for (int i = 0; i < n; i++) {
		int x = get(c, b[i]);
		suf_b[i] = n - x;
	}
	/*rep(i, 0, n) {
		cout << suf_b[i] << " ";
	}
	cout << endl;*/
	for (int i = n - 2; i >= 0; i--)suf_b[i] += suf_b[i + 1];
	for (int i = 0; i < n; i++) {
		int x = get(b, a[i]);
		if (x < n)ans += suf_b[x];
	}
	cout << ans << endl;
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int T_ = 1;
	//cin >> T_;
	for (int i = 0; i < T_; i++)solve();
	return 0;
}







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

int main()
{
  int n;
  double m;
  cin >> n >> m;
  double a, b;
  int ans = 0;
  rep(i, n){
    cin >> a >> b;
    if(sqrt(pow(a,2) + pow(b,2)) <= m) ans++;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3696
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
int h[maxn];
int n,ans=0,now=0;
inline int read(){
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;char ch=getchar();}
	while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}
	return x*f;
}
int main(){
	n=read();
	for(int i=1;i<=n;i++){
		h[i]=read();
		if(h[i]<=h[i-1]){
			now++;
		}
		else ans=max(ans,now),now=0;
	}
	ans=max(ans,now);
	cout<<ans;
	return 0;
} 

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define inf 10000000000
#define N 1000000007
using namespace std;

long long n, m, x = 0, y = 0, ans;
long long minx = inf, miny = inf, maxx = 0, maxy = 0;

int main() {
  long long i;
  cin >> n >> m;
  cin >> minx;
  for(i = 1; i < n; ++i) {
    cin >> maxx;
    x += ((maxx - minx) * i) % N * (n - i) % N;
    x %= N;
    minx = maxx;
  }
  cin >> miny;
  for(i = 1; i < m; ++i) {
    cin >> maxy;
    y += ((maxy - miny) * i) % N * (m - i) % N;
    y %= N;
    miny = maxy;
  }
  cout << (x * y) % N << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
#define For(i,a,b) for(int i=a;i<b;i++)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define mp make_pair
#define bit(n) (1LL<<(n))
#define F first
#define S second
#define debug(x) cerr << x << endl
#define Complex complex<double>
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

/*
テストケース全てに目を通す
テストケースが2個以下だったらなんかある
N最小のコーナーケースがないか調べる
制約をしっかりと確認する（1からNまでの順列、全て異なる値などの制約も含め）
制約のn*mとn,mを読み違えない
操作の逆順を考える
オーバーフローしないか確かめる
Codeforcesではscanfを使う
modの引き算には+modをする
エラー出力は消す
エラー出力を消せ！！！！！
数値の区切り位置を誤読しない
木はn-1ノード
関数単位で調べる
cout << fixed;
cout << setprecision(n) << ans;
 */

int main() {
    string s;
  	cin >> s;
    int now=s.length()-1;
    while(now>=0){
        if(now>=6){
            if(s.substr(now-6,7)=="dreamer"){
              	now-=7;
            	continue;
            }
        }
      	if(now>=5){
          	if(s.substr(now-5,6)=="eraser"){
              	now-=6;
              	continue;
            }
        }
        if(now>=4){
            if(s.substr(now-4,5)=="dream" || s.substr(now-4,5)=="erase"){
              	now-=5;
            	continue;
            }
        }
        cout << "NO";
        return 0;
    }
    cout << "YES";
    return 0;


    
}

/*
*/



Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <sstream>

#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <deque>
#include <queue>
#include <stack>

#include <algorithm>
#include <utility>
#include <numeric>
#include <functional>

#include <chrono>
#include <random>

using namespace std;
using i64 = int_fast64_t;
using ui64 = uint_fast64_t;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<i64>;
using vvl = vector<vl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vb = vector<bool>;
using vvb = vector<vb>;
using pii = pair<int, int>;
using pll = pair<i64, i64>;

/////////////////////////////////////////////////

int main(){
    int n;
    cin >> n;
    vector<pair<pair<string, int>, pair<int, int>>> p(n);
    for(int i=0;i<n;i++){
        cin >> p[i].first.first >> p[i].first.second;
        p[i].second.first = i;
    }
    sort(p.begin(), p.end(), [&](const auto &l, const auto &r){
        return l.first.first == r.first.first ? l.first.second > r.first.second : l.first.first < r.first.first;
    });
    for(int i=0;i<n;i++){
        p[i].second.second = i+1;
    }
    // sort(p.begin(), p.end(), [&](const auto &l, const auto &r){
    //     return l.second.first < r.second.first;
    // });
    for(auto&& x:p){
        cout << x.second.first+1 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define db(x) (cerr << #x << ": " << (x) << '\n')
#define cps CLOCKS_PER_SEC
#define tests(t) int t; cin >> t; while(t--)
#define iceil(n, x) (((n) + (x) - 1) / (x))
#define ll long long
#define ld double
#define eb emplace_back
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define sz size()
#define all(v) (v).begin(), (v).end()
#define uni(v) sort(all(v)), (v).erase(unique(all(v)), (v).end())
#define fi first
#define se second
#define bitcount(x) __builtin_popcount(x)
#define PI acos(-1.0)
#define EPS 1e-9
#define mod 1000000007

#define par pair<int, int>
#define maxn 505

using namespace std;
///All indexing is 0-based
using namespace __gnu_pbds;
template<class key, class cmp = std::less<key>>
using ordered_set = tree<key, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
///methods: find_by_order(k); & order_of_key(k);
///To make it an ordered_multiset, use pairs of (value, time_of_insertion)
///to distinguish values which are similar

ll a[4];

int main()
{
    #ifdef acm
    freopen("a.in","r",stdin);
    #endif // acm
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    cin >> a[0] >> a[1];
    sort(a,a+2);

    for(int i=0;i<3;i++)
        if(a[i]!=i+1){
            cout << (i+1);
            return 0;
        }




}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <climits>
using namespace std;

#define MOD1097 1000000007

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mpair make_pair
#define pm(first, second) pb(mpair(first, second))
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(X) (X).begin(), (X).end()
#define reall(X) (X).rbegin(), (X).rend()
#define divcel(a, b) (((a) + ((b) - 1)) / (b))

int main(){

    int N;
    cin >> N;
    vector<ll> A(N);
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }
    ll cnt = 0;
    for(int i = 1; i < N; i++){
        if(A[i] > A[i-1])cnt++;
    }
    cout << cnt << endl;

    return 0;
}



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

template<typename First, typename Second, typename Third>
struct triple {
   First first;
   Second second;
   Third third;
};
using namespace std;

void solve(){
   long long a,b;
   cin>>a>>b;
   long long r=b/1000;
   if(r==a){
       cout<<0<<" "<<0<<" "<<r;
       return ;
   }
   for(int i=0;;i++){
        if(i*10000>b)
             break;
        long long y=r;
        for(int j=0;;j++){
              if(y+j+i==a){
                     cout<<i<<" "<<j<<" "<<y;
                     return;
              }
              y-=5;
             if(y<0)
                break;
        }
        r-=10;
       if(r<0)
         break;
   }        
   cout<<-1<<" "<<-1<<" "<<-1;
}
int main(){
    std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    solve();
  return 0;
}


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

using namespace std;

static const int N = 100;

//m[i][j]には、i～j番目までの行列のコストの最小値が入る。
int main(void){
    int n, p[N+1], m[N+1][N+1];
    cin >> n;
    //行列の行と列をpに入れる。i番目の行列の列とi+1番目の行列の行は同じ値なので同じ場所に入れてる
    for(int i = 1; i <= n; i++){
        cin >> p[i-1] >> p[i];
    }
    //i番目の行列とi番目の行列では計算が発生しないので0で初期化
    for(int i = 1; i <= n; i++)m[i][i] = 0;
    //連鎖行列積のコスト計算
    //lは対象とする行列の数を決めてる
    for(int l = 2; l <= n; l++){
        //i番目からj番目までの行列計算のコストを計算する。iとjはそのための変数
        //iは1番目の行列から、jが行列の存在する範囲を超えないようにi - l + 1番目までいく
        for(int i = 1; i <= n - l + 1; i++){
            //j = i + l だとi ~ jまでの範囲の行列の数が l + 1個になってしまうのでj = i + l - 1になっている。
            int j = i + l - 1;
            //めっちゃ小さい値で初期化
            m[i][j] = (1 << 21);
            //i番目からj番目までの最小コストを計算する。
            //(M1M2M3M4M5)の最小コストは、例えば(M1M2M3)(M4M5)だとすると、このときkは3。で、(M1M2M3)は(M1M2)(M3)と(M1)(M2M3)の小さいほうの値で、もう入ってる。
            //(M4M5)は一通りのコストしかないので、OK。
            //この時 m[1][5] = (M1M2M3)のコスト + (M4M5)のコスト + (前半の計算でできる行列) × (後半の計算で出来る行列)のコスト(M1の行数 * M3の列数 * M5の列数)
            for(int k = i; k <= j - 1; k++){
                m[i][j] = min(m[i][j], m[i][k] + m[k + 1][j] + p[i-1] * p[k] * p[j]);
            }
        }
    }
    cout << m[1][n] << endl;
    return 0;
}


Measured memory_bytes: 3116
import sys
import math
def get_array(): return list(map(int, sys.stdin.readline().strip().split()))
def get_ints(): return map(int, sys.stdin.readline().strip().split())
def input(): return sys.stdin.readline().strip()
x=int(input())
if x>=400 and x<=599:
    print(8)
elif x>=600 and x<=799:
    print(7)
elif x>=800 and x<=999:
    print(6)
elif x>=1000 and x<=1199:
    print(5)
elif x>=1200 and x<=1399:
    print(4)
elif x>=1400 and x<=1599:
    print(3)
elif x>=1600 and x<=1799:
    print(2)
else:
    print(1)

Measured memory_bytes: 62008
//CLMN
//Every cloud has a silver lining
//Hakuna matata

#include <bits/stdc++.h>

using namespace std;

typedef pair<int, int> ii;

#define fi first
#define se second
#define pb push_back
#define sqr(x) ((x) * (x))

const char *fin = "";
const char *fon = "";

#define oo (int) (1e9+7)
#define maxn (int) (1e5+5)
#define maxm (int) (5e5+5)

struct Point {
    int id, x, y;
    void read(int i) {
        id = i;
        cin >> x >> y;
    }
};

struct Edge {
    int u, v, w;
    void create(int _u, int _v, int _w) {
        u = _u; v = _v; w = _w;
    }
};

int lab[maxn];
Point p[maxn];
Edge e[maxm];
int n, m, cnt;
long long res;

bool cmpX(Point a, Point b) {
    return a.x < b.x;
}

bool cmp(Edge a, Edge b) {
    return a.w < b.w;
}

int find_set(int u) {
    if (lab[u] < 0) return u;
    lab[u] = find_set(lab[u]);
    return lab[u];
}

void unite(int r1, int r2, int w) {
    if (r1 == r2) return;

    ++cnt;
    res += 1ll * w;

    if (lab[r1] > lab[r2]) swap(r1, r2);
    lab[r1] = lab[r1] + lab[r2];
    lab[r2] = r1;
}

void findMST() {
    sort(e + 1, e + m + 1, cmp);
    memset(lab, -1, sizeof(lab));
    cnt = 0;
    for(int i = 1; i <= m; ++i) {
        if (cnt == n - 1) break;
        int u = e[i].u, v = e[i].v;
        unite(find_set(u), find_set(v), e[i].w);
    }
}

void createEdge() {
    for(int i = 1; i < n; ++i)
        e[++m].create(p[i].id, p[i + 1].id, abs(p[i].x - p[i + 1].x));
}

void sol() {
    sort(p + 1, p + n + 1, cmpX);
    createEdge();
    for(int i = 1; i <= n; ++i) swap(p[i].x, p[i].y);
    sort(p + 1, p + n + 1, cmpX);
    createEdge();
    findMST();
    cout << res;
}

void inp() {
    cin >> n;
    for(int i = 1; i <= n; ++i) p[i].read(i);
    sol();
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
   // freopen(fin, "r", stdin); freopen(fon, "w", stdout);
    inp();
    return 0;
}


Measured memory_bytes: 7680
/*
   ~~~~~~~~~~~~~~~~~~~
   \  |\/| | |\ | |  /
   /  |  | | |/ |_|  \
   ~~~~~~~~~~~~~~~~~~~
*/
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string.h>
#include<algorithm>
#define mp make_pair
#define sp setprecision
typedef long long ll;
#define vll vector<ll>
using namespace std;
/*ll xm(ll n)
{
	ll count=0,i;
	for(i=1;i<sqrt(n);i++){
		if(n%i==0) count+=2;
	}
	if(n/i==i) count++;
	return count;
}*/
int main()
{	
	ll n,cnt=0,x;
	cin>>n;
	for(ll i=1;i<=n;i++){
		x=n/i;
		cnt+=i*x*(x+1)/2;
	}
	cout<<cnt<<endl;
	return 0;
}

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

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const int MOD = 1000000007;
//const int MOD = 998244353;

// Lib
//

int N;
vector<long long> x, y;

int solve() {
    if (N == 1) return 1;

    int res = N;
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            if (i == j) continue;
            long long dx = x[j] - x[i], dy = y[j] - y[i];

            int sub = 0;
            for (int i2 = 0; i2 < N; ++i2) {
                for (int j2 = 0; j2 < N; ++j2) {
                    if (j2 == i2) continue;
                    if (dx == x[j2] - x[i2] && dy == y[j2] - y[i2]) ++sub;
                }
            }
            res = min(res, N - sub);
        }
    }
    return res;
}

int main(){
#ifdef MYLOCAL
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());
#endif
    cin >> N;
    x.resize(N); y.resize(N);
    for (int i = 0; i < N; ++i) cin >> x[i] >> y[i];
    cout << solve() << endl;
    return 0;
}


Measured memory_bytes: 256
use std::io::stdin;
use std::iter::Iterator;
use std::collections::VecDeque;

fn solve(cin: &mut ConsoleInputWrapper) {
    let n: f64 = cin.input().parse().unwrap();
    println!("{}", (n / 2f64).ceil() / n);
}

fn main() {
    let mut cin = ConsoleInputWrapper::new();
    solve(&mut cin);
}

fn min(a: i32, b: i32) -> i32 {
    if a < b { a } else { b }
}

fn max(a: i32, b: i32) -> i32 {
    if a > b { a } else { b }
}

fn split(h: i32, w: i32) -> i32 {
    let mut vec = Vec::new();
    if h > 1 {
        vec.push((h - h / 2) * w);
    }
    if w > 1 {
        vec.push((w - w / 2) * h);
    }
    match vec.iter().min() {
        Some(m) => m.clone(),
        None => i32::max_value()
    }
}

fn split2(h: i32, w: i32) -> i32 {
    let mut vec = Vec::new();
    if h > 1 {
        vec.push((h / 2) * w);
    }
    if w > 1 {
        vec.push((w / 2) * h);
    }
    match vec.iter().max() {
        Some(m) => m.clone(),
        None => i32::min_value()
    }
}

struct ConsoleInputWrapper {
    queue: VecDeque<String>
}

impl ConsoleInputWrapper {
    fn new() -> ConsoleInputWrapper {
        ConsoleInputWrapper {
            queue: VecDeque::new()
        }
    }
    fn input(&mut self) -> String {
        if self.queue.len() <= 0 {
            let mut s = String::new();
            stdin().read_line(&mut s).unwrap();
            let list: Vec<&str> = s.split_whitespace().collect();
            for string in list {
                self.queue.push_back(String::from(string));
            }
        }
        self.queue.pop_front().unwrap()
    }
}

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

int N(string d) {
	int s = 0;
	map<char, int>a;
	a['m'] = 1000;
	a['c'] = 100;
	a['x'] = 10;
	a['i'] = 1;
	for (int b = 0; b < d.length(); b++) {
		if (d[b] > '9' || d[b] < '0') {
			if (b == 0 || (d[b-1] > '9' || d[b-1] < '0'))s += a[d[b]];
			else s += a[d[b]] * (d[b-1] - 48);
		}
	}
	return s;
}
void write(int a) {
	map<int, char>c;
	c[1000] = 'm';
	c[100] = 'c';
	c[10] = 'x';
	c[1] = 'i';
	for (int b = 1000; b != 0; b /= 10) {
		switch (a / b) {
		case 0:break;
		case 1:cout << c[b]; break;
		default:cout << a / b << c[b]; break;
		}
		a -= b*(a / b);
	}
	cout << endl;
}
int main() {
	int b;
	cin >> b;
	for (int c = 0; c < b; c++) {
		string d, e;
		cin >> d >> e;
		write(N(d)+N(e));
	}
}

Measured memory_bytes: 3052