akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;

int n;

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> n;
	for (int i = 1; i <= 200; i *= 2) {
		if (i > n) {
			cout << i/2 << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let s = get!(String);
    let mut t = Vec::new();
    for (i, c) in s.chars().enumerate() {
        if i%2 == 0 {
            t.push(c);
        }
    }
    println!("{}", t.into_iter().collect::<String>());
}

Measured memory_bytes: 2328
H,W = map(int, input().split())
N = int(input())
A = [int(a) for a in input().split()]

ans = [[-1]*W for _ in range(H)]
i = 0
j = 0
cnt = 0
for k in range(N):
    for _ in range(A[k]):
        if (j == 0 and i%2 == 1) or (j == W-1 and i%2 == 0):
            ans[i][j] = k+1
            cnt += 1
            i += 1
            continue
        if cnt == H*W:
            break
        ans[i][j] = k+1
        cnt += 1
        if i%2 == 0:
            j += 1
        else:
            j -= 1
            
for i in range(H):
    ans[i] = map(str, ans[i])
    print(" ".join(ans[i]))

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

int main() {
  string s;
  cin >> s;
  int count = 0;
  if(s[0]=='1'){ count += 1; }
  if(s[1]=='1'){ count += 1; }
  if(s[2]=='1'){ count += 1; }
  cout << count << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
string s;

int getarea(int a,int b){
  int res=0,h=0;
  stack<P> st;
  for(int i=a;i<=b;i++){
    if(s[i]=='\\')st.push(P(h,i)),h--;
    if(s[i]=='/'){
      h++;
      if(!st.size())continue;
      P t=st.top();
      if(t.first==h)res+=i-t.second,st.pop();
    }
  }
  return res;
}

int check(int x){
  int h=0;
  for(int i=x;i<s.size();i++){
    if(s[i]=='\\')h--;
    if(s[i]=='/'){
      h++;
      if(!h)return i;
    }
  }
  return -1;
}

int main(){
  int h=0,ans=0;
  vector<int> v;
  cin>>s;
  for(int i=0;i<s.size();i++)
    if(s[i]=='\\'){
      int r=check(i);
      if(r>=0){
	int area=getarea(i,r);
	v.push_back(area);
	ans+=area,i=r-1;
      }
    }
  cout<<ans<<endl;
  cout<<v.size();
  if(v.size())cout<<' ';
  for(int i=0;i<v.size();i++){
    if(i)cout<<' ';
    cout<<v[i];
  }
  cout<<endl;
  return 0;
}

Measured memory_bytes: 1268
#include "bits/stdc++.h"
using namespace std;

int main(){
    int a,b,c;
    cin>> a>>b>>c;
  	int out;
  	if(c<=a+b+1){
      out = b+c;
    }else{
      out = a+b*2+1;
    }
  	cout<< out<<"\n";
    return(0);
}

Measured memory_bytes: 256
A, B, C, X, Y = map(int, input().split())

minp = A * X + B * Y
for i in range (1, 100001):
    p = 2 * C * i + A * max(0, X - i) + B * max(0, Y - i)
    if p < minp:
        minp = p
print(minp)

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

using namespace std;

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

const int d = 1 << 19;
vector<ll> t(d << 1);

void add(int i, ll x) {
    i += d;
    t[i] = x;
    for (i >>= 1; i > 0; i >>= 1) {
        t[i] = max(t[i << 1], t[i << 1 | 1]);
    }
}

ll get_max(int u, int l, int r, int a, int b) {
    if (r < a || b < l) return 0;
    if (a <= l && r <= b) return t[u];

    return max(get_max(u << 1, l, (l + r) / 2, a, b),
               get_max(u << 1 | 1, (l + r) / 2 + 1, r, a, b));
}

ll get_max(int l, int r) {
    return get_max(1, d, 2 * d - 1, l + d, r + d);
}

void solve() {
    int n;
    cin >> n;
    vector<int> h(n), a(n);
    for (auto &e : h) cin >> e;
    for (auto &e : h) e--;
    for (auto &e : a) cin >> e;

    for (int i = 0; i < n; i++) {
        add(h[i], get_max(0, h[i]) + a[i]);
    }

    cout << get_max(0, n - 1);
}

int main() {
    cout << fixed << setprecision(20);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int t = 1;
    // cin >> t;
    while (t--) solve();

    return 0;
}


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

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

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin>>n;
  vector<int>city(n);
  rep(i,n)cin>>city[i];
  int l,q;
  cin>>l>>q;
  int nl=n,c=0;
  while(nl>0){c++;nl/=2;}
  vector<vector<int>>db(n,vector<int>(c,n));
  int r=0;
  rep(i,n)
  {
    while(r+1<n&&city[r+1]<=city[i]+l)r++;
    db[i][0]=r;
  }
  rep(i,c-1)
  {
    rep(j,n)
    {
      db[j][i+1]=db[db[j][i]][i];
    }
  }
  rep(i,q)
  {
    int a,b;
    cin>>a>>b;
    a--;b--;
    if(a>b)swap(a,b);
    int cnt=0;
    while(1)
    {
      auto itr=lower_bound(all(db[a]),b);
      if(itr==db[a].begin()){cnt++;break;}
      cnt+=(1<<(itr-db[a].begin()-1));
      a=*(itr-1);
    }
    cout<<cnt<<"\n";

  }
  cout<<flush;


  return 0;

}


Measured memory_bytes: 11392
#include<iostream>
#include <string>
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#define ll long long int
#define ld long double
#define pb push_back
#define endl "\n"
#define mp make_pair
#define sz(v) (int)(v.size())
#define len(s) (int)(s.length())
#define M 1000000007
#define all(v) v.begin(),v.end()
#define fr(a,b,c) for(ll i=a;i<=b;i+=c)
#define inarr(arr,n); for(ll i=0;i<n;i++) cin >> arr[i];
#define outarr(arr,n); for(ll i=0;i<n;i++) cout<<arr[i]<<" ";
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
const ll inf = 9e18;
const ld pi = 2*acos(0.0); 
using namespace std;
ll power(ll a,ll n) 
{
    if(n==0){
        return 1;
    }
    ll p=power(a,n/2) % M;
    p = (p * p) % M;
    if (n%2==1)
    {
        p=(p*a)%M;
    }
    return p;
}
ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
}
const int N=1e6;
vector <ll> sieve(N,0); 
void si() 
{
    sieve[1]=1;
    for(int i=2;i<N;i++){
        if(sieve[i]==0){
            for(int j=i;j<N;j+=i){
                sieve[j]=i;
            }
        }
    }
}
int main(){
    ios;
    int n;
    cin>>n;
    vector <ll> a(n);
    inarr(a,n);
    ll ans=0;
    ll maxi=0;
    for(int i=0;i<n;i++){
        maxi=max(maxi,a[i]);
        ans+=maxi-a[i];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 12624
#include "bits/stdc++.h"
#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>>
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
typedef long long ll;
const int inf = 1000000001;
const ll INF = 1e18 * 4;
using namespace std;

int main(){
    ll N,M,K,tmp,pep,ans=0;
    cin>>N>>K;
    int ret[N]={0};
    rep(i,0,K){
        cin>>tmp;
        rep(j,0,tmp){
            cin>>pep;
            ret[pep-1]++;
        }
    }
    rep(i,0,N){
        if(ret[i]==0)
            ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3636
#include<stdio.h>
int main(void)
{
	int a,b,c,e,f;
	e=0;
	scanf("%d", &a);
	int d[a];
	for(b=0; b<a; b++){
		scanf("%d", &d[b]);
		}
	for(f=0; f<a; f++){
	for(b=a-1; b>=f; b--){
		if(d[b]<d[b-1])
		{
			c=d[b];
			d[b]=d[b-1];
			d[b-1]=c;
			e++;
		}
	}
	}
		for(b=0; b<a; b++){
			printf("%d", d[b]);
			if(b==a-1){break;}
			printf(" ");
		}
		printf("\n");
		printf("%d\n",e);
		return 0;
}


Measured memory_bytes: 2092
fn main() {
    proconio::input! {
        n: usize,
    }
    // a * b + c = n
    // n - c = a * b
    // a * b が n より小さい組み合わせの数
    let mut count = 0usize;
    for a in 1..n {
        let b = (n - 1) / a;
        count += b;
    }
    println!("{}", count);
}


Measured memory_bytes: 2144
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
typedef pair<int,int> pi;
typedef long long ll;

const int N = 1000005;

int n,deg[N],mxNode,mxCost,pr[N];
vector<int> g[N];

void dfs(int u , int p,int dist){
	if(dist>mxCost){
		mxCost = dist;
		mxNode = u;
	}
	pr[u] = p;
	for(auto v : g[u]){
		if(v==p)continue;
		dfs(v,u,dist+1);
	}
}
vector<int> ans;
void append(vector<int> cur){
	for (int i = 0; i < cur.size(); ++i)
		ans.pb(cur[i]);
}
int main(){
	cin >> n;
	for(int u,v,i = 0 ; i < n-1 ; ++i){
		scanf("%d%d",&u,&v);
		g[u].pb(v);
		g[v].pb(u);
	}
	mxNode = mxCost = -1;
	dfs(1,-1,0);
	mxCost = -1;
	dfs(mxNode,-1,0);
	vector<int> all;
	while(1){
		all.push_back(mxNode);
		mxNode = pr[mxNode];
		if(mxNode == -1)break;
	}
	int res = 0;
	for (int i = 0; i < all.size(); ++i){
		deg[all[i]] = g[all[i]].size();
		if(i>0)deg[all[i]]--;
		if(i+1<all.size())deg[all[i]]--;
		res += deg[all[i]]+1;
	}
	if(res != n){
		puts("-1");
		return 0;
	}
	vector<int> fn;
	for(int it = 0 ; it < 2 ; ++it){
		reverse(all.begin(),all.end());
		ans.clear();
		int cnt = n;
		for(int i = 0 ; i < all.size();++i){
			int need = deg[all[i]];
			vector<int> cur;
			for(int j = 0 ; j < need;++j)cur.pb(cnt--);
			reverse(cur.begin(),cur.end());
			cur.push_back(cnt--);
			reverse(cur.begin(),cur.end());
			append(cur);
		}
		reverse(ans.begin(),ans.end());
		if(!it)fn = ans;
		if(it)fn = min(fn,ans);
	}
	for (int i = 0; i < fn.size(); ++i){
		if(i)printf(" ");
		printf("%d",fn[i]);
	}
	puts("");
	return 0;
}

Measured memory_bytes: 36600
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    private const int INF = 1000000007;
    private struct Pair { public long x, y; public Pair(long x, long y) { this.x = x; this.y = y; } }
    public static void Solve()
    {
        int N = NextInt();
        int[] W = LineInt();
        int all = W.Sum();
        int ans = INF;
        for (int i = 1; i < N; i++)
        {
            int S1 = W.Take(i).Sum();
            int S2 = all - S1;
            ans = Math.Min(ans, Math.Abs(S1 - S2));
        }
        Console.WriteLine(ans);
    }
    public static void Main()
    {
        var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        Solve();
        Console.Out.Flush();
    }
}
public class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static char NextChar() { Confirm(); return char.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


Measured memory_bytes: 13524
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<long long,long long> Pll;
#define fout(num) cout << fixed << setprecision(20) << (num) << endl
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ
//vector<vector<ll>> dp(n,vector<ll>(n))
//exist x map o set

signed main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    ll w,h; cin >> w >> h;
    vector<ll> p(w),q(h);
    ll score=0;
    rep(i,w){
        cin >> p[i];
        score+=p[i];
    }
    score*=(h+1);
    rep(i,h) cin >> q[i];
    sort(ALL(q));
    ll sum[h+1];
    sum[0]=0;
    rep(i,h) sum[i+1]=sum[i]+q[i];
    score+=sum[h];
    rep(i,w){
        ll x=upper_bound(ALL(q),p[i])-q.begin();
        score+=sum[x];
        score-=x*p[i];
    }
    cout << score  << endl;
}


Measured memory_bytes: 5556
import java.util.Scanner;

/**
 * Sort
 */
public class Main {

    public int size;
    public int[] mx;

    public void scan() {
        Scanner sc = new Scanner(System.in);
        this.size = sc.nextInt();
        this.mx = new int[this.size];
        for (int i = 0; i < this.size; i++) {
            this.mx[i] = sc.nextInt();
        }
    }

    public void go() {
        for (int i = 1; i < this.size; i++) {
            this.print();
            int v = this.mx[i];
            int j = i - 1;
            while (j >= 0 && this.mx[j] > v) {
                this.mx[j + 1] = this.mx[j];
                j--;
            }
            this.mx[j + 1] = v;
        }
        this.print();
    }

    public void print() {
        for (int i = 0; i < this.size; i++) {
            System.out.print(this.mx[i]);
            if (i == this.size - 1) {
                System.out.println();
            } else {
                System.out.print(" ");
            }
        }
    }

    public static void main(String[] args) {
        Main sort = new Main();
        sort.scan();
        sort.go();
    }
}


Measured memory_bytes: 34136
using System;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.IO;

namespace SolutionCS
{
    class Program
    {
        struct Elem
        {
            public int timeToNext;
            public int timeStart;
            public int timePeriod;
        }

        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());

            N--;
            Elem[] e = new Elem[N];

            for (int i = 0; i < N; i++)
            {
                string[] s = Console.ReadLine().Split(' ');
                e[i].timeToNext = int.Parse(s[0]);
                e[i].timeStart = int.Parse(s[1]);
                e[i].timePeriod = int.Parse(s[2]);
            }

            for(int s = 0; s < N; s++)
            {
                int ans = 0;
                for (int i = s; i < N; i++)
                {
                    // 発射前についてしまう場合、この駅の発車時刻で出発
                    if ( ans <= e[i].timeStart)
                    {
                        ans = e[i].timeStart;
                    }
                    else
                    {
                        int next = ans - e[i].timeStart;
                        int mul = (next + e[i].timePeriod - 1) / e[i].timePeriod;
                        ans = e[i].timeStart + e[i].timePeriod * mul;
                    }

                    ans += +e[i].timeToNext;
                }

                Console.WriteLine(ans);
            }

            Console.WriteLine(0);
        }
    }
}


Measured memory_bytes: 11092
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<queue>
#include<functional>
#include<map>
#include<set>
using namespace std;
//#define int long long
typedef pair<int, int> pii;
typedef priority_queue<pii, vector<pii>, greater<pii> > RPQ;
#define mk make_pair
#define INF (1 << 30)
#define INFL (1ll << 60ll)
#define mod 1000000007

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

signed main(){
    int a, b;
    cin >> a >> b;
    cout << gcd(a, b) << endl;


    return 0;
}

/*

*/


Measured memory_bytes: 3092
function AA(){
   for(var i=1;i<arr.length-1;i++){
      if(arr[i]==0){arr[i]="A";return;}
   }
}
function BB(){
   for(var i=arr.length-2;i>=1;i--){
      if(arr[i-1]!="A" && arr[i]==0 && arr[i+1]!="A"){arr[i]="B";return;}
   }
   for(var i=1;i<arr.length-1;i++){
      if(arr[i]==0){arr[i]="B";return;}
   }
}
function CC(){
   for(var i=1;i<arr.length-1;i++){
      if(arr[i]!=0 && arr[i+1]==0){arr[i+1]="C";return;}
      if(arr[i]!=0 && arr[i-1]==0){arr[i-1]="C";return;}
   }
   if(n%2==1)arr[(n-1)/2+1]="C";
   if(n%2!=1)arr[n/2+1]="C";
}
function DD(){
   var max=[0,0];
   for(var i=1;i<arr.length-1;i++){
      if(arr[i]!=0)continue;
      var jA=i;
      var jB=i;
      var cnt=0;
      while(true){
         if(arr[jA]!="X")jA--;
         if(arr[jB]!="X")jB++;
         if(arr[jA]=="X" && arr[jB]=="X")break;
         if(arr[jA]!="X" && arr[jA]!=0)break;
         if(arr[jB]!="X" && arr[jB]!=0)break;
         cnt++;
         if(max[1]<cnt)max=[i,cnt];
      }
   }
   if(max[1]!=0){arr[max[0]]="D";return;}
   for(var i=1;i<arr.length-1;i++){
      if(arr[i]==0){arr[i]="D";return;}
   }
}
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=input.trim().split("\n");
while(true){
   var nm=Arr.shift().split(" ").map(Number);
   var n=nm[0];
   var m=nm[1];
   if(n==0 && m==0)break;
   var arr=[];
   for(var i=0;i<n;i++)arr.push(0);
   arr.unshift("X");
   arr.push("X");
   for(var i=0;i<m;i++){
      var v=Arr.shift();
      if(v=="A")AA();
      if(v=="B")BB();
      if(v=="C")CC();
      if(v=="D")DD();
   }
   arr.shift();
   arr.pop();
   console.log(arr.join("").replace(/0/g,"#"));
}

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

using ll    = long long;
using ull   = unsigned long long;
using veci  = vector<int>;
using vecll = vector<ll>;
#define EPS (1e-7)
#define INF (1e9)
#define PI  (acos(-1))
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define REP(i,n) for(int i= 0;i<(int)(n);++i)
#define pb push_back

veci enum_div(int n){
	veci ret;
	ret.pb(1);
	for(int i=1;i*i<n;i++){
		if(n%i==0){
			ret.pb(i);
			if(i != n/i){ret.pb(n/i);}
		}
	}
	ret.pb(n);
	return ret;
}
int gcb(int a,int b){return ((b == 0)? a : gcb(b,a%b));}
int gcd(int a,int b){return (a*b) / gcb(a,b);}

int main(){
    int n,m;
    cin >> n >> m;
    cout << (n-1)*(m-1) <<endl;
	return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

typedef long long ll;

#define rep(i, a, n) for (ll i = a; i < (ll)n; ++i)
#define INF 10e12
#define MOD 1000000000 + 7
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))

