akhauriyash/Code-Regression huggingface dataset:
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/

#include <cstdio>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
#include <cassert>
#include <iomanip>
#include <set>
#include <stack>
#include <bitset>
/*
多倍長整数, cpp_intで宣言
#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
*/

//#pragma gcc target ("avx2")
//#pragma gcc optimization ("o3")
//#pragma gcc optimization ("unroll-loops")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printim(a) printf(a ? "possible\n" : "imposible\n")
#define printdb(a) printf("%.50lf\n", a) //少数出力
#define printLdb(a) printf("%.50Lf\n", a) //少数出力
#define printdbd(a) printf("%.16lf\n", a) //少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str()) //string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2LL) //等差数列の和、初項,末項,項数
#define pb push_back
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0L)*2.0L*PI)
#define rad_to_deg(rad) (((rad)/2.0L/PI)*360.0L)
#define Please return
#define AC 0
#define manhattan_dist(a, b, c, d) (abs(a - c) + abs(b - d)) /*(a, b) から (c, d) のマンハッタン距離 */
#define inf numeric_limits<double>::infinity();
#define linf numeric_limits<long double>::infinity()


using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1e9+7;
constexpr long double eps = 1e-6;
const long double PI = acosl(-1.0L);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);
	while (c != '\n' && c != -1 && c != ' ') {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

ll LSB(ll n) { return (n & (-n)); }

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {

	int a, b;
	scanf("%d%d", &a, &b);
	printf("%d\n", a * b);

	Please AC;
}

Measured memory_bytes: 3756
import java.util.*;
 
public class Main{
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long dp[] = new long[100100];
        int h[] = new int[n];
        for(int i=0; i<n; i++){
            h[i] = sc.nextInt();
        }
        
        dp[0] = 0;
        dp[1] = Math.abs(h[0]-h[1]);

        for(int i=2; i<n; i++){
            dp[i] = Math.min(dp[i-2] + Math.abs(h[i-2]-h[i]),dp[i-1] + Math.abs(h[i-1]-h[i]));
        }
        System.out.println(dp[n-1]);
    }
}


Measured memory_bytes: 56848
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long int
 
#define REP(i, n) for(int i = 0; i < (n); i++)
#define SREP(i, s) for(int i = 0; i < (s.size()); i++)
#define SORT(v, n) sort(v, v+n);
#define GSORT(v, n) sort(v, v+n, greater<int>());
#define VSORT(v) sort(v.begin(),v.end());
#define VGSORT(v) sort(v.begin(),v.end(),greater<int>());
#define REV(a) reverse(begin(a),end(a));
 
ll gcd(ll x, ll y){
	if(x<y) swap(x,y);
	if(y==0) return x;
	return gcd(y,x%y);
}
 
ll lcm(ll x, ll y){
	return (x*y/gcd(x,y));
}
 
