akhauriyash/Code-Regression huggingface dataset:
//Finite Disappointment and Infinite Hope
#include <bits/stdc++.h>
using namespace std;
#define help ios_base:: sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define dbg(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) { cerr<<endl; }
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << "\t"; err(++it, args...);
}
template<typename T1,typename T2>
ostream& operator <<(ostream& c,pair<T1,T2> &v){
	c<<"("<<v.first<<","<<v.second<<")"; return c;
}
template <template <class...> class TT, class ...T>
ostream& operator<<(ostream& out,TT<T...>& c){
    out<<"{ ";
    for(auto &x:c) out<<x<<" ";
    out<<"}"; return out;
}
typedef long long ll;
const ll N=2e5+5,MOD=1e9+7;
int main(){
help
    ll n,m;cin>>n>>m;
    if(n==m)cout<<"Yes";
    else cout<<"No";

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

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

struct Edge { int to, id;};

int main () {
  int n;
  cin >> n;
  vector<vector<Edge>> g(n);
  vi ans(n-1);
  rep(i,n-1) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    g[a].push_back((Edge){b,i});
    g[b].push_back((Edge){a,i});
  }

  queue<int> q;
  vi used(n);
  q.push(0);
  used[0] = 1;
  while (!q.empty()) {
    int v = q.front(); q.pop();
    int c = -1;
    rep(i,g[v].size()) {
      int u = g[v][i].to, ei = g[v][i].id;
      if (used[u]) c = ans[ei];
    }
    int k = 1;
    rep(i,g[v].size()) {
      int u = g[v][i].to, ei = g[v][i].id;
      if (used[u]) continue;
      if (k == c) ++k;
      ans[ei] = k++;
      q.push(u);
      used[u] = 1;
    }
  }

  int mx = 0;
  rep(i,n) {
    mx = max(mx, sz(g[i]));
  }
  cout << mx << endl;
  rep(i,ans.size()) printf("%d\n", ans[i]);
  return 0;
}

Measured memory_bytes: 7424
h, w, a, b = map(int, input().split())
for i in range(h):
  s = [0]*a+[1]*(w-a)
  t = [1]*a+[0]*(w-a)
  if i < b:
    print("".join(map(str, s)))
  else:
    print("".join(map(str, t)))

Measured memory_bytes: 42716
#while 1:
    #n=map(int,raw_input().split())




l = int(raw_input())


for i in range(l):
    n= int(raw_input())
    line = raw_input()
    arr = [ [0,0,0] for j in range(n+1)]
    u = [0] * (n+1)
    d = [0] * (n+1)
    
    if(line[0]=='Y'): u[0]=1
    if(line[2*n]=='Y'): d[0]=1
    if(line[2*n-1]=='Y'): u[n]=1
    if(line[4*n-1]=='Y'): d[n]=1
    for i in range(1,n):
        if(line[2*i-1]=='Y'): u[i]=1
        if(line[2*i]=='Y'): u[i]=1
        if(line[2*n + 2*i-1]=='Y'): d[i]=1
        if(line[2*n + 2*i]=='Y'): d[i]=1
    #
    #print "u",u
    #print "d",d
    
    if(u[0]==1 and d[0] ==1):
           arr[0][0]=3
           arr[0][1]=2
           arr[0][2]=2
    if(u[0]==1 and d[0] ==0):
           arr[0][0]=1
           arr[0][1]=1
           arr[0][2]=2
    if(u[0]==0 and d[0] ==1):
           arr[0][0]=3
           arr[0][1]=2
           arr[0][2]=2
    if(u[0]==0 and d[0] ==0):
           arr[0][0]=0
           arr[0][1]=1
           arr[0][2]=2
           
    for i in range(1 , n+1):
        if(u[i]==1 and d[i] ==1):
               arr[i][0]=min( \
                   arr[i-1][0]+1+3, \
                   arr[i-1][1]+1+2, \
                   arr[i-1][2]+1+2)
               arr[i][1]=min( \
                   arr[i-1][0]+1+2, \
                   arr[i-1][1]+1+2, \
                   arr[i-1][2]+1+2)
               arr[i][2]=min( \
                   arr[i-1][0]+1+2, \
                   arr[i-1][1]+1+2, \
                   arr[i-1][2]+1+3)
        if(u[i]==1 and d[i] ==0):
               arr[i][0]=min( \
                   arr[i-1][0]+1+1, \
                   arr[i-1][1]+1+1, \
                   arr[i-1][2]+1+2)
               arr[i][1]=min( \
                   arr[i-1][0]+1+1, \
                   arr[i-1][1]+1+1, \
                   arr[i-1][2]+1+2)
               arr[i][2]=min( \
                   arr[i-1][0]+1+2, \
                   arr[i-1][1]+1+2, \
                   arr[i-1][2]+1+3)
        if(u[i]==0 and d[i] ==1):
               arr[i][0]=min( \
                   arr[i-1][0]+1+3, \
                   arr[i-1][1]+1+2, \
                   arr[i-1][2]+1+2)
               arr[i][1]=min( \
                   arr[i-1][0]+1+2, \
                   arr[i-1][1]+1+1, \
                   arr[i-1][2]+1+1)
               arr[i][2]=min( \
                   arr[i-1][0]+1+2, \
                   arr[i-1][1]+1+1, \
                   arr[i-1][2]+1+1)
        if(u[i]==0 and d[i] ==0):
               arr[i][0]=min( \
                   arr[i-1][0]+1, \
                   arr[i-1][1]+1+1, \
                   arr[i-1][2]+1+2)
               arr[i][1]=min( \
                   arr[i-1][0]+1+1, \
                   arr[i-1][1]+1, \
                   arr[i-1][2]+1+1)
               arr[i][2]=min( \
                   arr[i-1][0]+1+2, \
                   arr[i-1][1]+1+1, \
                   arr[i-1][2]+1)
        #
    print arr[n][0]

           
        
       

    

