akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#define debug(x) cerr << __LINE__ << ' ' << #x << ':' << x << '\n'
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
template<class T> using pque = priority_queue<T, vector<T>, greater<T>>;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr int mod1e9 = 1000000007;
constexpr int mod998 = 998244353;
constexpr ld eps = 1e-12;
constexpr ld pi = 3.141592653589793238;
constexpr ll ten(int n) { return n ? 10 * ten(n - 1) : 1; };
int dx[] = { 1,0,-1,0,1,1,-1,-1 }; int dy[] = { 0,1,0,-1,1,-1,1,-1 };
void fail() { cout << "-1\n"; exit(0); } void no() { cout << "No\n"; exit(0); }
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }
template<class T> istream &operator >> (istream &s, vector<T> &v) { for (auto &e : v) s >> e; return s; }
template<class T> ostream &operator << (ostream &s, const vector<T> &v) { for (auto &e : v) s << e << ' '; return s; }

struct fastio {
	fastio() {
		cin.tie(0); cout.tie(0);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(20);
		cerr << fixed << setprecision(20);
	}
}fastio_;

constexpr ll mod = mod998;

int main() {
	int n, k;
	cin >> n >> k;
	vector<ll> dp(n + 1), sum(n + 2);
	vector<int> l(k), r(k);
	rep(i, k) cin >> l[i] >> r[i];
	dp[1] = sum[2] = 1;
	for (int i = 2; i <= n; i++) {
		rep(j, k) {
			int x = i - l[j] + 1;
			int y = i - r[j];
			if (x >= 0) dp[i] += sum[x];
			if (y >= 0) dp[i] -= sum[y];
		}
		dp[i] %= mod;
		if (dp[i] < 0) dp[i] += mod;
		sum[i + 1] = sum[i] + dp[i];
		if (sum[i + 1] >= mod) sum[i + 1] -= mod;
	}
	cout << dp[n] << '\n';
}

Measured memory_bytes: 6368
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  vector<int>v(n,0);
  for(int i=0;i<n;i++)cin>>v[i];
  int sum=0;
  for(int i=0;i<n;i++)
  {
    for(int j=i+1;j<n;j++)
    {
       sum+=v[i]*v[j];
    }  
  }
  cout<<sum;
   return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
#define INFLL        1e18
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define DELNL        cin.ignore(numeric_limits<streamsize>::max(),'\n')
#define VV(T,h,w)    vector<vector<T>>(h,vector<T>(w))
#define VVI(T,h,w,i) vector<vector<T>>(h,vector<T>(w,i))
using namespace std;
using ll=long long;
using ull=unsigned long long;
template<typename T>using pqg=priority_queue<T,vector<T>,greater<T>>;
template<typename T=ll>inline T in(){T ret;cin>>ret;return ret;}

void yakusu(ll n,vector<ll>&y)
{
    for(ll i=1;i*i<=n;++i){
        if(n%i==0){
            y.push_back(i);
            if(i!=n/i)y.push_back(n/i);
        }
    }
}
int main()
{
    ll n=in(),k=in();
    vector<ll>a(n);REP(i,n)a[i]=in();

    vector<ll>y;
    yakusu(accumulate(ALL(a),0LL),y);
    sort(ALL(y),greater<ll>());

    ll ans=0;
    vector<ll>ar(n);
    REP(i,y.size()){
        ll rsum=0;
        REP(j,n)rsum+=ar[j]=a[j]%y[i];
        sort(ALL(ar),greater<ll>());
        if(accumulate(ar.begin()+rsum/y[i],ar.end(),0LL)<=k)ans=max(ans,y[i]);
    }
    cout<<ans<<endl;
}

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

string str;

struct u{
	string bk;
	u(){bk="000000000000000000000000000";}
	void gao(){
		for(int i=0;i<str.length();i++){
			bk[str[i]-'a'+1]++;
		}
	}
	friend bool operator == (u a,u b){
		for(int i=1;i<=26;i++){
			if(a.bk[i]==b.bk[i]) continue;
			return false;
		}
		return true;
	}
	friend bool operator < (u a,u b){
		for(int i=1;i<=26;i++){
			if(a.bk[i]==b.bk[i]) continue;
			return a.bk[i]<b.bk[i];
		}
		return true;
	}
}s[100005];


map<string,int> p;
map<string,int>::iterator it;
int n;
vector<int> qqq;
long long ans;
signed main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>str;
		s[i].gao();
	}
	//sort(s+1,s+n+1);
	/*for(int i=1;i<=n;i++){
		cout<<s[i].bk<<endl;
	}*/
	for(int i=1;i<=n;i++){
		it=p.find(s[i].bk);
		if(it==p.end()){
			p.insert(make_pair( s[i].bk ,1));
		}
		else p[ s[i].bk ]++;

	}
	it=p.begin();
	while(it!=p.end()){
		int pppp=it->second;
		ans+=pppp*(pppp-1)/2;
		//cout<<it->first<<' '<<it->second<<endl;
		it++;
	}

	cout<<ans;
}

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

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

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

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

    return 0;
}


Measured memory_bytes: 3092
#pragma warning(disable:4996)

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

typedef long long ll;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define pb push_back
#define mp make_pair
#define fill(x,y) memset(x,y,sizeof(x))

const ll INF = (1ll << 60);
const int INF_CONST = (int)1e9;
const ll MOD_CONST = (ll)(1e9 + 7);