int main(){
	ios::sync_with_stdio(false);cin.tie(0);
////////////////////////////////////////////
	int n,p;
	string s;
	cin >> n;
	pair<pair<string,int>,int> pp[n];
	REP(i,n){
		cin >> s >> p;
		pp[i] = make_pair(make_pair(s,-p),i);
	}
	SORT(pp,n);
	REP(i,n){
		cout << pp[i].second+1 << endl;
	}
	
	
/////////////////////////////////////////////
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
using namespace std;

int n, m, x;
int a[110];
int sum1 = 0, sum2 = 0;
int main()
{
	cin >> n >> m >> x;
	for(int i = 0; i < m; i++) {
		cin >> a[i];
		if(a[i] < x) sum1++;
		else sum2++;
	}
	printf("%d\n", min(sum1, sum2));
}

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

int main(void){
    long long int n,i=0,j,cnt=0,max=0;
    cin >> n;
    vector<int>h(n);
    for(i=0;i<n;i++){
        cin >> h[i];
    }
    
    for(i=0;i<n-1;i++){
        cnt=0;
       for(j=i;j<n-1;j++){
            if(h[j]>=h[j+1]){
                cnt++;
            }else{
                break;
            }
        }
        if(max<cnt)max=cnt;
        if(max>n-i)break;
    }
    cout << max;
    
}


Measured memory_bytes: 640
#include<stdio.h>
#include<queue>
struct S{int n,e,s,w,u,d,p,x,y;bool operator<(const S&r)const{return p>r.p;}};
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
int S::*r[4][2]={
	{&S::e,&S::w},
	{&S::s,&S::n},
	{&S::w,&S::e},
	{&S::n,&S::s},
};
void R(int&a,int&b,int&c,int&d){int t=a;a=b,b=c,c=d,d=t;}
int main()
{
	int h,w,a[10][10],sx,sy,gx,gy,i,j;
	while(scanf("%d%d",&h,&w),h)
	{
		for(i=0;i<h;++i)for(j=0;j<w;++j)scanf("%d",&a[i][j]);
		scanf("%d%d%d%d",&sy,&sx,&gy,&gx);
		std::priority_queue<S>q;
		S s={5,3,2,4,1,6,0,sx,sy};
		q.push(s);
		bool f[10][10][7][7]={0};
		for(;;)
		{
			s=q.top();q.pop();
			if(s.x==gx&&s.y==gy){printf("%d\n",s.p);break;}
			if(f[s.y][s.x][s.u][s.s]++)continue;
			for(i=0;i<4;++i)
			{
				S t=s;
				t.x+=dx[i];t.y+=dy[i];
				if(t.x<0||t.y<0||t.x>=w||t.y>=h)continue;
				R(t.d,t.*r[i][0],t.u,t.*r[i][1]);
				t.p+=a[t.y][t.x]*t.d;
				q.push(t);
			}
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
int a[100010];
pii b[100010];
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
    }
    sort(a + 1, a + 1 + n);
    for (int i = 1; i <= m; ++i) {
        cin >> b[i].second >> b[i].first;
    }
    sort(b + 1, b + 1 + m, greater<pii>());
    int p = 0;
    for (int i = 1; i <= m; ++i) {
        for (int j = p + 1, cnt = 0; j <= n; ++j) {
            if (b[i].first <= a[j]) {
                p = j - 1;                
                break;
            }
            ++cnt;
            a[j] = b[i].first;
            if (cnt == b[i].second) {
                p = j;
                break;
            }
        }
    }
    long long answer = 0;
    for (int i = 1; i <= n; ++i) {
     //   cout << a[i] << " ";
        answer += a[i];
    }
    cout << answer;
}

Measured memory_bytes: 4760
#include<stdio.h>
#include<math.h>
 
int main(){
 
  int n, t, count, i, j;
  int num[10000];
 
  scanf("%d",&n);
 
  for(i=0; i < n; i++){
    scanf("%d",&num[i]);
  }
  count = n;
 
  for (i = 0; i < n; i++){
    if (num[i] == 2) {
    }
    else if(num[i] % 2 == 0){
      count--; 
    }
    else{
      t = sqrt(num[i]);
      for(j=3; j<=t; j=j+2){
        if(num[i] % j == 0){
          count--;  
          break;  
        }
      }  
    }
  }
 
  printf("%d\n",count);
 
  return 0;
}

Measured memory_bytes: 1840
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
using namespace std;
typedef long long LL;
typedef pair<int,int> P;
const int NN=50*50*2+1;

struct edge
{
	int s;
	int t;
	int st;
	int ts;
	int init;
	int nex(int a){
		return a==s?t:s;
	}
	int res(int a){
		return a==s?st:ts;
	}
	void use(int a, int v){
		if(a==s){
			st-=v;
			ts+=v;
		}
		else
		{
			st+=v;
			ts-=v;
		}
	}
};
typedef vector<edge*>::iterator It;
template<int NN, int MM>
struct MaxFlow
{
	edge es[MM];
	int esize;
	vector<edge*> edges[NN];
	void add(int a, int b, int v)
	{
		es[esize].s=a;
		es[esize].t=b;
		es[esize].st=v;
		es[esize].ts=v;
		es[esize].init=v;
		edges[a].push_back(es+esize);
		edges[b].push_back(es+esize);
		esize++;
	}
	edge* pre[NN];
	int done[NN];
	int q[NN];
	int s;
	int t;
	int flow()
	{
	int ret=0;
	int f=0;
	while(1){
		f++;
		int qs=0;
		int qe=1;
		q[0]=s;
		done[s]=f;
		while(qs<qe){
			int top=q[qs++];
			for(It it=edges[top].begin();it!=edges[top].end();it++){
				int nex=(*it)->nex(top);
				if((*it)->res(top)&&done[nex]!=f){
					q[qe++]=nex;
					pre[nex]=*it;
					done[nex]=f;
					if(nex==t){
						goto OK;
					}
				}
			}
		}
		break;
OK:
		int p=t;
		int res=INT_MAX;
		while(p!=s){
			int pp=pre[p]->nex(p);
			res=min(res,pre[p]->res(pp));
			p=pp;
		}
		p=t;
		while(p!=s){
			int pp=pre[p]->nex(p);
			pre[p]->use(pp,res);
			p=pp;
		}
		ret+=res;
	}
	return ret;
	}
};

MaxFlow<301, 1000> mf;
int main() {
	int N,M;
	cin >> N >> M;
	for(int i=0;i<M;i++){
		int X,Y;
		cin >> X >> Y;
		mf.add(X,Y,1);
	}
	cin >> mf.s >> mf.t;
	cout << mf.flow() << endl;
	int rev=0;
	for(int i=0;i<mf.esize;i++){
		if(mf.es[i].st>mf.es[i].init){
			rev++;
		}
	}
	cout << rev << endl;
	for(int i=0;i<mf.esize;i++){
		if(mf.es[i].st>mf.es[i].init){
			cout << i+1<<endl;
		}
	}
	return 0;
}

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

int main(){
	int a, b, d , r ;
	double f;
	
	cin >> a >> b;
	d = a / b;
	r = a % b;
	f = (double)a / (double)b;
	
	cout << d << " "<< r ;
	printf(" %.8lf\n", f);

	return 0;
}

Measured memory_bytes: 3220
from collections import deque

h, w = map(int, input().split())
ch,cw = map(int, input().split())
dh, dw = map(int, input().split())
ls = [input() for _ in range(h)]


widou = []

for i in range(-2,3):
    for j in range(-2, 3):
        widou.append((i, j))
widou.remove((0,0))
widou.remove((1,0))
widou.remove((0,1))
widou.remove((-1,0))
widou.remove((0,-1))
#print(widou)

start = (ch-1, cw-1)
goal = (dh-1, dw-1)

explored = set()
tempexplored = set()

yexp= deque()
yexp.append(start)
ytemp= deque()
ytemp.append(start)

wap = 0


while yexp:
    now = yexp.popleft()
    ytemp.popleft()

    if now == goal:
        print(wap)
        exit(0)

    x = now[0]
    y = now[1]

    explored.add((x, y))
    tempexplored.add((x, y))

    idou = [(1,0), (0,1), (0,-1), (-1,0)]
    for i, j in idou:
        a = x + i
        b = y + j
        if 0 <= a < h and 0 <= b < w:
            if ls[a][b] == '.':
                if (a, b) not in explored:
                    #print(a,b)
                    yexp.append((a,b))
                    ytemp.append((a,b))
                    explored.add((a,b))
                    tempexplored.add((a,b))
    #print(ytemp)
    #print(tempexplored)
    #print(explored)


    if len(ytemp) ==0:
        #print('waap')
        wap += 1
        for s,t in tempexplored:
            #print(s,t)
            for i, j in widou:
                #print(i,j)
                a = s + i
                b = t + j
                #print('kekka', a,b)


                if 0 <= a < h and 0 <= b < w:
                    #print(a, b)
                    if ls[a][b] == '.':
                        if (a, b) not in explored:
                            #print('OK')
                            yexp.append((a, b))
                            ytemp.append((a, b))
                            explored.add((a, b))
        tempexplored = set()
        #print(ytemp)
        #print(tempexplored)
        #print(explored)
print('-1')

Measured memory_bytes: 152544
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>

using namespace std;

int main(){
    int H,W;
    cin >> H >> W;
    vector<vector<char> > mat(H+2,vector<char>(W+2,'#'));
    for(int i=1; i<H+1; i++){
        for(int j=1; j<W+1; j++){
            cin >> mat[i][j];
        }
    }

    int MOD=1000000007;
    vector<vector<int> > dp(H+2,vector<int>(W+2, 0));
    dp[1][1]=1;
    for(int i=1; i<H+1; i++){
        for(int j=1; j<W+1; j++){
            if(mat[i][j]=='#' || (i==1 && j==1)){
                continue;
            }
            dp[i][j]=dp[i-1][j]+dp[i][j-1];
            dp[i][j]%=MOD;
        }
    }
    cout << dp[H][W] << endl;
}

Measured memory_bytes: 5248
#include <iostream>
#include <algorithm>
#include <queue>
#include <list>
#include <string>
using namespace std;

int main()
{
	int N,Q,l,r;
	cin >> N >> Q;
    string s;
    int aclis[100001];
    int acindex = 0;
    cin >> s;
    int i=0,previ = 0;
	/*while(i != s.length() + 1){
        i = s.find("AC",i);
        if(i == -1) i=s.length();
        for(int j=previ;j<i;j++){
            aclis[j+1] = acindex;
        }
        acindex++;
        previ = i;
        i++;
    }*/
    for(int i=0;i<N;i++){
        aclis[i] = acindex;
        if(s[i] == 'A'){
            if(s[i+1] == 'C') acindex++;
        }
    }
    int index[100001];
    for(int i=0;i<Q;i++){
        cin >> l >> r;
        index[i] = aclis[r-1] - aclis[l-1];
    }
    for(int i=0;i<Q;i++) cout << index[i] << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
//const int INF = 1e8;
using namespace std;

int main(){
	string s;
	cin >> s;
	s[3] = '8';
	cout << s << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp make_pair
#define PII pair<int,int>
#define TP tuple<int,int,int>
#define fi first
#define se second
#define pb push_back

using namespace std;

typedef long long LL;

const int nmax = 100005; const LL inf = 2e18; const int mod = 1000000009;

LL N,a[nmax],b[nmax],sol,cnt;

int main(){
//   #ifndef GLOBAL_JUDGE
//      freopen("txt.in","r",stdin);
//      freopen("txt.out","w",stdout);
//   #endif // GLOBAL_JUDGE
   LL i,j,y;
   cin >> N;
   for(i = 1; i <= N; ++i)
      cin >> a[i] >>  b[i];

   for(i = N;i;--i){
      a[i]+=cnt;
      if(a[i]%b[i] == 0)continue;
      y = a[i]%b[i];
      cnt+=(b[i]-y);
      sol+=(b[i]-y);
   }
   cout << sol << '\n';
   return 0;
}


Measured memory_bytes: 1792
#include <cstdio>

using namespace std;

double nx[4], ny[4], a[3], b[3], c[3];

void line(double ax, double ay, double bx, double by, double *a, double *b, double *c)
{

  if(ax == bx){
    *b = 0;
    *c = ax;
    return;
  }
  if(ay == by){
    *a = 0;
    *c = ay;
    return;
  }

  double aa = ax - bx;
  double bb = ay - by;
  *a = bb / aa;
  *c = (*b) * ay - (*a) * ax;
}

int position(double a, double b, double c, double px, double py)
{
  if(a == 0)
    return c<py?1:-1;

  if(b == 0)
    return c<px?1:-1;

  return (a * px + c < py)?1:-1;
}

int main()
{
  while(scanf("%lf%lf", &nx[0], &ny[0]) != -1){
    for(int i=0;i<3;i++) a[i] = b[i] = c[i] = 1;
    
    for(int i=1;i<4;i++)
      scanf("%lf%lf", &nx[i], &ny[i]);

    line(nx[0], ny[0], nx[1], ny[1], &a[0], &b[0], &c[0]);
    line(nx[1], ny[1], nx[2], ny[2], &a[1], &b[1], &c[1]);
    line(nx[0], ny[0], nx[2], ny[2], &a[2], &b[2], &c[2]);

    //    for(int i=0;i<3;i++)
    //      printf("%lf %lf %lf\n", a[i], b[i], c[i]);
    
    puts((position(a[0], b[0], c[0], nx[2], ny[2]) * position(a[0], b[0], c[0], nx[3], ny[3]) > 0 &&
	  position(a[1], b[1], c[1], nx[0], ny[0]) * position(a[1], b[1], c[1], nx[3], ny[3]) > 0 &&
	  position(a[2], b[2], c[2], nx[1], ny[1]) * position(a[2], b[2], c[2], nx[3], ny[3]) > 0)?"YES":"NO");
  }
  return 0;
}

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

// template {{{
#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); (i) += 1)
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); (i) -= 1)

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

// constexpr i32 mod   = 998244353;
constexpr i32 mod   = 1e9 + 7;
constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

constexpr int dx[] = {0, -1, 1, 0, -1, 1, -1, 1};
constexpr int dy[] = {-1, 0, 0, 1, -1, -1, 1, 1};

struct IoSetup { IoSetup(int x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

template <typename T> vector<T> make_vector(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_vector(ts...))>(a, make_vector(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// }}}

void solver() {
    int N = input() % 10;

    if (N == 3) {
        cout << "bon" << endl;
    } else if (N == 0 || N == 1 || N == 6 || N == 8) {
        cout << "pon" << endl;
    } else {
        cout << "hon" << endl;
    }
}

signed main(int argc, char *argv[]) {
    solver();
}


Measured memory_bytes: 3600
import java.util.ArrayList;
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;

public class Main {
	static long[][] d;
	static int[]r;
	static long ans = 100000000000000l;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int R = sc.nextInt();
		r = new int[R];
		for(int i = 0; i < R; i++) {
			r[i] = sc.nextInt() - 1;
		}
		int[] A = new int[M];
		int[] B = new int[M];
		long[] C = new long[M];
		for(int i = 0; i < M; i++) {
			A[i] = sc.nextInt() - 1;
			B[i] = sc.nextInt() - 1;
			C[i] = sc.nextLong();
		}
		sc.close();
		d = new long[R][N];
		for(int i = 0; i < R; i++) {
			d[i] = dijkstra(N, r[i], A, B, C, true);
		}
		perm(0, new int[R], new boolean[R]);
		System.out.println(ans);
	}
//	static class Data{
//		int id, r;
//		public Data(int id, int r) {
//			this.id = id;
//			this.r = r;
//		}
//	}
	public static void perm(int n, int[] a, boolean[] flag) {
		if(n == a.length) {
			//ans = Math.min(ans, k);
			long k = 0;
			for(int i = 1; i < a.length; i++) {
				k += d[a[i - 1]][r[a[i]]];
				//System.out.println(a[i - 1] + " " + a[i]);
			}
			ans = Math.min(ans, k);
			return;
		}
		for(int i = 0; i < a.length; i++) {
			if(flag[i]) continue;
			a[n] = i;
			flag[i] = true;
            perm(n + 1, a, flag);
            flag[i] = false;
		}
	}
	/**
	 * ダイクストラ法 (優先度付きキュー)
	 * @param N 頂点数 (0 ~ N-1)
	 * @param t 始点
	 * @param from, to 辺
	 * @param cost 辺のコスト
	 * @param flag true なら無向辺、 false なら有向辺
	 * @return d t から各頂点への最短距離
	 */
	public static long[] dijkstra(int N, int t, int[] from, int[] to, long[] cost, boolean flag) {
		final int WHITE = 0;
	    final int GRAY = 1;
	    final int BLACK = 2;
	    final long INF = 100000000000000l;
		long[] d = new long[N];
		int[] color = new int[N];
		@SuppressWarnings("unchecked")
		ArrayList<Node>[] adj = new ArrayList[N];
		for(int i = 0; i < N; i++) {
			d[i] = INF;
			color[i] = WHITE;
			adj[i] = new ArrayList<Node>();
		}
		int E = from.length;
		for(int i = 0; i < E; i++) {
			adj[from[i]].add(new Node(to[i], cost[i]));
			if(flag)adj[to[i]].add(new Node(from[i], cost[i]));

		}
		Queue<Node> pq = new PriorityQueue<Node>(new MyComparator());
		d[t] = 0;
		pq.add(new Node(t, 0l));
		while(!pq.isEmpty()) {
			Node f = pq.poll();
			int u = f.id;
			color[u] = BLACK;
			if(d[u] < f.cost) continue;
			for(int j = 0; j < adj[u].size(); j++) {
				int v = adj[u].get(j).id;
				if(color[v] == BLACK) continue;
				if(d[v] > d[u] + adj[u].get(j).cost) {
					d[v] = d[u] + adj[u].get(j).cost;
					pq.add(new Node(v, d[v]));
					color[v] = GRAY;
				}
			}
		}
		return d;
	}
	static class Node{
		int id;
		long cost;
		public Node(int id, long cost) {
			this.id = id;
			this.cost = cost;
		}
	}
	static class MyComparator implements Comparator<Node>{
		@Override
        public int compare(Node v1, Node v2) {
			if(v1.cost < v2.cost) {
				return -1;
			}else if(v1.cost == v2.cost) {
				return 0;
			}else {
				return 1;
			}
		}
	}
}

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

int main() {
    int n, k, num;
    cin >> n >> k;
    num = 1;
    for (int i=0; i<n; i++) {
        if (num<k) num *= 2;
        else num += k;
    }
    cout << num << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1e9+7;

#define vec     vector<int>
#define vecll   vector<ll>
#define vec2    vector<vector<int>>
#define vec2ll  vector<vector<ll>>
#define vpair   vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>

#define rep(i,n)         for(int i=(int)0; i<(int)n; i++)
#define REP(i,m,n)       for(int i=(int)m; i<(int)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define prt(var)         cout << var << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(var)      rep(i,var.size()){cout << var[i] << " ";} cout << "\n"

//----------------------------------------------------------------

int main(void) {
  int n;
  cin >> n;
  ll a[n][3];
  rep(i,n){
    rep(j,3){
      cin >> a[i][j];
    }
  }

  vec2ll dp;
  dp.resize(n,vector<ll>(3));
  rep(i,n){
    rep(j,3){
      dp[i][j]=0;
    }
  }
  dp[0][0]=a[0][0];
  dp[0][1]=a[0][1];
  dp[0][2]=a[0][2];

  REP(i,1,n){
    dp[i][0] = max(dp[i-1][1]+a[i][0], dp[i-1][2]+a[i][0]);
    dp[i][1] = max(dp[i-1][0]+a[i][1], dp[i-1][2]+a[i][1]);
    dp[i][2] = max(dp[i-1][0]+a[i][2], dp[i-1][1]+a[i][2]);
  }

  prt(max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2])));


}


Measured memory_bytes: 8064
#include<bits/stdc++.h>
using namespace std;
#include<bits/stdc++.h> 
using namespace std; 
  
 
string updateString(string S,  
                    string A, string B) 
{ 
  
    int l = A.length(); 
  
  
    for (int i = 0; i + 3 <= S.length(); i++) 
    { 
  
         
        string curr = S.substr(i, i + 3); 
  
       
        if (curr == A)  
        { 
  
           
            string new_string = ""; 
            new_string += S.substr(0, i) + B +  
                          S.substr(i + 3, S.length()); 
            S = new_string; 
            i += 3 - 1; 
        } 
        else
        { 
  
            
            string new_string = ""; 
            new_string += S.substr(0, i) + A +  
                          S.substr(i + l, S.length()); 
            S = new_string; 
            i += l - 1; 
        } 
    } 
  
    
    return S; 
} 


main(){
  string s;
  cin>>s;
  int n=s.size();
 
	string x = "ABC";
	string y = "ARC";
  
  

	
	cout << updateString(s,x,y)<<endl;  
                   

	return 0;
}
  

Measured memory_bytes: 3636
import java.util.*;

public class Main {
    private final static int M = 1000000007;

    private static long solve(int N, int[][] edges) {
        List<Integer>[] adj = new List[N];
        int[] degree = new int[N];

        for (int i = 0; i < N; i++) adj[i] = new ArrayList<>();
        for (int[] edge: edges) {
            adj[edge[0]].add(edge[1]);
            adj[edge[1]].add(edge[0]);
            degree[edge[0]]++;
            degree[edge[1]]++;
        }

        long[] white = new long[N];
        long[] black = new long[N];
        Arrays.fill(white, 1);
        Arrays.fill(black, 1);
        
        boolean[] done = new boolean[N];
        boolean[] added = new boolean[N];
        Queue<Integer> q = new ArrayDeque<>();

        for (int i = 0; i < N; i++)
            if (degree[i] < 2) q.add(i);            

        int node = -1;
        while (!q.isEmpty()) {
            node = q.poll();

            for (int next: adj[node]) {
                if (done[next]) {
                  white[node] = (white[node] * (white[next] + black[next])) % M;
                  black[node] = (black[node] * white[next]) % M;
                } else if (--degree[next] < 2 && !added[next]) {
                  q.add(next);
                  added[next] = true;
                }                
            }
            done[node] = true;            
        }
      
        return  (white[node] + black[node]) % M;
    }

    public static long run(Scanner scanner) {
        int N = scanner.nextInt();
        int[][] edges = new int[N-1][2];
        for (int i=0; i < N-1; i++)
            edges[i] = new int[] { scanner.nextInt()-1, scanner.nextInt()-1};

        return solve(N, edges);
    }

    public static void main(String[] args) {
        try (Scanner scanner = new Scanner(System.in)) {
            System.out.println(run(scanner));
        }
        //Tests.run();
    }
}


Measured memory_bytes: 105372
#!usr/bin/env python3
from collections import defaultdict, deque, Counter, OrderedDict
from bisect import bisect_left, bisect_right
from functools import reduce, lru_cache
from heapq import heappush, heappop, heapify

import itertools
import math, fractions
import sys, copy

def L(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline().rstrip())
def SL(): return list(sys.stdin.readline().rstrip())
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI1(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return [list(x) for x in sys.stdin.readline().split()]
def R(n): return [sys.stdin.readline().strip() for _ in range(n)]
def LR(n): return [L() for _ in range(n)]
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def LIR1(n): return [LI1() for _ in range(n)]
def SLR(n): return [SL() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]

def perm(n, r): return math.factorial(n) // math.factorial(r)
def comb(n, r): return math.factorial(n) // (math.factorial(r) * math.factorial(n-r))

def make_list(n, *args, default=0): return [make_list(*args, default=default) for _ in range(n)] if args else [default for _ in range(n)]

dire = [[1, 0], [0, 1], [-1, 0], [0, -1]]
dire8 = [[1, 0], [1, 1], [0, 1], [-1, 1], [-1, 0], [-1, -1], [0, -1], [1, -1]]
alphabets = "abcdefghijklmnopqrstuvwxyz"
ALPHABETS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
MOD = 1000000007
INF = float("inf")

sys.setrecursionlimit(1000000)

def main():
    N = I()
    A, B, C = sorted(LI()), sorted(LI()), sorted(LI())

    ans = 0
    for bi in B: ans += bisect_left(A, bi) * (N - bisect_right(C, bi))
    
    print(ans)



if __name__ == '__main__':
    main()

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

int main(){

    string s = "YAKI";
    string t; cin >> t;
    //t += "banhei";
    bool flag = true;
    for(int i = 0; i < 4; i++){
        if(s[i] != t[i]){
            flag = false;
        }
    }

    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll ; 
typedef long double ld ;
typedef pair<ll , ll> pll ;

const ll N = 2e5 + 30 , Mod = 1e9 + 7 ;
const ll SQ = 330 ;

int main () {
    ios::sync_with_stdio(0), cin.tie(0) ;
    ll n ;
    cin >> n ;
    string s , t ;
    cin >> s >> t ;
    s = '.' + s ;
    t = '.' + t ;
    for (int i = n ; i >= 0 ; i --) {
    	string s1 = "" , s2 = "" ;
    	for (int j = n - i + 1 ; j  <= n ; j ++) s1 += s[j] ;
    	for (int j = 1 ; j <= i ; j ++) s2 +=t[j] ;
    	if (s1 == s2) {
    		return cout << 2 *n -  i , 0 ;
		}
	}
    return (0) ;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <numeric>
#include <climits>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <utility>
#include <cctype>
#include <iterator>
////////////////////////////////////////////////
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define FOR(i, m, n) for (int i = (int)m; i < (int)n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.end(); itr++)
#define REPe(e, mp) for (auto& e : mp)
#define all(x) x.begin(), x.end()
#define MOD 1000000007  // 1e9+7
using namespace std;
using ll = long long int;
using vecint = vector<int>;
using vecll = vector<ll>;
using vec2int = vector<vector<int>>;
using P = pair<int, int>;
////////////////////////////////////////////////
////////////////////////////////////////////////
int main() {
  ////////////////////////////////////////////////
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ////////////////////////////////////////////////
  int k;
  cin >> k;
  int bmodk = 7;
  vector<bool> seen(k, false);
  REP(i, k + 1) {
    if (bmodk % k == 0) {
      cout << i + 1 << endl;
      return 0;
    } else {
      if (seen[bmodk] == true) {
        cout << -1 << endl;
        return 0;
      } else {
        seen[bmodk] = true;
      }
    }
    bmodk = bmodk * 10 + 7;
    bmodk %= k;
  }
}


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

#define F first
#define S second
#define PB push_back

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef priority_queue<int> HEAP;
typedef priority_queue<int, vector<int>, greater<int> > RHEAP;

const int N = 100010, M = 2 * N, mod = 1e9 + 7;

int n, m, max_d;
int h[N], e[M], ne[M], idx;
int fact[N], infact[N];
vector<int> cnt[N];

void add(int a, int b)
{
	e[idx] = b, ne[idx] = h[a], h[a] = idx ++ ;
}

void dfs(int u, int depth, int fa)
{
	int sum = 0;
	for (int i = h[u]; ~i; i = ne[i])
	{
		int j = e[i];
		if (j == fa) continue;
		
		sum ++ ;
		dfs(j, depth + 1, u);
	}
	cnt[depth].PB(sum);
	max_d = max(max_d, depth);
}

int qp(int a, int b)
{
	int res = 1;
	while (b)
	{
		if (b & 1) res = (LL)res * a % mod;
		a = (LL)a * a % mod;
		b >>= 1;
	}
	return res;
}

void init()
{
	memset(h, -1, sizeof h);
	fact[0] = infact[0] = 1;
	for (int i = 1; i < N; i ++ )
	{
	    fact[i] = (LL)fact[i - 1] * i % mod;
	    infact[i] = (LL)infact[i - 1] * qp(i, mod - 2) % mod;
	}
}

int main()
{
	init();
	scanf("%d%d", &n, &m);
	for (int i = 0; i < n - 1; i ++ )
	{
		int a, b;
		scanf("%d%d", &a, &b);
		add(a, b), add(b, a);
	}
	
	dfs(1, 1, -1);
	
	int res = m;
	for (int i = 1; i < max_d; i ++ )
		for (auto u : cnt[i])
			if (i == 1) res = (LL)res * fact[m - 1] % mod * infact[m - u - 1] % mod;
			else res = (LL)res * fact[m - 2] % mod * infact[m - u - 2] % mod;
	
	printf("%d\n", res);
	return 0;
}

Measured memory_bytes: 12288
def fb(num):
    a, b = 1, 0
    for _ in range(num):
        a, b = a + b, a
    return b



ary = []
flag = 0
n, m = map(int, input().split())
for i in range(m):
  a = int(input())
  ary.append(a)
  if ary[i] == ary[i-1]+1:
    flag = 1
    break
if flag == 1:
  print(0)
else:
  ary.append(n+1)
  count = max(1,ary[0])
  count = fb(count)
  for i in range(1,len(ary)):
    sa = ary[i]-ary[i-1]-1
    if sa == 0:
      pass
    else:
        count*=fb(sa)
  count = count%1000000007
  print(count)
  

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

constexpr int f(int x) {
	return x*(x + 1) / 2;
}

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

	int i = 1;
	for (; i <= n; i++) {
		if (f(i - 1) < n && n <= f(i)) {
			break;
		}
	}

	int m = f(i) - n;
	for (int k = 1; k <= i; k++) {
		if (k != m) {
			cout << k << endl;
		}
	}

	return 0;

}

Measured memory_bytes: 256
using System;
using System.Collections;
class main{
	public static void Main(){
		double r = double.Parse(Console.ReadLine());
		double S, C;
		S = Math.Pow(r, 2) * Math.PI;
		C = 2 * r * Math.PI;
		Console.WriteLine("{0} {1}", S.ToString("F6"), C.ToString("F6"));
	}
}

Measured memory_bytes: 9492
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
typedef long long ll;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=LLONG_MAX;
const int inf=INT_MAX;
const int nmax=3e5+5;
const int mod=1e9+7;
using namespace std;
int n,m,i,idx,j,bit[nmax],ans[nmax];
pair<int,int>a[nmax];
vector<int>d[nmax];
void upd(int i)
{
	for(;i<=m;i+=i&(-i))bit[i]++;
}
int qry(int i)
{
	int rs=0;
	for(;i>=1;i-=i&(-i))rs+=bit[i];
	return rs;
}
int main()
{
    //freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	cin>>n>>m;
	for(i=1;i<=n;i++)cin>>a[i].fr>>a[i].sc;
	sort(a+1,a+n+1);
	for(i=1;i<=m;i++)for(j=i;j<=m;j+=i)d[j].pb(i);
	for(i=1;i<=m;i++)
	{
		while(a[idx+1].fr<=i && idx<n)
		{
			idx++;
			upd(a[idx].sc);
		}
		for(j=0;j<d[i].size();j++)ans[d[i][j]]+=qry(min(m,i+d[i][j]-1))-qry(i-1);
	}
	for(i=1;i<=m;i++)cout<<ans[i]<<endl;
	return 0;
}

Measured memory_bytes: 19584
#include <bits/stdc++.h>
//#include <ext/numeric>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define oo 0x3f3f3f3f
#define OO 0x3f3f3f3f3f3f3f3f
#define popcount(n) __builtin_popcount(n)
#define popcountll(n) __builtin_popcountll(n)

using namespace std;
//using namespace __gnu_cxx;
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const double PI = acos(-1.0), EPS = 1e-6;
const long long inf = 2e12 + 12;
const int MAXN = 300005, MAXM = 45004, Mod = 998244353 , MAXLog = 20;


int main() {
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "rt", stdin);
//    freopen("output.txt", "w", stdout);
#endif
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0), cout.precision(10), cout << fixed;

    int n;
    cin >> n;
    vector<int> val(n);
    for (int i = 0; i < n; ++i) {
        cin >> val[i];
    }
    int ans = 0;
    vector<int> cost(n);
    for (int i = 0; i < n; ++i) {
        cin >> cost[i];
        if (cost[i] < val[i])
            ans += val[i] - cost[i];
    }

    cout << ans << '\n';

    return 0;
}

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

using namespace std;

vector<int> parent;
vector<int> cardinality;
vector<int> height;

void init(int n) {
    parent.assign(n,-1);
    cardinality.assign(n,1);
    height.assign(n,0);
    
    for (int i=0; i<n; i++) {
        parent[i] = i;
    }
}

int find(int x) {
    if (parent[x] == x) {
        return x;
    } else {
        return parent[x] = find(parent[x]);
    }
}

void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) {
        return;
    }
    if (height[x] < height[y]) {
        parent[x] = y;
        cardinality[y] += cardinality[x];
    } else {
        parent[y] = x;
        cardinality[x] += cardinality[y];
        if (height[x] == height[y]) {
            ++height[x];
        }
    }
}

int size(int x) {
    x = find(x);
    return cardinality[x];
}

bool same(int x, int y) {
    return find(x) == find(y);
}

int N,M;
vector<int> P;

int main() {
    cin >> N >> M;
    
    P.assign(N, 0);
    for (int i=0; i<N; i++) {
        cin >> P[i];
        P[i]--;
    }

    init(N+1);
    for (int i=0; i<M; i++) {
        int x,y;
        cin >> x >> y;
        x--; y--;
        unite(x,y);
    }

    int answer = 0;
    for (int i=0; i<N; i++) {
        if (same(i, P[i])) {
            answer++;
        }
    }

    cout << answer << endl;
}


Measured memory_bytes: 1792
#include<stdio.h>

int main(){
  long long int x, a, b;

  scanf("%lld %lld %lld", &x, &a, &b);
  if(a>=b) printf("delicious\n");
  else if(a<b&&b-a<=x) printf("safe\n");
  else if(a<b&&b-a>x) printf("dangerous\n");
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for(int i= 0; i < (n); i++)
using ll= long long int;
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; }
ll mod= 1e9 + 7;



int main(){
  int n;
  cin >>n;
  int a[100001]={};
  ll ans=0;
  rep(i,n){
    int g;
    cin >>g;
    ans+=g;
    a[g]++;
  }
  int q;
  cin >> q;
  rep(i,q){
    int b,c;
    cin >> b >>c;
    ans+=(c-b)*a[b];
    cout << ans << endl;
    int r=a[b];
    a[b]=0;
    a[c]+=r;
  }
}

Measured memory_bytes: 4024
#include<iostream>
using namespace std;
int n,a,t[11],tc,u[11],uc,flg;
int main(){
  cin>>n;
  while(n--){
    flg=t[0]=u[0]=tc=uc=0;
    for(int i=0;i<10;i++){
      cin>>a;
      if(t[tc]>u[uc]&&t[tc]<a){
	t[tc+1]=a;tc++;
      }else if(t[tc]<u[uc]&&u[uc]<a){
	u[uc+1]=a;uc++;
      }else if(t[tc]<a){
	t[tc+1]=a;tc++;
      }else if(u[uc]<a){
	u[uc+1]=a;uc++;
      }else{
	flg=1;
      }
    }
    /*
    for(int i=0;i<tc;i++)cout<<t[i]<<' ';
    cout<<endl;
    for(int i=0;i<uc;i++)cout<<u[i]<<' ';
    cout<<endl;
    */
    cout<<(flg?"NO":"YES")<<endl;
  }

}

Measured memory_bytes: 1152
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();
      	int k = sc.nextInt();
      	int q = sc.nextInt();
      	
      	int[] a = new int[n];
        for(int i = 0; i < a.length; ++i){
          a[i] = k;
        }
      	while(sc.hasNext()){
          int num = sc.nextInt();
          int next = num - 1;
          a[next] += 1;
        }
      	for(int i = 0; i < a.length; ++i){
        	a[i] = a[i] -q;
        	if(a[i] > 0){
        	System.out.println("Yes");
        	}else{
        	 System.out.println("No");
            }
        }
     }
}


