akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
using namespace std;
int main() {
    int n=0,f=0,k=0,c=0,d=0,l=0,i=0;
    cin >> n;
    string a[n],out;
    int b[n][26],e[26];
//配列bのリセット(デバッグ用)
    for(i = 0; i < n; i++){
        for(int f = 0; f < 26; f++){
            b[i][f] = 0;
            e[f]=50;
        }}
//S_nへの文字列の代入
    for(i = 0; i < n; i++){
        cin >> a[i];
    }
//S_nからの文字情報の取得
    for(f=0;f<n;f++){
        c = a[f].size();
        for(int l=0;l<c;l++){
            d = (int)(a[f].at(l)) - (int)'a';
            b[f][d] += 1;
        }}
//S_nにおける各配列の最小の取得
    for (i=0; i<26; i++) {
        for (l=0;l<n;l++){
            if (e[i] >= b[l][i]) {
                e[i] = b[l][i];
            }}}
//結果文字列の作成
        for(l=0;l<26;l++){
            for (k=0;k<e[l];k++) {
                out.push_back(97+l);
            }
        }
//結果文字列の出力
   cout << out <<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define cout16 cout << setprecision(16) 
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using P = std::pair<int,int>;
using vp = std::vector<P>;
using namespace std;
#define INF 1001001001
#define LL_INF 1001001001001001001

int main(void) {
	int a,p; cin >> a >> p;
	p += a*3;
	int ans = p/2;
	cout << ans << endl;
}




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

#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define ALL(v) v.begin(), v.end()
#define SZ(x) ((ll)(x).size())

const double PI  = acos(-1.0);
const double EPS = 1e-9;
const ll INF = 1e9+10;
const ll mod = 998244353;
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; }
#define print(x) cerr << #x << " is " << x << endl;
//#define print(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl; 



int main()
{
    int N;
    
    cin >> N;
    queue<int> q;
    vector<int> A(N, 0), B(N, 0), C(N, 0);
    
    ll ans = 0;
    rep(i, N - 1){
        int a;
        cin >> A[i + 1];
        A[i + 1]--;
        C[A[i + 1]]++;
    }
#if 0
    rep(i, N){
        if (C[i] == 0){
            q.push(i);
            B[i] = 0;
            B[A[i]] += 1;
        }
    }
    while(q.size()){
        int x = q.front(); q.pop();
        //cout << "x = " << x << endl;
        q.push(A[x]);
        B[A[x]] += B[x];
        if (x == 0)break;
    }
#endif
    rep(i, N)
        cout << C[i] << endl;
    return 0;
}


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

int a,b;
int main(){
  cin>>a>>b;
  if(a<=0&&b>=0)cout<<"Zero";
  else if(a<0 && (a+b)%2==0) cout<<"Negative";
  else cout<<"Positive";
  cout<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main
{
	public static void main ( String[] args ) {
		Scanner sc = new Scanner ( System.in );

		int n = 0;
		n = sc.nextInt ();

		int[] a = new int[ n ];
		
		for ( int i = 0; i < n; i++ ) {
			a[ i ] = sc.nextInt ();
		}

		for ( int j = n - 1; 0 <= j; j-- ) {
			System.out.print ( a[ j ] );
			if ( j == 0 ) {
				break;
			}
			System.out.print ( " " );
		}
		System.out.println ();
	}
}

Measured memory_bytes: 26232
import sys
def p(s):
  sys.stderr.write(str(s)+"\n")

a=int(input())
b=int(input())
c=int(input())
x=int(input())

ans=0

for i in range(a+1):
  for j in range(b+1):
    for k in range(c+1):
      if x==( (500*i)+(100*j)+(50*k) ):
        ans+=1

print(ans)


Measured memory_bytes: 3060
N = input()
v = [int(i) for i in input().split() ]

v_new = sorted(v)

while len(v_new) > 1:
 	v_new[0] = ((v_new[0] + v_new[1]) / 2)
 	
 	for i in range(len(v_new) - 2):
 		v_new[ i + 1 ] = v_new[ i + 2 ]

 	#末尾 を削除
 	del v_new[-1]	

print(v_new[0])
 		

Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <unordered_map>
#include <map>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <deque>
#include <cmath>
#include <stack>
#include <queue>
#include <string>
#include <iomanip>
#include <cstring>
#include <climits>
#include <cstdio>

#define nl '\n'

using namespace std;

string s;

int main(){

    cin >> s;

    if(s[0] == s[1] && s[1] == s[2]){
        cout << "No";
    } else {
        cout << "Yes";
    }






}
 
//g++ -std=c++14 comp.cpp -o c && c.exe
//g++ -std=c++14 comp.cpp -o c; ./c.exe
//g++ -std=c++14 comp.cpp && ./a.out


//Surely this is going to AC

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int  main()
{
    int n,ara[100],i,c=0;
    cin>>n;
    for(i=1;i<=n;i++){
        cin>>ara[i];
    }
    for(i=1;i<=n;i++){
        if(i%2==1&&ara[i]%2==1)
            c++;
    }
    cout<<c<<endl;
    return 0;
}


Measured memory_bytes: 3620
-- FileName   : 164b
-- CreatedDate: 2020-04-26 21:05:13

import Control.Monad
import Data.List

fight a b c d
   | c - b <= 0 = "Yes"
   | a - d <= 0 = "No"
   | otherwise  = fight (a-d) b (c-b) d

main = do
   [a,b,c,d] <- getIntList
   putStrLn $ fight a b c d


--------------------------------------------
getIntList        = map (read :: String -> Int) . words <$> getLine
getIntegerList    = map (read :: String -> Integer) . words <$> getLine
getIntegerListN m = map (read :: String -> Integer) <$> replicateM m getLine


base :: Integer
base = 1000000007

plus :: Integer -> Integer -> Integer
plus a b = (a+b) `mod` base

times :: Integer -> Integer -> Integer
times a b = a * b `mod` base

minus :: Integer -> Integer -> Integer
minus a b
   | a < b     = a-b + base
   | otherwise = a-b

power :: Integer -> Integer -> Integer
power n k
   | k == 0         = 1
   | k `mod` 2 == 0 = power (times n n) (k`div`2)
   | otherwise      = times n $! power n (k-1)

inv :: Integer -> Integer
inv n = power n $ base - 2

binom :: Integer -> Integer -> Integer
binom n m
   | (n-m) < m = times (foldr times 1 [m+1..n]) $ inv $ foldr times 1 [1..n-m]
   | otherwise = times (foldr times 1 [n-m+1..n]) $ inv $ foldr times 1 [1..m]


Measured memory_bytes: 3892
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define endl '\n'
typedef long long ll;
typedef pair<int,int> pii;

int main(){
	int n, ans=1; cin>>n;
	int alt[n]; 
	for (int i = 0; i<n; i++){
		cin>>alt[i];
	}
	int m = alt[0];
	for(int i=1; i<n; i++){
		if(alt[i]>=m){
			ans++;
			m=alt[i];
		}
	}
	cout<<ans<<endl;
}


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

#define REP(i, n) for (int i = 0; i < n; i++)
#define INF 1000000000

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef long double ld;

//ある値がvector内の要素に含まれているか否か判定する
int vector_finder(std::vector<int> 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;
  }
}

