akhauriyash/Code-Regression huggingface dataset:
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

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

	string s;
	
	cin >> s;
	int a[4];

	rep(i, 4)
	{
		a[i] = s[i] - '0'; 
	}

	int sum = 0;
	for(int i=0; i < 2;i++)
	{
		sum = a[0];

		if (i & 0x01)
		{
			sum += a[1];
		}
		else
		{
			sum -= a[1];
		}

		for(int j = 0; j < 2; j++)
		{
			int bj_sum = sum;
			if (j & 0x01)
			{
				sum += a[2];
			}
			else
			{
				sum -= a[2];
			}

			for (int k = 0; k < 2; k++)
			{
				int back_sum = sum;
				if (k & 0x01)
				{
					sum += a[3];
				}
				else
				{
					sum -= a[3];
				}

				if (sum == 7)
				{
					cout << a[0] << ((i == 1) ? '+' : '-') << a[1] << ((j == 1) ? '+' : '-') << a[2] << ((k == 1) ? '+' : '-') << a[3] << "=7" << endl;
					return 0;
				}
				sum = back_sum;
				
			}
			sum = bj_sum;
		}
	}

	
	return 0;
}


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

int n;
int p[101], q[101], r[101], b[101];
bool parent_check[101];
int parent;

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

int solve(int bar)
{
  int heavy_r = r[bar] ? solve(r[bar]) : 1;
  int heavy_b = b[bar] ? solve(b[bar]) : 1;

  int moment_r = heavy_r * p[bar];
  int moment_b = heavy_b * q[bar];
  
  int gcd_moment = gcd(moment_r, moment_b);
  moment_r /= gcd_moment;
  moment_b /= gcd_moment;

  heavy_r *= moment_b;
  heavy_b *= moment_r;

  return heavy_r + heavy_b;
}

void main_b()
{
  memset(parent_check, false, sizeof parent_check);
  
  for(int i = 1; i <= n; i++){
    int _p, _q, _r, _b;
    cin >> _p >> _q >> _r >> _b;
    
    int gcd_long = gcd(_p, _q);
    p[i] = _p / gcd_long;
    q[i] = _q / gcd_long;
    r[i] = _r;
    b[i] = _b;
    
    parent_check[_r] = parent_check[_b] = true;
  }

  for(int i = 1; i <= n; i++)
    if(!parent_check[i])
      parent = i;

  cout << solve(parent) << endl;
  return;
}

