akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll=long long;
using lb = long double;
//#define int long long
//#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
const int MOD = 1e9 + 7;
const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279; //円周率
/*---------------------便利な関数--------------------------------------*/
int fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}

int gcd(int a, int b) {        //最大公約数
    if (b == 0) return a;
    return gcd(b, a % b);
}

int lcm(int a, int b) {      //最小公倍数
    return a * b / gcd(a, b);
}

int keta(int n) {        //桁数を求める
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}

int ketasum(int n) {    //各桁の和
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
//最小化問題(DP)
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
//最大化問題(DP)
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
/*-------------ここまで---------------------------------------------*/
int main(){
    int a, b;
    cin >> a >> b;
    if (a % 2 == 1 && b % 2 == 1) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

int main() {
  int x, y, a, b, c;
  cin >> x >> y >> a >> b >> c;
  vector<int> p(a);
  vector<int> q(b);
  vector<int> r(c);
  for(int i = 0; i < a; i++) cin >> p.at(i);
  for(int i = 0; i < b; i++) cin >> q.at(i);
  for(int i = 0; i < c; i++) cin >> r.at(i);
  
  sort(p.begin(), p.end(), greater<int>());
  sort(q.begin(), q.end(), greater<int>());
  sort(r.begin(), r.end(), greater<int>());
  
  long long ans = 0;
  priority_queue<int> app;
  for(int i = 0; i < x; i++) app.push(p.at(i));
  for(int i = 0; i < y; i++) app.push(q.at(i));
  for(int i = 0; i < c; i++) app.push(r.at(i));
  
  for(int i = 0; i < x + y; i++){
    long long k = app.top();
    app.pop();
    ans += k;
  }
  
  cout << ans << endl;
}

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

const int MX = 200050;
const int MAXL = 20;

struct RMQ {
	int f[20][MX], n;
	RMQ() {}
	void init(int _n, int *a) {
		n = _n;
		for (int i = 0; i < n; i++) {
			f[0][i] = a[i];
		}
		for (int j = 1; 1<<j <= n; j++) {
			for (int i = 0; i < n; i++) {
				f[j][i] = f[j-1][i];
				if (i + (1<<j-1) < n) {
					f[j][i] = min(f[j][i], f[j-1][i + (1<<j-1)]);
				}
			}
		}
	}
	inline int get(int s, int e) { // Get minimum value between
		// [s, e](both inclusive)
		assert(s <= e && 0 <= s);
		int k = 31-__builtin_clz(e-s+1);
		return min(f[k][s], f[k][e-(1<<k)+1]);
	}
} r0, r1;

int p0[MX], p1[MX], p[MX], pos[MX];

struct node {
	int st, ed, P0, P1;
	node(int st = 0, int ed = 0) : st(st), ed(ed) {
		if(st & 1) {
			int k = r1.get(st / 2, ed / 2 - 1);
			P0 = pos[k];
			k = r0.get(P0 / 2 + 1, ed / 2);
			P1 = pos[k];
		}
		else {
			int k = r0.get(st / 2, ed / 2);
			P0 = pos[k];
			k = r1.get(P0 / 2, ed / 2);
			P1 = pos[k];
		}
	}
	bool operator < (const node& rhs) const { return p[P0] > p[rhs.P0]; }
};

int main() {
	int n; scanf("%d", &n);
	for(int i = 0; i < n / 2; i++) {
		scanf("%d%d", p0 + i, p1 + i);
		pos[p0[i]] = i * 2; pos[p1[i]] = i * 2 + 1;
		p[i * 2] = p0[i]; p[i * 2 + 1] = p1[i];
	}
	r0.init(n / 2, p0); r1.init(n / 2, p1);
	priority_queue<node> pq;
	pq.push(node(0, n - 1));
	vector<int> res;
	while(pq.size()) {
		node nd = pq.top(); pq.pop();
		if(nd.st < nd.P0) pq.push(node(nd.st, nd.P0 - 1));
		if(nd.P0 + 1 < nd.P1) pq.push(node(nd.P0 + 1, nd.P1 - 1));
		if(nd.P1 < nd.ed) pq.push(node(nd.P1 + 1, nd.ed));
		res.push_back(p[nd.P0]);
		res.push_back(p[nd.P1]);
	}
	for(int i = 0; i < res.size(); i++) printf("%d%c", res[i], i == res.size() - 1 ? '\n' : ' ');
	return 0;
}


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

int n,a[200010],ji[200010];
map<int,int> mp;
const long long mod=1e9+7;
long long dp[200010];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
	{
		scanf("%d",&a[i]);
		if(!mp[a[i]])
		ji[i]=0;
		else
		ji[i]=mp[a[i]];
		mp[a[i]]=i;		
	}	
	dp[1]=1;
	for(int i=2;i<=n;++i)
	{
		if(i-1!=ji[i])
		dp[i]=(dp[i-1]+dp[ji[i]])%mod;
		else
		dp[i]=dp[i-1];
	}
	printf("%lld\n",dp[n]);
	return 0;
}

Measured memory_bytes: 12800
// #include <bits/stdc++.h>//C++のライブラリすべてinclude
#include<stdio.h>
#include<string>
#include<iostream>
#include<algorithm>
#include<queue>
#include<tuple>
#include<limits>//ex numeric_limits<int>::max()
#include<math.h>
#define llong long long
#define INF 999999999

using namespace std;

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

    int N,M,X,Y;
    cin >> N>>M>>X>>Y;
    vector<int> x(N),y(M);

    for (int i = 0; i < N; ++i)
    {
        cin>>x[i];
    }
    for (int i = 0; i < M; ++i)
    {
        cin>>y[i];
    }
    sort(x.begin(),x.end());
    sort(y.begin(),y.end());
    for (int i = x[N-1]+1; i <= y[0]; ++i)
    {
        if(X<i&&i<=Y){
            cout << "No War"<<endl;
            return 0;
        }
    }
    cout << "War"<<endl;
}


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