using namespace std;

int main(void)
{
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int n;
    string s;
    cin >> n >> s;
    rep(i, 0, s.size()) cout << char('A' + (s[i] - 'A' + n) % 26);
    cout << endl;
}

Measured memory_bytes: 3652
#include <iostream>

using namespace std;

int main(){
    long long N, H, W;
    cin >> N >> H >> W;
    long long ans = 0;
    for(int i = 0; i < N; ++i){
        long long A, B;
        cin >> A >> B;
        if(A >= H && B >= W) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define rp(a) while(a--)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main(){
	int n;
	cin>>n;
	string tmp;
	getline(cin,tmp);
	while(n--){
		getline(cin,tmp);		
		rep(a,10000){
			bool h=false;
			rep(b,26){
				string s=tmp;
					rep(k,s.size())if(isalpha(s[k]))s[k]=(a*(s[k]-'a')+b)%26+'a';
				if(s.find("this")!=string::npos||s.find("that")!=string::npos){
					cout<<s<<endl;
					h=true;break;
				}
				if(h)break;
			}
			if(h)break;
		}
	}
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define pb push_back
#define ff first
#define ss second
#define endl '\n'
#define fast ios::sync_with_stdio(false); cin.tie(NULL);
const double eps = 1e-6;

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

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

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

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

#define int long long

void solve(){

	int n , k;
	cin>>n>>k;
	double a[n];
	for(int i = 0 ; i < n;  ++i){

		cin>>a[i];

		double val = a[i]*(a[i]+1.00)/2.00;

		val/=a[i];
		a[i] = val;

		if(i)
			a[i] += a[i-1];
	}

	double ans = a[k-1];

	for(int i = k ; i < n; ++i){

		ans = max(ans , a[i] - a[i-k]);
	}

	cout<<fixed<<setprecision(10)<<ans<<endl;
}


signed main(){

    fast;
    int t = 1;
    //cin>>t;
    for(int i = 1 ; i <= t; ++i){

    	solve();
    }
}




Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define int long long
int inf=1e18;

struct edge{
	int to,cst;
	edge(){};
	edge(int _to,int _cst){
	to=_to;cst=_cst;
    };
};

vector<vector<edge>> g;
vector<int> d;

void add_edge(int a,int b,int c){
	g[a].push_back(edge(b,c));
	g[b].push_back(edge(a,c));
};



void calc_d(int cur,int pre){
	for(auto&& w:g[cur]){
		if(w.to!=pre){
			d[w.to]=d[cur]+w.cst;
				calc_d(w.to,cur);
		}
    }
};

signed main(){
	int n;cin>>n;
	g.resize(n);
	for(int i=0;i<n-1;i++){
		int a,b,c;cin>>a>>b>>c;a--;b--;
		add_edge(a,b,c);
	}
	for(int i=0;i<n;i++){
	cerr<<i+1<<" ";
	for(auto&& w:g[i])cerr<<w.to+1<<" ";
    cerr<<endl;
	}
	cerr<<endl;

	int q,k;cin>>q>>k;k--;
	d.resize(n,-1);
	d[k]=0;
	calc_d(k,-1);
	for(auto&& w:d)cerr<<w<<" "<<endl;
	cerr<<endl;
	for(int i=0;i<q;i++){
		int x,y;cin>>x>>y;x--;y--;
		cout<<d[x]+d[y]<<endl;
	}	
}

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

int main() {
  int n,m;
  cin>>n>>m;
  vector<int> x(m);
  for (size_t i = 0; i < m; i++) {
    cin>>x[i];
  }
  if(n>=m){
    cout<<0;
    return 0;
  }
  sort(x.begin(),x.end());
  vector<int> y(m-1);
  for (size_t i = 0; i < m-1; i++) {
    y[i]=x[i+1]-x[i];
  }
  sort(y.begin(),y.end());
  int sum = 0;
  for (size_t i = 0; i < m-n; i++) {
    sum+=y[i];
  }
  cout<<sum;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
map<int,vector<int>>mp;
vector<int>dp;
int calcpath(int v)
{
  if(mp[v].size()==0)
    return 0;
  if(dp[v]!=-1)
    return dp[v];
  int ans=0;
  for(int i=0;i<mp[v].size();i++){
    int x=calcpath(mp[v][i]);
    ans=max(ans,x);
  }
  return dp[v]=1+ans;
}
int main()
{
  int v,e;
  cin>>v>>e;
  dp.resize(v+1,-1);
  for(int i=0;i<e;i++){
    int x,y;
    cin>>x>>y;
    mp[x].push_back(y);
  }
  int ans=0;
  for(int i=1;i<=v;i++){
  	int x=calcpath(i);
  	ans=max(ans,x);
  }
  cout<<ans;
  return 0;
}

Measured memory_bytes: 19216
#include <iostream>
#include <string>
using namespace std;
int main(){
  string s,t;
  cin >> s >> t;
  for(int i=0;i<s.size();i++){
    cout << s[i];
    if(i<t.size())cout << t[i];
  }
  cout << endl;
  return 0;
}

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

int main(){
    string s;
    cin >> s;
    ll ans = 0;
    vector<ll> a(s.size()+1),b(s.size()+1);
    rep(i,s.size()){
        if(s[i] == '<')a[i+1] = a[i]+1;
    }
    for(int i = s.size()-1;i >= 0;i--){
        if(s[i] == '>')b[i] = b[i+1]+1;
    }
    for(int i = 0;i<= s.size();i++) ans += max(a[i],b[i]);
    cout << ans << endl;
}


Measured memory_bytes: 8708
#include <bits/stdc++.h>
using namespace std;
namespace modular_space {
	long long mod;
	struct umod {
		long long val;
		umod(): val(0ll){}
		umod(long long x){ x %= mod; if(x < 0) x += mod; val = x; }
		umod& operator += (umod oth){ val += oth.val; if(val >= mod) val -= mod; return *this; }
		umod& operator -= (umod oth){ val -= oth.val; if(val < 0) val += mod; return *this; }
		umod& operator *= (umod oth){ val = val * oth.val % mod; return *this; }
		umod& operator /= (umod oth){ return *this *= oth.inverse(); }
		umod& operator ^= (long long oth){ return *this = pwr(*this, oth); }
		umod operator + (umod oth) const { return umod(*this) += oth; }
	       	umod operator - (umod oth) const { return umod(*this) -= oth; }
		umod operator * (umod oth) const { return umod(*this) *= oth; }
		umod operator / (umod oth) const { return umod(*this) /= oth; }
		umod operator ^ (long long oth) const { return umod(*this) ^= oth; }
		bool operator < (umod oth) const { return val < oth.val; }
		bool operator > (umod oth) const { return val > oth.val; }
		bool operator <= (umod oth) const { return val <= oth.val; }
		bool operator >= (umod oth) const { return val >= oth.val; }
		bool operator == (umod oth) const { return val == oth.val; }
		bool operator != (umod oth) const { return val != oth.val; }
		umod pwr(umod a, long long b) const {
			umod r = 1;
			for(; b; a *= a, b >>= 1)
				if(b&1)
					r *= a;
			return r;
		}
		umod inverse() const {
			long long a = val, b = mod, u = 1, v = 0;
			while(b){
				long long t = a/b;
				a -= t * b; swap(a, b);
				u -= t * v; swap(u, v);
			}
			if(u < 0)
				u += mod;
			return u;
		}
		friend istream& operator >> (istream &is, umod &oth);
		friend ostream& operator << (ostream &os, const umod& oth);
	};
	ostream& operator << (ostream &os, const umod &oth){
		os << oth.val;
		return os;
	}
	istream& operator >> (istream &is, umod &oth){
		long long x; is >> x;
		oth = umod(x);
		return is;
	}
	struct binprime_kit {
		int sz;
		vector<umod> fat, ifat;
		void init(int s){
			sz = s;
			fat.resize(sz + 1);
			ifat.resize(sz + 1);
			fat[0] = 1;
			for(int i = 1; i <= sz; i++) fat[i] = fat[i - 1] * i;
			ifat[sz] = fat[sz] ^ (mod - 2);
			for(int i = sz - 1; i >= 0; i--) ifat[i] = ifat[i + 1] * (i + 1);
		}
		umod coef(int n, int r){
			if(n < r) return 0;
			return fat[n] * (ifat[r] * ifat[n - r]);
		}
	};
};
using U = modular_space::umod;
const int maxn = 2020;
U f[maxn][maxn];
int main(){
	modular_space::mod = 1'000'000'007;
	modular_space::binprime_kit kit; kit.init(maxn * maxn);
	int n, k; cin >> n >> k;
	if(k == 1) cout << 1 << endl;
	else {
		f[0][0] = 1;
		for(int i = 0; i <= n; i++){
			for(int j = 0; j <= i; j++){
				int empty = n - i + (n - j) * (k - 1) - 2;
				if(f[i][j].val){
					f[i + (i == j)][j + 1] += f[i][j] * kit.coef(empty, k - 2);
					f[i + 1][j] += f[i][j];
				}
			}
		}
		cout << f[n][n] * kit.fat[n] << endl;
	}
	return 0;
}


Measured memory_bytes: 95872
import math

n = int(input())
given_lst = sorted(list(map(int,input().split())))
max_num = max(given_lst)
lst_status = [1 for _ in range(max_num+1)]


prev_e = -99999
for e in given_lst:
    if prev_e == e:
        lst_status[e] = 0
    divided_num = e + e
    while(divided_num <= max_num):
        lst_status[divided_num] = 0
        divided_num += e

    prev_e = e

ans = 0
for e in given_lst:
    if lst_status[e] == 1:
        ans += 1

print(ans)



Measured memory_bytes: 33116
length, width = map(int, input().split())
Maze = [list(input()) for _ in range(length)]

def bfs(i, j):
    t = [[-1] * width for _ in range(length)]
    t[i][j] = 0
    stack = [(i, j)]
    while(stack):
        x, y = stack.pop(0)
        if x - 1 >= 0 and Maze[x - 1][y] != '#' and t[x-1][y] == -1:
            t[x-1][y] = t[x][y] + 1
            stack.append((x-1, y))
        if x + 1 < length and Maze[x + 1][y] != '#' and t[x + 1][y] == -1:
            t[x + 1][y] = t[x][y] + 1
            stack.append((x+1, y))
        if y - 1 >= 0 and Maze[x][y-1] != '#' and t[x][y-1] == -1:
            t[x][y-1] = t[x][y] + 1
            stack.append((x, y-1))
        if y + 1 < width and Maze[x][y+1] != '#' and t[x][y+1] == -1:
            t[x][y+1] = t[x][y] + 1
            stack.append((x, y+1))
    return max(max(answer) for answer in t)
answer = 0

for i in range(length):
    for j in range(width):
        if Maze[i][j] != '#':
            answer = max(answer, bfs(i,j))

print(answer)

Measured memory_bytes: 3188
n,m=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
k=sum(a)/(4*m)
s=0
for i in range(m):
    if a[-i-1]>=k:
        pass
    else:
        s=1
        break
if s==1:
    print("No")
else:
    print("Yes")

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

// https://ei1333.github.io/luzhiled/snippets/graph/dinic.html
template< typename flow_t >
struct Dinic {
  const flow_t INF;

  struct edge {
    int to;
    flow_t cap;
    int rev;
    bool isrev;
  };

  vector< vector< edge > > graph;
  vector< int > min_cost, iter;

  Dinic(int V) : INF(numeric_limits< flow_t >::max()), graph(V) {}

  void add_edge(int from, int to, flow_t cap) {
    graph[from].emplace_back((edge) {to, cap, (int) graph[to].size(), false});
    graph[to].emplace_back((edge) {from, 0, (int) graph[from].size() - 1, true});
  }

  bool bfs(int s, int t) {
    min_cost.assign(graph.size(), -1);
    queue< int > que;
    min_cost[s] = 0;
    que.push(s);
    while(!que.empty() && min_cost[t] == -1) {
      int p = que.front();
      que.pop();
      for(auto &e : graph[p]) {
        if(e.cap > 0 && min_cost[e.to] == -1) {
          min_cost[e.to] = min_cost[p] + 1;
          que.push(e.to);
        }
      }
    }
    return min_cost[t] != -1;
  }

  flow_t dfs(int idx, const int t, flow_t flow) {
    if(idx == t) return flow;
    for(int &i = iter[idx]; i < graph[idx].size(); i++) {
      edge &e = graph[idx][i];
      if(e.cap > 0 && min_cost[idx] < min_cost[e.to]) {
        flow_t d = dfs(e.to, t, min(flow, e.cap));
        if(d > 0) {
          e.cap -= d;
          graph[e.to][e.rev].cap += d;
          return d;
        }
      }
    }
    return 0;
  }

  flow_t max_flow(int s, int t) {
    flow_t flow = 0;
    while(bfs(s, t)) {
      iter.assign(graph.size(), 0);
      flow_t f = 0;
      while((f = dfs(s, t, INF)) > 0) flow += f;
    }
    return flow;
  }

  void output() {
    for(int i = 0; i < graph.size(); i++) {
      for(auto &e : graph[i]) {
        if(e.isrev) continue;
        auto &rev_e = graph[e.to][e.rev];
        cout << i << "->" << e.to << " (flow: " << rev_e.cap << "/" << e.cap + rev_e.cap << ")" << endl;
      }
    }
  }
};

int main()
{
    int H, W; cin >> H >> W;
    vector<string> A(H);
    for (auto &a : A) cin >> a;
    Dinic<int> graph(H*W*2);
    const int INF = 1e9;
    int S = -1, T = -1;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (A[i][j] == 'S') S = (i*W+j)*2;
            if (A[i][j] == 'T') T = (i*W+j)*2+1;
            if (A[i][j] != '.') {
                graph.add_edge((i*W+j)*2+1, (i*W+j)*2, 1);
                for (int k = 0; k < H; k++) {
                    if (i != k && A[k][j] != '.') {
                        graph.add_edge((i*W+j)*2, (k*W+j)*2+1, INF);
                    }
                }
                for (int k = 0; k < W; k++) {
                    if (j != k && A[i][k] != '.') {
                        graph.add_edge((i*W+j)*2, (i*W+k)*2+1, INF);
                    }
                }
            }
        }
    }
    int ans = graph.max_flow(S, T);
    cout << (ans >= INF ? -1 : ans) << '\n';
    return 0;
}


Measured memory_bytes: 83584
#include"bits/stdc++.h"
using namespace std;

template<typename T>
class UnionFind {
  public:
    vector<T> parent;

    UnionFind(T n) {
      parent = vector<T>(n, -1);
    }

    T root(T a) {
      if (parent[a] < 0) return a;
      else return parent[a] = root(parent[a]);
    }

    T size(T a) {
      return -parent[root(a)];
    }

    bool connect(T a, T b) {
      a = root(a);
      b = root(b);
      if (a == b) {
        return false;
      }

      if (size(a) < size(b)) swap(a, b);

      parent[a] += parent[b];
      parent[b] = a;
      return true;
    }
};

void Main() {
  int N, M;
  cin >> N >> M;

  UnionFind<int> u = UnionFind<int>(N);
  vector<int> r[N];
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    r[a - 1].push_back(b - 1);
    r[b - 1].push_back(a - 1);
    u.connect(a - 1, b - 1);
  }

  if (u.size(0) != N) cout << "No" << endl;
  else {
    cout << "Yes" << endl;
    vector<int> dst(N, -1);
    dst[0] = 0;
    queue<int> q;
    q.push(0);
    while (q.size()) {
      int room = q.front(); q.pop();
      for (auto n: r[room]) {
        if (dst[n] < 0) {
          q.push(n);
          dst[n] = room;
        }
      }
    }
    for (int i = 1; i < N; i++) {
      cout << dst[i] + 1 << endl;
    }
  }
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}



Measured memory_bytes: 10752
#include<stdio.h>
#include<iostream>
#include<string>
using namespace std;


int main() {


	string s;
	cin >> s;
	
	
	int l;
	int r;
	
	l = (s[0]-'0')*10 + s[1]-'0';
	r = (s[2]-'0')*10 + s[3]-'0';

	//YYMMのみ
	if ((l > 12  || l==0)&& r <= 12 && r >= 1)
		printf("YYMM\n");
	else if ((r > 12 || r==0) && l <= 12 && l >= 1)
		printf("MMYY\n");
	else if (l <= 12 && r <= 12 && l>=1 && r>=1)
		printf("AMBIGUOUS\n");
	else
		printf("NA\n");
	//
	

	
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rng(i, l, r) for (size_t i = (l); i < (r); ++i)
#define rep(i, n) rng(i, 0, n)
#define gnr(i, l, r) for (size_t i = (r)-1; i >= (l); i--)
#define per(i, b) gnr(i, 0, b)
#define ALL(obj) (obj).begin(), (obj).end()    //1,2,3,...
#define rALL(obj) (obj).rbegin(), (obj).rend() //...,3,2,1

using namespace std;

const int INF = 1e18;
void solve()
{

    // remove the bottom 3 lines when you submit this code.
    std::ifstream in("./sample.txt");
    std::cin.rdbuf(in.rdbuf());

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    int a[n];
    rep(i, n) cin >> a[i];

    int cost = INF;

    for (int i = -100; i <= 100; i++)
    {
        int costtmp = 0;
        for (int j = 0; j < n; j++)
        {
            costtmp += pow(a[j] - i, 2);
        }

        cost = min(cost, costtmp);
    }

    cout << cost << endl;
}

signed main()
{
    solve();
    return 0;
}


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

using namespace std;

#define intt long long
#define FAST ios_base::sync_with_stdio(0); cin.tie(0);

const int N = 200005;

int a[N], con[N];

int main() {

	FAST;

	int n;
	cin >> n;
	for (int i = 1; i <= n; i ++) {
		cin >> a[i];
	}
	sort(a + 1, a + n + 1);
	reverse(a + 1, a + n + 1);
	con[1] = 0;
	con[2] = a[1];
	for (int i = 3; i <= n; i ++) {
		con[i] = a[(i + 1) / 2];
	}
	intt ans = 0;
	for (int i = 1; i <= n; i ++) {
		ans += con[i];
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 5176
#include <bits/stdc++.h>
#include <cstdlib>  // abs() for integer 邨ｶ蟇ｾ蛟､豎ゅａ繧・▽
#include <cmath>    // abs() for float, and fabs()
#include <algorithm>
#include <vector>
#include <string>
#define rep(i,n) for(int i = 0; i < (n);i++)
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
using namespace std;
#define INF 2000000000
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
typedef long long ll;


int main(){
	ll n ; cin >> n;
	vector<ll> A(n+1);
	A[0]=0;
	ll ans = 0;
	for(int i = 1 ; i <= n; i ++){
		cin>>A[i];
	}			
	for(ll i =1 ; i<= n ; i++){
		ans+=(A[i]/2);
		if(A[i+1]!=0){
			A[i+1]+=A[i]%2;
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 1024
import sys
input=sys.stdin.readline
N,W=map(int,input().split())
w=[0]*N
v=[0]*N
for i in range(N):
    w[i],v[i]=map(int,input().split())
dp=[[0]*(W+1) for _ in range(N+1)]
for i in range(N):
    for j in range(W+1):
        if j>=w[i]:
            dp[i+1][j]=max(dp[i][j-w[i]]+v[i],dp[i][j])
        else:dp[i+1][j]=dp[i][j]

print(dp[N][W])

Measured memory_bytes: 120044
import java.io.IOException;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) throws IOException {
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int y = sc.nextInt();
    int z = sc.nextInt();
    int answer = (x-z) / (y+z);
    System.out.println(answer);
    }
  }


Measured memory_bytes: 25556
def main():
	n = int(input())

	for _ in range(n):
		len_list = map(int, input().split())
		check_tri(len_list)

def check_tri(len_list):
	import itertools
	import math

	flag = False
	for tmp in list(itertools.permutations(len_list)):
		if (pow(tmp[0], 2) + pow(tmp[1], 2)) == pow(tmp[2], 2):
			flag = True
			break

	if flag == True:
		print('YES')
	else:
		print('NO')

if __name__ == '__main__':
	main()

Measured memory_bytes: 7748
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <bitset>
#include <map>
#include <string>

#define repd(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;

int inputValue(){
	int a;
	cin >> a;
	return a;
}

void inputArray(int *p,int a){
	rep(i,a){
		cin >> p[i];
	}
}

void inputVector(vector<int> *p,int a){
	rep(i,a){
		int input;
		cin >> input;
		p -> push_back(input);
	}
}

template <typename T>
void output(T a,int precision){
	if(precision > 0){
		cout << setprecision(precision) << a << "\n";
	}else{
		cout << a << "\n";
	}
}

int main(){
	//source
	int n=inputValue();
	repd(i,n,1000){
		if(n<100){
			continue;
		}
		string n_str=to_string(i);
		if(n_str[0]==n_str[1] && n_str[0]==n_str[2]){
			cout << i << endl;
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <stdio.h>
using namespace std;
int main() {
	int N;
	cin >> N;
	int a[N];
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}
	int cnt = 0;
	for (int x = 0; x < N; x++) {
		bool c = true;
		for (int y = 0; y < x; y++) {
			if (a[y] > a[x]) {
				c = false;
			}
		}
		if (c == true) {
			cnt += 1;
		}
	}
	cout << cnt << endl;

}

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


  int main()
  {


       ios_base::sync_with_stdio(false);
       cin.tie(NULL);
   
   int a,b;
   cin>>a>>b;
   vector<pair<int,int>>nish;
   vector<int>all(105,0);
   for(int i=0;i<b;i++)
   {
    int first;
    cin>>first;
    all[first]=1;

   }

   for(int i=0;i<=105;i++)
   {
    if(all[i]==0)
      nish.push_back({abs(i-a),i});
   }

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

   cout<<nish[0].second<<endl;
    return 0;

  }

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

int main() {
    ll a, b, c, d; cin >> a >> b >> c >> d;
    ll ans = -1e18;
    ans = max(ans, a*c);
    ans = max(ans, a*d);
    ans = max(ans, b*c);
    ans = max(ans, b*d);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3620
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<deque>
#include<cmath>
#include<stack>
#include<string.h>
#include <iomanip>
#define rep(i,n) for(int i = 0;i<n;i++)
#define _GLIBCXX_DEBUG
using ll = long long; 
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() {
    ll x;
    cin >> x;
    ll a = 100;
    ll cnt = 0;
    while(a<x) {
        a *= 1.01;
        cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3636
#include<stdio.h>

int check(int a,int t[100000],int x[100000],int y[100000])
{
    int time,ntfx,ntfy;
    if(a>0)
    {
        time = t[a] - t[a-1];
        ntfx = x[a] - x[a-1];
        ntfy = y[a] - y[a-1];
    }
    else
    {
        time = t[a];
        ntfx = x[a];
        ntfy = y[a];
    }
    int judge = time - (ntfx+ntfy);
    if(judge<0||judge%2==1)
    {
        return 0;
    }
    return 1;
}

int main(void)
{
    int n,t[100000],x[100000],y[100000];
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%d%d%d",&t[i],&x[i],&y[i]);
    }
    for(int i=0;i<n;i++)
    {
        if(check(i,t,x,y)==0)
        {
            printf("No");
            return 0;
        }
    }
    printf("Yes");
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  int A[N];
  rep(i,N) A[i] = 0;
  rep(i,N-1){
    int x;
    cin >> x;
    A[x-1] += 1;
  }
  rep(i,N) cout << A[i] << endl;

  return 0;
}

Measured memory_bytes: 4452
#include <iostream>
#include <functional>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>

namespace TokorotenLab
{
    class Logger
    {
    private:
        bool isEnable;

    public:
        Logger(bool isEnable = true) : isEnable(isEnable) {}

        template<class T>
        Logger& operator<<(const T& val)
        {
            if(isEnable)
            {
                std::cout << val;
            }
            return *this;
        }

        void set_enable()
        {
            isEnable = true;
        }

        void set_disable()
        {
            isEnable = false;
        }

        void endl()
        {
            if(isEnable)
            {
                std::cout << std::endl;
            }
        }
    };

    Logger logger;

    /*
    Arguments:
        Search range: [begin, end)
        Target function: f(x)
    Requirement:
        f(x) => { false, ..., false, true, ..., true }
    Judge:
        true_bound == begin => All f(x) are true
        true_bound == end => All f(x) are false
    */
    std::pair<long long, long long> binary_search(long long begin, long long end, std::function<bool(long long)> f)
    {
        long long false_bound = begin - 1LL; // ( ..., false_bound] => false
        long long true_bound = end; // [true_bound, ... ) => true
        long long x;

        while(true_bound - false_bound > 1LL)
        {
            x = false_bound + (true_bound - false_bound) / 2LL;
            if(f(x))
            {
                true_bound = x;
            }
            else
            {
                false_bound = x;
            }
        }

        return std::make_pair(false_bound, true_bound);
    }
}

using namespace std;

#define int long long

signed main()
{
    int n;
    int q, k;

    vector<vector<pair<int, int> > > edges;
    vector<int> dist;

    const int INF = 1LL << 62LL;

    cin >> n;

    edges.resize(n + 1, vector<pair<int, int> >());
    dist.resize(n + 1, INF);

    for(int i = 0; i < n - 1; ++i)
    {
        int a, b, c;
        cin >> a >> b >> c;

        edges[a].push_back(make_pair(b, c));
        edges[b].push_back(make_pair(a, c));
    }

    cin >> q >> k;

    queue<int> que;

    que.push(k);
    dist[k] = 0;

    while(!que.empty())
    {
        int node = que.front(); que.pop();

        for(int i = 0; i < edges[node].size(); ++i)
        {
            int next_node = edges[node][i].first;
            int next_cost = dist[node] + edges[node][i].second;

            if(dist[next_node] == INF)
            {
                dist[next_node] = next_cost;
                que.push(next_node);
            }
        }
    }

    for(int i = 0; i < q; ++i)
    {
        int x, y;
        cin >> x >> y;
        cout << dist[x] + dist[y] << endl;
    }

    return 0;
}

Measured memory_bytes: 9984
#include<cstdio>
#include<cstring>
#include<algorithm>

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

using namespace std;

const int INF=1<<29;

int main(){
	for(int cas=1,n;scanf("%d",&n),n;cas++){
		char s[100][101];
		int p[100],len[100];
		rep(i,n) scanf("%s%d",s[i],p+i), len[i]=strlen(s[i]);
		char tar[201]; scanf("%s",tar);

		int m=strlen(tar);
		int dp[201];
		rep(i,m+1) dp[i]=(i==0?0:-INF);
		rep(i,m+1){
			rep(j,n) if(i-len[j]>=0 && dp[i-len[j]]>=0 && strncmp(tar+i-len[j],s[j],len[j])==0) {
				dp[i]=max(dp[i],dp[i-len[j]]+p[j]);
			}
		}
		int sz=dp[m]; // tar = 10^sz と解釈された

		// knapsack
		int dp2[20001];
		rep(j,sz+1) dp2[j]=(j==0?0:INF);
		rep(i,n){
			rep(j,sz-p[i]+1) dp2[j+p[i]]=min(dp2[j+p[i]],dp2[j]+len[i]);
		}
		printf("Case %d: %d\n",cas,dp2[sz]);
	}

	return 0;
}

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

int main(){
	char a;
	int l[3];
	int ans[2] = {0};


	while(cin >> l[0] >> a >> l[1] >> a >> l[2]){
		if(l[2] * l[2] == l[0] * l[0] + l[1] * l[1])
			ans[0]++;
		else if(l[0] == l[1])
			ans[1]++;
	}

	cout << ans[0] << endl << ans[1] << endl;
}

Measured memory_bytes: 1160