akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,m, n) for(int i=m; i<n; i++)
typedef long long ll;

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

int main(){
  ll a,b;cin>>a>>b;
  ll rec=GCD(a,b);
  ll res=1;
  vector<ll> ans;
  rep(i,2,sqrt(rec)+1){
      if(rec%i==0){
          ans.push_back(i);
          while(rec%i==0){
              rec/=i;
          }
      }
  }
  
  ans.push_back(rec);
  res+=(ans.size());
  if(rec==1) res--;
  cout<<res<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v)) os<<*i<<(i==end(v)-1?"":" "); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
    is>>p.first>>p.second; return is; }
template <class T> bool chmax(T &a,const T &b) {if(a<b) {a=b;return 1;} return 0;}
template <class T> bool chmin(T &a,const T &b) {if(b<a) {a=b;return 1;} return 0;}
template <class T> using heap = priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int A,B,C;
    cin>>A>>B>>C;
    if(A%2 || B%2 || C%2) {
        cout<<0<<endl;
        return 0;
    }
    if(A==B && B==C) {
        cout<<-1<<endl;
        return 0;
    }
    int ans=0;
    while(1) {
        int a=A,b=B,c=C;
        A=b/2+c/2;
        B=a/2+c/2;
        C=a/2+b/2;
        ans++;
        if(A%2 || B%2 || C%2) break;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int a[4], b, c;

	for (int i = 0; i < 4; i++)
	{
		scanf("%d", &a[i]);
	}

	if (a[0] < a[1])
	{
		b = a[0];
	}
	else if (!a[0] < a[1])
	{
		b = a[1];
	}

	if (a[2] < a[3])
	{
		c = a[2];
	}
	else if (!a[2] < a[3])
	{
		c = a[3];
	}

	printf("%d\n", b+c);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <set>
#include <math.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> Q;
const ll mod = 1000000007;
const ll INF = 1000000000000000;

ll bit[200010];
ll n, m, a[100010], b, c, dp[100010];

ll sum(ll i)
{
	ll s = 0;
	while (i > 0)
	{
		s += bit[i];
		i -= i & -i;
	}
	return s;
}

void add(ll i, ll x)
{
	while (i <= n)
	{
		bit[i] += x;
		i += i & -i;
	}
}

ll pow_mod(ll x, ll y)
{
	ll res = 1;
	while (y > 0)
	{
		if (y % 2 == 1)
		{
			(res *= x) %= mod;
		}
		(x *= x) %= mod;
		y /= 2;
	}
	return res;
}

ll div(ll x)
{
	return pow_mod(x, mod - 2);
}



int main(void)
{
	cin >> n >> m;
	for (int i = 1; i < pow_mod(2, 12); i++)
	{
		dp[i] = INF;
	}
	for (int i = 1; i <= m; i++)
	{
		cin >> a[i] >> b;
		ll bi = 0, c;
		for (int j = 1; j <= b; j++)
		{
			cin >> c;
			bi += pow_mod(2, c - 1);
		}

		for (int j = 0; j < pow_mod(2, 12); j++)
		{
			if (dp[j] == INF) continue;

			dp[j | bi] = min(dp[j | bi], dp[j] + a[i]);
		}
	}

	if (dp[pow_mod(2, n) - 1] == INF)
	{
		cout << -1 << endl;
	}
	else
	{
		cout << dp[pow_mod(2, n) - 1] << endl;
	}

	int www;
	cin >> www;
}


Measured memory_bytes: 384
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define int long long int
#define pb push_back
#define fi first
#define se second
#define fr(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define IO ios :: sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define pii pair<int,int>
const int mod = 1e9 + 7;
const int mod1 = 998244353;
typedef long double f80;
#ifndef LOCAL
#define endl '\n'
#endif
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rand(int l, int r){
    uniform_int_distribution<int> uid(l, r);
    return uid(rng);
}
inline bool cmp(const pii &a, const pii &b){
    return a.fi + a.se < b.fi + b.se;
}
const int N = 5005;
int dp[N];
pii p[N];
void solve(){
    int n;
    cin >> n;
    fr(i, 1, n){
        cin >> p[i].fi >> p[i].se;
    }
    sort(p + 1, p + n + 1, cmp);
    fill(dp + 1, dp + n + 1, 1e18);
    fr(i, 1, n){
        for(int j = i - 1; j >= 0; j--){
            if(dp[j] <= p[i].fi){
                dp[j + 1] = min(dp[j + 1], dp[j] + p[i].se);
            }
        }
    }
    int ans = 0;
    fr(i, 1, n){
        if(dp[i] != 1e18){
            ans = max(ans, i);
        }
    }
    cout << ans;
}

signed main()
{
    IO;
    #ifdef LOCAL
        freopen("inp.txt", "r", stdin);
        // freopen("out.txt", "w", stdout);
    #endif
    clock_t clk = clock();
    int t;
    // cin >> t;
    t = 1;
    fr(i, 1, t){
        solve();
    }
    cerr << endl << setprecision(10) << fixed << (double)(clock() - clk) / CLOCKS_PER_SEC;
    return 0;
}

Measured memory_bytes: 384
using System;
// using System.Collections.Generic;
// using System.Globalization;
// using System.IO;
// using System.Linq;
// using System.Text;
// using System.Text.RegularExpressions

class Program
{
    static void Main()
    {
        string S = Console.ReadLine();
        bool flg = false;
        for (int i = 1; i < S.Length; i++)
        {
            if (S[i - 1] == S[i])
            {
                flg = true;
                break;
            }
        }
        Console.WriteLine(flg ? "Bad" : "Good");
        return;
    }
}

Measured memory_bytes: 25716
#include<iostream>
#include<iomanip>

using namespace std;

int main(){

    char a[3];
    int b=700,c;

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

    for(int i=0;i<3;i++){
        if(a[i]=='o'){
            b+=100;
        }
    }

    cout<<b<<endl;

return 0;
}

Measured memory_bytes: 256
from collections import deque
DVSR = 1000000007
def LI(): return [int(x) for x in input().split()]
H,W=LI()
MP=[input() for _ in range(H)]
MEMO=[[(-1,0)]*W for _ in range(H)]
MEMO[0][0] = (0,1)
QU=deque([])

QU.append((0,0,0))
IT=[(1,0),(0,1)]
while QU:
    i,j,cost = QU.popleft()
    cost+=1
    pat = MEMO[i][j][1]
    for dy, dx in IT:
        ny, nx = i+dy, j+dx
        if ny < H and ny >= 0 and nx < W and nx >= 0 and MP[ny][nx] == '.':
            cost2, pat2 = MEMO[ny][nx]
            if cost2 == -1:
                MEMO[ny][nx] = (cost, pat)
                QU.append((ny,nx,cost))
            elif cost2 == cost:
                _pat = (pat+pat2)%DVSR
                MEMO[ny][nx] = (cost,_pat)

print(MEMO[H-1][W-1][1])

Measured memory_bytes: 88796
import sys
from math import ceil, floor, sqrt, sin, cos, pi
from itertools import accumulate, permutations, combinations
from fractions import gcd # 最大公約数
from collections import deque, Counter
from operator import itemgetter
from heapq import heappop,heappush
sys.setrecursionlimit(10**7)
def lcm(x, y): return ((x * y) // gcd(x, y)) # 最小公倍数
# list(map(int, input().split()))

s = input()
ans = 0
l = len(s)
h = floor(l / 2)
for i in range(h):
    if s[i] != s[l - i - 1]:
        ans += 1
print(ans)

Measured memory_bytes: 5176
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <queue>
#include <set>
#include <map>
#include <stack>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int N,K;
ll V[500];
 
vector<ll> L;
ll sum;
 
 
int main(){
    cin >> N >> K;
    for(int i=0;i<N;i++){
        cin >> V[i];
    }
    int a = min(K,N);
    ll ans = 0;
    for(int i=0;i<a+1;i++){
        for(int j=0;j<a-i+1;j++){
            L={};
            sum=0;
            for(int k=0;k<i;k++){
                L.push_back(V[k]);
                sum+=V[k];
            }
            for(int k=0;k<j;k++){
                L.push_back(V[N-k-1]);
                sum+=V[N-k-1];
            }
            sort(L.begin(),L.end());
            int s = lower_bound(L.begin(),L.end(),0) - L.begin();
            int ss = min(s,K-i-j);
            for(int k=0;k<ss;k++){
                sum -= L[k];
            }
            if(ans<sum){
                ans = sum;
            }
            
        }
        
    }
    
    cout << ans << endl;
    
}
 
 


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define All(a) a.begin(),a.end()
#define INF 1000000007
const int MOD = 1000000007;
//accumulate(vec.begin(), vec.end(), 0)

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

bool isPrime(int n){
  if(n < 2) return false;
  else if(n == 2) return true;
  else if(n%2==0) return false;

  for(int i=3;i<=sqrt(n);i++){
    if(n%i==0) return false;
  }
  return true;
}

int main(){
  string s;
  cin >> s;
  if(s=="SUN") cout<< 7 <<endl;
  else if(s=="MON") cout<< 6 <<endl;
  else if(s=="TUE") cout<< 5 <<endl;
  else if(s=="WED") cout<< 4 <<endl;
  else if(s=="THU") cout<< 3 <<endl;
  else if(s=="FRI") cout<< 2 <<endl;
  else if(s=="SAT") cout<< 1 <<endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.Math;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      	
      	String n = sc.next();
      	boolean con = true;
      
      	for(int i = 0;i < n.length() && con;i++){
          if(n.charAt(i) == '7') con = false;
        }
      
      	if(con) System.out.println("No");
      	else System.out.println("Yes");
        
	}
}


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

const ll MAX = 1000000007;

ll calc(int a, ll b, ll p){
    if (b == 0){
        return 1;
    } else if (b%2 == 0){
        ll d = calc(a, b/2, p);
        return (d*d) % p;
    } else {
        return (a * calc(a, b-1, p)) % p;
    }
}

int main() {
    int X, Y; cin >> X >> Y;
    int P = X+Y;
    if (P%3 != 0 || X*2 < Y || Y*2 < X){
        cout << 0 << endl;
        return 0;
    }

    int c = P/3;
    int x = X - c;
    int y = Y - c;
    int p = x+y;
    ll ans = 1;

    for (int i = 1; i <= p; i++){
        ans *= i;
        ans %= MAX;
    }
    if (x != 0){
        for (int i = 1; i <= x; i++){
            ans *= calc(i, MAX-2, MAX);
            ans %= MAX;
        }
    }
    if (y != 0){
        for (int i = 1; i <= y; i++){
            ans *= calc(i, MAX-2, MAX);
            ans %= MAX;
        }
    }
    
    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
    public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		int[][] moves = new int[h][w];
		int[][] map = new int[h][w];
		for (int i = 0; i < h; i++) {
			String s = sc.next();
			for (int j = 0; j < w; j++) {
				if (s.charAt(j) == '#')
					map[i][j] = 1;
				else
					map[i][j] = 0;
			}
		}

		for(int i=0; i<h; i++){
			int count = 0;
			for(int j=0; j<w; j++){
				if(map[i][j] == 0){
					count++;
					if(j==w-1){
						int k = j;
						while(k>=0 && map[i][k] == 0){
							moves[i][k] = count;
							k--;
						}
					}
				} else {
					int k = j-1;
					while(k>=0 && map[i][k] == 0){
						moves[i][k] = count;
						k--;
					}
					count = 0;
				}
			}
		}

		for(int i=0; i<w; i++){
			int count = 0;
			for(int j=0; j<h; j++){
				if(map[j][i] == 0){
					count++;
					if(j==h-1){
						int k = j;
						while(k>=0 && map[k][i] == 0){
							moves[k][i] += count;
							k--;
						}
					}
				} else {
					int k = j-1;
					while(k>=0 && map[k][i] == 0){
						moves[k][i] += count;
						k--;
					}
					count = 0;
				}
			}
		}
		int ans = 0;
		for(int i=0; i<h; i++){
			for(int j=0; j<w; j++){
				ans = Math.max(ans, moves[i][j]-1);
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 85660
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(ll i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(ll i=(begin);i>(end);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define ISORT(a) sort(a.begin(), a.end(),greater<ll>())
#define REVERSE(a) reverse(a.begin(), a.end())
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=(" <<; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << ")" << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}

#define ll long long
#define f first
#define s second
#define pb push_back
#define INF 1000000000000000000
using namespace std;

using vec = vector<ll>;
using mat = vector<vec>;
using Pii = pair<ll, ll>;
using PiP = pair<ll, Pii>;
using PPi = pair<Pii, ll>;

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

	if (A % 2 == 0 || B % 2 == 0 || C % 2 == 0) cout << 0 << endl;
	else cout << min(min(A * B, B * C), C * A) << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Deque;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	private void run() {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int n = scanner.nextInt();
			if (n == 0)
				break;

			int[][] num = new int[n][3];
			int size = 0;
			for (int i = 0; i < n; i++) {
				int a = scanner.nextInt();
				int b = scanner.nextInt();
				int c = scanner.nextInt();
				num[i][0] = a;
				num[i][1] = b;
				num[i][2] = c;
				size = Math.max(size, Math.max(a, b));
			}
			size++;
			int[][] cost = new int[size][size];
			for (int[] t : cost)
				Arrays.fill(t, 1 << 24);
			for (int i = 0; i < n; i++) {
				int a = num[i][0];
				int b = num[i][1];
				int c = num[i][2];
				cost[a][b] = c;
				cost[b][a] = c;

			}
			for (int i = 0; i < size; i++) {
				cost[i][i] = 0;

			}
			for (int i = 0; i < size; i++) {
				for (int j = 0; j < size; j++) {
					if (i == j)
						continue;
					for (int k = j + 1; k < size; k++) {
						cost[j][k] = cost[k][j] = Math.min(cost[j][k],
								cost[i][j] + cost[i][k]);

					}
				}
			}
			int ans = 0;
			int min = Integer.MAX_VALUE;
			for (int i = 0; i < size; i++) {
				int sum = 0;
				for (int j = 0; j < size; j++) {
					sum += cost[i][j];
				}
				if (sum < min) {
					min = sum;
					ans = i;
				}
			}
			System.out.println(ans + " " + min);
		}

	}

	private void slove(int x, int[][] cost) {
		Deque<Integer> deque = new ArrayDeque<Integer>();
		for (int i = 0; i < cost.length; i++) {
			if (cost[i][x] != 1 << 24) {
				deque.offer(i);
			}
		}
		cost[x][x] = 0;
		while (!deque.isEmpty()) {
			int pri = deque.poll();
			for (int i = 0; i < cost.length; i++) {
				if (pri == i)
					continue;
				if (cost[pri][i] != 1 << 24
						&& cost[x][i] > cost[pri][i] + cost[x][pri]) {
					cost[x][i] = cost[pri][i] + cost[x][pri];
					cost[i][x] = cost[pri][i] + cost[x][pri];
					if (!deque.contains(i))
						deque.offer(i);
				}
			}
		}

	}
}

Measured memory_bytes: 19540
#include <iostream>
#include <string>
using namespace std;
int main(void){
    // Your code here!
    string n;
    cin >> n;
    int sum = 0;
    for (auto i : n) {
        sum += (int)i - 48;
        sum %= 9;
    }
    cout << ((!(sum % 9))?"Yes":"No") << endl;
}

Measured memory_bytes: 3716
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF LLONG_MAX/5
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
int mypow(int a,int b,int c){
	if(b==0)return 1;
	if(b%2)return mypow(a,b-1,c)*a%c;
	int z=mypow(a,b/2,c);
	return z*z%c;
}
signed main(){
	int n;
	cin>>n;
	f(i,n+1){
		if((int)(i*1.08)==n){
			cout<<i<<endl;
			return 0;
		}
	}
	cout<<":("<<endl;
	return 0;
}


Measured memory_bytes: 256
# include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
# define pb push_back
# define pii pair < int, int >
# define F first
# define S second
# pragma GCC optimize("unroll-loops")
# pragma GCC optimize("Ofast")
# define int long long int
# define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
const int N=2e5+100,inf=1e15,mod=998244353 ;

ll a[N];
ll par[N];
map <int,int> mp,vis;
ll f[N];
int32_t main(){
    ll n,k;
    cin >> n >> k;
    for (int i=1;i<=n;i++){
        cin >> a[i];
        a[i]--;
        par[i]=par[i-1]+a[i];
        par[i]%=k;
    //    cout << par[i] << endl;
    }
    ll ans=0;
    mp[0]++;
    for (int i=1;i<=n;i++){
        if (i>=k){
            mp[par[i-k]]--;
        }
        ans+=mp[par[i]];
        mp[par[i]]++;
    }
    cout << ans ;
}


Measured memory_bytes: 15872
#include <bits/stdc++.h>
#define foi(i,k,n) for(int i = (int)k; i < (int)n; ++i)
using namespace std;
typedef long long ll;
const int MOD = 7 + 1000000000;
const int MAXH = 5 + 1000;
int H,W;
int memo[MAXH][MAXH];
char mat[MAXH][MAXH];

int dp(int i, int j) {
    if(i < 0 || j < 0 || (mat[i][j] == '#')) return 0;
    if(i == 0 && j == 0) return 1;
    int& ans = memo[i][j];
    if(ans == -1) {
        ans = (dp(i - 1, j) + dp(i, j - 1)) % MOD;
    }
    return ans;
}

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    cin >> H >> W;
    foi(i,0,H) {
        foi(j,0,W) {
            cin >> mat[i][j];
        }
    }
    memset(memo, -1, sizeof memo);
    cout << dp(H - 1, W - 1) << '\n';
    return 0;
}


Measured memory_bytes: 5248
N = int(input())
S = input()
count_R = 0
count_G = 0
count_B = 0
count = 0
for i in range(N):
    if S[i] == 'R':
        count_R = count_R+1
    elif S[i] == 'G':
        count_G = count_G+1
    else:
        count_B = count_B+1
count = count_R*count_G*count_B

for i in range(N):
  for j in range(i+1,N):
    if S[i] != S[j]:
      k = 2*j-i
      if k>=N:
        break
      else:
        if S[i] != S[k] and S[j] != S[k]:
          count = count-1
print(count)

Measured memory_bytes: 9184
n = int(input())
w = [input() for _ in range(n)]

t = set(w)
if len(w) != len(t):
    print("No")
    exit(0)

for i in range(n-1):
    s0 = w[i]
    s1 = w[i+1]
    if s0[-1] != s1[0]:
        print("No")
        exit(0)

print("Yes")

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

ll gcd(ll a,ll b){
  while(b!=0){
    a%=b;
    swap(a,b);
  }
  return a;
}

int main(){
  int A1,A2,A3;
  cin >> A1 >> A2 >> A3;
  if(A1+A2+A3>=22){
    cout << "bust" << endl;
  }
  else{
    cout << "win" << endl;
  }
}
      
  
  
  

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

int main(){
    bool fundo[10] = {false};
    int value[] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512};

    int weight;
    bool space_need = false;

    while(cin >> weight){
        for(int i=0; i<=9; i++){
            if(weight % 2 == 1){
                fundo[i] = true;
            }
            weight /= 2;
        }

        for(int i=0; i<=9; i++){
            if(fundo[i] == true){
                if(space_need) printf(" ");
                printf("%d", value[i]);
                fundo[i] = false;
                space_need = true;
            }
        }
        cout << endl;
        space_need = false;
    }

    return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <random>
#include <chrono>

using namespace std;

typedef long long ll;
typedef long double ld;
#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

const ll SIZE = 1e5 * 2 + 10, INF = 1e9 + 10, MOD = 1e9 + 7;



int main()
{
    fastInp;

    ll l, r, d;
    cin >> l >> r >> d;

    ll cnt = 0;
    for (int i = l; i <= r; i++) {
        if (i % d == 0) cnt++;
    }

    cout << cnt;

    return 0;
}

Measured memory_bytes: 3608
#include<iostream>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#define ll long long
using namespace std;
int a[100005];
int main()
{
  int n;
  int ans=0;
  scanf("%d",&n);
  for(int i=0;i<n;i++)
  {
  	scanf("%d",&a[i]);
  }
  sort(a,a+n);
  int len=1;
  for(int i=0;i<n;i++)
  {
      if(a[i]==a[i+1])
      {
      	len++;
	  }
	  else
	  {
	  	if(len>a[i])
	  	{
	  	ans+=len-a[i];
		  len=1;	
		  }
	  	
	  	else if(len<a[i])
	  	{
	  	ans+=len;
	  	len=1;
		  }
		  else
		  len=1;
	  
	  }
  }
  printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int n, k;
struct an{
	int a, b;
};
vector<an> ans;
bool comp(an a, an b)
{
	return a.a + a.b < b.a + b.b;
}

int main()
{
	cin >> n >> k;
	if (n % 2 == 1)
    {
        if (2 * k > n + 1)
        {
            cout << -1;
            return 0;
        }
        int x = n / 2;
        for (int i = k; i < k + x + 1; i++)
        {
            ans.push_back({i, i + n + x});
        }
        for (int i = k + x + 1; i < k + n; i++)
        {
            ans.push_back({i, i + n - x - 1});
        }
        sort(ans.begin(), ans.end(), comp);
        for (int i = 0; i < n; i++)
        {
            cout << ans[i].a << " " << ans[i].b << " " << i + k + 2 * n << "\n";
        }
    }
    else
    {
        int x = n / 2;
        if (k <= x)
        {
            for (int i = k; i < k + x; i++)
            {
                ans.push_back({i, i + 3 * x});
            }
            for (int i = k + x; i < k + 2 * x; i++)
            {
                ans.push_back({i, i + x});
            }
            sort(ans.begin(), ans.end(), comp);
            for (int i = 0; i < n; i++)
            {
                cout << ans[i].a << " " << ans[i].b << " " << i + k + 2 * n << "\n";
            }
        }
        else
        {
            cout << -1;
            return 0;
        }
    }
}


Measured memory_bytes: 3188
program b
implicit none
integer n, l, s, i, res, num
integer,allocatable,dimension(:) :: x
read*, n, l
allocate(x(n))
s=n*(2*l+n-1)/2
 do i=1,n
 x(i)=l+i-1
 end do
res=abs(x(1))
num=1 
 do i=1,n
 if(res.gt.abs(x(i))) then
 res=abs(x(i))
 num=i
 end if
 end do
s=s-x(num)
print*, s
end program

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<(n);++i)
#define rep2(i,a,b) for (ll i=(a);i<(b);++i)
#define debug(x) cout << #x << '=' << x << endl
#define all(v) (v).begin(),(v).end()
const ll MOD=1e9+7;
//const ll MOD=998244353;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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;
}

const int MAX_ROW=61; // to be set appropriately
const int MAX_COL=1e5+10; // to be set appropriately

struct BitMatrix {
    int H, W;
    bitset<MAX_COL> val[MAX_ROW];
    BitMatrix(int m = 1, int n = 1) : H(m), W(n) {}
    inline bitset<MAX_COL>& operator [] (int i) {return val[i];}
};

void GaussJordan(BitMatrix &A, bool is_extended = false) {
    vector<bool> used(A.H, 0);
    for (int col = 0; col < A.W; ++col) {
        if (is_extended && col == A.W - 1) break;
        int pivot = -1;
        for (int row = 0; row < A.H; ++row) {
            if (used[row]) continue;
            if (A[row][col]) {
                pivot = row;
                break;
            }
        }
        if (pivot == -1) continue;
        for (int row = 0; row < A.H; ++row) {
            if (row != pivot && A[row][col]) A[row] ^= A[pivot];
        }
        used[pivot] = true;
    }
}

const int MAX_B=61;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    vector<ll> A(N);
    rep(i,N) cin >> A[i];
    vector<int> cnt(MAX_B,0),can(MAX_B,0);
    ll ans=0;
    BitMatrix BM(MAX_B,N+1);
    for (int i=MAX_B-1;i>=0;--i){
        rep(j,N) if (A[j]&(1LL<<i)) ++cnt[i];
        if (cnt[i]&1) ans+=1LL<<i;
        else if (cnt[i]>0){
            can[i]=1;
            rep(j,N) if (A[j]&(1LL<<i)) BM[MAX_B-1-i][j]=1;
            BM[MAX_B-1-i][N]=1;
        }
    }
    GaussJordan(BM,true);
    rep(i,MAX_B){
        if (!can[MAX_B-1-i]) continue;
        int ok=0;
        rep(j,N) if (BM[i][j]==1) ok=1;
        if (BM[i][N]==0) ok=1;;
        if (ok) ans+=(2LL<<(MAX_B-1-i));
    }
    cout << ans << endl;
}

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

max1 = 0
max2 = 0

tmp = 0

for i in range(n):
    A = int(input())
    if A > max1 :
        max1 = A
        tmp = i
    elif A > max2:
        max2 = A

for i in range(tmp):
    print(max1)

print(max2)

for i in range(n-tmp-1):
    print(max1)


Measured memory_bytes: 4540
using System.Linq;
using System.Collections.Generic;
using System;

public class P
{
    public int p { get; set; }
    public int id { get; set; }
}

public class hello
{
    public static void Main()
    {
        while (true)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var n = int.Parse(line[0]);
            var L = int.Parse(line[1]);
            if (n == 0 && L == 0) break;
            var input = new int[n, 2];
            var maxd = -1; var maxmod = 0; var maxt = 0;
            for (int i = 0; i < n; i++)
            {
                line = Console.ReadLine().Trim().Split(' ');
                var outd = line[0] == "L" ? 1 : 0;
                var p = int.Parse(line[1]);
                input[i, 0] = outd;
                input[i, 1] = p;
                var wt = outd == 1 ? p : L - p;
                var wmod = p % 2;
                if (wt > maxt | (wt == maxt && outd > maxd))
                { maxd = outd; maxt = wt; maxmod = wmod; }
            }
            var a = new List<P>();
            var count1 = 0;
            for (int i = 0; i < n; i++)
            {
                if (input[i, 1] % 2 == maxmod)
                {
                    a.Add(new P { id = i, p = input[i, 1] });
                    if (input[i, 0] == 1) count1++;
                }
            }
            if (maxd == 1) count1--;
            var ans = a.OrderBy(x => x.p).Select(x => x.id).ToArray();
            Console.WriteLine("{0} {1}", maxt, ans[count1] + 1);
        }
    }
}