int main(void)
{
	cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(20);

	int N; cin >> N;
	int cnt = 0;
	REP(i, N) {
		int a; cin >> a;
		if (a % 2 != 0) {
			cnt++;
		}
	}
	if (cnt % 2 == 0)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
	

	return 0;
}

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

using namespace std;

#define INF (1 << 30)

int dp[20001][256];


int main()
{
  int N, M;
  while(cin >> N >> M, N || M){
    int C[16], x[20000];
    for(int i = 0; i < M; i++) cin >> C[i];
    for(int i = 0; i < N; i++) cin >> x[i];
    for(int i = 0; i < 20001; i++){
      for(int j = 0; j < 256; j++) dp[i][j] = INF;
    }
    dp[0][128] = 0;
    for(int i = 0; i < N; i++){
      for(int j = 0; j < 256; j++){
	if(dp[i][j] == INF) continue;
	for(int k = 0; k < M; k++){
	  int y = j + C[k];
	  if(y < 0) y = 0;
	  else if(y > 255) y = 255;
	  int sqsum = (x[i] - y)*(x[i] - y);
	  dp[i+1][y] = min(dp[i+1][y], dp[i][j] + sqsum);	  
	}
      }
    }
    cout << *min_element(dp[N], dp[N] + 256) << endl;
  }
  return 0;
}

Measured memory_bytes: 21236
/*  -*- coding: utf-8 -*-
 *
 * d.cc: D - DivRem Number
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

/* typedef */

typedef long long ll;

/* global variables */

/* subroutines */

/* main */

int main() {
  ll n;
  scanf("%lld", &n);

  ll sum = 0;
  for (ll r = 1; r * r < n; r++) {
    ll m = n / r - 1;
    if (n / m == n % m) sum += m;
  }

  printf("%lld\n", sum);
  return 0;
}


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

using namespace std;
typedef pair<int, int> P;
const int INF = 1e9;
int h, w;

vector<string> maze;

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

int bfs(P start, P end) {
  vector< vector<int> > dist(h, vector<int>(w, INF));

  queue<P> q;
  q.push(start);
  dist[start.first][start.second] = 0;
  while (!q.empty()) {
    P cur = q.front(); q.pop();
    if (cur.first == end.first && cur.second == end.second) {
      return dist[cur.first][cur.second];
    }

    for (int i = 0; i < 4; ++i) {
      int nx = cur.second + dx[i];
      int ny = cur.first + dy[i];
      if (nx < 0 || nx >= w || ny < 0 || ny >= h || dist[ny][nx] != INF || maze[ny][nx] == '#') {
	continue;
      }
      dist[ny][nx] = dist[cur.first][cur.second] + 1;
      q.push(P(ny, nx));
    }
  }
  return dist[end.first][end.second];
}

int main() {
  cin >> h >> w;

  for (int i = 0; i < h; ++i) {
    string s;
    cin >> s;
    maze.push_back(s);
  }

  int ans = 0;
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      for (int k = 0; k < h; ++k) {
	for (int y = 0; y < w; ++y) {
	  if (maze[i][j] != '#' && maze[k][y] != '#') {
	    int x = bfs(P(i, j), P(k, y));
	    if (x != INF) {
	      ans = max(ans, x);
	    }
	  }
	}
      }
    }
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
ary = []
3.times do |i|
    ary[i] = gets.split.map(&:to_i)
end
0.upto(ary[0].max) do |a1|
    b1 = ary[0][0] - a1
    b2 = ary[0][1] - a1
    b3 = ary[0][2] - a1
    0.upto(ary[1].max) do |a2|
        0.upto(ary[2].max) do |a3|
            if (a1 + b1 == ary[0][0] &&
                a1 + b2 == ary[0][1] &&
                a1 + b3 == ary[0][2] &&
                a2 + b1 == ary[1][0] &&
                a2 + b2 == ary[1][1] &&
                a2 + b3 == ary[1][2] &&
                a3 + b1 == ary[2][0] &&
                a3 + b2 == ary[2][1] &&
                a3 + b3 == ary[2][2])
                puts 'Yes'
                exit
            end
        end
    end
end
puts 'No'

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

#define REP(type, i, a, b) for( type i = a; i < b; i++ )
typedef long long ll;

using namespace std;

int main (void) {
    int N;
    scanf("%lld", &N);
    map<string, int> mp;

    REP(int, i, 0, N){
        string s, c;
        cin >> s >> c;
        if ( s.at(0) == 'i' ) mp[c]++;
        else{
            if ( mp.count(c) > 0 ) printf("yes\n");
            else printf("no\n");
        }
    }
    return 0;
}



Measured memory_bytes: 36544
import java.util.*;
 
 
class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int K = sc.nextInt();
        int S = sc.nextInt();
 
        int sum = 0;
 
        for(int x = 0;x <= K;x++){
            if(x > S) break;
           for(int y = 0;y <= K;y++){
               if(x + y > S) break;
               int z = S -x - y;
               if(z >= 0 && z <= K) sum++;
               }
           } 
        
        System.out.println(sum);
    }
}

