akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

signed main(){
	int n,a,b;
	cin >> n;
	if(n == 1) cout << "Hello World" << endl;
	else{
		cin >> a >> b;
		cout << a + b << endl;
	}
	return 0;
}

Measured memory_bytes: 256
l,r = map(int,input().split())
sub = r-l
l %= 2019
r %= 2019

if(sub >= 2019):
    print(0)
    exit()

mina = float('INF')

for x in range(l,r+1):
    for y in range(x,r+1):
        if(x==y):
            continue
        
        ans = (x * y) % 2019
        if(mina > ans):
            mina = ans
       
print(mina)

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

using namespace std;


int main() {
	int N, K, X, Y;
	cin >> N >> K >> X >> Y;

	if(N > K) {
		cout << K * X + (N - K) * Y << endl;
	} else {
		cout << N * X << endl;
	}

	return 0;
}


Measured memory_bytes: 256
N = int(input())
A = sorted(list(map(int,input().split())))

n = A[-1]
A = A[:-1]

r_val = n//2
diff_min = float(n)

for a in A:
    diff = abs(n/2 - float(a))
    if diff_min > diff:
        diff_min = diff
        r = a

print(n,r)


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

ll gcd(ll a, ll b){
  if(a < b) swap(a, b); 
  if(a % b == 0) return b;
  else return gcd( a - b, b);
}


int main(){
  ll a,b,c,count1=0,count2=0;
  cin >> a >> b;
  c=gcd(a,b);
  while(c%2==0){
    c/=2;
    if(!count1)count1=1;
  }
  count2=count1;
  for(ll i=3;i<=sqrt(c);i+=2){
    while(c%i==0){
      c/=i;
      count1++;
    }
    if(count1>count2+1)count1=count2+1;
    count2=count1;
  }
  if(count1==1&&c==1)cout << 2<<endl;
  else if(count1>1&&c==1)cout<<count1+1<<endl;
  else if(c==1)cout<<1<<endl;
  else cout << count1+2<<endl;
}

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

int main() {
  string s;
  cin >> s;
  vector<int>a(s.size());
  
  int count=1;
  for(int i=0; i<s.size(); i++){
    if(s[i]==s[i+1]){
      a[i]=0;
      count++;
  }
    if(s[i]!=s[i+1]  || i==s.size()-1){
      if(s[i]=='R')a[i]=count;
      else{
        a[i-count+1]=count;
        if((a[i-count]+a[i-count+1])%2==0){
          a[i-count+1]=(a[i-count]+a[i-count+1])/2;
          a[i-count]=a[i-count+1];
        }
          
        else if((a[i-count]+a[i-count+1])%2==1 && a[i-count]%2==1){
          a[i-count+1]=(a[i-count]+a[i-count+1])/2;
          a[i-count]=a[i-count+1]+1;
        }
        
        else if((a[i-count]+a[i-count+1])%2==1 && a[i-count+1]%2==1){
          a[i-count]=(a[i-count]+a[i-count+1])/2;
          a[i-count+1]=a[i-count]+1;
        }
        
      }
      
      count=1;
    }
    
  }
  
  for(int i=0; i<s.size(); i++){
   cout << a[i] << " "; 
  }
}



Measured memory_bytes: 1024
n = int(input())
for i in range(n):
  A =list(map(int,input().split()))
  A.sort()
  a=A[0]
  b=A[1]
  c=A[2]
  if c*c == a*a + b*b:
    print("YES")
  else:
    print("NO")
    


Measured memory_bytes: 5592
K = int(input())
array = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(array[K-1])

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		int K = stdIn.nextInt();
		int X = stdIn.nextInt();
		int ans = 0;
		ans = K * 500;
		if(ans >= X){
			System.out.println("Yes");
		}
		else{
			System.out.println("No");
		}
		stdIn.close();
	}
}

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

#define fi first
#define se second
#define be begin
#define en end
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ALL(a) (a).be() , (a).en()
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)        //repeat n times
#define REP2(i,s,n) for(int (i)=(s);(i)<(n);(i)++)   //repeat from s to n 
#define REPD(i,n) for(int (i)=(n);(i)>=0;(i)--)      //repeat from n to 0
#define REPD2(i,s,e) for(int (i)=(s);(i)>=(e);(i)--) //repeat from s to e
#define RANGE(i,v) for(auto &(i):v)                  //repeat range
#define ASIZE(a) (sizeof(a) / sizeof(a[0]))          //array size

using LL = long long;

template<typename T> using V = vector< T >;
using Vi = V<int>;
using Vll = V<LL>;
using Vs = V<string>;

int main(){
    int n;
    cin>>n;
    Vi a(n),b(n);
    REP(i,n) cin>>a[i];
    b = a;
    sort(ALL(b),greater<int>());
    REP(i,n){
        if(a[i] != b[0]){
            cout<<b[0]<<endl;
        }else{
            cout<<b[1]<<endl;
        }
    }

    return 0;
}

Measured memory_bytes: 3200
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <cstdlib>
typedef long long int ll;
using namespace std;

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