int main(){
    string s, p, c;
    cin >> s >> p;

    bool can = false;
    for (int i = 0; i < s.size(); i++)
    {
        c = "";
        int a = i;
        for (int j = 0; j < p.size(); j++)
        {
            if(a == s.size()) a = 0;
            c += s.at(a);
            a++;
        }
        
        if(c == p) can = true;
    }
    
    if(can) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 3216
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct Node {
    int key;
    struct Node *right, *left, *parent;
};
typedef struct Node Node;

Node *root, *NIL;

void insert(int k) {
    Node *y = NIL;
    Node *x = root;
    Node *z;
    
    z = (Node *)malloc(sizeof(Node));
    z->key   = k;
    z->left  = NIL;
    z->right = NIL;
    
    while(x != NIL) {
        y = x;
        if(z->key < x->key) {
            x = x->left;
        } else {
            x = x->right;
        }
    }
    
    z->parent = y;
    if(y == NIL) {
        root = z;
    } else {
        if( z->key < y->key) {
            y->left = z;
        } else {
            y->right = z;
        }
    }
}

void inorder(Node *u) {
    if(u == NIL) return;
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
}
void preorder(Node *u) {
    if(u == NIL) return;
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
}
    
int main(void) {
    int n, i, x;
    char com[16];
    scanf("%d",&n);
    
    for(i=0;i<n;i++) {
        scanf("%s",com);
        if(!strcmp(com,"insert")) {
            scanf("%d",&x);
            insert(x);
        } else if(!strcmp(com,"print")) {
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }

    return 0;
}





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

int main(){
  long N,sum = 0;
  cin >> N;
  long a[3*N];
  for(int i=0;i<3*N;i++)
    cin >> a[i];
  sort(a,a+3*N);
  for(long j=3*N-2;N-1<j;j-=2)
  	sum += a[j];
  cout << sum << endl;
}

Measured memory_bytes: 2560
import java.util.Scanner;


public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
Scanner sc =new Scanner(System.in);
String s =sc.next();
String t=sc.next();
int a=sc.nextInt();
int b =sc.nextInt();
String u =sc.next();
if(u.equals(s)){
	a=a-1;
	}
if(u.equals(t)){
b=b-1;
}
System.out.print(a+" ");
System.out.println(b);
	}
}

Measured memory_bytes: 23252
#include<stdio.h>

int main(void){
	int a,b,i,count,str[100];
	char c;
	i=0;
	do{
	scanf("%d %c %d",&a,&c,&b);
	if(c == '+')
		str[i] = a+b;
	if(c =='-')
		str[i] = a-b;
	if(c =='*')
		str[i] = a*b;
	if(c =='/' && b!=0)
		str[i] = a/b;
	count=i;
	i++; 
	}while(c!='?');

	for(i=0;i<=(count-1);i++){
	printf("%d\n",str[i]);
	}

	return 0;
}

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

int main()
{
    long int N, A;
    cin >> N >> A;
    long int x[N];
    for (int i=0; i<N; i++){
        long int tmp;
        cin >> tmp;
        x[i]=tmp-A;
    }
    sort(x, x+N);//昇順にソート
    long int X = A;
    if (X<x[N-1]){
        X = x[N-1];
    }
    long int dp[N+1][2*N*X+1];//dp[j][t]はy1,,,yjから0枚以上選んでyiの合計をt-NXにするような選び方の総数
    for (int i=0; i<2*N*X; i++){
        for (int j=0; j<N; j++){
            dp[j][i]=0;
        }
    }
    dp[0][N*X]=1;
    for (int i=1; i<=N; i++){
        for (int t=0; t<=2*N*X; t++){
            if (t-x[i-1]<0 || t-x[i-1]>2*N*X){
                dp[i][t]=dp[i-1][t];
            }else if(0<=t-x[i-1] && t-x[i-1]<=2*N*X){
                dp[i][t]=dp[i-1][t-x[i-1]]+dp[i-1][t];
            }
        }
    }
    cout << dp[N][N*X]-1 << '\n';
    return 0;
}

Measured memory_bytes: 2176
#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef pair<int,int> P;
constexpr double EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max()/2;
constexpr int MOD = 1e9+7;

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

    int a,b;cin>>a>>b;
    if(a%2 && b%2) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


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

int items[3000][3000];
long long dp[3000][3000][4];

int main() {
    int R, C, K; cin >> R >> C >> K;
    memset(items, 0, sizeof items);
    for (int i = 0; i < K; i++) {
        int r, c, v; cin >> r >> c >> v;
        items[r-1][c-1] = v;
    }
    memset(dp, 0, sizeof dp);
    for (int r = 0; r < R; r++)
        for (int c = 0; c < C; c++)
            for (int d = 3; d >= 0; d--) dp[r][c][d] = -(1LL<<60);
    dp[0][0][0] = 0;
    dp[0][0][1] = items[0][0];
    for (int r = 0; r < R; r++)
        for (int c = 0; c < C; c++)
            for (int d = 3; d >= 0; d--) {
                if (r < R-1) {
                    dp[r+1][c][0] = max(dp[r+1][c][0], dp[r][c][d]);
                    dp[r+1][c][1] = max(dp[r+1][c][1], dp[r][c][d] + items[r+1][c]);
                }
                if (c < C-1) {
                    dp[r][c+1][d] = max(dp[r][c+1][d], dp[r][c][d]);
                    if (d < 3) {
                        dp[r][c+1][d+1] = max(dp[r][c+1][d+1], dp[r][c][d] + items[r][c+1]);
                    }
                }
            }
    // for (int d = 0; d < 4; d++) {
    //     for (int r = 0; r < R; r++) {
    //         for (int c = 0; c < C; c++) {
    //             cerr << dp[r][c][d] << ' ';
    //         }
    //         cerr << endl;
    //     }
    //     cerr << endl;
    // }

    long long ans = 0;
    for (int d = 3; d >= 0; d--)
        ans = max(ans, dp[R-1][C-1][d]);
    cout << ans << endl;
}


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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()