Measured memory_bytes: 21460
#include <bits/stdc++.h>
#define rep(i, m, n) for(int i = m; i < (n); i++)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << " ";} cout << endl;
#define printa2(x,m,n) for(int i = 0; i < m; i++){ for(int j = 0; j < n; j++){ cout << x[i][j] << " ";} cout << endl;}
#define printp(x,n) for(int i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
typedef struct{
    int x;
    int y;
} P;
typedef struct{
    ll to;
    ll cost;
} edge;
typedef pair<ll, ll> lpair;
ll X[200010], Y[200010];
ll H,W,N;
map<lpair, ll> mp;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> H >> W >> N;
    rep(i,0,N){
        cin >> X[i] >> Y[i];
        X[i]--; Y[i]--;
    }
    // char c[20][20];
    // rep(i,0,H){
    //     rep(j,0,W){
    //         c[i][j] = '.';
    //     }
    // }
    // rep(i,0,N){
    //     c[X[i]][Y[i]] = '#';
    // }
    // rep(i,0,H){
    //     rep(j,0,W){
    //         cout << c[i][j];
    //     }
    //     cout << endl;
    // }
    map<lpair, ll> mp;
    rep(i,0,N){
        mp[make_pair(X[i], Y[i])] = 1;
    }
    ll pos[200010] = {};
    ll is_check[200010] = {};
    ll py = 0;
    rep(i,0,H-1){
        if(mp[make_pair(i+1,  py)] == 1){
            // print(i);
            pos[py] = i;
            is_check[py] = 1;
            break;
        }
        if(mp[make_pair(i+1, py+1)] == 0){
            pos[py] = i+1;
            is_check[py] = 1;
            py++;
        }
        // if(mp[make_pair(i, py+1)] == 1 && mp[make_pair(i+1, py)] == 1){
        //     pos[py] = i;
        //     break;
        // }else if(mp[make_pair(i+1, py)] == 1){
        //     pos[py] = i;
        //     break;
        // }else if(mp[make_pair(i, py+1)] == 1){
        //     pos[py] = i;
        // }else{
        //     pos[py++] = i;
        // }
        // cout << i << " " << py << endl;
    }
    // printa(pos, W);
    ll ans = H;
    rep(i,0,N){
        if(pos[Y[i]] < X[i] && is_check[Y[i]] != 0){
            ans = min(ans, X[i]);

        }
    }
    print(ans);

}


Measured memory_bytes: 40704
import java.util.*;
import java.io.*;

public class Main {
	public static void main(String []args)throws Exception{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String str=br.readLine();
		StringTokenizer st = new StringTokenizer(str);
		int a=Integer.parseInt(st.nextToken());
		int b=Integer.parseInt(st.nextToken());
		int c=a*b;
		if(c%2==0){
			System.out.print("Even");
		}else{
			System.out.print("Odd");
		}
	}
	
}


Measured memory_bytes: 21076
N,K,*A = $<.read.split.map &:to_i
A.sort!
P = A.bsearch_index {|a| a>0} || N
Z = A[0,P].bsearch_index {|a| a>=0} || P
if K <= Z*(N-P)
  X = A[0]*A[-1] .. A[Z-1]*A[P]
  B,C = Z<N-P && A.map!(&:-@) ? [A[P..-1].reverse!,A[0,Z]] : [A[0,Z],A[P..-1].reverse!]
  p X.bsearch {|x;t|
    u = -(x/-B[-1]) 
    i = C.bsearch_index {|c| t > c} || C.size  if t!=u && t=u
    j = B.size-1
    K <= C[i,N].inject(i*B.size) {|s,c;u|
      if u != x/c
        h,u = 1,x/c
        h += h  while h<j && B[j-h] > u
        j = j<h ? 0 : j-h
        j += h if B[j+h] <= u  while 0 < h>>=1
        j += 1 if B[j] <= u 
        break s  if j==0
      end
      s + j
    }
  }
  exit
end
exit p(0)  if K <= k = Z*(N-P) + (P-Z)*(2*(N-P+Z)+(P-Z-1))/2
x = [A[P-N]*A[P+1-N], A[0]*A[1], A[Z-1]*A[Z-2]].select {|x| x>0}
X = x.min .. [A[0]*A[1], A[-2]*A[-1]].max
B = A[0,Z].map!(&:-@).reverse
C = A[P,N-P]
p X.bsearch {|x|
  s = k
  [B,C].each{|a|
    j = a.size-1
    next if j<1 || a[0]*a[1] > x
    t = x/a[-1]
    i = a[0,j].bsearch_index {|a| a > t} || j
    s += (j+j-i+1)*i/2
    while j >= i+=1
      h,t = 1,x/a[i-1]
      h += h  while i<=j-h && a[j-h] > t
      j = i<=j-h ? j-h : i
      j += h if a[j+h] <= t  while 0 < h>>=1
      j += 1 if a[j] <= t
      s += j-i
    end
  }
  s >= K
}

Measured memory_bytes: 21116
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

long int gcd2(long int a, long int b) {
    long int one = (a >= b) ? a : b;
    long int two = (a >= b) ? b : a;
    long int buf = 0;
    while ((buf = one%two) != 0) {
        one = two;
        two = buf;
    }
    return two;
}

long int gcd(long int *a, int n) {
    long int start = a[0];
    for (int i=1; i<n; i++) {
        start = gcd2(start, a[i]);
    }
    return start;
}

int main() {
    int n = 0;
    long int x = 0;
    scanf("%d %ld\n", &n, &x);
    long int a[n];
    long int buf = 0;
    long int min = 1000000001;
    for (int i=0; i<n; i++) {
        scanf("%ld", &buf);
        a[i] = abs(buf - x);
    }
    long int ans = gcd(a, n);
    printf("%ld\n", ans);
    return 0;
}