struct edge_t {
  int dest;
  int weight;
};

struct vertex_t {
  vector<edge_t> edges;
  vector<int> weight;

  // for dijkstra
  bool done; // confirm or not
  int cost;  // now cost
  int from;

  bool operator<(const vertex_t &another) const { // priority --> min
    return another.cost < cost;                   // order(cost)
  }

  bool operator>(const vertex_t &another) const { // priority --> min
    return another.cost > cost;                   // order(cost)
  }

  bool operator==(const vertex_t &another) const {
    return another.cost == cost; // order(cost)
  }

  vertex_t() {
    cost = INF;
    done = false;
  }
};

int bellman_ford(vector<vertex_t> &graph, int size, int start) {
  int i, j, k, count = 0;
  bool flag = false;
  graph[start].cost = 0;
  REP(i, size) {
    REP(j, size) {
      vertex_t cur = graph[j];
      for (edge_t edge : cur.edges) {
        if (cur.cost + edge.weight < graph[edge.dest].cost) {
          if (i == size - 1)
            flag = true;
          graph[edge.dest].cost = cur.cost + edge.weight;
        }
      }
    }
  }
  if (flag) {
    return 1;
  } else {
    return 0;
  }
}

class tree_t {
  public:
  bool is_leaf;
  tree_t *right;
  tree_t *left;

  tree_t() {
    is_leaf = false;
    right = NULL;
    left = NULL;
  }
};

vector<string> splitstr(const string &s, char delim) {
  vector<string> elems;
  string item;
  for (char ch : s) {
    if (ch == delim) {
      if (!item.empty())
        elems.push_back(item);
      item.clear();
    } else {
      item += ch;
    }
  }
  if (!item.empty())
    elems.push_back(item);
  return elems;
}

unsigned getDigitNum(unsigned num) {
  unsigned digit = 0;
  while (num != 0) {
    num /= 10;
    digit++;
  }
  return digit;
}

////////////////////////// let's code! /////////////////////////////

int i, j, k;

///// variables frequent to use /////

