akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
ll MOD = 1000000007;
ll INF = 214748364700000000;
double EPS = 1e-12;
double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<ll>>;

template <class T>
class SegmentTree{
  ll N;                         //葉の数
  vector<T> data;               //データを格納(要素数2*N-1)
  T def;                        //初期値かつoperationの単位元
  function<T(T,T)> operation;   //区間クエリで使う関数ラムダ式で入れる
  function<T(T,T)> update;      //一点更新で使う関数

  T _query(ll a,ll b,ll k,ll l,ll r){   //区間(a,b)を考え半開区間[l,r)が管轄
      if(b <= l || r <= a) return def;  
      if(a <= l && r <= b){
          return data[k];
      }else{
          T c1 = _query(a,b,k*2+1,l,(l+r)/2);   //左の子
          T c2 = _query(a,b,k*2+2,(l+r)/2,r);   //右の子
          return operation(c1,c2);
      }
  }
  public:
  SegmentTree(size_t _N,T _def,function<T(T,T)> _operaition,function<T(T,T)> _update):def(_def),operation(_operaition),update(_update){
          N = 1;                //N必要サイズにNを調整
          while(N < _N){
              N *= 2;
          }
          data = vector<T>(2*N-1,def);
  }

  void change(ll i,T x){
      i += N-1;
      data[i] = update(data[i],x);
      while(i > 0){
          i = (i-1)/2;
          data[i] = operation(data[i*2+1],data[i*2+2]);
      }
  }

  T query(ll a,ll b){
      return _query(a,b,0,0,N);
  }

  T operator[](ll i){
      return data[i+N-1];
  }
};

ll gcd(ll a,ll b){
    if(a == 0 || b == 0) return max(a,b);
    if(a < b) return gcd(b,a);
    ll r = INF;
    while(r){
        r = a % b;
        a = b;
        b = r;
    }
    return a;
}

int main(){
    ll N;cin >> N;
    vector<ll> A(N);
    rep(i,N) cin >> A[i];
    auto f = [](ll a,ll b){return gcd(a,b);};
    auto g = [](ll a,ll b){return b;};
    SegmentTree<ll> ST(N,0,f,g);
    ll ans = 0;
    rep(i,N){
        ST.change(i,A[i]);
    }
    rep(i,N){
        ans = max(ans,gcd(ST.query(0,i),ST.query(i+1,N)));
    }
    cout << ans << endl;
}

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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define fi first
#define se second
#define setpre(x) cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ cout << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , ";
    logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 100005;

/* ...o(^-^)o... */

int main(){
    map<string, int> blue, red;
    ii(n); rep(i,n){ string s; cin>>s; blue[s]++; }
    ii(m); rep(i,m){ string s; cin>>s; red[s]++; }
    int ans = 0;
    for(auto& b : blue) ans = max(ans, b.se - red[b.fi]);
    out(ans);
}

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

typedef long long ll;

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

    int n; cin >> n;
    vector<int> a(n+2),diff(n+1);
    a[0] = 0; a[n+1] = 0;
    for(int i=0;i<n;i++){
        cin >> a[i+1];
        diff[i] = abs(a[i+1] - a[i]);
    }
    diff[n] = abs(a[n]);
    ll sum = 0;
    for(int i=0;i<n+1;i++) sum += diff[i];
    for(int i=1;i<n+1;i++){
        int hiku = diff[i-1] + diff[i];
        int tasu = abs(a[i+1]-a[i-1]);
        cout << sum-hiku+tasu << endl;
    }
    return 0;
}

Measured memory_bytes: 2048
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>
#include <stack>

using namespace std;

typedef long long ll;
typedef long double ld;

#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect
#define mkt make_tuple
#define no {cout << -1; return;}