Measured memory_bytes: 896
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  int n, k;
  cin >> n >> k;
  int score[3];
  for (int i = 0; i < 3; i++) cin >> score[i];
  vector<int> won(n);
  string s;
  cin >> s;
  for (int i = 0; i < n; i++) {
    if (i < k || s[i] != s[i - k] || !won[i - k]) won[i] = 1;
  }
  long long ans = 0;
  for (int i = 0; i < n; i++) if (won[i]) {
    if (s[i] == 'r') ans += score[2];
    if (s[i] == 's') ans += score[0];
    if (s[i] == 'p') ans += score[1];
  }
  cout << ans << '\n';
  return 0;
}

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

int main() {
  uint64_t H,W;
  cin >>H>>W;
  if (H ==1||W==1 ){
    cout << 1 << endl;
  }
  else{
    cout << H*(W/2)+(W%2)*(H-H/2) << endl;
  }
}


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

using namespace std;

int n;
int a[100010],diff[100010];
long long sum=0;

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",a+i);
		sum+=a[i];
	}

	for(int i=1;i<n;i+=2){
		diff[i+2]=diff[i]+(a[i+1]-a[i])*2;
	}
	diff[2]=diff[n]+(a[1]-a[n])*2;
	for(int i=2;i<n;i+=2){
		diff[i+2]=diff[i]+(a[i+1]-a[i])*2;
	}
	long long sum1=0;
	for(int i=1;i<=n;i++)
		sum1+=(long long)diff[i];
	long long base=(sum-sum1)/n;
	for(int i=1;i<=n;i++){
		printf("%d ",diff[i]+base);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 2048
#include<string>
#include<iostream>

using namespace std;




int main() {
//    MaximumRange m;
//    cout<<m.findMax("+--+--+")<<endl;
    int r,g,b;
    cin>>r>>g>>b;
    int a=r*100+g*10+b;
    if(a%4==0){
        cout<<"YES"<<endl;
    } else{
        cout<<"NO"<<endl;
    }
}


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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1;
    for(int T = 0; T < t ; T++){
        ll n, x;
       cin >> n >> x;
       ll a[n], ans = 0;
       for(int i = 0; i < n; i++)
            cin >> a[i];
       if(a[0] > x){
           ans += a[0] - x;
           a[0] = x;
       }
       for(int i = 1; i < n; i++){
           if(a[i] + a[i - 1] > x){
                ans += a[i] + a[i -1] - x;
               a[i] = x - a[i - 1];
           }
       }
       std::cout << ans  << std::endl;
    }
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <float.h>
#include <iomanip>
#include <iostream>
using namespace std;
 
int main(){

    int N;
    string S,half="";
    cin>>N>>S;

    for(int i=0;i<N/2;i++){
        half+=S[i];
    }

    half+=half;

    if(S==half){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }

    return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int ans = 0;
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
    if (i > 1) {
    if (((vec.at(i) < vec.at(i - 1)) && (vec.at(i - 1) < vec.at(i - 2)) || ((vec.at(i) > vec.at(i - 1))) && (vec.at(i - 1) > vec.at(i - 2)))) {
      ans++;
    }
    }
  }
  cout << ans << endl;
}

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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
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; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }
template <class T1, class T2, class Pred = std::less<T2> >
struct sort_pair_second {
    bool operator()(const std::pair<T1,T2>&left, const std::pair<T1,T2>&right) {
        Pred p;
        return p(left.second, right.second);
    }
};

int p[110];
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N, K;
    cin >> N >> K;
    rep(_, K) {
      int d; cin >> d;
      rep(_, d) {
        int A; cin >> A;
        p[A-1]++;
      }
    }
    int cnt = 0;
    rep(i, N) if (p[i]) cnt++;
    cout << N - cnt << endl;
    return 0;

}

Measured memory_bytes: 3668
import java.util.*;
 