int main()
{
  while(cin >> n && n)
    main_b();
  return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
//#define int long long
#define mod 1000000007
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
#define mp make_pair
using namespace std;
int get() { int r; cin >> r; return r; }
int n, m, key, p;
int t[60][60], nm[30][60];
vector<int>v[60];
bool b[60];
int f(char ch) {
	if (ch == '0')return 0;
	if (ch == '1')return 1;
	if (ch == '2')return 2;
	if (ch == '3')return 3;
	if (ch == '4')return 4;
	if (ch == '5')return 5;
	if (ch == '6')return 6;
	if (ch == '7')return 7;
	if (ch == '8')return 8;
	if (ch == '9')return 9;
}
signed main() {
	char c1, c2; cin >> c1 >> c2;
	string a, b;
	for1(i, f(c1))a += c2;
	for1(i, f(c2))b += c1;
	cout << min(a, b) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
#define mod1 998244353
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long int li;
typedef unsigned long long int ull;
using namespace std;
bool sortbysec(const pair<li,li>&a,const pair<li,li>&b)
{
    return (a.second<b.second);
}
li mpow(li x,li y)
{
  li ans=1;
  while(y)
  {
    if(y%2!=0)
    ans=((ans%mod)*(x%mod))%mod;
    y/=2;
    x=((x%mod)*(x%mod))%mod;
  }
  return ans;
}
int main()
{
fast_io
li n,a,b;
cin>>n>>a>>b;
li x=n/(a+b);
li rem=n%(a+b);
if(rem>a)
rem=a;
cout<<x*a+rem;

  return  0;
}


Measured memory_bytes: 256
/* Atcoder abc171a
 * See tasks at: https://atcoder.jp/contests/abc171/tasks/abc171_a
 */
#include <bits/stdc++.h>

#define until(symbol, max) for (int symbol = 0; (symbol) < (max); (symbol)++)

using namespace std;
using ll = long long;
int main()
{
    char c;
    cin >> c;

    if ('A' <= c && c <= 'Z')
    {
        cout << "A";
    }
    else
    {
        cout << "a";
    }
    return 0;
}


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

using namespace std;

const int N = 1e5+5;

int n;
int a[N], b[N], c[N];
int dp[N][4];

int main(){

    cin >> n;

    for(int i=1;i<=n;i++){
        cin >> a[i] >> b[i] >> c[i];
    }

    dp[1][1] = a[1];
    dp[1][2] = b[1];
    dp[1][3] = c[1];

    for(int i=2;i<=n;i++){
        dp[i][1] = max(dp[i-1][2]+a[i] , dp[i-1][3]+a[i]);
        dp[i][2] = max(dp[i-1][1]+b[i] , dp[i-1][3]+b[i]);
        dp[i][3] = max(dp[i-1][2]+c[i] , dp[i-1][1]+c[i]);
    }
    cout << max(dp[n][1],max(dp[n][2],dp[n][3])) << "\n";

    return 0;
}


Measured memory_bytes: 2944
N = int(input())

ac = 0
wa = 0
tle = 0
re = 0

for i in range(N):
  S = input()
  if(S == "AC"):
    ac += 1
  elif(S == "WA"):
    wa += 1
  elif(S == "TLE"):
    tle += 1
  else:
    re += 1
 
print("AC x",ac)
print("WA x ",wa)
print("TLE x",tle)
print("RE x",re)



Measured memory_bytes: 9204
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    string s;
    cin >> s;
    int i;
    for(i = s.length()-2;i >= 0;i-=2){
        if(s.substr(0,i/2) == s.substr(i/2,i/2)){
            break;
        }
    }
    cout << i << endl;
    return 0;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main(int argc, char *argv[]) {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    int X, A; cin >> X >> A;
    cout << (X < A ? 0 : 10) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int num,total=0;
    scanf("%d",&num);

    while(num){
        total = total + num%10;
        num = num/10;
    }
    if(total==1)
        printf("10");
    else
        printf("%d",total);
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int array[100];
int main()
{
    int n,tmp;
    int i,j,k=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
        {
           scanf("%d",&array[i]);
        }

    for (i = 0; i < n - 1; i++){
    for (j = n - 1; j >= i ; j--){   
      if (array[j] < array[j-1]) { 
      		tmp=array[j-1];
            array[j-1]=array[j];
            array[j]=tmp;
              k++;
      }
    }
  }
        printf("%d",array[0]);
        for(i=1;i<n;i++){
            printf(" %d",array[i]);
        }
        printf("\n%d\n",k);
    
    return 0;
}



Measured memory_bytes: 2036
def digit_sum(n):
    res = 0
    while n > 0:
        res += n % 10
        n //= 10
    return res


n, a, b = map(int, input().split())

res = 0
for i in range(1, n + 1):
    if a <= digit_sum(i) <= b:
        res += i
print(res)

Measured memory_bytes: 3060
# -*- coding: utf-8 -*-


# 入力を整数に変換して受け取る
def input_int():
    return int(input())


# マイナス1した値を返却
def int1(x):
    return int(x) - 1


# 半角スペース区切り入力をIntに変換してMapで受け取る
def input_to_int_map():
    return map(int, input().split())


# 半角スペース区切り入力をIntに変換して受け取る
def input_to_int_tuple():
    return tuple(map(int, input().split()))


# 半角スペース区切り入力をIntに変換してマイナス1した値を受け取る
def input_to_int_tuple_minus1():
    return tuple(map(int1, input().split()))


def main():
    a, b = input().split()

    from decimal import Decimal

    import math
    return math.floor(Decimal(a) * Decimal(b))

if __name__ == "__main__":
    print(main())


Measured memory_bytes: 10084
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <random>
#include <string.h>
#include <cmath>
#include <unordered_map>
#include <cstdio>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long ll;

ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}
ll kai(ll x, ll y, ll m) {
	ll res = 1;
	for (ll i = x - y + 1; i <= x; i++) {
		res *= i; res %= m;
	}
	return res;
}
ll mod_pow(ll x, ll y, ll m) {
	ll res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

ll comb(ll x, ll y, ll m) {
	if (y > x)return 0;
	return kai(x, y, m) * mod_pow(kai(y, y, m), m - 2, m) % m;
}

int n;
int ans[100010];

signed main() {
	cin >> n;
	for (int i = 1; i <= 100; i++)for (int j = 1; j <= 100; j++)for (int k = 1; k <= 100; k++)ans[i*i + j * j + k * k + i * j + j * k + i * k]++;
	for (int i = 1; i <= n; i++)cout << ans[i] << endl;
}


Measured memory_bytes: 3864
#include <bits/stdc++.h>
using namespace std;
#define int                     long long int
#define ld                      long double
#define pb                      push_back
#define MOD                     998244353
#define inf                     3e18
#define vi                      vector<int>
#define vld                     vector<ld>
#define pii                     pair<int,int>
#define mii                     map<int,int>
#define fi                      first
#define se                      second
#define fastIO                  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << " "<< name << " : " << arg1 <<'\n'; }
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...);
}

void inp_out()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
    #endif
}

int bin_exp(int b,int e)
{
	if(e==0)	
		return 1;
	int a=bin_exp(b,e/2);
	if(e&1)	
		return a*a*b;
	else 
		return a*a;
}

int powm(int x,int y,int m=MOD) 
{
	x=x%m;
	int res=1;
	while(y)
	{
		if(y&1)
			res=res*x;
		res%=m;
		y=y>>1;
		x=x*x;
		x%=m;
	}
	return res;
}

int modInverse(int a,int m=MOD)
{
	return powm(a,m-2,m);
}


int dp[3005][3005];
int n;
vi a;
int fa=0;

int cal(int pos,int s)
{
	if(pos==-1)
	{
	//	if(s==0)
	//		return 1;

		return 0;
	}

	if(dp[pos][s]!=-1)
		return dp[pos][s];

	int &ans=dp[pos][s];

//	db(pos,s);
	

	int v1=cal(pos-1,s);

	int v2=0,v3=0;

	if(s>=a[pos])
		v2=cal(pos-1,s-a[pos]);

	if(s-a[pos]==0)
	{
		v3=powm(2,pos);
	}

	ans=((v1*2+v2)+v3)%MOD;

//	db(pos,s,ans);
	return ans;

}

int32_t main()
{
	fastIO
	inp_out();
	int s;
	cin>>n>>s;
	memset(dp,-1,sizeof(dp));
	a=vi(n);
	for(int i=0;i<n;++i)
		cin>>a[i];

	cout<<cal(n-1,s);



	return 0;
}

