akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)

using namespace std;

int main(){
    int H;
    while(cin >> H && H > 0) {
        int grid[55][55];
        int W = 5;
        REP(y, H) REP(x, W) cin >> grid[y][x];
        int ans = 0;
        REP(_, H * W) {
            bool d[55][55] = {};
            REP(y, H) {
                int c = 1;
                for(int x = 1; x < W; x++) {
                    if(grid[y][x] == grid[y][x - 1]) {
                        c++;
                        if(c >= 3) {
                            REP(i, c) {
                                d[y][x - i] = true;
                            }
                        }
                    } else {
                        c = 1;
                    }
                }
            }
            REP(y, H) REP(x, W) if(d[y][x]) ans += grid[y][x];
            REP(y, H) REP(x, W) if(d[y][x]) grid[y][x] = 0;
            REP(__, H * W) REP(y, H - 1) REP(x, W) if(grid[y][x] > 0 && grid[y + 1][x] == 0) swap(grid[y + 1][x], grid[y][x]);
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1168
n, m, x, y = map(int, input().split())
xs = max(list(map(int, input().split())))
ys = min(list(map(int, input().split())))
if x < y:
    flag = True
    for i in range(x + 1, y + 1):
        if i > xs and ys >= i:
            flag = False
            print('No War')
            break
    if flag:
        print('War')
else:
    print('War')


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define N 200006
using namespace std;
int n,m;char c[N],a[N];
int main()
{
	scanf("%s",c+1);n=strlen(c+1);
	for(int i=1;i<=n;i++){
		if(m&&a[m]=='S'&&c[i]=='T')m--;
		else a[++m]=c[i];
	}
	printf("%d\n",m);
}

Measured memory_bytes: 640
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

a, b, x = MAP()

ans = b // x - (a-1) // x
print(ans)


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


void solve(void) {
  ll N, M; cin >> N >> M;
  vector<pair<ll, string> > submit(M);
  for(ll mi = 0; mi < M; ++mi) {
    ll first;
    string second;
    cin >> first >> second;
    submit[mi] = make_pair(first-1, second);
  }

  vector<bool> is_ac_judged(N, false);
  vector<ll> num_wa_submitted(N, 0);

  ll score = 0, penalty = 0;

  for (ll i = 0; i < M; ++i) {

    // ACが出た問題ならスルー
    if (is_ac_judged[submit[i].first] == true) continue;

    // 初めてのAC
    if(submit[i].second == "AC") is_ac_judged[submit[i].first] = true;
    else num_wa_submitted[submit[i].first]++;
  }
  
  for(ll i = 0; i < N; ++i) {
    if (is_ac_judged[i] == true) {
      score++;
      penalty += num_wa_submitted[i];
    }
  }

  cout << score << " " << penalty << endl;
}


int main(void) {
  solve();
  return 0;
}

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

ll R,S,P;

ll po(char x){
    if(x == 'p') return S;
    if(x == 's') return R;
    if(x == 'r') return P;
}

ll f(vector<char> A){
    ll L = A.size();
    ll sum = 0;
    bool flag = true;
    rep(i,L){
        if(i == 0) sum += po(A[i]);
        else{
            if(A[i] != A[i-1]){
                sum += po(A[i]);
                flag = true;
            }
            else{
                flag = !flag;
                if(flag) sum += po(A[i]);
            }
        }
    }
    return sum;
}

int main(){
    int N,K; cin >> N >> K >> R >> S >> P;
    string T; cin >> T;
    vector<vector<char>> str(K);
    rep(i,N){
        str[i%K].push_back(T[i]);
    }
    ll ans = 0;
    rep(i,K){
        ans += f(str[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 7936
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>

using namespace std;

typedef long long ll;

ll mod(ll x,ll m){
  return (m+x%m)%m;
}

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

ll mod_inv(ll a,ll m){
  ll x,y;
  extgcd(a,m,x,y);
  return mod(x,m);
}

ll m1=999979,m2=999983;

ll solve(ll x,int o,ll y){
  ll a=0,b=0,p,q;

  if(o==1)a=mod(x+y,m1),b=mod(x+y,m2);
  if(o==2)a=(x-y+m1)%m1,b=(x-y+m2)%m2;
  if(o==3)a=mod(x*y,m1),b=mod(x*y,m2);
  if(o==4)a=(x*mod_inv(y,m1))%m1,b=(x*mod_inv(y,m2))%m2;
  
  extgcd(m1,m2,p,q);
  
  return (b*m1*p+a*m2*q)%(m1*m2);
}

int main(void){
  ll n,o,x=0,y;

  cin >> n;

  while(n--){
    cin >> o >> y;
    x=solve(x,o,y);
  }
  cout << x << endl;
  return 0;
}

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

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

using ll = long long;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1<<30;
const ll mod = 1000000007LL;

int main() {
  ll N,A,B,C,D;
  cin>>N>>A>>B>>C>>D;
  N--;
  ll t = B-A;
  if(C+D!=0LL){
    ll u = (D*N-t)/(C+D), d=((C*N-1LL-t)/(C+D))+1LL;
    if(u-d>=0LL&&!(u<0||d>N)){
      cout<<"YES"<<endl;
    }
    else cout<<"NO"<<endl;
  }
  if(C+D==0LL){
    if(t == 0LL) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
  }
}

Measured memory_bytes: 256
import sys, re
from math import ceil, floor, sqrt, pi, factorial#, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left
from functools import reduce
input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_list(N): return [s_list() for _ in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7

def mod_cmb(n: int, k: int, p: int) -> int:
    if n < 0 or k < 0 or n < k: return 0
    if n == 0 or k == 0: return 1
    if (k > n - k):
        return mod_cmb(n, n - k, p)
    c = d = 1
    for i in range(k):
        c *= (n - i)
        d *= (k - i)
        c %= p
        d %= p
    return c * pow(d, p - 2, p) % p

def main():
    x, y = i_map()

    if (x+y)%3 != 0:
        print(0)
        exit()

    a = int((2*x-y) / 3)
    b = int((-x+2*y) / 3)

    if a < 0 or b < 0:
        print(0)
        exit()

    print(mod_cmb(a+b,a,MOD))

if __name__ == '__main__':
    main()


Measured memory_bytes: 3828
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int) n; i++)
using ll = long long;
template <class T>
using vt = std::vector<T>;
using vvi = std::vector<vt<int>>;

int main(){
  int n;
  std::cin >> n;

  std::map<int, int> A;
  rep(i,n) {
    int num;
    std::cin >> num;
    A[num]++;
  }

  int cnt = 0;
  for(auto& a : A){
    cnt += a.second%2;
  }

  std::cout << cnt << '\n';
  return 0;
}


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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

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

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll N, K;
  cin >> N >> K;
  ll max_val = 0;
  ll sum = 0;
  
  vector<ll> H(N);
  rep(i, N){
    cin >> H[i];
    sum += H[i];
  }

  sort(H.rbegin(), H.rend());

  ll sum_sub = 0;
  for(int i = 0; i < min(N, K); i++){
    sum_sub += H[i];
  }

  cout << sum - sum_sub << endl;


  return 0;
}


Measured memory_bytes: 1920
#include<bits/stdc++.h>
#define slowanddetermined ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define debug(x); cout<<#x<<"="<<x<<endl;
#define debug2(x,y); cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl;
#define int long long
using namespace std;
int mod=1e9+7;

int dp[100007][13];
int32_t main()
{
    
    string s;
    cin>>s;

    int n=s.size();
    dp[0][0]=1;

    for(int i=0;i<n;i++){

        for(int j=0;j<10;j++){ //to try all the numbers in case of que mark
            if(s[i]=='?'){
                for(int k=0;k<13;k++){
                    dp[i+1][(k*10+j)%13]+=dp[i][k];  //j is the digit selected k is the previous digit selected so (10*k+j)%13=k%13
                    dp[i+1][(k*10+j)%13]%=mod;
                }
            }
            else{
                    for(int k=0;k<13;k++){
                    dp[i+1][(k*10+(s[i]-'0'))%13]+=dp[i][k];
                    dp[i+1][(k*10+(s[i]-'0'))%13]%=mod;
                }
                break; //only one number that is s[i]-'0' to try
            }
        }
    }


    cout<<dp[n][5]<<endl;





    return 0;

}


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

int main(){
  int N,L;
  cin >> N >> L;
  vector<int> a(N);
  int sum = 0;
  for(int i = 0;i < N;i++){
    a[i] = L + (i+1) - 1;
    sum += L + (i+1) - 1;
  }

  int hikaku = abs(a[0]);
  int ans = sum - a[0];
  for(int i = 1;i < N;i++){
    if(abs(a[i]) < hikaku){
      hikaku = abs(a[i]);
      ans = sum - a[i];
    }
  }

  cout << ans << endl;
}


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

#define all(x) (x).begin(),(x).end()
#define fastio ios_base::sync_with_stdio(false)

typedef double db;
typedef long long ll;
typedef unsigned long long ull;

typedef long double ldb;
typedef pair <int,int> pii;
typedef pair <ll, ll> pll;

int main() {
	fastio;
	int s,w; cin >> s >> w;
	if(w >= s) cout << "unsafe" << endl;
	else
		cout << "safe" << endl;
	return 0;
}

Measured memory_bytes: 3616
#pragma GCC optimize("Ofast",3,"inline")
#include<bits/stdc++.h>
using namespace std;
#define fir first
#define sec second
#define m_p make_pair
#define y1 ygftgfgcdtfgxffgx
#define y2 yfdsesgvtyghftfvv
#define x1 xvyr6cf6fgcfgf676
#define x2 xcr6rfc5r66y6r6fr
#define up_bound upper_bound
#define low_bound lower_bound
#define next_per next_permutation
#define pb push_back
#define i_to_s to_string
typedef priority_queue<int> p_queue;
typedef priority_queue<int, vector<int>, greater<int> > min_p_queue;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int mon[20]={31,28,31,30,31,30,31,31,30,31,30,31};
ll gcd(ll x,ll y){return ((y==0)?x:gcd(y,x%y));}
string s;
string t1,t2;
int n,a,b;
bool palindrome(string s){
	int p1=0,p2=s.size()-1;
	while(p1<=p2){
		if(s[p1]!=s[p2])return 0;
		p1++,p2--;
	}
	return 1;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	cin>>s;
	n=s.size();
	a=(n-1)/2;
	b=(n+3)/2;
	t1=s.substr(0,a);
	t2=s.substr(b-1,n-b+1);
//	cout<<t1<<' '<<t2<<'\n';
	if(palindrome(s)==0||palindrome(t1)==0||palindrome(t2)==0)cout<<"No";
	else cout<<"Yes";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <functional>
#include <random>
#include <time.h>
#include <chrono>
#include <sstream>
#include <iomanip>
#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 ll long long
#define INF 1000000001
#define mod 1000000007
#define sort(s) sort(s.begin(), s.end());
#define reverse(s) reverse(s.begin(), s.end());
#define P pair<int,int>
#define valid(x,y,h,w) (0<=x&&x<h&&0<=y&&y<w)
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
using namespace std;
int POW(int x, int y) { return int(pow(double(x), double(y))); }
double log(double a, double b) { return log(b) / log(a); }


int main() {
	int n, m;
	cin >> n >> m;
	vector<pair<int,int>> x(n);
	rep(i, n) {
		int a, b;
		cin >> a >> b;
		x[i] = make_pair(a, b);
	}
	sort(x);
	ll ans = 0;
	int h = 0;
	rep(i, n) {
		int a, b;
		a = x[i].first;
		b = x[i].second;
		if (h + b < m) {
			h += b;
			ans += (ll)a*b;
		}
		else {
			ans += (ll)a*(m - h);
			cout << ans << endl;
			return 0;
		}
	}
}



Measured memory_bytes: 1024
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
#define MOD 1000000007
using namespace std;

char str0[100005];
char str1[100005];

ll gcd(ll a, ll b) {
    if(b == 0) return a;
    return gcd(b,a%b);
}
 
ll lcm(ll a, ll b) {
    ll g = gcd(a,b);
    return a / g * b;   // Be careful not to overflow
}

int main(int argc, char* argv[])
{    
    long n, m;
    scanf("%ld%ld", &n, &m);

    if(n<=m) {
        scanf("%s", str0);
        scanf("%s", str1);
    }
    else {
        scanf("%s", str1);
        scanf("%s", str0);
        long tmp=n; n=m; m=tmp;
    }

    long i;
    if(m%n==0) {
        for(i=0; i<n; i++) {
            if(str0[i]!=str1[i*(m/n)]) {
                printf("-1\n"); return 0;
            }
        }
        printf("%ld\n", m);
    }
    else {
        ll aa = lcm(m,n);
        long bb = (ll)m * n / aa;
        for(i=0; i<bb; i++) {
            if(str0[i*(n/bb)]!=str1[i*(m/bb)]) {
                printf("-1\n"); return 0;
            }
        }
        printf("%ld\n", aa);
    }

    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    int n;
    std::cin >> n;
    int m = n / 2 * 2;
    std::deque<std::pair<int, int>> q;
    for (int i = 2; i <= m / 2; i++) {
        for (int j = 1; j < i; j++) {
            q.emplace_back(i, j);
            q.emplace_back(m - i + 1, j);
            q.emplace_back(i, m - j + 1);
            q.emplace_back(m - i + 1, m - j + 1);
        }
    }
    if (n % 2) {
        for (int i = 1; i <= m; i++) {
            q.emplace_back(i, n);
        }
    }
    std::cout << q.size() << std::endl;
    for (auto &el : q) std::cout << el.first << " " << el.second << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>

using namespace std;
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; }

typedef unsigned int uint;
typedef long long llong;
typedef unsigned long long ullong;
typedef long double lldouble;

typedef vector<llong> vecllong;
typedef vector<vecllong> vvecllong;

const llong MOD = 1e9 + 7;
const llong INF = 1e17;

#define FOR(i, n) for (llong i = 0; i < n; i++)
#define FORS(i, a, b) for (llong i = a; i < b; i++)
#define FORR(i, n) for (llong i = n; i > 0; i++)

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

    llong N;
    cin >> N;

    vecllong A(N);
    llong maxIndex = 0;
    llong minIndex = 0;
    FOR(i, N) {
        cin >> A[i];
        if(A[maxIndex] < A[i]) maxIndex = i;
        if(A[minIndex] > A[i]) minIndex = i;
    }

    if(A[maxIndex] + A[minIndex] >= 0) {
        cout << (N + N - 1) << endl;
        FORS(i, 1, N + 1) {
            if(i == maxIndex + 1) continue;
            printf("%lld %lld\n", maxIndex + 1, i);  // すべて正にする
        }
        printf("%lld %lld\n", maxIndex + 1, maxIndex + 1);
        FORS(i, 1, N) {
            printf("%lld %lld\n", i, i + 1);
        }
    } else {
        cout << (N + N - 1) << endl;
        FORS(i, 1, N + 1) {
            if(i == minIndex + 1) continue;
            printf("%lld %lld\n", minIndex + 1, i);  // すべて負にする
        }
        printf("%lld %lld\n", minIndex + 1, minIndex + 1);
        for(llong i = N; i > 1; i--) {
            printf("%lld %lld\n", i, i - 1);
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int D;
vector<int> C;
vector<vector<int>> S;

long long getTime() {
	timespec ts;
	clock_gettime(CLOCK_REALTIME_COARSE, &ts);
	long long r = ts.tv_sec;
	r *= 1000000000;
	r += ts.tv_nsec;
	return r;
}

ll calcScore(const vector<int>& T) {
	vector<int> last(26);
	ll score = 0;
	for (int d = 1; d <= D; ++ d) {
		int i = T[d-1];
		last[i] = d;
		score += S[d-1][i];
		for (int j = 0; j < 26; ++ j) {
			score -= C[j] * (d - last[j]);
		}
	}
	return score;
}

int main() {
	auto startTime = getTime();

	cin >> D;
	C.resize(26);
	for (auto& x : C) cin >> x;
	S = vector<vector<int>>(D, vector<int>(26));
	for (auto& x : S) for (auto& y : x) cin >> y;

	ll maxScore = -(1LL<<60);
	vector<int> ans;
	vector<int> res(D);
	for (int i = 0; i < D; ++ i) {
		res[i] = 0;
		for (int j = 1; j < 26; ++ j) {
			if (S[i][j] > S[i][res[i]]) res[i] = j;
		}
	}
	auto s = calcScore(res);
	if (s > maxScore) { maxScore = s; ans = res; }
	for (int tt = 1; ; ++ tt) {
		if (tt % 1024 == 0 && getTime() - startTime >= 1900000000) break;
		int i = rand() % D;
		int tmp = res[i];
		res[i] = rand() % 25 + 1;
		if (tmp == res[i]) res[i] = 0;
		auto s1 = calcScore(res);
		if (s1 > s) { s = s1; }
		else { res[i] = tmp; }
		if (s1 > maxScore) { maxScore = s1; ans = res; }
	}
	for (auto x : ans) cout << x + 1 << endl;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i < (int)(n); i++)
#define Sort(a) sort(a.begin(), a.end())
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
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;}

int main(){
    ll x;
    cin >> x;
    bool flag = false;
    //int tmp = pow(x, 0.2);
    for(int a = 1; a <= 120; a++){
        for(int b = -a+1; b < a; b++){
            if(x%(a-b) == 0){
                ll a_5 = pow(a, 5);
                ll b_5 = pow(b, 5);
                    //cout << a << " " << b << " ";
                    //cout << a_5 << " " << b_5 << endl;
                if(x == a_5 - b_5){
                    cout << a << " " << b << endl;
                    flag = true;
                    break;
                }
            }
        }
        if(flag) break;
    }
    return 0;
}

Measured memory_bytes: 4100
import java.util.Scanner;

public class Main{
    public static void main(String[] args) { 
        try (Scanner sc = new Scanner(System.in)) { 
            String line = sc.nextLine();  
            int length = line.length(); 
            for (int i = 0; i < length; i++) { 
                char ch = line.charAt(i);
                if(Character.isLowerCase(ch)){
                    ch = Character.toUpperCase(ch);
                }else{
                    ch = Character.toLowerCase(ch);
                }
                System.out.printf("%c",ch);
            }
            System.out.println();
        }
    }
}


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

using namespace std;

typedef long long int ll;

int main(void)
{
	int n;
	vector<ll> a;
	cin >> n;
	map<ll, ll> m;
	ll aaa = 0;
	for (int i = 0; i < n; ++i)
	{
		ll ai;
		cin >> ai;
		aaa = aaa ^ ai;
		m[ai]++;
		a.push_back(ai);
	}
	if (aaa == 0)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 5748
import java.util.Scanner;
import java.util.Arrays;
 
public class Main {
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			Integer bar[] = {1, 9, 7, 4};

			int in_bar[] = new int[4];

			for (int i=0; i<4; i++) {
				in_bar[i] = sc.nextInt();
			}
			
			int ok_count = 0;

			for (int i=0; i<4; i++) {
				for (int j=0; j<4; j++) {
					if (bar[i] == in_bar[j]) {
						ok_count++;
						break;
					}
				}
			}
			
			if (ok_count == 4) {
				System.out.println("YES");
			} else {
				System.out.println("NO");
			}

		}
	}
}

Measured memory_bytes: 21844
'use strict'

const main = (INPUT) => {
  const input = INPUT.split('\n')
  const N = Number(input[0].split(' ')[0])
  const H = Number(input[0].split(' ')[1])
  const W = Number(input[0].split(' ')[2])
  const ary = input.slice(1)

  let cnt = 0
  for (let i = 0; i < N; i++) {
    let A = Number(ary[i].split(' ')[0])
    let B = Number(ary[i].split(' ')[1])
    if (H <= A && W <= B) {
      cnt++
    }
  }
  console.log(cnt)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 22084
#include <algorithm>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;

int main() {
  int N;
  while (cin >> N) {
    vector<ll> A(N), B(N);
    for (int i = 0; i < N; i++) {
      cin >> A[i] >> B[i];
    }
    ll add = 0;
    for (int i = N - 1; i >= 0; i--) {
      add += (B[i] - (A[i] + add) % B[i]) % B[i];
    }
    cout << add << endl;
  }
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define FIN         ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ii          pair<int,int>
#define F           first
#define S           second
#define pb          push_back
#define all(x)      (x).begin(),(x).end()
#define rall(x)     (x).rbegin(),(x).rend()
#define fore(i,a,b) for(int i = a;i < b; i+= 1)
#define forr(i,a)   for(int i = a; i >= 0; i--)
#define fori(i,m)   for(auto i = m.begin(); i != m.end(); i++) 
#define w(t)        while(t--)
#define sz(s)       int(s.size())
#define cls(a,car)  memset(a,car,sizeof (a))
#define db(x)       cerr << #x << " is " << x << '\n'
#define FI          freopen("input.txt", "r", stdin)
#define FO          freopen("output.txt", "w", stdout)
#define EjecuteTime cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
#define angle(x)    double(x * acos(-1) / 180.0)
using namespace std;
typedef long long   ll;
typedef vector<int> vi;
typedef vector<ii>  vii;
const int N = 3e3 + 5;
const ll mod = 1e9 + 7;
const double E = 1e-9;
int dx[] = {1, 0}, dy[] = {0, 1};
//int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
//int dx[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy[] = {0, 1, 1, 1, 0, -1, -1, -1};
//int dx[] = {2, 1, -1, -2, -2, -1, 1, 2}, dy[] = {1, 2, 2, 1, -1, -2, -2, -1};
// fflush(stdout)
// cout << flush
// a + b = a ^ b + 2 * (a & b)
int r, c, k;
int arr[N][N];
ll dp[N][N][4];
ll f(int i, int j, int row){
    if(i + 1 == r && j + 1 == c){
        if(row < 3)
            return arr[i][j];
        return 0;
    }
    ll &ans = dp[i][j][row];
    if(ans == -1){
        ans = 0;
        for(int k = 0; k < 2; k++){
            int _i = i + dx[k];
            int _j = j + dy[k];
            if(_i >= 0 && _i < r && _j >= 0 && _j < c){
                if(!k){//down
                    if(row < 3)
                    ans = max(ans, f(_i, _j, 0) + arr[i][j]);
                    ans = max(ans, f(_i, _j, 0));                   
                }else{// right
                    if(row < 3)
                        ans = max(ans, f(_i, _j, row + 1) + arr[i][j]);
                    ans = max(ans, f(_i, _j, row));
                }
            }
        }
    }
    return ans;
}
int main(){
    FIN;
    cin >> r >> c >> k;
    for(int i = 0; i < k; ++i){
        int u, v, w;
        cin >> u >> v >> w;
        u--;
        v--;
        arr[u][v] = w;
    }
    /*for(int i = 0; i < r; i++){
        for(int j = 0; j < c; j++)
            cout << arr[i][j] << ' ';
        cout << endl;
    }*/
    for(int i = 0; i < r; i++)
        for(int j = 0; j < c; j++)
            for(int k = 0; k < 4; k++)
                    dp[i][j][k] = -1;
    cout << f(0, 0, 0) << '\n';
    EjecuteTime;
    return 0;
}       


Measured memory_bytes: 321308
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define F first
#define S second
#define endl "\n"
#define nl cout<<endl
#define pb push_back
#define f(i,a,b) for(ll i=a;i<b;i++)
#define Knucklehead ios_base::sync_with_stdio(false);cin.tie(NULL);
#define txti freopen("input.txt", "r", stdin);
#define txto freopen("output.txt", "w", stdout);
//#define mod 100000007

#define mat vector<vector<ll>>
mat cn(ll n, ll m){return vector< vector<ll> >(n, vector<ll>(m));}
bool compare(char &s1,char &s2){return s1 > s2;} 

bool sortmahstyle(const pair<ll,ll> &a,  const pair<ll,ll> &b) 
{ 
    if(a.second > b.second )
        return true;
    if( a.second==b.second && a.first > b.second )
       return true;
 
    return false;
 }
//me
ll const mod = 1e9;
ll const inf = 2e5+1;

void solve()
{   

    ll n,l; cin >> n >> l;

    string a[n]; f(i,0,n) cin>> a[i];

    sort(a,a+n);
    f(i,0,n)
        cout << a[i];
    nl;
}

int main() {
Knucklehead 
//*
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
/**/


        
        ll t;
        /**/t=1;
        /*/cin>>t;/**/
        f(testcases,0,t){
            solve();
        }
 
 
 
 
    return 0;
}

Measured memory_bytes: 3640
#include<iostream>
using namespace std;
long long sum;
long long a, b, n; char s;
int main() {
	cin >> n;
	while (cin >> a >> s >> b) {
		if (s == '(') { sum += b; }
		else { sum -= b; }
		if (sum == 0) { cout << "Yes" << endl; }
		else { cout << "No"<<endl; }
	}
}

Measured memory_bytes: 1156
using System;
using System.Linq;

class B{
  static void Main(){
    int N = int.Parse(Console.ReadLine());
    int[] d = new int[N];
    for (int i = 0; i < N; i++){
      d[i] = int.Parse(Console.ReadLine());
    }
    var ans = d.Distinct().ToArray();
    Console.WriteLine(ans.Length);
  }
}

Measured memory_bytes: 18644
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))

flag = True
for i in range(n - 1):
    if a[i + 1] - a[i] >= 2:
        flag = False
if a[0] != 0:
    flag = False

count = 0
if flag == True:
    for i in range(n - 1):
        if a[i] != 0:
            count = count + 1
        if a[i] >= a[i + 1]:
            count = count + max(0, a[i + 1] - 1)
   
if flag == False:
    print(-1)
elif a[n - 1] != 0:
    print(count + 1)
else:
    print(count)

Measured memory_bytes: 11052
package main

import (
	"bufio"
	_ "container/heap"
	"fmt"
	"os"
	_ "sort"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	return a / gcd(a, b) * b
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
const MOD = int(1e+9) + 7
const INF = 1 << 60

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	defer wtr.Flush()
	S := sc.nextStr()
	Q := sc.nextInt()
	var changed bool
	var front, back []rune
	for i := 0; i < Q; i++ {
		query := sc.nextInt()
		if query == 1 {
			changed = !changed
		} else {
			f := sc.nextInt()
			c := sc.nextRuneSlice()[0]
			if changed {
				if f == 1 {
					back = append(back, c)
				} else {
					front = append(front, c)
				}
			} else {
				if f == 1 {
					front = append(front, c)
				} else {
					back = append(back, c)
				}
			}
		}
	}
	if !changed {
		for i := len(front) - 1; i >= 0; i-- {
			fmt.Fprint(wtr, string(front[i]))
		}
		fmt.Fprint(wtr, S)
		for i := 0; i < len(back); i++ {
			fmt.Fprint(wtr, string(back[i]))
		}
	} else {
		for i := len(back) - 1; i >= 0; i-- {
			fmt.Fprint(wtr, string(back[i]))
		}
		for i := len(S) - 1; i >= 0; i-- {
			fmt.Fprint(wtr, string(S[i]))
		}
		for i := 0; i < len(front); i++ {
			fmt.Fprint(wtr, string(front[i]))
		}
	}
	fmt.Fprintln(wtr)
}


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

using namespace std;

const int N=1e5+10;
vector<int> G[N];
int dep[N];
int parent[N][20];

void init(int n)
{
    for(int i=1;i<20;i++)
    {
        for(int v=0;v<n;v++)
        {
            parent[v][i]=parent[v][i-1]==-1?-1:parent[parent[v][i-1]][i-1];
        }
    }
}

int lca(int u,int v)
{
    if(dep[u]>dep[v]) swap(u,v);
    for(int i=19;i>=0;i--)
    {
        if(parent[v][i]!=-1&&dep[parent[v][i]]>=dep[u])
        {
            v=parent[v][i];
        }
    }
    if(u==v) return u;
    for(int i=19;i>=0;i--)
    {
        if(parent[u][i]!=parent[v][i])
        {
            u=parent[u][i];
            v=parent[v][i];
        }
    }
    return parent[u][0];
}

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

    parent[0][0]=-1;
    for(int i=0;i<n;i++)
    {
        int k;
        cin>>k;
        while(k--)
        {
            int c;
            cin>>c;
            parent[c][0]=i;
            dep[c]=dep[i]+1;
        }
    }

    init(n);

    int q;
    cin>>q;
    while(q--)
    {
        int u,v;
        cin>>u>>v;
        cout<<lca(u,v)<<endl;
    }

    return 0;
}



Measured memory_bytes: 13648
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define fo(i,j,n) for (int i=(j); i < (n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() {    
    int n, m; cin >> n >> m;
    vector<pll> drinks(n);
    rep(i, n){
        ll a, b; cin >> a >> b;
        drinks[i] = pll(a, b);
    }
    sort(all(drinks));

    ll res = 0, cnt = 0;
    rep(i, n){
        if(m - cnt > drinks[i].second){ //必要本数 > 購入可能本数
            res += drinks[i].first * drinks[i].second;
            cnt += drinks[i].second;
        }else{
            res += (m - cnt) * drinks[i].first;
            break;
        }
    }
    cout << res << ln;
} 


Measured memory_bytes: 1792
#ifdef DEBUG_IS_VALID
#define DEB 1 
#define _LIBCPP_DEBUG 0
#else
#define DEB 0
#define NDEBUG
#endif

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

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#define fi first
#define se second
#pragma GCC optimize ("-O3")

using namespace std;

#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T1,typename T2>ostream& operator << (ostream& os, pair<T1,T2> p){cout << "(" << p.first << ", " << p.second << ")"; return os;}
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
template<typename T>ostream& operator << (ostream& os, set<T>& st){cout << "{"; for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << (next(itr)!=st.end() ? ", " : ""); cout << "}"; return os;}
template<typename T1,typename T2>ostream& operator << (ostream& os, map<T1,T2> mp){cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) cout << "(" << (itr->first) << ", " << (itr->second) << ")" << (next(itr)!=mp.end() ? "," : ""); cout << "}"; return os; }

void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline bool chmax(T& a,T const& b){if(a>=b) return false; a=b; return true;}
template<class T> inline bool chmin(T& a,T const& b){if(a<=b) return false; a=b; return true;}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vp = vector<Pl>;
using vvp = vector<vp>;

const int INF = 1<<29;
const long long LINF=1LL<<59;

const string YES = "Yes";
const string NO = "No";
void yn(bool ok){
  cout << (ok ? YES : NO) << endl;
}

void solve(){
  ll N; cin >> N ;
  ll p = 1LL<<N;
  multiset<ll> S,T;
  rep(i,p){
    ll x;
    cin >> x ;
    S.insert(-x);
  }
  {
    auto itr = S.begin();
    T.insert(*itr);
    S.erase(itr);
  }
  rep(i,N){
    vl temp;
    for(auto itr = T.begin(); itr != T.end(); itr++){
      // Sから*itr より大きい要素で最大のを消す
      auto itr2 = S.upper_bound(*itr);
      if(itr2==S.end()){
        cout << NO << endl;
        return;
      }
      temp.pb(*itr2);
      S.erase(itr2);
    }
    for(auto x:temp) T.insert(x);
  }
  cout << YES << endl;
}

int main(){
  std::cout << std::fixed << std::setprecision(15);
  solve();
  // Failed to predict input format
  return 0;
}


Measured memory_bytes: 14068
#include <bits/stdc++.h>
 
#define loop(n, i) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define HERE cout << "HERE: " << __LINE__ << endl;
#define INSP(v) cout << v << " at " << __LINE__ << endl;

using namespace std;
typedef long long ll;
//typedef pair<int, int> P;
typedef struct { int w, d; } P;

int main()
{
    while (1) {
        int n, w, d; cin >> n >> w >> d;
        if (!w) break;
        vector<P> C = {{ w, d }};

        loop (n, i) {
            int p, s; cin >> p >> s;
            P c = C[p-1];
            C.erase(C.begin()+p-1);
            vector<P> cs;
            s %= c.w + c.d;
            if (s < c.w) cs = {{ s, c.d }, { c.w-s, c.d }};
            else cs = {{ c.w, s-c.w }, { c.w, c.d-(s-c.w) }};
            if (cs[0].w*cs[0].d > cs[1].w*cs[1].d) swap(cs[0], cs[1]);
            C.insert(C.end(), all(cs));
        }

        vector<int> area;
        for (P c : C) area.push_back(c.w * c.d);
        sort(all(area));
        cout << area[0];
        loop (area.size()-1, i) cout << " " << area[i+1];
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3160
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define INF 1e9
typedef long long ll;
using namespace std;

int main() {
    string s; cin >> s;
    int D = 0;
    if(s[0]!='A') D += 1;
    int count = 0;
    REP(i,2,s.size()-1){
        if(s[i]=='C') count += 1;
    }
    if(count!=1) D+=1;
    count = 0;
    rep(i,s.size()){
        if(s[i]>='A' && s[i]<='Z') count += 1;
    }
    if(count!=2) D+=1;
    if(D==0){
        cout << "AC" << endl;
    }else{
        cout << "WA" << endl;
    }

    return 0;
}

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

int main(){
  int N=0 ;
  cin>>N;
  int a[N];
  for(int i=0;i<N;i++){
    cin>>a[i];
  }
  cout <<a[N-1];

  for(int j=N-2;j>=0;j--)
  {cout <<" "<<a[j];
  }
  
  cout <<endl;
  
  return 0;
}



Measured memory_bytes: 3124
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
    int h, w;
    cin >> h >> w;
    vector<vi> d(h, vi(w));
    rep(i, h) rep(j, w) cin >> d[i][j];
    vi ord(h*w);
    rep(i, h*w) ord[i] = i;
    for(int i = 1; i < h; i += 2) {
        int s = w*i;
        int t = s+w;
        reverse(ord.begin()+s, ord.begin()+t);
    }
    vi ans;
    rep(i, h*w-1) {
        int x = ord[i]%w;
        int y = ord[i]/w;
        if(d[y][x]&1) {
            ans.pb(i);
            int nx = ord[i+1]%w;
            int ny = ord[i+1]/w;
            d[ny][nx] += 1;
        }
    }
    cout << ans.size() << endl;
    for(auto& i : ans) {
        int x = ord[i]%w;
        int y = ord[i]/w;
        int nx = ord[i+1]%w;
        int ny = ord[i+1]/w;
        cout << y+1 << " " << x+1 << " " << ny+1 << " " <<  nx+1 << endl;
    }
    return 0;
}

Measured memory_bytes: 4728
import java.util.*;
public class Main {
    public static void main(String[] args){
      // 入力
      Scanner sc = new Scanner(System.in);
      String S = sc.nextLine();
      
      // 判定
      String result;
      if(S.equals("hi") || S.equals("hihi") || S.equals("hihihi") || S.equals("hihihihi") || S.equals("hihihihihi")){
        result = "Yes";
      }else{
        result = "No";
      }
      
      // 出力
      System.out.println(result);
    }

}

Measured memory_bytes: 25300
from collections import deque
S = deque(input())
Q = int(input())
d = 0 # d=0:right, d=1:left
for i in range(Q):
  I = list(input().split())
  if I[0] == "1":
    d ^= 1
  else:
    if d + int(I[1]) == 2:
      S.append(I[2])
    else:
      S.appendleft(I[2])
if d == 1:
  S.reverse()
for s in S:
  print(s, end="")
print()

Measured memory_bytes: 100648
n = int(input())
a = [int(input()) for i in range(n)]

ma = max(a)
count = a.count(ma)
if count >= 2:
    for i in range(n):
        print(ma)
else:
    for i in range(n):
        if a[i] == ma:
            b = a[:i]+a[i+1:]
            print(max(b))
        else:
            print(ma)

Measured memory_bytes: 15604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
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; }

const int MOD = 1000000007;
const int INF = 1e9;

const int mod = 1000000007;
const int inf = 1e9;
#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    string s;
    cin >> s;
    if((s[0] == s[1] && s[1] == s[2]) || (s[1] == s[2] && s[2] == s[3])) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=1;i<=n;++i)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
using namespace std;

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); i++)
#define repi(i,a,b) for (int i=a;i<(b);i++)
#define SIZE_OF_ARRAY(a) (sizeof(a)/sizeof(a[0]))
using namespace std;
typedef long long ll;
  
  int main(void){
    cin.tie(0); //cin高速化
    ios::sync_with_stdio(false); //cin高速化
	int x,a,b;
    cin >> x >> a >> b;
    x -= a;
    x %= b;
    cout << x << endl;
    return 0;
  } 

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    // 自分の得意な言語で
    // Let's チャレンジ！！
    int n;
    scanf("%d",&n);
  	int data[20];
  	for(int i = 0; i< n;i++){
      scanf("%d",&data[i]);
    }
  
    int num = 1;
  	for(int i = 1;i < n;i++){
      	for(int j = i-1;j >= 0;j--){
          	if(data[i] < data[j]){
              break;
            }
          	if(j==0){
              num++;
          	}
        }
    }
    printf("%d",num);
    return 0;
}

Measured memory_bytes: 128
///
// File:  c.go
// Author: ymiyamoto
//
// Created on Thu Mar  1 21:37:20 2018
//
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var S string
	fmt.Scan(&S)

	count := 0
	for i := 0; i < int(1<<uint32(len(S))); i++ {
		tmp := i
		cur := tmp & 1
		start := 0
		for j := 0; j < len(S); j++ {
			if cur != tmp&1 {
				val, _ := strconv.ParseInt(S[start:j], 10, 64)
				count += int(val)
				start = j
			}
			tmp >>= 1
		}
		val, _ := strconv.ParseInt(S[start:len(S)], 10, 64)
		count += int(val)
	}
	fmt.Println(count / 2)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=103,INF=1<<30;
int H,W;
string URDL="URDL",ans;

vector<int> dh={-1,0,1,0},dw={0,1,0,-1};

bool DFS(vector<string> S,pair<int,int> u,int dir,int rem){
    if(rem==0) return true;
    
    for(int k=0;k<4;k++){
        if(abs(dir-k)==2) continue;
        
        int h=u.first,w=u.second;
        
        while(h>=0&&h<H&&w>=0&&w<W){
            if(S[h][w]=='o'){
                S[h][w]='.';
                if(DFS(S,{h,w},k,rem-1)){
                    ans.push_back(URDL[k]);
                    
                    return true;
                }
                S[h][w]='o';
                break;
            }
            
            h+=dh[k];
            w+=dw[k];
        }
    }
    
    return false;
}

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>H>>W;
    int N=0;
    vector<string> S(H);
    pair<int,int> s;
    int sd;
    for(int i=0;i<H;i++){
        cin>>S[i];
        for(int j=0;j<W;j++){
            if(S[i][j]=='o') N++;
            
            for(int k=0;k<4;k++){
                if(S[i][j]==URDL[k]){
                    s={i,j};
                    sd=k;
                    S[i][j]='.';
                }
            }
        }
    }
    
    DFS(S,s,sd,N);
    
    reverse(all(ans));
    
    cout<<ans<<endl;
}



Measured memory_bytes: 3244
#include <iostream>

using namespace std;
char a[100];
int main()
{
    cin >> a;
    if(a[0] == 'Y' && a[1] == 'A' && a[2] == 'K' && a[3] == 'I')cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
def maxHeapify(a, i):
    l = 2*i
    r = 2*i + 1
    if l <= h and a[l] > a[i]:
        largest = l
    else:
        largest = i
    if r <= h and a[r] > a[largest]:
        largest = r
    
    if largest != i:
        a[i], a[largest] = a[largest], a[i]
        maxHeapify(a, largest)

h = int(input())
n = int(0.5*h)
key = list(map(int,input().split()))
key.insert(0,0)

for i in range(n):
    j = n - i
    maxHeapify(key, j)

print("",*key[1:])

Measured memory_bytes: 65996
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

ll DP[2][100005];

int main() {
  string L;
  cin>>L;
  DP[0][0] = 1;
  DP[1][0] = 2;
  for(int i=1;i<L.size();++i) {
    if(L[i]=='1') {
      DP[0][i] = (DP[0][i-1]*3%mod+DP[1][i-1])%mod;
      DP[1][i] = DP[1][i-1]*2%mod;
    }
    else {
      DP[0][i] = DP[0][i-1]*3%mod;
      DP[1][i] = DP[1][i-1];
    }
  }
  cout<<(DP[0][L.size()-1]+DP[1][L.size()-1])%mod<<endl;
}



Measured memory_bytes: 5260
/*input
sardine
*/

//sometimes it's the people who no one imagines anything of 
//who do the things that no one can imagine.

//code author: iamxlr8

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

#define ll long long
#define N 300005

int main() 
{
    string s;
    cin>>s;
    for(ll i=0;i<s.size();i++)
        cout<<"x";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(void) {
	char str;
	cin >> str;
	if (str == 'A') printf("T");
	else if (str == 'T') printf("A");
	else if (str == 'C') printf("G");
	else if (str == 'G') printf("C");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

ll n,res=INF;

int main(){
	cin>>n;
	for(ll i=1;i*i<=n;i++) if(n%i==0) res=min(res,i+n/i-2);
	cout<<res<<endl;
}

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

int main(){
int N;
  cin>>N;
  
  vector<char>S(N);
  for(int i=0; i<N; i++){
   cin>>S[i];
  }
  
  bool ans=false;
  for(int i=0; i<N; i++){
  if(S[i]=='Y'){ans=true;}
  }
  if(ans){cout<<"Four"<<endl;}
    else{cout<<"Three"<<endl;}
}

Measured memory_bytes: 256