public class Main {
	public static void main (String[] args) {
		Scanner in = new Scanner(System.in);
		
		int a = in.nextInt();
      	String s = in.next();
      
      if(a>=3200){System.out.print(s);}
      else{System.out.print("red");}
      
	}
}

Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int ctoi(const char c) {
    if ('0' <= c && c <= '9') return (c - '0');
    return -1;
}
vector<int> input(int n) {
    vector<int> vec(n);
    for (int i = 0; i < n; i++) {
        cin >> vec.at(i);
    }
    return vec;
}
void output(vector<int> vec) {
    for (int i = 0; i < vec.size(); i++) {
        cout << vec[i] << " ";
    }
    return;
}
vector<vector<int>> input(int n, int m) {
    vector<vector<int>> table(n, vector<int>(m));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> table. at(i).at(j);
        }
    }
    return table;
}
void output(vector<vector<int>> table) {
    for (int i = 0; i < table.size(); i++) {
        for (int j = 0; j < table.at(0).size(); j++) {
            cout << table.at(i).at(j) << " ";
        }
        cout << endl;
    }
}
long long perm(int n, int r) {
    if (n < r) {
        cout << "error" << endl;
        return 0;
    }
    long long perm = 1;
    for (int i = n; i > n - r; i--) {
        perm *= i;
    }
    return perm;
}
long long comb(int n, int r) {
    if (n < r) {
        cout << "error" << endl;
        return 0;
    }
    long long comb = perm(n,r);
    for (int i = r; i > 0; i--) {
        comb /= i;
    }
    return comb;
}
long long homo(int n, int r) {
    return comb(n + r - 1, n - 1);
}
long long fact(int n) {
    long long fact = 1;
    for (int i = n; i > 0; i--) {
        fact *= i;
    }
    return fact;
}
int gcd(int a, int b)
{
    if (a % b == 0)
    {
        return(b);
    }
    else
    {
        return(gcd(b, a % b));
    }
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int main() {
  int n,x;
  cin >> n >> x;
  vector<int> m=input(n);
  int sum=0;
  rep(i,n){
    sum+=m[i];
  }
  x-=sum;
  sort(m.begin(),m.end());
  int min=m[0];
  cout << n+x/min << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
    string s;
    cin >> s;
    int cnt = 0;
    for(int i = 0; i < 3; i++)
    {
        if(s[i] == 'o') cnt++;
    }

    cout << 700 + 100*cnt << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<cmath>
#define big long long
using namespace std;
 
int main() {
 
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);

	big n;
	cin>>n;
	big a[n+1],b[n];
	for(big i=0;i<n+1;i++) cin>>a[i];
	for(big i=0;i<n;i++) cin>>b[i];

	big ans=0;

	for(big i=0;i<n;i++)
	{
		big q=min(a[i],b[i]);
		a[i]-=q;
		b[i]-=q;
		big w=min(a[i+1],b[i]);
		a[i+1]-=w;
		b[i]-=w;
		ans+=(q+w);
	}

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

Measured memory_bytes: 1792
#include<iostream>
#include<cmath>

using namespace std;

bool is_prime(int x) {
  for(int i=2; i<ceil(sqrt(x)); i++) {
    if(x%i==0) return false;
  }
  return true;
}

int main() {
  int X;
  cin >> X;
  int ans = X;
  while(true) {
    if(is_prime(ans)) {
      break;
    }
    ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;


void solve(long long N, std::vector<long long> A){
    vector<LL> costs;
    LL sum=0;
    // costs.PB(A[0]);
    // sum+=A[0];
    for(int i=0; i < A.size()-1; i++){
        costs.PB(abs(A[i]-A[i+1]));
        sum+=abs(A[i]-A[i+1]);
    }
    // costs.PB(abs(A[N-1])); //back in 0
    // sum+=A[N-1];
    for(int i=1; i<=N; i++){
        int ans=sum;
        ans=sum-costs[i-1]-costs[i] + abs(A[i-1]-A[i+1]);
        cout<<ans<<endl;
    }

}

int main(){
    long long N;
    cin>>N;
    // scanf("%lld",&N);
    std::vector<long long> A;
    // for(int i = 0 ; i < N ; i++){
    //     scanf("%lld",&A[i]);
    // }
    A.PB(0);
    for(int i = 0 ; i < N ; i++){
        LL v;
        cin>>v;
        A.PB(v);

    }
    A.PB(0);
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 2932
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

ll modpow(ll a, ll N, ll mod) {
  ll ans = 1;
  ll tmp = a;
  while(N > 0) {
    if(N % 2 == 1) (ans *= tmp) %= mod;
    (tmp *= tmp) %= mod;
    N /= 2;
  }
  return ans;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  string x; cin >> x;
  int mx = 300005;
  vector<int> memo(mx);
  rep(i, mx) {
    int cur = i;
    int cnt = 0;
    while(cur) {
      int p = __builtin_popcount(cur);
      cur %= p;
      cnt++;
    }
    memo[i] = cnt;
  }
  int one = 0;
  rep(i, n) if(x[i]=='1') one++;
  map<int, int> mp;
  for(int j=max(one-1, 1); j<=one+1; j++) {
    rep(i, n) {
      if(x[i]=='1') (mp[j] += modpow(2, n-1-i, j)) %= j;
    }
  }
  rep(i, n) {
    if(x[i] == '0') {
      int cur = (mp[one+1] + modpow(2, n-1-i, one+1)) % (one+1);
      cout << memo[cur]+1 << "\n";
    } else {
      if(one-1 == 0) {
        cout << 0 << "\n";
      } else {
        int cur = (mp[one-1] + (one-1) - modpow(2, n-1-i, one-1)) % (one-1);
        cout << memo[cur]+1 << "\n";
      }
    }
  }
  return 0;
}


Measured memory_bytes: 4672
#include<bits/stdc++.h>
#define mins(a,b) a=min(a,b)
#define maxs(a,b) a=max(a,b)
using namespace std;

int main(){
  char s;
  cin>>s;
  if(s=='A')
  cout<<'T'<<endl;
  if(s=='T')
  cout<<'A'<<endl;
  if(s=='C')
  cout<<'G'<<endl;
  if(s=='G')
  cout<<'C'<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
            #define ll long long
            #define f   first
            #define s   second
            #define pb          push_back
            #define mod        1000000007
            #define mod1       1000000009
            #define hell        998244353
            #define inf         1000000000000000000LL
            #define pi          3.14159265358979323
            //#define N           100005 
            const int N=1000005;
            using namespace std;
            ll n,k,sum,q,res,m,val,ans;
            ll x,y;
            double p;
            ll xx[]={1,0,-1,0};
            ll yy[]={0,1,0,-1};
            void solve()    
            {   ll a,b,c;
                cin>>a>>b>>c;
                if(b*c>=a) cout<<"Yes";
                else cout<<"No";

                
                
            }
            int main()  
            {   ios_base::sync_with_stdio(false);
                cin.tie(0);cout.tie(0);
                ll t=1;
                
                //cin>>t;
                 for(ll i=1;i<=t;i++)
                    solve();
                
            }            


Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
int main(){
	int k,n;
    cin>>k>>n;
    vector<int>a(n);
    for(int i=0;i<n;i++)cin>>a[i];
    int maxl =k-a[n-1]+a[0];
    for(int i=0;i<n-1;i++){
    maxl=max(maxl,a[i+1]-a[i]);
    }
    cout<<k-maxl<<endl;
    }
    

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

using i64 = long long int;

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

    int left = 0, right = s.size()-1, lc = 0, rc = 0;
    int ans = 0;
    bool ok = true;
    while(left <= right){
        if(s[left] == 'x' && s[right] == 'x'){
            lc++; rc++;
            left++; right--;
        }else if(s[left] == 'x' && s[right] != 'x'){
            lc++;
            left++;
        }else if(s[left] != 'x' && s[right] == 'x'){
            rc++;
            right--;
        }else if(s[left] != s[right]){
            ok = false;
            break;
        }else{
            ans += max(lc, rc) - min(lc, rc);
            lc = 0; rc = 0;
            left++; right--;
        }
    }

    cout << (ok ? ans : -1) << endl;

    return 0;
}


Measured memory_bytes: 512
chomp (my ($n, $k) = split / /, <STDIN>);

$sum = 0;
for my $i (1..$n) {
  if ($i >= $k) {
    $sum += 1;
    next;
  }
  $cnt = 1;
  while ($k > $i * 2 ** $cnt) {
    $cnt++;
  }
  $sum += 0.5 ** $cnt;
}
$sum /= $n;
print "$sum\n";

Measured memory_bytes: 896
import numpy as np
from collections import deque
h, w = map(int, input().split())

inf = 1009
grid = np.zeros((h + 2, w + 2), dtype=int)
for i in range(h):
    grid[i + 1][1:-1] = np.array([1 if j == "." else 0 for j in input()])
white = grid.sum()

cost = np.ones((h+2, w+2), dtype=int)*inf
cost[1][1] = 1

d = ((1, 0), (0, 1), (-1, 0), (0, -1))
to = deque([(1, 1)])
while to:
    x, y = to.popleft()
    c = cost[x][y]
    for xi, yi in d:
        nx = x + xi
        ny = y + yi
        if not grid[nx][ny]:
            continue
        to.append((nx, ny))
        cost[nx][ny] = min(cost[nx][ny], c+1)
        grid[nx][ny] = 0

if cost[-2][-2] == inf:
    ans = -1
else:
    ans = white-cost[-2][-2]
print(ans)


Measured memory_bytes: 22200
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Random;
import java.util.Collections;
import java.util.ArrayDeque;
import java.util.Queue;
import java.util.Deque;

public class Main{
    public static void main (String args[]){

        Scanner first = new Scanner(System.in);
        int first_word = first.nextInt();
        
        int hundred = first_word/100;
        first_word = first_word-hundred*100;
        int ten     = (first_word)/10;
        first_word = first_word - ten*10;
        
        int one     = first_word;
        if(hundred == one ){
            System.out.println("Yes");

        }else{
            System.out.println("No");

        }
    }
}

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

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

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

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

    return a

result = factorization(N)

count = 0
for p, i in result:
    if p == 1:
        continue
    s = 0
    for k in range(1, i+1):
        if s + k > i:
            break
        else:
            N /= p ** k
            count += 1
            s += k
print(count)


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

LL n,a,b,c,d;
map<LL,LL> s;
LL dfs(LL n=1e18){
	if(n==0){
		return 0;
	}
	if(s.count(n)){
		return s[n];
	}
	LL &ans=s[n];
	ans=((LL)1e15)/n<d?1e15:n*d;
	ans=min(ans,dfs(n/2)+a+(n%2)*d);
	ans=min(ans,dfs(n/3)+b+(n%3)*d);
	ans=min(ans,dfs(n/5)+c+(n%5)*d);
	ans=min(ans,dfs(n/2+1)+a+(2-n%2)*d);
	ans=min(ans,dfs(n/3+1)+b+(3-n%3)*d);
	ans=min(ans,dfs(n/5+1)+c+(5-n%5)*d);
	return ans;
}

void work(){
	cin>>n>>a>>b>>c>>d;
	s.clear();
	cout<<dfs(n)<<endl;
}

int main(){
	int t;
	cin>>t;
	while(t--){
		work();
	}
	return 0;
}

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

int main(){
  ll n;
  cin >> n;
  ll ans = 0;
  ans = (n/11)*2;
  if (n%11 > 6) ans +=2;
  else if (n%11 == 0);
  else{
    ans += 1;
  }
  
  cout << ans << endl;

 
 
 

  return 0;
}


Measured memory_bytes: 3636
import java.io.*
import java.util.*

var pw = PrintWriter(System.out)
fun solve(a: Long, b: Long){
    println((a+b)/2 + (a+b) % 2)
    pw.flush()
    return
}


fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val a = sc.next().toLong()
    val b = sc.next().toLong()
    solve(a, b)
}



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

using namespace std;

typedef long long ll;

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

	char not_one_num;
	bool one_flag = true;
	for(int i = 0; i < k; i++){
		if(s[i] != '1'){
			not_one_num = s[i];
			one_flag = false;
			break;
		}
	}

	if(!one_flag){
		cout << not_one_num << endl;
	}else{
		cout << "1" << endl;
	}
}

Measured memory_bytes: 256
a, b = gets.split.map(&:to_i)
s = gets.chomp

if (s[0..a-1].include?("-"))
    puts "No"
    exit
end

if (s[a] != "-")
    puts "No"
    exit
end

if (s[a+1..a+1+b-1].include?("-"))
    puts "No"
    exit
end

puts "Yes"


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

struct Edge{int to, id;};
vector<vector<Edge>> glaph;
vector<int> ans;

void dfs(int v, int p=-1, int k=-1){
  int c = 1;                  //辺の色
  rep(i, glaph[v].size()){
    int u = glaph[v][i].to;
    int ei = glaph[v][i].id;  //edge id
    if(u == p) continue;      //親方向の頂点と同じ場合スキップ
    if(c == k) c++;           //親方向の辺と同色の場合スキップ
    ans[ei] = c;  c++;        //辺に色を付ける
    dfs(u, v, ans[ei]);       //再帰 dfs(現在の頂点, 親方向の頂点, 親方向の辺)
  }
}

int main(){
  int n;
  cin >> n;
  glaph.resize(n);          //要素数nでリサイズ
  ans.resize(n);            //要素数nでリサイズ
  rep(i, n-1){
    int a, b;
    cin >> a >> b;
    a--; b--;               //1 <= ai < bi <= N のためデクリメント
    glaph[a].push_back((Edge){b, i});
    glaph[b].push_back((Edge){a, i});
  }
  dfs(0);                   //dfs実行
  //色の数を求め出力
  int mx = 0;
  rep(i, n) mx = max(mx, int(glaph[i].size()));
  cout << mx << endl;
  //各辺の色を出力
  rep(i, n-1) cout << ans[i] << endl;

  return 0;
}


Measured memory_bytes: 8320
h,w = map(int,input().split())
masu = [input() for i in range(h)]
masu = [i for i in masu if i != "."*w]
Tmasu =[]
for j in range(w):
    x = [s[j] for s in masu]
    Tmasu.append("".join(x))
Tmasu = [i for i in Tmasu if i != "."*len(masu)]
ans = []
for k in range(len(masu)):
    x = [s[k] for s in Tmasu]
    ans.append("".join(x))
for l in ans:
    print(l)

Measured memory_bytes: 3064
N = int(input())
S = input()

cR = len([1 for s in S if s == 'R'])
cG = len([1 for s in S if s == 'G'])
cB = len([1 for s in S if s == 'B'])
# 条件2を無視したときの組の数
_all = cR * cG * cB

# 条件2でNGになるような組の数
ng_condition2 = 0
for i in range(N-1):
  for j in range(i+1, N):
    k = j+j-i
    if k >= N:
      break
    if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
      ng_condition2 += 1

print(_all - ng_condition2)

Measured memory_bytes: 9156
#include <iostream>
#include <algorithm>
#include <vector>
#include <functional>
#include <cmath>
#include <string>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
const int MOD = 1000000007;

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int main(){
    int n;cin>>n;
    int p[100000];
    rep(i,n)cin>>p[i];

    sort(p,p+n);
    cout<<p[n/2]-p[n/2-1]<<endl;
}

Measured memory_bytes: 640
def intinput(): return map(int,input().split())

n,k=intinput()
s=input()
x=1
cnt=0
lis=[]
for i in range(n):
    if s[i]==str(x):
        cnt+=1
    else:
        lis.append(cnt)
        cnt=1
        x ^= 1
lis.append(cnt)
if len(lis)%2==0:
    lis.append(0)
x=[0]
for i in range(len(lis)):
    x.append(x[i]+lis[i])
l = 2*k+1
ans=0
for i in range(0,len(x),2):
    left=i
    right=min(len(x)-1,l+i)
    tmp = x[right]-x[left]
    ans = max(ans,tmp)
print(ans)

Measured memory_bytes: 7932
height, width = gets.split.map(&:to_i)
field = []
height.times do
  field << gets.chomp.split('').map{ |p| p=='.' ? 0 : p }
end
field.each.with_index do |line, h|
  line.each.with_index do |point, w|
    if point == '#'
      (h-1..h+1).each do |h2|
        (w-1..w+1).each do |w2|
          if h2.between?(0, height-1) && w2.between?(0, width-1)
            field[h2][w2] += 1 unless field[h2][w2] == '#'
          end
        end
      end
    end
  end
end
field.each do |line|
  puts line.join('')
end


Measured memory_bytes: 2172
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);
        int s = scan.nextInt();
        int w = scan.nextInt();

		if (w>=s) {
			System.out.println("unsafe");
		} else {
			System.out.println("safe");
		}
	    scan.close();	
    }
}

