akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric> 
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	int A[n + 1];
	int min_n = INF, sum = 0;
	for(int i = 0; i < n; i++)
	{
		cin >> A[i];
		if(A[i] % 10 != 0)
		{
			min_n = min(A[i], min_n);
		}
		sum += A[i];
	}
	if(min_n == INF)
	{
		if(sum % 10 == 0) cout << 0 << endl;
		else cout << sum << endl;
	}
	else
	{
		if(sum % 10 == 0) cout << sum - min_n << endl;
		else cout << sum << endl;
	}
	return 0;
}



Measured memory_bytes: 256
/**
 *       Author:  kulubat
 *       Written on Tuesday, 14 April 2020.
 **/

#include <bits/stdc++.h>


using namespace std;


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int N, L;
    cin >> N >> L;
    vector<string> A(N);
    string ans;

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

    sort(A.begin(), A.end());

    for(auto a: A)
        ans += a;


    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define SORT(v) sort(v.begin(),v.end())
#define fori(i,a,b) for(ll i=a;i<b;i++)
#define M 1000000007
#define deb(x) cout<< #x << " " << x << endl;

double pi=3.14159265358979323846;

typedef pair<int,int> pii;
typedef pair<long long int, long long int>pll;
typedef vector<int>vi;
typedef vector<long long int>vl;
#define MAXN 10000001
 

int main ()
{
    ll T;
   T=1;
   //cin>>T;
    while(T--)
    {	
   string s,t;
   cin>>s>>t;
   int m=s.length(),n=t.length();
   vector<vector<int>>dp(m+1,vector<int>(n+1));
   for(int i=0;i<=m;i++){
   	for(int j=0;j<=n;j++){
   		if(i==0||j==0)dp[i][j]=0;
   		else if(s[i-1]==t[j-1]){
   			dp[i][j]=1+dp[i-1][j-1];
   		}
   		else{
   			dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
   		}
   	}
   }
   int i=m,j=n,l=dp[m][n];
  // deb(l)
   
   string ans="";
   while(i>=1&&j>=1){
   	if(s[i-1]==t[j-1]){
   		ans+=s[i-1];
   		i--;j--;
   	}
   	else{
   		if(dp[i-1][j]>=dp[i][j-1]){
   			i--;
   		}
   		else{j--;}
   	}
   }
   reverse(ans.begin(),ans.end());
   cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 38576
/*
   Creator - Glitched
   Yeet!!
*/
#include "bits/stdc++.h"

using namespace std;

#define testcases ll T;cin>>T;while(T--)
#define ll long long
#define loop(i,x,n) for(ll i=x;i<n;i++)
#define loopr(i,x,n) for(ll i=n-1;i>=x;i--)
#define ff first
#define ss second
#define pb push_back
#define elif else if
#define flush cout<<"\n"
#define mod 1E9+7
#define L LONG_MAX
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
const string yes = "Yes", no = "No";
// vector<bad()ool> v(1E5, false);

int main()
{
    deque<char> s;
    string temp;cin>>temp;

    loop(i,0,temp.size()){
        char var = temp[i];
        s.pb(var);
    }

    ll rev = 0;
    testcases{
        ll x,y;

        cin>>x;

        if(x==1){
            rev++;
        }
        else{
            char a;
            cin>>y>>a;
            if(rev%2==0){
                if(y==1){
                    s.push_front(a);
                }
                else
                    s.push_back(a);
            }
            else{
                if(y==1){
                    s.push_back(a);
                }
                else
                    s.push_front(a);
            }
        }
    }
    if(rev%2==1){
        loopr(i,0,s.size())cout<<s[i];
    }
    else{
        loop(i,0,s.size())cout<<s[i];
    }
    // cout<<s;

}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#include<iostream>
#include <string>
#include <typeinfo>
using namespace std;
 
int main() {
    int a,b;
    cin >> a >> b;
    if(a % 2 != 0 && b%2 != 0)cout << "Yes";
    else cout << "No";
    

} 


Measured memory_bytes: 3628
from heapq import heappop, heappush
N, M = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(M)]

edges = [[] for _ in range(N)]
for u, v, c in X:
    edges[u - 1].append((v - 1, c))
    
for i in range(N - 1):
    edges[i + 1].append((i, 0))

INF = float("inf")
d = [INF] * N
d[0] = 0

pq = []
heappush(pq, (0, 0))

while len(pq) > 0:
    cost, u = heappop(pq)
    for v, c in edges[u]:            
        if d[v] > d[u] + c:
            d[v] = d[u] + c
            heappush(pq, (d[v], v))
            
print(d[-1] if d[-1] != INF else -1)



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

int main()
{
  int n, x;
  ll ans = 0;
  cin >> n >> x;
  vector<ll> a(n);
  for (int i = 0; i < n; i++)
  {
    cin >> a.at(i);
  }

  if (a.at(0) > x)
  {
    ans += a.at(0) - x;
    a.at(0) = x;
  }

  for (int i = 1; i < n; i++)
  {
    if (a.at(i - 1) + a.at(i) > x)
    {
      ans += a.at(i - 1) + a.at(i) - x;
      a.at(i) -= a.at(i) - x + a.at(i - 1);
    }
  }
  cout << ans << endl;
}


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

using namespace std;

typedef long long ll;

int x, y, z;
int boxes[3];
int main()
{
    
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);

    cin >> x >> y >> z;

 
    boxes[0] = x;
    boxes[1] = y;
    boxes[2] = z;

    swap(boxes[0], boxes[1]);
    swap(boxes[0], boxes[2]);

    cout << boxes[0] << " " << boxes[1] << " " << boxes[2] << endl;

    
    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <map>
#include <cmath>
#include <string>
using namespace std;

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


ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll c, ll d) { return c / gcd(c, d) * d; }

