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

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;

const int INF=1e9;
const int MOD=1e9+7;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

struct Edge{
	int src,dst,cap,flow;
	Edge(){}
	Edge(int s,int d,int c,int f=0):src(s),dst(d),cap(c),flow(f){}
};
struct Graph{
	vector<Edge> es;
	vi head,next;
	Graph(){}
	Graph(int n):head(n,-1){}
	// 有向辺を追加するとき逆辺の容量c2は普通0である．
	// 両方向に容量があるならc2も指定する．
	void AddEdge(int u,int v,int c1,int c2=0){
		es.emplace_back(u,v,c1); next.push_back(head[u]); head[u]=es.size()-1;
		es.emplace_back(v,u,c2); next.push_back(head[v]); head[v]=es.size()-1;
	}
};

void BFS(const Graph& g,int tap,vi& layer)
{
	queue<pii> q; q.emplace(tap,0);
	while(q.size()){
		int u,d; tie(u,d)=q.front(); q.pop();
		if(layer[u]!=INF) continue;
		layer[u]=d;
		for(int i=g.head[u];i!=-1;i=g.next[i])
			if(g.es[i].cap-g.es[i].flow>0)
				q.emplace(g.es[i].dst,d+1);
	}
}

int DFS(Graph& g,int v,int sink,const vi& layer,int flow)
{
	if(v==sink) return flow;
	int f=flow;
	for(int& i=g.head[v];i!=-1;i=g.next[i]){
		Edge& e=g.es[i];
		if(layer[e.src]>=layer[e.dst]) continue;
		int residue=e.cap-e.flow;
		if(residue==0) continue;
		int augment=DFS(g,e.dst,sink,layer,min(residue,f));
		e.flow+=augment;
		g.es[i^1].flow-=augment;
		f-=augment;
		if(f==0) break;
	}
	return flow-f;
}

int Dinic(Graph& g,int tap,int sink)
{
	int res=0;
	for(int n=g.head.size();;){
		vi layer(n,INF);
		BFS(g,tap,layer);
		if(layer[sink]==INF) break;
		vi temp=g.head;
		res+=DFS(g,tap,sink,layer,INF);
		swap(g.head,temp);
	}
	return res;
}

int main()
{
	for(int n,m,l;~scanf("%d%d%d",&n,&m,&l) && n|m|l;){
		vvi d(n,vi(n,INF));
		rep(i,n) d[i][i]=0;
		rep(i,m){
			int u,v,w; scanf("%d%d%d",&u,&v,&w);
			d[u-1][v-1]=d[v-1][u-1]=w;
		}
		vi ps(n),ks(n);
		rep(i,n) scanf("%d",&ps[i]);
		rep(i,n) scanf("%d",&ks[i]);
		
		rep(k,n) rep(i,n) rep(j,n)
			d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
		
		Graph g(2*n+2);
		rep(i,n){
			g.AddEdge(i,n+i,INF);
			repi(j,i+1,n)
				if(d[i][j]<l){
					g.AddEdge(i,n+j,INF);
					g.AddEdge(j,n+i,INF);
				}
		}
		int tap=2*n,sink=tap+1;
		rep(i,n){
			g.AddEdge(tap,i,ps[i]);
			g.AddEdge(n+i,sink,ks[i]);
		}
		printf("%d\n",Dinic(g,tap,sink));
	}
	
	return 0;
}

Measured memory_bytes: 1964
# include<bits/stdc++.h>
# define ull unsigned long long int
using namespace std;
int main()
{
   int n;
   cin>>n;
   vector<int>ar;
   ull sum=0;
   for(int i=0;i<n;i++)
   {
     int val;
     cin>>val;
     ar.push_back(val);
     sum+=ar[i];
    }
    int m;
    cin>>m;
    while(m--)
    {
      ull p,x;
      cin>>p>>x;
      ull out=sum-ar[p-1]+x;
      cout<<out<<endl;
    }

}

Measured memory_bytes: 3572
# coding: utf-8

from queue import Queue

n = int(input())
c = list(input())
# c = "W" * (10**5) + "R" * (10**5)
# c = list(c)


queue = Queue()
stack = []
for i in range(len(c)):
    if c[i] == "W":
        queue.put(i)
    else:
        stack.append(i)

def is_ok(c):
    for i in range(len(c)-1):
        if c[i] == "W" and c[i+1] == "R":
            return False
    return True

ans = 0
while True:
    if queue.empty() or stack == []:
        break
    i = queue.get()
    j = stack.pop()
    if j < i:
        break
    ans += 1

print(ans)



Measured memory_bytes: 19248
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptor/reversed.hpp>
#include<boost/operators.hpp>
#include<boost/dynamic_bitset.hpp>
namespace adaptor = boost::adaptors;
template<class T>using p_queue = std::priority_queue<T, std::vector<T>, std::greater<>>;