Int INF = 1e18;
int inf = 1e9;
Int mod = 1e9+7;

int dp_all[1000001];
int dp_odd[1000001];

int main() {
    vector<int> num_all, num_odd;
    for (int i = 1; i * (i + 1) * (i + 2) / 6 <= 1e6; i++) {
        num_all.push_back(i * (i + 1) * (i + 2) / 6);
        if ((i * (i + 1) * (i + 2) / 6) % 2 == 1) {
            num_odd.push_back(i * (i + 1) * (i + 2) / 6);
        }
    }
    for (int i = 0; i <= 1e6; i++) {
        dp_all[i] = dp_odd[i] = inf;
    }
    dp_all[0] = 0;
    for (int i = 0; i < (int)num_all.size(); i++) {
        for (int j = 0; j + num_all[i] <= 1e6; j++) {
            dp_all[j + num_all[i]] = min(dp_all[j + num_all[i]], dp_all[j] + 1);
        }
    }
    dp_odd[0] = 0;
    for (int i = 0; i < (int)num_odd.size(); i++) {
        for (int j = 0; j + num_odd[i] <= 1e6; j++) {
            dp_odd[j + num_odd[i]] = min(dp_odd[j + num_odd[i]], dp_odd[j] + 1);
        }
    }
    vector<pair<int, int>> res;
    while (true) {
        int n;
        cin >> n;
        if (n == 0) break;
        res.emplace_back(dp_all[n], dp_odd[n]);
    }
    for (int i = 0; i < (int)res.size(); i++) {
        cout << res[i].fi << " " << res[i].se << endl;
    }
    return 0;
}



Measured memory_bytes: 10936
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mod=1337;
int main()
{
    ll n,k;
    cin>>n;
    vector<int>v(n,0);
    cin>>k;
    while(k--)
    {
        ll a;
        cin>>a;
      //  vector<int>ss(a);
        for(int i=0;i<a;i++)
        {
            int x;
            cin>>x;
            v[x-1]=1;
        }
    }
    ll cnt=0;
    for(int i=0;i<n;i++)
    {
        if(v[i]==0) cnt++;
    }
    cout<<cnt<<"\n";
}


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

int main(void){
    int input;
    cin >> input;
    
    int n[4];
    int i;
    for(i = 3; i >= 0; i--){
        n[i] = input % 10;
        input /= 10;
    }
    
    int op;
    int sum;
    for(op = 0; op <= 7; op++){
        sum = n[0];
        
        if(op & 4){
            sum += n[1];
        }else{
            sum -= n[1];
        }
        
        if(op & 2){
            sum += n[2];
        }else{
            sum -= n[2];
        }
        
        if(op & 1){
            sum += n[3];
        }else{
            sum -= n[3];
        }
        
        if(sum == 7){
            cout << n[0] << ((op & 4) ? '+' : '-') << n[1] << ((op & 2) ? '+' : '-') << n[2] << ((op & 1) ? '+' : '-') << n[3] << "=7" << endl;
            return 0;
        }
    }
    
    return 0;
}

Measured memory_bytes: 256
object Main {
  def main(args: Array[String]) = {
    val s = scala.collection.mutable.Queue[String]()

    for (x <- io.Source.stdin.getLines()) {
      s += x
      if (s.size == 2) {
        val a = s.dequeue().split(' ').map(n => n.toInt)
        val b = s.dequeue().split(' ').map(n => n.toInt)
        val (hit, blow) = hitAndBlow(a, b)
        println(hit + " " + blow)

      }
    }
  }

  def hitAndBlow(a: Seq[Int], b: Seq[Int]): Tuple2[Int, Int] = {
    var hit = 0
    for (i <- 0 until 4) {
      if (a(i) == b(i)) {
        hit += 1
      }
    }

    val blow = a.intersect(b).size - hit

    (hit, blow)
  }
}