int main() {
  int K, X;

  cin >> K >> X;

  int min, max;

  if (-1000000 > X - K) {
    min = -1000000;
    max = X + K - 1;
  } else if (1000000 < X + K) {
    min = X - K;
    max = 1000000;
  } else {
    min = X - K + 1;
    max = X + K;
  }

  for (i = min; i < max; i++) {
    cout << i << " ";
  }
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

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

    ll N;
    cin >> N;
    vector<ll> A(N);
    REP(i, N) cin >> A[i];

    sort(A.begin(), A.end());
    ll tmp = 0;
    ll res = 0;
    REP(i, N-1){
    	tmp += A[i];
    	if(2*tmp < A[i+1]) res = i+1;
    }
    cout << N - res << endl;
    return 0;
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC147B
{
    class Program
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();
            int l = S.Length;
            int ans = 0;
            for(int i = 0; i < l / 2; i++)
            {
                if (S[i].ToString() != S[l - 1 - i].ToString())
                {
                    ans += 1;
                }
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 25792
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}


int const INF = 1001001001;


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

int n,m;
cin >> n >> m;
vi x(m);
rep(i,m) cin >> x[i];
sort(all(x));

if(n >= m) {
    cout << 0 << endl;
    return 0;
}

vi dist(m-1);
rep(i,m-1) dist[i] = x[i+1] - x[i];
sort(all(dist));
int ans = 0;
rep(i,m-n) ans += dist[i];
cout << ans << endl;



return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <bits/stdc++.h>
#define ll long long int 
#define MOD 1e9 + 7 
#define INF 1<<30
using namespace std ;
 
 
int main() {
        ios::sync_with_stdio(false);
        int n ;
        cin >> n;
        long sum = 0 ;
        long a , b ;
        for(int i = 0 ; i < n; i++) {
                cin >> a >> b ;
                sum += ( b - a + 1 ) ;
        }
        cout << sum << endl ;
 
}
                                                                      


Measured memory_bytes: 256
a,b=map(int,input().split())
s=input()
keep=0
for i in range(0,a):
  if not 48<=ord(s[i])<=57:
    keep=1
    break
if not s[a]=="-":
  keep=1
for j in range(a+1,a+b+1):
  if not 48<=ord(s[j])<=57:
    keep=1
    break
print(["No","Yes"][keep==0])

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

int main() {
    rep(i,3010){
        int a,b; cin >> a >> b;
        if(a==0&&b==0)break;
        else if(a>b)
        cout << b << " " << a << endl;
        else 
        cout << a << " " << b << endl;
    }

    return 0;
}


Measured memory_bytes: 3004
W=87,i,n;char a[100002],s[999999];f(x,y){*a=x;a[1]=y;for(i=0;++i<=n;)a[i+1]=a[i]==W^a[i-1]==W^s[i]=='o'?83:W;if(!strncmp(a,a+n,2))a[n]=0,puts(a),exit(0);}main(){scanf("%d%s",&n,&s);strncat(s,s,n);f(83,83);f(83,W);f(W,83);f(W,W);puts("-1");}

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

int main() {
int n,ans=0;
  cin >> n;
vector<int> a(n);
for(int i=0; i<n; i++){
cin >> a.at(i);
}for(int i=1; i<n-1; i++){
  if((a.at(i-1)<a.at(i)&&a.at(i)<a.at(i+1))||(a.at(i-1)>a.at(i)&&a.at(i)>a.at(i+1))){
  ans++;
  }
}
cout << ans << endl;
}


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

using namespace std;

#define LL long long
#define int long long
#define fi first
#define se second
#define double long double
#define pll pair<LL, LL>
#define pii pair<LL, LL>
#define fastio ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);

constexpr int N = 2e5+5;
constexpr int M = 1e9+7;

// #define DEBUG 1  //调试开关
struct IO {
#define MAXSIZE (1 << 20)
#define isdigit(x) (x >= '0' && x <= '9')
    char buf[MAXSIZE], *p1, *p2;
    char pbuf[MAXSIZE], *pp;

    IO() : p1(buf), p2(buf), pp(pbuf) {}
    ~IO() { fwrite(pbuf, 1, pp - pbuf, stdout); }

    inline char gc() {
        if (p1 == p2) p2 = (p1 = buf) + fread(buf, 1, MAXSIZE, stdin);
        return p1 == p2 ? ' ' : *p1++;
    }
    inline bool blank(char ch) {
        return ch == ' ' || ch == '\n' || ch == '\r' || ch == '\t';
    }
    template <class T>
    inline void read(T &x) {
    double tmp = 1;
    bool sign = 0;
    x = 0;
    char ch = gc();
    for (; !isdigit(ch); ch = gc())
        if (ch == '-') sign = 1;
    for (; isdigit(ch); ch = gc()) x = x * 10 + (ch - '0');
    if (ch == '.')
        for (ch = gc(); isdigit(ch); ch = gc())
        tmp /= 10.0, x += tmp * (ch - '0');
    if (sign) x = -x;
    }
    inline void read(char *s) {
    char ch = gc();
    for (; blank(ch); ch = gc())
        ;
    for (; !blank(ch); ch = gc()) *s++ = ch;
    *s = 0;
    }
    inline void read(char &c) {
    for (c = gc(); blank(c); c = gc())
        ;
    }
    inline void push(const char &c) {
    #if DEBUG  //调试，可显示字符
    putchar(c);
    #else
    if (pp - pbuf == MAXSIZE) fwrite(pbuf, 1, MAXSIZE, stdout), pp = pbuf;
    *pp++ = c;
    #endif
    }
    template <class T>
    inline void write(T x) {
    if (x < 0) x = -x, push('-');  // 负数输出
    static T sta[35];
    T top = 0;
    do {
        sta[top++] = x % 10, x /= 10;
    } while (x);
    while (top) push(sta[--top] + '0');
    }
    template <class T>
    inline void write(T x, char lastChar) {
    write(x), push(lastChar);
    }
} io;

int n;
int a[N];
vector<int> g[N];
int dp[N];
int fa[N];
int sz[N];
int ans[N];
int fact[N];

int kpow(int a, int b) {
    int c = 1;
    while (b) {
        if (b & 1) c = c * a % M;
        a = a * a % M;
        b >>= 1;
    }
    return c;
}

inline int inv(int x) {
    return kpow(x, M-2);
}

void init() {
    for (int i = 1; i < N; i++)
        fact[i] = fact[i-1] * i % M;
}

void dfs(int u, int p) {
    fa[u] = p;
    sz[u] = 1;
    for (int v: g[u]) {
        if (v == p) continue;
        dfs(v, u);
        sz[u] += sz[v];
    }
}

void dfs2(int u) {
    for (int v: g[u]) {
        if (v == fa[u]) continue;
        ans[v] = ans[u] * sz[v] % M * inv(n - sz[v]) % M;
        dfs2(v);
    }
}

signed main() {
    fastio;
    init();
    cin >> n;
    for (int i = 1; i <= n-1; i++) {
        int u, v;
        cin >> u >> v;
        g[u].push_back(v), g[v].push_back(u);
    }
    dfs(1, 0);
    ans[1] = 1;
    for (int i = 1; i <= n; i++) {
        ans[1] = ans[1] * i % M * inv(sz[i]) % M;
    }
    dfs2(1);
    for (int i = 1; i <= n; i++) {
        cout << ans[i] << endl;
    }
    return 0;
}

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

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			n = scanner.nextInt();
			u = scanner.nextInt();
			if ((n | u) == 0)
				break;
			need = new int[n];
			int all = 0;
			unit = new int[n];
			for (int i = 0; i < n; i++) {
				unit[i] = scanner.nextInt();
				all += unit[i];
				int k = scanner.nextInt();
				for (int j = 0; j < k; j++) {
					int x = scanner.nextInt();
					need[i] |= (1 << x);
				}
			}
			if (all == u) {
				System.out.println(n);
				continue;
			}
			ans = n;
			v = new boolean[1 << n];
			slove(0, 0, 0);
			System.out.println(ans);
		}
	}

	private void slove(int bit, int one, int have) {
		if (ans == one)
			return;
		if (have >= u) {
			ans = one;
			return;
		}
		if (ans - 1 == one)
			return;

		for (int i = 0; i < n; i++) {
			int a = bit | (1 << i);
			if (v[a] || (bit | need[i]) != bit)
				continue;
			v[a] = true;
			slove(a, one + 1, have + unit[i]);
		}
	}

	int n, u;
	int[] need, unit;
	int ans;
	boolean[] v;
}

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