Measured memory_bytes: 35680
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define Repr(i, n, a) for (int i = (n); i >= (a); i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) a.begin(), a.end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;

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

    int a, b;
    cin >> a >> b;
    cout << ((a * b) % 2 ? "Odd" : "Even") << endl;
}

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

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

fn main() {
  let (a, b): (i8, i8) = (read(), read());
  println!("{}",
    if a > b { a + (a - 1) }
    else if a < b { b + (b - 1) }
    else { a + b }
  );
}

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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = 1e18;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
//#define mp make_pair

int main() {
  ll n, p;
  cin >> n >> p;
  if (n == 1) {
    cout << p << endl;
    return 0;
  }
  map<ll, ll> cnt;
  for (ll i = 2; i*i <= p; i++) {
    while (p % i == 0) {
      cnt[i]++;
      p /= i;
    }
  }
  if (p > 1) {
    cnt[p]++;
  }
  ll ans = 1;
  for (auto itr = cnt.begin(); itr != cnt.end(); itr++) {
    DEBUG(*itr);
    if (itr->second < n) continue;
    ans *= pow(itr->first, (itr->second / n));
  }
  cout << ans << endl;
}


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

int main()
{
   vector <int>a;
   int i,input;
   for(i=0;i<10;i++)
   {
       cin>>input;
       a.push_back(input);
   }
   sort(a.begin(),a.end());
   reverse(a.begin(),a.end());
    for(i=0;i<3;i++)
        cout<<a[i]<<endl;
    return 0;
}