Measured memory_bytes: 8928
#include <iostream>

using namespace std;

bool test(char&,char&,char&,char);

int main()
{
  char S[3] = {0};
  
  cin >> S[1];
  cin >> S[2];
  cin >> S[3];
  
  if(test(S[1],S[2],S[3],'A'))
  {
    cout << "No" << endl;
  }
  else if(test(S[1],S[2],S[3],'B'))
  {
    cout << "No" << endl;
  }
  else
  {
    cout << "Yes" << endl;
  }
}

bool test(char &a,char &b,char &c,char d)
{
  return a == d && b == d && c == d;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n;
  cin>>n;
  int flag=0;
  while(n!=0){
      int x=n%10;
      if(x==7){
          cout<<"Yes"<<endl;
          flag=1;
          break;
      }
      n/=10;
    
  }
  if(flag==0){
      cout<<"No"<<endl;
  }
  
 return 0; 
}

Measured memory_bytes: 3576
n = int(input())
a = list(map(int,input().split()))
mod = 10**9 + 7

sum_a = 0
sum_ex = 0
for ai in a:
    sum_a += ai
    sum_a %= mod
    sum_ex += ai**2
    sum_ex %= mod

ans = (sum_a*sum_a - sum_ex)%mod
ans *= pow(2,mod-2,mod)
ans %= mod
print(ans)

Measured memory_bytes: 94340
#include "bits/stdc++.h"
#define int long long
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef pair <int, int> pi;
const int MM = 1e5 + 34;
vector<pair<int,int>> g[MM];
int v[MM];
typedef long long lli;
lli D[102020], N, M;
void addedge(int from, int to, int wt) { //0 based , directed x to y
    g[from].push_back({to, wt});
    g[to].push_back({from, wt});

}
void dijkstra(int x) {
    for(int i = 0; i < N; i++) {
        D[i] = 1e18;
    }
    D[x] = 0;
    priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> q;
    q.push({0,x});
    
    while(!q.empty()) {
        pair<int,int> p = q.top();
        q.pop();
        
        int u = p.second, dist = p.first;
        if(dist > D[u]) {
            continue;
        }
    
        for(pair<int,int> pr : g[u]) {
            int v = pr.first;
            lli next_dist = dist + pr.second;
            if(next_dist < D[v]) {
                D[v] = next_dist;
                q.push({next_dist,v});
            }
        }
    }
}
int D1[MM], D2[MM];
int32_t main() {fio; // remove during scanf
	int S, T;
	cin >> N >> M >> S >> T;
	S--; T--;
	vector <pair <pi, pi> > edges;
	for(int i = 0; i < M; i++) {
		int u, v, y, s;
		cin >> u >> v >> y >> s;
		u--; v--;
		edges.push_back({{u, v}, {y, s}});
		addedge(u, v, y);
	}
	dijkstra(S);
	for(int i = 0; i < N; i++) {
		D1[i] = D[i];
		g[i].clear();
	}
	for(int i = 0; i < M; i++) {
		addedge(edges[i].first.first, edges[i].first.second, edges[i].second.second);
	}
	dijkstra(T);
	set <pi> ok;
	for(int i = 0; i < N; i++) {
		D[i] = D1[i] + D[i];
		ok.insert({D[i], i});
	}
	for(int i = 0; i < N; i++) {
		cout << 1000000000000000 - (*ok.begin()).first << '\n';
		ok.erase({D[i], i});
	}

    return 0;
}

Measured memory_bytes: 21612
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vv vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int> >
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define INF 1000000000
#define eps 1e-7
#define mod 1000000007
#define int ll
using namespace std;

signed main(void) {
    int A,B;cin>>A>>B;
    if (A%3==0||B%3==0||(A+B)%3==0) {
        cout << "Possible" << endl;
    } else {
        cout << "Impossible" << endl;
    }


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = (1 << 29);
const long long INFL = (1LL<<60);
const double eps = (1e-9);

int n, m;    // n: nodes, m: edges
vector<vector<int>> nodes(9);

int ans = 0;

void dfs(int v, vector<int>* visited)
{
  visited->push_back(v);
  if (visited->size() == n) {
    ans++;
    visited->pop_back();
    return;
  }
  for (int i : nodes[v]) {
    if (find(visited->begin(), visited->end(), i) == visited->end()) {
      dfs(i, visited);
    }
  }
  visited->pop_back();
  return;
}

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

  rep(i, m) {
    int a, b;
    cin >> a >> b;
    nodes[a].push_back(b);
    nodes[b].push_back(a);
  }
  vector<int> visited;

  dfs(1, &visited);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    long n=sc.nextLong();
    long a=sc.nextLong();
    long b=sc.nextLong();
    if((a&1)==(b&1)){
      System.out.println((b-a)/2);
    }else{
      System.out.println(Math.min((a),(n-b+1))+(b-a)/2);
    }
  }
}

Measured memory_bytes: 23252
#include <stdio.h>
#include <string.h>

int main()
{
    char str[1024], com[8], p[1024], t;
    int a, b, q, i;
    scanf("%s%d", str, &q);
    for(i=0; i<q; i++) {
        scanf(" %s%d%d", com, &a, &b);
        if(com[0]=='p') {
            t=str[b+1];
            str[b+1]='\0';
            puts(str+a);
            str[b+1]=t;
        } else if(com[2]=='v') {
            for(; a<b; a++, b--) {
                t=str[a];
                str[a]=str[b];
                str[b]=t;
            }
        } else {
            scanf(" %s", p);
            for(b=0; p[b]; a++, b++) {
                str[a]=p[b];
            }
        }
    }
    return 0;
}

Measured memory_bytes: 588
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
typedef int long long ll;
using namespace std;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int main(){
  
    int H,W,h,w;
    cin>>H>>W>>h>>w;
    cout<<(H-h)*(W-w)<<endl;
    
    
    
  
return 0;
}


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

