akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)
#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)
const ll INF = 1145141919;
const ll MOD = 1000000007;
template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}

int main(){

    string s;
    ll x, y;
    cin >> s;
    cin >> x >> y;
    set<ll>X, Y;
    X.insert(0);
    Y.insert(0);
    
    vector<ll>v;
    s += "T";
    for(ll i = 0, j = 0; i < s.size(); i++){
        if(s[i] == 'F')j++;
        else{
            v.push_back(j);
            j = 0;
        }
    }
    for(ll i = 0; i < v.size(); i++){
        set<ll>S;
        set<ll>::iterator it;
        if(i % 2 == 0){
            for(it = X.begin(); it != X.end(); it++){
                if(i)S.insert(*it - v[i]);
                S.insert(*it + v[i]);
            }
            X = S;
        }
        else{
            for(it = Y.begin(); it != Y.end(); it++){
                S.insert(*it - v[i]);
                S.insert(*it + v[i]);
            }
            Y = S;
        }
    }
    if(X.find(x) != X.end() && Y.find(y) != Y.end()){
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,v) for (int i = 0; i < v.size(); i++)
#define RREPALL(i,v) for (int i = v.size()-1; i >= 0; i--)
#define SORT(v) sort(v.begin(), v.end())
#define MIN_ELEMENT(v) min_element(v.begin(), v.end())
#define MAX_ELEMENT(v) max_element(v.begin(), v.end())
#define COUNT(v,n) count(v.begin(), v.end(), n);
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

map<pair<string, int>, int> mp;

int main()
{
    int n, m, ans = 0;
    cin>>n;
    REP(i,n) {
        string s;
        int p;
        cin>>s>>p;
        mp[{s, -p}] = i + 1;
    }
    for (auto itr : mp) {
        cout<<itr.second<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n,q;
    string s;
    cin >> n >> q >> s;
    vector<int> hai_n(n+1,0);
    for(int i=0;i<n-1;i++){
        if(s.at(i)=='A' && s.at(i+1)=='C'){
            s.at(i+1) = 'b';
        }
    }
    int k=0;
    for(int i=0;i<n;i++){
        if(s.at(i)=='b'){
            k++;
        }
		hai_n.at(i+1)=k;
    }
    for(int i=0;i<q;i++){
        int l,r;
        cin >> l >>r ;
        int sum=hai_n.at(r)-hai_n.at(l-1);
      	if(s.at(l-1)=='b'){
          if(s.at(l-2)=='A'){
            sum -=1;
          }
        }
        cout << sum <<endl;
    }
}
       


Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <array>

using namespace std;
using pii=pair<int, int>;
using mii=map<int, int>;

namespace ce {
    constexpr int mod = 1e9 + 7;
    constexpr int max = 333333;
}

constexpr int64_t __pow_mod(int64_t n, int64_t p, int64_t mod) noexcept {
    if (p == 0) {
        return 1;
    }
    if (p % 2 == 0) {
        int64_t t = __pow_mod(n, p / 2, mod);
        return (t * t) % mod;
    }
    return n * __pow_mod(n, p - 1, mod) % mod;
}

constexpr int64_t pow_mod(int64_t n, int64_t p, int64_t mod) noexcept {
    int64_t res = __pow_mod(n, p, mod);
    if (res == 0) {
        res = mod;
    }
    if (res % mod != 0) {
        res %= mod;
    }
    return res;
}

template<int N>
struct seq {
    int arr[N];

    constexpr seq() : arr() {
        int i = 1;
        arr[0] = 0;
        while (i < N) {
            arr[i] = i;
            i++;
        }
    }
};

using initializer=int64_t (*)(int64_t, int64_t, int64_t);

template<int N, int MOD, initializer init>
struct invs {
    int arr[N + 1];

    constexpr invs() : arr() {
        int i = 1;
        arr[0] = 0;
        while (i < N) {
            arr[i] = init(i, MOD - 2, MOD);
            i++;
        }
    }
};

//pow_mod(333333,1000000005,1000000007)
int main() {
    int X, Y;
    cin >> X >> Y;

    if (X > 2 * Y || Y > 2 * X) {
        cout << 0 << endl;
        return 0;
    } else if ((X + Y) % 3 != 0) {
        cout << 0 << endl;
        return 0;
    } else if ((X + Y) < 3) {
        cout << 0 << endl;
        return 0;
    }

    int diff = abs(X - Y);
    int total = (X + Y) / 3;
    int a = (total - diff) / 2;
    int b = a + diff;
    if ((a + b) != total) {
        cerr << "e" << endl;
    }

    int64_t count = 1;
    //constexpr auto seq_arr = seq<ce::max + 1>();
    //constexpr auto inv_arr = invs<ce::max, ce::mod, pow_mod>();
    constexpr int mod = 1e9 + 7;
    constexpr int max = 333333;

    for (auto i = a + b; i > b; i--) {
        count *= i;
        if (count % mod != 0) {
            count %= mod;
        }
        int64_t inv = pow_mod(i - b, mod - 2, mod);
        count *= inv;
        if (count % mod != 0) {
            count %= mod;
        }
    }

    cout << (count) % mod << endl;
    return 0;
}


Measured memory_bytes: 888
from collections import *
n=int(input())
l=[]
for i in range(n):
    s=input()
    l.append(s)
c=Counter(l)
cs=c.most_common()
m=c.most_common()[0][1]
tmp=0
ans=[]
for i in range(len(cs)):
    if cs[i][1]!=m:
        break
    else:
        ans.append(cs[i][0])
ans.sort()
for i in ans:
    print(i)

Measured memory_bytes: 157420
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
#define MOD 1000000007
int main(){
ll n;
cin>>n;
vector<ll> a(n);
for(int i=0;i<n;i++) cin>>a[i];
sort(a.begin(),a.end());
reverse(a.begin(),a.end());
ll c=0;
for(int i=1;i<n;i++) c+=a[i];
cout<<(c>a[0]?"Yes":"No");
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
using namespace std;
int ans=0;
int n;
long long a[100005]={0}; 
int main(){
cin>>n;
for(int i=1;i<=n;i++){
	scanf("%lld",&a[i]);
	if(a[1]==i)ans++;
}
if(ans==0){
	cout<<0;
	return 0;
}
ans=0;
for(int i=1;i<=n;i++){
	if(a[i]==i){
		ans++;
		swap(a[i],a[i+1]);
	}
}
cout<<ans;
}


Measured memory_bytes: 1024
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n1 = sc.nextInt();
        int n2 = sc.nextInt();
         int add = n1+n2;
         int mul = n1*n2;
         int sub = n1-n2;
        // System.out.println(add);
        // System.out.println(mul);
        // System.out.println(sub);
         if(add>mul &&add>sub)System.out.println(add);
         else if(mul>sub)
            System.out.println(mul);
         else System.out.println(sub);
         
    }
}


Measured memory_bytes: 20948
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn shuffle(s: &str, h: usize) -> String {
    let (l,r) = s.split_at(h);
    String::from(r) + l
}

fn main() {
    loop {
        let mut s: String = read();
        if s == "-" {
            break;
        }
        let n: usize = read();
        for _ in 0..n {
            let h: usize = read();
            s = shuffle(&s,h);
        }
        println!("{}", s);
    }
}



Measured memory_bytes: 5028
n, m, l = map(int, input().split())
a = [[] for _ in range(n)]
b = [[] for _ in range(m)]
   
for i in range(n):
  a[i] = list(map(int, input().split()))
   
for i in range(m):
  b[i] = list(map(int, input().split()))
   
for i in range(n):
  line = []
    
  for j in range(l):
    c = 0
      
    for k in range(m):
      c += a[i][k]*b[k][j]
      
    line.append(str(c))
  
  print(' '.join(line))


Measured memory_bytes: 6244
N, K = map(int, input().split())
P = list(map(int, input().split()))


ans = 0
for i in range(K):
    ans += P[i]

max_ans = ans
for i in range(K, N):
    ans += P[i]
    ans -= P[i-K]
    if ans > max_ans:
        max_ans = ans

print((max_ans + K)/2)

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

#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FILL0(x) memset(x,0,sizeof(x))

using namespace std;

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

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

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

    int N;
    cin >> N;

    vector<int> boss(N);
    fill(boss.begin(), boss.end(), 0);
    rep(i, N-1)
    {
        int a;
        cin >> a;
        a--;
        boss[a]++;
    }


    rep(i, N)
    {
        cout << boss[i] << " ";
    }
    cout << endl;
 

 

    return 0;
}
 