Measured memory_bytes: 18496
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main(){
    int N, K;
    cin >> N >> K;
    vector<int> h(N);

    for(int i=0; i<N; i++) cin >> h[i];

    sort(h.begin(), h.end());
    int m = h[K-1]- h[0];

    int tmp;
    for(int i=1; i<=N-K; i++){
        tmp = h[i+K-1] - h[i];
        if(tmp < m) m = tmp;
    }

    cout << m << endl;
    return 0;
}

Measured memory_bytes: 640
#152_B
a, b = map(int, input().split())

s1 = ''
for i in range(a):
    s1 = s1 + str(b)

s2 = ''
for i in range(b):
    s2 = s2 + str(a)

if s1 < s2:
    print(s1)
else:
    print(s2)

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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)
#define In(vec) rep(i, n) cin>>vec[i];
#define ANS(s) cout << s << endl
#define inc(a, b) cin >> a >> b;

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int> >;
using vii = vector<pair<int, int> >;

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 a, ll b) { return b ? GCD(b, a % b) : a; }
int round_int(int a, int b) { return (a + (b - 1)) / b; }


// 4,8方向に探索する際に用いる配列
int dx[4] = { 0,  0, 1, -1 };
int dy[4] = { 1, -1, 0,  0 };
//int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
//int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

