akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
#include <climits>
#include <cmath>
#include <utility>
#include <iomanip>

using namespace std;



int main(int argc, char *argv[])
{
	int r, d , x;
	int ans;

	//input
	cin >> r >> d >> x;


	//calc
	ans = x;
	for (int i = 0; i < 10; i++){
		ans = r * ans - d;

		//ans
		cout << ans << endl;
	}




	return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.util.stream.*;
class Main {
    public static void main(String[] args) {
        Scanner input;
        input = new Scanner(System.in);
        int N = input.nextInt();
        Integer[] a = new Integer[N];
        for (int i = 0; i < N; i++){
            a[i] = input.nextInt();
        }
        Arrays.sort(a,Comparator.reverseOrder());
        int A = 0;
        int B = 0;
        for (int i = 0; i < N; i++){
            if (i%2 == 0){
                A += a[i];
            }
            else{
                B += a[i];
            }
        }
        System.out.println(A-B);
    }
}

Measured memory_bytes: 21716
const main = function(input){
  var str = input.trim();
  var len = str.length;

  if(str[0]!=="A" || isUpper(str[1]) ||isUpper(str[len-1])){
    console.log("WA");
    return;
  }

  var CCount=0;
  for(var i=2;i<len-1;i++){
    if(isUpper(str[i])){
    	if(str[i]==="C") CCount++;
        else{
          CCount=0;
          break;
        }
    }
  }
  if(CCount===1) console.log("AC");
  else console.log("WA");
}

const isUpper = function (str){
  return str===str.toUpperCase();
}
 
 
main(require("fs").readFileSync("/dev/stdin","utf-8"));

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

int main() {
#ifndef DEBUG
	ios::sync_with_stdio(false);
#endif
	string s, t;
	cin >> s >> t;
	unsigned short LCS[s.length()+1][t.length()+1];
	memset(LCS,0,sizeof(LCS));
	for(unsigned short i=1; i<=s.length(); i++) {
		for(unsigned short j=1; j<=t.length(); j++) {
			LCS[i][j] = s[i-1]==t[j-1] ? LCS[i-1][j-1]+1 
				: max(LCS[i-1][j], LCS[i][j-1]);
		}
	}
#ifdef DEBUG
	cout << "LCS length: "
		<< LCS[s.length()][t.length()] << endl;
#endif
	char rst[LCS[s.length()][t.length()]+1];
	memset(rst, 0, sizeof(rst));
	for(unsigned short i=s.length(),j=t.length(),idx=sizeof(rst)-1; i>0&&j>0; i--, j--) {
		if(s[i-1]==t[j-1]) {
			rst[--idx]=s[i-1];
		} else if(LCS[i-1][j]>LCS[i][j-1]) {
			j++;
		} else {
			i++;
		}
	}
	cout << rst << '\n';
	return 0;
}


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

using namespace std;
using ll = long long;
using pii = pair<int, int>;

int N, A;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N >> A;
  cout << (N % 500 <= A ? "Yes" : "No") << endl;

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
int main()
{
	int c;
	scanf("%d",&c);
	int a[c];
	for(int w=0 ; w<c ; w++)
		scanf("%d",&a[w]);
	int number=0;
	std::sort( a, a+c );
//	for(int i=0; i<c ;i++)
//		for(int k=0 ; k+1<c-i ; k++)
//			if(a[k]>a[k+1])
//			{
//				int x=a[k];a[k]=a[k+1];a[k+1]=x;
//			}

 	number=a[c/2]-a[c/2-1];
	printf("%d\n",number);
//	system("pause");
	return 0;
}

Measured memory_bytes: 512
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let s: Vec<char> = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().chars().collect()
    };

    let ans = s.len() / 2 - s.iter().filter(|&&c| c == 'p').count();

    println!("{}", ans);
}


Measured memory_bytes: 4352
#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 = 300100;
long long n, a[N], ans;

int main() {
	ios_base::sync_with_stdio(false);
	cin >> n;
	for(int i = 1; i <= 3 * n; i++)
		cin >> a[i];

	sort(a + 1, a + 3 * n + 1);
	for(int i = n + 1; i <= 3 * n; i++)
		if(i % 2 != n % 2)
			ans += a[i];
	cout << ans << '\n';

}	

	

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define pb push_back
#define N 200001
#define ll long long
#define int ll 
#define pi pair<int , int>
#define pip pair<pair<pi , int>>
#define mp make_pair 
#define f first
#define s second
#define mod 1000000007
ll Mod(ll x, ll y, int p) 
{ll res = 1; x = x % p;
while (y > 0) 
{if(y & 1) res = (res*x) % p; 
y = y>>1;x = (x*x) % p; 
}return res; 
}
int* getlps(string pattern){
 int len = pattern.length();
 int * lps = new int[len];
 lps[0] = 0;
 int i = 1 , j = 0;
 while(i < len){
  if(pattern[i] == pattern[j]){
	  lps[i] = j+1;
   i++;
   j++;
  }
  else{
		if(j != 0){
		 j = lps[j-1];
		}
		else{
		 lps[i] = 0;
		 i++;
		}
  }
 }
 return lps;
}
class Triplet{
 public:
 int x ;
 int y ;
 int gcd;
};
Triplet extendedEuclid(int a , int b){
 if(b == 0){Triplet ans; ans.gcd = a;ans.x = 1;ans.y = 0;return ans;}
 Triplet smallAns = extendedEuclid(b , a%b);
 Triplet ans;
 ans.gcd = smallAns.gcd;
 ans.x = smallAns.y;
 ans.y = smallAns.x - (a/b)*smallAns.y;
 return ans;
}
int mmInverse(int a , int m){
 Triplet ans = extendedEuclid(a , m);
 return (ans.x+m)%m;
}
int fact[N];
void calfac(int n ){
fact[0] = 1;
for(int i = 1 ; i <= n+2; i++){
 fact[i] = (((fact[i-1]%mod)*(i%mod))%mod + mod)%mod;
}
 }