Measured memory_bytes: 3168
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			var N = int.Parse(Console.ReadLine());
			string s = Console.ReadLine();
			var array = new bool[N];
			for (int i = 0; i < N; i++)
			{
				array[i] = s[i] == 'o';
			}
			var result = new bool[][] { new[] { true, true }, new[] { true, false }, new[] { false, true }, new[] { false, false } };
			for (int i = 0; i < 4; i++)
			{
				if(GetString(result[i], array, N) != "-1")
				{
					Console.WriteLine(GetString(result[i], array, N));
					return;
				}
			}
			Console.WriteLine("-1");
		}
		static string GetString(bool[] K,bool[] s, int N)
		{
			var answer = new bool[N+1];
			answer[0] = K[0];
			answer[1] = K[1];
			for (int i = 1; i < N; i++)
			{
				if (answer[i] == true && answer[i - 1] == true)
				{
					if (s[i])
					{
						answer[i+1] = true;
					}
					else
					{
						answer[i+1] = false;
					}
				}
				else if (answer[i] == false && answer[i - 1] == true)
				{
					if (s[i])
					{
						answer[i+1] = false;
					}
					else
					{
						answer[i+1] = true;
					}
				}
				else if (answer[i] == true && answer[i - 1] == false)
				{
					if (s[i])
					{
						answer[i+1] = false;
					}
					else
					{
						answer[i+1] = true;
					}
				}
				else if (answer[i] == false && answer[i - 1] == false)
				{
					if (s[i] )
					{
						answer[i+1] = true;
					}
					else
					{
						answer[i+1] = false;
					}
				}
			}
			if (answer[0] == answer[N]&&((s[0] == answer[0] == answer[1] == answer[N-1])||(!s[0] == !(answer[0] == answer[1] == answer[N - 1]))))
			{
				return string.Join("", answer.Take(N).Select(z => z ? "S" : "W"));
			}
			else
			{
				return "-1";
			}
		}
	}
}


