akhauriyash/Code-Regression huggingface dataset:
/******************************************************************************

                            Online C Compiler.
                Code, Compile, Run and Debug C program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <stdio.h>

int main()
{
    int A;
    int B;
    int sum = 0;
    scanf("%d",&A);
    scanf("%d",&B);
    int i = 0;
    while(i<2){
        if(A>B){
            sum += A;
            A--;
        }
        else{
            sum+=B;
            B--;
        }
    
        i++;
    }
    printf("%d", sum);
    return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
    
    public static void main(String... args) {
        Scanner scanner = new Scanner(System.in);
        String[] numbers = scanner.nextLine().split(" ");
        int w = Integer.parseInt(numbers[0]);
        int h = Integer.parseInt(numbers[1]);
        int x = Integer.parseInt(numbers[2]);
        int y = Integer.parseInt(numbers[3]);
        int r = Integer.parseInt(numbers[4]);
        
        int right = x - r;
        int top = y + r;
        int left = x + r;
        int bottom = y - r;
        
        if ((right >= 0 && right <= w - 2*r)
            && (bottom >= 0 && bottom <= h - 2*r)
            && (left <= w) && (top <= h)) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
    }
}


Measured memory_bytes: 26324
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define bit(n,k) (((ll)n>>(ll)k)&1) /*nのk bit目*/
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
vl dx={-1,-1,-1,0,0,1,1,1};
vl dy={1,-1,0,1,-1,1,0,-1};
ll flag[1LL<<16];
ll dp[1LL<<16];
ll n;
vvl a(20,vl(20));
ll f(ll S){
  if(flag[S])return dp[S];
  flag[S]=1;
  ll temp=0;
  rep(i,n-1){
    for(ll j=i+1;j<n;j++){
      if(bit(S,i)&&bit(S,j))temp+=a[i][j];
    }
  }
  ll fans=temp;
  for(ll T=(S-1)&S;T>0;T=(T-1)&S){
    fans=max(fans,f(T)+f(S^T));
  }
  dp[S]=fans;
  return fans;
}

int main(){
  cin>>n;
  rep(i,n){
    rep(j,n)cin>>a[i][j];
  }
  cout<<f((1LL<<n)-1)<<endl;
}

Measured memory_bytes: 1280
N = int(input())
w = [input() for i in range(N)]


if len(set(w)) == N: #set:重複なしのリスト(型はlistではなく、set)
    if all(w[i][-1] == w[i+1][0] for i in range(N-1)):
        print("Yes")
        exit() #プログラムを終了

print("No")