void Main()
{
	std::size_t N;
	std::cin >> N;
	std::map<int, std::map<int, std::size_t>> xs;
	std::map<int, std::map<int, std::size_t>> ys;
	std::vector<std::pair<int, int>> points(N);
	for (auto i : boost::irange<std::size_t>(0, N))
	{
		int x, y;
		std::cin >> x >> y;
		xs[x].emplace(y, i);
		ys[y].emplace(x, i);
		points[i] = std::make_pair(x, y);
	}
	std::vector<int> flag(N);
	std::set<int> xflag, yflag;
	std::size_t count = 0;
	for (auto i : boost::irange<std::size_t>(0, N))
	{
		if (flag[i])
		{
			continue;
		}
		auto x = points[i].first;
		auto y = points[i].second;
		if (xs[x].size() == 1 || ys[y].size() == 1)
		{
			continue;
		}
		std::set<int> xp, yp;
		std::stack<int> stack;
		stack.emplace(i);
		while (stack.size())
		{
			auto index = stack.top();
			stack.pop();
			if (flag[index])
			{
				continue;
			}
			flag[index] = true;
			auto tx = points[index].first;
			auto ty = points[index].second;
			if (!xflag.count(tx))
			{
				for (auto x : xs[tx])
				{
					yp.emplace(x.first);
					stack.emplace(x.second);
				}
			}
			if (!yflag.count(ty))
			{
				for (auto y : ys[ty])
				{
					xp.emplace(y.first);
					stack.emplace(y.second);
				}
			}
			xflag.emplace(tx);
			yflag.emplace(ty);
		}
		count += xp.size() * yp.size();
	}
	std::cout << count - boost::count(flag, true) << std::endl;
}

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

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

// syntax sugar: `for (int i = 0; i < N; ++i)`
#define rep(i, N) for (int i = 0; i < (int)(N); ++i)
// syntax sugar: `for (int i = 0; i < N; ++i)`
#define REP(type, name, beginValue, endCondValue) \
  for (type name = beginValue; name < endCondValue; ++name)
// syntax sugar: 多次元vector
#define VECTOR_DIM3(T, name, d1, d2, d3, initValue) \
    std::vector<std::vector<std::vector<T>>> name(d1, std::vector<std::vector<T>>(d2, std::vector<int>(d3, initValue)));
#define VECTOR_DIM2(T, name, d1, d2, initValue) \
    std::vector<std::vector<T>> name(d1, std::vector<T>(d2, initValue));
#define VECTOR_DIM1(T, name, d1, initValue) \
    std::vector<T> name(d1, initValue);


// ABC091B - Two Colors Card Game
int main(){
  int N, M;
  std::unordered_map<string, int> data;
  cin >> N;
  string si;
  rep(i,N) { // 青
    cin >> si;
    data[si]++;
  }
  cin >> M;
  rep(i,M) { // 赤
    cin >> si;
    data[si]--;
  }

  // 最大のものが0以上であればその数を出力
  int ret = INT_MIN;
  for (const auto& pair : data) {
    if (pair.second > ret) {
      ret = pair.second;
    }
  }

  cout << (ret > 0 ? ret : 0) << endl;


  return 0;
}


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

int main() {
	bool accepted = true;
    int price = 700;
    std::string s = "";
    std::cin >> s;
	std::string::iterator str_iter = s.begin();
    for(int i = 0; i < s.length(); ++i)
    {
      if(*str_iter == 'o')
      {
        price += 100;
      }
      str_iter++;
    }
	std::cout << price;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        int i,j,k,x,n,co=0;
        Scanner s = new Scanner(System.in);
        while(true){
            n = s.nextInt();
            x = s.nextInt();
            if(n==0&&x==0)break;
            for(i=1;i<=n;i++){
                for(j=i+1;j<=n;j++){
                    for(k=j+1;k<=n;k++){
                        if(i+k+j==x)co++;
                    }
                }
            }
            System.out.println(co);
            co =0;
        }
    }
}


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

int main()
{
	int r, g, b,x;
	cin >> r;
	cin >> g;
    cin>> b;
	x = 100 * r+10*g+b;
	if (x % 4 == 0)cout << "YES" << endl;
	else cout << "NO" << endl;
}

Measured memory_bytes: 256
/*
 * 	Just close your eyes
 * 		The sun is going down
 * 			You'll be alright...
 * 				No one can hurt you now
 * 					Come, morning light...
*/
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#ifndef rd
#define endl '\n'
#endif
#define deb cout<<"Line: "<<__LINE__<<" plz "
#define pb push_back
#define fi first
#define se second
#define int long long
typedef long long ll;
#define pii pair<int,int>
#define sz(x) ((int)x.size())
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define all(con) con.begin(),con.end()
const ll inf=1e18;
const int mod=1e9+7;
typedef vector<int> vi;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
vector<int> gra[100005];
int dsu[100005];
int wei[100005];
int pend[100005];
vector<pair<int,pii>> edges;
int fpar(int i) {
	return (dsu[i]<0)?i:dsu[i]=fpar(dsu[i]);
}
void merge(int i, int j) {
	if((i=fpar(i))!=(j=fpar(j))) {
		pend[i]+=pend[j];
		wei[i]+=wei[j];
		dsu[i]+=dsu[j];
		dsu[j]=i;
	}
}
void solve()
{
	int n,m,u,v,w;
	cin>>n>>m;
	for(int i=1; i<=n; i++)
		dsu[i]=-1;
	int ans=0;
	for(int i=1; i<=n; i++) {
		cin>>wei[i];
	}
	for(int i=1; i<=m; i++) {
		cin>>u>>v>>w;
		edges.pb({w,{u,v}});
	}
	sort(all(edges));
	for(int i=0; i<m; i++) {
		merge(edges[i].se.fi,edges[i].se.se);
		int comp=fpar(edges[i].se.fi);
		pend[comp]++;
		if(wei[comp]>=edges[i].fi) {
			ans+=pend[comp];
			pend[comp]=0;
		}
	}
	cout<<m-ans<<endl;
}
signed main() {
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	srand(chrono::steady_clock::now().time_since_epoch().count());
	auto clk=clock();
	int t=1;
//	cin>>t;
	while(t--)
		solve();
#ifdef rd
	cout<<endl<<endl<<(double)(clock()-clk)/CLOCKS_PER_SEC<<endl;
#endif
	return 0;
}

Measured memory_bytes: 8820
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MOD1 1000000007