Measured memory_bytes: 59244
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
inline ll read(){
	ll re=0,flag=1;char ch=getchar();
	while(ch>'9'||ch<'0'){
		if(ch=='-') flag=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9') re=(re<<1)+(re<<3)+ch-'0',ch=getchar();
	return re*flag;
}
ll n,a[100010];
int main(){
	n=read();ll i,ans1=2,ans2=2,tmp1,tmp2;
	for(i=1;i<=n;i++) a[i]=read();
	for(i=n;i>=1;i--){
		tmp1=(ans1/a[i])*a[i]+((ans1%a[i])!=0)*a[i];
		tmp2=(ans2/a[i])*a[i]+a[i]-1;
		if(tmp1>tmp2){
			printf("-1\n");return 0;
		}
		ans1=tmp1;ans2=tmp2;
//		cout<<"min "<<ans<<endl;
	}
	printf("%lld %lld",ans1,ans2);
}

Measured memory_bytes: 1024
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
/*---------------------DEBUGGING--------------------------------------------*/
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 mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define pcc pair<char,char>
#define F first
#define S second
#define int long long
#define pi 3.141592653589793238462643383279502
#define M  1000000007
#define rep(i,a,n) for(int i=a;i<n;i++)
#define INF 10000000000000
#define N 200005
#define vi vector<int>
#define all(v) v.begin(),v.end()
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>



signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   int n,m;
   cin>>n>>m;
   int a[n];
   rep(i,0,n)cin>>a[i];
   int l=a[0];
   rep(i,1,n)
   {
       int g=__gcd(l,a[i]);
       if(log10(l) + log10(a[i])>18)
       {
           cout<<0<<endl;
           return 0;
       }
       l=((l*a[i])/g);
       

   }
   rep(i,0,n)
   {
       if((l/a[i])%2==0)
       {
           cout<<0<<endl;
           return 0;
       }
   }
   l/=2;
   m/=l;
   if(m & 1LL)
   {
       cout<<(m/2 + 1)<<endl;
   }
   else
    cout<<(m/2)<<endl;



}



