akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) \
  for (ll i = static_cast<int>(a); i < static_cast<int>(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, ) (__VA_ARGS__)  // NOLINT
#define chmax(x, a)  do { x = max(x, a); } while(0)
#define chmin(x, a)  do { x = min(x, a); } while(0)

using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<ll,ll> PLL;

template<typename T>
using reversed_priority_queue = \
    std::priority_queue<T, std::vector<T>, std::greater<T> >;

ll dy[] = {0,1,0,-1};
ll dx[] = {1,0,-1,0};
const ll INF = 1e15;
ll d[2000][2000];
char a[2000][2000];

typedef pair<ll, PLL> T;

void solve() {
  rep(y, 2000) rep(x, 2000) d[y][x] = INF;
  reversed_priority_queue<T> q;
  ll Y, X, sy, sx, ey, ex;
  cin >> Y >> X >> sy >> sx >> ey >> ex;
  sy--, sx--, ey--, ex--;
  rep(y, Y) {
    string s;
    cin >> s;
    rep(x, X) {
      a[y][x] = s[x];
    }
  }

  q.push({0, {sy, sx}});
  while (!q.empty()) {
    auto cd = q.top().first, cy = q.top().second.first, cx = q.top().second.second;
    q.pop();
    if (d[cy][cx] <= cd)
      continue;
    d[cy][cx] = cd;
    //cout << "debug: " << cy << " " << cx << " " << cd << endl;
    //walk
    rep(k, 4) {
      ll ny = cy + dy[k], nx = cx + dx[k];
      if (ny < 0 || ny >= Y || nx < 0 || nx >= X || a[ny][nx] == '#')
        continue;
      q.push({cd, {ny, nx}});
    }
    // warp
    for (ll ny = cy - 2; ny <= cy + 2; ny++) for (ll nx = cx - 2; nx <= cx + 2; nx++) {
      if (ny < 0 || ny >= Y || nx < 0 || nx >= X || a[ny][nx] == '#')
        continue;
      q.push({cd+1, {ny, nx}});
    }
  }

  ll ans = d[ey][ex];
  if (ans == INF)
    ans = -1;
  cout << ans << endl;
}

int main() {
  //ll T;
  //cin >> T;
  //rep(_,T)
    solve();
  return 0;
}


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

int main()
{
  string str, tmp;
  int n, m;
  while (cin >> str, str != "-"){
    cin >> n;
    for (int i = 0; i < n; i++){
      cin >> m;
      tmp = str.substr(0, m);
      str.erase(str.begin(), str.begin() + m);
      str += tmp;
    }
    cout << str << endl;
  }
  return (0);
}

Measured memory_bytes: 1232
#include <iostream>
#include <algorithm>
#include <cstdio>

using namespace std;

const int K = 14 + 1;
const int P = 190;
const int N = 1120 + 1;

int t[K][P][N];

int p[P], size = 0;
bool prime[N];

int result[K][N];

int main(void)
{  
  fill( prime, prime + N, true );
  prime[0] = prime[1] = false;
  for(int i=2; i*i<N; ++i){
    for(int j=2; i*j<N; ++j){
      prime[i*j] = false;
    }
  }
  for(int i=0; i<N; ++i){
    if( prime[i] )p[size++] = i;
  }

  for(int i=0; i<size; ++i){
    t[1][i][p[i]] = 1;
  }

  for(int i=0; i+1<K; ++i){
    for(int j=0; j<size; ++j){
      for(int k=0; k<N; ++k){
	if( t[i][j][k] == 0 )continue;
	for(int l=j+1; l<size; ++l){
	  if(k + p[l] < N){
	    t[i+1][l][k+p[l]] += t[i][j][k];
	  }
	}
      }
    }
  }

  for(int i=0; i<K; ++i){
    for(int j=0; j<P; ++j){
      for(int k=0; k<N; ++k){
	result[i][k] += t[i][j][k];
      }
    }
  }

  for(int n, k; scanf("%d %d\n", &n, &k) && n && k; printf("%d\n", result[k][n]));

  return 0;
}

Measured memory_bytes: 12000
nums = list(map(int, input().split()))

mx = max(nums)
ct = 0

ct = sum([(mx - n) // 2 for n in nums])
amari = sum([(mx-n) % 2 for n in nums])
if amari == 1:
  ct += 2
elif amari == 2:
  ct += 1

print(ct)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define ll long long
#define ull unsigned long long
#define mod 1000000007
#define SORT(v) sort(v.begin(), v.end())
#define RSORT(v) sort(v.rbegin(), v.rend())
typedef pair<int, int> pii;

ll exp(ll taban, ll us) {
    ll carpan = taban % mod;
    ll temp = us;
    ll res = 1;
    while(temp){
        if(temp % 2) res = (res*carpan) % mod;
        temp /= 2;
        carpan = (carpan*carpan) % mod;
    }
    return res;
}
ll ebob(ll a, ll b){
    if(!a)return b;
    return ebob(b%a, a);
}
ll ekok(ll a, ll b){
    return (a*b)/ebob(a, b);
}
ll gcd(ll a, ll b){
    if(!a) return b;
    return gcd(b%a, a);
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n, k; cin>>n>>k;
	vector<int> vec(n);
	int sum = 0;
	for(auto &x: vec){
		cin>>x;
		sum += x;
	}
	RSORT(vec);
	int res = k;
	for(int i = 0; i < n; i++){
		if(4*k*vec[i] >= sum) res--;
		else break;
		if(res == 0) break;
	}
	if(res == 0) cout<<"Yes";
	else cout<<"No";
}

Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		int q = Integer.parseInt(sa[1]);
		String s = br.readLine();
		int[] cnt = new int[n + 1];
		for (int i = 1; i < n; i++) {
			cnt[i + 1] = cnt[i];
			if (s.charAt(i - 1) == 'A' && s.charAt(i) == 'C') {
				cnt[i + 1]++;
			}
		}
		for (int i = 0; i < q; i++) {
			sa = br.readLine().split(" ");
			int l = Integer.parseInt(sa[0]);
			int r = Integer.parseInt(sa[1]);
			System.out.println(cnt[r] - cnt[l]);
		}
		br.close();
	}
}


Measured memory_bytes: 50360
N,M,X,Y = map(int,input().split())


x = map(int, input().split())
y = map(int, input().split())
a = min(y)
b = max(x)
if X < Y:
    if b >= a:
        print("War")
    elif X >= a:
        print("War")
    elif Y <= b:
        print("War")
    else:
        print("No War")
else:
    print("War")

Measured memory_bytes: 3060
N = gets.to_i
@ls = []
N.times do
  @ls << gets.split
end
 
btc_amount = @ls.select{ |price, unit| unit == 'BTC' }.map{ |price, _| price.to_f }.inject(:+)
jpy_amount = @ls.select{ |price, unit| unit == 'JPY' }.map{ |price, _| price.to_i }.inject(:+)
 
if btc_amount.nil?
  puts  jpy_amount
elsif jpy_amount.nil?
  puts btc_amount.to_f * 380000
elsif !!jpy_amount && !!btc_amount
  puts btc_amount.to_f * 380000 + jpy_amount
end

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

int main(){

    int n, i, j, k;
    int x, t;
    int *a;

    scanf( "%d", &n );

    a = (int*)malloc(sizeof(int)*n);

    for( i=0; i<n; i++ )
        scanf( "%d", &a[i] );


    x = a[n-1];
    i=-1;

    for( j=0; j<(n-1); j++ ){
        if( a[j] <= x ){
            i++;
            t = a[i];
            a[i] = a[j];
            a[j] = t;
        }
    }
    i++;
    t = a[i]; a[i]=a[n-1]; a[n-1]=t;

    for( k=0; k<n; k++ ){
        if( k == i ) printf( "[" );
        printf( "%d", a[k]  );
        if( k == i ) printf( "]" );
        printf( "%c", ((n-1>k))?' ':'\n' );
    }
    

    free( a );
    return 0;
}



Measured memory_bytes: 2100
S = int(input())
if S >= 3600:
    h = int(S / 3600)
    m = int((S - (h * 3600)) / 60)
    s = (S - (h * 3600)) % 60

elif S >= 60:
    h = int(S / 3600)
    m = int(S / 60)
    s = S % 60

else:
    h = int(S / 3600)
    m = int(S / 60)
    s = S
print(h,m,s,sep = ':')


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


int main(void) {
	int N;
	cin >> N;
	vector <int> L;
	for (int i = 0; i < N; i++) {
		int l;
		cin >> l;
		L.push_back(l);
	}
	std::sort(L.begin(), L.end());

	int short_sum = 0;
	for (int i = 0; i < N-1; i++) {
		short_sum += L.at(i);
	}
	if (short_sum > L.at(N-1)) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	
	return 0;
}


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

int main() {
    int n,m,c;
    cin >> n >> m >> c;
    int a[n][m], b[m];
    for(int i=0;i<m;i++){
        cin >> b[i];
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin >> a[i][j];
        }
    }
    int res = 0;
    for(int i=0;i<n;i++){
        int ans = 0;
        for(int j=0;j<m;j++){
            ans += b[j]*a[i][j];
        }
        ans += c;
        if(ans > 0){
            res++;
        }
    }
    cout << res << endl;
    return 0;
}

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

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> a(n, -1);
    bool ok = true;
    for(int i=0;i<m;i++){
        int s, c;
        cin >> s >> c;
        s--;
        if(a[s] == -1 || a[s] == c){
            a[s] = c;
        }else{
            ok = false;
        }
    }
    if(n > 1){
        if(a[0] == 0) ok = false;
        if(a[0] == -1) a[0] = 1;
        for(int i=1;i<n;i++){
            if(a[i] == -1) a[i] = 0;
        }
    }else{
        if(a[0] == -1) a[0] = 0;
    }
    if(ok){
        for(auto c : a){
            cout << c;
        }
        cout << endl;
    }
    else{
        cout << -1 << endl;
    }
    return 0;
}

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