long long int facctorialMethod(int k){//階乗
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

long long int tousasum(long long int n){//等差数列
    return n*(n+1)/2;
}

unsigned GetDigit(unsigned num){//桁数
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}

bool IsPrime(int num)//素数判定
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

map< ll, ll > prime_factor(ll n) {//素因数分解
    map< ll, ll > ret;
    for(ll i = 2; i * i <= n; i++) {
        while(n % i == 0) {
            ret[i]++;
            n /= i;
        }
    }
    if(n != 1) ret[n] = 1;
    return ret;
}

ll calcNumOfCombination(ll n, ll r){
    ll num = 1;
    for(ll i = 1; i <= r; i++){
        num = num * (n - i + 1) / i;
    }
    return num;
}



int main() {
    int N,K;
    cin >> N >> K;
    ll h[N];
    for(int i=0;i<N;i++){
        cin >> h[i];
    }
    sort(h,h+N);
    ll min=1e9;
    for(int i=0;i<N-K+1;i++){

        if((h[i+K-1]-h[i])<min){
            min = h[i+K-1]-h[i];

        }
    }
    cout << min << endl;


}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
 
int main() {
 
  string a,b;
  cin>>a>>b;

  if(a==b)
    cout<<"EQUAL"<<endl;
  else if(a.size()>b.size())
    cout<<"GREATER"<<endl;
  else if(a.size()<b.size())
    cout<<"LESS"<<endl;
  else{
    if(a>b)
      cout<<"GREATER"<<endl;
    else
      cout<<"LESS"<<endl;
  }

  return 0;
}

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

int main(){
  vector<vector<int>> c(3, vector<int>(3));
  for(int i=0; i<3; i++){
    for(int j=0; j<3; j++){
      cin >> c.at(i).at(j);
    }
  }
  bool takahashi = true;
  vector<int> dif(3);
  for(int i=0; i<2; i++){
    for(int j=0; j<3; j++){
      dif.at(j) = c.at(i).at(j)-c.at(i+1).at(j);
    }
    if(dif.at(0)!=dif.at(1) || dif.at(1)!=dif.at(2)){
      takahashi = false;
      break;
    }
    for(int j=0; j<3; j++){
      dif.at(j) = c.at(j).at(i)-c.at(j).at(i+1);
    }
    if(dif.at(0)!=dif.at(1) || dif.at(1)!=dif.at(2)){
      takahashi = false;
      break;
    }
  }
  if(takahashi){
    cout << "Yes";
  }else{
    cout << "No";
  }
  return 0;
}

Measured memory_bytes: 3592
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

Int N,K;

void solve(Int rest) {
    vector<pair<int,int> > uv;
    Int M = 0;

    for(int j = 2;j <= N;j++) {
        M++;
        uv.push_back(make_pair(1,j));
    }

    M += rest;
    int a = 2;
    int b = 3;
    for(int i = 0;i < rest;i++) {
        uv.push_back(make_pair(a,b));
        if(b == N) {
            a++;
            b = a+1;
        } else {
            b++;
        }
    }

    cout<<uv.size()<<endl;
    for(int i = 0;i < uv.size();i++) {
        cout<<uv[i].first<<" "<<uv[i].second<<endl;
    }

    return;
}

int main(void) {
    cin>>N>>K;

    if(K > ((N-1)*(N-2))/2) {
        cout<<-1<<endl;

        return 0;
    }

    Int rest = ((N-1)*(N-2))/2-K;
    solve(rest);

    return 0;
}


Measured memory_bytes: 384
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

a,b,k = map(int,input().split())
aa = make_divisors(a)
bb = make_divisors(b)
print(sorted(set(aa) & set(bb))[-k])


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

int main(int argc, char const *argv[])
{
	long long n,a[5];
	cin>>n;
	for (int i = 0; i < 5; ++i)
	{
		cin>>a[i];
	}
	sort(a,a+5);
	cout<<4LL+(n+a[0]-1)/a[0]<<endl;
	return 0;
}


Measured memory_bytes: 256
def gcd(a, b):
  while b:
     a, b = b, a % b
  return a

gcd_ij = []  
ans = 0
N = int(input())

for i in range(1, N+1):
    for j in range(1, N+1):
            gcd_ij.append(gcd(i, j))

for ij in gcd_ij:
    for k in range(1, N+1):
        ans += gcd(ij, k)
        
print(ans)

Measured memory_bytes: 69964
/*input
6 10
4 4 1 1 1 7
3 5 19
2 5 20
4 5 8
1 6 16
2 3 9
3 6 16
3 4 1
2 6 20
2 4 19
1 2 9
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define REP(i, j, k)  for(int i = j; i <  k; ++i)
#define RREP(i, j, k) for(int i = j; i >= k; --i)
#define F first
#define S second
#define mp make_pair
#define pb emplace_back
#define PII pair<int , int>
#define DBGG(i,j)     cout << i << " " << j << endl
#define DB4(i,j,k,l)  cout << i << " " << j << " " << k << " " << l << endl
#define IOS cin.tie(0) , cout.sync_with_stdio(0)
#define endl "\n"
///------------------------------------------------------------
#define int long long
#define MAX 100009
#define INF 0x3f3f3f3f

struct djs{
    int x[MAX] , v[MAX] , siz[];
    void init(){ REP(i , 0 , MAX) x[i] = i; }
    int Find(int now){ return x[now] == now ? now : Find(x[now]); }
    void Union(int a , int b){
        a = Find(a) , b = Find(b);
        if(v[a] > v[b]) swap(a , b);
        x[a] = b;
        v[b] += v[a];
    }
    int operator[](int now){ return Find(now); }
} ds;

int n , m , e[MAX][3] , x[MAX] , in[MAX] , s[MAX];
int cut[MAX][2] , rrr[MAX][2] , is[MAX];
int cmp(int a , int b){ return e[a][2] < e[b][2]; }
int32_t main(){
    IOS;
    cin >> n >> m;
    REP(i , 1 , n + 1) cin >> x[i];
    REP(i , 1 , m + 1) REP(j , 0 , 3) cin >> e[i][j];
    REP(i , 1 , m + 1) s[i] = i;
    sort(s + 1 , s + 1 + m , cmp);
    
    ds.init();
    REP(i , 1 , n + 1) ds.v[i] = x[i];

    REP(idx , 1 , m + 1){ int i = s[idx];
        int v1 = e[i][0] , v2 = e[i][1];

        if(ds[v1] != ds[v2]){
            is[i] = 1;
            rrr[i][0] = ds[v1];
            cut[i][0] = ds.v[ds[v1]];
            rrr[i][1] = ds[v2];
            cut[i][1] = ds.v[ds[v2]];
            ds.Union(v1 , v2);
        }
                // cout << "\t\t\t"; REP(i , 1 , n + 1) cout << ds.x[i] << " "; cout << endl;
                // cout << "\t\t\t"; REP(i , 1 , n + 1) cout << ds.v[i] << " "; cout << endl;
    }
    int ans = 0;
    RREP(idx , m , 1){ int i = s[idx];
        int v1 = e[i][0] , v2 = e[i][1];
        // DB4("edge " , e[i][2] , "vs = " , ds.v[ds[v1]]);
        //         DB4(rrr[i][0] , cut[i][0] , rrr[i][1] , cut[i][1]);
        if(ds.v[ds[v1]] < e[i][2]){
            ans ++;
            if(is[i]){
                ds.x[rrr[i][0]] = rrr[i][0] , ds.v[rrr[i][0]] = cut[i][0];
                ds.x[rrr[i][1]] = rrr[i][1] , ds.v[rrr[i][1]] = cut[i][1];
                // cout << "\t\t\t"; REP(i , 1 , n + 1) cout << ds.x[i] << " "; cout << endl;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 10368
from sys import exit

s = input()
l = len(s)

for i in range(l-2):
  if s[i] == s[i+1]:
    print(i+1, i+3)
    exit()
  if s[i] == s[i+2]:
    print(i+1, i+3)
    exit()

if s[l-2] == s[l-1]:
  print(l-1, l)
else:
  print(-1, -1)


Measured memory_bytes: 3188
function parseInt(x) parse(Int, x) end

function main()
	n = readline() |> parseInt
	a = readline() |> split |> a -> parseInt.(a)
	b = [0 for i in 1:n]
	for i in 1:n
		b[i] = a[i] -i
	end
	m = median(b)
	sum = 0
	for i in 1:n
		sum += abs(b[i]-m)
	end
	println(convert(Int, sum))
end

main()

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

int n;
int P[110][11];
int F[110][11];
int ans = -(1<<30);

int main(){
    cin >> n;
    for (int i = 0; i < n; i++) for (int j = 0; j < 10; j++) cin >> F[i][j];
    for (int i = 0; i < n; i++) for (int j = 0; j <= 10; j++)cin >> P[i][j];
    for (int b = 1; b < 1<<10; b++) {
        int profit = 0;
        for (int i = 0; i < n; i++) {
            int cnt = 0;
            for (int j = 0; j < 10; j++) {
                if(b>>j&F[i][j]) cnt++;
            }
            profit += P[i][cnt];
        }
        ans = max(ans, profit);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
ans = 0
l,r = 0, 0
xor = a[0]
add = a[0]

while r < n and l <= r:
    if xor == add:
        ans += r - l + 1
        r += 1
        if r< n:
            xor ^= a[r]
            add += a[r]
    else:
        if l < n:
            xor ^= a[l]
            add -= a[l]
        l += 1

print(ans)


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

#define F first
#define S second
#define pii pair<int, int>
#define pb push_back

using namespace std;

typedef long long ll;
typedef long double ld;

const int N = 110, mod = 1e9 + 7;

ll h[N], dp[N][N], f[N][N], y[N], t[N];

int power(int a, int b)
{
	if(b == 0) return 1;
	ll res = power(a, b/2); 
	res *= res, res %= mod;
	if(b & 1) res *= a, res %= mod;
	return res;
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	vector <int> vc; vc.pb(0);

	int n; cin >> n;
	for (int i=0; i<n; i++) {
		cin >> h[i];
		vc.pb(h[i]);
	}

	sort(vc.begin(), vc.end());
	vc.resize(unique(vc.begin(), vc.end()) - vc.begin());
	
	int cnt = 0;
	for (auto Y : vc)
		y[cnt ++] = Y;

	for (int i=0; i<n; i++)
		t[i] = lower_bound(vc.begin(), vc.end(), h[i]) - vc.begin();


	for (int j=0; j<t[0]; j++)
	{
		int y1 = y[j], y2 = y[j + 1];
		if(y2 >= y1 + 2)
		{
			int R = h[0] - y[j] - 2, L = h[0] - y[j + 1];
			dp[0][j] = power(2, R + 1) + mod - power(2, L); dp[0][j] %= mod;
		}
		int pw = max(0LL, h[0] - y[j + 1] - 1);
		f[0][j] = power(2, pw);
	}

	for (int i=1; i<n; i++)
		for (int j=0; j<t[i]; j++)
		{
			if (j < t[i] - 1)
			{
				if(j + 1 <= t[i - 1])
				{
					ll way = dp[i - 1][j];
					if(h[i] > h[i - 1]) way *= power(2, h[i] - h[i - 1]);
					dp[i][j] = way % mod;

					bool done = 0;

					way = f[i - 1][j];
					if(j == t[i - 1] - 1) way *= 2, way %= mod, done = 1;

					if(h[i] > h[i - 1]) way *= power(2, h[i] - h[i - 1] - done), way %= mod;
					f[i][j] = way;

				}else
				{
					ll way = 2LL * f[i - 1][t[i - 1] - 1] % mod;
					int R = h[i] - y[j] - 2, L = h[i] - y[j + 1];
					way *= (power(2, R + 1) + mod - power(2, L)) % mod;
					dp[i][j] = way % mod;

					f[i][j] = 2LL * f[i - 1][t[i - 1] - 1] % mod;
					f[i][j] *= power(2, h[i] - y[j + 1] - 1); f[i][j] %= mod;
				}
			}else
			{
				if(t[i - 1] >= j + 1){
					dp[i][j] = dp[i - 1][j];
					ll ps = 0;
					for (int k=j; k<t[i - 1]; k++)
					{
						ps += 2LL * f[i - 1][k]; ps %= mod;
						if(k + 1 < t[i - 1]) ps += 2LL * dp[i - 1][k + 1], ps %= mod;
					}
					f[i][j] = ps;
				}else
				{
					ll way = 2LL * f[i - 1][t[i - 1] - 1];
					way *= power(2, h[i] - y[j] - 1) + mod - 1; way %= mod;
					dp[i][j] = way;

					f[i][j] = 2LL * f[i - 1][t[i - 1] - 1] % mod;
				}
			}
		}

	ll ans = 0;
	for(int j=0; j<t[n - 1]; j++) {
		ans += (2LL * dp[n - 1][j]) % mod;
		ans += (2LL * f[n - 1][j]) % mod;
		ans %= mod;
	}

	ans %= mod;
	cout << ans << endl;

}


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

string solve(int sx, int sy, int tx, int ty) {
  string s;
  int dx = tx - sx;
  int dy = ty - sy;
  int i;
  for (i = 0; i < dx; i++) {
    s.push_back('R');
  }

  for (i = 0; i < dy; i++) {
    s.push_back('U');
  }

  for (i = 0; i < dx; i++) {
    s.push_back('L');
  }

  for (i = 0; i <= dy; i++) {
    s.push_back('D');
  }

  for (i = 0; i <= dx; i++) {
    s.push_back('R');
  }

  for (i = 0; i <= dy; i++) {
    s.push_back('U');
  }

  s.push_back('L');
  s.push_back('U');

  for (i = 0; i <= dx; i++) {
    s.push_back('L');
  }

  for (i = 0; i <= dy; i++) {
    s.push_back('D');
  }

  s.push_back('R');

  return s;
}

int main() {
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;

  cout << solve(sx, sy, tx, ty) << "\n";
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>

int main( void ) 
{
 
    int n;
    scanf( "%d", &n );
    
    int i, j;
    int num[10000];
    int cnt = n;
    for( i=0; i<n; i++ ) {
        scanf( "%d", &num[i] );
    }
    for( i=0; i<n; i++ ) {    
        if( 2 == *(num+i) ) { continue; }
        
        if( 0 == *(num+i)%2 ) {
            cnt--;
        } else {
            int max = sqrt( num[i] );
            for( j=3; j<=max; j+=2 ) {
                if( 0 == *(num+i)%j ) {
                    cnt--;
                    break;
                }
            }
        }
    }
     
    printf( "%d\n", cnt );
    
    return 0;
}

Measured memory_bytes: 632
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        var s = Console.ReadLine().Trim();
        var t = Console.ReadLine().Trim();
        var ret = 0;
        for (int i = 0; i < n; i++)
        {
            var w = s.Substring(i);
            var w2 = t.Substring(0, n - i);
            if (w == w2) { ret = n - i;  break; }
        }
        Console.WriteLine( 2 * n - ret);
    }
}


Measured memory_bytes: 11092
import math
n, m = input().split()
n = int(n)
m = int(m)
x = 0
y = 0
if n > 1:
  x = int(math.factorial(n)/(2 * math.factorial(n-2)))
if m > 1:
  y = int(math.factorial(m)/(2 * math.factorial(m-2)))

print(x+y)



Measured memory_bytes: 9076
s =  list(input())

ret = 0
i = 0
a = 0
bc = 0

while True :
    while i < len(s) and s[i] == 'A' :
        a += 1
        i += 1

    while i < len(s) - 1 and s[i:i+2] == ['B', 'C']  :
        bc += 1
        i += 2

    ret += a * bc

    bc = 0

    if i < len(s) and s[i] != 'A' :
        a = 0
        
    while i < len(s) and s[i] != 'A' :
        i += 1

    if i >= len(s) - 1 :
        break
    

print(ret)


Measured memory_bytes: 61936
//ALDS1_11_B:Depth First Search
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <cstdlib>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <math.h>
#include <random>
#include <time.h>
#include <cassert>
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> v[101];
    for(int i=0; i<n; i++){
        int u,k;
        cin >> u >> k;
        for(int j=0; j<k; j++){
            int tmp;
            cin >> tmp;
            v[u].push_back(tmp);
        }
    }

    int d[101];
    for(int i=1; i<=n; i++) d[i] = -1;

    queue<int> que;
    que.push(1);
    int now = 0;
    while(!que.empty()){
        int tmp = que.size();
        for(int i=0; i<tmp; i++){
            if(d[que.front()] != -1){
                que.pop();
                continue;
            }

            d[que.front()] = now;
            for(int j=0; j<v[que.front()].size(); j++){
                if(d[v[que.front()][j]] == -1) que.push(v[que.front()][j]);
            }
            que.pop();
        }
        now++;
    }

    for(int i=1; i<=n; i++){
        cout << i << " " << d[i] << endl;
    }
}


Measured memory_bytes: 3184
import bisect
N, A, B = map(int, input().split())
V = list(map(int, input().split()))

V.sort()
s = sum(V[-A:])
k = V[-A]
l = bisect.bisect_left(V, k)
r = bisect.bisect_right(V, k)
p = N-A


def f(n):
    y = 1
    for i in range(2, n+1):
        y *= i
    return y


print(s/A)
if r == N:
    a = 0
    for i in range(A, min(B, N-l)+1):
        a += f(N-l)//f(i)//f(N-l-i)
    print(a)
else:
    print(f(r-l)//f(r-p)//f(p-l))


Measured memory_bytes: 3188
//  LINK ZADATKA: http://abc070.contest.atcoder.jp/tasks/abc070_c

#include <queue>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <complex>
#include <fstream>
#include <cstring>
#include <string>
#include <climits>

using namespace std;

typedef long long ll;
typedef complex<double> point;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector< vector<int> > vvi;
typedef unsigned long long ull;

#define FOR(k,a,b) for(int k=(a); k<=(b); ++k)
#define REP(k,a) for(int k=0; k<(a);++k)
#define SZ(a) int((a).size())
#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define INF 999999999
#define INFLONG 1000000000000000000
#define MOD 1000000007
#define MAX 100
#define ITERS 100
#define MAXM 200000
#define MAXN 1000000
#define _gcd __gcd
#define eps 1e-9

ull n, brojevi[150];

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


ull lcm(ull a, ull b){
	ll temp = gcd(a, b);
	return temp?(a/temp*b) : 0;
}




int main(){
	scanf("%llu", &n);
	
	REP(i, n) scanf("%llu", &brojevi[i]);
	
	ull sol;
	sol = accumulate(brojevi, brojevi+n, brojevi[0], lcm);
	
	printf("%llu\n", sol);
	
	return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
#include<stdlib.h>

int main() {
  int i=0, j=0, printi=0, l=0, key=0;
  int array[100];

  scanf("%d", &l);
  for(i=0 ; i<l ; i++) {
    scanf("%d", &array[i]);
  }
  
  for(printi = 0 ; printi < l; printi++){
    printf("%d", array[printi]);
    if(printi != l-1) printf(" ");
  }
  printf("\n");
    
  for(j=1 ; j<l ; j++){
    key = array[j];

    i = j-1;
    while((i >= 0) && (array[i] > key)){
      array[i+1] = array[i];
      i--;
    }
    
    array[i+1] = key;

    for(printi = 0 ; printi < l; printi++){
      printf("%d", array[printi]);
      if(printi != l-1) printf(" ");
    }
    printf("\n");
  }
  
  return 0;
}



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


main() {
  string s;cin>>s;
  bool p=s[0]=='R';
  bool q=s[1]=='R';
  bool r=s[2]=='R';
  if(p&&q&&r){
    cout << 3 << endl;
  } else if((p&&q)||(q&&r)){
    cout << 2 << endl;
  } else if(p||q||r){
    cout << 1 << endl;
  } else {
    cout << 0 << endl;
  }
}

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

#define pb push_back
#define ppb pop_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define ll long long
#define bit __builtin_popcountll
#define sqr(x) (x) * (x)
#define forit(it,S) for(__typeof((S).begin()) it = (S).begin(); it != (S).end(); it++)
#define debug(x) cout << #x <<" = " << x << endl
#define forn(i, n) for(int i = 0 ; (i) < (n) ; ++i)
#define printvpair(v) for(int i = 0 ; (i) < (v.size()) ; ++i) cout << v[i].first  <<" " << v[i].second << endl;
#define printv(v) for(int i = 0 ; (i) < (v.size()) ; ++i) cout << v[i] << " "; cout << endl;

using namespace std;

typedef pair<int, int> pii;

const double eps = 1e-9;
const double pi = acos(-1.0);
const ll INF = 1000000000000;

const int dx[4] = {0,  0, 1, -1};
const int dy[4] = {1, -1, 0,  0};
const int N = 2 * 1e5 + 7;
int a[N];
int n;
int main() {
	ios_base::sync_with_stdio(0);
	int n;
	cin >> n;
	ll sumTotal = 0;
	forn(i,n) {
		cin >> a[i];
		sumTotal += a[i];	
	}
	
	ll sum1,sum2;
	sum1 = sum2 = 0;
	ll mn = INF; 
	forn(i,n - 1){
		sum1 += a[i];
		sum2 = sumTotal - sum1;
		if (abs(sum2 - sum1) < mn){
			mn = abs(sum2 - sum1);
		}
	}
	
	cout << mn << endl;
	
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <cstdlib>
using namespace std;
int main(){
 int n,k;
 cin >> n>>k;
 int x[n];
 for(int i=0;i<n;i++) cin>>x[i];
 long long int ans=0;
for(int i=0;i<n;i++){
  int a,b;
  a=2*x[i];b=2*abs(k-x[i]);
  ans+=min(a,b);
}
cout << ans<<endl;
}


Measured memory_bytes: 256
i = 0
h = -1
c = -1
l = -1
while i < 10
    x = gets.to_i
    if x > l
        if x > c
            if x > h
                l = c
                c = h
                h = x
            else
                l = c
                c = x
            end
        else
            l = x
        end
    end
    i = i + 1
end
puts h
puts c
puts l

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

using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset

typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;

#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'

char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
// end of Template

int dua[6];
int n,m;
int main(){

//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    dua[0] = 1;
    for(int i=1;i<=5;i++)dua[i] = 2 * dua[i-1];
    cin>>n>>m;
    cout << ((1900*m)+(100*(n-m)))*dua[m] <<newl;


}


Measured memory_bytes: 256
//https://blog.csdn.net/hesorchen
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <stack>
#include <list>
#include <set>
#include <queue>
#include <string>
#include <cstring>
using namespace std;
#define ll long long
#define lowbit(a) (a & (-a))
#define endl "\n"
#define PI acos(-1.0)
#define mod 1000000009
#define INF 0x3f3f3f3f
#define MAX 200010

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

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

int H, A[MAX + 1];  // Hは最大のノード，Aはヒープの配列

void maxHeapify(int i)
{
    int l, r, largest;
    l = 2 * i;  // 左の子
    r = 2 * i + 1; // 右の子

    // 左の子，自分，右の子で値が最大のノードを選ぶ
    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(largest);
    }
}

int main()
{
    cin >> H;

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

    for (int i = H / 2; i >= 1; i--) {
        maxHeapify(i);
    }

    for (int i = 1; i <= H; i++) {
        cout << " " << A[i];
    }
    cout << endl;

    return 0;
}


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int x, y;
  cin >> x >> y;
  for (int i = 0; i < 100; i++) {
    for (int j = 0; j < 100; j++) {
      if (2 * i + 4 * j == y && i + j == x) {
        cout << "Yes" << '\n';
        return 0;
      }
    }
  }
  cout << "No" << '\n';
  return 0;
}

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

int main(){
    int N, M;
    cin >> N >> M;
    int X, Y;
    cin >> X >> Y;
    int MAX_X=-100, MIN_Y=100;
    for(int i=0; i<N; i++){
        int x; cin >> x;
        MAX_X = max(MAX_X, x);
    }
    for(int i=0; i<M; i++){
        int y; cin >> y;
        MIN_Y = min(MIN_Y, y);
    }
    if(MAX_X <Y && X < MIN_Y && MAX_X < MIN_Y ) cout << "No War" << endl;
    else cout << "War" << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma comment(linker, "/STACK:1024000000,1024000000")

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

#define pb push_back
#define F first
#define S second

#define f(i,a,b)  for(int i = a; i < b; i++)
// #define endl '\n'

using ll = long long;
using db = long double;
using ii = pair<int, int>;

const int N = 1.5e5, LG = 17, MOD = 998244353;
const int SQ = 390;
const long double EPS = 1e-7;
ll n, s;
ll fx(ll b, ll n){
  if(b > n)return n;
  return fx(b,n/b) + n % b;
}
int32_t main(){
#ifdef ONLINE_JUDGE
  ios_base::sync_with_stdio(0);
  cin.tie(0);
#endif // ONLINE_JUDGE
  ///N / > sqrt(N) = < sqrt(N)
  ///hence let's say N / X = V[i],(S-V[i])
  ///what is X
  cin >> n >> s;
  if(n==1){
    if(s==1){
      cout<<2<<endl;
    } else
    cout << -1 << '\n';
    return 0;
  }
  vector<int> v = {1};
  for(ll i = 2; i <= 10000000; i++){
    if(fx(i,n)==s){
      cout<<i<<'\n';
      return 0;
    }
    v.pb(i);
  }
  ///the smallest integer such that n / x = v[i]
  for(int i = 10000; i >= 1; --i){
    if(s == i && n % i == 0){
      cout << n / i << '\n';
      return 0;
    }
    ll lo = 1, hi = n;
    while(lo < hi){
      ll md= lo+(hi-lo)/2;
      if(n / md <= i)hi=md;
      else
        lo = md + 1;
    }
    if(n/lo!=i || s <= i)continue;
    ll l = lo;
    hi = n;
    while(lo < hi){
      ll md = lo +(hi-lo+1)/2;
      if(n/md==i)
        lo = md;
      else
        hi = md - 1;
    }
    ll r = lo;  ///what remains as the integer increase the mod decrease
    lo = l, hi = r;
    while(lo < hi){
      ll md = lo + (hi - lo+1) / 2;
      if(n%md>=(s-i))lo=md;
      else
        hi=md-1;
    }
    if(fx(lo,n)==s){
      cout<<lo<<'\n';
      return 0;
    }
  }

  if(fx(n+1,n) == s){
    cout << n + 1 << '\n';
    return 0;
  }

  cout << -1 << '\n';




  return 0;
}


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

int main() {
  int N, K;
  cin >> N >> K;
  int sum = 0;
  for (int i = 0; i < N; i++){
    int x;
    cin >> x;
    if (x <= K / 2){
      sum = sum + 2 * x;
    }
    else {
      sum = sum + 2 * (K - x);
    }
  }
  cout << sum << endl;
}



Measured memory_bytes: 3548
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

// AtCoder
#include <atcoder/all>
using namespace atcoder;

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

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fls(x) (64 - __builtin_clzll(x))
#define pcnt(x) __builtin_popcountll(x)
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;



int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, m; cin >> n >> m;
    dsu d(n);
    rep (i, m) {
        int a, b; cin >> a >> b;
        a--; b--;
        d.merge(a, b);
    }
    map<int, int> mp;
    rep (i, n) mp[d.leader(i)]++;
    ll ans = 0;
    cout << mp.size() - 1 << "\n";
    /***************************************************/
    /* Use "submit code (with ACL v1)" when using ACL! */
    /***************************************************/
    return 0;
}

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