Measured memory_bytes: 1024
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.util.LinkedList;
import java.util.Arrays;
import java.util.stream.Collectors;

class Main {
  public static void main(String[] args) {
    try {
        var stdin = new BufferedReader(new InputStreamReader(System.in));
        String line = null;
        
        // 読み込み
        while((line = stdin.readLine()) == null);
        Integer n = Integer.valueOf(line.split(" ")[0]);
        Integer x = Integer.valueOf(line.split(" ")[1]);
        Integer t = Integer.valueOf(line.split(" ")[2]);
        
        Integer result = (n / x + (n % x == 0 ? 0 : 1)) * t;
        
        System.out.println(result);
    } catch(Exception e) {
    }
   
  }
}

Measured memory_bytes: 32676
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=200010;
const ll mod=1e9+7;


int main(){
  int n;
  cin >> n;
  int ans=0;
  vector<int> a(n);
  rep(i,n){
    cin >> a[i];
    ans += a[i];
  }
  if(ans%10!=0){ cout<<ans<<endl; return 0;}
  sort(a.begin(),a.end());
  rep(i,n)if(a[i]%10!=0){
    ans -= a[i];
    break;
  }

  cout << (ans%10!=0?ans:0) << endl;
  return 0;
}

Measured memory_bytes: 256
//#include <ext/pb_ds/assoc_container.hpp>
#include <bits/stdc++.h>
using namespace std;
//using namespace __gnu_pbds;
//template <class c, class cmp = less<c> > using ordered_set = tree<c, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL); 
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 
#endif
template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}
template <typename T,typename U>pair<T,U> operator+(const pair<T,U> & l,const std::pair<T,U> & r) { return {l.first+r.first,l.second+r.second};}
typedef long long int ll;
const ll mod =1e9+7;
const int maxn = 2000005;
#define endl '\n'
#define int ll
#define all(x) (x).begin(),(x).end()