Measured memory_bytes: 74312
// Contest: AtCoder Beginner Contest 179 (https://atcoder.jp/contests/abc179)
// Problem: A: Plural Form (https://atcoder.jp/contests/abc179/tasks/abc179_a)


// region boilerplate
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <chrono>
#include <cstdint>
#include <deque>
#include <exception>
#include <forward_list>
#include <functional>
#include <initializer_list>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#if __cplusplus >= 201703L
#   include <optional>
#   include <string_view>
#   include <variant>
#endif

using namespace std;

#if __cplusplus >= 201703L
#   define all(a)      begin(a),end(a)
#   define sz(x)       ((int)size(x))
#else
#   define all(a)      (a).begin(),(a).end()
#   define sz(x)       ((int)(x).size())
#endif

#define rep(a, b)      for(int a = 0; a < (b); ++a)
#define reps(a, b, c)  for(int a = (b); a < (c); ++a)
#define trav(a, b)     for(auto& a : b)

using ll = long long;
using ld = long double;
using u64 = uint64_t;
using u32 = uint32_t;

using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vpi = vector<pi>;

#if __cplusplus >= 201703L
#   define MAYBE_UNUSED [[maybe_unused]]
#else
#   define MAYBE_UNUSED
#endif

MAYBE_UNUSED static constexpr int INF = (int)1e9 + 5;
MAYBE_UNUSED static constexpr ll INFL = (ll)1e18 + 5;
MAYBE_UNUSED static mt19937 rng((u32)chrono::duration_cast<chrono::nanoseconds>(chrono::high_resolution_clock::now().time_since_epoch()).count());
//endregion

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

    string s; cin >> s;
    if (s.back() == 's')
        s += "es";
    else
        s += "s";
    cout << s << '\n';

    return 0;
}


Measured memory_bytes: 3668
#include <bits/stdc++.h>
#define repi(i, a, b) for (int i = (int)(a) ; i < (int)(b) ; i++)
#define rep(i, n) repi(i, 0, n)
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
// using P = pair<int, int>;
struct Vec{
    double x, y;
};
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;
}
using namespace std;

const int mod = 1000000007;
class mint {
public:
    long long x;
    mint(long long x=0) : x((x%mod+mod)%mod) {}
    mint operator-() const { 
      return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res/=a;
    }

    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x;
        return os;
    }
};

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    // cout << fixed << setprecision(15);
    int n;
    mint s = 0;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) {
        cin >> a[i];
        s += a[i];
    }
    mint ans = 0;
    rep(i, n - 1){
        s -= a[i];
        mint ar = (a[i] * s.x);
        ans += ar;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4788
def two_int():
    N, K = map(int, input().split())
    return N,K

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))

N=one_int()