using namespace std;
#define ll long long

#define rep(i, a) for (int (i) = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int (i) = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int (i) = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int (i) = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define TRUE__ "Yes"
#define FALSE__ "No"
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x

#ifdef LOCAL
#define lcout(a) cout << a;
#define lcoutln(a) cout << a << endl;
#define lcerr(a) cerr << a;
#define lcerrln(a) cerr << a << endl;
#else
#define lcout(a) 
#define lcoutln(a) 
#define lcerr(a) 
#define lcerrln(a) 
#endif

int imos[24*60*60];

int time2num(string t)
{
	int h, m, s;
	h = (t[0] - '0') * 10 + t[1] - '0';
	m = (t[3] - '0') * 10 + t[4] - '0';
	s = (t[6] - '0') * 10 + t[7] - '0';
	m += h * 60;
	s += m * 60;
	return s;
}

int main()
{
	int N;
	cin >> N;
	while (N) {
		rep(i, N) {
			string s1, s2;
			cin >> s1 >> s2;
			int l = time2num(s1);
			int r = time2num(s2);
			imos[l]++;
			imos[r]--;
		}
		int ma = imos[0];
		reps(i, 1, 24*60*60) {
			imos[i] += imos[i-1];
			ma = max(ma, imos[i]);
		}
		rep(i, 24*60*60) {
			imos[i] = 0;
		}
		cout << ma << endl;
		cin >> N;
	}
}



Measured memory_bytes: 3372
#include <bits/stdc++.h>
using namespace std;
#define rip(a,b,c) for(int (a)=(c);(a)<(b);(a)++)
const long long INF= 1LL << 60;
int main(){
    //入力始まり
    int N;
    cin >> N;
    vector<int>d(N);
    rip(i,N,0){
        cin >> d[i];
    }
    //入力終わり

    int num[110]={0};
    rip(i,N,0){
        num[d[i]]=1;
    }
    int counter=0;
    rip(i,110,0){
        if(num[i]){
            counter++;
        }
    }

    cout << counter << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPP(i, n) for(int i = 1; i <= n; ++i)
#define REPR(i, n) for(int i = n-1; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> a(n), ans(n);
    REP(i,n) {
        cin >> a[i];
        ans[--a[i]] = i+1;
    }
    REP(i,n) {
        cout << ans[i] << '\n';
    }
    return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,Y;
  cin>>N>>Y;
  for(int x=0;x<=N;x++){
    for(int y=0;y<=N;y++){
      int z=N-(x+y);
      if(z>=0 && 10000*x+5000*y+1000*z==Y){
        cout<<x<<' '<<y<<' '<<z<<endl;
        return 0;
      }
    }
  }
  cout<<-1<<' '<<-1<<' '<<-1<<endl;
  return 0;
}

Measured memory_bytes: 3624
#include <cstdio>
#include <cstdlib>

#define MAX 1000000000 + 7

long long factorial(int n){
  long long ret = 1;
  while(n > 1){
    ret *= n;
    ret %= MAX;
    n--;
  }
  return ret;
}