Measured memory_bytes: 9032
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(lint i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;
lint p=1e9+7;

lint pow_mod(lint a,lint b,lint p){
  if(b==0)return 1;
  if(b%2==0){
    lint d=pow_mod(a,b/2,p);
    return (d*d)%p;
  }else{
    return (a*pow_mod(a,b-1,p))%p;
  }
}

//x / a mod p=x * inv_mod(a,p) 
lint inv_mod(lint a,lint p){
  return pow_mod(a,p-2,p);//(a^(p-2))mod p
}


int main(){
  lint N,M,K;
  cin>>N>>M>>K;
  lint ans=0;
  FOR(i,1,N){
    ans+=i*(N-i)*M*M;
    ans%=p;
  }
  FOR(i,1,M){
    ans+=i*(M-i)*N*N;
    ans%=p;
  }
  cerr<<ans<<endl;
  lint d=1;
  REP(i,K-2){
    ans*=((N*M-2)-i);
    ans%=p;
    d*=i+1;
    d%=p;
  }
  ans*=inv_mod(d,p);
  ans%=p;
  if(ans<0)ans+=p;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int c[3][3], i, j;
    int a[2][3];
    for(i=0; i<3; i++) {
        for(j=0; j<3; j++) {
            cin >> c[i][j];
            if(i>0) {
                a[i-1][j] = c[i][j] - c[i-1][j];
            }
        }
    }

    for(i=0; i<2; i++) {
        for(j=1; j<3; j++) {
            if(a[i][0]!=a[i][j]) {
                cout << "No" << endl;
                return 0;
            }
        }
    }

    cout << "Yes" << endl;
    return 0;
    
}

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

int main() {
  int count = 0;
  string s;
  cin >> s;
  if(s == "RRR") count = 3;
  if((s ==  "RRS") || (s == "SRR")) count = 2;
  if((s == "RSR") || (s == "RSS")) count = 1;
  if((s == "SSR") || (s == "SRS")) count = 1;
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 3624
L, R = map(int, input().split())
S = 2019
if ((L-1) // 2019) != (R // 2019):
  print(0)
else:
  for i in range(L, R):
    for j in range(i+1, R+1):
      S = min((i*j)%2019, S)
  print(S)

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

int main(){long A, B, C, D, E, F;
cin >> A >> B >> C >> D >> E >> F;

vector<long> dp(3000 + 10);
// rep(i, C) dp.at(i) = 0;
for(long i = C; i <= D - 1; i++) dp.at(i) = C;
for(long i = D; i <= 3000; i++){
    dp.at(i) = max(dp.at(i - C) + C, dp.at(i - D) + D);
}
vector<bool> dpw(30 + 5);
rep(i, 33) dpw.at(i) = false;
dpw.at(0) = true;
for(long i = A; i <= B - 1; i++){
    if(dpw.at(i - A)) dpw.at(i) = true;
}
for(long i = B; i <= 31; i++){
    if(dpw.at(i - A) || dpw.at(i - B)) dpw.at(i) = true;
}

long tmp = 0; long dpi; long recall, rec;
for(long i = 1; i <= F / 100; i++){
    if(dpw.at(i)){
    dpi = dp.at(min(i * E, F - i * 100));
    if(dpi * 10000 / (i * 100 + dpi) >= tmp){
        tmp = dpi * 10000 / (i * 100 + dpi);
        recall = i * 100 + dpi;
        rec = dpi;
    }
    }
}
cout << recall << ' ' << rec << endl;
// cout << ans << endl;
return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
#define ll long long
#define Add_Speed ios_base::sync_with_stdio(0);cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define f first
#define sz size()
#define s second          
#define pii pair<int, int>
#define int ll
#define all(s) s.begin(), s.end()
#define file(s) freopen(s".in","r",stdin); freopen(s".out","w",stdout);

using namespace std;
 
const int maxn = (int)2e5 + 100;
const int M = (int)2e6 + 100;
const int mod = (int)1e9 + 7;
const int inf = mod;                

int n, x, y, f[maxn], inv[maxn];
int binpow(int a, int b){
    if(b == 0) return 1;
    if(b % 2 == 0){
        int d = binpow(a, b / 2);
        return d * 1ll * d % mod;
    }
    else{
        int d = binpow(a, b - 1);
        return d * 1ll * a % mod;
    }                   
}
int C(int n, int k){
    return (f[n] * 1ll * inv[k]) % mod * 1ll * inv[n - k] % mod % mod;
}
int calc(int x, int y, int x1, int y1){
    int tot = x1 - x + y1 - y;
    return C(tot, x1 - x);
}
int dp[maxn], h, w;
pii a[maxn];
main () {
    Add_Speed;
    cin >> h >> w >> n;
    f[0] = inv[0] = 1;
    for(int i = 1; i < maxn; i++) f[i] = f[i - 1] * 1ll * i % mod, inv[i] = binpow(f[i], mod - 2);
    for(int i = 1; i <= n; i++) cin >> a[i].f >> a[i].s; 
    a[++n] = mp(h, w);
    sort(a + 1, a + n + 1);
    for(int i = 1; i <= n; i++){
        dp[i] = calc(1, 1, a[i].f, a[i].s);
        for(int j = 1; j < i; j++){
            if(a[j].s <= a[i].s)
                dp[i] = (dp[i] - (dp[j] * calc(a[j].f, a[j].s, a[i].f, a[i].s) % mod) + mod);
                dp[i] %= mod;
        }
    }
    cout << dp[n];
}               

Measured memory_bytes: 6144
A = input()
B = input()
C = input()
D = input()
E = input()
total = 0
last = 0

for i in [A, B, C, D, E]:
  if i[-1] == '0':
    total += int(i)
  else:
    total += int(i[0:-1] + '0') + 10
    if last < (10 - int(i[-1])):
      last = 10 - int(i[-1])

print(total-last)


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <unordered_map>
#include <map>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <deque>
#include <cmath>
#include <stack>
#include <queue>

#define nl '\n'

using namespace std;

long long n, x, y;

int main(){

    cin >> n;

    x = round(sqrt(n));

    while(n%x != 0){
        x--;
    }

    y = n/x;

    cout << x + y -2;

}

//g++ -std=c++14 comp.cpp -o b; ./b.exe


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define all(a) (a).begin(), (a).end()
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define sz() size()
#define fr first
#define sc second
#define int long long
#define mp make_pair
#define rc(s) return cout<<s,0
#define rcc(s) cout<<s,exit(0)
using namespace std;

int sum;
char x;

int32_t main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
    srand(chrono::steady_clock::now().time_since_epoch().count());
    while(cin >> x){
        sum += (x - '0');
    }
    if(sum % 9 == 0){
        cout << "Yes" << '\n';
    }
    else{
        cout << "No" << '\n';
    }
}


Measured memory_bytes: 3656
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll h,w,k;
  cin >> h >> w >> k;
  ll res = 0;
  vector<string> s(h);
  for(int i = 0;i < h;i++)cin >> s[i];
  for(int i = 0;i < (1<<h + w);i++){//2のa乗回繰り返す(0 ~ 2^a- 1)
    ll now = 0;
    for(int j = 0;j < h;j++){
      for(int k = 0;k < w;k++){
        if(s[j][k] == '#' && !(i & (1<<j)) && !(i & (1<<h+k)))now++;
      }
    }
    if(now == k)res++;
  }
  cout << res << endl;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  string S, T;
  cin >> S;
  cin >> T;

  bool ok = false;
  rep(i,S.size()){
    string rotS = S.substr(i) + S.substr(0,i);
    if(rotS == T) ok = true;
  }

  if(ok) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())


int n, c, k;
int t[100000];


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

	cin >> n >> c >> k;
	rep(i, n)cin >> t[i];

	sort(t, t + n);
	int ans = 0, idx = 0;
	while (idx<n) {
		int nxt = upper_bound(t, t + min(n,idx+c), t[idx] + k) - t;
		idx = nxt;
		ans++;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;
import java.math.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		BigInteger A = sc.nextBigInteger();
		BigInteger B = sc.nextBigInteger();
		if(A.compareTo(B) == 0) System.out.println("EQUAL");
		else if(A.compareTo(B) > 0) System.out.println("GREATER");
		else if(A.compareTo(B) < 0) System.out.println("LESS");
	}

}

Measured memory_bytes: 23892
#include <cstdio>
#include <algorithm>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)

constexpr int MAX_N = 100000, MAX_K = 1000;

int N, K;
int fld[2*MAX_K][2*MAX_K], S[4*MAX_K+1][4*MAX_K+1], S_mod[2*MAX_K+1][2*MAX_K+1];

int main()
{
  scanf( "%d%d", &N, &K );

  int ox, oy;
  rep( i, N )
  {
    int x, y;
    char c;
    scanf( "%d%d %c", &x, &y, &c );

    if( c == 'W' )
      y += K;

    x %= 2*K;
    y %= 2*K;
    //++fld[(x+add)%(2*K)][y%(2*K)];
    //++fld[x%(2*K)][(y+add)%(2*K)];
    
    ++S[x][y];
    --S[x][y+K];
    --S[x+K][y];
    ++S[x+K][y+K];

    ++S[x+K][y+K];
    --S[x+K][y+2*K];
    --S[x+2*K][y+K];
    ++S[x+2*K][y+2*K];

    /*nx = (x+add)%(2*K), ny = y%(2*K);
    left = std::max( 0, nx-K ), bottom = std::min( 2*K-1, ny+K );
    
    ++S[left][ny];
    --S[nx+1][ny];
    --S[left][bottom];
    ++S[nx+1][bottom];*/
  }

  rep( i, 4*K+1 ) rep( j, 4*K )
    S[i][j+1] += S[i][j];
  rep( i, 4*K ) rep( j, 4*K+1 )
    S[i+1][j] += S[i][j];

  rep( i, 4*K ) rep( j, 4*K )
    S_mod[i%(2*K)][j%(2*K)] += S[i][j];

  int ans = 0;
  rep( i, 2*K ) rep( j, 2*K )
    ans = std::max( ans, S_mod[i][j] );

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

  return 0;
}

Measured memory_bytes: 80000
import math
A, B, C, D = map(int, input().split())


def lcm(x, y):
    return (x * y) // math.gcd(x, y)

X = lcm(C, D)

ansB = (B-B//C)+(B-B//D)-(B-B//X)
ansA = ((A-1)-((A-1)//C))+((A-1)-(A-1)//D)-((A-1)-(A-1)//X)

print(ansB-ansA)

Measured memory_bytes: 62228
#include <bits/stdc++.h>
using namespace std;
int main(){
	char c;
  	cin>>c;
  
  	if(c=='A'){
		cout<<'T'<<endl;
    }else if(c=='T'){
		cout<<'A'<<endl;
    }else if(c=='G'){
		cout<<'C'<<endl;
    }else{
		cout<<'G'<<endl;
    }
}

Measured memory_bytes: 256
import bisect
A,B,Q = map(int,input().split())
INF = float('inf')
S = [-INF]+[int(input()) for _ in range(A)]+[INF]
T = [-INF]+[int(input()) for _ in range(B)]+[INF]

ans = []
for q in range(Q):
    x = int(input())
    i = bisect.bisect_right(S,x)
    j = bisect.bisect_right(T,x)
    d = INF
    for s in [S[i-1],S[i]]:
        for t in [T[j-1],T[j]]:
            d1 = abs(x-s) + abs(s-t)
            d2 = abs(x-t) + abs(s-t)
            d = min(d,d1,d2)
    ans.append(d)
print(*ans,sep="\n")

Measured memory_bytes: 23932
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
int main(){
	vector<P> vec;
	while(1){
		vec.clear();
		string s;
		for(int j=0;j<3;j++){
			cin >> s;
			if(s=="0")goto end;
			if(s[0]=='A'&&!vec.empty())vec.back().fi++;
			else if(s[0]=='B'&&!vec.empty())vec.back().sec++;
			int a = 0,b = 0;
			for(int i=1;i<s.size();i++){
				if(s[i]=='A')a++;
				else b++;
			}
			vec.pb(P(a,b));
		}
		if(vec.back().fi>=10&&vec.back().sec>=10){
			if(vec.back().fi>vec.back().sec)vec.back().fi++;
			else vec.back().sec++;
		}
		else{
			if(vec.back().fi>vec.back().fi)vec.back().fi++;
			else vec.back().sec++;
		}
		for(int i=0;i<vec.size();i++){
			printf("%d %d\n",vec[i].fi,vec[i].sec);
		}
	}
	end:;
	return 0;
}

Measured memory_bytes: 1188
#include <iostream>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
#include <tuple>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; --i)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);++i)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int n;
int v[50];
int dp[55][55];
priority_queue<int, vector<int>, greater<int>> que;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n;
  REP(i, n) {
    double a;
    cin >> a;
    que.push(a);
  }

  double ans = que.top(); que.pop();
  while(que.size() >= 1) {
    ans = (ans + que.top()) / 2;
    que.pop();
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  int n;
  int y,m,d;
  cin>>n;
  while(cin>>y>>m>>d){
    int s=(y-1)*195 + (m-1)*19 + m/2 + d-1;
    s += ((y-1)/3)*5;
    if(y%3==0)s += (m-1)/2;
    cout<<196470-s<<endl;
  }
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
using namespace std;
using ll = long long;
const ll MOD = (ll)1e9 + 7;
#define debug(x) cout << #x << ": " << x << endl

ll power(const ll& a, const ll& x) // a^x
{
    if(x == 0) return 1;
    ll res = power(a, x>>1);
    res = res * res % MOD;
    if(x & 1) res = res * a % MOD;
    return res;
}

ll inverse(const ll& a)
{
    return power(a, MOD - 2);
}

ll calc(const ll& n, const ll& a)
{
    ll p = 1, q = 1;
    for(int i = 0; i < a; i++)
    {
        p *= n - i;
        p %= MOD;
        q *= i + 1;
        q %= MOD;
    }
    return (p * inverse(q)) % MOD;
}

void solve()
{
    ll n, a, b; cin >> n >> a >> b;
    ll ans = power(2LL, n);
    ans -= 1LL;
    ans = (ans - calc(n, a)) % MOD;
    ans = (ans - calc(n, b)) % MOD;
    cout << (ans % MOD + MOD) % MOD << endl;
}

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define intMax 2147483647
#define rep(i, a, b) for (long long i = a; i < b; i++)
#define repp(i, a, b) for (long long i = a; i >= b; i--)
#define be(a) (a.begin(), a.end())
#define rbe(p) (p.rbegin(), p.rend())
#define pb push_back
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long n, m;
    cin >> n >> m;
    long long k = 2019;
    long long ans = intMax;
    for (long long i = n; i <= n + 2020 && i <= m; i++)
    {
        for (long long j = m; j >= n && j >= m - 2020; j--)
        {
            if ( i == j ){
                continue;
            }
            ans = min(ans, (i * j) % 2019);
        }
    }
    cout << ans;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<stack>
#define inf 0x3f3f3f3f
#define esp 1e-7
using namespace std;
long long read(){
    long long x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}

int n,num[100050];
int a[5];

int main(){
	n=read();
	memset(num,0,sizeof(num));
	memset(a,0,sizeof(a));
	for (int i=1;i<=n;i++){
		int tmp=read();
		while((tmp&1)==0){
			num[i]++;
			tmp>>=1;
		}
		if(num[i]>=2)	a[2]++;
		else	a[num[i]]++;
	}
	if (a[2]>=a[0])	printf("Yes\n");
	else if (a[1]==0&&a[0]<=a[2]+1)	printf("Yes\n");
	else			printf("No\n");
	
	return 0;
}

Measured memory_bytes: 640
from collections import Counter
from operator import itemgetter

n = int(input())
v = [int(x) for x in input().split()]

c0 = Counter(v)
if len(c0.values()) == 1:
    ans = n // 2
else:
    c1 = Counter(v[::2])
    c2 = Counter(v[1::2])

    x1 = sorted(c1.items(), reverse=True, key=itemgetter(1))
    x2 = sorted(c2.items(), reverse=True, key=itemgetter(1))

    ans = n
    if x1[0][0] == x2[0][0]:
        if len(x1) == 1:
            ans -= x2[0][1]
        elif len(x2) == 1:
            ans -= x1[0][1]
        else:
            if x1[0][1] + x2[1][1] < x2[0][1] + x1[1][1]:
                ans -= x2[0][1]
                ans -= x1[1][1]
            else:
                ans -= x1[0][1]
                ans -= x2[1][1]
    else:
        ans -= x1[0][1]
        ans -= x2[0][1]
print(ans)


Measured memory_bytes: 29532
n=int(input())
upper=list(map(int,input().split()))
downer=list(map(int,input().split()))
ans=0
if len(upper)+len(downer)==2:
    print(upper[0]+downer[0])
else:    
    for i in range(n):
        tem=sum(upper[:i+1])+sum(downer[i:])
        ans=max(ans,tem)
    print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<queue>
#include<cmath>
#include<set>
#include<deque>
using namespace std;
typedef long long ll;

typedef pair<int, int> pii;

const ll MOD_CONST = 1000000007;


const int INF = 1000000000;
const ll BIG_NUM = 1000000000000000000;


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

	ll ans = 0;
	for (int i = 1; i < n; i++) {
		ll cnt = ((n - i) * m) % MOD_CONST;
		cnt = (cnt * m) % MOD_CONST;
		ans = (ans + (cnt * i) % MOD_CONST) % MOD_CONST;
	}

	for (int i = 1; i < m; i++) {
		ll cnt = ((m - i) * n) % MOD_CONST;
		cnt = (cnt * n) % MOD_CONST;
		ans = (ans + (cnt * i) % MOD_CONST) % MOD_CONST;
	}

	vector<ll> facto(n * m);
	vector<ll> inv_mod(n * m);
	vector<ll> inv_facto(n * m);

	facto[0] = inv_mod[1] = inv_facto[0] = 1;
	for (int i = 2; i < n * m; i++) {
		inv_mod[i] = (MOD_CONST - (inv_mod[MOD_CONST % i] * (MOD_CONST / i)) % MOD_CONST) % MOD_CONST;
	}


	for (int i = 1; i < n * m; i++) {
		facto[i] = (i * facto[i - 1]) % MOD_CONST;
		inv_facto[i] = (inv_mod[i] * inv_facto[i - 1]) % MOD_CONST;
	}

	ans = (ans * facto[n * m - 2]) % MOD_CONST;
	ans = (ans * inv_facto[k - 2]) % MOD_CONST;
	ans = (ans * inv_facto[n * m - k]) % MOD_CONST;
	cout << ans << endl;
}




Measured memory_bytes: 4992
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int count = 0;

    for (int i = 0;; i++) {
      if (n < 3) break;
      n -= 3;
      count++;
    }
    System.out.println(count);
  }

}


Measured memory_bytes: 21844
import sys
import math
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
f=int(input())
num=[a,b,c,d]
s1=max(a,b,c,d)
s2=sorted(num)[-2]
s3=sorted(num)[-3]
i1=max(e,f)
s_sum=s1+s2+s3
total_max=s_sum+i1
print(total_max)


Measured memory_bytes: 5660
(n,m),*t=[map(int,t.split())for t in open(0)]
*e,=eval('[],'*-~n)
for a,b in t:e[a]+=b,;e[b]+=a,
q=[1]
d=[0]*-~n
for v in q:
 for w in e[v]:
  if d[w]<1:d[w]=v;q+=w,
print('Yes',*d[2:])

Measured memory_bytes: 247060
#include <iostream>
#include <algorithm>
using namespace std;
int m[200];
int main(void) {
	int n;
	cin >> n;
	n *= 2;
	for (int i = 0; i < n; ++i) {
		cin >> m[i];
	}
	sort(m, m + n);
	int sum = 0;
	for (int i = n-2; i >=0; i-=2) {
		sum += m[i];
	}
	cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5+100;
int n,f;
int main(){
    scanf("%d",&n);
    while(n){
        if(n%10==7) f=1;
        n/=10;
    }
    if(f) printf("Yes\n");
    else printf("No\n");
}

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


int main(){
  int sum,i,j,kari;
  string data;
  while(getline(cin, data)) {
    data = data.insert(data.length(), "KKKKKK");
    sum = j = 0;
    
    for(j = 0; j < data.length(); j++) {
      if(data[j] == 'M'){
	sum += 1000;
      }else if(data[j] == 'D'){
	if(data[j + 1] == 'M'){
	  sum += 900;
	    j++;
	}else{
	  sum += 500;
	}
      }else if(data[j] == 'C'){
	if(data[j + 1] == 'D' || data[j + 1] == 'M'){
	  if(data[j + 1] == 'D'){
	    sum += 400;
	    j++;
	  }else{
	    sum += 900;
	    j++;
	  }
	}else{
	  sum += 100;
	}
      }else if(data[j] == 'L'){
	sum += 50;
      }else if(data[j] == 'X'){
	if(data[j+1] == 'L' || data[j+1] == 'C'){
	  if(data[j+1] == 'L'){
	    sum += 40;
	    j++;
	  }else{
	    sum += 90;
	    j++;
	  }
	}else{
	  sum += 10;
	}
      }else if(data[j] == 'V'){
	sum += 5;
      }else if(data[j] == 'I'){
	if(data[j + 1] == 'V' || data[j + 1] == 'X'){
	  if(data[j + 1] == 'V'){
	    sum += 4;
	    j++;
	  }else{
	    sum += 9;
	    j++;
	  }
	}
	else{
	  sum += 1;
	}
      }
    }
    
    cout << sum << endl;
  }
  
  return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<queue>
#include<cstdio>
#include<cstring>
using namespace std;

#define REP(i,x,n) for(int i = x ; i < (int)(n) ; i++)
#define rep(i,n)  REP(i,0,n)
static const int INF = (1 << 29);

int n,m,c,s,g;
int p[55],q[55],r[55];
int tmpCost[20010][21],cost[101][101];
int dist[101][101][21];

int solve(){
   //wf
   for(int C = 1 ; C <= c ; C++){
      for(int k = 1 ; k <= n ; k++){
	 for(int i = 1 ; i <= n ; i++){
            for(int j = 1 ; j <= n ; j++){
	       dist[i][j][C] = min(dist[i][j][C], dist[i][k][C]+dist[k][j][C]);
            }
         }
      }
   }
	 
   rep(i,101)rep(j,101)cost[i][j] = (i==j) ? 0 : INF;
   
   for(int C = 1 ; C <= c ; C++){
      for(int i = 1 ; i <= n ; i++){
         for(int j = 1 ; j <= n ; j++){
	    if(dist[i][j][C]==INF)continue;
	    cost[i][j] = min(cost[i][j], tmpCost[dist[i][j][C]][C]);
         }
      }
   }
	 
   //wf
   for(int k = 1 ; k <= n ; k++){
      for(int i = 1 ; i <= n ; i++){ 
         for(int j = 1 ; j <= n ; j++){
	    cost[i][j] = min(cost[i][j], cost[i][k]+cost[k][j]);
         }
      }
   }
	 
   return (cost[s][g]==INF) ? -1 : cost[s][g];
}

void input(){
   memset(tmpCost,0,sizeof(tmpCost));
   rep(i,101)rep(j,101)rep(k,21)dist[i][j][k] = (i==j) ? 0 : INF;
	 
   for(int i = 0 ; i < m ; i++){
      int x,y,d,cc;
      scanf("%d%d%d%d",&x,&y,&d,&cc);
      dist[x][y][cc] = dist[y][x][cc] = min(d, dist[x][y][cc]);
   }
   
   for(int C = 1 ; C <= c ; C++)scanf("%d",&p[C]);

   for(int C = 1 ; C <= c ; C++){
      for(int i = 0 ; i < p[C] - 1 ; i++)scanf("%d",&q[i]);
      
      for(int i = 0 ; i < p[C] ; i++)scanf("%d",&r[i]);
      
      int T = 0;
      for(int i = 1 ; i <= 20000 ; i++){
	 if(T+1!=p[C] && i > q[T])T++;
	 tmpCost[i][C] = tmpCost[i-1][C] + r[T];
      }
   }
}

int main(){ 
   while(cin >> n >> m >> c >> s >> g){
      if((n|m|c|s|g)==0)break;
      input();
      cout << solve()<< endl;
   }
   return 0;
}

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

namespace ConsoleApp1
{
	class Program
	{
		static void Main(string[] args)
		{
			var textInput = Console.ReadLine();

			var inputs = textInput.Split(' ').Select(t => int.Parse(t)).ToArray();

			var count = inputs[1] - inputs[0]; // 東側の塔は count 本目

			var height = Enumerable.Range(1, count).Sum(); // 東側の塔の高さ

			Console.WriteLine(height - inputs[1]);
		}
	}
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vii = vector<vi>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const int INF = 2e9;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
struct UnionFind{
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
    UnionFind(int N) : par(N)
    { //最初は全てが根であるとして初期化
        for (int i = 0; i < N; i++)
            par[i] = i;
    }
    int root(int x)
    { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x)
            return x;
        return par[x] = root(par[x]);
    }
    void unite(int x, int y)
    {                     // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry)
            return;   //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }
    bool same(int x, int y)
    { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(){
  ll n, m;
  cin >> n >> m;
  ll ans = 0;
  vi a(m);
  vi b(m);
  rep(i, m){
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
  }
  rep(i,m){
    UnionFind tree(n);//初期化
    bool z = false;
    rep(j, m){
      if (j == i){//i番目の橋をつなげない
        continue;
      }
      tree.unite(a[j],b[j]);
    }
    rep(j, n - 1){
      if (!tree.same(0,j+1)){//一つでも根が違う橋があればans++
        z = true;
      }
    }
    if(z){
      ans++;
    }
  }
  print(ans);
}


Measured memory_bytes: 256
#include<stdio.h>
   int l[200],d[200];
   int n,x;
   int main()
   {
   while(scanf("%d%d",&n,&x)!=EOF)
	  {
	  for(int i=1;i<=n;i++)
		 {
		 scanf("%d",&l[i]);
         }
	  d[1]=0;
	  for(int i=2;i<=n+1;i++)
		 {
		 d[i]=d[i-1]+l[i-1];
         }
      int t=0;
	  for(int i=1;i<=n+1;i++)
		 {
		 if(d[i]<=x)
		 t++;
		 }
	  printf("%d\n",t);
      }
   return 0;
   }

Measured memory_bytes: 128
# coding:utf-8

import sys
import math
import time
import numpy as np
import collections
from collections import deque
import queue
import copy

# 最大公約数
def gcd(m,n):
  x = max(m,n)
  y = min(m,n)
  if x%y == 0:
    return y
  else:
    while x%y != 0:
      z = x%y
      x = y
      y = z
    else:
      return z

# 幅優先探索(BFS)でスタート座標(x, y)からの最大距離返す
def bfs(SS, x, y, H, W):#入力(座標系(迷路), x, y, xの端, yの端)
  x_next = [0, 0, -1, 1]
  y_next = [1, -1, 0, 0]
  tempx = x
  tempy = y
  mlength = 0
  q = deque()
  xytuple = (x, y, 0)
  q.append(xytuple)


  while q:
    xytuple = q.popleft()
    SS[xytuple[0]][xytuple[1]] = "x" #探索した場所は探索できないようにする
    for i in range(4): #このforで上下左右を調べてる
      tempx = xytuple[0] + x_next[i]
      tempy = xytuple[1] + y_next[i]
      #print(tempx, tempy, xytuple[2])
      #print(S)
      if(0 <= tempx and tempx < H and 0 <= tempy and tempy < W and SS[tempx][tempy] == "."):
        temptuple = (tempx, tempy, xytuple[2]+1)
        SS[temptuple[0]][temptuple[1]] = "x" #探索した場所は探索できないようにする
        mlength = max(mlength, xytuple[2] +1)
        q.append(temptuple)
      #print(q)
  return mlength

def brick(a,n,m,N):#ABC 148
  #n番目以降にmがあるか調べる
  if not m in a[n:]:
    print(N-(m-1))
  else:
    #b = copy.deepcopy(a)
    brick(a,a[n:].index(m),m+1,N)

#X = str(input()).split()
#a = [int(x) for x in input().split()]

N = int(input())
A = [int(x) for x in input().split()]
ans = "APPROVED"
for i in range(N):
    if(A[i]%2 == 0):
        if(A[i]%3 == 0 or A[i]%5 == 0):
            a = 0
        else:
            ans = "DENIED"


print(ans)


Measured memory_bytes: 12428
A, B, C = map(int, input().split())
count = 0
if A%2 == 1:
    count += 1
if B%2 == 1:
    count += 1
if C%2 == 1:
    count += 1

if count >= 2:
    print ('Hom')
else:
    print ('Tem')


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

int main(){
    long long k;
    cin>>k;
	int i;
    queue<long long> q;
    for(i=1;i<=9;i++)q.push(i);
    while(!q.empty()){
	    long long x=q.front();
	    q.pop();
	    k--;
	    if(k==0){
	    	cout<<x<<endl;
	    	return 0;
		}
	    for(int j=x%10-1;j<=x%10+1;j++){
		    if(j<0||j>9)continue;
		    q.push(x*10+j);
	    }
	}
	return 0;
}


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

#define int long long
typedef pair<int, int> P;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

/*
#define cin ifs
#define cout ofs
ifstream ifs("in.txt");
ofstream ofs("out.txt");
//*/

int A, B, C, X, Y;

signed main() {
    cin >> A >> B >> C >> X >> Y;
    int ans = LLONG_MAX;
    for (int i = 0; i <= X; i++) {
        int cur = A * i;
        int ab = (X - i) * 2;
        cur += ab * C;
        int needb = max(0LL, Y - (X - i));
        cur += min(needb * B, needb * 2 * C);
        ans = min(cur, ans);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int house[5][4][11];
int n;
int b, f, r, v;
int main(){
    cin >> n;
    for(int i = 1; i <= n; ++i){
        cin >> b >> f >> r >> v;
        house[b][f][r] += v;
    }
    for(int i = 1; i <= 4; ++i){
        for(int j = 1; j <= 3; ++j){
            for(int k = 1; k <= 10; ++k){
                cout << " " << house[i][j][k];
            }
            cout << endl;
        }
        if(i != 4){
            for(int l = 1; l <= 20; ++l){
                cout << '#';
            }
            cout << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3088
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

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

  auto friends = vector<unordered_map<ll, bool>>{};
  auto blocks = vector<unordered_map<ll, bool>>{};
  friends.resize(n + 1, unordered_map<ll, bool>());
  blocks.resize(n + 1, unordered_map<ll, bool>());

  // 入力を受け取る
  ll first, second;
  for (auto i = 0; i < m; i++)
  {
    cin >> first >> second;
    friends[first][second] = true;
    friends[second][first] = true;
  }

  for (auto i = 0; i < k; i++)
  {
    cin >> first >> second;
    blocks[first][second] = false;
    blocks[second][first] = false;
  }

  auto visited = vector<bool>();
  visited.resize(n + 1, false);
  auto ans = vector<ll>();
  ans.resize(n + 1, 0);

  auto graph_index = vector<int>();
  graph_index.resize(n + 1, 0);

  auto current_graph = 0;
  auto graphs = vector<set<ll>>{};

  for (auto i = 1; i <= n; i++)
  {
    // 訪問済み
    if (visited[i])
    {
      continue;
    }

    current_graph++;

    auto q = queue<ll>{};   // 未訪問のnodes
    auto graph = set<ll>{}; // 現在のgraphのなかのnode全体

    q.push(i);
    graph.insert(i);
    visited[i] = true;
    graph_index[i] = current_graph;

    while (!q.empty())
    {
      auto cur = q.front();
      q.pop();

      graph_index[cur] = current_graph;

      for (auto &o : friends[cur])
      {
        if (visited[o.first])
        {
          continue;
        }

        graph.insert(o.first);
        visited[o.first] = true;
        q.push(o.first);
      }
    }

    // ここまででgraph sizeはすでにわかっている
    auto nodes_size = graph.size();
    for (auto i : graph)
    {
      ans[i] = nodes_size - 1;
    }
    graphs.push_back(graph);
  }

  for (auto &g : graphs)
  {
    for (auto &node : g)
    {
      for (auto &f : friends[node])
      {
        if (graph_index[node] == graph_index[f.first])
        {
          ans[node]--;
        }
      }

      for (auto &b : blocks[node])
      {
        if (graph_index[node] == graph_index[b.first])
        {
          ans[node]--;
        }
      }
    }
  }

  for (auto i = 1; i <= n; i++)
  {
    cout << ans[i];
    if (i != n)
    {
      cout << " ";
    }
  }

  cout << endl;

  return 0;
}


Measured memory_bytes: 42880
s=gets.chomp
res=s.size+1
s.chars do |c|
    t=s.dup
    n=t.size
    cnt=0
    while t.chars.uniq.size>1
        (0...n-1-cnt).each{|i| t[i]=t[i+1] if t[i+1]==c }
        t[-1]=''
        cnt+=1
    end
    res=cnt if res>cnt
end
puts res


Measured memory_bytes: 1788
#include<iostream>
#include<string>
using namespace std;
int main(){
long n,i,a[7][2]={{1,2},{6,3},{1,6},{4,5},{5,2},{2,1},{6,6}},b;
string s;
while(cin>>s){
if(s=="#")break;
n=s.size();
for(b=i=0;i<n;i++)b=a[b][s[i]-48];
if(b==5)cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}
return 0;
}

Measured memory_bytes: 1180
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define vcout(v) rep(i,v.size()) cout << v[i] << " "; cout << endl
#define mcout(m) rep(j,m.size()){vcout(m[j]);}
const ll MOD = 1e9 + 7;

// a %*% b
vector<vector<ll>> prod(vector<vector<ll>> a, vector<vector<ll>> b){
    assert(a[0].size() == b.size());
    ll n_a = a.size();
    ll n_b = b[0].size();
    ll n_mid = b.size();
    vector<vector<ll>> res(n_a,vector<ll>(n_b));

    rep(i,n_a) rep(j,n_b) rep(k,n_mid){
        (res[i][j] += (a[i][k] * b[k][j]) % MOD) %= MOD;
    }

    return res;
}

// a^k
vector<vector<ll>> f(vector<vector<ll>> a, ll k){
    ll n = a.size();
    vector<vector<ll>> res(n,vector<ll>(n));
    rep(i,n) res[i][i] = 1; // a^0 = I

    while(k > 0){
        if(k & 1){
            res = prod(res,a);
        }
        a = prod(a,a);
        k >>= 1;
    }

    return res;
}

void mainsolve(){

    ll n,k;
    cin >> n >> k;
    vector<vector<ll>> a(n,vector<ll>(n));
    rep(i,n) rep(j,n) cin >> a[i][j];

    vector<vector<ll>> b = f(a,k);

    ll res = 0;
    rep(i,n) rep(j,n) (res += b[i][j]) %= MOD;

    cout << res << endl;
	return;
}

int main(){
	
	//ll TC;cin>>TC;rep(I,TC){cout<<"case:"<<I+1<<"---"<<endl; // comment out!
		mainsolve();
	//} // comment out!
	return 0;
}

Measured memory_bytes: 384
def main():
    global visited, adj, sets
    print = out.append
    ''' Cook your dish here! '''
    q = get_int()
    print(q**2)



''' Coded with love at India by Satyam Kumar '''
import sys, threading
from collections import defaultdict
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
out = []
get_int = lambda: int(input())
get_list = lambda: list(map(int, input().split()))
main()
# [main() for _ in range(int(input()))]
print(*out, sep='\n')

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

vector<vector<Int>> G(200010);

vector<Int> counter(200010,0);
vector<Int> parents(200010);

void seek_par(Int i, Int j = -1) {
    parents[i] = j;
    Int n = G[i].size();
    rep(k,n) {
        if (G[i][k] != j) {
            seek_par(G[i][k], i);
        }
    }
}

void dfs(Int i, Int j = -1) {
    Int c = counter[i];
    Int n = G[i].size();
    rep(k,n) {
        if (G[i][k] != j) {
            counter[G[i][k]] += c;
            dfs(G[i][k], i);
        }
    }
}

int main() {
    Int N, Q;
    cin >> N >> Q;

    rep(i,N-1) {
        Int a, b;
        cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    seek_par(1);

    while(Q-->0) {
        Int p, x;
        cin >> p >> x;
        counter[p] += x;
    }

    dfs(1);

    rep1(i,N) cout << counter[i] << endl;
    
}

Measured memory_bytes: 28928
// Original macro is in https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = || -> String {
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
 
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
 
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
    
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
 
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
 
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [$t:tt]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };
 
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

// for adhoc read (ex. https://atcoder.jp/contests/abc112/tasks/abc112_a)
#[allow(dead_code)]
fn read_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}
fn main() {
    input!{ x: i64 }
    println!("{}", 3*x*x);
}

Measured memory_bytes: 4352
n = int(input())
s = []
ac = 0
wa = 0
tle = 0
re = 0
for i in range(n):
    s.append(input())

for i in range(n):
    if s[i] == "AC":
        ac += 1
    elif s[i] == "WA":
        wa += 1
    elif s[i] == "TLE":
        tle += 1
    else:
        re += 1

print("AC x ", end='')
print(ac)

print("WA x ", end='')
print(wa)

print("TLE x ", end='')
print(tle)

print("RE x ", end='')
print(re)


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

using namespace std;

#ifdef DGC
#include "debug.h"
#else
#define debug(...) 9715
#endif
typedef long long ll;
typedef long double ld;
typedef complex<double> point;
#define F first
#define S second



int main()
{
	#ifdef DGC
		//freopen("a.in", "r", stdin);
		//freopen("b.out", "w", stdout);
	#endif

	ios_base::sync_with_stdio(0), cin.tie(0);

	ll n, d, x;
	cin >> n >> d >> x;
	vector<pair<ll, ll>> a(n);
	for (auto &i : a) cin >> i.F >> i.S;

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

	ll ans = 0;
	vector<ll> c(n+1);
	for (int i = 0; i < n; ++i)
	{
		c[i] += a[i].S;
		c[i+1] -= a[i].S;
	}
	for (int i = 0; i < n; ++i)
	{
		if (i) c[i] += c[i-1];
		if (c[i] > 0)
		{
			ll k = (c[i] + x-1) / x;
			ans += k;
			int p = lower_bound(a.begin(), a.end(), make_pair(a[i].F + 2*d + 1, 0LL)) - a.begin();
			c[i] -= k*x;
			c[p] += k*x;
		}
	}
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define vint vector<int>
#define vdouble vector<double>
#define vstring vector<string>
using namespace std;
#include <functional>

#include<map>
#include<set>
#include<queue>

typedef long long ll;
typedef unsigned long long ull;

const int MAX_N = 100;

int N;

class Edge{
public:
	int from, to, cost;
	Edge(int from = 0, int to = 0, int cost = 0) :
		from(from), to(to), cost(cost){}
	
	bool operator < (const Edge &e) const{
		return cost < e.cost;
	}
	bool operator > (const Edge &e) const{
		return cost > e.cost;
	}

};

class Node{
public:
	vector<Edge> edges;
	int color;
	Node(){
		color = 0;
	}
};

class Graph{
public:
	vector<Node> nodes;
	Graph(int n) {
		rep(i, n) { Node n;  nodes.push_back(n); }
	}
};

int main() {

	cin >> N;
	Graph g(N);

	rep(i, N)
	   rep(j, N){
		int cost; cin >> cost;
		if (cost != -1){
			Edge e(i, j, cost);
			g.nodes[i].edges.push_back(e);
		}
	}

	rep(i, N) { g.nodes[i].color = 0; }

	int i = 0;
	g.nodes[i].color = 1;

	priority_queue<Edge, vector<Edge>, greater<Edge> > pq;
	for (auto e : g.nodes[i].edges){
		pq.push(e);
	}

	int ret = 0;
	while (!pq.empty()){
		Edge e = pq.top(); pq.pop();
		Node *n = &g.nodes[e.to];
		if (n->color != 0){ continue; }
		
		n->color = 1;
		ret += e.cost;

		for (auto e : n->edges){
			pq.push(e);
		}
	}

	cout << ret << endl;
}

Measured memory_bytes: 3208
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <map>
using namespace std;

int main() {
	string S;
	cin >> S; int val = -1; bool OK = true;
	for (int i = 2; i < (int)S.size() - 1; i++) {
		if (S[i] == 'C') val = i;
	}
	if (val == -1) OK = false;
	for (int i = 1; i < S.size(); i++) {
		if (S[i] >= 'A' && S[i] <= 'Z' && val != i) OK = false;
	}
	if (S[0] != 'A') OK = false;
	if (OK == true) cout << "AC" << endl;
	else cout << "WA" << endl;
	return 0;
}

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


/*
#define true 1
#define false 0
typedef int bool;
*/

#define MAX 1000000
int par[MAX];
int rank[MAX];
int n, q;

void init(void){
	int i;
	for(i=0; i<n; i++){
		par[i] = i;
		rank[i] = 0;
	}
}

int root(int x){
	//printf("root:x=%d\n", x);//check
	return par[x] == x ? x : (par[x] = root(par[x]));
}

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

void unite(int x, int y){
	x = root(x);
	y = root(y);
	//printf("root:x=%d, y=%d\n", x, y);//check
	if(x == y) return;
	
	if(rank[x] < rank[y]){
		par[x] = y;
	}else{
		par[y] = x;
		if(rank[x] == rank[y]) rank[x]++;
	}
}

#define UNITE 0
#define SAME  1
void readQuery(void){
	int i;
	for(i=0; i<q; i++){
		int com, x, y;
		scanf("%d%d%d", &com, &x, &y);
		//printf("%d %d %d\n", com, x, y);//check
		if(com == UNITE){
			unite(x, y);
		}else if(com == SAME){
			printf("%c\n", same(x, y) ? '1' : '0');
		}
	}
}


int main(void){
	scanf("%d%d", &n, &q);
	
	init();
	
	readQuery();
	
	return 0;
}


Measured memory_bytes: 1996
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <iomanip>
#include <complex>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
using ll = long long;
constexpr long long INF = 1LL << 62;
constexpr int MOD = 1e9 + 7;

ll dp[101010][15];

ll mod_pow(ll x, ll e) {
    ll y = 1;
    while(e) {
        if(e&1) y = y*x%13;
        x = x*x%13;
        e >>= 1;
    }
    return y;
}

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    string s; cin >> s;
    int n = (int)s.size();
    reverse(s.begin(), s.end());

    dp[0][0] = 1;
    REP(i,n) {
        if(s[i]=='?') {
            for(int d = 0; d <= 9; ++d) {
                ll n = mod_pow(10, i) * d % 13;
                for(int m = 0; m < 13; ++m) {
                    (dp[i+1][(m+n)%13] += dp[i][m]) %= MOD;
                }
            }
        } else {
            ll x = s[i] - '0';
            ll n = mod_pow(10, i) * x % 13;
            for(int m = 0; m < 13; ++m) {
                (dp[i+1][(m+n)%13] += dp[i][m]) %= MOD;
            }
        }
    }
    cout << dp[n][5] << endl;

    return 0;
}

Measured memory_bytes: 12240
#include <stdio.h>

int main(void){

  int N;
  scanf("%d",&N);
  int keta(int a){
    int count=1;
    while(a/10!=0){
      a/=10;
      count++;
    }
    return count;
  }
 
  int k, j, l, count1=0;
  for(j=1;j<N+1;j++){
    if(keta(j)%2==1){
      count1++;
    }
    }

  printf("%d",count1);

       return 0;
}


Measured memory_bytes: 128
n, m = map(int, input().split())
a = list(map(int, input().split()))

s = []
for i in a:
    if i >= (sum(a)/(4*m)):
        s.append(1)
    else:
        s.append(0)

if s.count(1) >= m:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<string>
#include<algorithm>
#include<utility>
#include<math.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, int> P;
const int INF = pow(10, 8);
const ll LINF = ll(1e18);

int main(){
  int n;cin>>n;
  vector<vector<int> > ans(n, vector<int>(n, 0));
  for(int i=0;i<n;i++){
    int u, k;cin>>u>>k;u--;
    while(k--){
      int v;cin>>v;v--;
      ans[u][v]=1;
    }
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(j!=n-1)cout<<ans[i][j]<<" ";
      else cout<<ans[i][j]<<endl;
    }
  }
  return 0;
}



Measured memory_bytes: 3208
input()
A=list(map(int,input().split()))
M=[0,1000]
for i in range(0,len(A)-1):
    if A[i]>A[i+1]:
        M[1]+=A[i]*M[0]
        M[0]=0
    elif A[i]<A[i+1]:
        M[0]+=int(M[1]/A[i])
        M[1]=M[1]%A[i]
M[1]+=A[i+1]*M[0]
M[0]=0
print(M[1])


Measured memory_bytes: 9152
#!/usr/bin/env python3

import sys
input=sys.stdin.readline

mod=10**9+7
s=int(input())
dp=[0]*(s+1)
dp[0]=1
for i in range(3,s+1):
    for j in range(3,s+1):
        if i<j:
            continue
        else:
            dp[i]+=dp[i-j]
            dp[i]%=mod
print(dp[s]%mod)

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

template<class T> inline vector<pair<T,int> > factorize(T n)//NOTES:factorize( 
  {vector<pair<T,int> > R;for (T i=2;n>1;){if (n%i==0){int C=0;for (;n%i==0;C++,n/=i);R.push_back(make_pair(i,C));} 
   i++;if (i>n/i) i=n;}if (n>1) R.push_back(make_pair(n,1));return R;}

template<class T> inline bool isPrimeNumber(T n) 
  {if(n<=1)return false;for (T i=2;i*i<=n;i++) if (n%i==0) return false;return true;}

int main(){
	long long a, b;
	cin>>a>>b;
	vector<pair<long long,int> >  x = factorize(a);
	vector<pair<long long,int> > y = factorize(b);
	x.push_back(make_pair(1, 1));
	y.push_back(make_pair(1, 1));
	int res = 0;
	for(int i = 0; i < x.size(); ++i){
		for(int j = 0; j < y.size(); ++j){
			if(x[i].first == y[j].first){
				res++;
				break;
			}
		}
	}
	cout<<res<<endl;	
	return 0;
}


Measured memory_bytes: 256