if N%2==0:
    print(N//2 -1)
else:
    print(N//2)

Measured memory_bytes: 3060
a, b, c, d = gets.split(" ").map(&:to_i)
cnt = 0

while true
  cnt += 1
  if cnt.odd?
    c -= b
    if c <= 0
      puts "Yes"
      exit
    end
  else
    a -= d
    if a <= 0
      puts "No"
      exit
    end
  end
end

Measured memory_bytes: 14400
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<ctime>
#include<cstdio>
#include<string>
//#include<string>
//#include<sstream>
using namespace std;
int main()
{
	int n;
	scanf("%d",&n);
	int sum=2;
	if(sum>n) printf("1\n");
	else
	while(1){
		if(sum>n){
			printf("%d\n",sum/2);
			break;
		}
		sum=sum*2;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> ab(n);
  vector<pair<int, int>> cd(m);
  rep(i, n){
    int a, b;
    cin >> a >> b;
    ab.at(i) = make_pair(a, b);
  }
  rep(i, m){
    int c, d;
    cin >> c >> d;
    cd.at(i) = make_pair(c, d);
  }
  rep(i, n){
    int mn = 1001001001, ans = -1;
    auto now = ab.at(i);
    rep(j, m){
      auto add = cd.at(j);
      if(abs(now.first - add.first) + abs(now.second - add.second) < mn){
        mn = abs(now.first - add.first) + abs(now.second - add.second);
        ans = j;
      }
    }
    cout << ans+1 << endl;
  }
  return 0;
}

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

int main(){
  int a,b,c,d,e,k;
  cin >> a >> b >> c >> d >> e >> k;
  if(b - a <= k && c - a <= k && d - a <= k && e - a <= k
    && c - b <= k && d - b <= k && e - b <= k && d - c <= k
    && e - c <= k && e - d <= k){
      cout << "Yay!" << endl;
  }
  else{
    cout << ":(" << endl;
  }
}


Measured memory_bytes: 256
import sys  # sys.exit()を使いたいので

n = int(input())
a = list(map(int, input().split()))

if 0 in a:
# 0が1つでもあれば0です
    print(0)
else:
# 0がない場合
    cur = 1  # 現在の数値
    for x in a:
        cur *= x
        if cur > 10 ** 18:
        # 10**18を超えたので終了します
            print(-1)
            sys.exit()
    print(cur)  # 10**18以下なので、出力します

Measured memory_bytes: 21476
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
typedef long long ll;
int solve(int a[],int n,int k,int p,int dp[]) { 
  if(k<0)
  return p;
  if(dp[k]==0)
  return p;
  if(dp[k]==1)
  return p^1;
  for(int i=0;i<n;i++){
  	int so=solve(a,n,k-a[i],p^1,dp);
  	if(so==p){
  	dp[k]=0;
  	return p;
  	}
  }
  dp[k]=1;
  return p^1;
} 
  
   
int main(){
  int n,k;
  cin>>n>>k;
  int a[n];
  for(int i=0;i<n;i++)
  cin>>a[i];
  int dp[k+1];
  memset(dp,-1,sizeof(dp));
  int so=solve(a,n,k,0,dp);
  if(so==0)
  cout<<"First\n";
  else
  cout<<"Second\n";
  return 0;
}

Measured memory_bytes: 9984
N=int(input())
*V,=map(int,input().split())
import collections

c1=collections.Counter(V[0::2]).most_common()
c2=collections.Counter(V[1::2]).most_common()
c1.append([0,0])
c2.append([0,0])
if c1[0][0]!=c2[0][0]:
    print(N-c1[0][1]-c2[0][1])
else:
    print(min(N-c1[0][1]-c2[1][1],N-c1[1][1]-c2[0][1]))

Measured memory_bytes: 25196
n=int(input())
p=list(map(int,input().split()))
ans=0
for i in range(1,n-1):
    if p[i-1]<p[i]<p[i+1] or p[i+1]<p[i]<p[i-1]:
        ans+=1
    else :
        ans+=0
print(ans)

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

int main()
{
    int n,x,m,mn=100005;
    cin>>n>>x;

    long long sum=0,ans=n;
    while(n--){
        cin>>m;
        sum=sum+m;
        mn=min(mn,m);
    }
    ans+=(x-sum)/mn;
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vl vector<ll>
#define vul vector<ull>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi2d vector<vi >
#define vl2d vector<vl >
#define vpll vector<pll >

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rz resize
#define fr(i,n) for(i=0;i<(n);i++)
#define frr(i,n) for(i=(n-1);i>=0;i--)
#define fre(i,n) for(i=0;i<=(n);i++)
#define frre(i,n) for (i=(n);i>=0;i--)
#define frab(i,a,b) for(i=(a);i<(b);i++)
#define freab(i,a,b) for(i=(a);i<=(b);i++)
#define frrab(i,a,b) for(i=(b-1);i>=a;i--)
#define frreab(i,a,b) for(i=(b);i>=a;i--)

#define sz(a) int((a).size())
#define mset(a,b) (memset(a,b,sizeof(a)))
#define max3(a,b,c) (max((a),max((b),(c))))
#define min3(a,b,c) (min((c),min((a),(b))))
#define sumv(v) accumulate(all(v),ll(0))
#define productv(v) accumulate(all(v), ll(1), multiplies< ll >())
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
vector <ll> sprime;
vector<char> prime (1000000, true);
void sieve(ll n)
{
  //O(nloglogn) time
  sprime.pb(0);
  prime[0] = prime[1] = false;
  ll cnt = 0;
  for (ll i = 2; i <= n; ++i)
  {
    if (prime[i])
    {
      cnt++;
      sprime.pb(i);
      for (ll j = 2 * i; j <= n; j += i)
        prime[j] = false;
    }
  }
}
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll fastpowMOD(ll a, ll p, ll MOD) { if (p == 0) return 1; ll z = fastpowMOD(a, p / 2, MOD); z = (z * z) % MOD; if (p % 2) z = (z * a) % MOD; return z; }
ll fastpow(ll a, ll p) { if (p == 0) return 1; ll z = fastpow(a, p / 2); z = (z * z); if (p % 2) z = (z * a); return z; }

#define mod 1000000007
#define inf LLONG_MAX
#define minf LLONG_MIN
#define pi 3.14
#define ex 2.71

//*********************************************///
const int N = 1e5 + 5;
int i,j;
ll a[N];
ll dp[N];
void solve()
{
  int n,k;
  cin>>n>>k;
  freab(i,1,n)
    cin>>a[i];
  fr(i,n+5)
    dp[i]=1e16;
  dp[0]=dp[1]=0;
   a[0]=a[1];
  freab(i,2,n)
    freab(j,1,k)
    {
      if(i-j<=0)
        break;
      dp[i]=min(dp[i],dp[i-j]+abs(a[i]-a[i-j]));
    }
  cout<<dp[n]<<endl;
}

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


Measured memory_bytes: 2816
import java.util.Scanner;

public class Main{
    public static void main(String args[]){
        Scanner input = new Scanner(System.in);
        String word = input.nextLine();
        String pattern = input.nextLine();
        word += word;
        if(word.contains(pattern))
            System.out.println("Yes");
        else
            System.out.println("No");
    }
}


Measured memory_bytes: 26252
use std::io;

fn main() {
    let mut n = String::new();
    io::stdin().read_line(&mut n).ok();
    let n: u32 = n.trim().parse().unwrap();
    let mut a = String::new();
    io::stdin().read_line(&mut a).ok();
    let a: u32 = a.trim().parse().unwrap();
    println!("{}", n*n-a);
}


Measured memory_bytes: 4352
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int k = sc.nextInt();
		UnionFind uf = new UnionFind(n);
		int[] friend = new int[n];
		for (int i = 0; i < m; i++) {
			int a = sc.nextInt()-1;
			int b = sc.nextInt()-1;
			uf.unite(a, b);
			friend[a]++;
			friend[b]++;
		}
		int[][] hate = new int[k][2];
		for (int i = 0; i < k; i++) {
			int a = sc.nextInt()-1;
			int b = sc.nextInt()-1;
			hate[i][0] = a;
			hate[i][1] = b;
		}
		int[] ans = new int[n];
		for (int i = 0; i < n; i++) {
			ans[i] = uf.amount(i)-friend[i];
		}
		for (int i = 0; i < k; i++) {
			if(uf.same(hate[i][0],hate[i][1])) {
				ans[hate[i][0]]--;
				ans[hate[i][1]]--;
			}
		}
		for (int i = 0; i < n; i++) {
			System.out.printf("%d ",ans[i]-1);
		}sc.close();
	}	public static void print(int[][] array) {
		for (int i = 0; i < array.length; i++) {
			System.out.println(Arrays.toString(array[i]));
		}
	}
	public static class UnionFind {
		int par[]; int rank[]; int size[]; int count;
		public UnionFind(int n) {
			this.par = new int[n];
			this.rank = new int[n];
			this.size = new int[n];
			this.count = n;
			for(int i = 0; i < n; i++) {
				par[i] = i; rank[i] = 0; size[i] = 1;
			}
		}
		int find(int x) {//xの属する集合の根を探す
			if(par[x] == x) return x;
			else return par[x] = find(par[x]);
		}
		void unite(int x, int y) {//x,yの集合を合併
			x = find(x);
			y = find(y);
			if(x == y) return ;
			if(rank[x] < rank[y]) {
				par[x] = y;
				size[y] += size[x];
			}else {
				par[y] = x;
				size[x] += size[y];
				if(rank[x] == rank[y]) {
					rank[x]++;
				}
			}
			count--;
		}
		boolean same(int x, int y) {//x,yが同じ集合に属するか
			return find(x) == find(y);
		}
		int amount(int x) {//xの属する集合の要素数
			return size[find(x)];
		}
		int count() {//集合の数
			return count;
		}
	}
}

Measured memory_bytes: 162448
// D - Islands War
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rp(i,s,e) for(int i=(s);i<(e);++i)
using II = pair<int,int>;
using VII = vector<II>;

int solve(int N, int M, VII &V){
	sort(all(V));
	int ans = 0;
	int L = 0, R = 0;
	rp(i, 0, M){
		int l,r; tie(r,l) = V[i];
		if(l>=R){ L = l, R = r; ans++; }
	}
	return ans;
}

int main(){
	int N,M; cin>>N>>M;
	VII V;
	rp(i, 0, M){
		int a,b; cin>>a>>b;
		V.emplace_back(b,a);
	}
	cout<< solve(N,M,V) <<endl;
}

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

int main(){
    int n;

    while(cin >> n, n != 0){
        vector<int> s;
        for(int i=1; i<=n; i++){
            int tmp;
            cin >> tmp;
            s.push_back(tmp);
        }
        sort(s.begin(), s.end());


        s.at(0) = 0;
        s.at(s.size()-1) = 0;

        vector<int>::iterator it = s.begin();
        int sum = 0;
        while(it != s.end()){
            sum += *it;
            it++;
        }
        cout << sum / (s.size()-2) << endl;
    }
    return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
#include<math.h>
int main(void){
  
  int i;
  int N;
  scanf("%d",&N);
  
  int A=0;
  
  for(i=0;i<10;i++){
    if((N>=pow(2,i))&&(N<pow(2,i+1))){
      A=i;
    }
    else{}
  }
  
  printf("%d\n",(int)pow(2,A));
  
  return 0;
}
    
    
  

Measured memory_bytes: 2488
#include<iostream>
#include<algorithm>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main(){
    int a,b,c;
    cin >>a >> b >> c;
    cout << (a+b >= c ? "Yes" : "No" )<< endl;
    
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
  int n,ans=0;
  string s;
  cin>>n>>s;
  for(int i=0;i<n-2;++i){
    if(s.at(i)=='A'&&s.at(i+1)=='B'&&s.at(i+2)=='C')
      ++ans;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		final Scanner scanner = new Scanner(System.in);
		scanner.nextLine();
		final char[] hats = scanner.nextLine().toCharArray();
		int r = 0;
		
		for(int i = 0;i<hats.length;i++) {
			if(hats[i] == 'R') {
				r ++;
			}
		}
		
		if(r * 2 > hats.length) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
		
		scanner.close();

	}

}

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

int main(){
  string s, t;
  cin >> s >> t;
  
  for(int i = 0; i < t.size(); i++){
    cout << s[i] << t[i];
  }
  if(s.size() > t.size()){
    cout << s[s.size()-1] << endl;
  }
  else {
    cout << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ii pair<int,int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>
#define debug cout << "Ok" << endl;

using namespace std;

void solve(){

	return;
}
 
int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	
	vector<long long int>v(110,0);
	long long int resp=1000000000;
	int n,aux;
	cin >> n;

	while(n--){
		cin >> aux;
		for(int i=1;i<101;i++){
			v[i] += (aux-i) * (aux-i);
		}
	}

	for(int i=1;i<101;i++){
		resp = min(resp, v[i]);
	}

	cout << resp << endl;
	return 0;
}

Measured memory_bytes: 256
S = input()

if S == "SUN":
    print(7)

elif S == "MON":
    print(6)

elif S == "TUE":
    print(5)

elif S == "WED":
    print(4)

elif S == "THU":
    print(3)

elif S == "FRI":
    print(2)

else:
    print(1)



Measured memory_bytes: 2940
#include<iostream>

using namespace std;

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


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

int main() {
  int D;
  cin >> D;
  cout << "Christmas";
  for(int i=25; i > D; i--)
    cout << " Eve";
  return 0;
}

Measured memory_bytes: 256
"use strict"
 
function Main(input) {
  input = input.trim().split('\n');
  const N = Number(input[0]);
  const H = input[1].trim().split(' ').map(Number);

  let ret = 0;
  let move = 0;
  let tmp = H[0]
  for(let i=0; i<N; i++){
    if (tmp >= H[i+1]) {
      move += 1;
    } else {
      ret = Math.max(ret, move);
      move = 0;
    }
    tmp = H[i+1];
  }

  console.log(ret);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 17816
n,k=map(int,input().split())
a=[(2*k+1)*[0]for _ in range(2*k+1)]
for _ in range(n):
  x,y,c=input().split()
  x=int(x)
  y=int(y)
  if c=="B":y+=k
  x%=2*k
  y%=2*k
  a[x+1][y+1]+=1
ans=0
for i in range(1,2*k+1):
  for j in range(1,2*k+1):a[i][j]+=a[i-1][j]+a[i][j-1]-a[i-1][j-1]
for i in range(k,2*k+1):
  for j in range(k,2*k+1):
    t=a[i][j]-a[i-k][j]-a[i][j-k]+a[i-k][j-k]
    t+=a[i-k][j-k]
    t+=a[2*k][j-k]-a[i][j-k]
    t+=a[i-k][2*k]-a[i-k][j]
    t+=a[2*k][2*k]-a[i][2*k]-a[2*k][j]+a[i][j]
    ans=max(ans,t,n-t)
print(ans)

Measured memory_bytes: 106996
import java.util.*;
import java.math.*;
import java.lang.String;
import java.lang.System;
import java.lang.reflect.Array;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		String[] sArr = s.split("");
		String[] arr = new String[s.length()];
		Arrays.fill(arr, "");
		int[] count = new int[s.length()];
		Arrays.fill(count, 0);
		boolean ok = true;
		
		for (int i = 0; i < s.length(); i++) {
			if (i == 0) {
				arr[i] = sArr[i];
				count[i]++;
			} else {
				boolean check = false;
				int J = 0;
				loop1: for (int j = 0; j < i; j++) {
					if (arr[j].equals(sArr[i])) {
						check = true;
						J = j;
						break loop1;
					}
				}
				if (check) {
					count[J]++;
				} else {
					count[i]++;
					arr[i] = sArr[i];
				}
			}
		}
		for (int i = 0; i < s.length(); i++) {
			if (!(count[i] % 2 == 0 || count[i] == 0)) {
				ok = false;
				break;
			}
		}
		if (ok) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	
	
	}
}


Measured memory_bytes: 9680
#include<stdio.h>
int main()
{
  int X,A,B,a,b,c,d;
  scanf("%d%d%d",&X,&A,&B);
  a=X-A;
  b=a/B;
  c=B*b;
  d=a-c;
  printf("%d",d);
  return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <queue>

using namespace std;

#define int long long

signed main() {
	int N;
	int T[1000] = {}, A[1000] = {};

	cin >> N;
	int a, b;
	a = 1;
	b = 1;
	for (int i = 0; i < N; i++) {
		int x, y;
		cin >> x >> y;

		int c1 = (a + x - 1) / x;
		int c2 = (b + y - 1) / y;
		int c = max(c1, c2);
		a = x * c;
		b = y * c;
	}
	
	cout << a + b << endl;

	return 0;

}



Measured memory_bytes: 256
import fractions

A, B = map(int, input().split())

# A, B の正の公約数から互いに素となる組み合わせを選ぶとき、最大でいくつ選べる？
# 最大公約数を求める
gcd = fractions.gcd(A, B)


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


# 最大公約数を素因数分解する
f = factorization(gcd)
# 1のケースのみ1を出力する
if f == [[1, 1]]:
    print(1)
else:
    # 要素数＋１が選択可能な個数
    ans = len(f) + 1
    print(ans)

Measured memory_bytes: 5092
import sys
input=sys.stdin.readline

def main():
    N = int(input())
    P = []
    for _ in range(N):
        P.append(int(input()))

    # Q[i]: P[i] から左を見たとき、1ずつ増加して昇順にある要素の数
    Q = [0]*(N+1)
    for p in P:
        Q[p] = Q[p-1] + 1 # p-1 だけを見ればよい

    print(N-max(Q))

if __name__ == '__main__':
    main()


Measured memory_bytes: 18884
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair< int, int >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)
using namespace std;
void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int dp[509][509];
int C[509][509];
int recurr(int i,int j){
  if(dp[i][j]!=-1) return dp[i][j];
  if(i==j) return dp[i][j]=C[i][j]; 
  // number of line segements b/w i & j = line segement from i to j and line segments b/w i to j-1
  // and line segments b/w i+1 to j - line segments included in both(i to j-1, i+1 to j) range i.e i+1 to j-1
  return dp[i][j]=C[i][j]+recurr(i,j-1)+recurr(i+1,j)-recurr(i+1,j-1);
}
void  solve(){
  int n,m,Q,l,r;
  cin>>n>>m>>Q;
  rep(i,0,m){
    cin>>l>>r;
    C[l][r]++;
  }
  rep(i,1,n+1) rep(j,1,n+1) dp[i][j]=-1;

  recurr(1,n);

  rep(i,0,Q){
    cin>>l>>r;
    cout<<dp[l][r]<<endl;
  }
}
void solve1(){
  int n,m,Q,p,q,l,r;
  cin>>n>>m>>Q;
  vector<vector<int>> dp(n+1,vector<int>(n+1,0));
  rep(i,0,m){
    cin>>l>>r;
    dp[l][r]++;
  }
  rep(i,1,n+1) rep(j,1,n+1)dp[i][j]+=dp[i][j-1];
  rep(i,1,n+1) rep(j,1,n+1)dp[i][j]+=dp[i-1][j];
  rep(i,0,Q){
    cin>>p>>q;
    cout<<dp[q][q]+dp[p-1][p-1]-dp[p-1][q]-dp[q][p-1]<<endl;
  }
}
int main(){
    optimizeIO();
    solve();
    // solve1();
}


Measured memory_bytes: 5700
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
#include <functional>
#include <unordered_map>
#include <map>
#include <iomanip>
#include <sstream>

using namespace std;

#define int long long


long long subCount(vector<int> arr, int n, int k)
{

	unordered_map<int, int> mod;

	int cumSum = 0;
	for (int i = 0; i < n; i++) {
		cumSum += arr[i];

		mod[((cumSum % k) + k) % k]++;
	}

	int result = 0;

	for (auto const& x: mod)
	{
			if (x.second > 1)
			{
				result += (x.second * (x.second - 1)) / 2;
			}
		
	}

	if (mod.count(0))
	{
		result += mod[0];
	}

	return result;
}

signed main()
{
	int n;
	cin >> n;

	int k;
	cin >> k;

	vector<int> arr;

	for (int i = 0; i < n; i++)
	{
		int t;
		cin >> t;
		arr.push_back(t);
	}

	cout << subCount(arr, n, k) << "\n";
	return 0;
}

Measured memory_bytes: 5236
public class Main {

  private static void solve() {
    int n = ni();
    int m = ni();
    int[] s = na(n);
    int[] t = na(m);
    int mod = (int) 1e9 + 7;
    long[][] dp = new long[n + 1][m + 1];
    dp[0][0] = 1;
    for (int i = 0; i <= n; i++) {
      for (int j = 0; j <= m; j++) {
        if (i == 0 && j == 0)
          continue;


        if (i > 0) {
          dp[i][j] += dp[i - 1][j];
        }
        if (j > 0) {
          dp[i][j] += dp[i][j - 1];
        }

        if (i > 0 && j > 0 && s[i - 1] != t[j - 1]) {
          dp[i][j] += mod - dp[i - 1][j - 1];

        }
        dp[i][j] %= mod;
      }
    }
    System.out.println(dp[n][m]);
  }



  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}



Measured memory_bytes: 81236
gets
s=gets.strip
t=gets.strip
n,m=s.size,t.size
(puts"-1";exit)if s[0]!=t[0]
e=n.lcm m
h={}
n.times{|i|h[i*e/n]=s[i]}
m.times{|i|w=h[i*e/m]
next if w.nil?||w==t[i]
puts"-1"
exit}
puts e

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

int main(){
  int N;
  cin >> N;
  vector<int> B(N-1);
  for(int i=0; i<N-1; i++){
    cin >> B.at(i);
  }

  vector<int> A(N);
  A.at(0) = B.at(0);
  for(int i=0; i<N-2; i++){
    A.at(i+1) = min(B.at(i), B.at(i+1));
  }
  A.at(N-1) = B.at(N-2);

  int sum;
  for(int a : A){
    sum += a;
  }
  
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#define ll long long
using namespace std;
int main()
{
  ios_base::sync_with_stdio(0);
  string str1,str2,str3;
  cin >> str1 >> str2 >> str3;
  int p=0,q=0;
  if(str1[str1.length()-1]==str2[0])
    p=1;
  if(str2[str2.length()-1]==str3[0])
    q=1;
  if(p==1 && q==1)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}


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

#define ll long long

int main() {
  ll X;
  cin >> X;
  
  ll a = 100;
  
  int ans = 0;
  while(a < X) {
    a *= 1.01;
    ans++;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define fi first
#define se second
using namespace std;
int main()
{
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++)
        printf("%c",s[i]=='1'?'9':'1');
    return 0;
}



Measured memory_bytes: 256
from operator import itemgetter

N = int(input())

AB = []

for i in range(N):
    A, B = map(int, input().split())
    AB.append((A, B))

AB = sorted(AB, key=itemgetter(1))

t = 0
ans = 'Yes'
for A, B in AB:
    if t + A > B:
        ans = 'No'
        break
    else: t += A
    
print(ans)

Measured memory_bytes: 33428
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

#############
# Main Code #
#############

N, M = getNM()
dist = [[] for i in range(N)]
for i in range(M):
    l, r, d = getNM()
    dist[l - 1].append([r - 1, d])
    dist[r - 1].append([l - 1, -d])

dis = [float('inf')] * N

pos = deque([i for i in range(N)])
while len(pos) > 0:
    u = pos.popleft()
    # 始めの第一歩
    if dis[u] == float('inf'):
        dis[u] = 0
    # 行き先の位置が未確定なら確定させる
    # 既に確定しているなら判定
    for to, d in dist[u]:
        if dis[to] == float('inf'):
            dis[to] = dis[u] + d
            # 位置をレコードした頂点を優先的に処理する必要があるためappendleft
            # 例 que = [0, 2, 1], [1, 2, 3]
            # pos = [0, 1, 2] の時
            # dis = [0, -2, 1]でYesになるはず
            # 0を探索, 1の距離をレコードしてappend disは[0, inf, 1]
            # pos = [1, 2, 2]のため次は1を探索
            # dis[1] == infなのでdis[1] = 0にする
            # dis[1] = 0, dis[2] = 1なのでNo
            pos.appendleft(to)
        else:
            if dis[u] + d != dis[to]:
                print('No')
                exit()
print('Yes')

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

int main() {
  int a,b,k;
  cin >> a >> b >> k;
  
  int i=min(a,b),cnt=0;
  while(cnt<k) {
    if (a%i==0&&b%i==0) {
      cnt++;
    }
    i--;
  }

  i++;
  cout << i << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, b) for (ll i = (a); i < (b); ++i)

using namespace std;
using ll = long long;

static const ll MAX_N = 2 * 1e3;
static const ll INFTY = 2 * 1e3;
static const ll WHITE = 0;
static const ll GRAY = 1;
static const ll BLACK = 2;

ll N, X, Y;
vector<pair<ll, ll>> adj[MAX_N];
vector<ll> ans(MAX_N + 1, 0);

void dijkstra (ll from) {
  priority_queue<pair<ll, ll>> PQ;
  ll color[MAX_N];
  ll d[MAX_N];

  REP(i, 0, N) {
    d[i] = INFTY;
    color[i] = WHITE;
  }

  d[from] = 0;
  PQ.push(make_pair(0, from));
  color[from] = GRAY;

  while (!PQ.empty()) {
    pair<ll, ll> f = PQ.top(); PQ.pop();
    ll u = f.second;

    color[u] = BLACK;

    if (d[u] < f.first * (-1)) continue;

    for (ll j = 0; j < (ll)adj[u].size(); j++) {
      ll v = adj[u][j].first;

      if (color[v] == BLACK) continue;
      if (d[v] > d[u] + adj[u][j].second) {
        d[v] = d[u] + adj[u][j].second;
        PQ.push(make_pair(d[v] * -1, v));
        color[v] = GRAY;
      }
    }
  }

  REP(i, 0, N) {
#ifdef DEBUG
    // printf("%lld -> %lld: %lld\n", from, i, d[i]);
#endif
    ans.at(d[i])++;
  }
}

/**
 * main
 */
int main () {
  cin >> N;
  cin >> X;
  cin >> Y;

  REP(i, 0, N) {
    if (i + 1 <= N - 1) adj[i].push_back(make_pair(i + 1, 1));
    if (i - 1 >= 0) adj[i].push_back(make_pair(i - 1, 1));
    if (i == X - 1) adj[i].push_back(make_pair(Y - 1, 1));
    if (i == Y - 1) adj[i].push_back(make_pair(X - 1, 1));
  }

  REP(i, 0, N) {
    dijkstra(i);
  }

  for (ll i = 1; i <= N - 1; i++) {
    cout << (ans.at(i) / 2) << endl;
  }
}


Measured memory_bytes: 384
# coding: utf-8
X=int(input())

def bin_isOK(index,key):
    if index*(index+1)//2 >= key:
        return True
    else:
        return False


def binary_search(key):
    ng = -1
    ok = 10**9

    while abs(ok - ng) >1:
        mid = (ok + ng)//2

        if bin_isOK(mid,key):
            ok = mid
        else:
            ng = mid
    
    return ok

ans=binary_search(X)
print(ans)


Measured memory_bytes: 2940
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();

    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a: u32 = read();
    let b: u32 = read();
    let ans = if (a * b) % 2 == 0 { "Even" } else { "Odd" };

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


Measured memory_bytes: 2060
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int sx = sc.nextInt();
        int sy = sc.nextInt();
        int tx = sc.nextInt();
        int ty = sc.nextInt();

        int dx = tx - sx;
        int dy = ty - sy;

        char[] pathThere = new char[dx + dy];
        for (int i = 0; i < dx; i++) {
            pathThere[i] = 'R';
        }
        for (int i = 0; i < dy; i++) {
            pathThere[dx + i] = 'U';
        }

        char[] pathBack = new char[dx + dy];
        for (int i = 0; i < dx; i++) {
            pathBack[i] = 'L';
        }
        for (int i = 0; i < dy; i++) {
            pathBack[dx + i] = 'D';
        }

        StringBuilder sb = new StringBuilder();
        sb.append(pathThere);                              // first time there
        sb.append(pathBack);                               // first time back
        sb.append("DR").append(pathThere).append("UL");    // second time there
        sb.append("UL").append(pathBack).append("DR");     // second time there
        System.out.println(sb.toString());

    }
}


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

vector<ll> sieve(1000005,0);
vector<ll> fsctor(ll n)
{
	vector<ll> res;
	while(n>1)
	{
		res.push_back(sieve[n]);
		n /= sieve[n];
	}
	return res;
}
int main()
{
	int n;
	cin >> n;
	iota(sieve.begin(),sieve.end(),0);
	for(ll i = 2;i*i<1000005;i++)
	{
		if(sieve[i]<i)continue;
		for(ll j = i*i;j<1000005;j+=i)if(sieve[j]==j)sieve[j]=i;
	}

	vector<ll> a(n);
	for(auto &i:a)cin >> i;
	vector<map<int,int>> vm(n);
	vector<vector<ll>>a_primes(n);
	bool isparwize = true;
	for(int i = 0;i<n;i++)
	{
		auto now = fsctor(a[i]);
		now.erase(unique(now.begin(),now.end()),now.end());
		a_primes[i]=now;
		
		for(auto j:now)
		{
			vm[0][j]++;
			if(vm[0][j]>1)
			{
				isparwize = false;
			}
		}
		
	}
	vector<ll> prime;
	if(isparwize)
	{
		cout<<"pairwise coprime"<<endl;
		return 0;
	}
	ll GCD = a[0];
	for(int i = 0;i<n;i++)
	{
		GCD = __gcd(GCD,a[i]);
	}
		if(GCD==1)cout<<"setwise coprime"<<endl;
		else cout<<"not coprime"<<endl;
	

}


Measured memory_bytes: 138396