void solve() {
    int a, b, c;
    cin >> a >> b >> c;
    cout << (a + b - 1) / b * c;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //int t; cin >> t; loop(i, t)
    solve();
    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

bool is_tasai(string a) {
    vector<int> A(26, 0);
    for(char b: a) {
        A[b - 'a']++;
        if(A[b - 'a'] >= 2) return false;
    }
    return true;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    string s;
    cin >> s;
    int n = (int)s.size();
    for(int i = n; i >= 0; i--) {
        string t = s.substr(0, i);
        rep(j, 26) {
            string u = t;
            u += 'a' + j;
//            output(u);
            if(is_tasai(u) && u > s) {
                output(u);
                return 0;
            }
        }
    }
    output(-1);
    
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
#include <utility>
#include <cstring>
#include <numeric>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
#define rep(i,n) for(int i=0;i<n;i++)
#define repll(i,n) for(long long int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
template <typename T_char>
char ToUpper (char cX) { return toupper(cX); }
//g++ -std=c++1z temp.cpp
//./a.exe
ll digit(ll a){
    ll count = 0;
    for (ll i = 0; i < a; i++)
    {   if (a == 0)
        {
            break;
        }else
        {
            a = a/10;
            count++;
        }
    }
    return count;
}

uintmax_t comb(unsigned int n, unsigned int r) {
  if ( r * 2 > n ) r = n - r;
  uintmax_t dividend = 1;
  uintmax_t divisor  = 1;
  for ( unsigned int i = 1; i <= r; ++i ) {
    dividend *= (n-i+1);
    divisor  *= i;
  }
  return dividend / divisor;
}
//桁数のカウント
//pow(x,n) == x^n
//sum = accumulate(v.begin(),v.end(),0);
using Graph = vector<vector<int>>;




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

ll x;
cin >> x;

for(ll i = -200;i < 200;i++){
  for(ll j = -200;j < 200;j++){
    ll ans = pow(i,5) - pow(j,5);
    if(ans == x){
      cout << i << ' ' << j << endl;
      return 0;
    }
  }
}


//////////////////////////////////////////////////////
return 0;}


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

void Preorder(vector< vector<int> > &T,int root){
	cout <<" "<< root;
	if(T[root][0]!=-1) Preorder(T,T[root][0]);
	if(T[root][1]!=-1) Preorder(T,T[root][1]);
	return;
}

void Inorder(vector< vector<int> > &T,int root){
	if(T[root][0]!=-1) Inorder(T,T[root][0]);
	cout <<" "<< root;
	if(T[root][1]!=-1) Inorder(T,T[root][1]);
	return;
}

void Postorder(vector< vector<int> > &T,int root){
	if(T[root][0]!=-1) Postorder(T,T[root][0]);
	if(T[root][1]!=-1) Postorder(T,T[root][1]);
	cout <<" "<< root;
	return;
}

int main(){
	int n,i,j,k,d,e;
	cin >> n;
	
	vector< vector<int> > T(n);
	vector<int> check(n,0); 
	
	for (i=0;i<n;i++){
		cin >> k;
		for (j=0;j<2;j++){
			cin >> e;
			T[k].push_back(e);
			if(e!=-1) check[e]=1;
		}
	}
	
	int r;
	for (i=0;i<n;i++){
		if(check[i]==0){
			r=i;
			break;
		}
	}
	cout << "Preorder" <<endl;
	Preorder(T,r);
	cout <<endl;
	cout << "Inorder" <<endl;
	Inorder(T,r);
	cout <<endl;
	cout << "Postorder" <<endl;
	Postorder(T,r);
	cout <<endl;
	
	return 0;
}

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

int main(){
	int n,m,c;
	int l=0;
	cin>>n>>m>>c;
	int B[25];
	for(int i=0;i<m;i++){
	    cin>>B[i];
	}
    int A[n][m];
	for(int i=0;i<n;i++){
		int k=c;
		for(int j=0;j<m;j++){
	        cin>>A[i][j];
		    k+=(A[i][j]*B[j]);
		}
		if(k>0){
			l++;
		}

	}
	cout<<l<<endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<string>
#include<vector>
#include<deque>
#include<queue>

using std::cout;
using std::cin;
using std::setw;
using std::setfill;
using std::string;
using std::pair;
using std::vector;
using std::queue;
using std::deque;
using std::priority_queue;
using std::sort;
using std::greater;
using std::max;
using std::min;

using lli = long long int;
using ulli = unsigned long long int;

#define EVEL 1

#ifndef EVEL
#define dbug(X) std::cout << #X << ":" <<X<<" " ;
#define dbugf(s) std::cout << s << " ";
#define dbugln std::cout<<"\n";
#else
#define dbug(X) {}
#define dbugf(s) {}
#define dbugln {}
#endif

int N, ans;
lli in, cnt=1;
vector<lli> A;

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

	cin >> N;
	for(int i = 0; i < N; i++){
		cin >> in;
		A.push_back(in);
	}
	sort(A.begin(), A.end());
	in = A[0];
	ans = N;
	dbug(A[0]);
	dbugf(0);
	dbugln;
	for(int i = 1; i < N; i++){
		if(A[i] == in){
			cnt++;

		}else{
			if(cnt > 1){
				if(cnt % 2==0)ans -= cnt;
				else ans -= cnt-1;
				cnt = 1;
			}
			in = A[i];
		}
		dbug(A[i]);
		dbug(i);
		dbug(cnt);
		dbug(ans);
		dbugln;
	}
	if(cnt > 1){
		if(cnt % 2 == 0)ans -= cnt;
		else ans -= cnt-1;
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 1400
require 'set'

n, m = gets.split.map(&:to_i)
k = []
a = []

n.times do |i|
  ka = gets.split.map(&:to_i)
  k.push  ka.first
  a.push ka[1..-1]
end

u = a.to_set.reduce([].to_set) { |sum, e| sum + e }

all = u.to_set
all = a.reduce(u) { |int, e| int & e }

puts all.size


Measured memory_bytes: 2044
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cassert>
#include<sstream>
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>
#include<cstring>

using namespace std;

typedef unsigned uint;
typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;

struct tank{
	tank *l,*r;
	int m;
	int a;
	int h;
	int w;
} end;
tank *root;
int left(tank *t){
	return (t->a)*(t->h) - t->w;
}

void add(int x,int w){
//	cout << x <<"	" << w << endl;
	tank *cur=root;
	if(left(cur)==0) return;
	while(cur->l!=&end){
		if((cur->m)<x){
			if(left(cur->r)==0){
				if(left(cur->l)==0) break;
				else cur=cur->l;
			}else cur=cur->r;
		}else{
			if(left(cur->l)==0){
				if(left(cur->r)==0) break;
				else cur=cur->r;
			}else cur=cur->l;
		}
	}
	if(left(cur)>=w) cur->w+=w;
	else{
		int l=left(cur);
		cur->w+=l;
		w-=l;
		add(x,w);
	}
}

double height(int x){
	double h=50;
	tank *cur=root;
	while(cur->w==0){
		if(cur->l==&end) return 0;
		h-=cur->h;
		if(cur->m>x) cur=cur->l;
		else cur=cur->r;
	}
//	printf("%d	%d	%d	%d\n",cur->m,cur->a,cur->h,cur->w);
	return h-(cur->h)+((double)cur->w/cur->a);
}

bool sepcmp(pint a,pint b){
	return a.second > b.second;
}
bool qcmp(pair<pair<int,double>,pint> a,pair<pair<int,double>,pint> b){
	return a.second.second < b.second.second;
}

int main(){
	int d,n,m,l;
	cin >> d;
	int i,j,k;
	for(int ii=0;ii<d;ii++){
		root = new(tank);
		root->l = &end;
		root->r = &end;
		root->a = 100*30;
		root->h = 50;
		root->w = 0;
		cin >> n;
		pint sep[15];
		for(i=0;i<n;i++){
			cin >> sep[i].first >> sep[i].second;
		}
		sort(sep,sep+n,sepcmp);
		for(i=0;i<n;i++){
			int h=50;
			int l=0;
			int r=100;
			tank *cur = root;
			while(cur->l!=&end){
				h-=cur->h;
				if(cur->m > sep[i].first) r=cur->m,cur=cur->l;
				else l=cur->m,cur=cur->r;
			}
			cur->m=sep[i].first;
			cur->h-=sep[i].second;
			cur->l = new(tank);
			cur->r = new(tank);
			cur->l->l=&end; cur->l->r=&end; cur->r->l=&end; cur->r->r=&end;
			cur->l->a=(sep[i].first-l)*30; cur->r->a=(r-sep[i].first)*30;
			cur->l->h=sep[i].second; cur->r->h=sep[i].second;
			cur->l->w=0; cur->r->w=0;
		}
		
		pint fau[15];
		cin >> m ;
		for(i=0;i<m;i++) cin >> fau[i].first >> fau[i].second;
		
		pair<pair<int,double>,pint> q[15];
		cin >> l;
		for(i=0;i<l;i++) cin >> q[i].second.first >> q[i].second.second, q[i].first.first=i;
		sort(q,q+l,qcmp);
		
		int t=0;
		for(i=0;i<l;i++){
			for(j=0;j<m;j++){
				add(fau[j].first,fau[j].second*(q[i].second.second-t));
			}
			q[i].first.second=height(q[i].second.first);
			t=q[i].second.second;
		}
		
		sort(q,q+l);
		for(i=0;i<l;i++){
			printf("%.4f\n",q[i].first.second);
		}
	}
	return 0;
}

Measured memory_bytes: 0
# 入力が10**5とかになったときに100ms程度早い
import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_matrix(H):
    '''
    H is number of rows
    '''
    return [list(map(int, read().split())) for _ in range(H)]


def read_map(H):
    '''
    H is number of rows
    文字列で与えられた盤面を読み取る用
    '''
    return [read() for _ in range(H)]


def read_col(H, n_cols):
    '''
    H is number of rows
    n_cols is number of cols

    A列、B列が与えられるようなとき
    '''
    ret = [[] for _ in range(n_cols)]
    for _ in range(H):
        tmp = list(map(int, read().split()))
        for col in range(n_cols):
            ret[col].append(tmp[col])

    return ret


A, B, T = read_ints()

print(B*(T//A))


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define all(v) v.begin(),v.end()
#define rep(a,n,b) for(int i=a;i<n;i+=b)
#define rrep(a,n,b) for(int i=n;i>=a;i-=b)
#define iter(obj) for(auto x : obj) 
#define pb(i) push_back(i)
#define ff first
#define ss second
#define pchr(flag) cout<<(flag ? "YES" : "NO")
#define ll long long int
#define input freopen("input.txt","r",stdin)
#define op freopen("output.txt","w",stdout);
#define fastio std::ios::sync_with_stdio(false)
using namespace std;
const int N = 2e5+7;
const int MOD  = 1000000007;
const float PI = 3.1415926535;
int arr[N];
//33333333333;
int main()  {
	// input;  	
	fastio;
	string a;
	cin>>a;
	int n =a.size(),res=0;
	rep(0,n/2,1) {
		if(a[i] != a[n-(i+1)]) res++;
	}
	cout<<res;
} 


Measured memory_bytes: 256
#include <iostream>
int main(){
    int m, f, b;
    std::cin >> m >> f >> b;
    if(m+f<b){
        std::cout << "NA" << std::endl;
    }else if(m<b){
        std::cout << b-m << std::endl;
    }else{
        std::cout << 0 << std::endl;
    }
    return 0;
}


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

int main(){
  int a, b, c;
  cin>>a>>b>>c;
  if(a > b) swap(a, b);
  if(b > c) swap(b, c);
  if(a > b) swap(a, b);

  cout<<a<<" "<<b<<" "<<c<<endl;
  return 0;
}
    


Measured memory_bytes: 3076
#include <iostream>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <algorithm>
#include <functional>
#include <cstring>
#include <limits.h>

#define FOR(i,k,n)  for (int i=(k); i<(int)(n); ++i)
#define REP(i,n)    FOR(i,0,n)
#define FORIT(i,c)	for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define SZ(i) ((int)i.size())
#define pb          push_back
#define mp          make_pair
#define mt          make_tuple
#define ALL(X)      (X).begin(),(X).end()
#define LLMAX       9223372036854775807
#define LLMIN       -9223372036854775808
#define IMAX        2147483647
#define IMIN        -2147483648
typedef long long LL;

using namespace std;


int main(void){
    int N;
    vector<LL> A;
    vector<LL> S;
    cin>>N;
    REP(i,N){
        int a;
        cin>>a;
        A.pb(a);
    }
    sort(ALL(A));
    LL s=0;
    REP(i,N){
        s+=A[i];
        S.pb(s);
    }
    int ans=1;
    for(int i=N-2;0<=i;i--){
        if(S[i]*2 < A[i+1])
            break;
        ans++;
    }
    cout<<ans<<endl;
     return 0;
}

Measured memory_bytes: 2548
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define INF (1 << 30)
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
const long long mod = 1e9+7;

using namespace std;
using ll = __int64_t;
using ull = unsigned long long;

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

bool comp(const pair<int, ll>& p1, const pair<int, ll>& p2){
    return p1.second > p2.second;
}

//a, bの最大公約数．a > b
ull gcd(ull a, ull b){
    if(b == 0) return a;
    return gcd(b, a%b);
}
//a, bの最小公倍数
ull lcm(ull a, ull b) {
    return a*(b/gcd(a, b));
}

void solve(){
    ull a, b, c, d;
    cin >> a >> b >> c >> d;
    ull cstart, cend, dstart, dend;
    if(a%c == 0){
        cstart = a/c;
    }else{
        cstart = (a/c)+1;
    }
    cend = b/c;
    if(a%d == 0){
        dstart = a/d;
    }else{
        dstart = (a/d)+1;
    }
    dend = b/d;
    ull e = lcm(c, d);
    ull estart, eend;
    if(a%e == 0){
        estart = a/e;
    }else{
        estart = (a/e)+1;
    }
    eend = b/e;
    ull cNum = cend - cstart + 1;
    ull dNum = dend - dstart + 1;
    ull eNum = eend - estart + 1;
    ull ans = (1+b-a) - cNum - dNum + eNum;
//    cout << "b-a=" << (b-a) << ", c=" << cNum << ", d=" << dNum << ", e=" << eNum << endl; 
    cout << ans << endl;
}

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

Measured memory_bytes: 256
import collections
S = input()
dq = collections.deque(S)
Q = int(input())
q = []
hanten = False
for _ in range(Q):
    q = input().split(" ")
    if q[0] == '1':
        hanten = not hanten
    else:
        if q[1] == '1' and not hanten:
            dq.appendleft(q[2])
        elif q[1] == '1' and hanten:
            dq.append(q[2])
        elif q[1] == '2' and not hanten:
            dq.append(q[2])
        else:
            dq.appendleft(q[2])
if not hanten:
    print(''.join(dq))
else:
    print(''.join(dq)[::-1])

Measured memory_bytes: 8564
//API???????????????
import java.util.Scanner;

class Main{
      public static void main(String[] args){
	//???????????\???
    	Scanner scan = new Scanner(System.in);
    	int n;
    	int x;
    	int total = 0;
    	int c = 3 * 2 * 1; //3?????????????????????????????????????????????
    	int end = 0;
    	
	
    	for(int count = 0;;count = 0){
		//???????????´??°?????????????????£??\
    		n = scan.nextInt();
    		x = scan.nextInt();
    		
		//????????¨???0????????????
    		if(n == end && x == end){
    			break;
    		}
    		
    		for(int i = 1; i <= n; i++){
    			for(int j = 1; j <= n; j++){
    				for(int k = 1; k <= n; k++){
    					if(i != j && j != k && k != i){
	    					total = i + j + k;
	    	    			if(x == total) count++;
    					}
    	    			}
        		}
    		}
		count /= c;
    		System.out.println(count);
    	}
    }
}

Measured memory_bytes: 26668
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <cmath>
#include <limits>
#include <utility>
#include <map>
#include <iomanip>
#include <queue>
#include <cctype>
#include <stack>
#include<set>


#define rep(i,p,q) for(ll i = p;i < q;++i)
#define ll long long

using namespace std;

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll npk(ll n, ll k) {
	ll ret = 1;
	if (n < k || n < 0)return 0;
	rep(i, 0, k) {
		ret *= (n - i);
		ret %= MOD;
	}
	if (ret < 0) ret = 0;
	return ret;
}

/*
//135 E
int main(void) {
	ll n;
	cin >> n;
	ll x, y;
	cin >> x >> y;
	ll k = (abs(x) + abs(y)) % n;
	if (k == 0)
	{
		cout << (x + y) / n << endl;
	}
	else if (k % 2 != 0) cout << -1 << endl;
	else {
		auto ans = vector<pair<ll, ll>>();
		ll p = 0, q = 0;
		if (abs(x - p) + abs(y - q) > n) {
			if (abs(x - p) <= abs(y - p)) {
				for (ll i = 1; i * n < x; i++) {
					p += n * x / abs(x);
					ans.push_back(make_pair(p, q));
				}
				//x= 0 or y = 0で確かめる
				if (y != 0) {
					q = (n - abs(x - p)) * y / abs(y);
					if (x != 0)p = abs(x - p) * x / abs(x);
					ans.push_back(make_pair(p, q));
				}
			}
			else {
				for (ll i = 1; i * n < y; i++) {
					q += n * y / abs(y);
					ans.push_back(make_pair(p, q));
				}
				//x= 0 or y = 0で確かめる
				if (x != 0) {
					p = (n - abs(y - q)) * x / abs(x);
					if (y != 0)q = abs(y - q) * y / abs(y);
					ans.push_back(make_pair(p, q));
				}
			}
		}
		if(x == p && y == q){}
		else {
			while (abs(x - p) + abs(y - q) > n) {
				if (x == p) {
					q += n;
					ans.push_back(make_pair(p, q));
					if (y == q)break;
				}
				else if (y == q) {
					p += n;
					ans.push_back(make_pair(p, q));
					if (x == p)break;
				}
			}
			if (x != p || y != q) {
				ll dist = abs(x - p) + abs(y - q);
				if (dist %= 2 != 0)cout << "-1" << endl;
				else {
					ll wMove = n - dist / 2;
					if (wMove > 0) {
						if (max(abs(x - p), abs(y - q)) < abs(wMove));
					}
				}
			}
		}
		
	}
}
*/

//135 D
int main(void) {
	string s;
	cin >> s;
	vector<vector<ll>> dp = vector<vector<ll>>(s.length(), vector<ll>(13,0));
	rep(i, 0, s.length()) {
		if (i == 0) {
			if (s[i] == '?') {
				rep(j, 0, 10) {
					dp[i][j] += 1;
				}
			}
			else dp[i][s[i] - '0'] += 1;
		}
		else {
			rep(j, 0, 13) {
				if (s[i] == '?') {
					rep(k, 0, 10) {
						ll num = j * 10 + k;
						dp[i][num % 13] += dp[i-1][j];
						dp[i][num % 13] = dp[i][num % 13] % MOD;
					}
				}
				else {
					ll num = j * 10 + s[i] - '0';
					dp[i][num % 13] += dp[i-1][j];
					dp[i][num % 13] = dp[i][num % 13] % MOD;
				}
			}
			
		}
	}
	cout << dp[s.length() - 1][5] << endl;
}


Measured memory_bytes: 13696
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
int n,m,a[200000],p[200000];
vector<int> v[200000],u;
int find(int x){return p[x]==x?x:p[x]=find(p[x]);}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++)scanf("%d",a+i),p[i]=i;
	for(int i=0;i<m;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		p[find(x)]=find(y);
	}
	for(int i=0;i<n;i++)v[find(i)].push_back(a[i]);
	long long ans=0,cnt=0;
	for(int i=0;i<n;i++)
		if(!v[i].empty())
		{
			cnt++;
			sort(v[i].begin(),v[i].end());
			ans+=v[i].front();
			for(int j=1;j<v[i].size();j++)u.push_back(v[i][j]);
		}
	if(cnt==1){puts("0");return 0;}
	sort(u.begin(),u.end());
	for(int i=0;i<2*(n-m-1)-cnt;i++)
		if(u.size()<=i){puts("Impossible");return 0;}
		else ans+=u[i];
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 9472
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>

using namespace std;

typedef  long long int lint;

#define rep(i, n) for (lint i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define mp make_pair
#define enld endl

int main() {
	lint N, M;
	cin >> N >> M;
	vector<vector<char>>A(N, vector<char>(N));
	vector<vector<char>>B(M, vector<char>(M));
	rep(i, N) {
		rep(j, N) {
			cin >> A[i][j];
		}
	}
	rep(i, M) {
		rep(j, M) {
			cin >> B[i][j];
		}
	}
	bool ok = true;
	for (int i = 0; i <= N - M; i++) {
		for (int j = 0; j <= N - M; j++) {
			ok = true;
			rep(k, M) {
				rep(l, M) {
					if (A[i + k][j + l] != B[k][l]) {
						ok = false;
					}
				}
			}
			if (ok) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
}

Measured memory_bytes: 3576
#include <iostream>
#include <math.h>

long long ze(long long a, long long b);

int main(){
  
  long long n;
 
  scanf("%lld",&n);
  
  long long a[n+2];
  a[0]=0;
  a[n+1]=0;
  
  for(long long i=1;i<=n;i++){
    scanf("%lld",&a[i]);
  }
 
  long long ans=0;

  for(long long i=0;i<=n;i++){
    ans=ans+ze(a[i],a[i+1]);
  }

  for(long long i=0;i<n;i++){
    printf("%lld\n",ans-ze(a[i],a[i+1])-ze(a[i+1],a[i+2])+ze(a[i],a[i+2]));
  }



  
  
  return 0;
}

long long ze(long long a,long long b){
  if(a>b){
    return (a-b);
  }
  else{
    return (b-a);
  }
}


Measured memory_bytes: 2048
#include <stdio.h>

int main(void)
{
	int a,b=0;
	scanf("%d",&a);
	if(a==3){
		b++;
	}else if(a==5){
		b++;
	}else if(a==7){
		b++;
	}
	if(b==0){
		printf("NO");
	}else{
		printf("YES");
	}
	return 0;
}

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

int main() {
    int h, w;
    cin >> h >> w;

    vector<vector<char>> field(h, vector<char>(w));
    vector<vector<int>> dp(h, vector<int>(w));

    for(int i = 0; i < h; i++)
        for(int j = 0; j < w; j++)
            cin >> field[i][j];

    dp[0][0] = (field[0][0] == '#' ? 1 : 0);
    for(int i = 1; i < h; i++)
        dp[i][0] = dp[i-1][0] + (field[i][0] == '#' && field[i-1][0] != '#' ? 1 : 0);
    for(int j = 1; j < w; j++)
        dp[0][j] = dp[0][j-1] + (field[0][j] == '#' && field[0][j-1] != '#' ? 1 : 0);
    
    for(int i = 1; i < h; i++)
        for(int j = 1; j < w; j++)
            dp[i][j] = min(
                dp[i-1][j] + (field[i][j] == '#' && field[i-1][j] != '#' ? 1 : 0),
                dp[i][j-1] + (field[i][j] == '#' && field[i][j-1] != '#' ? 1 : 0)
            );
    
    cout << dp[h-1][w-1] << '\n';
}

Measured memory_bytes: 256
a,b = map(int,input().split())
s = input()
for i in range(a+b+1):
  if i == a:
    if s[i] != '-':
      print('No')
      exit()
  else:
    if not '0' <= s[i] <= '9':
      print('No')
      exit()
  
print('Yes')

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

typedef long long Int;
typedef pair<int,int> PII;
typedef vector<int> VInt;
 
#define FOR(i, a, b) for(i = (a); i < (b); ++i)
#define RFOR(i, a, b) for(i = (a) - 1; i >= (b); --i)
#define EACH(it, a) for(auto it = (a).begin(); it != (a).end(); ++it)
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define SIZE(a) int((a).size())
#define ALL(a) (a).begin(),(a).end()
#define MP make_pair

int f(vector<Int>& v)
{
	int n = SIZE(v);
	int i, j;
	int cnt = 0;
	FOR(i, 0, 60)
	{
		FOR(j, cnt, n)
			if(v[j] & (1LL << i))
				break;

		if(j == n) continue;
		if(j != cnt) swap(v[j], v[cnt]);
		FOR(j, cnt + 1, n)
			if(v[j] & (1LL << i))
				v[j] ^= v[cnt];

		++cnt;
	}
	return cnt;
}

void SolveTest(int test)
{
	int N;
	cin >> N;
	vector<Int> v(N);
	int i;
	FOR(i, 0, N) cin >> v[i];
	string S;
	cin >> S;
	int prev = 0;
	RFOR(i, N, 0)
	{
		vector<Int> w(v.begin() + i, v.end());
		int r = f(w);
		if(r != prev && S[i] == '1') break;
		prev = r;
	}
	cout << (i == -1 ? 0 : 1) << endl;
}

int main()
{
	int T, t;
	cin >> T;
	FOR(t, 0, T) SolveTest(t);
	return 0;
};

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

const int N = 2e5 + 10;
const ll mod = 1e9 + 7;
int n, a, b;
vector<int>v[N];

ll ksm(ll a, ll p)
{
    ll ans = 1;
    while (p)
    {
        if (p & 1) ans = ans * a % mod;
        a = a * a % mod;
        p >>= 1;
    }
    return ans;
}

ll dp[N], siz[N];
void dfs1(int son, int fa)
{
    siz[son] = 1;
    for (auto x: v[son])
    {
        if (x == fa) continue;
        dfs1(x, son);
        siz[son] += siz[x];
    }
}
void dfs2(int son, int fa)
{
    for (auto x: v[son])
    {
        if (x == fa) continue;
        dp[x] = dp[son] * ksm(siz[x], mod - 2) % mod * (n - siz[x]) % mod;
        dfs2(x, son);
    }
}

int main()
{
    ios::sync_with_stdio(false);
    cin >> n;
    for (int i = 1; i < n; i++)
    {
        cin >> a >> b;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    
    dfs1(1, 0);
    dp[1] = 1;
    for (int i = 1; i <= n; i++) dp[1] = dp[1] * siz[i] % mod;
    dfs2(1, 0);
    
    ll ans = 1;
    for (int i = 1; i <= n; i++) ans = ans * i % mod;
    for (int i = 1; i <= n; i++) cout << ans * ksm(dp[i], mod - 2) % mod << endl;
}

Measured memory_bytes: 17140
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt()
  val c = IndexedSeq.fill(n)((sc.nextInt(), sc.nextInt()))
  val a = c.map(_._1).sorted
  val b = c.map(_._2).sorted

  val amed = if (n % 2 == 1) a((n-1)/2) else a(n/2 - 1) + a(n/2)
  val bmed = if (n % 2 == 1) b((n-1)/2) else b(n/2 - 1) + b(n/2)
  println(bmed - amed + 1)
}

Measured memory_bytes: 76648
#include<bits/stdc++.h>
using namespace std;
const int maxn=200100;
int a[maxn],las[maxn];
int tr[maxn<<2];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	las[1]=1;
	for(int i=2;i<=n;i++){
		if(a[i]==0) las[i]=i;
		else las[i]=las[i-1];
	}
	long long ans=0;
	for(int i=n;i>=1;i--){
		if(a[i]==0) continue;
		if(a[i]>i-las[i]){
			puts("-1");
			return 0;
		}
		if(a[i]==a[i+1]-1) continue;
		if(a[i]>=a[i+1])
			ans+=a[i];
		else{
			puts("-1");
			return 0;
		}
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 2944
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
ll n;cin >> n;
vector<ll>a(n);
for(int i = 0;i<n;i++) cin >> a[i];
sort(a.rbegin(),a.rend());
ll sum = a[0];
int t = n-2;
int j = 1;
while(t){
    if(t==1) {sum += a[j];break;}
    sum += 2*a[j];
    j++;
    t = t-2;
}
cout << sum;
return 0;
}

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

using namespace std;

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

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll maxn  = 3e6;
const ll mod =1e9+7;
const ld PI = acos((ld)-1);

#define pb push_back
#define endl '\n'
#define dokme(x) return(cout << x , 0);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ms(x , y) memset(x , y , sizeof x);
#define file_init freopen("input.txt", "r+", stdin); freopen("output.txt", "w+", stdout);
ll pw(ll a, ll b, ll md = mod){ll res = 1;while(b){if(b&1){res=(a*res)%md;}a=(a*a)%md;b>>=1;}return(res);}

int n;
int ans = 0;
int a[maxn];
int k;
vector < int > ch[maxn];
int dp[maxn];

void dfs(int v){
    for(auto u : ch[v]){
        dfs(u);
        if(dp[u]== k - 1 and v!=1)
            ans++;
        else dp[v] = max(dp[v] , dp[u] + 1);
    }
}

int main(){
    migmig
    cin >> n >> k;
    for(int i = 1 ; i <= n ; i ++)
        cin >> a[i];
    if(a[1]!=1)
        ans++ , a[1] = 1;
    for(int i = 2; i <= n ; i ++)
        ch[a[i]].pb(i);
    dfs(1);
    cout << ans;
    return(0);
}

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

fn main() {
    let S = get!(String);
    let S: Vec<char> = S.chars().collect();
    for win in S.windows(2) {
        if win[0] == win[1] {
            println!("Bad");
            return;
        }
    }
    println!("Good");
}


Measured memory_bytes: 4352
integer N
integer(16),allocatable,dimension(:)::A,B
integer(16) ans
read*,N
allocate(A(N),B(0:N))
read*,A
B(0)=0
do i=1,N
  B(i)=A(i)+B(i-1)
end do
ans=huge(ans)
do i=1,N-1
  ans=min(ans,abs(2*B(i)-B(N)))
end do
print"(I0)",ans
end

Measured memory_bytes: 7040
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define  rep(i,n) for(ll i = 0; i < (n); ++i)
#define  red(i,n) for(ll i = (n)-1; i >= 0; --i)
inline ll gcd(ll a,ll b) { return b?gcd(b,a%b):a; }

int main()
{
    string s,t;
    cin>>s>>t;
    int ans=0;
    red(i,s.size()) ans+=(s[i]==t[i]);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   cout.tie(NULL);
   ll a,b,c,d;
   cin>>a>>b>>c>>d;
   ll res=max(a*c,a*d);
   ll x=max(b*c,b*d);
   cout<<max(res,x);
}


Measured memory_bytes: 3632
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<string>
#include<bitset>
#include<cfloat>
#include<iomanip>
#include<numeric>

//#define int long long
#define repi(i,start,end) for(int (i)=(start),TemPNuM=(int)(end);(i)<TemPNuM;++(i))
#define rep(i,end) repi((i),0,(end))
#define rfor(x,v) for(auto& (x) : (v))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fsort(v,lambda) sort(all((v)),(lambda))
#define vin(v) rep(i,(v).size())cin >> (v)[i];
#define vpin(v) rep(i,(v).size())cin>>v[i].first>>v[i].second

using namespace std;
using ll =  long long;
using pint =  pair<int,int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vpint = vector<pint>;

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; }
template<class T>void put_double(T a){if(cout.precision()!=12)cout<<setprecision(12);cout<<a<<endl;}
template<class T>void print(T a){cout << a << endl;}
//lambda: [](int x, int y){return x<y;}

signed main(void) {
    int n, k; cin >> n >> k;
    vector<double> p(n); vin(p);
    rep(i, n) p[i] = (p[i] + 1.0) / 2.0;
    vector<double> sum(n + 1, 0);
    rep(i, n) sum[i + 1] = sum[i] + p[i];
    double ans = 0;
    rep(i, n - k + 1) {
        chmax(ans, sum[i + k] - sum[i]);
    }
    put_double(ans);
    return 0;
}


Measured memory_bytes: 3328
import sys
import collections


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n = int(readline())
    a = list(map(int, readline().split()))
    d = collections.defaultdict(int)
    t = 1
    for i in range(n):
        if a[i] == 0:
            t *= 3 - d[0]
            d[a[i]] += 1
        else:
            t *= d[a[i]-1] - d[a[i]]
            d[a[i]] += 1
        t %= mod
    print(t)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 55524
//package atcoder;
 
import java.util.*;
//import java.math.BigDecimal;
 
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		String T = sc.next();
		StringBuilder sb = new StringBuilder();
		sb.append(T);
		sb.append(S);
		System.out.println(sb);
	}
}

Measured memory_bytes: 21716
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) {
			int h = scanner.nextInt();
			int w = scanner.nextInt();
			int n = scanner.nextInt();
			if ((h | w | n) == 0)
				break;
			int[][] map = new int[h + 1][w + 1];
			map[0][0] = --n;
			for (int i = 0; i < h; i++)
				for (int j = 0; j < w; j++) {
					int m = scanner.nextInt();
					map[i][j + 1] += (map[i][j] + (m & 1)) / 2;
					map[i+1][j] +=(map[i][j]+(m^1))/2;
					map[i][j] = (map[i][j]+m)%2;
				}
			int px = 0;
			int py = 0;
			while (px < w && py < h) {
				if (map[py][px] == 1)
					px++;
				else
					py++;
			}
			System.out.println((py + 1) + " " + (px + 1));
		}
	}
}