//cout << setprecision(13);
//next_permutation();
//__gcd();
//reverse();
//set ,tuple ,pair;
//bitset
//vector.find



Measured memory_bytes: 3992
def I(): return int(input())
def LI(): return list(map(int,input().split()))
def MI(): return map(int,input().split())
def LLI(n): return [list(map(int, input().split())) for _ in range(n)]

n = I()
c = list(input())
r = c.count('R')
print(c[:r].count("W"))


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

int N;

int main(){
    cin >> N;
    int max_count = 0;
    int result = 1;
    for (int i = 1; i < N + 1; i++)
    {
        int count = 0;
        int n = i;
        // cout << i << endl;
        /* code */
        while(true){
            // cout << n << endl;
            if (n % 2 == 0 && n > 0)
            {
                n /= 2;
                count++;
            }
            else{
                break;
            }   
        }
        if (count > max_count)
        {
            max_count = count;
            result = i;
            /* code */
        }
    }
    cout << result << endl;
    
}

Measured memory_bytes: 3600
#include<stdio.h>
int main(){
int n,m[1000][1000];
int i,j,a,b,c;
 
scanf("%d", &n);
  for(i=1;i<n+1;i++){
    for(j=1;j<n+1;j++){
      m[i][j]=0;
    }
  }
 
  for(i=1;i<n+1;i++){
    scanf("%d%d",&a,&b);
    for(j=1;j<b+1;j++){
      scanf("%d",&c);
      m[i][c]=1;
    }
  }
  for(i=1;i<n+1;i++){
    for(j=1;j<n+1;j++){
      if(j>1)printf(" ");
      printf("%d",m[i][j]);
    }
printf("\n");
 }
return 0;
}

Measured memory_bytes: 2084
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define endl '\n'
#define el cout << endl
#define long long long
#define oo 1000000

const int N = 1e6;
int n;

int main()
{
    //freopen("test.inp", "r", stdin);
    //freopen("test.out", "w", stdout);
    ios_base::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    if (a < 6)
    {
        cout << 0;
    }
    else
        if (a < 13) cout << b/2;
        else cout << b;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author champon
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill((T*)array, (T*)(array+N), val);}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

class debug
{
public:
    template<typename T> void vdeb(T vec);
    template<typename T1, typename T2> void adeb(T1 *arr, T2 n);
    template<typename T> void mdeb(T mp);
};

#endif //INCLUDE_DEBUG_HPP

template<typename T> void debug::vdeb(T vec)
{
    cout << "#vector set debug" << endl;
    for(auto vv : vec) cout << vv << " ";
    cout << endl;
}

template<typename T1, typename T2> void debug::adeb(T1 *arr, T2 n)
{
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}