int main() {
  string s;
  cin >> s;
  rep(i, s.size()){
      s[i] = 'x';
  }
  cout << s << endl;
}

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

int main(){
  int n, k, r, s, p;
  string t;
  cin >> n >> k >> r >> s >> p >> t;
  int ans = 0;
  for(int i=0; i<k; ++i){
    if(t[i] == 'r') ans += p;
    if(t[i] == 's') ans += r;
    if(t[i] == 'p') ans += s;
    for(int j=i+k; j<n; j += k){
      if(t[j] == t[j-k]) t[j] = 'z';
      if(t[j] == 'r') ans += p;
      if(t[j] == 's') ans += r;
      if(t[j] == 'p') ans += s;
    }
  }
  cout << ans << endl;
}

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

int main() {
  int X, N;
  cin >> X >> N;
  vector<int> p(N);
  for (int i = 0; i < N; ++i) {
    cin >> p[i];
  }

  bool num[201] = {};
  for (int i = 0; i < N; ++i) {
    num[p[i]] = true;
  }

  int min_abs = 101, ans = 0;
  for (int i = 0; i <= 200; ++i) {
    if (!num[i] && abs(i - X) < min_abs) {
      min_abs = abs(i - X);
      ans = i;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 3572
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>

using namespace std;

int main()
{
  int N;
  vector<int> A;

  cin >> N;
  int tmp;
  for(int i = 0; i < N; i++) {
    cin>>tmp;
    A.push_back(tmp);
  }

  int a = 0; int b = 0;
  for(int i = 0; i < N; i++) {
    if(A[i] % 2 == 0) a++;
    else b++;
  }

  if(a == 0) cout << pow(3, N) - 1 << endl;
  else {
    cout << pow(3, N) - pow(2, a) << endl;
  }

  return 0;
}


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

#define ll long long

void exgcd(int a, int b, int& x, int& y) {
	if (!b) {
		x = 1, y = 0;
	} else {
		exgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
}

int inv(int a, int n) {
	int x, y;
	exgcd(a, n, x, y);
	return (x < 0) ? (x + n) : (x);
}

const int Mod = 998244353;

template <const int Mod = :: Mod>
class Z {
	public:
		int v;

		Z() : v(0) {	}
		Z(int x) : v(x){	}
		Z(ll x) : v(x % Mod) {	}

		Z operator + (Z b) {
			int x;
			return Z(((x = v + b.v) >= Mod) ? (x - Mod) : (x));
		}
		Z operator - (Z b) {
			int x;
			return Z(((x = v - b.v) < 0) ? (x + Mod) : (x));
		}
		Z operator * (Z b) {
			return Z(v * 1ll * b.v);
		}
		Z operator ~() {
			return inv(v, Mod);
		}
		Z operator - () {
			return Z(0) - *this;
		}
		Z& operator += (Z b) {
			return *this = *this + b;
		}
		Z& operator -= (Z b) {
			return *this = *this - b;
		}
		Z& operator *= (Z b) {
			return *this = *this * b;
		}
};

Z<> qpow(Z<> a, int p) {
	Z<> rt = Z<>(1), pa = a;
	for ( ; p; p >>= 1, pa = pa * pa) {
		if (p & 1) {
			rt = rt * pa;
		}
	}
	return rt;
}

typedef Z<> Zi;


const int N = 2e5 + 5;
const int V = 1e6 + 5;

int n;
Zi f[V];
Zi Inv[V];

int main() {
	int m = 0;
	scanf("%d", &n);
	Zi ans = 0;
	for (int i = 1, x; i <= n; i++) {
		scanf("%d", &x);
		f[x] += x;
		ans -= x;
		m = max(m, x);
	}
	for (int i = 1; i <= m; i++) {
		for (int j = i + i; j <= m; j += i) {
			f[i] += f[j];
		} 
	}
	for (int i = 1; i <= m; i++) {
		f[i] = f[i] * f[i];
	}
	for (int i = m; i; i--) {
		for (int j = i + i; j <= m; j += i) {
			f[i] -= f[j];
		}
	}
	Inv[1] = 1;
	for (int i = 2; i <= m; i++) {
		Inv[i] = (-Inv[Mod % i] * (Mod / i));
	}
	for (int i = 1; i <= m; i++) {
		if (f[i].v) {
			ans = ans + f[i] * Inv[i];
		}
	}
	ans = ans * ((Mod + 1) >> 1);
	printf("%d\n", ans.v);
	return 0;
}


Measured memory_bytes: 8064
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
typedef long long int ll;
#define forn for(int i=0;i<n;i++) 
#define kek cout<<"\n"
#define press_F_to_pay_respect ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn for(int i=0;i<n;i++) 
#define form for(int j=0;j<n;j++) 
#define fora(i,a,b) for(int i = a; i < (b); i++)
#define pb push_back 
#define pob pop_back()
#define mp make_pair 
#define sc second 
#define f first 
#define all(v) ((v).begin()), ((v).end()) 
#define pob pop_back() 
#define halt {cout<<-1; return 0;}
const ll MOD = 1e9 + 7;
const int N = 200005;
const ll INF = 1e8;
const ll MOD1=998244353;
using namespace std;
bool comp(string a, string b)
{
          return a.size()<b.size();
}
int main()
{
#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
  press_F_to_pay_respect;
 // string al="abcdefghijklmnopqrstuvwxyz";
int n;
cin>>n;
ll ans=0;
for(int i=1;i<=n;i++)
{
    if(i%3==0 || i%5==0) continue;
    ans+=i;
}
cout<<ans;
 
 
 
 return 0;
 
 
 
  

}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#include <vector>
#include <cmath>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP2(i, m, n) for (int i = (m); i < (int)(n); ++i)
#define REPR(i, n) for (int i = (n)-1; i >= 0; --i)
#define REPR2(i, m, n) for (int i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a) sort(ALL(a), greater<int>())
#define REVERSE(a) reverse(ALL(a))
#define bit_search(bit, n) REP(bit, 1<<(n))
#define bit_check(bit, i) (bit>>(i)) & 1
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REP(i, a.size()) cin >> a[i];
#define INPUTP(a) REP(i, a.size()) cin >> a[i].first >> a[i].second;
#define ENDL cout << endl;
using namespace std;
using LL = long long;
using LD = long double;
using PII = pair<int, int>;
using VPII = vector<PII>;
using PLL = pair<LL, LL>;
using VPLL = vector<PLL>;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VC = vector<char>;
using VS = vector<string>;
using VB = vector<bool>;
const int INF = 1e9;
const LL MOD = 1e9 + 7;

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

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  LL k, a, b;
  cin >> k >> a >> b;
  LL ans, dif = b-a;
  if (dif <= 2) ans = k+1;
  else
  {
    ans = a;
    k -= a-1;
    if (k < 0) ans = k;
    else
    {
      LL ch = k / 2;
      ans += dif * ch;
      ans += k % 2;
    }
  }
  cout << ans << endl;

  return 0;
}

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

int H,A[MAX+1];

int left(int a){
  return 2*a;
}

int right(int a){
  return 2*a+1;
}

void maxHeapify(int *A,int i){
  int l = left(i);
  int r = right(i);
  int largest;
  // 左の子、自分、右の子で値が最大のノードを選ぶ
  if (l <= H && A[l] > A[i]) largest = l;
  else largest = i;
  if (r <= H && A[r] > A[largest]) largest = r;
  if (largest != i){
    swap(A[i],A[largest]);
    maxHeapify(A, largest);
  }// 再帰的に呼び出し
}

void buildMaxHeap(int *A){
  for (int i = H/2;i >= 1;i--) maxHeapify(A, i);
}

int main(){
  int i;

  cin >> H;
  for(i=1;i<=H;i++) cin >> A[i];
  buildMaxHeap(A);
  for(i=1;i<=H;i++) cout << " " << A[i];
  cout << endl;
  return 0;
}


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

int main()
{
 int N;
 cin >> N;
 int sum = 0;
 int maxLong = 0;
 for(int i = 0; i < N; i++){
     int L;
     cin >> L;
     sum += L;
     maxLong = max(maxLong, L);
 }
 if(maxLong < sum - maxLong){
     cout << "Yes" << endl;
 }
 else{
     cout << "No" << endl;
 }
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <stack>
#include <queue>
#define INF 1000000007
#define int long long
using namespace std;
using P = pair<int, int>;
using ll = long long;
signed main(){
    int c[13];
    int m[10];
    string s;
    cin>>s;
    if(s[s.size()-1]=='?'){
        for(int i=0;i<13;i++){
            if(i<10)c[i]=1;
            else c[i]=0;
        }
    }else {
        for(int i=0;i<13;i++){
            if(i==s[s.size()-1]-'0')c[i]=1;
            else c[i]=0;
        }
    }
    for(int j=0;j<10;j++)m[j]=j;
    for(int i=s.size()-2;i>=0;i--){
        for(int j=0;j<10;j++)m[j]=m[j]*10%13;
        int cb[13]={};
        if(s[i]=='?'){
            for(int j=0;j<13;j++){
                for(int k=0;k<10;k++){
                    cb[(j+m[k])%13]+=c[j];
                    cb[(j+m[k])%13]%=INF;
                }
            }
        }else{
            int h=s[i]-'0';
            for(int j=0;j<13;j++){
                cb[(j+m[h])%13]+=c[j];
                cb[(j+m[h])%13]%=INF;
            }
        }
        for(int j=0;j<13;j++)c[j]=cb[j];
    }
    cout<<c[5]<<endl;
    return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<string>
using namespace std;
struct Dice{
  int s[6];
  void roll(char c){
    int b;
    if(c=='E'){
      b=s[0];
      s[0]=s[3];
      s[3]=s[5];
      s[5]=s[2];
      s[2]=b;
    }
    if(c=='W'){
      b=s[0];
      s[0]=s[2];
      s[2]=s[5];
      s[5]=s[3];
      s[3]=b;
    }
    if(c=='N'){
      b=s[0];
      s[0]=s[1];
      s[1]=s[5];
      s[5]=s[4];
      s[4]=b;
    }
    if(c=='S'){
      b=s[0];
      s[0]=s[4];
      s[4]=s[5];
      s[5]=s[1];
      s[1]=b;
    }
  }
  int top() {
    return s[0];
  }
};
int main(){
  Dice d;
  for(int i=0;i<6;i++) cin >> d.s[i];
  string s;cin >> s;
  for(int i=0;i<s.size();i++) d.roll(s[i]);
  cout << d.top() << endl;
  return 0;
}



Measured memory_bytes: 3208
W, H, N = list(map(int, input().split()))
#1-> x < x_i, 2-> x > x_i, 3-> y < y_i, 4-> y > y_i
d = {'1': 0,
	 '2': W,
	 '3': 0,
	 '4': H}
for i in range(N):
	x, y, a = list(map(int, input().split()))
	if a == 1:
		if x > d['1']:
			d['1'] = x
	elif a == 2:
		if x < d['2']:
			d['2'] = x
	elif a == 3:
		if y > d['3']:
			d['3'] = y
	else:
		if y < d['4']:
			d['4'] = y
if d['1'] > d['2'] or d['3'] > d['4']:
	print(0)
else:
	print((d['2']-d['1']) * (d['4']-d['3']))

Measured memory_bytes: 3064
import Control.Applicative

main = do
    n <- readLn
    putStrLn $ solve n

solve n = f $ take n list
    where f numbers = unwords (map (show) numbers)


list =[11,31,41,61,71,101,131,151,181,191,211,241,251,271,281,311,331,401,421,431,461,491,521,541,571,601,631,641,661,691,701,751,761,811,821,881,911,941,971,991,1021,1031,1051,1061,1091,1151,1171,1181,1201,1231,1291,1301,1321,1361,1381]


Measured memory_bytes: 508
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int n,c[6]={500,100,50,10,5,1},ans;
    while(true){
        cin>>n;
        if(!n)break;
        n=1000-n,ans=0;
        for(int i=0;i<6;i++)ans+=n/c[i],n%=c[i];
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 3080
import sys
input = sys.stdin.readline
n,q = map(int,input().split())
A = [list(map(int,input().split())) for i in range(n)]
D = [int(input()) for i in range(q)]

E = []
F = {}
for i in range(n):
    s = A[i][0]
    t = A[i][1]
    x = A[i][2]
    F[x] = 0
    E.append((s-x, x, 1))
    E.append((t-x, x, -1))
E.append((10**10, 10**10, 1))

E.sort()

# print(E)

from heapq import heappush, heappop
Q = []

j = 0
for i in range(q):
    # print(F,j)
    while E[j][0] <= D[i]:
        if E[j][2] == 1:
            F[E[j][1]] += 1
            heappush(Q, E[j][1])
        else:
            F[E[j][1]] -= 1
        j += 1
    
    while len(Q) > 0 and F[Q[0]] == 0:
        _ = heappop(Q)
    if len(Q) == 0:
        print(-1)
    else:
        print(Q[0])


Measured memory_bytes: 127340
import java.util.Scanner;

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

    int n = sin.nextInt();
    int[] a = new int[n];
    a[0] = sin.nextInt();
    int min = a[0];
    int max = a[0];
    long sum = a[0];

    for ( int i = 1; i < a.length; i++) {
      a[i] = sin.nextInt();
      if(a[i] < min) min = a[i];
      else if(a[i] > max) max = a[i];
      sum += (long)a[i];
    }

    System.out.println(min + " " + max + " " + sum);
    sin.close();
  }
}


Measured memory_bytes: 42616
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 998244353;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd_calc(T a, T b){ if(b){ return gcd_calc(b, a % b); }else{ return a; }}
template<class T> T gcd(T a, T b){ if(a < b) swap(a, b); return gcd_calc(a, b); }
template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }
inline int at(int x, int k){ return (x >> k) & 1; }
random_device rnd;

int retu[8][3] = {{0, 1, 2}, {3, 4, 5}, {6, 7, 8}, {0, 3, 6}, {1, 4, 7}, {2, 5, 8}, {0, 4, 8}, {3, 4, 5}};

int main(){
    int N, K;
    cin >> N >> K;
    int ans = 0;
    while(N){
        N /= K;
        ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.awt.Point;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	static char[][] c;
	static int H, W;
	static List<Point> p;
	static long ans = 0;
	static boolean[][] m;
	static long cnt1 = 0;
	static long cnt2 = 0;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		H = sc.nextInt();
		W = sc.nextInt();
		String[] S = new String[H];
		for(int i = 0; i < H; i++) {
			S[i] = sc.next();
		}
		sc.close();
		c = new char[H][W];
		m = new boolean[H][W];
		for(int i = 0; i < H; i++) {
			for(int j = 0; j < W; j++) {
				m[i][j] = true;
			}
		}
		p = new ArrayList<Point>();
		for(int i = 0; i < H; i++) {
			for(int j = 0; j < W; j++) {
				c[i][j] = S[i].charAt(j);
				if(c[i][j] == '#') {
					p.add(new Point(j, i));
				}
			}
		}
		for(int i = 0; i < p.size(); i++) {
			int x = p.get(i).x;
			int y = p.get(i).y;
			if(!m[y][x]) {
				continue;
			}
			m[y][x] = false;
			cnt1 = 0;
			cnt2 = 1;
			rec('#', x, y);
			ans += cnt1 * cnt2;
		}
		System.out.println(ans);
	}
	static void rec(char color, int x, int y) {
		int[] dx = {1, -1, 0, 0};
		int[] dy = {0, 0, 1, -1};
		for(int i = 0; i < 4; i++) {
			int nx = x + dx[i];
			int ny = y + dy[i];
			if(nx >= 0 && nx < W && ny >= 0 && ny < H) {
				if(color == '#' && m[ny][nx] && c[ny][nx] == '.') {
					m[ny][nx] = false;
					cnt1++;
					rec('.', nx, ny);
				}else if(color == '.' && m[ny][nx] && c[ny][nx] == '#') {
					m[ny][nx] = false;
					cnt2++;
					rec('#', nx, ny);
				}
			}
		}
	}
}

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

const int maxn = 2000, mod = 1e9 + 7;
int n, k, dp[maxn + 3][maxn + 3];

int func(int x) {
	return x < mod ? x : x - mod;
}

int main() {
	scanf("%d %d", &n, &k);
	dp[0][n + 1] = 1;
	for (int i = 1; i <= k - 1; i++) {
		for (int j = 1; j <= n + 1 - i; j++) {
			dp[i][j] = dp[i - 1][j];
		}
		int sum = dp[i - 1][n + 1];
		for (int j = n; j >= 2; j--) {
			dp[i][j] = func(dp[i][j] + sum);
			sum = func(sum + dp[i - 1][j]);
		}
	}
	int ans = 0;
	for (int i = 1; i <= n + 1; i++) {
		ans = func(ans + dp[k - 1][i]);
	}
	for (int i = k + 2; i <= n; i++) {
		ans = func(ans << 1);
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 15872
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
using namespace std;


typedef long long ll;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)

const int mod = 1000000007;

int gcd (int a, int b){
  while(true){
    if(a < b) {
      int tmp = a;
      a = b;
      b = tmp;
    }
    if(b == 0) break;
    a = a % b;

  }
  return a;
}

int main(){
  int N, X;
  cin >> N >> X;
  vector<int> x(N);
  rep(i, N) cin >> x[i];

  x.push_back(X);
  sort(x.begin(), x.end());

  int ans = x[1] - x[0];
  for(int i = 1; i <= N; ++i){
    int diff = x[i] - x[i - 1];
    ans = gcd(diff, ans);
  }

  cout << ans << endl;
}


Measured memory_bytes: 1024
/*
    飲んだ魔剤で家が建つ。
    created at: 2020-04-07 20:19:45
*/

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

#define all(x) (x).begin(),(x).end()
#define rev(x) greater<x>()
#define MOD 1000000007
#define INF 1000000000

typedef long long LL;
typedef long double LD;

bool compare_by_b(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

LL modpower(LL n, LL m, LL mod)
{
    if (m == 0) {
        return 1;
    } else if (m % 2 == 0) {
        LL p = modpower(n, m/2, mod);
        return p*p % mod;
    } else {
        return n*modpower(n, m-1, mod) % mod;
    }
}

LL modinv(LL n, LL mod)
{
    return modpower(n, mod-2, mod);
}

LL modcombination(LL n, LL r, LL mod)
{
    LL ret = 1;

    for (int i = 0; i < r; i++) {
        ret *= (n-i);
        ret %= mod;
        ret *= modinv(i+1, mod);
        ret % mod;
    }

    return ret % mod;
}

int gcd(int k, int l)
{
    if (l > 0) return gcd(l, k%l);
    else return k;
}

struct UnionFind
{
    vector<int> par;

    UnionFind(int n) : par(n) {
        for (int i = 0; i < n; i++) par[i] = i;
    }

    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main()
{
    int a, b, x;
    cin >> a >> b >> x;

    if (x >= a && x <= a + b) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}


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

int main(void)
{
  int X;
  cin>>X;
  vector<string> data(X+1);
  for(int i=1;i<=X;i++){
    if(i%7==1) data[i]="fri";
    else if(i%7==2) data[i]="sat";
    else if(i%7==3) data[i]="sun";
    else if(i%7==4) data[i]="mon";
    else if(i%7==5) data[i]="tue";
    else if(i%7==6) data[i]="wed";
    else if(i%7==0) data[i]="thu";
  }
  cout<<data[X]<<endl;
  return 0;
}



Measured memory_bytes: 3236
#include <bits/stdc++.h>
#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;


    for (int i = 1; i <= 100; i++)
    {
        if ( (a*i) % b == c) {
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
    return 0;
}

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

class Program
{
    static void Main(string[] args)
    {
        var sol = new Solve();
        sol.Exec();
    }
}

class Solve
{
    public void Exec()
    {
        var l = Console.ReadLine().Split().Select(long.Parse).ToArray();
        long N = l[0], A = l[1], B = l[2];

        var div = N / (A + B);
        var rem = Math.Min(A, N % (A + B));

        Console.WriteLine(div * A + rem);
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "



#define int long long
void test_case() {
	int n; cin>>n;
	int a[n];
	for(int i=0;i<n;i++) cin>>a[i];
	
	int ans = 0;
	for(int i=1;i<n;i++){
		if(a[i] < a[i-1]){
			ans += a[i-1] - a[i];
			a[i] = a[i-1];
			
		}
		else if(a[i] > a[i-1]){
			
		}
	}
	
	cout<<ans<<endl;
}

signed main() {
	IOS
	int i=1, T=1;
	//cin>>T;
	while(T--){
		//cout<<"Case #"<<i<<": ";
		test_case();
		i++;
	}
}


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

// ================== CODE PREWRITTEN BEFORE THE CONTEST/PROBLEM ================== //
#define int long long
#define pb push_back
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define inf 0x3f3f3f3f

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<string> vs;

typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef set<int> si;
typedef map<string, int> msi;
// ================== CODE WRITTEN DURING THE CONTEST/PROBLEM ================== //

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

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

    if(a == b && b == c)cout<<"Yes\n";
    else cout<<"No\n";



}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
// gp_hash_table<int, int> mapka;

using namespace std;
#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

template<class C> void mini(C &a4, C b4) { a4 = min(a4, b4); }
template<class C> void maxi(C &a4, C b4) { a4 = max(a4, b4); }

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);
  int a,b,c;
  cin >> a >> b >> c;
  cout << b + min(c, b + a + 1) << "\n";
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int n;cin >> n;
  int a[n];
  int b = 0;
  int sum = 0;
  for(int i = 0; i < n; i++){
    cin >> a[i];
    sum += a[i];
    b = max(b, a[i]);
  }
  if(b*2<sum)cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
n,yen=map(int,input().split())
yen//=1000
for x in range(n+1):
  for y in range(n-x+1):
    z=n-x-y
    cur_yen=x*10+y*5+z*1
    if cur_yen == yen:
      print(x,y,z)
      exit()
print(-1,-1,-1)
      

Measured memory_bytes: 9188
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <tuple>
#include <deque>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
int n, b, c;
ll a[100000];
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    ll sump=0;
    ll summ=0;
    ll costp=0;
    ll costm=0;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }

    for (int i = 0; i < n; i++)
    {
        sump+=a[i];
        if(i%2==0){
            if(sump<=0){
                costp+=abs(sump)+1;
                sump=1;
            }
        }
        if(i%2==1){
            if(sump>=0){
                costp+=abs(sump)+1;
                sump=-1;
            }
        }
    }
    for (int i = 0; i < n; i++)
    {
        summ+=a[i];
        if(i%2==1){
            if(summ<=0){
                costm+=abs(summ)+1;
                summ=1;
            }
        }
        if(i%2==0){
            if(summ>=0){
                costm+=abs(summ)+1;
                summ=-1;
            }
        }
    }
    cout << min(costp,costm) << "\n";
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
#define PI 3.141592653589793
#define REP(i, n) for(int i = 0;i < n;++i)
long long N,M;
int main()
{
  cin>>N>>M;
  if(M==1||N==1){
    if(M!=1)cout<<max(0,(int)M-2);
    if(N!=1)cout<<max(0,(int)N-2);
    if(M==N==1)cout<<1;
  } else{
    cout<<(N-2)*(M-2);
  } 
  return 0;
}

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

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

int main() {
    int L, R, d;
    cin >> L >> R >> d;
    int ans = 0;
    FOR(i, L, R + 1) {
        if (i % d == 0) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3608
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;

public class Main {
	static final long MOD=1000000007;//998244353;
	public static void main(String[] args) {
		PrintWriter out = new PrintWriter(System.out);
		InputReader sc=new InputReader(System.in);
		int N=sc.nextInt();
		long[] A=sc.nextLongArray(N);
		long[] sum=new long[N];
		sum[N-1]=A[N-1];
		for (int i = N-2; i >= 0; i--) {
			sum[i]+=(sum[i+1]+A[i])%MOD;
		}
		long ans=0;
		for (int i = 0; i < N-1; i++) {
			ans+=(A[i]*sum[i+1])%MOD;
			ans%=MOD;
		}
		System.out.println(ans);
 	}
	static class InputReader { 
		private InputStream in;
		private byte[] buffer = new byte[1024];
		private int curbuf;
		private int lenbuf;
		public InputReader(InputStream in) {
			this.in = in;
			this.curbuf = this.lenbuf = 0;
		}
 
		public boolean hasNextByte() {
			if (curbuf >= lenbuf) {
				curbuf = 0;
				try {
					lenbuf = in.read(buffer);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (lenbuf <= 0)
					return false;
			}
			return true;
		}
 
		private int readByte() {
			if (hasNextByte())
				return buffer[curbuf++];
			else
				return -1;
		}
 
		private boolean isSpaceChar(int c) {
			return !(c >= 33 && c <= 126);
		}
 
		private void skip() {
			while (hasNextByte() && isSpaceChar(buffer[curbuf]))
				curbuf++;
		}
 
		public boolean hasNext() {
			skip();
			return hasNextByte();
		}
 
		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (!isSpaceChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}
 
		public int nextInt() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}
 
		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}
 
		public double nextDouble() {
			return Double.parseDouble(next());
		}
 
		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}
 
		public long[] nextLongArray(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}
 
		public char[][] nextCharMap(int n, int m) {
			char[][] map = new char[n][m];
			for (int i = 0; i < n; i++)
				map[i] = next().toCharArray();
			return map;
		}
	}
	}


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

using namespace std;

#define SZ(v) ((int)(v).size())
#define ALL(v) (v).begin(),(v).end()
#define one first
#define two second
using ll = long long;
using pi = pair<int, int>;
const int INF = 0x3f3f3f3f;
const ll LINF = 1ll * INF * INF;

int main() {
	int N; cin >> N;
	ll a = 1, b = 1;
	for(int i=0; i<N; i++) {
		int x, y; scanf("%d%d", &x, &y);
		ll minX = (a + x - 1) / x;
		ll minY = (b + y - 1) / y;
		ll times = max(minX, minY);
		a = times * x;
		b = times * y;
	}
	cout << a + b << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define TR(X) ({ if(1) cerr << "Trace: " << (#X) << " = " << (X) << endl; })
const ll mod = 1e9 + 7;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n; cin >> n;
	vector<bool> visited(n);
	vector<vector<ll> > dp(n, vector<ll>(2));
	vector<vector<ll> > adj(n);
	vector<ll> deg(n);
	for(ll i = 0; i < n - 1; i++) {
		ll a,b; cin >> a >> b;
		a--; b--;
		adj[a].push_back(b);
		adj[b].push_back(a);
		deg[a]++; deg[b]++;
	}
	queue<ll> q;
	ll cur;
	for(ll i = 0; i < n; i++) if(deg[i] <= 1) q.push(i);
	while(!q.empty()) {
		cur = q.front(); q.pop();
		dp[cur][0] = 1; dp[cur][1] = 1;
		assert(!visited[cur]);
		visited[cur] = true;
		for(ll nxt: adj[cur]) {
			if(visited[nxt]) {
				(dp[cur][0] *= (dp[nxt][0] + dp[nxt][1]) % mod) %= mod;
				(dp[cur][1] *= dp[nxt][0]) %= mod;
			} else {
				deg[nxt]--;
				if(deg[nxt] == 1) q.push(nxt);
			}
		}
	}
	cout << (dp[cur][0] + dp[cur][1]) % mod << '\n';
}


Measured memory_bytes: 13952
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
 
  if (a + b == c + d) {
    cout << "Balanced" << endl;
  }
  else if (a + b > c + d) {
    cout << "Left" << endl;
  }
  else if (a + b < c + d) {
    cout << "Right" << endl;
  } 
}

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

int main(){
    ll N;
    cin >> N;
    string S;
    cin >> S;
    ll white = 0, black = 0;
    
    for(ll i = 0; i < N; i++){
        if(S[i] == '.')
            white++;
        else
            black++;
    }
    
    ll ans;
    ans = min(black,white);
    white = 0;
    for(ll i = N - 1; i >= 0; i--){
        if(S[i] == '.')
            white++;
        else
            black--;
        ans = min(ans,black+white);
    }
    cout << ans << "\n";
    return 0;
} 


Measured memory_bytes: 640
# coding:UTF-8
import sys


def resultSur97(x):
    return x % (10 ** 9 + 7)


if __name__ == '__main__':
    # ------ 入力 ------#
    nl = list(map(int, input().split()))     # スペース区切り連続数字

    x = nl[0]
    sList = [input() for _ in range(x)]

    # ------ 処理 ------#
    sListSorted = sorted(sList)
    out = ""
    for s in sListSorted:
        out += s

    # ------ 出力 ------#
    print("{}".format(out))
    # if flg == 0:
    #     print("YES")
    # else:
    #     print("NO")


Measured memory_bytes: 9024
from sys import stdin


def input():
    return stdin.readline().strip()


def main():
    N, M = map(int, input().split())
    if N % 2 == 1:
        for i in range(1, M + 1):
            print(i, N - i)
    else:
        left1 = 1
        left2 = N // 2 + 1
        for i in range(M, 0, -1):
            if i % 2 == 1:
                print(left1, left1 + i)
                left1 += 1
            else:
                print(left2, left2 + i)
                left2 += 1


if __name__ == "__main__":
    main()


Measured memory_bytes: 9284
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
#define F first
#define S second
const int N = 100;
int d[N][N];
queue<pii> q;
void upd(int a[],int x)
{
    sort(a,a+3);
    a[1]-=a[0];
    a[2]-=a[0];
    if (a[2] >= N)
        return;
    if (!d[a[1]][a[2]]) {
        d[a[1]][a[2]] = x;
        q.push({a[1],a[2]});
    }
}
int main()
{
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    upd(a,1);
    while (q.size()) {
        a[0] = 0;
        tie(a[1],a[2]) = q.front();
        q.pop();
        int b[3];
        for (int i = 0; i < 3; ++i) {
            copy_n(a,3,b);
            b[i] += 2;
            upd(b,d[a[1]][a[2]] + 1);
            copy_n(a,3,b);
            b[i] -= 1;
            upd(b,d[a[1]][a[2]] + 1);
        }
    }
    cout << d[0][0] - 1 << endl;
}


Measured memory_bytes: 256
N, K = map(int, input().split())

res = 0

left = K
right = N
n = 1

# start
while left > N:
    n *= 2
    if left % 2 == 0:
        left = left // 2
    else:
        left = left // 2 + 1

# print(left, right, n)
while right > 0:
    res += (right - left + 1) / n
    n *= 2
    right = left - 1
    if left % 2 == 0:
        left = left // 2
    else:
        left = left // 2 + 1
    # print(left, right, n)
print(res / N)


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

#define vec(v) vector<int>(v)
#define be(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define mapci(mp) map<char*,int>(mp)
#define mapcc(mp) map<char*,char*>(mp)
typedef long long ll;
using namespace std;

int main() {
    int n;
    scanf("%d",&n);
    ll a[n],b[n],m,ans=0;
    for(int i=0;i<n;i++){
        scanf("%lld %lld",&a[i],&b[i]);
    }
    for(int i=n-1;i>=0;i--){
        m=(a[i]+ans)%b[i];
        if(m!=0){
            ans+=b[i]-m;
        }
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 1920
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <string>

using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)
#define repe(i,s,n)for(ll i = s;i<=n;i++)
int main() {
	ll X; cin >> X;
	ll t = 1;
	ll sum = 0;
	while (true) {
		sum += t;
		if (sum >= X) {
			break;
		}
		t++;
	}
	cout << t << endl;

	return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    int n; cin>>n;
    map<string,int>mp;
    rep(i,n){string gotiusa_is_god; cin>>gotiusa_is_god;mp[gotiusa_is_god]++;}
    int ujimatsu_tiya; cin>>ujimatsu_tiya;
    bool gotiusa=true;
    rep(i,ujimatsu_tiya){
        string rize; cin>>rize;
        if(!mp[rize]){cout<<"Unknown "<<rize<<endl; continue;}
        if(gotiusa)cout<<"Opened by "<<rize<<endl;
        else cout<<"Closed by "<<rize<<endl;
        if(gotiusa)gotiusa=false;
        else gotiusa=true;
    }
}

Measured memory_bytes: 3248
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define pii std::pair<int,int>
#define pli std::pair<ll,int>
#define pil std::pair<int,ll>
#define psi std::pair<string,int>
#define pll std::pair<ll,ll>
#define pci std::pair<char,int>
#define sll(x) scanf("%lld",&x)
#define prll(x) printf("%lld ",x)
#define pri(x) printf("%d ",x)
#define si(x) scanf("%d",&x)
#define pb push_back
#define vll std::vector<ll>
#define vpi std::vector<std::pair<int,int>>
#define vi std::vector<int>
#define vvi std::vector<std::vector<int>>
#define vvpil std::vector<std::vector<std::pair<int,ll>>>
#define vlpii std::vector<std::list<pii>>
#define vlpil std::vector<std::list<pil>>
#define li std::list<int>
#define lpil std::list<pil>
#define Endl printf("\n")
#define vli vector<list<int>>
#define vvll vector<vector<ll>>
#define mp make_pair
#define x first
#define y second
#define ull uint64_t
#define ma 100000000
#define imie(...) "[" << #__VA_ARGS__": " << (__VA_ARGS__) << "] "
const ll  INF=10000000000000;
const ll mod =  1e9 + 7;
using namespace std;
void add(ll& a , ll b){
	a += b;
	if(a >= mod) a -= mod;
}
ll mul(ll a , ll b){
	return (a * b) % mod;
}
ull Pow(ull a , ull b){
	if(b == 0) return 1 ;
	ull c = Pow(a , b / 2) ;
	if(b % 2) return (a * ((c * c) % mod)) % mod;
	return (c * c) % mod ;
}
int f(vi v){
	if(v.size() == 0) return 0 ;
	if(v.size() == 1) return v[0] ;
	int m = *min_element(v.begin() , v.end()) ;
	vi tmp ;
	int ans = m ;
	for(int i = 0 ; i < (int)v.size() ; i++){
		if(v[i] == m) {ans += f(tmp) ;tmp.clear() ;}
		else tmp.pb(v[i] - m) ;
	}
	ans += f(tmp) ;
	return ans ; 
}
		

int main(){
	IOS;
	cout.precision(30) ;
	int n ; cin >> n ;
	vi h(n) ;for(int i = 0 ; i < n ; i++) cin >> h[i] ;
	cout << f(h) << endl ;
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

int dist(vector<int> x, vector<int> y, int D){
  int tmp = 0;
  REP(i, D) tmp += (x[i] - y[i]) * (x[i] - y[i]);
  return tmp;
}

int main() {

  int N, D;
  cin >> N >> D;

  vector<vector<int>> x(N, vector<int>(D));
  REP(i, N)REP(j, D) cin >> x[i][j];

  int count = 0;
  REP(i, N)REP(j, N){
    if (i == j) continue;
    int tmp = dist(x[i], x[j], D);
    int sq = (int)sqrt(tmp);
    //cout << tmp << " " << sq << endl;
    if (tmp == sq * sq) count++;

  }

  cout << (count / 2) << endl;

  return 0;
}


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

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

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

    int n;
    cin >> n;

    vector<vector<int> > a(n, vector<int>(3));
    REP(i, n) REP(j, 3) cin >> a[i][j];

    vector<vector<int> > dp(n + 1, vector<int>(3, 0));

    REP(i, n) REP(j, 3) REP(k, 3) {
        if (j == k) continue ;
        chmax(dp[i + 1][k], dp[i][j] + a[i][k]);
    }

    int sum = 0;
    REP(i, 3) chmax(sum, dp[n][i]);

    cout << sum << '\n';
    return 0;
}

Measured memory_bytes: 11264
#include <stdio.h>

int main(void)
{
	int a,b;
	
	
	
	
	
	scanf("%d %d", &a,&b);
	while(1){
	if(-1000<=a && 1000>b){
		if(a>b){
			printf("a > b\n");
			break;
		}else if(a<b){
			printf("a < b\n");
			break;
		}else if(a == b){
			printf("a == b\n");
			break;
		}
	}else{
		scanf("%d %d", &a,&b);
	    continue;
	}
	}
	
		
	return 0;
}

Measured memory_bytes: 580