Measured memory_bytes: 44284
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 100000000000000 //10^14
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
int main()
{
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A.at(i);
    vector<bitset<20>> B(N);
    rep(i, N){
        bitset<20> s(A.at(i));
        B.at(i) = s;
    }
    ll ans = 0;
    //[i, j]でビットの重複があるか調べる、尺取り法
    set<ll> S;
    bool flag = false;
    bool comp = false;
    ll p = 0;
    rep(i, N){
        rep2(j, p, N){
            rep(k, 20){
                if(B.at(j).test(k) && S.count(k)){
                    rep(l, 20){
                        if(B.at(i).test(l)){
                            S.erase(l);
                        }
                    }
                    flag = true;
                    break;
                }
            }
            if(flag){
                flag = false;
                ans += j - i;
                p = j;
                break;
            }
            rep(k, 20){
                if(B.at(j).test(k)){
                    S.insert(k);
                }
            }
            if(j == N-1){
                comp = true;
                ans += (N - i) * (N - i + 1) / 2; 
            }
        }
        if(comp){
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 6432
#include<stdio.h>

int main(void)
{
  char str[120],str1[120];
  int i,j,s=0;
  int count=0;
  scanf("%s",str);
  for(i=0;str[i]!=0;i++){
    count++;
  }

  for(i=0;i<=count-1;i++){
    str1[i]=str[count-i-1];
  }

  for(i=0;i<(count/2);i++){
    if(str1[i]!=str[i])s++;
  }
  printf("%d",s);

  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int main()
{
	int v[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int a;
	cin >> a;
	cout << v[a-1] << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef int64_t ll; //こいつのセミコロン

//x番目のリュカ数を返す
ll lucas(ll n, vector<ll> &memo) {
    if (n == 0) return memo.at(0) = 2;
    else if (n == 1) return memo.at(1) = 1;

    if (memo.at(n) != -1) return memo.at(n);
    
    return memo.at(n) = lucas(n-1, memo) + lucas(n-2, memo);
}

//int64_tにしたらいったわ

int main () {
    ll x;
    cin >> x;
    vector<ll> memo(x+1, -1);
    ll ans = lucas(x, memo);
    cout << ans << endl;

    // rep(i, x+1) {
    //     cout << memo.at(i) << endl;
    // }
}

Measured memory_bytes: 256
N = int(input())
H = list(map(int,input().split()))

max_num = 0
posi = 0
while posi < N-1:
    count = 0
    for i in range(posi, N-1):
        if H[i] >= H[i+1]:
            count += 1
        else:
            break
    posi += count+1
    if max_num < count:
        max_num = count
print(max_num)

Measured memory_bytes: 15020
#include <iostream>
#include <cstring>
#include <string>    
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll n, a, b;
string str;

int main(){
	cin >> n;
	vector<P> task(n);
	for(ll i = 0; i < n; i++){
		cin >> a >> b;
		task[i] = P(b, a);
	}
	sort(task.begin(), task.end());
	
	ll time = 0;
	string ans = "Yes";
	for(ll i = 0; i < n; i++){
		b = task[i].first;
		a = task[i].second;
		time += a;
		if(time > b){ans = "No";}
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#include<cmath>
#define N 100005
#define A 1000005
#define MOD 1000000007 // //100000000 998244353 //
#define inf 1000000000000000000
#define ll long long
//#define M_PI 3.141592653589793238463

using namespace std;

#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define ft first
#define sd second
#define pb push_back
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n-1; i >= 0; i--)
#define itr(it, x) for(auto it = x.begin(); it != x.end(); it++)
#define mem(a, b) memset(a, (ll)b, sizeof(a))
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define edge(v, x, y) v[x].pb(y); v[y].pb(x);
#define popcount __builtin_popcount
#define ANS(s) {cout << s << "\n"; return;}

//~~~~~~fancy print~~~~~~~//
#define printpii(a) cout << a.ft << " " << a.sd << endl;
#define printpiii(a) cout << a.ft << " " << a.sd.ft << " " << a.sd.sd << endl;
#define print(a, n) rep(i, n) cout << a[i] << " "; cout << endl;
#define printv(v) for(auto x: v)cout << x << " "; cout << endl;
#define printm(a, n, m) rep(i, n) { rep(j, m) cout << a[i][j] << "\t"; cout << endl;}

ll lx[4] = {0, 0, 1, -1};
ll ly[4] = {1, -1, 0, 0};
ll dx[8] = {0, 0, 1, -1, 1, -1, 1, -1};
ll dy[8] = {1, -1, 0, 0, 1, 1, -1, -1};
void fast(){ios_base::sync_with_stdio(false);cin.tie(0);cout << setprecision(12) << fixed;}
ll lcm(ll a, ll b) {return (a*b)/__gcd(a, b); }

void solve()
{
    ll n;
    cin >> n;
    ll a[5];
    rep(i, 5) cin >> a[i];
    ll mn = *min_element(a, a+5);
    cout << 5+ (n+mn-1)/mn -1;
}
int main(){
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    fast();
    ll t = 1; //cin >> t;
    while(t--){
        solve();
    }
    return 0;
}


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

int n;
int a[105];


int main(){
	int ans = 0;
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) scanf("%d",&a[i]);
	for(int i = 1; i <= n; i++){
		int num = 1;
		while(a[i+1] == a[i]){
			num++;
			i++;
		}
		if(num % 2 == 0)
			ans += num/2;
		else if(num != 1 && num % 2 == 1) 
			ans += (num-1)/2;
	}
	printf("%d\n", ans);
return 0;
}

Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(unused_imports)]
use proconio::input;
// use std::collections::HashMap;
// use std::collections::VecDeque;
// use std::cmp::max;
// use std::cmp::min;


fn main() {
    input! {
        D: i64,
        T: i64,
        S: i64,
    }

    let ans = if D <= T * S { "Yes" } else { "No" };
    println!("{}", ans);
}


Measured memory_bytes: 2168
from collections import Counter
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    N = int(readline())
    A = [int(i) for i in readline().split()]

    t = Counter(A)
    total = 0
    for k, v in t.items():
        total += v * (v-1) // 2

    for a in A:
        tmp1 = t[a] * (t[a]-1) // 2
        tmp2 = (t[a]-1) * (t[a]-2) // 2
        print(total - tmp1 + tmp2)


if __name__ == "__main__":
    main()


Measured memory_bytes: 26040
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())


//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {

	int n, h, w; cin >> n >> h >> w;

	int ans = (n - h + 1)*(n - w + 1);

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <limits.h>
#include <stdlib.h>
#include <stdbool.h>
long long N,W;
static bool  dp[100001];

int 
main(){
	long long i,j,k;
	long long a[110000];
	scanf("%lld%lld",&N,&W);
	for(i=0;i<N;i++)
	//for(j=0;j<3;j++)
	{
		scanf("%lld",&a[i]);
	}
	//for(j=0;j<3;j++)
	//	dp[0][j]=0;
	
	#if 1
	for(i=1;i<=W;++i){
		for( j=0;j< N;j++){
			if(i-a[j]>=0) dp[i] |= !dp[i-a[j]];
		}
    }
    #endif

	if(dp[W])printf("First\n");
	else printf("Second\n");
	

	
 return 0;
}

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

int main() {
	// your code goes here
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	char b;
	cin>>b;
	if(b=='A'){
		cout<<"T";
	}else if(b=='C'){
		cout<<"G";
	}else if(b=='G'){
		cout<<"C";
	}else if(b=='T'){
		cout<<"A";
	}
	return 0;
}

Measured memory_bytes: 256
/*
  AOJ #2816
  title:Alphabet Block
  @kankichi573
 */
#include <stdio.h>
#include <string.h>

int alpha[26];
char s[1001];

int main()
{
  char *p;
  int i,ret;

  memset(alpha,0,sizeof(alpha));
  scanf("%s",s);
  for(p=s;*p;p++)
    alpha[*p-'a']++;
  for(i=ret=0;i<26;i++)
    ret+=(alpha[i]%2);

  printf("%d\n",ret/2);
  return(0);
}

Measured memory_bytes: 1860
N, M = map(int, input().split())
L = [[] for _ in range(N+1)]
for _ in range(M):
    a, b = map(int, input().split())
    L[a].append(b)
    L[b].append(a)

ans = [0 for _ in range(N+1)]
now = [1]
next = []

while len(now):
    for x in now:
        for y in L[x]:
            if (ans[y] == 0) and (y not in now):
                ans[y] = x
                next.append(y)
    now = next.copy()
    next = []

print("Yes")
for x in range(2, N+1):
    print(ans[x])

Measured memory_bytes: 105680
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}

var mod int
var t float64

func main() {
	mod = 1000000007
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := intScanner()
	t := intScanner()
	as := make([]int, n+1)
	bs := make([]int, n+1)
	for i := 1; i < n+1; i++ {
		as[i] = intScanner()
		bs[i] = intScanner()
	}
	dp := make([][]int, n+1)
	dpr := make([][]int, n+1)
	dp[0] = make([]int, t)
	dpr[0] = make([]int, t)
	for i := 1; i < n+1; i++ {
		dp[i] = make([]int, t)
		dpr[i] = make([]int, t)
		k := n - i + 1
		for j := 1; j < t; j++ {
			if j >= as[i] {
				x := dp[i-1][j-as[i]] + bs[i]
				y := dp[i-1][j]
				if x > y {
					dp[i][j] = x
				} else {
					dp[i][j] = y
				}
			} else {
				dp[i][j] = dp[i-1][j]
			}
			if j >= as[k] {
				x := dpr[i-1][j-as[k]] + bs[k]
				y := dpr[i-1][j]
				if x > y {
					dpr[i][j] = x
				} else {
					dpr[i][j] = y
				}
			} else {
				dpr[i][j] = dpr[i-1][j]
			}
		}
	}
	ans := 0
	for i := 1; i < n+1; i++ {
		for j := 0; j < t; j++ {
			x := dp[i-1][j] + dpr[n-i][t-1-j] + bs[i]
			ans = larger(ans, x)
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 151840
"use strict";
    
// 順列 被り有り
const permutateWithRepetitions = (
  permutationOptions,
  permutationLength
) => {
  if (permutationLength === 1) {
    return permutationOptions.map(permutationOption => [permutationOption]);
  }

  // Init permutations array.
  const permutations = [];

  // Get smaller permutations.
  const smallerPermutations = permutateWithRepetitions(
    permutationOptions,
    permutationLength - 1
  );

  // Go through all options and join it to the smaller permutations.
  permutationOptions.forEach((currentOption) => {
    smallerPermutations.forEach((smallerPermutation) => {
      permutations.push([currentOption].concat(smallerPermutation));
    });
  });

  return permutations;
}

const main = arg => {
    arg = arg.trim().split("\n");
    const A = parseInt(arg[0].split("")[0]);
    const B = parseInt(arg[0].split("")[1]);
    const C = parseInt(arg[0].split("")[2]);
    const D = parseInt(arg[0].split("")[3]);

    const operands = ["+", "-"];
    
    const patterns = permutateWithRepetitions(operands, 3);
    
    for(let i in patterns) {
        let temp = [];
        
        for(let j=0; j<patterns[i].length; j++) {
            if(j === 0) {
                temp.push(A);
            }
            
            if(j === 1) {
                temp.push(B);
            }
            
            if(j === 2) {
                temp.push(C);
            }
            
            
            temp.push(patterns[i][j]);
        }
        
        temp.push(D);

        if(eval(temp.join("")) === 7) {
            console.log(temp.join("") + "=7");
            return;
        }
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 21064
/**
 * File              : E-review.cpp
 * Author            : JCHRYS <jchrys@me.com>
 * Date              : 09.02.2020
 * Last Modified Date: 09.02.2020
 * Last Modified By  : JCHRYS <jchrys@me.com>
 */

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int const MAXA = 1e6+99;
ll const mod = 1e9+7;
vector<int> primes;
void sieve() {
    vector<bool> num(MAXA, true);
    num[0] = num[1] = false;
    for (int i = 2; i < MAXA; i++) {
        if (!num[i]) continue;
        for (ll j = i*1LL*i; j < MAXA; j += i) {
            num[j] = false;
        }
    }
    for (int i = 2; i < MAXA; i++)
        if (num[i])
            primes.push_back(i);
}

ll power(ll base, ll nth) {
    ll res = 1;
    while (nth) {
        if (nth&1LL) {
            res *= base;
            res %= mod;
        }
        base *= base;
        base %= mod;
        nth>>=1LL;
    }
    return res;
}

ll modinv(ll a) {
    return power(a, mod - 2) % mod;
}
// a^p = a (mod p)
// a^(p-1) = 1 (mod p);
// a * (a^(p - 2)) === 1 (mod p);

int main() {
    sieve();
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> lca(primes.size(), 0);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        int tmp = a[i];
        for (int j = 0; primes[j]*1LL*primes[j] <= a[i]; j++) {
            int cnt = 0;
            while (tmp>1 &&tmp % primes[j] == 0) {
                cnt++;
                tmp /= primes[j];
            }
            lca[j] = max(lca[j], cnt);
        }
        if (tmp > 1) {
            int idx = lower_bound(primes.begin(), primes.end(), tmp) - primes.begin(); 
            lca[idx] = max(lca[idx], 1);
        }
    }
    ll lcm = 1;
    for (int i = 0; i < (int)primes.size(); i++) {
        if (lca[i]) {
            lcm *= power(primes[i],  lca[i]);
            lcm%= mod;
        }
    }
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        ll tmp = (lcm * modinv(a[i])) % mod;
        ans += tmp;
        ans %= mod;
    }
    cout << ans;
    return 0;

}


Measured memory_bytes: 1144
s = input().strip()
g = 0
ans = 0
if s[0] == 'R': g+=1
else: g = 0
ans = max(ans, g)
if s[1] == 'R': g+=1
else: g = 0
ans = max(ans, g)
if s[2] == 'R': g+=1  
else: g = 0
ans = max(ans, g)
print(ans)

Measured memory_bytes: 61836
#include <bits/stdc++.h>
#include <cmath>
#define ll long long
using namespace std;
int main(void){
  
  int X;
  cin >> X;
  ll p = 0;
  ll q = 0;
  ll r = 0;
  ll s = 0;
  bool last = false;
  for(ll i=-1000;i<=1000;i++){
      r = i*i*i*i*i;
    for(ll j=-1000;j<=1000;j++){
        s = j*j*j*j*j;
      if(r-s == X){
        p=i;
        q=j;
        last = true;
        break;
      }
    }
    if(last){ break; }
  }
  cout << p << endl;
  cout << q << endl;
}


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

using namespace std;

int n;
char str[6010];
string ans[3010];
int occur_a[3010], occur_b[3010], pos[6010];

int main() {
	scanf("%d%s", &n, str + 1);
	int top_a = 0, top_b = 0;
	for (int i = 1; i <= n * 2; ++i) {
		if (str[i] == 'a') {
			occur_a[++top_a] = i;
			pos[i] = top_a;
		} else {
			occur_b[++top_b] = i;
			pos[i] = top_b;
		}
	}
	string result;
	
	for (int i = n; i >= 1; --i) {
		if (occur_a[i] < occur_b[i]) {
			int k = i;
			for (int j = occur_a[i] + 1; j < occur_b[i]; ++j) k = max(k, pos[j]);
			ans[i] = "ab" + ans[k + 1];
		} else {
			int k = i;
			while (k < n && occur_b[k + 1] < occur_a[k]) ++k;
			for (int j = occur_b[i]; j <= 2 * n; ++j)
				if (pos[j] >= i && pos[j] <= k) ans[i] += str[j];
			ans[i] += ans[k + 1];
		}
		ans[i] = max(ans[i], ans[i + 1]);
		result = max(result, ans[i]);
	}
	
	cout << result << "\n";
}

Measured memory_bytes: 14592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define inf (ll)1e9
#define mod (ll)(1e9+7)
#define d(x) cerr<<#x<<"="<<x<<endl;
#define p(x) cout<<(x)<<endl
#define ps(x) cout<<(x);
#define pk(x) cout<<(x)<<" ";
#define pfix(d,x) cout << fixed << setprecision(d) << x << endl;
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define minel(v) *min_element(all(v))
#define minind(v) distance((v).begin(), min_element(all(v)))
#define maxel(v) *max_element(all(v))
#define maxind(v) distance((v).begin(), max_element(all(v)))
#define p2d(v,n,m) rep(i,n){rep(j,m){pk(v[i][j]);}p("");}
#define fi first
#define se second
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
ll a[100001],b[100001],c[100001],d,n,m,x,y,z,h,w,k,mi=inf,ma=-inf,ans,s,t,l,r,res,tmp,itr,p,q;
bool flag;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int dx8[8]={1,1,0,-1,-1,-1,0,1},dy8[8]={0,1,1,1,0,-1,-1,-1};
char cha;
string st;
typedef map<ll, ll> imap;
typedef pair<ll, ll> P;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<pair<ll,ll> > VP;
P pa;


struct UnionFind {
  VL data;
  UnionFind(int size) : data(size, -1) { }
  bool unite(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool find(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  ll size(int x) {
    return -data[root(x)];
  }
  ll num_root(ll size){
    VL roots;
    rep(i,size)roots.pb(root(i));
    sort(all(roots));
    roots.erase(unique(all(roots)),roots.end());
    return roots.size();
  }
};

int main(void){
    cin>>n;
    p(n%2?n/2+1:n/2);
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, n) for(int i = 1; i <= (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define srep(i, from, to) for(int i = from; i < (int)(to); i++)
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

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

  map<string, int> m;
  int maxCount = 0;
  rep(i, n) {
    m[a[i]] = m[a[i]] + 1;
    maxCount = max(maxCount, m[a[i]]);
  }
  vector<string> list;
  for(auto p : m) {
    if(p.second == maxCount) {
      list.push_back(p.first);
    }
  }
  sort(list.begin(), list.end());
  rep(i, list.size()) {
    cout << list[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 28404
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll=long long;
using vi = vector<int>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

int main(){
    int n,k;
    cin >> n >> k;
    vi a(n);
    rep(i,n){
        cin >> a[i];
    }
    ll ans = 0;
    n--;
    while(n>0){
        n -= k-1;
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
using System;

namespace ITP1_1_D
{
    class Program
    {
        static void Main(string[] args)
        {
            int s = int.Parse(Console.ReadLine());
            int h = s / 3600;
            s -= h * 3600;
            int m = s / 60;
            s -= m * 60;
            Console.WriteLine("{0}:{1}:{2}", h, m, s);
        }
    }
}

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

using ll = long long;
#define ALL(c) (c).begin(), (c).end()
const int MOD = 1000000007;

int main() {
    string s;
    for (int i = 0; i < 3; i++) {
        cin >> s;
        cout << s[i];
    }
}


Measured memory_bytes: 256
import sys
from math import sqrt

def solve():
    n = int(input())

    print('{}: '.format(n), end='')
    print(*prime_factorization(n))

def prime_factorization(n):
    if n < 2:
        return [n]

    res = []
    lim = int(sqrt(n))

    for p in range(2, lim + 1):
        while n % p == 0:
            res.append(p)
            n //= p

    if n > 1:
        res.append(n)

    return res

if __name__ == '__main__':
    solve()

Measured memory_bytes: 7764
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

//The Sorcerer's Donut
public class Main{

	@SuppressWarnings("unchecked")
	void run(){
		int[][] move = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
		Scanner sc = new Scanner(System.in);
		for(;;){
			int h = sc.nextInt(), w = sc.nextInt();
			if((h|w)==0)break;
			char[][] m = new char[h][w];
			for(int i=0;i<h;i++)m[i]=sc.next().toCharArray();
			Set<String>[][] set = new HashSet[26][201];
			for(int i=0;i<26;i++)for(int j=0;j<=200;j++)set[i][j] = new HashSet<String>();
			String res = "";
			for(int i=0;i<h;i++)for(int j=0;j<w;j++){
				for(int k=0;k<8;k++){
					StringBuilder sb = new StringBuilder(m[i][j]+"");
					int pi = (i+move[k][0]+h)%h, pj = (j+move[k][1]+w)%w;
					while(pi!=i||pj!=j){
						sb.append(m[pi][pj]);
						String r = sb.toString();
						if(set[m[i][j]-'A'][r.length()].contains(r)){
							if(res.length()<r.length())res = r;
							else if(res.length()==r.length()&&r.compareTo(res)<0)res = r;
						}
						else set[m[i][j]-'A'][r.length()].add(r);
						pi = (pi+move[k][0]+h)%h; pj = (pj+move[k][1]+w)%w;
					}
				}
			}
			System.out.println("".equals(res)?"0":res);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 62000
h, w = map(int, input().split())

a = []
b = [['#' for i in range (w+2)] for j in range (h+2)] #[]で囲うことが重要


for i in range(h):
    a.append(list(input())) #splitを入れなければOK

for j in range(h):
    for k in range(w):
        b[j+1][k+1] = a[j][k]
        

for l in range(h+2):
    print("".join(b[l]))

Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		boolean flg = false;
		int cnt = 0;
		for (int i = 0; i < n; i++) {
			sc.nextLine();
			int a = sc.nextInt();
			int b = sc.nextInt();
			if (a == b) {
				cnt++;
				if (cnt == 3) {
					flg = true;
				}
			} else {
				cnt = 0;
			}
		}
		String ans = flg ? "Yes" : "No";
		System.out.println(ans);
	}
}


Measured memory_bytes: 36168
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b , a % b);
}

ll mod(ll a){
  return (a % 1000000007);
}

ll lcm(ll a,ll b){
  return (a*b)/gcd(a,b);
}


int main(){
  ll a,b; cin >> a >> b;
  if(b % a == 0) cout << a+b << endl;
  else cout << b-a << endl;
}

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



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

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;cin>>n;
  vector<int>t(n);
  rep(i,n)cin>>t[i];
  int sum=0;
  rep(i,n)sum+=t[i];
  int m;cin>>m;
  rep(i,m){
    int p,x;cin>>p>>x;
    cout<<sum-t[p-1]+x<<endl;
    
  }

  return 0;

}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define int long long
#define loop(i, a, b) for(int i = a; i < b; i++)
#define rep(i, a) loop(i, 0, a)
#define all(a) (a).begin(),(a).end()
using namespace std;
const int MOD = 1e9 + 7, INF = 1e9;
using vi = vector <int>;
using vvi = vector <vi>;
//g++ -std==c++14
struct edge {int to, cost;};
vector <edge> G[100010];
using P = pair<int , int>;
int V;
int d[100010];

void dijkstra(int s){
    priority_queue <P, vector<P>, greater<P> > que;
    fill(d, d + V, 1000000000);
    d[s] = 0;
    que.push(P(0 , s));
    
    while(!que.empty()){
        P p = que.top(); que.pop();
        int v = p.second;
        if(d[v] < p.first)  continue;
        for(int i = 0; i < G[v].size(); i++){
            edge e = G[v][i];
            if(d[e.to] > d[v] + e.cost){
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}

signed main(){
	int m;
	while(cin >> V >> m, V){
		int a, b, c;
		rep(i, m){
			cin >> a >> b >> c;
			a--; b--;
			G[a].push_back({b, c});
			G[b].push_back({a, c});
		}
		struct add{int kokkara, kokomade;};
		vector <add> karen;
		rep(i, V){
			rep(j, G[i].size()){
				int va = G[i][j].to;
				rep(k, G[va].size()){
					if(G[va][k].to == i)continue;
					karen.push_back({i, G[va][k].to});
				}
			}
		}
		dijkstra(0);
		int mini = d[V - 1];
		rep(i, karen.size()){
			G[karen[i].kokkara].push_back({karen[i].kokomade, 0});
			dijkstra(0);
			G[karen[i].kokkara].pop_back();
			mini = min(mini, d[V - 1]);
		}
		cout << mini << endl;
		rep(i, V)
			G[i].clear();
	}
}

Measured memory_bytes: 5556
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
   int N;
   cin>>N;
   int t[N],x[N],y[N];
   for(int i=0;i<N;i++){
       cin>>t[i]>>x[i]>>y[i];
   }
   int nowx=0,nowy=0,nowt=0;
   int count=0;
   for(int i=0;i<N;i++){
       if((t[i]-nowt)==(abs(nowx-x[i])+abs(nowy-y[i]))){count++; nowx=x[i]; nowy=y[i]; nowt=t[i];}
       else if((t[i]-nowt-abs(nowx-x[i])-abs(nowy-y[i]))%2==0&&(t[i]-nowt-abs(nowx-x[i])-abs(nowy-y[i]))>0){count++; nowx=x[i]; nowy=y[i]; nowt=t[i];}
   }
   if(count==N) {cout<<"Yes"<<endl;}
   else {cout<<"No"<<endl;}
   return 0;
}


Measured memory_bytes: 1408
//#include <tourist>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <iomanip>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <tuple>
#include <deque>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
//setprecision(15)有効数字15桁
//-std=c++14
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}
struct edge {
    int to, cost;
};
ll a, b;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> a>>b;
    ll ans=0;
    ll g=gcd(a,b);
     for(ll i=2;i<=sqrt(g);i++){
        if(g%i==0) ans++;
        while(g%i==0){
            g/=i;
        }
    }
    if(g!=1){
    ans++;
    }

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



Measured memory_bytes: 256
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int c = scanner.nextInt();

        if ( a<b && b<c) System.out.println("Yes");
        else System.out.println("No");
    }
}


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

using namespace std;

#define REP(i,a,b) for(ll i = a; i < b; i++)
#define DB( x ) cout << #x << " = " << x << endl;
#define sz(s) ((int)((s).size()))
#define endl '\n'

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pii;
typedef pair<int, pii> tri;
typedef vector <vector <ll>> matrix;
typedef pair<string, string> pss;

const ll mod = (ll)1e9 + 7;
const int MAX = (int)1e5 + 100;

const ll oo = 0x3f3f3f3f3f3f3f3f;

ll dp[MAX], a[MAX];

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

    memset(dp, oo, sizeof(dp));

    int n, k; cin >> n >> k;

    dp[1] = 0;

    for(int i = 1;i <= n;++i){
        cin >> a[i];
    }

    for(int i = 2;i <= n;++i){
        for(int j = 1;j <= k;++j){
            if(i - j >= 1)
                dp[i] = min(dp[i - j] + abs(a[i] - a[i - j]), dp[i]);
        }
    }

    cout << dp[n] << endl;
}


Measured memory_bytes: 1792
def chk_str(s,t):
    cnt = 0
    for i in range(len(s)):
        if s[i]!=t[i]:
            cnt += 1
    return cnt

s = str(input())
t = str(input())

ans = 99999
for i in range(len(s)-len(t)+1):
    #print(s[i:i+len(t)])
    ans = min(ans,chk_str(s[i:i+len(t)],t))
print(ans)

Measured memory_bytes: 9116
import Data.Monoid
import Data.Maybe (fromMaybe)

change :: Char -> Char
change '?' = 'a'
change c = c

solve :: String -> String -> Int -> Maybe String
solve [] _ _ = Nothing
solve s t 0
    | length s < length t = Nothing
    | any (\(a, b) -> a /= '?' && a /= b) (zip s t) = Nothing
    | otherwise = Just (t ++ fmap change (drop (length t) s))
solve (x:xs) t n = (change x :) <$> solve xs t (n - 1)

main :: IO ()
main = do
    s <- getLine
    t <- getLine
    putStrLn $ fromMaybe "UNRESTORABLE" $ getLast $ foldMap Last $ fmap (solve s t) [0..length s]


Measured memory_bytes: 508
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <algorithm>
#include <cmath>
#include <iomanip>
 
 
int main()
{
    int n; std::cin >> n;
    std::string s, t;
    std::cin >> s >> t;
    std::string ans;
    for(int i=0; i<n; i++)
    {
        std::cout << s[i] << t[i];
    }
    std::cout << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
int N,K;
  cin>>N>>K;
  int ans=1;
  for(int i=0;i<N;i++){
    if(ans<=K){
      ans*=2;
    }
    else{
      ans+=K;
    }
  }
  cout<<ans<<endl;
}

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

int main(void){
  int A, B, C;
  int ans;
  cin >> A >> B >> C;
  if(A == B)
    ans = C;
  if(A == C)
    ans = B;
  if(B == C)
    ans = A;
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 3588
#import<cstdio>
main(){int K,i=scanf("%d",&K)-2,n=(K+3)/4*2,j,k;for(printf("%d\n",n);++i<n;puts(""))for(j=-1;++j<n;printf("%d ",((k=i%2*n+(i+j)%n)>=K?k-n:k)%K+1));}

Measured memory_bytes: 1152