int32_t main()
{ 
  IOS
    
  int h,w,n;
  cin>>h>>w>>n;
  cout<<min((n+w-1)/w,(n+h-1)/h)<<endl;

  
  

}
 

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int i,n;
    char ch;
    int test[26];
 
    for(i=0;i<26;i++)
        {
            test[i]=0;
        }
        while(scanf("%c",&ch)!=EOF)
        {
            if(ch>='A' && ch<='Z')
            {
                n = ch-'A';
                test[n]++;
            }
            else if(ch>='a' && ch<='z' )
            {
                n = ch-'a';
                test[n]++;
            }
        }
        for(i=0;i<26;i++)
        {
            printf("%c : %d\n",i+'a',test[i]);
        }
return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<P> VP;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e18+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define dbgmint(n,arr) rep(i,n){cerr<<arr[i].x<<" ";}cerr<<endl;
#define out(a) cout<<a<<endl
#define out2(a,b) cout<<a<<" "<<b<<endl
#define vout(v) rep(i,v.size()){cout<<v[i]<<" ";}cout<<endl
#define Uniq(v) v.erase(unique(v.begin(), v.end()), v.end())
#define fi first
#define se second

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

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,v.size())i>>v[j];return i;}

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

ll dp[MAX][4];
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<std::setprecision(10);

    ll n;
    cin>>n;

    Vec a(n);
    Vec b(n);
    Vec c(n);
    memset(dp,0, sizeof(dp));
    rep(i,n){
        cin>>a[i]>>b[i]>>c[i];
    }
    rep(i,n){
        chmax(dp[i+1][0],dp[i][1]+a[i]);
        chmax(dp[i+1][0],dp[i][2]+a[i]);
        chmax(dp[i+1][1],dp[i][0]+b[i]);
        chmax(dp[i+1][1],dp[i][2]+b[i]);
        chmax(dp[i+1][2],dp[i][1]+c[i]);
        chmax(dp[i+1][2],dp[i][0]+c[i]);
    }
    ll ans=0;
    rep(j,3){
        chmax(ans,dp[n][j]);
    }
    cout<<ans<<endl;
    return  0;
}


Measured memory_bytes: 5760