int calc(int n , int r){
 if(r > n)return 0;
 if(r == n)return 1;
 int ans = 1;
 ans = ((ans%mod)*(fact[n])%mod + mod)%mod;
 ans = ((ans%mod)*(mmInverse(fact[n-r] , mod)%mod) + mod)%mod;
 ans = ((ans%mod)*(mmInverse(fact[r] , mod)%mod) + mod)%mod;
 return (ans+mod)%mod;
}
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
 calfac(60002);
 int n;
 cin>>n;
 if(n <= 2){
 	cout<<"0"<<endl;
 	return 0;
 }
 ll ans = 0;
 // i - 1 + n - 2*i , 
 for(int i = 1 ; i <= n ; i++){
 	  
 	    if(n - 3*i >= 0 && n - 2*i - 1 >= 0){
 	    	//int z = calc(n-2*i-1 , n - 3*i);
 	    	//cout<<"z:"<<z<<endl;
 	   ans = (ans%mod +  calc(n-2*i-1 , n - 3* i)%mod + mod)%mod;
 	}
 }
 cout<<ans<<endl;
}


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

#define LL long long

int main(){
	

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int d,n;
	cin>>d>>n;

	int x = (int)pow(100,d);
	if(n==100){cout<<(101*x)<<endl;}
	else{cout<<n*x<<endl;}
}

Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        Long x = sc.nextLong();
        Long tmp = x/500;
        Long uresi = tmp*1000;
        x -= 500*tmp;
        tmp = x/5;
        uresi += tmp*5;
        x -= 5*tmp;
        System.out.println(uresi);
    }
}


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

typedef long long ll;
using namespace std;

const ll MOD = 1e9+7;
const ll INF = 1e18+7;

signed main(){
	ll n;
	cin >> n;
	vector<ll> a(n);
	for(auto& x : a)
		cin >> x;
	// dp[i][j]: i番目の時点で{未開始,偶数,奇数,奇数終わり}ムーブな時の矛盾の最小値
	// 奇数である範囲は連続でなければならない

	vector<vector<ll>> dp(n + 1, vector<ll>(4, INF));
	dp[0][0] = 0;
	for(ll i = 0; i < n; ++i)
		dp[i + 1][0] = dp[i][0] + a[i];
	ll ans = INF;
	vector<ll> brui(n + 1, 0);
	for(ll i = n - 1; i >= 0; --i)
		brui[i] = brui[i + 1] + a[i];
	for(ll i = 0; i < n; ++i){
		// 偶数部分でスタート
		dp[i + 1][1] = min(dp[i + 1][1], dp[i][0] + (a[i] ? (a[i] % 2) : 2));
		// 奇数部分でスタート a[i]=0の時も挙動変わらない
		dp[i + 1][2] = min(dp[i + 1][2], dp[i][0] + !(a[i] % 2));
		// 奇数離脱部分でスタート
		dp[i + 1][3] = min(dp[i + 1][3], dp[i][0] + (a[i] ? (a[i] % 2) : 2));

		// 偶数部分を続ける
		dp[i + 1][1] = min(dp[i + 1][1], dp[i][1] + (a[i] ? (a[i] % 2) : 2));
		// 奇数部分に突入
		dp[i + 1][2] = min(dp[i + 1][2], dp[i][1] + !(a[i] % 2));
		// 奇数部分を続ける
		dp[i + 1][2] = min(dp[i + 1][2], dp[i][2] + !(a[i] % 2));
		// 奇数部分から離脱
		dp[i + 1][3] = min(dp[i + 1][3], dp[i][2] + (a[i] ? (a[i] % 2) : 2));
		// 奇数離脱部分を続ける
		dp[i + 1][3] = min(dp[i + 1][3], dp[i][3] + (a[i] ? (a[i] % 2) : 2));
	}
	for(ll i = 0; i <= n; ++i){
		ans = min(ans, dp[i][0] + brui[i]);
		ans = min(ans, dp[i][1] + brui[i]);
		ans = min(ans, dp[i][2] + brui[i]);
		ans = min(ans, dp[i][3] + brui[i]);
	}
	cout << ans << endl;
}


Measured memory_bytes: 17408
import java.util.Scanner;
  
public class Main{
    public void solve(){
        Scanner sc=new Scanner(System.in);
		int m = 0;
		int i = 1;
		int N = sc.nextInt();
		
        while(N != 0){
		for(int j=1; j<=N; j++){
			int k = sc.nextInt();
			
			if(k >= 2){
				 i ++;
			}else if(k == 1){
				 m ++;
			}
		}
			
			if(i >= 2){
				System.out.println(i+m);
			}else{
				System.out.println("NA");
			}
				
			 m = 0;
			 i = 1;
			 N = sc.nextInt();
		}
		
       }
        public static void main(String[]args){
        Main obj = new Main();
        obj.solve();
    }
}

Measured memory_bytes: 158620
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound

int main(){
  ll N;
  cin>>N;
  VVL F(N,VL(10));
  rep(i,N) rep(j,10) cin>>F[i][j];
  VVL P(N,VL(11));
  rep(i,N) rep(j,11) cin>>P[i][j];
  ll ans=-1001001001;
  rep(i,1<<10){
    if(i){
      VL B(10);
      rep(j,10) B[j]=(i>>j)&1;
      VL C(N);
      rep(j,10){
        if(B[j]) rep(k,N) if(F[k][j]) C[k]++;
      }
      ll tmp=0;
      rep(j,N) tmp+=P[j][C[j]];
      ans=max(ans,tmp);
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int N;
  string S;
  
  cin >> N;
  
  for ( int i = 0; i < N; i++) {
    
    cin >> S;
    
    if ( S == "Y" ) {
      cout << "Four" << endl;
      break;
    }
    
    else if ( i+1 == N ) {
      cout << "Three" << endl;
    }  
     
  }  
  
}

Measured memory_bytes: 256
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")
#include<bits/stdc++.h>
#define F first
#define S second
#define vec vector
#define ms multiset
#define pb push_back
#define pf push_front
#define pll pair<ll,ll>
#define pdd pair<ld, ld>
#define pq priority_queue
#define umap unordered_map
#define uset unordered_set
#define pii pair<int, int>
#define pnn pair<Node*, Node*>
#define uid uniform_int_distribution
#define FILE ifstream in("board.in");ofstream out("board.out");
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
typedef string str;
typedef long long ll;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); //uid<int> u1(5, 10); u1(rnd);

int main() {
    fast;
    str t; cin>>t;
    map<char, int> mp;
    int mx=0;
    for(char c : t) mp[c]++, mx = max(mx, mp[c]);
    if(mp.size()==2 && mx==2) cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    string s;
    cin >> s;
    int a;
    int z;
    for (int i = 0; i < s.size();i++)
    {
        if(s[i] == 'A'){
            a = i;
            break;
        }
    }
    for (int i = 0; i < s.size();i++)
    {
        if(s[i] == 'Z'){
            z = i;
        }
    }
    cout << z - a + 1 << endl;
}


Measured memory_bytes: 640
#include <stdio.h>

int main(){

  int i;
  int j;
  int h;
  int w;
  int n;
  int m;
 
  while(1)
    {
  scanf("%d %d", &h,&w);
  if(h==0 && w==0)break;
  for(i=1; i<h+1; i++)
    {
      for(j=1; j<w+1; j++)
	{ n = i%2;
	  m = j%2;
	  if( n  ==1 && m  ==1){
	    printf("#");}
	  else if(n != 1 && m != 1){
	      printf("#");}
	  else{
	    printf(".");
	  }
	   
	}
      printf("\n");
    }
  printf("\n");
    }
  return 0;
}

Measured memory_bytes: 572
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);  
cout.tie(0);   