constexpr auto MAX = 100010;

// ────────────────────────────────────────────────────

class position {
public:
	ii pos;
	int depth;

	position(ii pos, int depth) : pos(pos), depth(depth) {};
};

bool check[51][51] = { false };

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

	rep(i, h) cin >> t[i];

	int cnt = 0;
	rep(i, h) {
		rep(j, w) {
			if (t[i][j] == '.') ++cnt;
		}
	}


	queue<position> q;
	q.push(position(make_pair(0, 0), 0));
	check[0][0] = true;

	int dep = -1;
	while (!q.empty()) {
		position a = q.front(); q.pop();
		int y = a.pos.first;
		int x = a.pos.second;
		int d = a.depth;


		if (y == h - 1 && x == w - 1) {
			dep = d;
			break;
		}


		rep(i, 4) {
			int ty = y + dy[i];
			int tx = x + dx[i];

			if (0 <= tx && tx < w && 0 <= ty && ty < h && t[ty][tx] != '#' && check[ty][tx] == false) {
				q.push(position(make_pair(ty, tx), d + 1));
				check[ty][tx] = true;
			}
		}
	}
	//cout << cnt << endl;
	if (dep == -1) cout << -1 << endl;
	else cout << (cnt - 1) - dep << endl;
}

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

using namespace std;

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

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const int MOD = 998244353;
const int N = (int)2e5 + 10;