int main() {
    int A, B;
    cin >> A >> B; 
//    int ans = A/0.08;
//    if (floor(ans*0.1)==B) cout << ans;
    for (int i=1; i<1250; i++) {
        if (floor(i*0.08)==A && floor(i*0.1)==B) {
            cout << i;
            return 0;
        }
    }
    cout << -1;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

// struct node{
//   int data;
//   node *l, *r;
// };

// node *new_node(int in){
//   node *n = new node;
//   n->data = in;
//   n->l = NULL;
//   n->r = NULL;
//   return n;
// }

// node *dfs(int k, vector<int> &pr, vector<int> &in, int prl, int prr, int inl, int inr){
//   cerr << k << endl;
//   if(inr <= inl) return NULL;
//   node *ret = new_node(k);
//   int lprr, linr, rprl, rinl;
//   bool m = false;
//   int co = 0;
//   rep2(i, inl, inr){
//     if(in.at(i) == k){
//       linr = i;
//       rinl = i + 1;
//       break;
//     }
//     co++;
//   }
//   lprr = prl + co;
//   rprl = lprr + 1;
//   int lk = pr.at(prl), rk = pr.at(rprl);
//   ret->l = dfs(lk, pr, in, prl+1, lprr, inl, linr);
//   ret->r = dfs(rk, pr, in, rprl+1, prr, rinl, inr);
//   return ret;
// }

// void print_post_order(node *root){
//   if(root->l != NULL)print_post_order(root->l);
//   if(root->r != NULL)print_post_order(root->r);
//   cout << root->data << endl;
// }

int fd(vector<int> &in, int c){
  int ret = -1;
  rep(i, in.size()){
    if(in.at(i) == c){
      ret = i;
      break;
    }
  }
  return ret;
}

void rec(int l, int r, vector<int> &pr, vector<int> &in){
  static int prindex = 0;
  static bool sp = false;
  if(r <= l) return ;
  int c = pr.at(prindex++);
  int m = fd(in, c);
  rec(l, m, pr, in);
  rec(m+1, r, pr, in);
  if(sp == true){
    cout << " ";
  }else{
    sp = true;
  }
  cout << c;
}

int main(){
  int n;
  cin >> n;
  vector<int> pr(n), in(n);
  rep(i, n){
    int a;
    cin >> a;
    pr.at(i) = a;
  }
  rep(i, n){
    int a;
    cin >> a;
    in.at(i) = a;
  }

  rec(0, n, pr, in);
  cout << endl;

  return 0;
}


Measured memory_bytes: 3096
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE TypeFamilies #-}
import           Data.Maybe
import           Data.Int
import           Data.List
import           Data.Char
  -- import qualified Data.Vector.Unboxing as VU
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.ByteString.Char8 as BS
import           Data.List (scanl')
import           Data.IORef
import           Control.Monad
import           Control.Monad.ST
import           Control.Monad.State.Strict
import           Control.Applicative

readInt = BS.readInt . BS.dropWhile isSpace
getVector f = VU.unfoldr f <$> BS.getLine
getIntVector = getVector readInt
getBSVector = getVector BS.uncons

solve n as = do
  vec <- VUM.replicate n 0

  VU.forM as $ \a -> do
    VUM.modify vec (+1) (a-1)

  return vec

main = do
  n <- readLn :: IO Int
  as <- getIntVector

  vec <- solve n as :: IO (VUM.IOVector Int)
  forM_ [0..n-1] $ \i -> do
    print =<< VUM.read vec i


Measured memory_bytes: 9692
s = gets.chomp.to_s

unless s[0] == "A" && s[2..-2].count("C") == 1 && s[-1] != "C"
    puts "WA"
    exit
end

(1..(s.size - 1)).each do |i|
    unless s[i].downcase == s[i] || s[i] == "C"
        puts "WA"
        exit
    end
end

puts "AC"


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define FOR(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
const long long dx[4]={1,0,-1,0};
const long long dy[4]={0,1,0,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

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

    int res=a[0];
    FOR(i,1,n){
        res=gcd(res,a[i]);
    }  
    cout<<res<<endl;
    //cout<<gcd(10,40)<<endl; 
}

Measured memory_bytes: 1024
a,b,c,x,y=map(int,input().split())
ans1=a*x+b*y
ans2=0
ans3=max(x,y)*2*c

if x==y:
    ans2=c*x*2
elif x>y:
    ans2=c*y*2
    ans2+=a*(x-y)
else:
    ans2=c*x*2
    ans2+=b*(y-x)

print(min(ans1,ans2,ans3))

Measured memory_bytes: 3064
using System;

namespace _1_5_A
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                string[] str = Console.ReadLine().Split(' ');
                int a = int.Parse(str[0]);
                int b = int.Parse(str[1]);
                if (a == 0 || b == 0)
                {
                    break;
                }
                for (int i = 0; i < a; i += 1)
                {
                    for (int j = 0; j < b; j += 1)
                    {
                        Console.Write("#");
                    }
                    Console.Write("\n");
                }
                Console.Write("\n");
            }
        }
    }
}