#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif  


    int n;
    cin>>n;
    int a,b;
    cin>>a>>b;
    int s[n+1];
    for(int i=1;i<=n;i++)
        cin>>s[i];
    int x=0,y=0,z=0;
    for(int i=1;i<=n;i++)
    {
        if(s[i]<=a)
            x++;
        else if(s[i]>b)
            z++;
        else
        {
            y++;
        }
        
    }
    cout<<min({x,y,z});

} 
    
 


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

using P = tuple<int, int, int>;

int main() {
    int n;
    while(cin >> n, n){
        set<P> A, B;
        A.emplace(-1, 0, MOD);
        B.emplace(0, MOD, -1);
        for (int i = 0; i < n; ++i) {
            char c;
            cin >> c;
            if(c == 'W'){
                int x, y;
                cin >> x >> y;
                auto it = A.begin();
                while(y){
                    int p, q, r; tie(p, q, r) = (*it);
                    it = A.erase(it); B.erase(P(q, r, p));
                    if(r-q >= y){
                        A.emplace(x, q, q+y);
                        B.emplace(q, q+y, x);
                        A.emplace(p, q+y, r);
                        B.emplace(q+y, r, p);
                        y = 0;
                    }else {
                        y -= r-q;
                        A.emplace(x, q, r);
                        B.emplace(q, r, x);
                    }
                }
            }else {
                int x;
                cin >> x;
                if(c == 'D'){
                    auto it = A.lower_bound(P(x, 0, 0));
                    while(it != A.end() && get<0>(*it) == x) {
                        int p, q, r; tie(p, q, r) = (*it);
                        it = A.erase(it); B.erase(P(q, r, p));
                        A.emplace(-1, q, r);
                        B.emplace(q, r, -1);
                    }
                }else {
                    auto it = B.lower_bound(P(x, -1, -1));

                    int p, q, r; tie(p, q, r) = (*it);
                    while(x < p || it == B.end()) {
                        it--;
                        tie(p, q, r) = (*it);
                    }
                    cout << get<2>(*it) << "\n";
                }
            }
        }
        puts("");
    }

    return 0;
}


Measured memory_bytes: 3648
S = input()
n = len(S)
if n == 1:
    print(S)
    quit()
import itertools as it
def sum_insert(x,S): 
    z = zip(S,x)
    L = []
    for x in z:
        L.append(x[0])
        if x[1] == '1':
            L.append('+')
    L.append(S[-1])
    s = ''.join(L)
    return eval(s)
ans = 0
variation = []
for i in range (2**(n-1)):
    variation.append(format(i,'b').zfill(n-1))

for x in variation:
    ans += sum_insert(x,S)
print(ans)




Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define pb push_back
#define int long long
#define MOD 998244353
#define MOD2 1000000007
using namespace std;
int32_t main()
{
    int m,n;
    cin>>m>>n;
    int dp[1001][1001];
    dp[0][0]=1;
    string s[1001];
    for(int i=0;i<m;i++)
        cin>>s[i];
    int i=0,j=0;
    while(i<n && s[0][i]=='.')
        dp[0][i++]=1;
    i=0;
    while(i<m && s[i][0]=='.')
        dp[i++][0]=1;
    i=0,j=0;
    for(i=1;i<m;i++)
    {
        for(j=1;j<n;j++)
        {
            if(s[i][j]=='.')
                dp[i][j]=((dp[i-1][j]%MOD2)+(dp[i][j-1]%MOD2))%MOD2;
            else
                dp[i][j]=0;
        }
    }
    cout<<dp[m-1][n-1];
}

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

int main(){
  int n;
  map<char, int> m, check;
  string s;
  cin >> n;
  cin >> s;
  for(int i=0;i<n;i++){
    m[s[i]]++;
    check[s[i]]=0;
  }
  int mx=0, cnt=0;
  for(int i=0;i<n;i++){
    m[s[i]]--;
    if(check[s[i]]==0 && m[s[i]]>0){
      cnt++;
      mx = max(mx, cnt);
      check[s[i]]=1;
    }
    if(m[s[i]]==0 && check[s[i]]==1){
      cnt--;
    }
  }
  cout << endl;
  cout << mx << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int week, debt = 100000;
	scanf("%d", &week);
	while (week--) {
		debt *= 1.05;
		if (debt % 1000 != 0) {
			debt = (debt / 1000 + 1) * 1000;
		}
	}
	printf("%d\n", debt);
	return 0;
}

Measured memory_bytes: 592
#include<bits/stdc++.h>
using namespace std;
#define int long long 
signed main()
{
	// freopen ("input.txt","r",stdin);
	// freopen ("output.txt","w",stdout);
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;
    int da[a],db[b],dc[c],arr[x+y],t=0,ic,i,r=0;
    for(i=0;i<a;i++)
    cin>>da[i];
    for(i=0;i<b;i++)
    cin>>db[i];
    for(i=0;i<c;i++)
    cin>>dc[i];
    sort(da,da+a,greater<int>());
    sort(db,db+b,greater<int>());
    sort(dc,dc+c);
    for(i=0;i<x;i++)
    {
    arr[i]=da[i];
    }
    for(i=0;i<y;i++)
    {
    arr[i+x]=db[i];
    }
    for(i=0;i<c;i++)
    arr[i+x+y]=dc[i];
    sort(arr,arr+(x+y+c),greater<int>());
    for(i=0;i<x+y;i++)
    t+=arr[i];
    cout<<t;

}