Measured memory_bytes: 296508
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	int x,y,z;
	cin>>x>>y>>z;
	if(x<=y && y<=z ) cout<<x<<" "<<y<<" "<<z<<endl;
	else if(x<=y && y>=z && x<=z) cout<<x<<" "<<z<<" "<<y<<endl;
	else if(x>=y && x>=z && y<=z) cout<<y<<" "<<z<<" "<<x<<endl;
	else if(x>=y && x<=z && y<=z) cout<<y<<" "<<x<<" "<<z<<endl;
	else if(z<=y && z<=x && y<=x) cout<<z<<" "<<y<<" "<<x<<endl;
	else if(z<=x && x<=y && z<=y) cout<<z<<" "<<x<<" "<<y<<endl;
	return 0;
}


Measured memory_bytes: 3108
A, B = map(int, input().split())

def make_divisors(a, b):
    n = min(a, b)
    m = max(a, b)
    import math
    divisors = []
    for i in range(2, int(math.sqrt(n)) + 1):
        if n == 1:
            break
        if n % i == 0: #割り切れるとき
            if m % i == 0:
                divisors.append(i)
            while n % i == 0 and n != 1:
                n //= i
    if n != 1 and m % n == 0:
        divisors.append(n)
    return divisors

lst = make_divisors(A, B) #この中から素数を数えたらいい
print (len(lst) + 1)


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