int main() {
  string s;
  cin >> s;
  int n = s.size();
  string t = s[0] + to_string(n-2) + s[n-1];
  cout << t << endl;
}

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

using namespace std;

int main()
{
    int n,k;
    cin >> n >> k;
    for(int i=0;i<n;i++)
    {
        char temp;
        cin >> temp;
        if(i == k-1)
            cout << (char)tolower(temp);
        else
            cout << temp;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define In_The_Name_Of_Allah_The_Merciful ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define Alhamdulillah return 0;
#define all(v) v.begin(),v.end()
#define debug(n) cerr << "[" << #n << " = " << n << "]" << endl 

void Suhaib_Sawalha (){

    char c;
    cin >> c;
    cout << char(c+1);

}

int main(){
                                In_The_Name_Of_Allah_The_Merciful   /* بسم الله الرحمن الرحيم  */
#ifndef ONLINE_JUDGE
    freopen("SuhaibSawalha1.txt","r",stdin);
#endif
//int _;for(cin>>_;_;--_,cout<<'\n')
        Suhaib_Sawalha();
                                         Alhamdulillah                    /* الحمد لله */
}

Measured memory_bytes: 3592
#pragma GCC optimize("O3")
/*{{{*/
#include <bits/stdc++.h>
#ifdef LOCAL
int c_ = 0;
#define cout (c_?cerr:cout)
#define debug(...) \
{if(!c_++)cerr<<"\033[96;1m"; \
__VA_ARGS__; \
if(!--c_)cerr<<"\033[0m";}
#else
#define debug(...) {}
#endif
#define assrt(...) debug(\
if (not (__VA_ARGS__)) \
    exit((cerr << __LINE__ << ": " << #__VA_ARGS__ << '\n', 0));\
)
#define st first
#define nd second
#define all(...) (__VA_ARGS__).begin(), (__VA_ARGS__).end()
using namespace std; using ll = long long;
template < typename t > using V = vector< t >;
template < typename t, size_t s > using A = array< t, s >;
void print() {cout << '\n';}
template< typename t, typename... v >
void print(const t& a, const v&... b)
{cout << a << (sizeof...(b)?" ":""); print(b...);}
template< typename t > void print_range(t a, const t& b)
{ while (a != b) cout << (*a++) << ' '; cout << '\n';}
#define dump(...) debug(print(#__VA_ARGS__,'=',__VA_ARGS__))
#define dump_range(...) debug(cerr<<#__VA_ARGS__ << ": "; print_range(__VA_ARGS__))
/*}}}*/

constexpr int nax = 1e5;

ll su;
int n, x, tab[nax + 1], low[nax + 1], hig[nax + 1];
pair< ll, int > ilo[nax];

ll foo(const int v, const ll p)
{
    return p >= tab[v]? (ll)tab[v] * low[v] + (ll)(p - tab[v]) * hig[v] : p * low[v];
}

bool spr(ll a)
{
    ll q = a / x;

    ll sum[2] = {0ll, 0ll};

    for (int i = 0; i < (min((ll)n, q)); ++i)
        sum[0] += ilo[i].st;

    sum[1] = sum[0];
    if (q < n) sum[1] += ilo[q].st;

    ll p = a % x;

    ll b = 0;

    for (int i = 0; i < n; ++i)
        b = max(b, foo(ilo[i].nd, p) + (i < q? sum[1] - ilo[i].st : sum[0]));

    return b >= su;
}

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

    cin >> n >> x;

    for (int i = 1; i <= n; ++i)
        cin >> tab[i] >> low[i] >> hig[i];

    for (int i = 1; i <= n; ++i)
        ilo[i - 1] = {(ll)low[i] * tab[i] + (ll)hig[i] * (x - tab[i]), i};

    for (int i = 1; i <= n; ++i)
        su += (ll)low[i] * tab[i];

    sort(ilo, ilo + n);
    reverse(ilo, ilo + n);

    ll lo = 0, hi = (ll)n * x;

    while (lo < hi)
    {
        ll mi = (lo + hi) / 2;
        if (spr(mi))
            hi = mi;
        else
            lo = mi + 1;
    }

    print(lo);
}

Measured memory_bytes: 3072
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
using namespace std;
const int maxn=1009;
int a[maxn];
int b[maxn];
int s[maxn];
int n;
int main()
{
    while(scanf("%d",&n)!=EOF)
    {
        int len=n<<1;
        for(int i=0;i<len;i++)
        {
            scanf("%d",&s[i]);

        }
        sort(s,s+len);
         int sum=0;
         int index=0;
         int indx=0;
        for(int i=0;i<len;i+=2)
        {
           a[index++]=s[i];
           b[indx++]=s[i+1];
        }
        for(int i=0;i<index;i++)
        sum+=a[i];
        printf("%d\n",sum);
    }
    return 0;
}


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

using namespace std;

int main(void) {
    int a1, a2, a3;
    cin >> a1 >> a2 >> a3;
    if (a1 + a2 + a3 >= 22) {
        cout << "bust" << endl;
    } else {
        cout << "win" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		long n = in.nextInt();
		long m = in.nextInt();
		System.out.println(solve(n, m));
		in.close();
	}

	private static long solve(long n, long m) {
		if (n == 1 && m == 1)
			return 1;
		if (n == 1)
			return m - 2;
		if (m == 1)
			return n - 2;
		return (n - 2) * (m - 2);
	}
}

Measured memory_bytes: 21844
fn main() {
    let nr = read_vec::<usize>();
    let n = nr[0];
    let r = nr[1];

    if n < 10 {
        println!("{}", r + 100 * (10 - n));
    } else {
        println!("{}", r);
    }
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

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

using namespace std;

int main(void) {
  int k, t;
  cin >> k >> t;
  vector <int> a;
  for(int i = 0; i < t; i++) {
    int x;
    cin >> x;
    a.push_back(x);
  }

  sort(a.rbegin(), a.rend());
  while(a[1] != 0) {
    int mn = min(a[0], a[1]);
    a[0] -= mn;
    a[1] -= mn;
    sort(a.rbegin(), a.rend());
  }
  if(a[0] != 0) {
    a[0]--;
  }
  cout << a[0] << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main(void){
    int i,j,N;
    unsigned long s[6];
    unsigned long sum = 0;
    unsigned long min;

    N = 6;
    for(i = 0; i < N; i++)
    {
        scanf("%lu", &s[i]);
    }

    min = s[1];
    for(i = 1; i< N; i++)
    {
        if (s[i] < min) {
            min = s[i];
        }
    }
    sum = 4 + s[0] / min;
    if (s[0] % min != 0) {
        sum = sum + 1; 
    }
    printf("%lu",sum);
    return 0;
}

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

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

int main() {
    string s;

    cin >> s;

    string ans = "Yes";
    for (int i = 0; i < s.size(); i++) {
        if ((i % 2) == 0) {
            if (s.at(i) == 'L')
                ans = "No";
        }
        else {
            if (s.at(i) == 'R')
                ans = "No";
        }
        if (ans == "No")
            break;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include  <iostream>

using namespace std;
int main() {
  int k,x=0;
  cin>>k>>x;
  int c=x-k+1;
  int d=x+k-1;
  int s=0;
  if(c<-1000000){
    s=-1000000;
    for(int i=s;i<x+k;i++){
      cout << i << " ";
    }
  }else if(d>1000000){
    s=x-k+1;
    for(int i=s;i<=1000000;i++){
      cout << i << " ";
    }
  }else{
    s=c;
    for(int i=s;i<s+k+k-1;i++){
      cout << i << " ";
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
//解説写し　ダブリング
const int D=60;//入力10^18に合わせるとこれくらいで良い
const int MAX_N=200005;
int to[D][MAX_N];
int main(){
  int n;
  long long k;
  cin>>n>>k;
  vector<int>a(n);
  rep(i,n){
    cin>>to[0][i];
    to[0][i]--;
  }
  rep(i,D-1){
    rep(j,n){
      to[i+1][j]=to[i][to[i][j]];
    }
  }
  int v=0;
  for(int i=D-1;i>=0;--i){
    long long l=1LL<<i;
    if(l<=k){
      v=to[i][v];
      k-=l;
    }
  }
  cout<<v+1<<endl;                     
  return 0;
}

Measured memory_bytes: 50980
#include <iostream>
using namespace std;
#define MAX 30
#define rep(i,p) for(int i=0;i<p;i++)
#define rep1(i,p) for(int i=1;i<=p;i++)
enum MapInfo {
  OUT = -1, NONE  = 0,
  BAD =  1, START = 2,
  GOAL = 3
};
int dx[] = {0,0,1,-1};
int dy[] = {1,-1,0,0};
int start_x,start_y;
int w,h,hoge,abc;
int ice_map[MAX][MAX];
// -1  ??´???
//  0  ????????????
//  1  ?????????
//  2  ????????????
//  3  ??´??????
// ??°???????????????[1,w]x[1.h]
// ????????????????????´???
int dfs (int x, int y, int count, int cur_map[MAX][MAX]) {
  int ans = MAX;
  int temp,temp2;
  int mapp[MAX][MAX];
  if (count > 10) return count;
  // ?????????????????????
  rep(i,4) {
    rep(l,MAX) rep(m,MAX) mapp[l][m] = cur_map[l][m];
    // ???????????????????????§??????
    rep1(a,MAX) {
      temp = cur_map[x+a*dx[i]][y+a*dy[i]];
      if (temp == GOAL) return count;
      else if (temp == BAD) {
        if ( a == 1) break;
        else {
          // ??????????¶???????
          mapp[x+a*dx[i]][y+a*dy[i]] = NONE;
          temp2 = dfs(x+(a-1)*dx[i],y+(a-1)*dy[i],count+1,mapp);
          if (ans > temp2) ans = temp2;
          break;     
        }
      } else if (temp == OUT) break;
    }
  }
  return ans;
}
int main(){
  while(1) {
    cin >> w >> h;
    if ( w==0 and h==0 ) break;
    rep(i,MAX) rep(j,MAX) ice_map[i][j] = -1;
    rep1(i,h) 
      rep1(j,w) {
        cin >> hoge;
        ice_map[i][j] = hoge;
        if (hoge == START) {
          start_x = i;
          start_y = j;
          ice_map[i][j] = NONE;
        }
      }
    abc = dfs(start_x,start_y,1,ice_map);
    if (abc > 10) cout << -1 << endl;
    else cout << abc << endl;
  }
  return 0;
}

Measured memory_bytes: 1200
#include <iostream>
#include<iomanip>
#include<cmath>
#include<algorithm>
#include<string>
using namespace std;
int main()
{
    long long n;
    cin>>n;
    string dog="";
while(n>0){
if(n%26==0){
    dog='z'+dog;
    n--;
}
  else if(n<703){
    char answer=(n%26 - 1)+'a';
    dog=answer+dog;
     }
  else if(n<18279){
     char answer=(n%26 -1)+'a';
    dog=answer+dog;
     }
     else if(n<47255){
     char answer=(n%26 -1)+'a';
    dog=answer+dog;
     }else if(n>47255){
     char answer=(n%26 -1)+'a';
    dog=answer+dog;
     }
     n=n/26;
}
cout<<dog;
}




Measured memory_bytes: 3080
from math import floor, ceil
import decimal


def main():

    A, B = map(float, input().split())
    B = round(B, 2)
    A = int(A)
    A = decimal.Decimal(str(A))
    B = decimal.Decimal(str(B))
    AB = A*B
    AB = floor(AB)
    print(AB)


if __name__ == '__main__':
    main()


Measured memory_bytes: 10084
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
 
public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine();
        int number = Integer.parseInt(line);
        String[] in = br.readLine().split(" ");
        ArrayList<Integer> coordinate = new ArrayList<Integer>(); 
        int max = 0;
        int min = 1000;
        
        for(int i = 0; i < in.length; i++) {
            coordinate.add(Integer.parseInt(in[i]));
        }
        for(int j = 0; j < coordinate.size(); j++) {
            if(min > coordinate.get(j)) {
                min = coordinate.get(j);
            }
            if(max < coordinate.get(j)) {
                max = coordinate.get(j);
            }
        }
        System.out.println(max - min);
    }
}

Measured memory_bytes: 21204
package main
import (
  "bufio"
  "fmt"
  // "math"
  "os"
  "strconv"
  "strings"
)

// 行単位で読み込む場合
var sc = bufio.NewScanner(os.Stdin)

func main() {
  sc.Scan()
  // N, _ := strconv.Atoi((strings.Split(sc.Text(), " "))[0])
  M, _ := strconv.Atoi((strings.Split(sc.Text(), " "))[1])
  X, _ := strconv.Atoi((strings.Split(sc.Text(), " "))[2])

  sc.Scan()
  A := arrayAtoi(strings.Split(sc.Text(), " "))

  countLow := 0
  for _, v := range A {
    if v > X {
      break
    }
    countLow++
  }
  countHigh := M - countLow

  if countLow >= countHigh {
    fmt.Println(countHigh)
  } else {
    fmt.Println(countLow)
  }
  
}

// 配列中の文字列を全て数値に変換
func arrayAtoi(array []string) []int {
  retarray := []int{}
  for _, v := range array {
    num, e := strconv.Atoi(v)
    if e != nil {
      panic(e)
    }
    retarray = append(retarray, num)
  }
  return retarray
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iomanip>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;

int A,B,K;
int M_V;

int main(void){

	scanf("%d%d%d",&A,&B,&K);

	for(int i=0;i<K && A + i <= B;i++){
		printf("%d\n", A + i);
		M_V = A + i;
	}

	for(int i=0;i<K && B - K + 1 + i >= A;i++){
		if(B - K + 1 + i > M_V){
			printf("%d\n", B - K + 1 + i);
		}
	}

	return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
//long long
using ll = long long;
 
// pair<int, int>
using PII = pair<int, int>;
 
//最大値、mod
const int MOD = 1000000007;
const int INF = 1000000000;
const long long LINF = 1e18;
const int MAX = 510000;
 
//出力系
#define print(x) cout << x << endl
#define prints(x) cout << fixed << setprecision(10) << x << endl
#define printc(x) cout << setw(2) << setfill('0') << x << endl;
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()
 
//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
 
//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
 
// 最小公倍数
unsigned lcm(unsigned a, unsigned b){
    return a / gcd(a, b) * b; 
}
 
// a = max(a, b), a = min(a, b)
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; }
 
// 累乗(MODをとる)
ll pow_mod(ll num, ll pow, ll mod) {
    ll prod = 1;
    num %= mod;
    while (pow > 0) {
        if (pow & 1) prod = prod * num % mod;
        num = num * num % mod;
        pow >>= 1;
    }
    return prod;
}
 
 
 
// 二項係数(MODとる、1 ≦ k ≦ n ≦ 10^7 程度)
// COMinit()
// COM(x, y)
// とコンビで使う
 
// テーブルを作る前処理
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
int dx[4] = {1, 0, 0, -1}, dy[4] = {0, 1, -1 ,0};
 
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
 
    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }
 
    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }
 
    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }
 
    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};




int main(){
    int N;
    cin >> N;
    int h[3] ={0, 0, 0};
    ll ans = 1;
    REP(i, N){
        int x;
        cin >> x;
        int cnt = 0;
        bool flag = true;
        REP(j, 3){
            if(x == h[j]) {
                if(flag) h[j]++, flag = false;
                cnt++;
            }
        }
        ans *= cnt;
      	ans %= MOD;
    }
    print(ans);
    return 0;
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    x=int(input())
    for a in range(-118,120):
        for diff in range(238):
            if a**5-(a-diff)**5>10**9:
                break
            if a**5-(a-diff)**5==x:
                print(a,a-diff)
                sys.exit()

if __name__=='__main__':
    main()

Measured memory_bytes: 9040
#include <iostream>
#include <vector>
#include <string>
#include <list>
#include <queue>
#include <algorithm>
#define rep(i, n) for(i = 0; i < (n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define MOD 1000000007
#define PI 3.14159265358979323846
#define INF 1 << 30

using namespace std;
typedef long long ll;
typedef pair<int, int> pp;

int Search(int a, int b, vector<string> & s) {
	int i, j, ans = 0;
	rep(i, s.size()) {
		if (a & (1 << i))
			continue;
		rep(j, s[i].size()) {
			if (b & (1 << j))
				continue;
			if (s[i][j] == '#')
				ans++;
		}
	}
	return ans;
}

int main(void) {
	int num, i, j, h, w, k;
	ll ans = 0;
	cin >> h >> w >> k;
	vector<string> s(h);
	rep(i, h)
		cin >> s[i];
	rep(i, 1 << h) {
		rep(j, 1 << w) {
			if (Search(i, j, s) == k)
				ans++;
		}
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
	#include <cstdio>
	#include <cstring>
	#include <cmath>
	#include <cstring>
	#include <complex>
	#include <chrono>
	#define endl "\n"
	#define ll long long int
	#define vi vector<int>
	#define vll vector<ll>
	#define vvi vector < vi >
	#define pii pair<int,int>
	#define pll pair<long long, long long>
	#define mod 1000000007
	#define inf 1000000000000000001;
	#define all(c) c.begin(),c.end()
	#define mp(x,y) make_pair(x,y) 
	#define mem(a,val) memset(a,val,sizeof(a))
	#define eb emplace_back
	#define f first
	#define s second
	
	using namespace std;

	const int MX = 100010;			// maximum no. of nodes in graph
	vector<bool> visited(MX+1,0);

	int n;
	vector< vector<int> > G(MX+1);
	vector<int> dp(100005, 0);		// adjacency list, (edge,cost) pair
	//vector<int> pre(10005, 1);

	void dfs(int u){
		visited[u] = 1;
		
		for(int i : G[u]){
			
			if(!visited[i]) dfs(i);
			

			dp[u] = max(dp[u], 1+dp[i]);
		}
		
	}

	int main()
	{

		std::ios::sync_with_stdio(false);

		int T;
		//cin>>T;
		T = 1;
		while(T--)
		{

			
			int m;					// no. of edges
			cin>>n>>m;

			for(int i = 1 ; i <= m ; i++)
			{

				int u,v;
				ll c;
				cin>>u>>v;			// 1 based indexing of nodes
				
				G[u].eb(v);
				//G[v].eb(u);

			}
			for(int i=1; i<=n; i++){
				if(!visited[i]){
					dfs(i);
				}
			}

			cout<<*max_element(all(dp))<<endl;
		}
		return 0;
	}

Measured memory_bytes: 8192
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl '\n'

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

  //  ll t; cin>>t; while(t--)
    {
     ll a,b,c,k;
     cin>>a>>b>>c>>k;
     ll ans=0;
     if(k<=a)
     {
         cout<<k;
         return 0;
     }
     
     if(k>a)
     {
         ans+=a;
         k-=a;
         if(k>0)
         {
             k-=b;
         }
         if(k>0)
         {
             ans-=k;
         }
         cout<<ans;
         return 0;
         
     }


    }

  


    return 0;
}

Measured memory_bytes: 3656
import java.io.PrintWriter

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    val N = nextInt()
    val W = Array(N) { next() }
    if (W.distinct().size != N) {
        println("No")
        return
    }
    for (i in 0 until W.size - 1) {
        if (W[i].last() == W[i + 1].first()) continue
        println("No")
        return
    }
    println("Yes")
}

Measured memory_bytes: 37944
//# define FLAG
///delet....................................
# include   <bits/stdc++.h>
using namespace std;
# define    VI                      vector<int>
# define    pb                      push_back
# define    mp                      make_pair
# define    IOS                     ios::sync_with_stdio(false)
# define    mem(a,b)                memset(a,b,sizeof(a))
# define    FO(i,n,a)               for(int i=n; i>=a; --i)
# define    FOR(i,a,n)              for(int i=a; i<=n; ++i)
# define    pi                      acos(-1.0)
# define    MAX                     0x7fffffffffffff
# define    INF                     0x3f3f3f3f
# define    MOD                     1000000007
# define    eps                     0.00000001
# define    hr                      putchar('\n')
# define    bug                     puts("H")
# pragma    comment(linker,"/STACK:1024000000,1024000000")
typedef     unsigned long long      ULL;
typedef     long long               LL;
inline char gtc() {
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
# define    Template                int
inline Template read() {
    int flag=1;
    char ch=gtc();
    if(ch==EOF)return EOF;   ///EOFµÄÖµÊÇ-1
    Template sum=0;
    while(!((ch>='0'&&ch<='9')||ch=='-'))ch=gtc();
    if(ch=='-')flag=-1,ch=gtc();
    while(ch>='0'&&ch<='9')sum=sum*10+ch-'0',ch=gtc();
    return sum*flag;
}
inline void out(Template x) {
    if(x<0)putchar('-'),x=-x;
    if(x>9)out(x/10);
    putchar(x%10+'0');
}
///coding...................................

map<int,int>M;

int main() {
    IOS;
#ifdef FLAG
    freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
#endif
    int n,a,sum=0;
    cin>>n;
    while(n--) {
        cin>>a;
        ++M[a];
    }
    map<int,int>::iterator i;
    for(i=M.begin();i!=M.end();++i)
        if(i->second&1)++sum;
    cout<<sum<<endl;
    return 0;
}











///delete FLAG..............................




Measured memory_bytes: 4992
S=input()
Dict={}

for s in range(len(S)):
    if(Dict.get(S[s],None)==None):
        Dict[S[s]]=1
    else:
        Dict[S[s]]+=1
MIN=10*10

for s in Dict:
    count=0
    tMAX=0
    for s2 in range(len(S)):
        if(S[s2]==s):
            tMAX=max(tMAX,count)
            count=0
        else:
            count+=1
    tMAX=max(tMAX,count)    
    MIN=min(MIN,tMAX)

print(MIN)



Measured memory_bytes: 3064
import sys
sys.setrecursionlimit(10 ** 7)


def input():
    return sys.stdin.readline().strip()


def dfs(v):
    if dp[v] >= 0:
        return dp[v]
    res = 0
    for nv in g[v]:
        res = max(res, dfs(nv) + 1)
    dp[v] = res
    return res


n, m = map(int, input().split())
g = [[] for i in range(n)]
for _ in range(m):
    x, y = map(int, input().split())
    g[x - 1].append(y - 1)

dp = [-1] * n
for v in range(n):
    dp[v] = max(dp[v], dfs(v))
print(max(dp))


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

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL


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

    s64 n, k;
    cin >> n >> k;

    s64 ans = k;

    rep (i, n - 1) ans *= k - 1;

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



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ft first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=1e5+7;
static const ll MOD=1e9+7;
ll max(ll a, ll b) {return a>b?a:b;}
ll min(ll a, ll b) {return a<b?a:b;}



int main() {
  ll N;
  cin >> N;
  double v[55];
  ll i;
  
  priority_queue<double> q;
  for(i=0; i<N; i++) {
    cin >> v[i];
    q.push(-v[i]);
  }
  
  for(ll _=0; _<N-1; _++) {
    double u=q.top(); q.pop();
    double v=q.top(); q.pop();
    q.push((u+v)/2);
  }
  
  printf("%.10f\n", -q.top());
  
}













Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

int main(){
    int H, W;
    cin >> H >> W;
    vector<string> a(H, string(W, '.')), red=a, blue=a;
    rep(y, H) {
        char s_[501];
        scanf("%s", s_);
        a[y] = string(s_);
    }

    rep(x, W)for(int y=1;y<=H-2;++y) {
        if(x & 1)red[y][x] = '#';
        else blue[y][x] = '#';
    }
    rep(x, W) {
        red[0][x] = '#';
        blue[H - 1][x] = '#';
    }

    rep(y, H)rep(x, W)if(a[y][x] == '#') {
        red[y][x] = blue[y][x] = '#';
    }

    rep(y, H)printf("%s\n", red[y].c_str());
    puts("");
    rep(y, H)printf("%s\n", blue[y].c_str());
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define srt(i) sort(i.begin(), i.end())
#define rvt(i) sort(i.begin(), i.end(), greater<int>())

int main()
{
    int64_t n,k;
    cin >> n >> k;

    vector<int > a(n);
    rep(i,n){
      cin >> a.at(i);
      a.at(i)--;
    }
    
    vector<int > his(n, -1);
    bool noWarp = false;
    int result = a.at(0);
    for(int64_t i=2; i<=k; i++){
      result = a.at(result);

      if(!noWarp && his.at(result) != -1){
        int diff = i - his.at(result);
        int64_t tmp = (k-i)%diff;
        i = k-tmp;
        noWarp = true;
      }
      his.at(result) = i;
    }
    
    cout << result+1 << endl;
}


Measured memory_bytes: 4844
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

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

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

int main() {
    int N;
    cin >> N;
    int n1 = 0, n2 = 0, n3 = 0;
    for(int i=0; i<N; i++) {
        int tmp;
        cin >> tmp;
        if(tmp == 1) n1++;
        else if(tmp == 2) n2++;
        else n3++;
    }
    int sum_sushi = n1 + n2 + n3;

    vector<vector<vector<double>>> dp(N+2, vector<vector<double>> (N+2, vector<double>(N+2, 0.0)));
    
    for(int k=0; k<=N; k++)
        for(int j=0; j<=N; j++)
            for(int i=0; i<=N; i++) {
                if(i+j+k>N) break;
                if(i+j+k!=0){
                    double a = (double)i, b=(double)j, c=(double)k, d=(double)N;
                    if(i>0) dp[i][j][k] += a*dp[i-1][j][k];
                    if(j>0) dp[i][j][k] += b*dp[i+1][j-1][k];
                    if(k>0) dp[i][j][k] += c*dp[i][j+1][k-1];
                    dp[i][j][k] += d;
                    dp[i][j][k] /= (a+b+c);
                }
            }

    // cout << setprecision(10);
    // cout << dp[n1][n2][n3] << endl;
    printf("%.12f\n",dp[n1][n2][n3]);
    return 0;
}

Measured memory_bytes: 219776
#include<iostream>

using namespace std;

static const int N = 100;

int main(){
  int G[N][N];
  int u, v, k, n;

  cin >> n;

  for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++)
      G[i][j] = 0;
  }
  
   for(int i = 0; i < n; i++){
     cin >> u >> k;
     u--;
     for(int j = 0; j < k; j++){
       cin >> v;
     v--;
     G[u][v] = 1;
   }
}

   for(int i = 0; i < n; i++){
     for(int j = 0; j < n; j++){
       if(j)
	 cout << " ";
       cout << G[i][j];
     }
       cout << endl;
   }

   return 0;
}



Measured memory_bytes: 3112
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string str = Console.ReadLine();
		long N = long.Parse(str);
		string ans;
		if(N < 1200){
			ans = "ABC";
		} else if(N < 2800){
			ans = "ARC";
		} else {
			ans = "AGC";
		}
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 13140
#include <cstdio>
#include <cstring>

using namespace std;

int main(){
	while(true){
		int sum = 0;
		char number[1001];
		scanf("%s", number);
		if(strcmp(number, "0") == 0) break;

		int i = 0;
		while(number[i]){
			sum += number[i] - '0';
			i++;
		}
		printf("%d\n", sum);
	}

	return 0;
}

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


int main() {
    int N,M;
    ll sum=0;
    int count =0;
    cin >>N>>M;
    vector<pair<ll,int>>data(N);
    rep(i,N){
        cin >> data[i].first >> data[i].second;
    }
    sort(data.begin(),data.end());
    rep(i,N){
        count += data[i].second;
        if(count<=M){
        sum += data[i].first*data[i].second;
    }
    else{
        int amari =M-(count -data[i].second);
        sum += data[i].first*amari;
        break;
    }
    }
    cout <<sum<<endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define piii pair<int,pii>
#define pll pair<ll,ll>
#define plii pair<ll,pii>
#define vi vector<int>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mx 100001
#define eps 0.00000000001
#define mod 1000000007
#define pi acos(-1)
#define inf 100000000
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
string f(ll n){
  if(n==0)
  return "";
  n--;
  return
   f(n/=26)+char(n%26+'a');
}
int main(){
  fio;
 ll n;
 cin>>n;
 cout << f(n) << endl;
}


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

using namespace std;

typedef long long ll;
typedef long double Double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// chmax, chmin
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;
}

const long long MOD = 1000000007;


void solve(long long N, std::vector<long long> A) {
    ll v[3] = {-1, -1, -1};

    ll ans = 1;

    for (int i = 0; i < N; i++) {
        int c = 0;
        int id = -1;
        for (int j = 0; j < 3; j++) {
            if (v[j] + 1 == A[i]) {
                c++;
                id = j;
            }
        }
        if (c == 0) {
            ans = 0;
            break;
        }
        v[id] = A[i];
        ans *= c;
        ans %= MOD;
    }
    cout << ans << endl;

}

int main() {
    long long N;
    scanf("%lld", &N);
    std::vector<long long> A(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


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

int main(){
  int N;
  cin>>N;
  int a=N%10;
  if(a==3){
    cout<<"bon"<<endl;
  }
  else if(a==0 || a==1 ||a==6 ||a==8){
    cout<<"pon"<<endl;
  }
  else{
    cout<<"hon"<<endl;
  }
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    bool cant = true;
    int k;
    for(ll i = 1; i <= N + 1; i++) {
        if(2 * N == i * (i - 1)) {
            k = i;
            cant = false;
            break;
        }
    }

    if(cant) {
        cout << "No";
        return 0;
    }
    cout << "Yes\n" << k << "\n";

    k--;
    vector<vector<int>> ans(k + 1);
    int tmp = 0, diff = 1;
    for(int i = 0; i < N; i++) {
        if(tmp + diff > k) {
            tmp++;
            diff = 1;
        }
        ans[tmp].push_back(i + 1);
        ans[tmp + diff].push_back(i + 1);
        diff++;
    }
    for(int i = 0; i <= k; i++) {
        int size = ans[i].size();
        cout << size;
        for(int j = 0; j < size; j++) {
            cout << " " << ans[i][j];
        }
        cout << "\n";
    }
    return 0;
}


Measured memory_bytes: 2304
#include <algorithm>
#include <cassert>
#include <climits>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

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

const int INF = 1e9;
const long long LINF = 1e18;

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

    if (S == "Sunny") {
        cout << "Cloudy" << endl;
    } else if (S == "Cloudy") {
        cout << "Rainy" << endl;
    } else {
        cout << "Sunny" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
// import chie template :) {{{
import std.stdio, std.algorithm, std.array, std.string, std.math, std.conv,
    std.range, std.container, std.bigint, std.ascii, std.typecons;

// }}}
// nep.scanner {{{
class Scanner
{
    import std.stdio : File, stdin;
    import std.conv : to;
    import std.array : split;
    import std.string;
    import std.traits : isSomeString;

    private File file;
    private char[][] str;
    private size_t idx;

    this(File file = stdin)
    {
        this.file = file;
        this.idx = 0;
    }

    this(StrType)(StrType s, File file = stdin) if (isSomeString!(StrType))
    {
        this.file = file;
        this.idx = 0;
        fromString(s);
    }

    private char[] next()
    {
        if (idx < str.length)
        {
            return str[idx++];
        }

        char[] s;
        while (s.length == 0)
        {
            s = file.readln.strip.to!(char[]);
        }

        str = s.split;
        idx = 0;

        return str[idx++];
    }

    T next(T)()
    {
        return next.to!(T);
    }

    T[] nextArray(T)(size_t len)
    {
        T[] ret = new T[len];

        foreach (ref c; ret)
        {
            c = next!(T);
        }

        return ret;
    }

    void scan()()
    {
    }

    void scan(T, S...)(ref T x, ref S args)
    {
        x = next!(T);
        scan(args);
    }

    void fromString(StrType)(StrType s) if (isSomeString!(StrType))
    {
        str ~= s.to!(char[]).strip.split;
    }
}
// }}}

void main()
{
    auto cin = new Scanner;

    char[] s, t;
    cin.scan(s, t);
    foreach (i; 0 .. s.length)
    {
        s = s[$ - 1] ~ s[0 .. $ - 1];
        if (s == t)
        {
            writeln("Yes");
            return;
        }
    }
    writeln("No");
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {

    long long goalNum;
    cin >> goalNum;

    long long startingNum = 100;

    int years = 0;

    while (startingNum < goalNum) {
        startingNum += startingNum/100;
        years++;
    }
    cout << years;
    
    return 0;
}


Measured memory_bytes: 3600
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

ll f(ll n){
  ll res = (ll)1e12;
  for(ll i = 1; i*i<=n; ++i){
    if(n%i==0){
      res = min(res,i+n/i);
    }
  }
  return res-2;
}
int main() {
  ll n;
  cin>>n;
  cout << f(n) << endl;
}


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

using namespace std;

int main()
{
    int n, result = 0;
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        int num;
        cin >> num;
        if (i % 2 != 0)
            if (num % 2 != 0)
                result++;
    }
    cout << result;
    return 0;
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int main() {
  int X; cin >> X;
  ll ans = 0; int cnt = 0;
  while(true) {
    ans += X;
    cnt++;
    if(ans % 360 == 0) {
      cout << cnt << endl;
      break;
    }
  }
}

Measured memory_bytes: 3620