Measured memory_bytes: 13396
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

int n, Ma, Mb;
int a[50], b[50], c[50];
// dp[i][j][k] := i番目までの薬局をみて, タイプAの薬がjグラムで, Bの薬がkグラムの時の最小費用  
int dp[50][500][500];
const int INF = 1 << 30;

int main(void){
    cin >> n >> Ma >> Mb;
    rep(i, n) cin >> a[i] >> b[i] >> c[i];
    rep(i, 50)rep(j, 500)rep(k, 500)dp[i][j][k] = INF;
    dp[0][0][0] = 0;
    rep(i, n){
        rep(j, 500)rep(k, 500){
            if(dp[i][j][k] == INF) continue;
            //i番目の薬局を使う
            chmin(dp[i + 1][j + a[i]][k + b[i]], dp[i][j][k] + c[i]);
            //i番目の薬局を使わない
            chmin(dp[i + 1][j][k], dp[i][j][k]);
        }
    }

    int ans = INF;
    for(int i = 1; i < 50; i++){
        int A = Ma * i, B = Mb * i;
        if(A > 490 || B > 490) break;
        chmin(ans, dp[n][A][B]);
    }
    if(ans == INF) printf("-1\n");
    else printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 49024
from functools import reduce
import math

def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    # 1e10

    # 初期値用:十分小さい数(-100億)
    # -1e10
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    a, b, c = (_ for _ in input().split())
    if a[-1]==b[0] and b[-1] == c[0]:
        print('YES')
    else:
        print('NO')
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
int c=0,d=0;
vector<int>v[10];
int main()
{
    int a,b,i;
    for(i=0;i<3;i++)
    {
        cin>>a>>b;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    for(i=1;i<=4;i++)
    {
        if(v[i].size()==1)
        {
            c++;
        }
        else if(v[i].size()==2)
        {
            d++;
        }
    }
    if(c==d&&c==2)
    {
        cout<<"YES\n";
    }
    else
    {
        cout<<"NO\n";
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int K;
  int S=0;
  cin>>K;
  for(int A=1;A<=K;A++){
    for(int B=1;B<=K;B++){
      for(int C=1;C<=K;C++){
        S+=__gcd(A,__gcd(B,C));
      }
    }
  }
  cout<<S<<endl;
}

Measured memory_bytes: 3588
firstLine = list(map(int, input().split()))
costs = []

for i in range(firstLine[0]):
    line = list(map(int, input().split()))
    if line[1]> firstLine[1]:
        continue
    else:
        costs.append(line[0])

if len(costs)>0:
    print(sorted(costs)[0])
else:
    print("TLE")    

Measured memory_bytes: 3060