Measured memory_bytes: 3968
import java.util.*;
import java.text.*;
/*
Main class for AOJ where there is no input.
*/
public class Main{
   public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      String str;
      
      int[] n = new int[26];
      int nAscii;
      
      while(sc.hasNext()){
         str = sc.nextLine();
         str = str.toLowerCase();
         for(int i = 0; i < str.length(); i ++){
            nAscii = str.charAt(i);
         
            if(nAscii > 122 || nAscii < 97){
               continue;
            }else{
               n[nAscii - 97] ++;
            }
         }
      }
      
      for(int i = 0; i < 26; i ++){
         System.out.println((char)(i + 97) + " : " + n[i]);
      }
      
   }//main
}//class

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

typedef long long ll;

ll H, h, m, n, d;
// s=n/d

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

// ?????????2?????????????????????
bool sameWrong() {
  ll tt = 60*60*H*d;
  ll srad = 60*H*n;
  // srad = min(srad, tt-srad);
  ll mrad = 60*H*m*d+H*n;
  // mrad = min(mrad, tt-mrad);
  ll hrad = 60*60*h*d+60*m*d+n;
  // hrad = min(hrad, tt-hrad);

  return (srad == mrad) || (mrad == hrad) || (srad == hrad);
}

// ?§??????¨??????????§??????¨??????????§?????????????????????????
bool same3() {
  ll tt = 60*60*H*d;
  ll srad = 60*H*n;
  ll mrad = 60*H*m*d+H*n;
  ll hrad = 60*60*h*d+60*m*d+n;
  return min(abs(srad-mrad), tt-abs(srad-mrad)) == min(abs(hrad-srad), tt-abs(hrad-srad));
}

int main() {
  ll s;
  while (true) {
    cin >> H >> h >> m >> s;
    if (H == 0 && h == 0 && m == 0 && s == 0) break;

    ll prem = m, preh = h;
    ll ansn, ansd;
    while (true) {
      ansn = ansd = -1;
      n = 0;
      d = H-1;
      for (ll i = 0; i < (H-1)*60; i++) {
      	n = i;
      	if (prem == m && d*s > n) continue;
      	if (!sameWrong() && same3()) {
      	  ansn = n; ansd = d;
      	  break;
      	}
      }
      n = 0;
      d = 119*H-1;
      for (ll i = 0; i < (119*H-1)*60; i++) {
	n = i;
	if (prem == m && d*s > n) continue;
	if (!sameWrong() && same3() && (ansn == -1 || (ansn != -1 && ansn*d > n*ansd))) {
	  ansn = n; ansd = d;
	  break;
	}
      }

      if (ansn != -1) {
	if (ansn == 0) {
	  ansd = 1;
	}else {
	  ll t = gcd(ansn, ansd);
	  ansn /= t; ansd /= t;
	}
	cout << h << " " << m << " " << ansn << " " << ansd << endl;
	break;
      }
      m++;
      if (m == 60) {
	m = 0;
	h++;
	if (h == H) {
	  h = 0;
	}
      }
    }
  }
}

Measured memory_bytes: 1156
#include<iostream>
#include<algorithm>
#include<math.h>
#include<string>
#include<vector>
using namespace std;