template<typename T> void debug::mdeb(T mp)
{
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
debug dbg;

class BCoins {
public:
	void solve(std::istream& in, std::ostream& out)
	{
	    int a, b ,c, x;
	    in >> a >> b >> c >> x;

	    int cnt = 0;
	    for(int i=0; i<=a; i++){
	        for(int j=0; j<=b; j++){
	            for(int k=0; k<=c; k++){
	                int num = 500*i + 100*j + 50*k;
	                if(x == num) cnt++;
	            }
	        }
	    }
	    out << cnt << endl;
	}
};


int main() {
	BCoins solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

int main(){
    string g;
    int y,m,d;
    int ans;

    while(1){
        cin>>g>>y>>m>>d;
        if(g=="#")break;

        if(y>=32||(y==31&&m>=5))cout<<"? "<<y-30<<" "<<m<<" "<<d<<endl;
        else cout<<g<<" "<<y<<" "<<m<<" "<<d<<endl;
    }

    return 0;
}



Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	int n; cin>>n;
	bool ok=false;
	rep(i,0,100){
		rep(j,0,100){
			if(i*4+j*7==n)ok=1;
		}
	}
	cout<<(ok ? "Yes":"No")<<endl;
	
	return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
inline void read(int& x)
{
	x=0;char c=getchar();
	while(!isdigit(c)) c=getchar();
	while(isdigit(c)) x=x*10+c-'0',c=getchar();
}
#define maxn 10005
struct Edge{int fr,to;} eg[maxn<<1];
int head[maxn],edgenum;
inline void add(int fr,int to)
{
	eg[++edgenum]={head[fr],to};
	head[fr]=edgenum;
}
int a[maxn],dp[maxn],n;
#define to eg[i].to
void dfs(int rt,int fa)
{
	dp[rt]=0;
	for(int i=head[rt];i;i=eg[i].fr)
	{
		if(to==fa) continue;
		dfs(to,rt);
		if(a[rt]>a[to]&&!dp[to]) dp[rt]=1;
	}
}
int main()
{
	read(n);
	for(int i=1;i<=n;++i) read(a[i]);
	for(int i=1,x,y;i<n;++i) read(x),read(y),add(x,y),add(y,x);
	for(int i=1;i<=n;++i)
	{
		dfs(i,0);
		if(dp[i]) printf("%d ",i);
	}
	return 0;
}

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

int main() {
	int R, G, B, N;
	cin >> R >> G >> B >> N;

	int ans = 0;

	for (int r = 0; r < N / R + 1; r++)
	{
		int tmp = N - (R * r);
		if (tmp < 0) break;
		for (int g = 0; g < tmp / G + 1; g++)
		{
			int tmp = N - (R * r + G * g);
			if (tmp < 0) break;
			if (tmp % B == 0) ans++;
		}
	}

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


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {

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

        InputStreamReader is = new InputStreamReader(System.in);
        BufferedReader reader = new BufferedReader(is);

        List<String> mylist = new ArrayList<>();

        // 標準入力からの値を変数strinputに代入
        String strinput = reader.readLine();

        while (strinput != null) {

            mylist.add(strinput);
            strinput = reader.readLine();

        }

        String arr01[] = mylist.get(0).split(" ");
        String arr02[] = mylist.get(1).split(" ");
        String u = mylist.get(2);

        String s = arr01[0];
        String t = arr01[1];

        int a = Integer.valueOf(arr02[0]);
        int b = Integer.valueOf(arr02[1]);

        if (u.equals(s)) {
            a -= 1;
        } else {
            b -= 1;
        }
        System.out.println(a + " " + b);
    }

}


Measured memory_bytes: 21332
#include <bits/stdc++.h>
#define ALL(x) begin(x), end(x)

using namespace std;

int d[31][31];
int c[501][501];

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

    int N, C;
    cin >> N >> C;
    for (int i = 1; i < C + 1; i++) {
        for (int j = 1; j < C + 1; j++) {
            cin >> d[i][j];
        }
    }
    for (int i = 1; i < N + 1; i++) {
        for (int j = 1; j < N + 1; j++) {
            cin >> c[i][j];
        }
    }

    vector<vector<pair<int, int>>> v;
    int discon;

    for (int rem = 0; rem < 3; rem++) {
        v.push_back({});
        for (int color = 1; color < C + 1; color++) {
            discon = 0;
            for (int i = 1; i < N + 1; i++) {
                for (int j = 1; j < N + 1; j++) {
                    if (((i + j) % 3) == rem) {
                        discon += d[c[i][j]][color];
                    }
                }
            }
            v[rem].push_back(make_pair(discon, color));
        }
        sort(ALL(v[rem]));
    }

    int ans = INT_MAX;
    int t, ptr[3], tmp;

    for (int i = 0; i < 27; i++) {
        t = i;
        for (int j = 0; j < 3; j++) {
            ptr[j] = t % 3;
            t /= 3;
        }

        if ((v[0][ptr[0]].second != v[1][ptr[1]].second) &&
            (v[1][ptr[1]].second != v[2][ptr[2]].second) &&
            (v[2][ptr[2]].second != v[0][ptr[0]].second)) {
            tmp = 0;
            for (int j = 0; j < 3; j++) {
                tmp += v[j][ptr[j]].first;
            }
            ans = min(ans, tmp);
        }
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define mxn (int)1e5+10
using namespace std;
 
int ar[mxn][3], dp[mxn][3];
 
int solve(int day, int task) {
 
    if(day < 0) return 0;
 
    if(dp[day][task] != 0) return dp[day][task];
 
    int ans = INT_MIN;
 
    for(int t=0; t<3; ++t) {
        if(t != task)
            ans = max(ans, ar[day][task]+solve(day-1, t));
    }
    return dp[day][task] = ans;
}
 
int main() {
    int n; cin >> n;
 
    for(int i=0; i<n; ++i) {
        for(int j=0; j<3; ++j) {
            cin >> ar[i][j];
        }
    }
 
    int ans = INT_MIN;
    for(int j=0; j<3; ++j) {
        ans = max(ans, solve(n, j));
    }
 
    cout << ans << '\n';
 
    return 0;
}

Measured memory_bytes: 13724
#include<bits/stdc++.h>
using namespace std;
int n,a[505][505],dis[505][505];
int dx[4]={0,-1,0,1};
int dy[4]={1,0,-1,0};
void dfs(int x,int y){
	for(int i=0;i<4;++i){
		int tx=x+dx[i],ty=y+dy[i];
		if(1<=tx&&tx<=n&&1<=ty&&ty<=n&&dis[tx][ty]>dis[x][y]+a[tx][ty]) dis[tx][ty]=dis[x][y]+a[tx][ty],dfs(tx,ty);
	}
} 
int main(){
	cin>>n;int pi;
	for(int i=1;i<=n;++i)
		for(int j=1;j<=n;++j)
			dis[i][j]=min(min(i,j),min(n-i+1,n-j+1)),a[i][j]=1;
	int ans=0;
	for(int i=1;i<=n*n;++i){
		cin>>pi;
		int x=(pi-1)/n+1,y=(pi-1)%n+1;
		//cout<<x<<" "<<y<<" "<<dis[x][y]<<endl;
		a[x][y]=0; dis[x][y]--; dfs(x,y);
		ans+=dis[x][y];
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 24792
#include<iostream>
#include <algorithm>
#include <functional>
#include<vector>
#include<math.h>
#include<bitset>
#include<string>
#include <deque>
#include<queue>
#include <iomanip>
#include<map>
#include <random>
#include<type_traits>
#include<stack>
#include <sstream> 
using namespace std;


#define ll long long int
#define all(v) begin(v), end(v)
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
typedef pair<int, int> Edge;

vector<long long int> divi;


int main() {
	long long int a, b;
	cin >> a >> b;
	if (a == b) {
		cout << a << endl;
	}
	else {
		if (a % 2 == 0) {
			if (b % 2 == 0) {
				if ((b - a ) % 4 == 0) {
					cout << (b) << endl;
				}
				else {
					cout << (1^b) << endl;
				}
			}
			else {
				if ((b - a+1) % 4==0) {
					cout << 0 << endl;
				}
				else {
					cout << 1 << endl;
				}
			}
		}
		else {
			if (b % 2 == 0) {
				if ((b - a -1) % 4 == 0) {
					cout << (a^b) << endl;
				}
				else {
					cout << (1 ^ a^b) << endl;
				}
			}
			else {
				if ((b - a) % 4 == 0) {
					cout << a << endl;
				}
				else {
					cout << (a^1) << endl;
				}
			}
		}
	}


}


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

int deg[4];

int main() {
	for (int i = 0; i < 3; i++) {
		int x, y;
		cin >> x >> y;
		x--, y--;
		
		deg[x]++;
		deg[y]++;
	}
	
	int odd = 0;
	
	for (int i = 0; i < 4; i++) {
		odd += deg[i] % 2;
	}
	
	puts(odd == 2 || odd == 0 ? "YES" : "NO");
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
 
#pragma GCC optimize("Ofast")
//#pragma GCC optimization("unroll-loops, no-stack-protector")
//#pragma GCC target("avx,avx2,fma")
 
using namespace std;

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
template<typename T>
using pair2 = pair<T, T>;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define endl '\n';
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
template <class T> inline T gcd(T a, T b) { while (b) { a %= b; swap(a, b); } return a; }
template <class T> inline T lcm(T a, T b) { return a * b / gcd(a, b); }

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__);fflush(stderr);
#else
    #define eprintf(...) 42
#endif

clock_t startTime;
double getCurrentTime() {
    return (double)(clock() - startTime) / CLOCKS_PER_SEC;
}

const ll MOD = (ll)1e9 + 7, INF = (ll)1e18;;
ll add(ll x, ll y) {
    x += y;
    if (x >= MOD) return x - MOD;
    return x;
}
ll sub(ll x, ll y) {
    x -= y;
    if (x < 0) return x + MOD;
    return x;
}
ll mul(ll x, ll y) {
    return (x * y) % MOD;
}
ll bin_pow(ll x, ll p) {
    if (p == 0) return 1;
    if (p & 1) return mul(x, bin_pow(x, p - 1));
    return bin_pow(mul(x, x), p / 2);
}

const int N = 100100;
int a[N];
int n, t;
set <int> s;
map <int, int> m;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    startTime = clock();
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    cin >> n >> t;
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    
    s.insert(a[n - 1]);
    for (int i = n - 2; i >= 0; --i) {
        int mx = *--s.end();
        if (mx > a[i])
            m[mx - a[i]]++;
        s.insert(a[i]);
    }
    auto last = --m.end();
    cout << last->second << endl;
    
    return 0;
}


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

using namespace std;

typedef long long ll;

ll n,m;
ll mod = 1000000007;
char labrinth[1005][1005];

ll memo[1005][1005][5];
bool check[1005][1005][5];

ll dp(int x,int y,int dir){

    if(x==n || y == m) return 0;

    if(labrinth[x][y]=='#') return 0;

    if(x==n-1&&y==m-1) return 1;

    if(check[x][y][dir])
        return memo[x][y][dir];

    ll op1 = dp(x+1,y,1);
    ll op2 = dp(x,y+1,0);

    memo[x][y][dir]=(op1+op2)%mod;
    check[x][y][dir]=true;

    //cout << x << ' '<< y << ' ' << dir << ' ' << memo[x][y][dir]<< endl;

    return memo[x][y][dir];

}

int main() {
    cin>>n>>m;
    for(int i=0;i<n;i++){
        for(int j =0;j<m;j++){
            cin>>labrinth[i][j];
        }
    }

    cout << dp(0,0,0);

    return 0;
}

Measured memory_bytes: 45696
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int in() {int x; cin>>x; return x;}
ll lin() {ll x; cin>>x; return x;}
string sin() {string x;cin>>x;return x;}
using graph = vector<vector<int>>;
using graph2 = vector<vector<pair<int, int>>>;

bool ifprime(int x){
    if(x==1)return false;
    if(x==2)return true;
    if(x%2==0)return false;
    for(int i=2;i*i<=x;i++){if(x%i==0)return false;}
    return true;
}
ll mod(ll x, ll y){if(x>=0||x%y==0) return x%y;return y+x%y;} //mod including minus
ll dv0(ll x, ll y){if(x>=0||x%y==0)return x/y;return x/y-1;} //rnd down
ll dv1(ll x, ll y){if(x%y==0) return dv0(x,y);return dv0(x,y)+1;} //rnd up

//Start from Here
int main(){
    int N, K, C;
    cin>>N>>K>>C;
    string S;
    cin>>S;
    int a[K], b[K];
    int i=0;
    int cnt=0;
    while(i<N&&cnt<K){
        if(S.at(i)=='o'){
            a[cnt]=i;
            cnt++;
            i+=C+1;
        }
        else{
            i++;
        }
    }
    i=0;
    cnt=0;
    while(i<N&&cnt<K){
        if(S.at(N-1-i)=='o'){
            b[K-cnt-1]=N-1-i;
            cnt++;
            i+=C+1;
        }
        else{
            i++;
        }
    }
    rep(i, K){
        if(a[i]==b[i]){
            cout<<a[i]+1<<endl;
        }
    }
}

Measured memory_bytes: 3332
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long n,W;
  cin>>n>>W;
  long long val[n],wt[n];
  for(int i=0;i<n;i++){
      cin>>wt[i]>>val[i];
  }
  long long dp[n+1][W+1];
  for(int i=0;i<=n;i++){
      dp[i][0]=0;
  }
  for(int i=0;i<=W;i++){
      dp[0][i]=0;
  }
  for(int i=1;i<=n;i++){ //ith item
      for(int j=1;j<=W;j++){ //j wt
          dp[i][j]=dp[i-1][j];//not taking i
          if(wt[i-1]<=j){
              dp[i][j]=max(dp[i][j],val[i-1]+dp[i-1][j-wt[i-1]]);
          }
      }
  }
  cout<<dp[n][W];
}

Measured memory_bytes: 82480
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define PI 				acos(-1)
#define mp				make_pair
#define pb				push_back
#define all(a)			(a).begin(), (a).end()
#define srt(a)			sort(all(a))
#define mem(a, h)		memset(a, (h), sizeof(a))
#define f 				first
#define s 				second
#define MOD				1000000007
#define MOD1			998244353
#define EPS				1e-9
#define fore(i, b, e)	for(ll i = b; i < e; i++)
#define forg(i, b, e, m)	for(ll i = b; i < e; i+=m)
//ll in(){ll r=0,c;for(c=getchar();c<=32;c=getchar());if(c=='-') return -in();for(;c>32;r=(r<<1)+(r<<3)+c-'0',c=getchar());return r;}

using namespace std;
using namespace __gnu_pbds;

typedef long long 		ll;
typedef unsigned long long 		ull;
typedef pair<ll, ll>  ii;
typedef vector<ll>     vi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

int main()
{
	ios::sync_with_stdio(false); cin.tie(0);
	//freopen("asd1.txt", "r", stdin);
	//freopen("asd.txt", "w", stdout);
	string s;
	cin>>s;
	char com = '1', nom = '0';
	int con[2];
	fore(i, 0, 2)
	{
		con[i] = 0;
		fore(j, 0, s.size())
		{
			if(com != s[j])
				con[i]++;
			swap(com, nom);
		}
		
		com = '0', nom ='1';
	}
	cout<<min(con[0], con[1])<<'\n';
	return 0;
}

// read the question correctly (is y a vowel? what are the exact constralls?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs ll?) ARRAY OUT OF BOUNDSS2

Measured memory_bytes: 512
import math
N=int(input())
pl=[2]
for i in range(3,N+1):
  if all(i%p!=0 for p in pl):
    pl.append(i)
pd={}
Nf=math.factorial(N)
for i in range(len(pl)):
  if Nf%pl[i]==0:
    pd[pl[i]]=1
    Nf//=pl[i]
    while Nf%pl[i]==0:
      pd[pl[i]]+=1
      Nf//=pl[i]
l74=[]
l24=[]
l14=[]
l4=[]
l2=[]
for i in range(len(pd)):
  if pd[pl[i]]>=74:
    l74.append(pl[i])
  if pd[pl[i]]>=24:
    l24.append(pl[i])
  if pd[pl[i]]>=14:
    l14.append(pl[i])
  if pd[pl[i]]>=4:
    l4.append(pl[i])
  if pd[pl[i]]>=2:
    l2.append(pl[i])
ans1=len(l74)
ans2=len(l24)*(len(l2)-1) if len(l2)>=1 else 0
ans3=len(l14)*(len(l4)-1) if len(l4)>=1 else 0
ans4=(len(l4)-1)*len(l4)*(len(l2)-2)//2 if len(l2)>=2 else 0
print(ans1+ans2+ans3+ans4)

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main() {
  long long n, k;
  cin >> n >> k;
  
  n %= 1000000007;
  long long ans = 0;
  for (int i = k; i <= n+1; ++i) {
    long long tmp = i % 1000000007ll;
    long long mi = tmp * (tmp - 1) / 2, ma = n * tmp - (tmp - 1) * i / 2;
    ans += ma - mi + 1;
    ans %= 1000000007ll;
  }
  cout << ans << endl;
  return 0;
}


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


int N,K;

int dx[2] = {1,-1};

const int INF = 2000000000;
int main(){
	cin >> N >> K;
	int x[N];
	int d[N];
	for(int i=0;i<N;i++){
		cin >> x[i];
		d[i] = abs(x[i]);
	}
	int ans=INF;
		for(int i=0;i<N-K+1;i++){
			int mid = abs(x[i] - x[i+K-1]);
			ans = min(min(d[i],d[i+K-1]) + mid, ans);
		}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  // 前後をflagで管理、1の時前を向いている
  string S;
  cin >> S;
  list<char> T;
  rep(i, sz(S)) T.push_back(S[i]);
  int Q;
  cin >> Q;
  bool flag = 1;
  rep(i, Q) {
    int A;
    cin >> A;
    if (A == 1) {
      flag ^= 1;
    } else {
      int F;
      char C;
      cin >> F >> C;
      F = 2 - F;
      if (flag^F == 0) {
        T.push_front(C);
      } else {
        T.push_back(C);
      }
    }
  }
  if (flag == 0) reverse(T.begin(), T.end());
  auto itr = T.begin();
  for (int i = 0; i < sz(T); i++) {
    cout << *itr;
    ++itr;
  }
  cout << '\n';
  return 0;
}

Measured memory_bytes: 13072
#include<iostream>
using namespace std;
int main(){
  int d,n,ans;
  cin >> d >> n;
  if (n == 100) n += 1;
  if (d == 0) ans = n;
  else if (d == 1) ans = 100*n;
  else ans = 10000*n;
  cout << ans << endl;
}
  

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

int main(){
	int N;
	cin>>N;
	if(N%10==3){
		cout<<"bon"<<endl;
	}
	else if(N%10==0 || N%10==1 || N%10==6 ||N%10==8){
		cout<<"pon"<<endl;
	}
	else cout<<"hon"<<endl;
}


Measured memory_bytes: 3620
n = int(input())
s = int(input())

def f(b,n):
  if n < b:
    return n
  return f(b,n//b) + n%b


def solve(n,s):
  if s > n:
    return -1
  if s == n:
    return n+1
  nsq = int(n**0.5 + 1)
  for b in range(2,nsq+1):
    if f(b,n) == s:
      return b
  # 2桁で作れるかどうか
  # n = bx+y, s = x+y, x,y < b
  # n - s = (b-1)x, x < b
  m = n-s
  msq = int(m**0.5+1)
  for x in range(msq,0,-1):
    if m%x:
      continue
    b = m//x+1
    if f(b,n) == s:
      return b
  return -1
  
answer = solve(n,s)
print(answer)


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

int N, A, B;
string S;

int main() {
    cin >> N >> A >> B >> S;

    for (int i = 0; i < N; i++) {
        if (S[i] == 'a') {
            if (A > 0) {
                cout << "Yes" << endl;
                A--;
            }
            else if (B > 0) {
                cout << "Yes" << endl;
                B--;
            }
            else cout << "No" << endl;
        }
        else if (S[i] == 'b') {
            if (B > 0) {
                cout << "Yes" << endl;
                B--;
            }
            else cout << "No" << endl;
        }
        else cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 896
#include<iostream>
#include<stdio.h>
using namespace std;

int N;
long long A[10110];
int min() {
	long long min_v = A[0];
	for (int i = 0; i < N; ++i) {
		if (A[i] < min_v)
		{
			min_v = A[i];
		}
	}
	return min_v;
}

int max() {
	long long max_v = A[0];
	for (int i = 0; i < N; ++i) {
		if (A[i] > max_v)
		{ max_v = A[i];
		}
	}
	return max_v;
}



long long sum() {
	long long sum_v = 0;
	for (int i = 0; i < N; ++i) {
		sum_v += A[i];
	}
	return sum_v;

}

int main() {
	
	cin >> N;
	for (int i = 0; i < N; ++i)
	{
		cin >> A[i];
	}
	cout << min() <<' '<<max()<<' '<<sum()<<endl;
	return 0;

	

}


Measured memory_bytes: 3168
n=list(input())
a=n[0]*len(n)
n1=0
for i in range(len(n)):
    n1+=int(n[i])*(10**(len(n)-1-i))
if int(a)<n1:
    n[0]=str(int(n[0])+1)
    print((n[0])*len(n))
else:
    print(a)

Measured memory_bytes: 3064
k, n = gets.split(' ').map(&:to_i)
a = gets.split(' ').map(&:to_i)
r = (0 + a[0] - a[-1]).abs
l = (k + a[0] - a[-1]).abs
b = [[r, l].min]
for i in 0...a.size-1 do
  b << (a[i+1] - a[i]).abs
end
puts k - b.max

Measured memory_bytes: 17028
#include<bits/stdc++.h>
using namespace std;
int read() { 
    bool flag = true; int num = 0;char c = getchar(); 
    for(;c < '0' || c > '9';c = getchar())if(c == '-') flag = false; 
    for(;c >= '0' && c <= '9';c = getchar()) num = ( num << 3 ) + ( num << 1 ) + c - 48; 
    if(flag) return num;  else return -num; 
}
bool check(int x){
	int a,b,c,d,e;
	e=x%10;
	x/=10;
	d=x%10;
	x/=10;
    c=x%10;
	x/=10;
	b=x%10;
	x/=10;
	a=x%10;
	if(a==e&&b==d) return true;
	return false;
}
int main(){
	int n,m;
	n=read();m=read();
	int sum=0;
	for(int i=n;i<=m;++i)
	 if(check(i)) sum++;
	 cout<<sum;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

	for (int i = A; i <= B; i++)
	{
		if (i % K == 0)
		{
			cout << "OK" << endl;
			return 0;
		}
	}

	cout << "NG" << endl;

	return 0;
}

Measured memory_bytes: 3608
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
 


public class Main {
	static int a1[]= {0,-1,0,1};
	static int b1[]= {-1,0,1,0};
	private static Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");
	public static void main(String[] args) {
		int N=sc.nextInt();
		ArrayList<Integer> cc=new ArrayList<>(N);
		for(int i=0;i<N;i++) {
			cc.add(sc.nextInt());
		}
		Collections.sort(cc);
		p(cc.get(N/2)-cc.get(N/2-1));
		
	}
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
}
	

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

int main(int argc, char const *argv[])
{
    int n;cin>>n;
    string last_s;cin>>last_s;
    bool is_OK = true;
    set<string> set_s;
    set_s.insert(last_s);
    for(int i=1;i<n;i++){
        string s;cin>>s;
        if(last_s[last_s.size()-1]!=s[0]){
            is_OK = false;
            // break;
        }
        if(set_s.find(s) != set_s.end()){
            is_OK = false;
        }
        else
        {
            set_s.insert(s);
        }
        
        last_s = s;
    }
    is_OK ? cout << "Yes" << endl : cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define DEBUGP(val) cerr << #val << "=" << val << "\n"

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;



int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a, b;
  cin >> a >> b;
  int d = b - a;
  cout << d * (d + 1) / 2 - b << endl;
}


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

#define int long long
#define fi first
#define se second
#define pb push_back
#define ins insert
#define er erase

typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef pair<ii, ii> iiii;

const int oo = 1e18 + 7, mod = 1e9 + 7;

int n, m, s, c[55], d[55], dp[55][5005];
vector<iii> vc[55];
priority_queue<iii, vector<iii>, greater<iii>> pq;

void dijk(){
    while(!pq.empty()){
        //if(pq.size() <= 5000) cout << pq.size() << "\n";
        iii tmp = pq.top();
        pq.pop();
        if(tmp.fi > dp[tmp.se.fi][tmp.se.se]) continue;
        int u = tmp.se.fi;
        //cout << u << " " << tmp.se.se << " " << dp[tmp.se.fi][tmp.se.se] << " " << c[u] << " " << d[u] << "\n";
        if(tmp.se.se + c[u] <= 5000 && dp[u][tmp.se.se + c[u]] > (dp[u][tmp.se.se] + d[u])){
            dp[u][tmp.se.se + c[u]] = (dp[u][tmp.se.se] + d[u]);
            pq.push({dp[u][tmp.se.se + c[u]], {u, tmp.se.se + c[u]}});
        }
        for(int i = 0; i < vc[u].size(); i++){
            int v = vc[u][i].fi;
            if(tmp.se.se < vc[u][i].se.fi) continue;
            //cout << u << " " << tmp.se.se << " " << dp[u][tmp.se.se] << "\n";
            if(dp[v][tmp.se.se - vc[u][i].se.fi] > (dp[u][tmp.se.se] + vc[u][i].se.se)){
                //if(v == 3) cout << u << " " << v << " " << tmp.se.se << "\n";
                dp[v][tmp.se.se - vc[u][i].se.fi] = dp[u][tmp.se.se] + vc[u][i].se.se;
                //if(pq.size() < 10000) cout << v << " " << tmp.se.se - vc[u][i].se.fi << "\n";
                pq.push({dp[v][tmp.se.se - vc[u][i].se.fi], {v, tmp.se.se - vc[u][i].se.fi}});
            }
        }
    }
}

signed main(){
	ios_base::sync_with_stdio(0);
	cin >> n >> m >> s;
	s = min(s, 5000LL);
	for(int i = 1; i <= m; i++){
	    int u, v, a, b;
	    cin >> u >> v >> a >> b;
	    vc[u].pb({v, {a, b}});
	    vc[v].pb({u, {a, b}});
	}
	for(int i = 1; i <= n; i++) cin >> c[i] >> d[i];
    for(int i = 1; i <= n; i++){
	    for(int j = 0; j <= 5000; j++) dp[i][j] = oo;
	}
	dp[1][s] = 0;
	for(int i = 1; i <= n; i++){
	    for(int j = 0; j <= 5000; j++) pq.push({dp[i][j], {i, j}});
	}
	dijk();
	for(int i = 2; i <= n; i++){
	    int answ = oo;
	    for(int j = 0; j <= 5000; j++) answ = min(answ, dp[i][j]);
	    cout << answ << "\n";
	}
}


Measured memory_bytes: 17492
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

const int N = 100;
char a[2][N];
int dp[N];

int main() {
  int n;
  scanf("%d", &n);
  scanf("%s", a[0] + 1);
  scanf("%s", a[1] + 1);
  dp[0] = 1;
  for (int i = 1; i <= n; ) {
    if (a[0][i] == a[1][i]) {
      if (i == 1) {
        dp[i] = dp[i - 1] * 3LL % MOD;
      } else {
        if (a[0][i - 1] == a[1][i - 1]) {
          dp[i] = dp[i - 1] * 2LL % MOD;
        } else {
          dp[i] = dp[i - 1];
        }
      }
      i += 1;
    } else {
      if (i == 1) {
        dp[i] = dp[i - 1] * 6LL % MOD;
      } else {
        if (a[0][i - 1] == a[1][i - 1]) {
          dp[i] = dp[i - 1] * 2LL % MOD;
        } else {
          dp[i] = dp[i - 1] * 3LL % MOD;
        }
      }
      dp[i + 1] = dp[i];
      i += 2;
    }
  }
  printf("%d\n", dp[n]);
  return 0;
}


Measured memory_bytes: 256
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/

#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

const ll MODBASE = 1000000007LL;
const int MAXN = 310;
const int MAXM = 1010;
const int MAXK = 110;
const int MAXQ = 200010;

int n, m;
ll a[MAXN][MAXN], L;
int dp[MAXN][MAXN];

void bfs(int p) {
    FOR(i,1,n) dp[p][i] = 1000000000;
    dp[p][p] = 0;
    queue<int> q;
    q.push(p);
    while (!q.empty()) {
        int u = q.front();
        q.pop();
        FOR(v,1,n) 
            if (a[u][v] <= L) {
                if (dp[p][v] > dp[p][u] + 1) {
                    dp[p][v] = dp[p][u] + 1;
                    q.push(v);
                }
            }
    }
    FOR(i,1,n) 
        if (i == p) continue;
        else if (dp[p][i] == 1000000000) dp[p][i] = -1;
        else dp[p][i]--;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n >> m >> L;
    FOR(i,1,n)
        FOR(j,1,n) {
            if (i == j) a[i][j] = 0;
            else a[i][j] = 1e15;
            dp[i][j] = -1;
        }
    FOR(i,1,m) {
        int u, v;
        ll c;
        cin >> u >> v >> c;
        if (c > L) continue;
        a[u][v] = min(a[u][v], c);
        a[v][u] = min(a[v][u], c);
    }
    FOR(k,1,n)
        FOR(i,1,n)
            FOR(j,1,n) a[i][j] = min(a[i][j], a[i][k] + a[k][j]);
    FOR(i,1,n) bfs(i);
    // FOR(i,1,n) {
    //     FOR(j,1,n) cout << dp[i][j] << ' ';
    //     cout << endl;
    // }
    int q;
    cin >> q;
    while (q--) {
        int u, v;
        cin >> u >> v;
        cout << dp[u][v] << "\n";
    }
    return 0;
}


Measured memory_bytes: 1664
# ABC066C - pushpush (ARC077)
def main():
    N, *A = open(0).read().split()
    if int(N) & 1:
        B, C = A[::2][::-1], A[1::2]
    else:
        B, C = A[1::2][::-1], A[::2]
    print(" ".join(B), end=" ")
    print(" ".join(C))


if __name__ == "__main__":
    main()

Measured memory_bytes: 23644
#include<string.h>

#include<stdio.h>

int main(void)

{

int i,sum=0;

int flag=0;

char x[1002];

scanf("%s",x);

do

{

for(i=0;i<1002;i++){

if(x[i]==0){

printf("%d\n",sum);

break;

}else{

sum+=x[i]-0x30;

}

}

sum=0;

scanf("%s",x);

}while(x[0]!=0x30);

return 0;}

Measured memory_bytes: 536
main(i,j,n,r,x){
  for(;scanf("%d",&n),n;printf("%d\n",r)){
    for(i=0;i<n;i++)
      scanf("%d",a+i);
    for(r=i=0;i<n;i++)
      for(j=0;j<n-1;j++)
        if(a[j]>a[j+1])x=a[j],a[j]=a[j+1],a[j+1]=x,r++;
  }
  return 0;
}

Measured memory_bytes: 0
N = int(input())
a = list(map(int, input().split()))
b = sum(a) / N
m = 10000000000
ans = 0
for i in range(N - 1, -1 , -1):
    if abs(a[i] - b) <= m:
        m = abs(a[i] - b)
        ans = i
print(ans)

Measured memory_bytes: 3060
from collections import deque
n=int(input())
a=list(map(int,input().split()))
b=deque()
if n%2==0:
    for i in range(n):
        if i%2==0:
            b.append(str(a[i]))
        else:
            b.appendleft(str(a[i]))
    print(" ".join(b))
else:
    for i in range(n):
        if i%2==0:
            b.appendleft(str(a[i]))
        else:
            b.append(str(a[i]))
    print(" ".join(b))


Measured memory_bytes: 106800
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#define MAXN 100000
#define INF 0x7FFFFFFF
using namespace std;
struct edge
{
	int to,val;
	edge(){};
	edge(int _to,int _val):to(_to),val(_val){};
};
struct node
{
	int val,mark;
}poi[MAXN+5];
bool flag=true;
int cerval=-INF,low=0,high=INF;
bool vis[MAXN+5];
vector<edge> G[MAXN+5];
void DFS(int u)
{
	if(flag==false)
		return;
	vis[u]=true;
	edge e;
	int mark1,mark2,val1,val2;
	mark1=poi[u].mark;
	val1=poi[u].val;
	for(int i=0;i<G[u].size();i++)
	{
		e=G[u][i];
		mark2=poi[e.to].mark;
		val2=poi[e.to].val;
		if(vis[e.to]==true)
		{
			if(mark1+mark2==0)
			{
				if(val1+val2!=e.val)
				{
					flag=false;
					return;
				}
			}
			else
			{
				if(cerval!=-INF)
				{
					if(cerval*(mark1+mark2)+val1+val2!=e.val)
					{
						flag=false;
						return;
					}
				}
				else
				{
					if((e.val-val1-val2)%(mark1+mark2)!=0)
					{
						flag=false;
						return;
					}
					else
						cerval=(e.val-val1-val2)/(mark1+mark2);
				}
			}
		}
		else
		{
			poi[e.to].mark=-mark1;
			poi[e.to].val=e.val-val1;
			if(poi[e.to].mark>0)
				low=max(low,(-poi[e.to].val)/poi[e.to].mark);
			else
				high=min(high,(-poi[e.to].val)/poi[e.to].mark);
			DFS(e.to);
			if(flag==false)
				return;
		}
	}
}
int main()
{
	int n,m,u,v,x;
	scanf("%d %d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		scanf("%d %d %d",&u,&v,&x);
		G[u].push_back(edge(v,x));
		G[v].push_back(edge(u,x));
	}
	poi[1].mark=1;
	poi[1].val=0;
	DFS(1);
	if(flag==false||(cerval!=-INF&&(cerval<=low||cerval>=high))||low>=high)
	{
		printf("0\n");
		return 0;
	}
	if(cerval!=-INF)
		printf("1\n");
	else
		printf("%d\n",high-low-1);
	return 0;
}

Measured memory_bytes: 11264
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;

class AtCoder
{
    public void Slove()
    {
        long n = long.Parse(Console.ReadLine());
        var array =
            Enumerable.Range(0, 5)
            .Select(x => long.Parse(Console.ReadLine()))
            .ToArray();
        long sum = 0;
        long bef = long.MaxValue;
        long min = array.Min();
        sum = 4 + (n + min - 1) / min;
        Console.WriteLine(sum);
    }
    static void Main()
    {
        var ac = new AtCoder();
        ac.Slove();
    }
}

Measured memory_bytes: 13396
#include<stdio.h>

int main() {
	int a, b, c, i, count=0;

	scanf("%d %d %d", &a, &b, &c);

	for (i = a; i <= b; i++) {
		if (c % i == 0)count++;
	}

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


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

int main()
{
    int N;
    int num[3] = {0};

    cin >> N;
    for (int i = 0; i < N; i++)
    {
        int x;
        cin >> x;
        if (x % 4 == 0)
        {
            num[2]++;
        }
        else if (x % 2 == 0)
        {
            num[1]++;
        }
        else
        {
            num[0]++;
        }
    }

    if (num[2] < num[0] - 1)
    {
        cout << "No" << endl;
    }
    else if (num[2] == num[0] - 1)
    {
        if (num[1] == 0)
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
    }
    else if (num[2] > num[0] - 1)
    {
        cout << "Yes" << endl;
    }

    return 0;
}

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

const ll INF = 1e10;

int main(){
  int N,M,X;
  cin >> N >> M >> X;

  int C[N],A[N][M];
  rep(i,N){
    cin >> C[i];
    rep(j,M) cin >> A[i][j];
  }
  ll dp[1<<N][M];
  rep(i,1<<N) rep(j,M) dp[i][j] = 0;

  rep(bit, 1<<N){
    rep(u,N){
      if(bit & 1<<u){
        rep(j,M){
          dp[bit][j] = dp[bit ^ 1<<u][j] + A[u][j];
        }
      }
    }
  }
  ll ans = INF;
  for(ll bit = 1; bit < 1<<N; bit++){
    bool flg = true;
    ll sum = 0;
    rep(u,N){
      if(bit & 1<<u){
        sum += C[u];
        rep(j,M){
          if(dp[bit][j] < X) flg = false;
        }
      }
    }
    if(flg) ans = min(ans,sum);
  }



  cout << (ans == INF ? -1 : ans);
}


Measured memory_bytes: 3948