// typedef
// -----------------------------------------------------------------------------
typedef long long LL;

// repetition
// -----------------------------------------------------------------------------
#define FOR(i, a, b) for(int i= (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

// constant
// -----------------------------------------------------------------------------
const int INF = 1e9;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
const double PI = acos(-1.0);

// debug
// -----------------------------------------------------------------------------
#define DUMP(x)  cerr << #x << " = " << (x) << endl

int N;
int p[100100];

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

    cin >> N;
    FOR(i, 1, N + 1) {
        cin >> p[i];
    }

    int ans = 0;
    FOR(i, 1, N) {
        if (p[i] == i) {
            swap(p[i], p[i + 1]);
            ans++;
        }
    }
    if (p[N] == N) ans++;

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

Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

int main(){
	ll n;
	scanf("%lld",&n);
	printf("%lld",(pom(10,n,MOD)-2*pom(9,n,MOD)+pom(8,n,MOD)+MOD+MOD)%MOD);
}

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

typedef vector<int> vi;
#define ll long long
#define loop(i,n) for(int i=0; i<n; i++)
#define loop1(i,n) for(int i=1; i<=n; i++)
#define loopi(i,s,e) for(int i=s; i < e; i++)
#define loopiRev(i,s,e) for(int i=s; i >= e; i--)
#define PI 3.14159265359
#define x first
#define y second
#define point pair<double,double>
#define len(s)   (int)s.length()
#define sz(v)    (int)v.size()
#define all(a)   a.begin(),a.end()
#define clr(x, val)	memset((x), (val), sizeof(x))