int main(void){
    int H, N, Abuf;
    cin >> H >> N;
    for(int i=0; i<N; i++){
        cin >> Abuf;
        H -= Abuf;
    }
    if(H <= 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

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

t,x,y = 0,0,0
for _ in range(N):
  ti,xi,yi = map(int,input().split())

  dt = ti-t
  d = abs(xi-x)+abs(yi-y)
  if d > dt or (d-dt) % 2 != 0:
    print('No')
    exit()
print('Yes')

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

#define ankit_2305 cerr<<"\nTime taken : "<<(float)(clock()-time_p)/CLOCKS_PER_SEC<<" sec\n";
#define START clock_t
#define TIMER time_p=clock();
#define ll long long

#define MOD 1000000007

using namespace std;

int main(){
    START TIMER
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
	string s, t, p;
	cin>>s>>t;
	map<string, int> mp;
	int a;
	cin>>a;
	mp[s] = a;
	cin>>a;
	mp[t] = a;
	cin>>p;
	mp[p]--;
	cout<<mp[s]<<" "<<mp[t];
    ankit_2305
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define MP make_pair
#define PB push_back
#define X first
#define Y second

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ITER(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))

const double PI = acos(-1.0);
const LL INF = 1e9 + 47;
const LL LINF = INF * INF;
LL ways[200001];
LL n , k;
int main()
{
	//ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);
	//freopen("Out.txt", "w", stdout);
	cin >> n >> k;
	LL kilk = n / k;
	LL ans = kilk * kilk * kilk;
	if(k % 2 == 0)
	{
		kilk = (n + k / 2) / k;
		ans += kilk * kilk * kilk;
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
#include <iostream> 
#include <string> 
#include <vector> 
#include <cmath> 
#include <algorithm> 
#include <cstdlib> 
#include <ctime> 
#include <cstdio> 
#include <functional> 
#include <set> 
#include <queue> 
#include <cctype> 
#include <climits> 
#include <stack> 
#include <map> 
#include <cstring> 
#include <numeric>
#include <cctype>

using namespace std; 

const long long mod=1e9+7;


int main(){

    int x,n;
    cin>>x>>n;

    vector<bool> ok(200,true);
    for(int i=0;i<n;i++){
        int p;
        cin>>p;
        ok[p]=false;
    }

    int d=10000, res=-1;
    for(int i=0;i<200;i++){
        if(!ok[i]) continue;
        if(abs(x-i)<d){
            d=abs(x-i);
            res=i;
        }
    }

    cout<<res<<endl;

    return 0;
}


Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long x  = sc.nextLong();
		long y = sc.nextLong();
		long count = 0;
		long i = 2;
		while(true) {
			if(x <= y) {
				count++;
				x*=i;
			}
			else {
				break;
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 35844
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int ans = 0;
    int dir = 0;
    bool flag[4] = {};
    for(int i = 0; i < s.size(); i++)
    {
        if(s[i] == 'R') 
        {
            dir++;
            if(dir == 4)
            {
                dir = 0;
                if(flag[1] && flag[2] && flag[3]) 
                {
                    memset(flag, false, sizeof(flag));
                    ans++;
                }
            }
            else flag[dir] = true;
        }
        if(s[i] == 'L')
        {
            dir--;
            if(dir < 0) dir = 3;
            if(dir == 0) memset(flag, false, sizeof(flag));
        }
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 3212
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Collections;

public class Main {

  static int n;
  static long ans;
  static Integer[] a;

  public static void main(String[] args) throws Exception {

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    PrintWriter out = new PrintWriter(System.out);

    String[] in = br.readLine().split(" ");
    n = Integer.parseInt(in[0]);

    a = new Integer[n];
    in = br.readLine().split(" ");
    for (int i = 0; i < n; i++) {
      a[i] = Integer.parseInt(in[i]);
    }

    br.close();

    Arrays.sort(a, Collections.reverseOrder());

    for (int i = 1; i < n; i++) {
      ans += a[i / 2];
    }

    out.println(ans);

    out.flush();

  }
}

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

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

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#define PI 3.1415926535

using namespace std;

int main(){
	int a, b;
	cin >> a >> b;
	int h, m;
	cin >> h >> m;
	
	double a_rad = (((360.0 / 12.0) * (double)h)+((360.0 / (12.0*60.0))*(double)m)) / 180 * PI;
	double b_rad = (360.0 / 60.0 * (double)m) / 180.0 * PI;
	
	double a_x = (double)a * cos(a_rad);
	double a_y = (double)a * sin(a_rad);
	
	double b_x = (double)b * cos(b_rad);
	double b_y = (double)b * sin(b_rad);

	
	double ans = sqrt((a_x-b_x)*(a_x-b_x) + (a_y-b_y)*(a_y-b_y));
	
	printf("%.10f\n", ans);
	
}

Measured memory_bytes: 4036
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<deque>
#include<queue>
#include<numeric>
using namespace std;

using ll = long long;
const int INF = 1001001001;
const ll LLINF = 1001001001001001001;
const int MOD = 1000000007;

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

int main()
{
  ll n, k;
  cin >> n >> k;

  ll sum = 0;
  if (k == 0) {
    sum = n * n;
    cout << sum << endl;
    return 0;
  }
  for (int i = 1; i <= n; i++) {
    if (i >= k+1) {
      sum += ((n + 1) / i) * (i - k);
      //printf("i=%d, sum=%lld\n", i, ((n + 1) / i) * (i - k));
      if ((((n + 1) % i) - k > 0)) {
        //printf("i=%d\n", i);
        sum += ((n + 1) % i) - k;
      }
    }
  }
  cout << sum << endl;
} 




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

#define Fast cin.tie(0), ios::sync_with_stdio(0)
#define All(x) x.begin(), x.end()
#define louisfghbvc int t; cin >> t; while(t--)
#define sz(x) (int)(x).size()
using namespace std;
typedef long long LL;
typedef pair<LL, LL> ii;
typedef vector<LL> vi;

template<typename T> istream& operator>>(istream &is, vector<T> &v) { for(auto &it : v) is >> it; return is; }
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep = ""; for(const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

void dbg_out() { cerr << "\n"; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }


void solve(){
    LL d, t, s;
    cin >> d >> t >> s;
    if(t*s >= d){
        cout << "Yes\n";
    }
    else cout << "No\n";
}

int main()
{
    Fast;
    //louisfghbvc{
        solve();
    //}
    return 0;
}


Measured memory_bytes: 3628
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;

const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : abs(x); }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : abs(x); }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	int n;
	string s;
	cin >> n >> s;

	// #.
	// ↓
	// .#

	vector<int> black(n);
	for (int i = 0; i < n; i++) black[i] = s[i] == '#';
	for (int i = 1; i < n; i++) black[i] += black[i - 1];

	vector<int> white(n);
	for (int i = n - 1; i >= 0; i--) white[i] = s[i] == '.';
	for (int i = n - 2; i >= 0; i--) white[i] += white[i + 1];

	// #.#
	int ans = INT_MAX;
	for (int i = 0; i < n; i++) {
		int b = black[i];
		int w = i + 1 == n ? 0 : white[i + 1];

		ans = min(ans, b + w);
	}

	// ###
	ans = min(ans, white[0]);

	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 2196
# ABC154 B
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
s=input()
s=list(s)
for i in range(len(s)):
    s[i]='x'

ans=''
for ss in s:
    ans+=str(ss)
print(ans)

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
static int N_MAX = 100;

struct Pair {
	int value;
	char kind;	
};

void p(Pair C[], int N) {
	for (int i = 0; i < N; ++i) {
		if (i > 0) cout << " ";
		cout << C[i].kind << C[i].value;
	}
	cout << endl;
}

void swap(Pair &a, Pair &b) {
	Pair c = a;
	a = b;
	b = c;
}


void BubbleSort(Pair C[], int N) {
	for (int i = 0; i < N; ++i) {
		for (int j = N - 1; j > i; --j)
			if (C[j].value < C[j - 1].value) {
				swap(C[j], C[j-1]);
			}
	}
}

void SelectionSort(Pair C[], int N) {
	for (int i = 0; i < N; ++i) {
		int minj = i;
		for (int j = i; j < N; ++j)
			if (C[j].value < C[minj].value) minj = j;
		swap(C[i], C[minj]);
	}
}

bool isStable(Pair C[], Pair D[], int N) {
	for (int i = 0; i < N - 1; ++i) {
		int j = i + 1;
		if (C[i].value == C[j].value) {
			int k = 0, l = 0;
			for (; k < N; ++k)
				if (D[k].value == C[i].value && D[k].kind == C[i].kind)
					break;
			for (; l < N; ++l)
				if (D[l].value == C[j].value && D[l].kind == C[j].kind)
					break;
			if (k > l)
				return false;
		}
	}
	return true;
}

int main() {
	int N;
	Pair C[N_MAX];
	Pair D[N_MAX];
	cin >> N;
	for (int i = 0; i < N; ++i) {
		cin >> C[i].kind >> C[i].value;
	}
	for (int i = 0; i < N; ++i) D[i] = C[i];

	BubbleSort(D, N);
	p(D, N);
	cout << (isStable(D, C, N) ? "Stable" : "Not stable") << endl;

	for (int i = 0; i < N; ++i) D[i] = C[i];
	SelectionSort(D, N);
	p(D, N);
	cout << (isStable(D, C, N) ? "Stable" : "Not stable") << endl;

	return 0;
}

Measured memory_bytes: 1172
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author dilip
 */

/*
*   author : dilip
*   time : 23-06-2019 22:11
*/

#include <iostream>
#include <fstream>

#include <iostream>
#include<stdio.h>
#include<bits/stdc++.h>

using namespace std;

class AFiftyFifty {
public:
	void solve(std::istream& in, std::ostream& out) {
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
		string s;
		in >> s;
		int a[26] = {0};
		for(int i=0;i<4;i++)a[s[i]-'A']++;
		for(int i=0;i<26;i++){
			if(a[i] == 1 || a[i] > 2) {
				out << "No" << endl;
				return;
			}
		}
		out << "Yes" << endl;


	}
};


int main() {
	AFiftyFifty solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	static int p;
	static int q;
	static int n;
	static int a = -1;
	static int b = -1;
	static int cnt = 0;
	
	static void dfs(String v) {
		if (v.length() == n) {
//			System.out.print(v);
			cnt++;
			if (Integer.valueOf(v) == p) {
				a = cnt;
//				System.out.printf(" a cnt=%d", cnt);
			}
			if (Integer.valueOf(v) == q) {
				b = cnt;
//				System.out.printf(" b cnt=%d", cnt);
			}
//			System.out.println();
			return;
		}
		
		for (int i = 1; i <= n; i++) {
			if (v.contains(Integer.toString(i))) {
				continue;
			}
			String nv = v + i;
			dfs(nv);
		}
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		
		p = sc.nextInt();
		for (int i = 1; i < n; i++) {
			p = p * 10 + sc.nextInt();
		}
		
		q = sc.nextInt();
		for (int i = 1; i < n; i++) {
			q = q * 10 + sc.nextInt();
		}
		
//		System.out.printf("p=%d\n", p);
//		System.out.printf("q=%d\n", q);
		
		for (int i = 1; i <= n; i++) {
			dfs(Integer.toString(i));
		}
		
		int ans = Math.abs(a - b);
		System.out.println(ans);
	}
}


Measured memory_bytes: 45856
def main():
  n=int(input())
  a=list(map(int,input().split()))
  a.sort()
  a_max=a[-1]
  x=[True]*(a_max+1)
  a=a+[0]
  for i in range(n):
    ai=a[i]
    if x[ai]:
      l=a_max//ai-1
      aj=ai
      for _ in range(l):
        aj+=ai
        x[aj]=False
    if a[i]==a[i+1]:
      x[a[i]]=False
  ans=0
  x[0]=False
  for i in a:
    if x[i]:
      ans+=1
  print(ans)
if __name__=='__main__':
  main()

Measured memory_bytes: 95172
#include <bits/stdc++.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define acc(v) accumulate(v.begin(), v.end(), 0)

using namespace std;
typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;

int main()
{
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    int ans = 0;
    if(a > k){
        ans += k;
    }else{
        ans += a;
        k -= a;
        if(b > k){
            cout << ans << endl;
            return 0;
        }else{
            k -= b;
            ans -= k;
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
  int N;cin>>N;
  int T,A;cin>>T>>A;
  vector<int>H(N);
  for (int i=1;i<=N;++i){
    cin>>H[i];
  }
  
  int res=0;//何番目の地点
  int cc=1<<30;//仮
  for (int i=1;i<=N;++i){
    int d=(T*1000-H[i]*6)-A*1000;
    if (d<0)d=-d;
    if (cc>d){
      cc=d;
      res=i;
    }
  }
  cout<<res<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <fstream>
#include <list>
#include <string>
#include <map>
#include <numeric>
#include<unordered_map>
#include<queue>
#include <set>
#include<unordered_set>
#include <bitset>
#include <cmath>
#include <functional>
using namespace std;
int main()
{
	ifstream fin("input.txt");
	long long N, ans = 0, A, i = 0;
	cin >> N;
	map<long long, long long>mymap;
	while (i < N)
	{
		cin >> A;
		mymap[A]++;
		i++;
	}
	map<long long, long long>::iterator it;
	for (it = mymap.begin(); it != mymap.end(); it++)
	{
		if ((it->second) % 2 == 1)
		{
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 6528
H,W=map(int,input().split())
A=[]
for _ in range(H):
    a=list(input())
    if("#" in a):
        A.append(a)
answer=[]
for i in range(W):
    tmp=[]
    hantei=True
    for a in A:
        if(a[i]=="#"):
            hantei=False
        tmp.append(a[i])
    if(hantei==False):
        answer.append(tmp)

result = list(zip(*answer))
for r in result:
    print("".join(r))

Measured memory_bytes: 3316
/* ***************************************
Author        :Scau.ion
Created Time  :2016/12/05 22:10:12 UTC+8
File Name     :ion.cpp
*************************************** */

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

#define LL long long
#define ULL unsigned long long
#define PB push_back
#define MP make_pair
#define PII pair<int,int>
#define VI vector<int>
#define VPII vector<PII>
#define X first
#define Y second
#define IOS ios::sync_with_stdio(0);cin.tie(0);
#define IN freopen("in", "r", stdin);
#define OUT freopen("out", "w", stdout);

const int maxn=100010;

int a[maxn];

int main()
{
    IOS;
    int n,x;
    cin>>n>>x;
    LL ans=0;
    for (int j=1;j<=n;++j)
    {
        cin>>a[j];
        if (a[j]+a[j-1]>x)
        {
            ans+=a[j]+a[j-1]-x;
            a[j]=x-a[j-1];
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 640
N, K = gets.chomp.split(' ').map(&:to_i)
xs = gets.chomp.split(' ').map(&:to_i)

puts (0..N - K).map { |i|
  (xs[i] - xs[i + K - 1]).abs + [xs[i].abs, xs[i + K - 1].abs].min
}.min


Measured memory_bytes: 12548
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int A, B;
	cin >> A >> B;
	vector<vector<int> >d(A + 1, vector<int>(B + 1, 0));
	vector<vector<int> >noneed(A + 1, vector<int>(B + 1, 0));
	for (int i = 1; i <= A; i++) {
		for (int j = 1; j <= B; j++) {
			cin >> d[i][j];
		}
	}
	bool f;
	int mn = 100;
	int sc = 0;
	int xx, yy;
	int xmax = 0;
	bool ok = true;
	vector<pair<pair<int, int>, int> > vp;
	for (int a = 1; a <= A; a++) {
		for (int b = 1; b <= B; b++) {
			if (noneed[a][b] == 0) {
				xx = -1;
				mn = 10000;
				for (int x = 0; x <= 100; x++) {
					for (int y = 0; y <= 100; y++) {
						int z = d[a][b] - x*a - y*b;
						if (z < 0)break;
						f = true;
						sc = 0;
						for (int a2 = 1; a2 <= A; a2++) {
							for (int b2 = 1; b2 <= B; b2++) {
								if (d[a2][b2] > x*a2 + y*b2 + z) {
									f = false;
									break;
								}
								else if (noneed[a2][b2] == 0 && d[a2][b2] == x*a2 + y*b2 + z) {
									sc--;
								}
							}
							if (!f) {
								break;
							}
						}
						if (f) {
							if (mn > sc) {
								mn = sc;
								xx = x;
								yy = y;
							}
							//break;
						}
					}
				}
				if (xx == -1) {
					cerr << a << " " << b << endl;
					ok = false;
					break;
				}
				for (int a2 = 1; a2 <= A; a2++) {
					for (int b2 = 1; b2 <= B; b2++) {
						if (d[a2][b2] == xx*a2 + yy*b2 + d[a][b] - xx*a - yy*b) {
							noneed[a2][b2] = 1;
						}
					}
				}
				xmax = max(xx, xmax);
				vp.push_back(make_pair(make_pair(xx, yy), d[a][b] - xx*a - yy*b));
			}
		}
		if (!ok)break;
	}
	if (ok) {
		int v = 0;
		sort(vp.begin(), vp.end());
		vector<int> ymax(xmax + 1, -1);
		for (int i = 0; i < vp.size(); i++) {
			ymax[vp[i].first.first] = max(ymax[vp[i].first.first], vp[i].first.second);
			//cerr << vp[i].first.first << " " << vp[i].first.second << " " << vp[i].second << endl;
		}
		map<pair<int, int>, int> mp;
		vector<pair<pair<int, int>, int> >ed;
		mp[make_pair(0, 0)] = 0;
		for (int i = 0; i < xmax; i++) {
			v++;
			ed.push_back(make_pair(make_pair(v - 1, v), -1));
			mp[make_pair(v, 0)] = v;
		}
		for (int i = 0; i <= xmax; i++) {
			for (int j = 0; j < ymax[i]; j++) {
				v++;
				ed.push_back(make_pair(make_pair(mp[make_pair(i, j)], v), -2));
				mp[make_pair(i, j + 1)] = v;
			}
		}
		v++;
		int fc = v;
		for (int i = 0; i < vp.size(); i++) {
			ed.push_back(make_pair(make_pair(mp[make_pair(vp[i].first.first, vp[i].first.second)], fc), vp[i].second));
		}
		cout << "Possible" << endl;

		cout << fc + 1 << " " << (int)ed.size() << endl;
		for (int i = 0; i < ed.size(); i++) {
			cout << ed[i].first.first + 1 << " " << ed[i].first.second + 1 << " ";
			if (ed[i].second == -1) {
				cout << "X" << endl;
			}
			else if (ed[i].second == -2) {
				cout << "Y" << endl;
			}
			else {
				cout << ed[i].second << endl;
			}
		}
		cout << 1 << " " << fc + 1 << endl;
	}
	else {
		cout << "Impossible" << endl;
	}

}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#pragma warning( disable:4996 )
using namespace std;
typedef long long ll;
typedef long long Int;
#define MOD 1000000007

#define SWAP(a,b) (a += b,b = a - b,a -= b)
#define MIN(a, b) ((a) < (b) ? (a) : (b))


int main(void) {
	/*int x, y;
	scanf("%d %d", &x, &y);
	if (x == 1 && y == 1) {
		printf("1000000\n");
		return 0;
	}
	else {
		printf("%d\n", ((4 - ((x>=4)?4:x)) + (4 - ((y>=4)?4:y))) * 100000);
	}*/
	int n;
	ll a[200001];
	scanf("%d", &n);
	ll total = 0;
	for (int i = 0; i < n; i++) {
		scanf("%lld", &a[i]);
		total += a[i];
	}
	ll before = 0;
	ll length = a[0];
	ll counter = 1;
	while (1) {
		before = length;
		length += a[counter++];
		if (length == total / 2 && total % 2 == 0) {
			printf("0\n");
			return 0;
		}
		if (length > total / 2) {
			if (length * 2 - total < total - before*2) {
				printf("%d\n", length * 2 - total);
			}
			else {
				printf("%d\n", total - before * 2);
			}
			
			return 0;
		}
	}
	
	return 0;
}

Measured memory_bytes: 1664
#include <stdio.h>

int main() {
    char str[3];
    int ans, num, i;
    ans = num = 0;

    for(i=0;i < 3;i++) {
        scanf("%c", &str[i]);
        if(str[i] == 'R') {
            num++;
            if(ans < num) ans = num;
        } else {
            num = 0;
        }
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 1660
#include<iostream>
#include<utility>
#include<algorithm>
#include<iterator>
using namespace std;

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

int main(){
    int N,M;
    cin >> N >> M;
    long long A[N];
    pair<int, long long> BC[M];
    int B;
    long long C;
    int Cnum[M],Csup[M];
    for(int i=0; i<M; i++) Cnum[i]=0;

    for(int i=0; i<N; i++){
        cin >> A[i];
    }
    for(int j=0; j<M; j++){
        cin >> B >> C;
        BC[j]=make_pair(B,C);
    }

    sort( A, A+N );
    sort( BC, BC+M, compare_by_b );

    for(int i=0; i<M; i++){
        B=BC[i].first;
        C=BC[i].second;
        long long *jp=lower_bound(A,A+N,C);
        int j= distance(A,jp);
        //Cnum[i] = min(j, B);
        Csup[i] = j;
    }

    long long ans=0;
    int cnumtmp=0;
    int cnumtmp2,cnumtmp3;
    for(int i=M-1; i>=0; i--){
        B = BC[i].first;
        C = BC[i].second;
        if( Csup[i] > cnumtmp ){
            cnumtmp2 = min( B+cnumtmp, Csup[i] )-cnumtmp;
        }else{
            cnumtmp2 = 0;
        }

        ans += C * cnumtmp2;

        //cout << "i', cnumtmp2, C ans " << M-1-i << " " << cnumtmp2 << " " << C << " " << ans << endl;
        cnumtmp+=cnumtmp2;
    }
    //cout << "cnumtmp " << cnumtmp << endl;
    for(int i=cnumtmp; i<N; i++){
        //cout << "i ans " << i << " " << ans << endl;
        ans += A[i];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3328
# iの倍数に入ったボールの和を2で割った余りa
n = int(input())
a = list(map(int, input().split()))
b = [0 for _ in range(n)]
c = []
# impossible = False
# bを後ろから順に決定
for i in reversed(range(n)):
    sum_i = sum(b[i::i+1])
    if not sum_i % 2 == a[i]:
        b[i] = 1
        c.append(i+1)

print(sum(b))
if c:
    print(' '.join(map(str, c)))


Measured memory_bytes: 19896
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
//typedef pair<int,int> P;
//priority_queue<int> pque;
//priority_queue<int, vector<int>, greater<int>> pque;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2000000000;//10^9
ll MOD  = 1000000007;
int N;
vector<ll> a(410);
ll Wa[410][410];
ll dp[410][410];
void makeWa(int N){
    for(int i = 1; i <= N; i++){
        for(int j = i; j <= N; j++){
            ll wa = 0;
            for(int k = i; k <= j; k++){
                wa += a.at(k-1);
            }
            Wa[i][j] = wa;
        }
    }
}

ll solve(int left, int right){
    if(left == right){
        return 0;
    }
    if(right - left == 1){
        return a.at(left-1) + a.at(right-1);
    }
    if(dp[left][right] != 0){
        return dp[left][right];
    }
    
    ll min = INFL;
    for(int i = 0; i < right - left; i++){
        if(min > solve(left, left + i) + solve(left + i + 1, right)){
            min = solve(left, left + i) + solve(left + i + 1, right);
        }
    }
    return dp[left][right] = min + Wa[left][right];
    
    
}


int main(void){
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> a.at(i);
    }
    makeWa(N);
    cout << solve(1, N) << endl;
    
    
}


Measured memory_bytes: 2816
import sys
read = sys.stdin.buffer.read
#input = sys.stdin.readline
#input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode('utf-8')
import math


def main():
	
	k=II()
	
	ans=0
	
	li=[0]*(k+1)
	
	for a in range(1,k+1):
		for b in range(1,k+1):
			li[math.gcd(a,b)]+=1
	
	for i in range(1,k+1):
		for c in range(1,k+1):
			if li[i]!=0:
				ans+=li[i]*math.gcd(i,c)
				
	
	print(ans)





	
if __name__ == "__main__":
	main()


Measured memory_bytes: 9164
using static System.Math;
using System;

public class hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var h = int.Parse(line[0]);
        var w = int.Parse(line[1]);
        var ans = getAns(h, w);
        Console.WriteLine(ans);
    }
    static int[,] setArray(int h, int w)
    {
        var c = new string[] { "W", "B", "R" };
        var a = new int[h, 3];
        var s = Console.ReadLine().Trim();
        for (int i = 0; i < 3; i++)
            a[0, i] = w - s.Replace(c[i], "").Length;
        for (int i = 1; i < h; i++)
        {
            s = Console.ReadLine().Trim();
            for (int j = 0; j < 3; j++)
                a[i, j] = a[i - 1, j] + w - s.Replace(c[j], "").Length;
        }
        return a;
    }
    static int getAns(int h, int w)
    {
        var a = setArray(h, w);
        var ans = int.MaxValue;
        for (int i = 0; i < h - 2; i++)
            for (int j = i + 1; j < h - 1; j++)
            {
                var t =a[i, 1] - a[i, 0] + a[j , 2] - a[j, 1];
                ans = Min(ans, t);
            }
        return ans + a[h - 1, 0] + a[h - 1, 1];
    }
}




Measured memory_bytes: 15952
#include <bits/stdc++.h>
#define INF 990000000
//
using namespace std;

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

set<char> lis;
for(int i=0;i<3;i++)lis.insert(s[i]);

if((int)lis.size()==2)
cout <<"Yes"<<endl;
else
cout <<"No"<<endl;


}






Measured memory_bytes: 256
#pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0)
#define ull unsigned ll
#define uint unsigned
#define pai pair<int,int>
#define pal pair<ll,ll>
#define IT iterator
#define pb push_back
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);++i)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);--i)
#define endl '\n'
typedef long long ll;
const int N=2e5+7;
ll n,d;
ll x,y;
ll ans;
int main()
{
    int cnt=0;
    cin>>n>>d;
    for(int i=1;i<=n;i++)
    {
        cin>>x>>y;
        ans=x*x+y*y;
        if(ans<=d*d)
            cnt++;
    }
    cout<<cnt<<endl;
}

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

#define INF 1000000007
#define ll long long
#define F first
#define S second
#define pii pair<ll int,ll int>
#define pb push_back
#define ppb pop_back
#define vi vector<ll int>


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t=1;
	//cin >> t;
	while(t--){
		int a,b;
		cin >> a >> b;
		int a1,b1;
		a1 = ceil(((float)a*25)/2);
		b1 = b*10;
		int ans = max(a1,b1);
		if((ans*8)/100 != a || ans/10 != b) cout << -1;
		else cout << ans;
	}
	return 0;
}


Measured memory_bytes: 256
// AtCoder Regular Contest 075
// C - Bugged

#include <cstdio>
#include <algorithm>
#define MAX_N 100
using namespace std;
typedef long long int ll;


int N;
int s[MAX_N];

int main() {

    int ans = 0;

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

    if (ans % 10 == 0) {
        sort(s, s + N);
        for (int i = 0; i < N; i++) {
            if (s[i] % 10 != 0) {
                ans -= s[i];
                break;
            }
        }
        if (ans % 10 == 0) {
            ans = 0;
        }
    }

    printf("%d\n", ans);

    return 0;

}





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

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

	int sum = 0;
	char input, p=' ';
	for(int i=0; i<n; i++){
		cin >> input;
		if(input != p){
			sum++;
			p = input;
		}
	}

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
typedef long long ll;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=(1LL<<61);
const int inf=(1<<30);
const int nmax=2e5+50;
const int mod=1e9+7;
using namespace std;
ll a,b,c,k;
int main()
{
	//freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	cin>>a>>b>>c>>k;
	if(k&1)rc(b-a);
	cout<<a-b<<endl;
    return 0;
}

Measured memory_bytes: 256
n,k=map(int,input().split())
a=sorted(list(map(int,input().split())))
mod = 10**9+7 # 変える
fac = [1]*n
finv = [1]*n
inv = [0]*n
inv[1] = 1
for i in range(2,n):
    fac[i] = fac[i-1]*i % mod
    inv[i] = mod - inv[mod%i] *(mod//i) %mod
    finv[i] = finv[i-1] * inv[i] % mod
def comb(n,k):
    if n<k:
        return 0
    if n<0 or k<0:
        return 0
    return fac[n]*(finv[k] * finv[n-k] % mod)%mod
ans=0
for i in range(n-k+1):
    ans=(ans+comb(n-i-1,k-1)*(a[n-i-1]-a[i]))%mod
print(ans)

Measured memory_bytes: 19024
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <climits>

using namespace std;

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int n, m, res = 0;
    cin >> n >> m;
    vector<vector<bool>> a(n + 2, vector<bool>(m + 2));
    for (int i = 0; i < n; i++)
    {
        string s;
        cin >> s;
        for (int j = 0; j < m; j++)
            a[i + 1][j + 1] = (s[j] == '.');
    }

    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++)
        {
            if (!a[i + 1][j + 1]) continue;
            vector<vector<int>> d(n, vector<int>(m, INT_MAX));
            d[i][j] = 0;
            vector<pair<int, int>> q;
            q.emplace_back(i, j);
            for (int k = 0; k < q.size(); k++)
            {
                auto p = q[k];
                int x = p.first;
                int y = p.second;
                res = max(res, d[x][y]);
                vector<int> dx = {-1, 0, 0, 1};
                vector<int> dy = {0, -1, 1, 0};
                for (int dir = 0; dir < 4; dir++)
                {
                    int xx = x + dx[dir];
                    int yy = y + dy[dir];
                    if (a[xx + 1][yy + 1] && d[xx][yy] == INT_MAX)
                    {
                        d[xx][yy] = d[x][y] + 1;
                        q.emplace_back(xx, yy);
                    }
                }
            }
        }

    cout << res << "\n";

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner (System.in);
		int a = sc.nextInt();
		String s = sc.next();
		if(a>=3200) {
			System.out.println(s);
		}
		else {
			System.out.println("red");
		}	
	}
}


Measured memory_bytes: 23252
#include <iostream>

using namespace std;

int main(){

  int N,P=0,W=0,G=0,Y=0,ans=0;
  char clr;

  cin >> N;

  for(int i = 0; i < N; i++){
    cin >> clr;
    
    switch(clr){
    case 'P':P++;
      break;
    case 'W':W++;
      break;
    case 'G':G++;
      break;
    case 'Y':Y++;
      break;
    }
  }
  
  if(P!=0){
    ans++;
  }
  if(W!=0){
    ans++;
  }
  if(G!=0){
    ans++;
  }
  if(Y!=0){
    ans++;
  }

  if(ans==3){
    cout << "Three" << "\n";
  }
  else{
    cout << "Four" << "\n";
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pf push_front

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

int main()
{
int n;
cin>>n;
vi a(n);
rep(i,n)
cin>>a[i];
sort(All(a));
int max_=a.back();
int else_sum=accumulate(All(a),0)-max_;
if(else_sum>max_)
	cout<<"Yes"<<endl;
else
	cout<<"No"<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main()
{
    string S, T;

    cin >> S;
    cin >> T;

    vector<vector<int>> cost(S.length() + 1);

    for (int i = 0; i < S.length() + 1; i++)
    {
        cost[i].resize(T.length() + 1);
        cost[i][0] = i;
    }

    for (int i = 0; i < T.length() + 1; i++)
    {
        cost[0][i] = i;
    }

    int c;
    for (int i = 1; i < S.length() + 1; i++)
    {
        for (int j = 1; j < T.length() + 1; j++)
        {
            c = S[i-1] == T[j-1] ? 0 : 1;
            cost[i][j] = min(min(cost[i - 1][j], cost[i][j - 1])+1, cost[i - 1][j - 1] + c);
        }
    }
    cout << cost[S.length()][T.length()] << endl;
    /*
    for (int i = 0; i < S.length() + 1; i++)
    {
        for (int j = 0; j < T.length() + 1; j++)
        {
            cout << " " << cost[i][j];
        }
        cout << endl;
    }
    */
    
}


Measured memory_bytes: 6852
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<P,P> PP;
const ll MOD=998244353;
const ll MAX_N=500010;
const ll INF=4999999996000000001;


int main(){
    int h,w,k;
    cin>>h>>w>>k;
    vector<vector<char> > c(h,vector<char>(w));
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++) cin>>c[i][j];
    }
    int ans=0;
    for(int gyou=0;gyou<(1<<h);gyou++){
        for(int retu=0;retu<(1<<w);retu++){
            int num=0;
            for(int i=0;i<h;i++){
                for(int j=0;j<w;j++){
                    if(gyou>>i&1 && retu>>j&1 && c[i][j]=='#') num++;
                }
            }
            if(num==k) ans++;
        }
    }
    cout<<ans<<endl;

}

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

using namespace std;
const int N = 2e5+5;
pair<int,int> v[N];
int main()
{
    int n;
    cin >> n;
    for (int i = 1; i<=n; i++)
    {
        cin >> v[i].first;
        v[i].second = i;
    }
    sort(v+1,v+n+1);
    for (int i = 1; i<=n; i++)
        cout << v[i].second << " ";
}


Measured memory_bytes: 1536
import sys
def input(): return sys.stdin.readline().rstrip()
from bisect import bisect
def main():
    a,b,q=map(int,input().split())
    S=[int(input())for _ in range(a)]
    T=[int(input())for _ in range(b)]

    def dfs(cur,flag1,flag2):
        if flag2==1:
            index_s=bisect(S,cur)
            #print(cur,index_s)
            if index_s>0 and index_s<a:
                if flag1==0:
                    return min(abs(S[index_s-1]-cur),abs(S[index_s]-cur))
                else:
                    return min(dfs(S[index_s-1],0,0)+abs(S[index_s-1]-cur),dfs(S[index_s],0,0)+abs(S[index_s]-cur))
            else:
                if index_s==a:
                    nx=S[-1]
                elif index_s==0:
                    nx=S[0]
                if flag1==1:
                    return dfs(nx,0,0)+abs(nx-cur)
                else:
                    return abs(nx-cur)
        else:
            index_t=bisect(T,cur)
            #print(cur,index_t)
            if index_t>0 and index_t<b:
                if flag1==0:
                    return min(abs(T[index_t-1]-cur),abs(T[index_t]-cur))
                else:
                    return min(dfs(T[index_t-1],0,1)+abs(T[index_t-1]-cur),dfs(T[index_t],0,1)+abs(T[index_t]-cur))
            else:
                if index_t==b:
                    nx=T[-1]
                elif index_t==0:
                    nx=T[0]
                if flag1==1:
                    return dfs(nx,0,1)+abs(nx-cur)
                else:
                    return abs(nx-cur)

    for i in range(q):
        x=int(input())
        print(min(dfs(x,1,1),dfs(x,1,0)))


if __name__=='__main__':
    main()

Measured memory_bytes: 12204
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
typedef long long ll;
using namespace std;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<pint> vpint;
int INF=1e+9+1;
int main(){
	int N;
	int t[100000],x[100000],y[100000];
	int tb=0,xb=0,yb=0;
	int flag=1;
	scan(N);
	rep(i,N){
		scan(t[i]);scan(x[i]);scan(y[i]);
		int dt=t[i]-tb,dx=abs(x[i]-xb),dy=abs(y[i]-yb);
		if(dx+dy<=dt&&(dt-(dx+dy))%2==0){

		}
		else{
			flag=0;
		}
	}
	if(flag) prin("Yes");
	else prin("No");

	return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <stack>
#include <cmath>
#include <time.h>
#define ll long long
#define LINF 0x3f3f3f3f3f3f3f3f
#define INF 0x3f3f3f3f
#define PI 3.14159265
#define RAND (rand()*rand())
using namespace std;
const int MAX = 1e5 + 10; //N
const ll MOD = 1e9 + 7;
int N, M, K, Q;

int main()
{
	int i, j;
	scanf("%d%d", &N, &K);
	ll cnt = 0LL;
	if (K % 2 == 0) {
		ll val = 0LL;
		for (i = 1; i <= N; ++i) {
			if (i%K == (K / 2)) val++;
		}
		cnt = val*val*val;
	}
	ll tmp = (ll)N/ K;
	cnt += tmp * tmp * tmp;
	printf("%lld", cnt);

}

Measured memory_bytes: 256