Measured memory_bytes: 8836
#include<complex>
#include<vector>
#include<iostream>
#include<cstdio>
#include<set>
#include<map>
#include<cassert>

#define TYPE_A 1
#define TYPE_B 2

using namespace std;

typedef pair<int,int> ipoint;

#define foreach(it,o) for(__typeof((o).begin()) it=(o).begin();it!=(o).end();++it)

int main(){
  while(true){
    int ans = 0;
    map<int, set<int> > Xa;
    map<int, set<int> > Xb;
    
    int AN,BN,R;
    scanf("%d%d%d", &AN, &BN, &R);

    if( AN == 0 && BN == 0 ) break;

    for(int i = 0; i < AN; ++i){
      int xa,ya;
      scanf("%d%d",&xa,&ya);
      Xa[xa].insert(ya);
    }

    for(int i = 0; i < BN; ++i){
      int xb,yb;
      scanf("%d%d",&xb,&yb);
      Xb[xb].insert(yb);
    }

    foreach(itxa,Xa){
      foreach(itxas,itxa->second){
	int X=itxa->first;
	int Y=*itxas;
	int stx = X-4*R-1;
	int edx = X+4*R+1;
	int sty = Y-4*R-1;
	int edy = Y+4*R+1;
	
	set<int> tset;
	map<int, set<int> >::iterator itstx = Xb.lower_bound( stx );
	map<int, set<int> >::iterator itedx = Xb.upper_bound( edx );
	
	for(map<int,set<int> >::iterator itm = itstx; itm != itedx; ++itm ){
	  //if( 0 <= itm->first && itm->first < 10000 ){
	    int dx = X-itm->first;
	    dx *= dx;
	    set<int>::iterator itsty = itm->second.lower_bound( sty );
	    set<int>::iterator itedy = itm->second.upper_bound( edy );
	    
	    for(set<int>::iterator its=itsty;its!=itedy;++its){
	      int dy = Y-*its;
	      int d = dx+dy*dy;// - 4*R*R;
	      if( d <= 16*R*R ) ++ans;
	    }
	    //}
	}
      }
    }

    printf("%d\n", ans);
  }
  return 0;
}

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

int main(){
  int a[4],d;
  cin>>a[0]>>a[1]>>a[2]>>d;
  sort(a,a+3);
  for(int i=0;i<d;i++){
    a[2]*=2;
  }
  cout<<a[0]+a[1]+a[2]<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int n,m,a[1000000],ans,x,y;
int main(){
        scanf("%d%d",&n,&m);
        for(int i=1;i<=n;i++){
                scanf("%d",&a[i]);
        }
        ans=1000000000;
        for(int i=1;i<=n-m+1;i++){
                x=a[i];
                y=a[i+m-1];
                if(x>0){
                        ans=min(ans,y);
                        continue;
                }
                if(y<0){
                        ans=min(ans,-x);
                        continue;
                }
                ans=min(ans,y-2*x);
                ans=min(ans,-x+2*y);
        }
        printf("%d",ans);
}

Measured memory_bytes: 640
// When you are hungry for something and you're determined and you're focused 
// and you're committed to something it's hard to surrender, isn't it?

#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define ll long long 
#define int ll
#define mod 1000000007
#define mod1 1000000006
#define modi 998244353
#define setbit(x) __builtin_popcount(x)
#define ff first
#define ss second
#define pb push_back
vector<ll> vi[300005];
int color[100005];
ll pa[500005];
ll si[500005];
#define pb push_back
bool visi[1000005]={false};
bool is[100005];
ll fac[10000001];
ll prime[400005];
ll bit[100005];
const long double eps = 1.0e-14;      // allowable error
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL);
 
 
void fact(){
    fac[0]=1;
    for(int i=1;i<=10000000;i++){
        fac[i]=(fac[i-1]*i)%mod;
    }
    return ;
}
void sieve(){
    prime[0]=0;
    prime[1]=0;
    for(int i=2;i<400005;i++){
        prime[i]=1;
    }
    for(int i=2;i*i<400005;i++){
        if(prime[i]==1){
            for(int j=i*i;j<400005;j+=i){
                prime[j]=0;
            }
        }
    }
    
}
 
ll power(ll n , ll p ){
    if(p==0)
        return 1;
    
    ll res = power((n*n)%mod,p/2);
    if(p%2==1)
        res = (n*res)%mod;
    
    return res;
}
 
 
void upd(ll i,ll val,ll n) {
    for(;i<=n;i+=i&(-i))
        bit[i]+=val;
}
 
ll qry(ll i) {
    ll sum=0;
    for(;i>0;i-=i&(-i))
        sum+=bit[i];
    return sum;
}
 
 
ll fin(ll u) {
    if(pa[u]==u)
        return u;
    return fin(pa[u]);
}
 
void uni(ll u,ll v) {
    ll p1=fin(u);
    ll p2=fin(v);
    if(p1==p2)
        return;
    if(si[p1]<si[p2])
        swap(p1,p2);
    si[p1]+=si[p2];
    pa[p2]=p1;
    return;
}
 