void initialize(vector<int> &F, int n){
    F = vector<int> (n+1, 0);

    for(int i=2; i*i  <= n; i++){
        if(F[i] == 0)
            for(int k=i*i; k <=n ; k+= i)
                if(F[k] == 0) F[k] = i;
    }
}

//you don't know math, unless you can do math!
int l,n;
vector<int> cuts;
ll dp[1100][1100];

ll solve(int i, int j){
    ll &ret= dp[i][j];
    if(ret != -1)
        return ret;

    int cur= lower_bound(cuts.begin(), cuts.end(), i+1) - cuts.begin();
    if(cur == cuts.size() || cuts[cur] >= j)
        return ret= 0;



    ret= 10000000;
    while(cur < n && cuts[cur] < j){
        ret = min(ret, solve(i, cuts[cur]) + solve(cuts[cur], j) + j - i);
        cur++;
    }

    return ret;
}
int main() {
    //freopen("input.txt" , "r" , stdin) ;
    //freopen("output.txt" , "w" , stdout) ;

    cin.tie(0);
    cin.sync_with_stdio(0);

    string a,b,c; cin>>a>>b>>c;

    cout<< (char)toupper(a[0]) << (char)toupper(b[0]) << (char)toupper(c[0]);
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <iostream>
using namespace std;
int main ()
{
	int n;
	int a[200009];
	int b[200009];
	scanf("%d",&n);
	for (int i = 1; i <= n; i++)
	{
		scanf("%d",&a[i]);
		b[i] = a[i];
	}
	sort(b+1,b+1+n);
	int x,y;
	x = b[n/2],y = b[n/2+1];
	for (int i = 1; i <= n; i++)
	{
		if (a[i] <= x) printf("%d\n",y);
		else printf("%d\n",x);
	}
}

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

int main(){
  int x, y;
  cin >> x >> y;
  
  int ans = 0;
  for(int i = x; i <= y; i++) {
  	int a, b, c, d, e;
  	e = i%10; d = (i-e)%100; c = (i-d-e)%1000; b = (i-e-c-d)%10000; a = (i-b-c-d-e)%1000000;
  
  	if(a == 10000*e && b == 100*d) {
    	ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
#define pb push_back
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pii pair<int,int>
using namespace std;
 
int main(){
    fast 
    ll n;cin>>n;
    string ans="";
    char x;
    
    while(n){
        if(n%26!=0){
             x='a'-1+n%26;n=n/26;}
        else {x='z';n=n/26-1;}
        
        ans=x+ans;
    
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <algorithm>
#include <functional>

int N, K, c[200009];
int main() {
	std::cin.tie(0);
	std::ios_base::sync_with_stdio(false);
	std::cin >> N >> K;
	for (int i = 0; i < N; i++) {
		int a;
		std::cin >> a;
		a--;
		c[a]++;
	}
	std::sort(c, c + N, std::greater<int>());
	int s = N;
	for (int i = 0; i < K; i++) s -= c[i];
	std::cout << s << "\n";
	return 0;
}


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

int main()
{
    int q,w,e,r,m,n;
    while(~scanf("%d %d %d %d",&q,&w,&e,&r))
    {
        m=q*w;
        n=e*r;
        if(m>n)
            printf("%d\n",m);
        else
            printf("%d\n",n);
    }
    return 0;
}


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

typedef long long ll;

#define v(T) vector<T>
#define ttt(T) tuple<T, T, T>
#define pb push_back
#define mp make_pair
#define rep(i, s, n) for(int i=s;i<n;i++)
#define repeq(i,s,n) for(int i=s;i<=n;i++)
#define poiu(n) for(int i=0; i < n; i++)
#define MOD (int)10e9+7
#define endl '\n'

template<typename T>
void max_self(T& a, T b) { a=a>b?a:b; }
template<typename T>
void min_self(T& a, T b) { a=a<b?a:b; }

using namespace std;

int n;
double temp;

double dp[3000];


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

    cin >> n;

    dp[0]=1;

    for(int coin=0; coin<n; ++coin) {
        cin >> temp;
        
        for(int i=coin+1; i>=0; --i) {
            dp[i]=(i==0? 0 : dp[i-1]*temp) + dp[i]*(1-temp);
        }
    }

    double ans = 0;
    for(int i=0; i<=n; ++i) {
        int tails = n-i;
        if(i>tails)
            ans+=dp[i];
    }
    printf("%.10lf\n", ans);
    return 0;

}




Measured memory_bytes: 256
import std.stdio, std.algorithm, std.string, std.conv, std.array, std.range, std.math;
int read() { return readln.chomp.to!int; }
int[] reads() { return readln.split.to!(int[]); }


void solve() {
    string s = readln;
    writeln(s.count('+').to!int - s.count('-').to!int);
}

void main() {
    solve();
    readln;
}

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

int tmp[100];
int n = 0;

int pop()
{
	n = n - 1;
	return tmp[n];
}

void push( int x )
{
	tmp[n] = x;
	n = n + 1;
}

int main()
{
	char input[200];
	int size = strlen( input );
	int i = 0;
	int a, b;
	char *tmpa;

	while ( scanf( "%s", input ) != EOF )
	{
		if ( input[0] == '+' )
		{
			a = pop();
			b = pop();
			push( b + a );
		}
		else if ( input[0] == '-' )
		{
			a = pop();
			b = pop();
			push( b - a );
		}
		else if ( input[0] == '*' )
		{
			a = pop();
			b = pop();
			push( a * b );
		}
		else
		{
			push( atoi( input ) );
		}
	}

	fprintf( stdout, "%d\n", tmp[n - 1] );

	return 0;
}

Measured memory_bytes: 548
def main():
    n = int(input())
    v_list = list(map(int, input().split()))
    c_list = list(map(int, input().split()))
    ans = 0

    for i in range(n):
        if v_list[i] > c_list[i]:
            ans += v_list[i] - c_list[i]

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 61752
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>

using namespace std;

int main(){
	string s,t;
	cin>>s>>t;
	if(s.size()!=t.size()){
		cout<<"No"<<endl;
		return 0;
	}
	if(s==t){
		cout<<"Yes"<<endl;
		return 0;
	}
	int sz=s.size()-1;
	int fl=0;
	for(int i=0;i<sz;i++){
		s=s.substr(sz,1)+s.substr(0,sz);
		if(s==t){
			cout<<"Yes"<<endl;
			fl=1;
			break;
		}
	}
	if(!fl){
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
# Generated by AtcoderGreedy on 2018-05-12
# ARC097 C
# Your code here

$s = gets.chomp

$K = gets.chomp.to_i - 1

$dict = {}

$s.size.times do |i|
  $dict[$s[i]] ||= []

  (0...5).each do |j|
    $dict[$s[i]] << $s[i..(i + j)]
  end
end

$dict = $dict.sort

group = 0

$dict.each do |item|
  key = item[0]
  values = item[1].uniq.sort

  if group <= $K && $K < values.size + group
    puts values[$K - group]
    break
  else
    group += values.size
  end
end


Measured memory_bytes: 3836
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin>>S;
  int s=S.size();
  map<char,int> ma;
  for(int i=0;i<s;i++){
    ma[S[i]]++;
  }
  for(char c='a';c<='z';c++){
    if(ma[c]==0){
      cout<<c<<endl;
      return 0;
    }
  }
  cout <<"None"<<endl;
}

Measured memory_bytes: 3680