int main(){

  int n, m;
  long long ans = 0;
  scanf("%d %d", &n, &m);
  if(n == m){
    ans = factorial(n) * factorial(m) * 2;
    ans %= MAX;
  }else if(abs(n - m) == 1){
    ans = factorial(n) * factorial(m);
    ans %= MAX;
  }

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

  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int N; cin >> N;
    int ans = 0;
    for(int C = 0; C < N/4 + 1; C++)
    {
        for(int D = 0; D < N/7 + 1; D++)
        {
            if(4*C + 7*D == N)
            {
                ans++;
            }
        }
    }
    if(ans != 0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

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

#define TOP 0
#define NORTH 1
#define WEST 2
#define EAST 3
#define SOUTH 4
#define BOTTOM 5
#define DIRECTIONS 6

int main()
{
  int n,i,t;
  string s;
  int die[DIRECTIONS];
  while(cin>>n,n){
    for(i=0;i<DIRECTIONS;i++)die[i]=i+1;

    for(i=0;i<n;i++){
      cin>>s;
      if(s=="north"){
	t=die[TOP];
	die[TOP]=die[SOUTH];
	die[SOUTH]=die[BOTTOM];
	die[BOTTOM]=die[NORTH];
	die[NORTH]=t;
      }
      if(s=="west"){
	t=die[TOP];
	die[TOP]=die[EAST];
	die[EAST]=die[BOTTOM];
	die[BOTTOM]=die[WEST];
	die[WEST]=t;
      }
      if(s=="east"){
	t=die[TOP];
	die[TOP]=die[WEST];
	die[WEST]=die[BOTTOM];
	die[BOTTOM]=die[EAST];
	die[EAST]=t;
      }
      if(s=="south"){
	t=die[TOP];
	die[TOP]=die[NORTH];
	die[NORTH]=die[BOTTOM];
	die[BOTTOM]=die[SOUTH];
	die[SOUTH]=t;
      }
    }
    cout<<die[TOP]<<endl;
  }
}

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

int main()
{
	int N, A, B, t, res = 0;
	cin >> N >> A >> B;
	for (int i = 0; i < N; i++) {
		cin >> t;
		if (t < A || t >= B) {
			res++;
		}
	}
	cout << res << endl;
	return 0;
}


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

int main(){
  int N,x,y;
  y = 0;
  cin >> N;
  x = N;
  for(int i=0;;i++){
    y += N % 10;
    N /= 10;
    if(i == 8){
      if(x%y == 0){
        cout << "Yes";
      }else{
        cout << "No";
      }
      break;
    }
  }
}

Measured memory_bytes: 256
// A C++ program to demonstrate working of Chinise remainder 
// Theorem 
#include<bits/stdc++.h>
#define int long long
using namespace std; 

int ans = 1e18, k=1, inp, n, m;
int a[18],r[18];

int min(int a, int b)
{
    if (a<b)
        return a;
    return b;
}

// Returns modulo inverse of a with respect to m using extended 
// Euclid Algorithm. Refer below post for details: 
// https://www.geeksforgeeks.org/multiplicative-inverse-under-modulo-m/ 
int inv(int a, int m) 
{ 
    int m0 = m, t, q; 
    int x0 = 0, x1 = 1; 
  
    if (m == 1) 
       return 0; 
  
    // Apply extended Euclid Algorithm 
    while (a > 1) 
    { 
        // q is quotient 
        q = a / m; 
  
        t = m; 
  
        // m is remainder now, process same as 
        // euclid's algo 
        m = a % m, a = t; 
  
        t = x0; 
  
        x0 = x1 - q * x0; 
  
        x1 = t; 
    } 
  
    // Make x1 positive 
    if (x1 < 0) 
       x1 += m0; 
  
    return x1; 
} 
  
// k is size of num[] and rem[].  Returns the smallest 
// number x such that: 
//  x % num[0] = rem[0], 
//  x % num[1] = rem[1], 
//  .................. 
//  x % num[k-2] = rem[k-1] 
// Assumption: Numbers in num[] are pairwise coprime 
// (gcd for every pair is 1) 
int findMinX(int num[], int rem[], int k) 
{ 
    // Compute product of all numbers 
    int prod = 1; 
    for (int i = 0; i < k; i++) 
        prod *= num[i]; 
  
    // Initialize result 
    int result = 0; 
  
    // Apply above formula 
    for (int i = 0; i < k; i++) 
    { 
        int pp = prod / num[i]; 
        result += rem[i] * inv(pp, num[i]) * pp; 
    } 
  
    return result % prod; 
} 

void findAll(int done)
{
    if (done==k)
    {
        inp=findMinX(a,r,k);
        --inp;
        if (inp==0)
            inp=m;
        else if (inp==-1)
            inp=m-1;
        ans=min(ans,inp);
        return;
    }
    r[done]=0;
    findAll(done+1);
    r[done]=1;
    findAll(done+1);
}
  
// Driver method 
signed main(void) 
{ 
    int cur=2;
    cin>>n;
    m=n*2;
    while (n%2==0)
    {
        n/=2;
        cur*=2;
    }
    a[0]=cur;
    for (int i=3;i*i<=n;++i)
    {
        if (n%i==0)
        {
            cur=1;
            while (n%i==0)
            {
                cur*=i;
                n/=i;
            }
            a[k]=cur;
            ++k;
        }
    }
    if (n>1)
    {
        a[k]=n;
        ++k;
    }
    findAll(0);
    cout<<ans;
    return 0; 
} 

Measured memory_bytes: 3636
def my_solve(string):
    x, y, z, k, *abc = map(int, string.split())
    a, b, c = abc[:x], abc[x:x + y], abc[x + y:]
    ab = sorted([_a + _b for _b in b for _a in a])[-k:]
    *abc, = map(str, sorted([_ab + _c for _c in c for _ab in ab], reverse=True)[:k])
    return "\n".join(abc)


def solve(string):
    x, y, z, k, *abc = map(int, string.split())
    a, b, c = map(sorted, [abc[:x], abc[x:x + y], abc[x + y:]])
    ans = []
    for ia in range(1, x + 1):
        for ib in range(1, x + 1):
            for ic in range(1, x + 1):
                if ia * ib * ic <= k:
                    ans.append(a[x - ia] + b[y - ib] + c[z - ic])
                else:
                    break
    return "\n".join(list(map(str, sorted(ans, reverse=True)[:k])))


if __name__ == '__main__':
    print(solve('\n'.join([input() for _ in range(4)])))


Measured memory_bytes: 9592
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>
#include <map>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
 
using namespace std;
 
const int maxn = 350;
 
char a[maxn][maxn];
 
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%s",a[i]);
        //printf("%s\n",a[i]);
 
    }
    int sum = 0;
    for(int k=0;k<n;k++)
    {
        bool yes = true;
        for(int i=0;yes&&i<n;i++)
        {
            for(int j=0;yes&&j<n;j++)
            {
                int ii = i+k;
                int jj = j+k;
                if(i+k>=n)
                {
                    ii -= n;
                }
                if(j+k>=n)
                {
                    jj -= n;
                }
                if(a[ii][j] != a[jj][i])
                {
                    yes = false;
                }
            }
        }
        if(yes)
        {
            sum += n;
        }
    }
    printf("%d\n",sum);
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, s;
  cin >> N;
  for (int i = 0; i < N; i++) {
    int r, l;
    cin >> r >> l;
    s = l - r + 1 + s;
  }
  cout << s << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int W,H,x,y,r;
  scanf("%d%d%d%d%d",&W,&H,&x,&y,&r);
  if(0<=x-r && 0<=y-r){  
    if(W>=x+r && H>=y+r){
      if(0<=x-r && H>=y+r){
	if(0<=y-r && W>=x+r){
	  printf("Yes\n");
	}
	else printf("No\n");
      }
      else printf("No\n");    
    }
    else printf("No\n");
  }
  if(0>x-r || 0>y-r)printf("No\n");
  return 0;
}

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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set

using namespace std;