int32_t main() {
    fio

    int n,dr;
    cin >> n >> dr;
    
    if(n >= 10) {
        cout << dr;
    }
    else {
        cout << dr + (100*(10-n)) << endl;
    }
    

	return 0;
    
}

Measured memory_bytes: 8832
dic = {"AC": 0, "WA": 0, "TLE": 0, "RE": 0}
for _ in range(int(input())):
  res = input()
  dic[res] += 1

print("AC x",dic["AC"])
print("WA x",dic["WA"])
print("TLE x",dic["TLE"])
print("RE x",dic["RE"])
  

Measured memory_bytes: 9148
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n,k = LI()
    a = LI()
    l = k + 1

    y = [1] * (a[-1]+1) + [0] * (l-a[-1]-1)

    for i in range(n-2,-1,-1):
        z = [None] * l
        s = 0
        c = a[i] + 1
        for j in range(c):
            z[j] = s = (s + y[j]) % mod

        for j in range(c,l):
            z[j] = s = (s + y[j] - y[j-c]) % mod

        y = z

    return (y[-1] + mod) % mod


print(main())


Measured memory_bytes: 13488
n=int(input())
h=[int(i) for i in input().split()]
c=[]
for i in range(n-1):
    c.append(1) if h[i]>=h[i+1] else c.append(0)
a=0
cnt=0
for i in range(n-1):
    if c[i]==0:
        a=max(a,cnt)
        cnt=0
    elif i==n-2:
        cnt+=1
        a=max(a,cnt)
    else:
        cnt+=1
print(a)

Measured memory_bytes: 64228
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(){
  ll n;
  cin >> n;
  n=n%10;
  if(n==3){
    cout << "bon";
  }
  if((n==0)||(n==1)||(n==6)||(n==8)){
    cout << "pon";
  }
  if((n==2)||(n==4)||(n==5)||(n==7)||(n==9)){
    cout << "hon";
  }
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;

#define sync std::ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define loopi(n) for(int i=0;i<n;i++)
#define loopj(n) for(int j=0;j<n;j++)
#define loop(a,b,c) for(int i=a;i<=b;i=i+c)

#define     deb(x)      cout<<#x<<"="<<x<<endl
#define     all(x)      (x).begin(),(x).end()
#define     reset(a)    memset(a,0,sizeof(a))
#define     sz(x)       ((int)(x.size()))
#define     pb          push_back
#define     pf          push_front
#define     pob	        pop_back
#define     pof         pop_front
#define     ins         insert
#define     F           first
#define     S           second
#define     mkp         make_pair
#define     mkt         make_tuple
#define     bitcount(x) __builtin_popcountll(x)
#define     gcd(a,b)    (__gcd(a,b))
#define     lcm(a,b)    ((a*b)/gcd(a,b))
#define PI 3.1415926535897932384626
 
const int mod = 1e9+7;

//============================================//

void solve()
{
	int n;
	cin>>n;
	ll a[n];
	loopi(n)	cin>>a[i];
	
	ll ans=0,sum=0;
	loopi(n)
		sum=sum+a[i];
		
	loopi(n-1)
	{
		sum=sum-a[i];
		ans=(ans%mod+((a[i]%mod)*(sum%mod))%mod)%mod;
	}
	cout<<ans;
}
int main() 
{
	sync;

	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
		cout<<endl;
	}
}

Measured memory_bytes: 5196
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  int i;
  if(a<=b){
    for(i=0;i<b;i++){
      cout<<a;
    }
  }
  else{
    for(i=0;i<a;i++){
      cout<<b;
    }
  }
  return 0;
}

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

int main(){
	int a,b;cin>>a>>b;
	bool flag = false;
	for(int i=1;i<=100000;i++){
		int c = i * 0.08;
		int d= i * 0.1;
		if(c ==a && b== d){
			cout<<i<<endl;
			flag = true;
			break;
		}
	}
	if(!flag)cout<<"-1"<<endl;
}

Measured memory_bytes: 256
N=int(input())
T,A=map(int,input().split())
H=[int(i) for i in input().split()]
MIN=10000
num=0
for s in H:
    if (abs(A-(T-(s*0.006))))<MIN:
        MIN=(abs(A-(T-(s*0.006))))
        num=(H.index(s)+1)
    else:
        continue
print(num)

Measured memory_bytes: 3064
import numpy as np

H, N = map(int, input().split())
AB = np.array([list(map(int, input().split())) for i in range(N)])
A = AB[:, 0]
B = AB[:, 1]

# インデックスはライフ 値はそれを以下にする最小MP
dp = np.array([10**10 for i in range(H+1)], dtype=int)
# dp = np.array([np.inf for i in range(H+1)], dtype=int)
dp[0] = 0

for i in range(1, H+1):
    # print(np.maximum(i-A, 0))
    dp[i] = min(dp[np.maximum(i-A, 0)] + B)

print(dp[-1])

Measured memory_bytes: 14696
N, K = gets.split.map(&:to_i)
MOD = 10**9 + 7

rn = Math.sqrt(N).to_i
a = [1] * rn
i = rn + 1
while i <= N
  j = N/(N/i) + 1
  a << j - i
  i = j
end
c = a.size
dp = Array.new(K + 1){Array.new(c + 1, 0)}
dp[0][0] = 1
(0 ... K).each do |k|
  s = [0]
  (0 ... c).each{|j| s[j + 1] = (s[j] + dp[k][j]) % MOD}
  (0 ... c).each{|j| dp[k + 1][j] = (s[c - j] * a[j]) % MOD}
end
puts dp[K].inject(0){|s, x| (s + x) % MOD}