int main()
{
    long long right[100010];
    long long left[100010];
    long long n,c;
    cin >> n >> c;
    long long x[100010];
    long long v[100010];
    for(int i = 1; i <= n; i++){
        cin >> x[i];
        cin >> v[i];
    }
    long long x_left[100010];
    long long v_left[100010];
    for(int i = 1; i <= n; i++){
        x_left[i] = c - x[n + 1- i];
        v_left[i] = v[n + 1- i];
    }
    right[0] = 0;
    left[0] = 0;
    x[0] = 0;
    x_left[0] = 0;
    long long answer = 0;
    long long right_zahyou[100010];
    long long left_zahyou[100010];
    long long right_plus[100010];
    long long left_plus[100010];
    right_zahyou[0] = 0;
    left_zahyou[0] = 0;
    right_plus[0] = 0;
    left_plus[0] = 0;
    for(int i = 1; i <= n; i++){
        right[i] = right[i - 1] + v[i] - (x[i] - x[i - 1]);
        left[i] = left[i - 1] + v_left[i] - (x_left[i] - x_left[i - 1]);
        right_zahyou[i] = x[i];
        left_zahyou[i] = x_left[i];
        right_plus[i] = max(right_plus[i - 1], right[i] - right_zahyou[i]);
        left_plus[i] = max(left_plus[i - 1], left[i] - left_zahyou[i]);
        //cout << left[i] << endl;
    }
    for(int i = 1; i <= n; i++){
        //cout << right[i] << " " << right_plus[i] << " " << right_zahyou[i] << endl;
    }
    for(int i = 1; i <= n; i++){
        right[i] += left_plus[n - i];
        left[i] += right_plus[n - i];
        //cout << right[i] << " " << left[i] << endl;
        answer = max(answer, left[i]);
        answer = max(answer, right[i]);
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 6528
import numpy as np

N,K = (int(x) for x in input().split())
x = np.zeros(N)
count = 0

for i in range(K):
    d=int(input())
    A=[int(x) for x in input().split()]
    for k in A:
        x[k-1] = x[k-1] + 1

for i in range(N):
    if x[i] == 0:
        count = count + 1

print(count)

Measured memory_bytes: 27144
#include<cstdio>
using namespace std;
typedef long long ll;
int power( ll x, int n, ll MOD){
  int res = 1;
  while( n > 0 ){
    if( n & 1 ) res = res * x % MOD;
    x = x * x % MOD;
    n >>= 1;
  }
  return res;
}
bool suspect(ll a,int s,ll d,ll n){
  ll x = power( a, d, n);
  if(x == 1) return true;
  for(int i = 0 ; i < s ; i++ ){
    if(x == n - 1) return true;
    x = x * x % n;
  }
  return false;
}
bool isPrime(ll n){
  if(n == 1 || ( n > 2 && n % 2 == 0)) return false;
  ll d = n - 1, s = 0, tmp[] = { 2, 3, 5, 7, 11, 13, 17, 19, 23};
  while(d % 2 == 0) ++s, d /= 2;
  for(int i = 0 ; tmp[i] < n && i < 9 ; i++ ){
    if(!suspect( tmp[i], s, d, n)) return false;
  }
  return true;
}
int main(){
  int q, n,ret = 0;
  scanf("%d", &q);
  while(q--){
    scanf("%d", &n);
    ret += isPrime(n);
  }
  printf("%d\n", ret);
}



Measured memory_bytes: 2764
#include <stdio.h>
#include <iostream>
#include <algorithm>
typedef std::pair<int, int> P;
bool pairCompare(const P& firstElof, const P& secondElof)
{
    return firstElof.first < secondElof.first;
}
int main(void){
  long long int N,K;
  P p[100000];
  long long int sum;
  std::cin >> N >> K;
  for(int i=0;i<N;i++){
    std::cin >> p[i].first >> p[i].second;
  }
  sort(p,p+N,pairCompare);
  sum=0;
  int i;
  for(i=0;i<N;i++){
    sum += p[i].second;
    if(sum >= K)break;
  }
  printf("%lld",p[i].first);
  return 0;
}

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

#define rep(i,n) for(int i = 0;i < n;++i)
#define rep2(i,n,m) for(int i = n;i < m;++i)
#define all(v) v.begin(),v.end()

using namespace std;
using ll = long long;


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

    int n,m;

    cin >> n;
    rep2(i,1,10){
        rep2(j,1,10){
            m = i * j;
            if(n == m){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int w = Integer.parseInt(br.readLine());
		int n = Integer.parseInt(br.readLine());
		int[] lots = new int[w];
		for(int i = 0;i < lots.length;i++){
			lots[i] = i + 1;
		}
		String[] buf;
		int leader, trailer;
		for(int i = 0;i < n;i++){
			buf = br.readLine().split(",");
			leader = Integer.parseInt(buf[0]) - 1;
			trailer = Integer.parseInt(buf[1]) - 1;
			int tmp = lots[leader];
			lots[leader] = lots[trailer];
			lots[trailer] = tmp;
		}
		for(int i = 0;i < lots.length;i++){
			System.out.println(lots[i]);
		}
	}
}

Measured memory_bytes: 16920
#include<bits/stdc++.h>
#include<string>
typedef long long ll;
const int mod = 1e9 + 7;
using namespace std;

void solve() {
	ll n;
	cin >> n;
	ll x = n * n;
	 cout << n + x + (n * x) << endl; 
}
 
int main() {
	ios_base :: sync_with_stdio(0);
	cin.tie(0);
	cout.precision(20);
		solve();
	return 0;
}
 
 
 


Measured memory_bytes: 3624
#include<stdio.h>

int cal_gcd(int x, int y) {
	int r = x%y;
	while(r!=0) {
		x = y;
		y = r;
		r = x%y;
	}
	return y;
}

int main() {
	int a,b, gcd, lcm;
	while(scanf("%d %d", &a, &b) != EOF) {
		gcd = cal_gcd(a,b);
		lcm = (a/gcd)*b;
		printf("%d %d\n",gcd, lcm);
	}
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
int main() {
	string s;
	cin >> s;
	bool a = 0;
	bool b = 0;
	bool c = 0;
	bool d = 0;
	for (int i=0;i<s.length();i++) {
		if (s[i] == 'E') a = true;
		if (s[i] == 'S') b = true;
		if (s[i] == 'W') c = true;
		if (s[i] == 'N') d = true;
	}
	if ((a^c) || (b^d)) cout << "No" << endl;
	else cout << "Yes" << endl;
	return 0;
}

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

int main() {
	int n, t;
	std::cin >> n >> t;
	std::vector<int> time(t + 2, 0);
	int l, r;
	for (auto i = 0; i < n; ++i) {
		std::cin >> l >> r;
		++time[l]; --time[r];
	}
	int max = 0;
	for (auto i = 0; i <= t; ++i) {
		if (max < time[i]) {
			max = time[i];
		}
		time[i + 1] += time[i];
	}
	std::cout << max << std::endl;
}


Measured memory_bytes: 3112
#include <stdio.h>
 
int main(){
    int x,y,tmp;
 
    scanf("%d%d",&x,&y);
 
    while(x!=0||y!=0){
        if(x>y){
            tmp=x;
            x=y;
            y=tmp;
        }
        printf("%d %d\n",x,y);
        scanf("%d%d",&x,&y);
    }
 
    return 0;
}

Measured memory_bytes: 600
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.IntStream;

public class Main {

    private enum right {
        y,
        u,
        i,
        o,
        p,
        h,
        j,
        k,
        l,
        n,
        m,
        ;
   }

    static int cnt = 0;
    static List<String> hands = new ArrayList<>();

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line;
        while ((line = br.readLine().trim()) != null && !"#".equals(line)) {
            output(line);
            clear();
        }
    }

    public static void output(String line) {
        IntStream.range(0, line.length()).mapToObj(i->line.substring(i,i+1)).forEach(key -> {
            if(Arrays.stream(right.values()).map(e->e.name()).anyMatch(e->key.equals(e))) {
                hands.add("r");
            } else {
                hands.add("l");
            };
        });
        IntStream.range(0, hands.size()).filter(i->0<i).forEach(i -> {
            if(!hands.get(i-1).equals(hands.get(i))) cnt++;
        });
        System.out.println(cnt);
    }

    public static void clear() {
        hands.clear();
        cnt = 0;
    }
}


Measured memory_bytes: 33864
#include <algorithm>
#include <bits/stdc++.h>
#include<iostream>
#include<string>
using namespace std;
#define rep(i, n) for (int i = 0; i <(int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
int main(){
    string alpha="abcdefghijklmnopqrstuvwxyz";
    char s;cin>>s;
    rep(i,25){
        if(s==alpha[i])cout<<alpha[i+1]<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int         long long
#define endl        "\n"

const int mod = 1e9+7;

inline int add(int a, int b) { int res = a + b; if(res >= mod) res -= mod;  return res; }
inline int sub(int a, int b) { int res = a - b; if(res < 0) res += mod; return res;}
inline int mul(int a, int b) { return (a * b)%mod; }



void solve() {
    int a, b; cin >> a >> b;
    cout << (a*b) << endl;
}

signed main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cout << fixed << setprecision(12);


    int T = 1;
    //cin >> T;

    while(T--) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>

#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define all(v) (v).begin(), (v).end()
#define rev(s) (s).rbegin(), (s).rend()
#define MP make_pair
#define X first
#define Y second

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;

int op(int lhs, int rhs, int ope){
	if(ope == 0) return lhs+rhs;
	if(ope == 1) return lhs-rhs;
	if(ope == 2) return lhs*rhs;
}

int calc(int a, int b, int c, int d, int o1, int o2, int o3){
	if( op(op(op(a, b, o1), c, o2), d, o3) == 10) return 0; // 1->2->3
	if( op(op(a, op(b, c, o2), o1), d, o3) == 10) return 1; // 2->1->3
	if(	op(a, op(op(b, c, o2), d, o3), o1) == 10) return 2; // 2->3->1
	if(	op(a, op(b, op(c, d, o3), o2), o1) == 10) return 3; // 3->2->1
	if(	op(op(a, b, o1), op(c, d, o3), o2) == 10) return 4; // 1->3->2 (== 3->1->2)
	return -1;
}

void output(int a, int b, int c, int d, int o1, int o2, int o3, int type){
	string ope = "+-*";
	if(type == 0) printf("(((%d %c %d) %c %d) %c %d)\n", a, ope[o1], b, ope[o2], c, ope[o3], d);
	if(type == 1) printf("((%d %c (%d %c %d)) %c %d)\n", a, ope[o1], b, ope[o2], c, ope[o3], d);
	if(type == 2) printf("(%d %c ((%d %c %d) %c %d))\n", a, ope[o1], b, ope[o2], c, ope[o3], d);
	if(type == 3) printf("(%d %c (%d %c (%d %c %d)))\n", a, ope[o1], b, ope[o2], c, ope[o3], d);
	if(type == 4) printf("((%d %c %d) %c (%d %c %d))\n", a, ope[o1], b, ope[o2], c, ope[o3], d);
}

bool solve(int a, int b, int c, int d){
	rep(o1, 3) rep(o2, 3) rep(o3, 3){
		int res = calc(a, b, c, d, o1, o2, o3);
		if(res != -1){
			output(a, b, c, d, o1, o2, o3, res);
			return true;
		}
	}
	return false;
}

int main(){
	vi a(4);
	while(1){
		rep(i, 4) cin >> a[i];
		if(!a[0]) break;
		sort(all(a));
		bool ok;
		do{
			ok = solve(a[0], a[1], a[2], a[3]);
		}while(!ok && next_permutation(all(a)));
		if(!ok) cout << "0" << endl;
	}

	return 0;
}

Measured memory_bytes: 1244
#include<bits/stdc++.h>
using namespace std;
int main()
{
string s;
cin>>s;
int c=0,d=1;
for(int i=0;i<s.length()-1;i++)
{
if((s[i]=='R')&&(s[i+1]=='R'))
c++;
else if((s[i]=='S')&&(s[i+1]=='S'))
d++;
}
if(d==3)
cout<<"0"<<endl;
else if(c==2)
cout<<"3"<<endl;
else if(c==1)
cout<<"2"<<endl;
else 
cout<<"1"<<endl;
return 0;
}

Measured memory_bytes: 3612
#include "bits/stdc++.h"
using namespace std;

int main() {
    int A, B, C;
    cin >> A >> B >> C;

    int ABC = max(max(A, B), C);
    int sum = A + B + C;
    int ans = 0;
    while (true) {
        if (sum % 3 == 0 && sum >= ABC * 3) {
            break;
        }
        sum += 2;
        ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())
H = [int(s) for s in input().split()]
for i in range(N - 1):
    if H[i + 1] - H[i] >= 0:
        H[i + 1] -= H[i + 1] != H[i]
    else:
        print('No')
        exit(0)

print('Yes')

Measured memory_bytes: 14396
#include <bits/stdc++.h>
//#include <atcoder/all>
#define rep(i, a) for (int i = (int)0; i < (int)a; ++i)
#define rrep(i, a) for (int i = (int)a - 1; i >= 0; --i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define RREP(i, a, b) for (int i = (int)a - 1; i >= b; --i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define popcount __builtin_popcount
using ll = long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

// #pragma GCC target("avx2")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")
template <class T>
inline bool chmin(T &a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}

ll gcd(ll n, ll m)
{
	ll tmp;
	while (m != 0)
	{
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m)
{
	return abs(n) / gcd(n, m) * abs(m); //gl=xy
}

using namespace std;
//using namespace atcoder;

 struct UF {
	vector<int>par;//親
	vector<int>Rank;//木の深さ
    vector<int>sz;//要素数

    UF(int n){init(n);}

	//初期化
	void init(int n) {
		par.resize(n); Rank.resize(n);sz.resize(n);
		for (int i = 0; i < n; i++) {
			par[i]= i;
			Rank[i] = 0;
            sz[i]=1;
		}
	}

	//木の根を求める
	int find(int x) {
		if (par[x] == x) {
			return x;
		}
		else {
			return par[x] = find(par[x]);
		}
	}

	//xとyの属する集合を併合
	bool unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y)return false;//すでに同じ集合に属している

		if (Rank[x] < Rank[y]) {//高さが小さい方を下に
			par[x] = y;
            sz[y]+=sz[x];
		}
		else {
			par[y] = x;
			if (Rank[x] == Rank[y])Rank[x]++;//同じだとrankが変わらないままになるので増やす（それ以外は大きい方のrankが採用される）
            sz[x]+=sz[y];
		}
		return true;
	}

	//xとyが同じ集合に属するかを判定
	bool same(int x, int y) {
		return find(x) == find(y);
	}

    int size(int k){//要素数を求める
        return sz[find(k)];
    }
};

void solve(){
	int n,m;
	cin>>n>>m;
	UF tree(n);
	rep(i,m){
		int a,b;
		cin>>a>>b;
		a--;b--;
		tree.unite(a,b);
	}
	int ans=0;
	rep(i,n){
		if(tree.find(i)!=tree.find(0)){
			++ans;
			tree.unite(0,i);
		}
	}
	cout<<ans;
}

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


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

int main() {
  int n;
  cin >> n;
  long num1 = 2;
  long num2 = 1;
  for(int i=0; i<n-1; i++) {
    long t1 = num1;
    long t2 = num2;
    num1 = t2;
    num2 = t1 + t2;
  }
  cout << num2 << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		String a = sc.next();
      	int s = 0;
		switch (a){
			case "SSS":
				s = 0;
				break;
			case "SRR":
				s = 2;
				break;
          case "RRS":
            	s = 2;
            break;
          	case "RRR":
            	s = 3;
            break;
			default:
				s = 1;
		}
      System.out.println(s);
	}
}

Measured memory_bytes: 35536
#include <iostream>
#include <vector>
#include <map>
#include <queue>

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
static const int INF=1<<24;
map<int,int> ma;
vector<vector<int> > puz;
vector<vector<int> > v;
vector<vector<int> > pp;

template<class T>
void initvv(vector<vector<T> > &v,int a,int b,const T &t=T()){
	v.assign(a,vector<T>(b,t));
}


int  foo(){
	int ret=0;
	rep(i,2){
		rep(j,4){
			ret*=10;
			ret+=v[i][j];
		}
	}
	return ret;
}

int  foo1(){
	int ret=0;
	rep(i,2){
		rep(j,4){
			ret*=10;
			ret+=pp[i][j];
		}
	}
	return ret;
}
void foo2(int t){
	rep(i,2){
		rep(j,4){
			pp[1-i][3-j]=t%10;
			t/=10;
		}
	}
}

int solve(int c,int d){
	cout<<c<<" "<<d<<endl;
	// cout<<c<<endl;
	// if(c==1){
		// rep(i,2){
			// rep(j,4){
				// cout<<v[i][j]<<" ";
			// }
			// cout<<endl;
		// }
		// cout<<endl;
	// }
	if(c>d) return d;
	bool f=true;
	rep(i,2){
		rep(j,4){
			if(v[i][j]!=puz[i][j]){
				f=false;
				// if(c==1)cout<<i<<" "<<j<<" "<<v[i][j]<<" "<<puz[i][j]<<endl;
			}
		}
	}

	if(f) return c;
	int  now=foo();
	// if(c==0) cout<<now<<endl;
	if(ma[now]) return ma[now];
	int t=d;
	rep(i,4){
		if(v[0][i]==0){
			if(i>=1){
				swap(v[0][i-1],v[0][i]);
				// if(c==0) cout<<"hoge\n";
				t=min(t,solve(c+1,t));
				// if(c==0) cout<<t<<endl;
				swap(v[0][i-1],v[0][i]);
			}
			if(i!=3){
				swap(v[0][i+1],v[0][i]);
				// cout<<"hoge";
				t=min(t,solve(c+1,t));
				// return 0;
				swap(v[0][i+1],v[0][i]);
			}
			swap(v[1][i],v[0][i]);
			t=min(t,solve(c+1,t));
			swap(v[1][i],v[0][i]);
		}
		if(v[1][i]==0){
			if(i>=1){
				swap(v[1][i-1],v[1][i]);
				t=min(t,solve(c+1,t));
				swap(v[1][i-1],v[1][i]);
			}
			if(i!=3){
				swap(v[1][i+1],v[1][i]);
				t=min(t,solve(c+1,t));
				swap(v[1][i+1],v[1][i]);
			}
			swap(v[1][i],v[0][i]);
			t=min(t,solve(c+1,t));
			swap(v[1][i],v[0][i]);
		}
	}
	// if(c==0) cout<<"aaa"<<endl;
	return ma[now]=t;
}


int main(){
	initvv(puz,2,4);
	rep(i,4){
		// cout<<i<<endl;
		puz[0][i]=i;
		puz[1][i]=i+4;
	}
	pp=puz;
	queue<int> q;
	q.push(foo1());
	int c=0;
	while(q.size()){
		int qs=q.size();
		// cout<<c<<endl;
		rep(i,qs){
			int top=q.front();
			q.pop();
			if(ma[top]){
			}
			else{
				ma[top]=c;
				if(c==0){
					ma[top]=111;
				}
				foo2(top);
				rep(i,2){
					rep(j,4){
						if(pp[i][j]==0){
							if(j!=0){
								swap(pp[i][j],pp[i][j-1]);
								q.push(foo1());
								swap(pp[i][j],pp[i][j-1]);
							}
							if(j!=3){
								swap(pp[i][j+1],pp[i][j]);
								q.push(foo1());
								swap(pp[i][j],pp[i][j+1]);
							}
							swap(pp[i][j],pp[1-i][j]);
							q.push(foo1());
							swap(pp[i][j],pp[1-i][j]);
						}
					}
				}
			}
		}
		c++;
	}
	ma[1234567]=0;
	// rep(i,2){
		// rep(j,4){
			// cout<<puz[i][j]<<endl;
		// }
	// }
	// vector<vector<int> > v;
	initvv(v,2,4);
	while(cin>>v[0][0]){
		rep(i,3){
			cin>>v[0][i+1];
		}
		rep(i,4) cin>>v[1][i];
		// ma.clear();
		// rep(i,2){
			// rep(j,4){
				// cout<<puz[i][j]<<" ";
			// }
			// cout<<endl;
		// }
		// cout<<"*************\n";
		cout<<ma[foo()]<<endl;
		// cout<<solve(0,40330)<<endl;
	}
}

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

int main(){
  int N;
  cin >> N;
  int Amax = 0;
  int Bmin = INF;
  int A, B;
  rep(i, N){
    cin >> A >> B;
    Amax = max(Amax, A);
    Bmin = min(Bmin, B);
  }
  int res = 0;
  res += Amax;
  res += Bmin;
  cout << res << endl;
}

Measured memory_bytes: 3560
#include <iterator>
#include <list>
#include <algorithm>
#include <iostream>
#include <unordered_set>
#include <unordered_map>
#include <vector>
#include <sstream>
#include <iomanip>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <numeric>
using namespace std;

int main() {
  int N; cin >> N;
  int cnt = 0;
  for (int i = 1; i <= N; i++) {
    int p; cin >> p;
    if (p != i)
      ++cnt;
    if (cnt > 2) {
      cout << "NO" << endl;
      return 0;
    }
  }

  cout << "YES" << endl;

  return 0;
}


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

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

    ll sum = accumulate(a.begin(), a.end(), 0ll);
    sum -= a[0];
    ll branch = 1;
    ll ans = 0;
    for (int i = 0; i <= n; i++) {
        if (branch < a[i] || sum < 0) {
            puts("-1");
            return 0;
        }

        // cout << i << " " << branch << " " << sum << endl;
        ans += branch;
        sum -= a[i];
        branch -= a[i];
        branch = min(branch * 2, sum);
    }
    // if (a[n] == branch) {
    //     ans += branch;
    // } else {
    //     ans = -1;
    // }
    cout << ans << endl;
}

Measured memory_bytes: 4000
n = int(input())

set1 = set()
set2 = set()

str = list()

for i in range(0, n):
    str1,str2 = input().split()
    if str1[0] == 'i':
        set1.add(str2)
    if str1[0] == 'f':
        set2.add(str2)
        set3 = set1 & set2
        if set3 == set():
            str.append('no')
        else:
            str.append('yes')
        set2.clear()

for i in range(0, len(str)):
    print(str[i])


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

signed main(){
	string S;
	string T[3] = {"Sunny", "Cloudy", "Rainy"};
	cin >> S;
	for(int i = 0; i < 3; i++){
		if(S == T[i]){
			cout << T[(i + 1) % 3] << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 3500
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[n];
    int z=0,o=0,t=0,th=0;
    for(int i=0;i<n;i++) {
        cin>>a[i];
        if(a[i]%4==0) z++;
        else if(a[i]%4==1) o++;
        else if(a[i]%4==2) t++;
        else th++;
    }
    if(z>=o+t+th-1) {
        cout<<"Yes";
        return 0;
    }
    if(o+th > z+1 || (o+th>z && t!=0)) cout<<"No";
    else cout<<"Yes";
    return 0;
}


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

double angle(double a, double b, double x)
{
    double volume = a * a * b;
    if (x < volume / 2.0)
    {
        return M_PI / 2 - atan(2.0 * x / (a * b * b));
    }
    else
    {
        return atan(2.0 * (volume - x) / (a * a * a));
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    double a, b, x;
    cin >> a >> b >> x;

    cout << fixed << setprecision(10) << angle(a,b,x) * 180.0 / M_PI << '\n';

    return 0;
}

Measured memory_bytes: 512
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>



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

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)









 
int main(){
    ll n;
    cin >> n;
    ll ans = INF;
    for(ll i = 1; i <= sqrt(n); i++){
        if(n % i == 0){
            ans = min(ans, (n / i - 1) + (i - 1));
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <list>
#include <stack>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){
    int n,x,t; 
    cin>>n>>x>>t; 
    cout << (((n+x-1)/x)*t) << endl;
    
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


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

int main() {
  string s1, s2, s3;
  cin >> s1 >> s2 >> s3;
  
  char now = 'a';
  
  for(int i=0; i<400; i++){
  switch(now){
    case 'a':
      if(s1.size() == 0){
        cout << "A" << endl;
        break;
      }
      now = s1.at(0);
      s1.erase(s1.begin());
      continue;
    
    case 'b':
       if(s2.size() == 0){
        cout << "B" << endl;
        break;
       }
      now = s2.at(0);
      s2.erase(s2.begin());
      continue;
      
    case 'c':
       if(s3.size() == 0){
        cout << "C" << endl;
        break;
       }
      now = s3.at(0);
      s3.erase(s3.begin());
      continue;
  }
   break;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<cmath>

#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define P pair<int,int>

int main(){
	int n,a,b;
	cin>>n>>a>>b;
	int ans=0;

	for(int i=1;i<=n;i++){
		int tmp=i,sum=0;
		for(int j=6;j>=0;j--){
			if(tmp/(pow(10,j))>0){
				int s=tmp/pow(10,j);
				sum+=s;
				tmp-=s*pow(10,j);
				//cout<<"A"<<endl;
			}
		}
			
		if(a<=sum&&sum<=b)ans+=i;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
    string a,b,c;
    cin >> a >> b;
    int aa,bb;
    cin >> aa >> bb;
    cin >> c;
    if(a==c)
        cout << aa-1 << " " << bb;
    else
        cout << aa << " " << bb-1;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lli long long int
using namespace std;
int main(){
   ios_base::sync_with_stdio(false); 
    cin.tie(NULL);  
  cout.tie(0);
  lli a,b;
  cin>>a>>b;
  if((a+b)%2==0){
    cout<<(a+b)/2;
  }
  else{
    cout<<"IMPOSSIBLE";
  }
}

Measured memory_bytes: 256
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

a, b, c, x, y = mi()
n_min = min(x,y)
price = 0
if(a+b > 2*c):
    price += 2*c * n_min
else:
    price += (a+b) * n_min

if(x>y):
    n_mod = x-n_min
    d = a
else:
    n_mod = y-n_min
    d = b

if(d < c*2):
    price += d * n_mod
else:
    price += c*2 * n_mod

print(price)

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

using namespace std;

#define fo(i, n) for(int i = 1; i <= n; ++i)

#define pb push_back
#define eb emplace_back

typedef long long ll;
const int N = 200200;
const int mod = 1e9 + 7;
const int K = 30000;

int n;
int p[N];
int used[N];
int a[N];
inline bool dfs(int v, int last = 1) {
    if (v > n) {
        int s = 0, g = 0;
        for (int i = 1; i <= n; ++i)
            s += a[i], g = __gcd(g, a[i]);
        if (g != 1) return 0;
        for (int i = 1; i <= n; ++i)
            if (__gcd(a[i], s - a[i]) == 1) return 0;
        fo(i, n)
            cout << a[i] << ' ';
        exit(0);
        return 1;
    }
    for(int i = last + 1; i <= K; i++) {
        if(!used[i]) continue;
        a[v] = i;
        if(dfs(v + 1, i)) return 1;
    }
    return 0;
}

inline int lcm(int x, int y) {
    return x / __gcd(x, y) * y;
}


int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    cin >> n;
        memset(used, 0, sizeof used);
        int x = 0;
        for(int i = 2; i <= 11; ++i) {
            for(int j = i; j <= 30000; j += i)
                used[j] = 1;
        }
        int cnt = 0;
        int last = 0;
        for(int i = 1; cnt + 2 < n && i <= 30000; ++i)
            if(used[i]) {
                a[++cnt] = i;
                last = i;
            }
    dfs(n - 1, last);
    return 0;
}

Measured memory_bytes: 1280