const ll MOD = 1000000007;

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

  if (s[2] == s[3] && s[4] == s[5]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
def main():
    S = int(input())
    x1, y1 = 0, 0
    if S < 10**18:
        x2, y2 = 10**9, 1
        y3 = S // x2 + 1
        x3 = x2 * y3 - S
    else:
        x2, y2 = 10**9, 0
        x3, y3 = 0, 10**9
    print(' '.join(map(str, [x1, y1, x2, y2, x3, y3])))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <set>
#include <math.h>
#include <random>
#define PI 3.14159265359
#define ll long long
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define Rep(i, k, n) for(int i = k; i < (int)n; i++)
using namespace std;

int main() {
    int N;
    string S;
    cin >> N >> S;
    int ans = 0;
    rep(i, N - 1) {
        int cnt = 0;
        map<char, bool> dic;
        rep(j, i + 1) {
            dic[S[j]] = true;
        }
        rep(j, i + 1) {
            if(dic[S[j]]){
            Rep(k, i + 1, N){
                if(S[j] == S[k]) {
                    cnt++;
                    dic[S[j]] = false;
                    break;
                }
              }
            }
        }
        ans = max(ans, cnt);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
let () =
  let rec makelist n m = if n = m then [m] else n :: makelist (n+1) m in
  Scanf.scanf "%d %d\n" @@ fun x n ->
  let p = Array.init n @@ fun _ -> Scanf.scanf "%d " @@ fun d -> d in
  let _ = Array.fast_sort compare p in
  let q = Array.to_list p in
  let lst = makelist 0 101 in
  let (_, slst) = List.partition (fun x -> List.mem x q) lst in
  let (ans, _) = List.fold_left
      (fun (ans, diff) y -> if abs (x-y) < diff then (y, abs (x-y))
        else if abs (x-y) = diff && y < ans then (y, abs (x-y))
        else (ans,diff)) (102, max_int) slst in
  Printf.printf "%d\n" ans

Measured memory_bytes: 3852
n, card = int(input()), input().split()
card1, card2 = card[:], card[:]

for i in range(n-1):
    for j in range(n-1, i, -1):
        if int(card1[j][1]) < int(card1[j-1][1]):
            card1[j], card1[j-1] = card1[j-1], card1[j]
print(" ".join(card1))
print("Stable")

for i in range(n-1):
    for j in range(i+1, n):
        if j == i+1:
            idx = j
        elif int(card2[idx][1]) > int(card2[j][1]):
            idx = j
    if int(card2[i][1]) > int(card2[idx][1]):
        card2[i], card2[idx] = card2[idx], card2[i]
print(" ".join(card2))
if card1 == card2:
    print("Stable")
else:
    print("Not stable")



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

int main(){
    string S,T;
    cin >> S >> T;
    int A,B;
    cin >> A >> B;
    string U;
    cin >> U;
    if(S == U){
        A -= 1;
    }
    if(T == U){
        B -= 1;
    }
    cout << A << " " << B << endl;
}

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

int main(){
    int m, n;
    while(1){
        cin >> m >> n;
        if(m + n == 0)  break;

        vector<int> people;
        for(int i = 1; i <= m; i++) people.push_back(i);

        string x;
        bool freeze = false;
        int pos = 0;

        for(int num = 1; num <= n; num++){
            cin >> x;
            if(freeze)  continue;
            
            string answer = "";
            if(num % 3 == 0)    answer += "Fizz";
            if(num % 5 == 0)    answer += "Buzz";
            if(num % 3 != 0 && num % 5 != 0)    answer = to_string(num);

            if(x != answer){
                people.erase(people.begin() + pos);
                if(pos == people.size())    pos = 0;
                if(people.size() == 1)  freeze = true;
            }else{
                pos = (pos + 1) % people.size();
            }
        }

        for(int i = 0; i < people.size(); i++){
            if(i)   cout << " ";
            cout << people[i];
        }
        cout << endl;

    }
    return 0;
}


Measured memory_bytes: 3236
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1000000007;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const ll MAX_N = ll(1e5 + 5);
const double EPS = 1e-10;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()

ll n, a[MAX_N], t[MAX_N], ans = 1;
bool f[2][MAX_N]{};  // 値がわかっているか

int main() {
    cin >> n;
    REP(i,n) cin >> a[i];
    REP(i,n) cin >> t[i];
    f[0][0] = true;
    f[1][n-1] = true;
    REP(i,n-1){
        if(a[i] < a[i+1]) f[0][i+1] = true;
    }
    REP(i,n-1){
        if(t[i] > t[i+1]) f[1][i] = true;
    }
    REP(i,n){
        if(f[0][i] && f[1][i]){
            if(a[i] != t[i]) ans = 0;
        }
        else if(f[0][i]){
            if(a[i] > t[i]) ans = 0;
        }
        else if(f[1][i]){
            if(a[i] < t[i]) ans = 0;
        }
        else {
            ans *= min(a[i], t[i]);
            ans %= MOD;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1920
n,k = map(lambda x: int(x), input().split())

d = []
a = []
for i in range(k):
    d.append(int(input()))
    a.append(list(map(lambda x: int(x), input().split())))


def set_sum(list):
    n = len(list)
    for i in range(n):
        list[i] = set(list[i])
    result = set()
    for i in range(n):
        result = result | list[i]
    return result



print(n - len(set_sum(a)))


Measured memory_bytes: 9784
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using P = pair<int,int>;

//----***Like a Pythonista***----
#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)
#define RREP(ii,nn,jj) for (ll ii = nn; jj<ii;ii--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

//----***定数***----
#define MOD 1000000007
#define INF 100000000000000000
#define EPS 1e-9
const vector<vector<int>> DXY={{-1,0},{1,0},{0,-1},{0,1}};

//----***パーツ***----
#define fr first
#define se second
#define pb push_back

//----***入出力***---
void print() { std::cout << "\n"; }
template <class T>void print(const T &x) {std::cout << x<<"\n";}
template <class T, class... Args>void print(const T &x, const Args &... args) {std::cout << x << " ";print(args...);}
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0);
#define dbg cerr<<"🥺🥺🥺🥺🥺🥺"<<endl;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);};}initial_;


int A,B,N;
int func(int x){
  return (A*x)/B-A*(x/B);
}

signed main(){
  cin>>A>>B>>N;
  if(N<B){
    print(func(N));
    return 0;
  }
  print(func(B-1));
  // int ans=-1;
  // x=1;
  // while(x<=N){
  //   ans = max(ans,func(x));
  //   debug(func(x))
  //   x++;
  //   if(x>N)break;
  //   ans = max(ans,func(x));
  //   x+=B-1;
  // }
  // print(ans);



}


Measured memory_bytes: 3620
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int[] array = new int[3];
		int count = 0;
		while (sc.hasNext()) {
			array[count] = sc.nextInt();
			count++;
		}
		
		int max = 0;
		for (int i=0; i < array.length; i++ ) {
			int tmpMax = array[i]*10;
			boolean findSecond = false;
			for (int j=0; j < array.length; j++ ) {
				if (i==j) {
					continue;
				}
				tmpMax+=array[j];
			}
			
			if(max < tmpMax){
				max = tmpMax;
			}
		}
		
		System.out.println(max);
	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int N, b[100], ans[100], ai = 0;
    cin >> N;
    REP(i, N) cin >> b[i];
    // 1 2 1 2 5
    int size = N;
    REP(_, N) {
        int s = size;
        RREP(i, N) {
            if (b[i] == s) {
                ans[ai++] = b[i];
                b[i] = -1;
                size--;
                break;
            }
            else if (b[i] != -1) s--;
        }
    }

    if (ai == N) {
        RREP(i, N) cout << ans[i] << endl;
    }
    else cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
//To compile : type "$     g++ test.cpp -std=c++14 -I .    "
#include <atcoder/all>
#include <bits/stdc++.h>
//#include <chrono>
//#pragma GCC optimize("Ofast")
using namespace std;
using namespace atcoder;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,Q,K,A,B;
string S;
typedef pair<ll, ll> P;
const ll INF = (1LL<<60);

int main() {
	cin>>N>>Q;
	fenwick_tree<ll> fw(N);
	rep(i,N){
		scanf("%lld", &A);
		fw.add(i, A);
	}
	rep(_, Q){
		int t, u, v;
		scanf("%d%d%d", &t, &u, &v);
		if(t == 0){
			fw.add(u, v);
		}else{
			printf("%lld\n", fw.sum(u, v));
		}
	}
}


Measured memory_bytes: 8204
#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;

// セグメントツリー
class SegmentTree {
private:
    Int n;
    vector<Int> node;
    Int ident = 0;
    Int f(Int x, Int y) {
        return x | y;
    }
public:
    SegmentTree(vector<Int> v) {
        Int v_size = v.size();
        n = 1;
        while (n < v_size) {
            n *= 2;
        }
        node.resize(2 * n, ident);
        for (Int i = 0; i < v_size; i++) {
            node[n + i] = v[i];
        }
        for (Int i = n - 1; i >= 1; i--) {
            node[i] = f(node[i * 2], node[i * 2 + 1]);
        }
    }
    void update(Int x, Int val) {
        x += n;
        node[x] = val;
        while (x > 1) {
            x /= 2;
            node[x] = f(node[x * 2], node[x * 2 + 1]);
        }
    }
    // [a, b) での答え
    Int query(Int a, Int b, Int k = 1, Int l = 0, Int r = -1) {
        //cout << l << " " << r << endl;
        if (r < 0) {
            r = n;
        }
        if (r <= a or b <= l) {
            return ident;
        }
        if (a <= l and r <= b) {
            return node[k];
        }
        Int vl = query(a, b, 2 * k, l, (l + r) / 2);
        Int vr = query(a, b, 2 * k + 1, (l + r) / 2, r);
        return f(vl, vr);
    }
};

int main() {
    Int n, q;
    string s;
    cin >> n >> s >> q;
    vector<Int> v(n);
    for (Int i = 0; i < n; i++) {
        v[i] = (1<<(s[i] - 'a'));
    }
    SegmentTree seg(v);
    for (Int i = 0; i < q; i++) {
        Int mode;
        cin >> mode;
        if (mode == 1) {
            Int x;
            char c;
            cin >> x >> c;
            seg.update(x - 1, 1<<(c - 'a'));
        } else {
            Int l, r;
            cin >> l >> r;
            l--, r--;
            Int val = seg.query(l, r + 1);
            Int cnt = 0;
            for (Int i = 0; i < 26; i++) {
                if (val & (1<<i)) {
                    cnt++;
                }
            }
            dump(cnt);
        }
    }
    return 0;
}

Measured memory_bytes: 16900
import java.util.Scanner;


public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		sc.close();
		if(a < b && b < c)
			System.out.println("Yes");

		else
			System.out.println("No");
	}
}

Measured memory_bytes: 17232
#include  <bits/stdc++.h>
#define ll long long
using namespace std;
 
bool cmp(int a,int b){
        return a>b;
}
 
 
int  main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
 
    //Insert code
 
    ll n;
    cin>>n;
    string s;
    cin>>s;
    ll nw=0,nb=0;
    for (int i=0;i<n;i++){
        if (s[i]=='#') nb++;
        else nw++;
    }
    ll tmp=nw,res=nw;
    for (int i=0;i<n;i++){
        if (s[i]=='#') tmp++;
        else tmp--;
        res=min(res,tmp);
    }
    cout<<res;
    //End code
 
    cerr << "\nTime elapsed: " << 1000*clock() / CLOCKS_PER_SEC << "ms\n";
    
}

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

#define ll long long int
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define phi 3.1415926535
 
using namespace std;
 
ll tc, cnt = 0, number, many, total = 0;
int rmove[4] = {0, 0, -1, 1};
int cmove[4] = {1, -1, 0, 0};



int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
 
    // freopen("input.txt","r", stdin);
    // freopen("output.txt","w", stdout);
    // g++ -std=c++11 Default.cpp  -o test

    int a, b;
    cin >> a >> b;

    double temp = (b - 2 * a) / 2.0;

    //cout << temp << " " << a - temp << endl;

    if(temp == ceil(temp) && a - temp >= 0 && temp >= 0)
        cout << "Yes";
    else
        cout << "No";
    cout << endl;
    
    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << " ms\n";
    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define st first
#define nd second

using namespace std;

void debug_out() { cerr << endl; }
template<class T> ostream& prnt(ostream& out, T v) { out << v.size() << '\n'; for(auto e : v) out << e << ' '; return out;}
template<class T> ostream& operator<<(ostream& out, vector <T> v) { return prnt(out, v); }
template<class T> ostream& operator<<(ostream& out, set <T> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, map <T1, T2> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, pair<T1, T2> p) { return out << '(' << p.st << ' ' << p.nd << ')'; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}

#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(int _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"

const int N = 100100;
int n, a[N], l, ok, last;

int main() {
	ios_base::sync_with_stdio(false);

	cin >> n >> l;

	for(int i = 1; i <= n; i++) {
		cin >> a[i];
		if(i > 1 && !ok) {
			if(a[i] + a[i - 1] >= l) {
				ok = 1;
				last = i - 1;
			}
		}
	}
	if(!ok) return cout << "Impossible\n", 0;
	
	cout << "Possible\n"; 
	for(int i = 1; i < last; i++) cout << i << '\n';
	for(int i = n - 1; i > last; i--) cout << i << '\n';
		cout << last << '\n';
}	

	

Measured memory_bytes: 1280
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

typedef long long ll;

#define MOD 1000000007

class Comb{
private:
  ll *fac,*finv,*inv;
public:
  Comb(){
    fac = new ll[1000000];
    finv = new ll[1000000];
    inv = new ll[1000000];
    fac[0] = 1;
    for(int i=1;i<1000000;i++){
      fac[i] = i*fac[i-1];
      fac[i] %= MOD;
    }
    inv[1] = 1;
    for(int i=2;i<1000000;i++){
      inv[i] = MOD-inv[MOD%i]*(MOD/i)%MOD;
    }
    finv[0] = 1;
    for(int i=1;i<1000000;i++){
      finv[i] = inv[i]*finv[i-1];
      finv[i] %= MOD;
    }
  }
  ll calc(ll n,ll k){
    ll c = fac[n];
    c *= finv[k];c %= MOD;
    c *= finv[n-k];c %= MOD;
    return c;
  }
};

ll gcd(ll x,ll y){
  if(x%y == 0) return y;
  else return gcd(y,x%y);
}

vector<int> extract(int n){
  int x;
  x = n%10;
  if(n < 10){
    return {n%10,n%10};
  }
  while(n > 9){
    n = n/10;
  }
  return {n,x};
}
int main(){
  int n;
  cin >> n;
  ll table[10][10];
  ll ans = 0;
  for(int i=0;i<10;i++){
    for(int j=0;j<10;j++){
      table[i][j] = 0;
    }
  }
  vector<int> temp;
  for(int i=1;i<n+1;i++){
    temp = extract(i);
    table[temp[0]][temp[1]]++;
  }

  for(int i=1;i<10;i++){
    for(int j=1;j<10;j++){
      ans += table[i][j]*table[j][i];
    }
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define N 1000
#define M 100000
void MatrixChain(void);
int A[N+1][N+1],B[N+1],n;
int main()
{
  int i;

  scanf("%d",&n);
  for(i=1;i<=n;i++)
    {
      scanf("%d %d",&B[i-1],&B[i]);
    }
  MatrixChain();
  printf("%d\n",A[1][n]);
  return 0;
}

void MatrixChain(void)
{
  int i,j,k,l,flag=0,Com=0;

  for(i=1;i<=n;i++)
    {
      A[i][i]=0;
    }
  for(l=2;l<=n;l++)
    {
      for(i=1;i<=n-l+1;i++)
        {
          j=i+l-1;
          A[i][j]=M;
          for(k=i;k<=j-1;k++)
            {
              if(A[i][j]>A[i][k]+A[k+1][j]+B[i-1]*B[k]*B[j])
                {
                  A[i][j]=A[i][k]+A[k+1][j]+B[i-1]*B[k]*B[j];
                }
            }
        }
    }
}

Measured memory_bytes: 984
#include <bits/stdc++.h>
#define lli long long int
#define MOD 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define repf(i, n) for(int i=1; i<(int)(n+1); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<lli>
#define vvi vector<vector<lli>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
using namespace std;

bool isPrime(lli x){
    if(x == 2) return true;
    if(x%2 == 0 || x <= 2) return false;
    double r = sqrt(x);
    for(lli i=3; i<=r; i+=2) if(x%i == 0) return false;
    return true;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    int x;
    cin >> x;
    while(!isPrime(x)) x++;
    cout << x << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

        int n = sc.nextInt();
        String s[] = sc.next().split("");

        int result = 0;
        for (int i = 0; i < n-1; i++) {
            if (!s[i].equals(s[i+1])) {
                result++;
            }
        }

        System.out.println(result+1);
    }
}

Measured memory_bytes: 32324
/*****Here we go again!******/

#include<bits/stdc++.h>
using namespace std;

#define pi 3.1415926535
#define endl "\n"
#define yes cout << "YES\n"
#define no cout << "NO\n"
#define ll long long
#define llu unsigned long long
#define pb push_back
#define mp make_pair
#define sz(x) (int)x.size()
#define tc int test_case; cin >> test_case; while(test_case--)
#define f(i,a,n) for(int i = a ; i < n ; i++)
#define rf(i,n,a) for(int i = n-1 ; i >= a ; i--)
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
#define get(a,n) f(i,0,n) cin >> a[i];
#define show(a,n) f(i,0,n) cout << a[i] << " "; cout << endl;
#define fast ios:: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define trace(x) cerr << '>' << #x << ':' << (x) << "\n"
#define trace2(x,y) cerr<< '>' << #x << ':' << (x) << " | " << #y << ':' << (y) << "\n"
#define trace3(a,b,c) cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n"
#define trace4(a,b,c,d) cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<"\n"

typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;
typedef map<int,int> mii;
typedef map<ll,ll> mll;

const int inf = 1e9;
const ll inf64 = 1e18;
const int mod = inf + 7;
const int N = 1e5 + 10;

int main()
{
    fast;
    int n, x, t;
    cin >> n >> x >> t;
    cout << ((n+x-1)/x)*t;
}


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

int main(){
    int n;
    string s;
    cin >> n >> s;
    int ans = n;
    for (int i = 0; i < n - 1; i++) {
        if (s[i]==s[i+1]) {
            ans--;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
q=int(input())
ab=[list(map(int,input().split())) for _ in range(q)]
from math import floor
for a,b in ab:
    # a*bをぎりぎりまで攻めたい
    # (1,1)とかはもったいない。(1,a*b-1)は良い。片方は√a*b未満で、片方は√a*bより大きい組み合わせ。
    # a==bならa未満の整数yについて適切な数字xを選べばy*x<a*bとできる。xは他のxと被らないように選択できる。
    if a==b:
        print(2*a-2)
    else:
        # t,t+1 組み合わせの積がa*bで抑えられているかどうか。(t+1)*(t+1)は必ずa*bを超える。
        # t未満の自然数については適切な整数を選べばa*b以下にできる。
        t=floor((a*b)**0.5)
        # (1,2*t-1),(2,2*t-2),(3,(a*b-1)//3),...,(t-1,(a*b-1)//(t-1))
        if t*t>=a*b: 
            # (t,t),(t,t+1)はだめ。この条件を満たすのはt*t=a*b、a!=bのときのみ。t未満の数字と適切な数字を選べばよいが、t未満の数字の内一つはaなので、その分を引く。
            print(2*t-3)
        elif t*(t+1)>=a*b: 
            # (t,t)はOK。(t,t+1)はだめ。(t,t)をまず選ぶ。t未満の数字と適切な数字を選べばよいが、t未満の数字の内一つはaなので、その分を引く。
            print(2*t-2)
        else:
            # t*tもt*(t+1)もOK。(t,t+1),(t+1,t)をまず選ぶ。あとはt未満の数字と適切な数字を選べばよいが、t未満の数字の内一つはaなので、その分を引く。
            print(2*t-1)


Measured memory_bytes: 9444
import java.util.*;
public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        sc.close();
        Deque<Character> deq = new ArrayDeque<Character>();
        int count = 0;

        for(int i = 0; i < str.length(); i++){
            if(str.charAt(i) == 'S'){
                deq.push('e');
            }else{
                Character temp = deq.poll();
                if(temp == null){
                    count++;
                }
            }
        }

        System.out.println(count + deq.size());
    }
}

Measured memory_bytes: 26564
#include <bits/stdc++.h>
using namespace std;
int sum[200002];
int main()
{
	int n, x;
	cin >> n;
	for (int i=2; i<=n; i++)
	{
		cin >> x;
		sum[x]++;
	}
	for (int i=1; i<=n; i++) cout << sum[i] << endl;
	return 0;
}

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


/* エイリアス */
#define ll long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define endl '\n'

#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define em emplace


/* 関数マクロ */
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, n, m) for (ll i = n; i <= m; ++i)
#define rep3(i, n, m) for (ll i = n; i >= m; --i)
#define all(v) v.begin(), v.end()
#define si(v) int(v.size())
#define UNIQUE(v) sort(all(v)), v.erase(unique(all(v)),v.end())


/* 定数 */
const ll mod = 1e9 + 7;
const ll infll = (1LL << 62) - 1;
const ll inf = (1LL << 30) - 1;


/* その他 */
template<class S, class T> inline bool chmax(S &a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class S, class T> inline bool chmin(S &a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> using pq = priority_queue<T>;
template<class T> using pqg = priority_queue<T, vector<T>, greater<T>>;


signed main()
{
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll x; cin >> x;
  ll d = x / 100;
  ll y = 100 * d + d * 5;

  cout << (y >= x) << endl;
}

Measured memory_bytes: 3612
#include <stdio.h>
#include <memory.h>
#include <string.h>
#define MAX 30

char ch[MAX], p[MAX];
int len, b[MAX], ac[30], cnt;
char ch2[1050000][22];

void dfs(int now, int sw){
	int i;
	b[now]=sw;
	if (now==len){
		for (i=1;i<=len;i++){
			p[i]=ch[i];
			if (b[i]) p[i]++;
		}
		memset(ac, 0, sizeof(ac));
		int flag=0;
		for (i=1;i<=len;i++){
			if (ac[p[i]-'a']){
				if (p[i]!=ch[i]){
					flag=1;
					break;
				}
			}else{
				ac[p[i]-'a']=1;
				if (p[i]-1!=ch[i] && p[i]!='a'){
					flag=1;
					break;
				}
			}
		}
		if (flag==0){
			cnt++;
			for (i=1;i<=len;i++) ch2[cnt][i]=p[i];
		}
	}else{
		dfs(now+1, 0);
		if (ch[now+1]!='z') dfs(now+1, 1);
	}
}

int main(void){
	int i,j;
	for (;;){
		scanf("%s", &ch[1]);
		if (ch[1]=='#') break;
		len=strlen(&ch[1]);
		dfs(1, 0);
		if (ch[1]!='z') dfs(1, 1);
		printf("%d\n", cnt);
		if (cnt>=10){
			for (i=1;i<=5;i++) printf("%s\n", &ch2[i][1]);
			for (i=cnt-4;i<=cnt;i++) printf("%s\n", &ch2[i][1]);
		}else{
			for (i=1;i<=cnt;i++) printf("%s\n", &ch2[i][1]);
		}
		for (i=1;i<=cnt;i++){
			for (j=1;j<=len;j++) ch2[i][j]=0;
		}
		cnt=0;

	}
	return false;
}

Measured memory_bytes: 1364