Measured memory_bytes: 79224
// reference: https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

use std::cmp::Ordering;
#[derive(Eq, PartialEq, Clone, Debug)]
pub struct Rev<T>(pub T);

impl<T: PartialOrd> PartialOrd for Rev<T> {
    fn partial_cmp(&self, other: &Rev<T>) -> Option<Ordering> {
        other.0.partial_cmp(&self.0)
    }
}

impl<T: Ord> Ord for Rev<T> {
    fn cmp(&self, other: &Rev<T>) -> Ordering {
        other.0.cmp(&self.0)
    }
}

impl<T: Copy> Copy for Rev<T> {}

fn main() {
    input! {
        n: usize,
        sp: [(String, usize); n]
    }

    let mut sp = (1..n + 1)
        .zip(sp.into_iter())
        .map(|(i, (s, p))| (s, p, i))
        .collect::<Vec<_>>();
    sp.sort_by(|x, y| {
        if x.0 == y.0 {
            y.1.cmp(&x.1)
        } else {
            x.0.cmp(&y.0)
        }
    });
    for (_, _, i) in sp {
        println!("{}", i);
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define FOR(i, k, n) for(int i = (k); i < (n); i++)
#define FORe(i, k, n) for(int i = (k); i <= (n); i++)
#define FORr(i, k, n) for(int i = (k); i > (n); i--)
#define FORre(i, k, n) for(int i = (k); i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using ll = long long;

const int INF = 1001001001;
const int mod = 1000000007;

int main(void){
  int n;
  cin >> n;
  vector<int> a(n);
  REP(i, n) cin >> a[i];

  vector<int> b(n, 0);
  int m = 0;
  REPr(i, n-1){
    int sum = 0;
    for(int j = 2; (i+1)*j <= n; j++){
      sum ^= b[(i+1)*j-1];
    }
    if(a[i] != sum){
      b[i] = 1;
      m++;
    }
  }

  cout << m << endl;
  REP(i, n){
    if(b[i]) cout << i+1 << " ";
    if(i == n-1) cout << endl;
  }

  return 0;
}

Measured memory_bytes: 2432
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<cstring>
#include<bitset>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<numeric>
using namespace std;

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

#define rep(i,x) for(int i=0;i<x;i++)
#define re(i,x,y) for(int i=x;i<y;i++)

long long INF=1e9;
const long long mod=2019;
#define ll long long

int main(){
    int a;
    cin>>a;
    int N=a;
    int num=0;
    while(N>0){
        N/=10;
        num++;
    }
    int x;
    ll ans=0;
    if(num==1){
        cout<<a<<endl;
        return 0;
    }
    else if(num%2==0){
        if(num>=3){
        for(int i=3;i<=num;i+=2){
            ans+=(pow(10,i)-pow(10,i-1));
        }
        }
        ans+=9;
    }
    
    else if(num%2!=0){
        if(num>=3){
        for(int i=3;i<=num-1;i+=2){
            ans+=(pow(10,i)-pow(10,i-1));
        }
        }
        ans+=9;
        x=a-(pow(10,(num-1)));
        ans=ans+x+1;
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

const int N = 200100;
const long long INF = (long long) 1e18;

int n, m, p, a[N], b[N], c[N];
long long d[N];
vector <int> q;
vector <int> s;
vector <int> r[N];
vector <int> g[N];

int main() {

	scanf("%d %d %d", &n, &m, &p);

	for (int i = 0; i < m; i++) {
		scanf("%d %d %d", &a[i], &b[i], &c[i]);
		a[i]--;
		b[i]--;
		c[i] -= p;
		g[a[i]].push_back(i);
		r[b[i]].push_back(i);
	}

	vector <bool> vis(n, false);

	vis[n - 1] = true;
	q.push_back(n - 1);

	for (int i = 0; i < q.size(); i++) {
		int cur = q[i];
		for (int j = 0; j < r[cur].size(); j++) {
			int id = r[cur][j];
			int o = a[id] + b[id] - cur;
			if (!vis[o]) {
				vis[o] = true;
				q.push_back(o);
			}
		}
	}

	vector <int> occ(n, 0);
	vector <bool> mark(n, false);

	for (int i = 0; i < n; i++) {
		d[i] = -INF;
		mark[i] = false;
	}

	d[0] = 0;
	mark[0] = true;
	s.push_back(0);

	for (int i = 0; i < s.size(); i++) {
		int cur = s[i];
		occ[cur]++;
		mark[cur] = false;
		if (occ[cur] >= 5000) {
			puts("-1");
			exit(0);
		}
		for (int j = 0; j < g[cur].size(); j++) {
			int id = g[cur][j];
			int o = a[id] + b[id] - cur;
			if (!vis[o]) {
				continue;
			}
			if (d[o] < d[cur] + c[id]) {
				d[o] = d[cur] + c[id];
				if (!mark[o]) {
					mark[o] = true;
					s.push_back(o);
				}
			}
		}
	}

	long long res = max(0LL, d[n - 1]);

	printf("%lld\n", res);

	return 0;

}

Measured memory_bytes: 80232
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10, gcd
from itertools import permutations, combinations, product, accumulate, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
#from fractions import gcd
from decimal import *
import heapq
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 1, 0, -1, 1, -1, -1, 1]
dy = [1, 0, -1, 0, 1, -1, 1, -1]
debugmode = True

x = INT()
print(lcm(360, x) // x)

Measured memory_bytes: 72788
#include<bits/stdc++.h>
using namespace std;
long long s,x2,y2,x3,y3;
int main(){
	scanf("%lld",&s);
	if(s<=1000000000ll) printf("0 0 1 0 0 %lld",s);
	else{
		x2=1000000000ll;
		y3=(s-1ll)/x2+1;
		x3=x2*y3-s;
		printf("0 0 %lld 1 %lld %lld",x2,x3,y3);
	}
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class Progaram
{
    static void Main(string[] args)
    {
        var line = Console.ReadLine().Split(' ')
            .Select(x => int.Parse(x)).ToList();
        var n = line[0];
        var l = line[1];
        var sl = new List<string>();

        for (var i = 0; n > i; i++)
        {
            sl.Add(Console.ReadLine());
        }

        sl.Sort();
        var text = "";
        foreach (var i in sl)
        {
            text += i;
        }
        Console.WriteLine(text);
    }
}



Measured memory_bytes: 14048
import java.io.*;
import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static PrintWriter out = new PrintWriter(System.out);
	

	public static void main(String[] args) throws Exception {
		int n = sc.nextInt(), arr[] = new int[n], xor = 0;
		for(int i = 0; i < n; i++) {
			arr[i] = sc.nextInt();
			xor ^= arr[i];
		}
		
		for(int i = 0; i < n; i++) {
			out.print((arr[i] ^ xor) + " ");
		}
		
		out.close();
	}

}

class Scanner {
	StringTokenizer st;
	BufferedReader br;

	public Scanner(InputStream system) {
		br = new BufferedReader(new InputStreamReader(system));
	}

	public Scanner(String file) throws Exception {
		br = new BufferedReader(new FileReader(file));
	}

	public String next() throws IOException {
		while (st == null || !st.hasMoreTokens())
			st = new StringTokenizer(br.readLine());
		return st.nextToken();
	}

	public String nextLine() throws IOException {
		return br.readLine();
	}

	public int nextInt() throws IOException {
		return Integer.parseInt(next());
	}

	public double nextDouble() throws IOException {
		return Double.parseDouble(next());
	}

	public Long nextLong() throws IOException {
		return Long.parseLong(next());
	}
}

Measured memory_bytes: 58280
import * as fs from 'fs';

namespace AtCoder.hitachi2020 {

    export class Program {
        /**
         * in
         * hihi
         * out
         * Yes
         */
        static main(inp: string): void {

            if (inp.length %2 ===1) {
                console.log('No');
                return;
            }


            for (let i = 0; i < inp.length; i++) {
                if (i % 2 === 0) {
                    // h
                    if (inp[i] !== 'h') {
                        console.log('No');
                        return;
                    }
                } else {
                    // i
                    if (inp[i] !== 'i') {
                        console.log('No');
                        return;
                    }
                }


            }

            console.log('Yes');
        }
    }
}

AtCoder.hitachi2020.Program.main(fs.readFileSync('/dev/stdin', 'utf8').trim());


Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
#define endl '\n'
#define ll long long
#define ld long double
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vpi vector<pi>
 
const int MOD = 1e9 + 7;
const ll INF = 1e18;
const int MX = 3e5 + 5;
const ld PI = 4 * atan((ld)1);

int cnt[MX];
vi adj[MX];
void dfs(int u,int par){
	cnt[u]+=cnt[par];
	for(auto v:adj[u]){
		if(v==par) continue;
		dfs(v,u);
	}
}

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	int n,q;
	cin>>n>>q;
	for(int i=0;i<n-1;i++){
		int x,y;
		cin>>x>>y;
		adj[x].push_back(y);
		adj[y].push_back(x);
	}
	for(int i=0;i<q;i++){
		int p,x;
		cin>>p>>x;
		cnt[p]+=x;
	}
	dfs(1,0);
	for(int i=1;i<=n;i++) cout<<cnt[i]<<" ";
		cout<<endl;
}

Measured memory_bytes: 26624
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#define int long long
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define F first
#define S second
#define P pair
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define V vector
#define RE return
#define ALL(a) a.begin(),a.end()
#define MP make_pair
#define PB emplace_back
#define PF emplace_front
#define FILL(a,b) memset(a,b,sizeof(a))
#define lwb lower_bound
#define upb upper_bound
using namespace std;
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int a,b,n;
	cin>>a>>b>>n;
	if(n<b){
		cout<<n*a/b;
		RE 0;
	}
	int t=n;
	t-=b-1;
	t=t/b;
	t=t*b+b-1;
	cout<<(t*a/b)-(t/b)*a;
	RE 0;
}




Measured memory_bytes: 3612
#include <iostream>
#include<string>
#include<cstring>
#include <cstdio>
#include<utility>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<bitset>
#include<queue>
#include<set>
#include <limits>
#include <numeric>
#include <type_traits>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
typedef pair<double,double>P_D;
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define reprev(i, n) for (int i = (int)n - 1; i >= 0; i--)
#define ALL(a)  (a).begin(),(a).end()
#define MAX 100100
#define MAX_N 200100
#define SENTINEL 2000000000
#define MAX_B 1001001
#define NIL -1
#define MOD 1000000007
#define INF 1 << 29
#define INFTY 1000000000000000000LL
int n;
int a[MAX][3];
ll dp[MAX][3];
int main(){
    cin>>n;
    rep(i,n)rep(j,3)cin>>a[i][j];
    
    //dpの準備
    memset(dp,0,sizeof(dp));
    rep(i,n){
        rep(j,3)rep(k,3){
            if(j==k)continue;
            dp[i+1][j]=max(dp[i][k]+a[i][j],dp[i+1][j]);
    }
    }
    ll res=0;
    rep(i,3)if(res<dp[n][i])res=dp[n][i];
    cout<<res<<endl;
}

Measured memory_bytes: 3712