int main() {
  long long n, m; cin >> n >> m;
  long long ans=0;
  if (n > 2 && m > 2) ans = (n-2)*(m-2);
  else if (n == 1 && m > 2) ans = m-2;
  else if (m == 1 && n > 2) ans = n-2;
  else if (n == 1 && m == 1) ans = 1;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 888
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#ifdef on_linux
	#include <sys/resource.h>
#endif

#ifdef dobby_is_a_free_elf
	#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
	#define trace(...) 0;
#endif

using namespace std;
using namespace __gnu_pbds;


#define all(x)                  (x).begin(), (x).end()
#define between(i,x,y)          ((i) >= (x) && (i) <= (y))
#define DECIMAL(n)              cout << fixed << setprecision(n)
#define fi                      first
#define lbd                     lower_bound
#define mem0(x)                 memset(x, 0, sizeof (x))
#define mem1(x)                 memset(x, -1, sizeof (x))
#define mp                      make_pair
#define pb                      push_back
#define pf                      push_front
#define ppb                     pop_back
#define ppf                     pop_front
#define sc                      second
#define sqr(a)                  ((a) * (a))
#define sz(x)                   (int)((x).size())
#define ubd                     upper_bound

#define int                     long long

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template <typename T>
using ordered_set = tree<T, null_type,
      less<T>,
      rb_tree_tag,
      tree_order_statistics_node_update>;
// find_by_order(k)  returns iterator to kth element starting from 0
// order_of_key(k) returns count of elements strictly smaller than k


const long double PI = 3.14159265358979323846264338;
const double eps = 1e-10;
#ifdef int
	const long long INF = 1e18;
#else
	const long long INF = 1e9;
#endif
const int32_t fftmod = 998244353;
const int32_t MOD = 1000000007;
const int32_t N = 1e5 + 10;
const int32_t NN = 1e6 + 10;



inline void elf_magic(int testcase)
{
	string s, t;
	cin >> s >> t;
	int ans = sz(t);
	for (int i = 0; i + sz(t) <= sz(s); ++i) {
		int x = 0;
		for (int j = 0; j < sz(t); ++j) {
			x += (s[i + j] != t[j]);
		}
		ans = min(ans, x);
	}
	cout << ans;
	return;
}

int32_t main()
{
	#ifdef on_linux
	rlimit cpu_time {.rlim_cur = 2, .rlim_max = RLIM_INFINITY};
	setrlimit(RLIMIT_CPU, &cpu_time);
	#endif

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

	int TESTS = 1;
	//cin >> TESTS;
	for (int i = 1; i <= TESTS; ++i) {
		// cout << "Case #" << i << ": ";
		elf_magic(i);
		if (i != TESTS)	{ cout << '\n'; }
	}
	return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int64_t n,m;
  cin >> n >> m;
  int64_t ans=0;
  if(n*2>=m){
    cout << m/2;
    return 0;
  }
  ans+=n;
  m-=2*n;
  ans+=m/4;
  cout << ans;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

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

int main() {
  int n;
  cin>>n;
  string s;
  map<string,int> m;
  
  rep(i,n){
    cin>>s;
    m[s]++;
  }
  
  int ma=0;
  for(auto x:m){
    ma=max(ma,x.second);
  }
  for(auto x:m){
    if(x.second==ma) cout<<x.first<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 25216
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, m, X, Y; cin >> n >> m >> X >> Y;
    vi x(n); for(auto& e : x) cin >> e, chmax(X, e);
    vi y(m); for(auto& e : y) cin >> e, chmin(Y, e);

    string res = (X < Y ? "No War":"War");
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
s = gets.to_i

current_number = s
past_numbers = [current_number]
(1..1000000).each.with_index(2) do |num, i|
  next_num = current_number.even? ? current_number / 2 : 3 * current_number + 1
  if past_numbers.include?(next_num)
    puts i
    break
  end
  past_numbers << next_num
  current_number = next_num
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                   \
  ifstream in("atcoder-problems/abc082_b.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v) \
rep(l, v.size()) { cout << v[l] << " "; } \
cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18+100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  string s, t;
  cin >> s >> t;

  sort(s.begin(), s.end());
  sort(t.begin(), t.end(), greater<>());

  cout << (s < t ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
If I'm the sun, you're the moon
Because when I go up, you go down
*******************************
I'm working for the day I will surpass you
https://www.a2oj.com/Ladder16.html
*/
import java.util.*;
import java.io.*;
import java.math.*;

   public class Main
   {
      public static void main(String omkar[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));  
         StringTokenizer st = new StringTokenizer(infile.readLine());
         String input = st.nextToken();
         if(input.charAt(2) == input.charAt(3) && input.charAt(4) == input.charAt(5))
            System.out.println("Yes");
         else
            System.out.println("No");
      }
   }

Measured memory_bytes: 21076
#include<bits/stdc++.h>
using namespace std;
int main(){
 int bingo[3][3];
 for(int j = 0;j<3;j++){
  for(int k = 0;k<3;k++){
    cin >> bingo[j][k];
  }
 }
 int n;
 cin >> n;
 int num[n];
 for (int i = 0;i<n;i++){
   cin >> num[i];
   for(int j = 0; j < 3; j++) for(int k = 0; k < 3; k++)
    if(bingo[j][k] == num[i]) bingo[j][k] = -1;
 }
 string ans = "No";
  for(int i = 0; i < 3; i++)
    if(bingo[i][0] == -1 && bingo[i][1] == -1 && bingo[i][2] == -1)
      ans = "Yes";
  for(int i = 0; i < 3; i++)
    if(bingo[0][i] == -1 && bingo[1][i] == -1 && bingo[2][i] == -1)
      ans = "Yes";
  if(bingo[0][0] == -1 && bingo[1][1] == -1 && bingo[2][2] == -1)
    ans = "Yes";
  if(bingo[0][2] == -1 && bingo[1][1] == -1 && bingo[2][0] == -1)
    ans = "Yes";
  cout << ans;
  return 0;
  }

Measured memory_bytes: 764
import qualified Data.Vector         as V
import qualified Data.Vector.Mutable as VM
import Control.Applicative
import Control.Monad
import Data.IORef
import Text.Printf

type Process = (String, Int)

roundRobin :: Int -> [Process] -> IO ()
roundRobin q xs = do
  queue <- V.thaw $ V.fromList (xs ++ [("String", 0)])
  front <- newIORef 0
  rear  <- newIORef $ length xs
  loop q 0 queue front rear
  where
    n = length xs
    loop q t queue front rear = do
      f <- readIORef front
      r <- readIORef rear
      when (f /= r) $ do
        i <- readIORef front
        writeIORef front (if i == n then 0 else i + 1)
        (name, time) <- VM.read queue i
        if time <= q
          then do
          printf "%s %d\n" name (t + time)
          loop q (t + time) queue front rear
          else do
          j <- readIORef rear
          writeIORef rear (if j == n then 0 else j + 1)
          VM.write queue j (name, time - q)
          loop q (t + q) queue front rear

main :: IO ()
main = do
  [n, q] <- map read . words <$> getLine
  xs <- map (toTuple . words) <$> replicateM n getLine
  roundRobin q xs
    where toTuple [n, t]  = (n, read t)



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

struct KnapsackNolim { // 個数制限なし
    void add_item(int vi, int wi){ v.push_back(vi); w.push_back(wi);}
    int solve(int W){
        int n=v.size(); vector<int> dp(W+1,0);
        for(int i=0;i<n;++i)
            for(int j=w[i];j<W+1;++j)
                dp[j] = max(dp[j],dp[j-w[i]]+v[i]);
        return dp[W];
    }
    vector<int> v, w;  // val, wei
};

int main(){
  int N, W, v, w;
  cin >> N >> W;
  KnapsackNolim k;
  for(int i=0;i<N;++i){
    cin >> v >> w;
    k.add_item(v,w);
  }
  cout << k.solve(W) << endl;
}


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

int main() {
	int i, j;
	for (i = 1; i < 10; i++) {
		for (j = 1; j < 10; j++) {
			cout << i << "x" << j << "=" << i * j << endl;
		}
	}
	return 0;
}


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

vector< vector < int > > adjMatrix;

int findMSTCost(int n) {
  vector< bool > visited (n, false);
  visited[0] = true;
  int cost = 0;
  for (int numberVertices = 1; numberVertices < n; numberVertices++) {
    int minEdge = 3000, minVertex = n;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
	if ((i != j) &&
	    (visited[i] == true) &&
	    (visited[j] == false) &&
	    (adjMatrix[i][j] != -1) &&
	    (adjMatrix[i][j] < minEdge)) {
	  minEdge = adjMatrix[i][j];
	  minVertex = j;
	}
      }
    }
    cost += minEdge;
    visited[minVertex] = true;
  }
  return cost;
}

int main(int argc, char **argv) {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  adjMatrix = vector< vector < int > > (n, vector< int > (n, 0));
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      cin >> adjMatrix[i][j];
  cout << findMSTCost(n) << endl;
  return 0;
}



Measured memory_bytes: 3208
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <climits>
#include <cassert>
#include <algorithm>
#include <utility>

using namespace std;
using Int = long long int;
using UInt = unsigned long long int;
using VI = vector<long long int>;
using VVI = vector<vector<long long int> >;

int main(void) {
    string s;
    cin >> s;

    string result = "";
    for (Int i = 0; i < (Int)s.length(); ++i) {
        // 0か1が入力されたらその文字を追加し，Bが入力されたら文字列の一番右の文字を消す
        if (s[i] == '0' || s[i] == '1') {
            // 末尾に文字を挿入する
            result += s[i];
        } else if (s[i] == 'B' && result != "") {
            // 末尾の文字を削除する
            result.pop_back();
        }
    }
    cout << result << endl;
    return 0;
}



Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define fi first
#define se second
#define pb push_back
#define rep(i, s, n) for (int i = s; i < n; i++)
#define rrep(i, s, n) for (int i = (n)-1; i >= (s); i--)
#define all(a) a.begin(),a.end()
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
const long long MOD = 1000000007, INF = 1e18;
 
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
 
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}

template<typename T>vector<T>
make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
	for(auto &e:t) fill_v(e,v);
}

void pv(vector<int>&v){
	for(int i = 0;i<v.size();i++){
		if(i)cout<<' ';
		cout<<v[i];
	}
	cout<<endl;
}

const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

long long H(int n,int k){
    return COM(n+k-1,k);
}

signed main()
{
	IOS();
	COMinit();
	int N,M,K;
	cin>>N>>M>>K;
	int t = COM(N*M-2,K-2);
	int s = 0;
	rep(i,1,N){
		(s += (N - i) * i)%=MOD;
	}
	(t *= (M * M) % MOD)%=MOD;
	(t *= s)%=MOD;
	int ans = t;
	swap(N,M);
	t = COM(N*M-2,K-2);
	s = 0;
	rep(i,1,N){
		(s += (N - i) * i)%=MOD;
	}
	(t *= (M * M) % MOD)%=MOD;
	(t *= s)%=MOD;
	cout<<(ans+t)%MOD<<endl;
}


Measured memory_bytes: 12160