int powr(int a, int k){ 
  if(k == 0)
    return 1;
  int p = powr(a, k/2);
  p = (p * 1ll * p) % MOD;
  if(k % 2 == 1) p = (p * 1ll * a) % MOD;
  return p;
}

int fac[N];

int ncr(int n, int k){
  int r = fac[n];
  r=(r*1ll*powr(fac[k],MOD-2))%MOD;
  r=(r*1ll*powr(fac[n-k],MOD-2))%MOD;
  return r;
}

int main(){
  fastIO;
  fac[0]=1;
  for(int i = 1; i < N ; i ++ )
    fac[i]=(fac[i-1]*1ll*i)%MOD;
  int n, m, k;
  cin >> n >> m >> k;
  int ans = 0;
  int cur;
  for(int i = 0 ; i <= k ; i ++ ){
    cur = ncr(n - 1, i);
    cur = (cur * 1ll * m) % MOD;
    cur = (cur * 1ll * powr(m - 1, n - 1 - i)) % MOD;
    ans = (ans + cur) % MOD;
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 4472
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
using namespace std;
using ll = long long;
//const ll MOD = (ll)1e9+7;
const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

#ifdef DEBUG
#define OUTPUT(x) (output(x), output("\n"))
#else
#define OUTPUT(x) (void)0
#endif

ll modpow(ll x, ll b){
	ll res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

ll modinv(ll x){
	return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t a){
	if(was_output)cout << " ";
	cout << a;
	was_output = true;
}
void outendl(){
	was_output = false;
	cout << endl;
}

int main(){
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << (a != c) << endl;
	return 0;
}


Measured memory_bytes: 256
import sys
N,M=map(int, sys.stdin.readline().split())
ll=float("-inf")
rr=float("inf")
for _ in range(M):
    l,r=map(int, sys.stdin.readline().split())
    ll=max(ll,l)
    rr=min(rr,r)

if ll<=rr:
    print rr-ll+1
else:
    print 0

Measured memory_bytes: 33640
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline
N, M = map(int, input().split())
node = [0]*(N+1)
for _ in range(M):
    a, b = map(lambda x: int(x)-1, input().split())
    node[a] += 1
    node[b] += 1

if all(x % 2 == 0 for x in node):
    print("YES")
else:
    print("NO")


Measured memory_bytes: 3828
def search(N):
    ans = False
    if not N >= 90:
        for i in range(1,10):
            if N%i == 0 and 1 <= N // i <= 9:
                ans = True
                break
            else:
                pass        
    return ans

N = int(input())
if search(N):
    print("Yes")
else:
    print("No")



Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int INF = 1000000000;
const long INF64 = 9223372036854775807;
const int MOD = 1000000007;

int main(){
	string s;
	std::cin >> s;
	int le=s.size();
	bool han=1;
	rep(i,le){
		if(i%2==0&&s[i]=='L')han=0;
		if(i%2==1&&s[i]=='R')han=0;
		
	}
	if(han)std::cout << " Yes" << std::endl;
	else std::cout << "No" << std::endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second

using namespace std;
typedef long long int64;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int64 x;
	cin >> x;
	vector<pair<int64, int>> a;
	a.emplace_back(0, 0);
	for (int64 i = 1; i <= 1000; ++ i) {
		int64 x = i * i * i * i * i;
		a.emplace_back(x, i);
		a.emplace_back(- x, - i);
	}
	sort(a.begin(), a.end());
	for (int i = 0; i < a.size(); ++ i) {
		for (int j = 0; j < a.size(); ++ j) {
			if (a[i].F - a[j].F == x) {
				cout << a[i].S << ' ' << a[j].S;
				return 0; 
			}
		}
	}
}

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



int hassh[27];

double eps=0.0000000000000000001;

int main() {

    ios::sync_with_stdio(0);
    string s;
    cin>>s;
    string pre="";
    string suf="";

    int q;
    cin>>q;

    bool rev=false;

    for(int i=1;i<=q;i++){
        int typ;
        int f;
        char ch2;
        cin>>typ;
        if(typ==1){
            if(rev==true){
                rev=false;
            }
            else{
                rev=true;
            }
        }
        else{
            cin>>f>>ch2;
            if(f==1){
                if(rev==false){
                    pre=pre+ch2;
                }
                else{
                    suf=suf+ch2;
                }
            }
            else{
                if(rev==true){
                    pre=pre+ch2;
                }
                else{
                    suf=suf+ch2;
                }
            }
        }
    }

    if(rev==false){
        reverse(pre.begin(),pre.end());
        cout<<pre<<s<<suf;
    }
    else{
        reverse(suf.begin(),suf.end());
        reverse(s.begin(),s.end());
        cout<<suf<<s<<pre;
    }

    

    return 0;
}

Measured memory_bytes: 1424
#include<iostream>
    using namespace std;
    int main()
    {
      int x;
      std::cin >> x;
      if (x<1200) {
        std::cout << "ABC" << '\n';
        /* code */
      }

      else{
        std::cout << "ARC" << '\n';
      }
        return 0;
      }


Measured memory_bytes: 256
using AtCoderBeginnerContest139.Questions;
using AtCoderBeginnerContest139.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace AtCoderBeginnerContest139.Questions
{
    public class QuestionC : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            var n = inputStream.ReadInt();
            var h = inputStream.ReadIntArray();

            var steps = 0;
            var maxSteps = 0;

            for (int i = 0; i < h.Length - 1; i++)
            {
                if (h[i] >= h[i + 1])
                {
                    maxSteps = Math.Max(maxSteps, ++steps);
                }
                else
                {
                    steps = 0;
                }
            }

            yield return maxSteps;
        }
    }
}


namespace AtCoderBeginnerContest139
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionC();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace AtCoderBeginnerContest139.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace AtCoderBeginnerContest139.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

Measured memory_bytes: 24156
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;


int main(){
  ll N, M;
  cin >> N >> M;
  vector<ll> a;
  for(int i=1; i*i<=M; i++){
    if(!(M%i)){
      a.push_back(i);
      a.push_back((M/i));
    }
  }
  sort(a.begin(), a.end());
  a.erase(unique(a.begin(), a.end()), a.end());
  auto ans = upper_bound(a.begin(), a.end(), (M/N));
  ans--;
  cout << *ans << endl;
  
}


Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
x = int(input())


ans = 0
for i in range(0,500*a+1,500):
    for j in range(0,100*b+1,100):
        if (x-i-j)%50 == 0 and x-i-j >= 0 and (x-i-j)//50 <= c:
            ans += 1
print(ans)

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

void _126() {
    string s;
    cin >> s;
    int first = atoi(s.substr(0, 2).c_str());
    int second = atoi(s.substr(2, 2).c_str());

    if (first > 0 && first <= 12 && second > 0 && second <= 12)
        cout << "AMBIGUOUS" << endl;
    else if (first > 0 && first <= 12)
        cout << "MMYY" << endl;
    else if (second > 0 && second <= 12)
        cout << "YYMM" << endl;
    else
        cout << "NA" << endl;
}

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



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

typedef long long ll;
#define repd(i,a,b) for (ll i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)

ll mod=1e9+7;

using namespace std;


ll inputValue(){
	ll a;
	cin >> a;
	return a;
};

void inputArray(int * p, ll a){
	rep(i, a){
		cin >> p[i];
	}
};

template<typename T>
void inputVector(vector<T>& p, ll a){
	rep(i, a){
		T input;
		cin >> input;
		p.emplace_back(input);
	}
}


template <typename T>
void output(T a) {
	cout << a << "\n";
}



int main(int argc, const char * argv[]) {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
  string s;
  cin >> s;
  string r_sub(s);
  reverse(r_sub.begin(),r_sub.end());
  if ( s != r_sub) {
    cout << "No" << endl;
    return 0;
  }
  string f_sub=s.substr(0,s.size()/2);
  string fr_sub(f_sub);
  reverse(fr_sub.begin(),fr_sub.end());
  if ( f_sub != fr_sub){
    cout << "No" << endl;
    return 0;
  }
  string b_sub=s.substr((s.size()+1)/2,s.size());
  string br_sub(b_sub);
  reverse(br_sub.begin(),br_sub.end());
  if ( b_sub != br_sub ){
    cout << "No" << endl;
    return 0;
  }

  cout << "Yes" << endl;

  return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
using namespace std;
const int max_n= 10000;
int n,W,L,kk,m,V,e,r,ML, MD, E, v, H;
const int INF = 1e9+1;
const int mod = 1e9 + 7;
bool used[max_n][max_n];
string s1,s2;
int x[max_n],y[max_n],table[max_n][max_n],d[max_n][max_n],ppar[max_n],rrank[max_n],spf[max_n],a[max_n],b[max_n],c[max_n];
typedef pair<long , long> pii;
vector<long long> G[max_n];
vector<int> ls;
vector<pair<int, int> > edgee[max_n];
struct edge{
    int from,to,cost;
};
bool comp(const edge& e1, const edge& e2){
    return e1.cost < e2.cost;   
}
edge es[max_n];
typedef pair<int, int> P;
struct Cmp{
    bool operator()(const pii &a,const pii &b){
        return a.second > b.second;
    }
};
void warshall_floyd(){
    for(int k=0 ; k<n ; k++){
         for(int i=0 ; i<n ; i++){
              for(int j=0 ; j<n ; j++){
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
}
void solve(){
    warshall_floyd();
    long long count = 0;
    for(int i=0 ; i<m ; i++){
        if(c[i] > d[a[i]][b[i]])    count++;
    }
    cout << count << endl;
}
int main(){
    cin >> n >> m;
    for(int i=0 ; i<n ; i++){
        for(int j=0 ; j<n ; j++){
            d[i][j] = INF;
            if(i == j)  d[i][j] = 0;       
        }
    }
    for(int i=0 ; i<m ; i++){
           cin >> a[i] >> b[i] >> c[i];
            --a[i]; --b[i];
            d[a[i]][b[i]] = d[b[i]][a[i]] = c[i];
        
    }
    solve();
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << endl; exit(0); }
inline void no() { cout << "No" << endl; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { x = max(x, y); }
template <typename T> inline void amin(T &x, T y) { x = min(x, y); }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

struct UnionFind {
  vector<int> data;
  UnionFind(int n) {
    data.assign(n, -1);
  }
  int root(int k) {
    if (data[k] < 0) return k;
    return data[k] = root(data[k]);
  }
  bool unite(int x, int y) {
    x = root(x), y = root(y);
    if (x == y) return false;
    if (data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return true;
  }
  int size(int k) {
    return -data[root(k)];
  }
};

void solve() {
  int N, K, L;
  cin >> N >> K >> L;
  UnionFind kuf(N), luf(N);
  rep(i, K) {
    int x, y;
    cin >> x >> y;
    x--, y--;
    kuf.unite(x, y);
  }
  rep(i, L) {
    int x, y;
    cin >> x >> y;
    x--, y--;
    luf.unite(x, y);
  }
  map<pair<int, int>, vi32> mp;
  rep(i, N) {
    mp[make_pair(kuf.root(i), luf.root(i))].emplace_back(i);
  }
  vi32 ans(N);
  each(m, mp) {
    each(v, m.second) {
      ans[v] = m.second.size();
    }
  }
  cout << ans << endl;
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int A[3];
  for (int i = 0; i < 3; i++) {
    cin >> A[i];
  }
  sort(A, A + 3);
  cout << (A[2] - A[1]) + (A[1] - A[0]) << '\n';
  return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
s = list(map(int, input().split()))
t = list(map(int, input().split()))
mod = 10**9 + 7

dp = [[1] * (m+1) for _ in range(n+1)]

for i in range(n):
    for j in range(m):
        dp[i+1][j+1] = dp[i][j+1] + dp[i+1][j] - dp[i][j]
        dp[i+1][j+1] %= mod
        if s[i] == t[j]:
            dp[i+1][j+1] += dp[i][j]
            dp[i+1][j+1] %= mod

print(dp[n][m])


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

using namespace std;

int main()
{
    long long n,a,b;
    cin >> n;
    for(a=sqrt(n);a>0;a--)
    {
        if(n/a==n*1.0/a)
        {
            b=n/a;
            break;
        }
    }
    cout << b+a-2 << endl;
    return 0;
}


Measured memory_bytes: 256