akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
const long long mod=1000000000+7;
const long long INF=-mod;

//マクロ
//型エイリアス
using ll = long long;
using P=pair<long long,long long>;
using vl=vector<long long>;
//ショートカット
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,k,n) for(int i=k;i<n;i++) //半開区間
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
//入力
#define vin(v,N) for(long long i=0;i<N;i++) cin>>v.at(i)
#define lin(n) long long n;cin>>n
#define vlin(v,N) vector<long long>v(N);for(long long i=0;i<N;i++)cin>>v.at(i)

#define max(a,b) max((ll)a,(ll)b)
#define min(a,b) min((ll)a,(ll)b)

//関数
//最大公約数
long long gcd(long long m, long long n){
  long long a=max(m,n);
  long long b=min(m,n);
  long long r=a%b;
  while(r!=0){
    a=b; b=r; r=a%b;
  }
  return b;
}
// 最小公倍数
long long lcd(long long m, long long n){
  return m*n/gcd(m,n);
}
//xのn乗
long long power(long long x, long long N){
  long long ret=1;
  for(long long i=0;i<N;i++)   
    ret*=x;
  return ret;
}
//繰り返し二乗法
long long repeat_squaring(long long x, long long n){
  if(n==0) return 1;
  else if(n%2==0){
    long long t=repeat_squaring(x,n/2);
    return t*t%mod;
  }
  else
    return x*repeat_squaring(x,n-1);
}
//nCr
long long Comb (long long n, long long r);
//nCr (mod)
long long modC(long long n, long long r) {
    vector<long long> f(n+1),inv(n+1),invf(n+1);
    f[0]=f[1]=1;
    invf[0]=invf[1]=1;
    inv[1]=1;
    for (long long i=2;i<n+1;i++) {
        f[i]=(i*f[i-1])%mod;
        inv[i]=mod-((mod/i)*inv[mod%i])%mod;
        invf[i]=(inv[i]*invf[i-1])%mod;
    }
    long long cmb=f[n]*(invf[r]*invf[n-r]%mod)%mod;
    if (n>=r) return cmb;
    else return 0;
}
//素因数分解(mapで返す)
map<long long,long long> factor(long long p){
  ll p1=p;
  map<long long,long long>ret;
  for(long long i=2;i*i<=p1;i++){
     while(p%i==0){
      ret[i]++;
      p/=i;
    }
  }
  if(p!=1)
  ret[p]++;
  return ret;
}
//素数判定
bool is_prime(long long N){
  for(long long i=2;i*i<=N;i++){
    if(N%i==0)
      return false;
  }
  return true;
}
//最大値更新
void chmax(long long &a,long long b){
  a=max(a,b);
}
//最小値更新
void chmin(long long &a,long long b){
  a=min(a,b);
}

ll f(ll n){
  if(n%2==1){
    if(n%4==1){
      return (n ^ (n-1));
    }
    else{
      return ( ( 1 ^ n ) ^ (n-1) );
    }
  }
  else{
    if(n%4==2)
      return (1 ^ n);
    else
      return n;
    
  }
}

//メイン関数
int main(){
  //doubleの桁数
  cout<<fixed<<setprecision(10);
  
  lin(a);lin(b);
  
  if(a==0)
    cout<<f(b);
  else
    cout<<(f(b) ^ f(a-1));
}

Measured memory_bytes: 384
x, y = list(map(int, input().split()))

def group(x):
    if x in [1,3,5,7,8,10,12]:
        return 1
    if x in [4,6,9,11]:
        return 2
    return 3

if group(x) == group(y):
    print('Yes')
else:
    print("No")


Measured memory_bytes: 38384
#include<bits/stdc++.h>
#define dalao main
#define ll long long
#define debug(x) {cerr<<#x<<" = "<<(x)<<endl;}
using namespace std;
int m,n,k,black=0,cha;
int s[10][10]={0},blackm[10]={0},blackn[10]={0};
bool used[10][10]={0};
bool valid(int x,int y,int cc)
{
    //debug(x)debug(y)
    for(int i=0;i<=m-1;i++)
    {
        if((1<<i) & x)//选中第i行
            for(int l=1;l<=n;l++)
            {
                if(s[i+1][l]==1 && !used[i+1][l])
                {
                    used[i+1][l]=true;
                    cc--;
                }
            }
    }
    for(int i=0;i<=n-1;i++)
    {
        if((1<<i) & y)//选中第i列
            for(int l=1;l<=m;l++)
            {
                //debug(i)
                if(s[l][i+1]==1 && !used[l][i+1])
                {
                    used[l][i+1]=true;
                    cc--;
                }
            }
    }

    //debug(cc)
    if(cc==0)
        return true;
    else
        return false;
}
int dalao()
{
    ios::sync_with_stdio(false);
    cin>>m>>n>>k;
    for(int i=1;i<=m;i++)
    {
        string ss;
        cin>>ss;//日你妈的，又是getchar毁我前程
        for(int j=1;j<=n;j++)
        {
            char c=ss[j-1];
            if(c=='#')
            {
                s[i][j]=1;//1黑0白
                black++;
                blackm[i]++;//第m行的黑色个数
                blackn[j]++;//第n列的黑色个数
            }
            else
                s[i][j]=0;
        }
    }

    cha=black-k;//要去掉的黑块个数

    if(cha<0)
    {
        cout<<0;
        return 0;
    }
    ll ans=0;

    for(int i=0;i<=(1<<m)-1;i++)
        for(int j=0;j<=(1<<n)-1;j++)
        {
            memset(used,0,sizeof(used));
            ans+=valid(i,j,cha);
        }

    cout<<ans;
    return 0;
}


Measured memory_bytes: 3652
N, M, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
jdg = False
if max(x) < min(y):
    if min(y)>X and max(x)<Y:jdg=True

print('No War' if jdg else 'War')

Measured memory_bytes: 3060
import operator
for e in iter(input,'0'):
    target = [[*map(int,input().split())]for _ in[0]*int(e)]
    bx, by = target[0]
    target = {(x - bx, y - by) for x, y in target}
    max_tx = max(map(operator.itemgetter(0), target))
    b = {tuple(map(int,input().split()))for _ in[0]*int(input())}
    max_sx = max(map(operator.itemgetter(0), b))
    lim_x = max_sx - max_tx
    for x,y in b:
        if x > lim_x:continue
        for u,v in target:
            if (x + u, y + v) not in b:break
        else:
            print(x - bx, y - by)
            break


Measured memory_bytes: 6096
#include<iostream>
#include <algorithm>
using namespace std;
int main(){
  int N, K, sum;
  int a[60];
  
  cin >> N >> K;
  for(int i=0;i<N;++i) cin >> a[i];
  
  sort(a, a+N, greater<int>());
  for(int j=0;j<K;++j) sum+=a[j];
  
  cout << sum;
}


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

int lcs(char *A, char *B){
    int m, n, i, j, max = 0;
    int C[1001][1001];
    char X[1001], Y[1001];

    m = strlen(A);
    n = strlen(B);
    
    X[0] = ' ';
    Y[0] = ' ';
    for(i = 0; i < m; i++) X[i+1] = A[i];
    for(i = 0; i < n; i++) Y[i+1] = B[i];

    for(i = 0; i <= m; i++) C[i][0] = 0;
    for(i = 1; i <= n; i++) C[0][i] = 0;

    for(i = 1; i <= m; i++){
        for(j = 1; j <= n; j++){
            if(X[i] == Y[j]){
                C[i][j] = C[i-1][j-1] + 1;
            }
            else if(C[i-1][j] >= C[i][j-1]){
                C[i][j] = C[i-1][j];
            }
            else {
                C[i][j] = C[i][j-1];
            }
            if(max <= C[i][j]){
                max = C[i][j];
            }
        }
    }

    return max;
}

int main(){
    char A[1001], B[1001];
    int i, nm;

    scanf("%d", &nm);

    for(i = 0; i < nm; i++){
        scanf("%s", A);
        scanf("%s", B);
        printf("%d\n", lcs(A, B));
    }
    
    return 0;
}


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

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

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int A[200010];
int L[200010];
int R[200010];

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

	int A, B;
	cin >> A >> B;

	cout << A * B - A - B + 1 << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream> 
#include<vector>
#include<algorithm>
#include<map>
#include<string>
#include<iomanip>
#include<set>
#include<queue>
#include<deque>
#include<sstream>
#include<cmath>
#include<bitset>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define req(i,n) for(int i = 1;i <=  n; i++)
#define rrep(i,n) for(int i = n-1;i >= 0;i--)
#define ALL(obj) begin(obj), end(obj)
#define RALL(a) rbegin(a),rend(a)
typedef long long int ll;
typedef long double ld;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
const int inf = 1<<31-1;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int main(void) {
    int n, sum = 0; cin >> n; n--;
    for (int i = 1; i <= n; i++) {
        sum += n / i;
    }cout << sum << endl;
}

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

int main(){

    int N,ans=0,now=0; cin >> N;
    int data[N];
    for(int i=0;i<N;i++) cin >> data[i];
    now = data[0];
    
    for(int i=1;i<N;i++){
        if(data[i] == now){ ans++; i++; }
        now = data[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 3640
import math

list_a = input().split()
moji_a = list_a[0]+list_a[1]
#print(moji_a)
moji_i =int(moji_a)

moji_i2=math.sqrt(moji_i)
#print(str(moji_i2))

if moji_i2.is_integer():print("Yes")
else:print("No")


Measured memory_bytes: 2940
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use std::process::exit;
use std::cmp::*;
use itertools::Itertools;
use num::*;
use num::integer::Roots;

fn main() {
    input! {
    a:String,
    b:String,
    }
    let mut a=a.chars().collect_vec();
    a.sort();
    let mut b=b.chars().collect_vec();
    b.sort();
    b.reverse();
    for i in 0..min(a.len(),b.len()) {
        if a[i]>b[i] {println!("No");exit(0)}
        else if a[i]<b[i] {println!("Yes");exit(0)}
    }
    println!("{}",if a.len()>=b.len(){"No"}else{"Yes"});
}

Measured memory_bytes: 2120
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<int,int>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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; }
ll dp[3][100005];
int main(){
   int n;
   cin>>n;
   V<ll> a(n),b(n),c(n);
   for(int i=0;i<n;i++)cin>>a[i]>>b[i]>>c[i];
   for(int i=0;i<n;i++){
       dp[0][i+1]=max(dp[1][i]+a[i],dp[2][i]+a[i]);
       dp[1][i+1]=max(dp[0][i]+b[i],dp[2][i]+b[i]);
       dp[2][i+1]=max(dp[0][i]+c[i],dp[1][i]+c[i]);
   }
   ll ans=0;
   for(int i=0;i<3;i++)chmax(ans,dp[i][n]);
   cout<<ans<<endl;
}

Measured memory_bytes: 4992
#include<stdio.h>

int main()
{
    int N,M,i,X,A,a=0,b=0;
    int kocka[105];
    scanf("%d", &N);
    scanf("%d", &M);
    scanf("%d", &X);
    for(i=0;i<=N;i++)
    {
        kocka[i]=0;
    }
    for(i=1;i<=M;i++)
    {
        scanf("%d", &A);
        kocka[A]=1;
    }
    for(i=X;i>=0;i--)
    {
        if(kocka[i]!=0)
            a++;
    }
    for(i=X;i<=N;i++)
    {
        if(kocka[i]!=0)
            b++;
    }
    if(a>b)
        printf("%d", b);
    else
        printf("%d", a);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	string s;
	deque<char>d;
	cin>>s;
	for(ll i=0;i<s.size();i++){
		d.push_back(s[i]);
	}
	bool ch1=true;
	ll n;
	cin>>n;
	for(ll i=0;i<n;i++){
		ll now;
		cin>>now;
		if(now==1){
			ch1=abs(ch1-1);
		}
		else{
			ll nex;
			cin>>nex;
			if(nex==2){
				nex=0;
			}
			char t;
				cin>>t;
			if(nex==ch1){
				d.push_front(t);
			}
			else{
				d.push_back(t);
			}
		}
	}
	if(ch1){
	for(auto itr=d.begin();itr!=d.end();itr++){
		cout << *itr;
	}
	}
	else{
		vector<char>t;
	for(auto itr=d.begin();itr!=d.end();itr++){
		
		t.push_back(*itr);
	}
	reverse(t.begin(),t.end());
	for(ll i=0;i<t.size();i++){
		cout << t[i];
	}
	}
	cout <<endl;
	return 0;
}

Measured memory_bytes: 1284
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MAX 200200
#define MOD 1000000007
#define inv2 500000004
inline int read(){int x=0;bool t=false;char ch=getchar();while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();if(ch=='-')t=true,ch=getchar();while(ch<='9'&&ch>='0')x=x*10+ch-48,ch=getchar();return t?-x:x;}
int fpow(int a,int b){int s=1;while(b){if(b&1)s=1ll*s*a%MOD;a=1ll*a*a%MOD;b>>=1;}return s;}
int n,a[MAX],tot,ans;int cnt[MAX];int c1[MAX],c2[MAX];
int lb(int x){return x&(-x);}
void add(int x,int w){while(x<=n)c1[x]=(c1[x]+w)%MOD,++c2[x],x+=lb(x);}
int getsum1(int x){int ret=0;while(x)ret=(ret+c1[x])%MOD,x-=lb(x);return ret;}
int getsum2(int x){int ret=0;while(x)ret+=c2[x],x-=lb(x);return ret;}
int D[MAX],invD[MAX],zero[MAX],S[MAX];
int main(){
    n=read();tot=1;for(int i=1;i<=n;++i)++cnt[a[i]=read()];for(int i=n-1;i;--i)cnt[i]+=cnt[i+1];for(int i=1;i<=n;++i)tot=1ll*tot*(cnt[i]-=(n-i))%MOD;
    if(!tot){puts("0");return 0;}
    S[0]=D[0]=1;
    for(int i=1;i<=n;++i){
        int x=1ll*(cnt[i]-1)*fpow(cnt[i],MOD-2)%MOD;
        if(!x)S[zero[i]=zero[i-1]+1]=i,D[i]=D[i-1];else zero[i]=zero[i-1],D[i]=1ll*D[i-1]*x%MOD;
        invD[i]=fpow(D[i],MOD-2);
    }
    for(int i=1;i<=n;++i){ans=(ans+1ll*(getsum1(a[i])-getsum1(S[zero[a[i]]]-1)+MOD)*D[a[i]]%MOD*tot%MOD*inv2%MOD)%MOD;add(a[i],invD[a[i]]);}
    for(int i=1;i<=n;++i)c1[i]=c2[i]=0;
    for(int i=n;i;--i){
        ans-=1ll*(getsum1(a[i]-1)-getsum1(S[zero[a[i]]]-1)+MOD)*D[a[i]]%MOD*tot%MOD*inv2%MOD;ans=(ans+1ll*getsum2(a[i]-1)*tot)%MOD;ans=(ans+MOD)%MOD;
        add(a[i],invD[a[i]]);
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 6528
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		long number = scanner.nextLong();
		String result = new String();
		
		while(number > 0) {
			int nums = (int) ('a' + (number - 1) % 26);
			char temporal = (char) nums;
			result = temporal + result;
			number = number / 26;
			if(temporal == 'z')
				number--;
		}
		System.out.print(result);
	}
}


Measured memory_bytes: 27024
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

typedef long long ll;

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

  int n, m;
  cin >> n >> m;
  ll x[n], y[n], z[n];
  for(int i = 0; i < n; i++){
    cin >> x[i] >> y[i] >> z[i];
  }

  int dx[2] = {-1, 1};
  int dy[2] = {-1, 1};
  int dz[2] = {-1, 1};
  ll ans = 0;
  for(int i = 0; i < 2; i++){
    for(int j = 0; j < 2; j++){
      for(int k = 0; k < 2; k++){
        ll a[n];
        for(int l = 0; l < n; l++){
          a[l] = dx[i] * x[l] + dy[j] * y[l] + dz[k] * z[l];
        }
        sort(a, a + n);
        ll sum = 0;
        for(int l = n - 1; l >= n - m; l--){
          sum += a[l];
        }
        ans = max(ans, sum);
      }
    }
  }

  cout << ans << endl;

  return 0;
}


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

// for loop
#define rep(i,a,n) for(int i=(a);i<(n);++i)
#define repe(i,a,n) for(int i=(a);i<=(n);++i)
#define rrep(i,n,a) for(int i=(n);n>(a);--i)
#define rrepe(i,n,a) for(int i=(n);n>=(a);--i)

// abbreviati
#define PB(v) push_back(v)
#define MP make_pair
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define ENDL << "\n"

using ll = long long;
using P = pair<int,int>;
using itn = int;

// constant
const int INF = 1<<30;
const ll INFLL = 1LL << 60;
const ll MOD = 1000000007;
const long double PI =(acos(-1));

/***Snippet***************************************************
ifelse, isprime, torad, todeg, lcm, bfs,chmin,chmax
**************************************************************/

// adjacency list
vector<int> to[100005];

// Graph
using Graph = vector<vector<int>>;

// Grid
int H,W;
vector<vector<int>> field;

// 4方向への移動ベクトル
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};


bool is_ascending(vector<int> &p){
    vector<int> p_a(p.size());
    p_a=p;
    sort(all(p_a));
    if(p_a==p) return 1;
    else return 0;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    itn n;
    cin >> n;
    vector<int> p(n);
    rep(i,0,n) cin >> p[i];

    int cnt=0;
    rep(i,0,n){
        if(p[i]!=i+1) cnt++;
    }

    if(cnt>2) cout << "NO" ENDL;
    else cout << "YES" ENDL;
    
    return 0;
}

Measured memory_bytes: 6008
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
const int MAX = 510000;
const int MOD = 998244353;


     signed main(){
         cout << std::fixed << std::setprecision(15);
  string a,b;
  cin>>a>>b;
  if(a.size()>b.size()){
       cout<<"GREATER"<<endl;
       return 0;
  }
  if(a.size()<b.size()){
       cout<<"LESS"<<endl;
       return 0;
  }
  if(a>b){
       cout<<"GREATER"<<endl;
       return 0;
  }
   if(a<b){
       cout<<"LESS"<<endl;
       return 0;
  }
  cout<<"EQUAL"<<endl;

 }

 


 






    





      

        


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <fstream>
#include <vector>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <set>
#include <map>
using namespace std;
typedef long long ll;

// #define DEBUG

const int maxlen = 10;
class Biginteger
{
    Biginteger(string s);
    int sign = 1;
    int a[maxlen + 1] = {};
};

Biginteger::Biginteger(string s)
{
    if (s[0] == '-')
        sign = -1;
}

int main()
{

#ifdef DEBUG
    cout << "DEBUG MODE" << endl;
    ifstream in("input.txt"); //for debug
    cin.rdbuf(in.rdbuf());    //for debug
#endif

    int h, w, x;
    cin >> h >> w;
    int grid[h][w] = {};
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            cin >> grid[i][j];
        }
    }

    int dp_list[h][w] = {};
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            if (i == 0 || j == 0)
            {
                dp_list[i][j] = grid[i][j] ^ 1;
            }
            else
            {
                if (grid[i][j] == 1)
                    dp_list[i][j] = 0;
                else
                    dp_list[i][j] = min({dp_list[i - 1][j - 1], dp_list[i - 1][j], dp_list[i][j - 1]}) + 1;
            }
        }
    }

    int ans = 0;
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            ans = max(ans, dp_list[i][j]);
        }
    }
    cout << ans * ans << endl;
    return 0;
}

// getline(cin,s);
// a = strtok(s, ",");  ","で分解
// for (int i = 0; i < n; i++)


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

const int inf = 1e9;
const ll linf = 1e18;
const ll mod = 1e9 + 7;

int main()
{
    string s;
    cin >> s;
    string ans = (s[0] != s[1] && s[1] != s[2] && s[2] != s[3]) ? "Good" : "Bad";
    cout << ans << endl; 
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define inf 0x3f3f3f3f
#define PII pair<int,int>
#define ls x<<1
#define rs x<<1|1
#define fi first
#define se second
#define pb push_back
#define cwk freopen("D:\\c++\\in.txt","r",stdin),freopen("D:\\c++\\out.txt","w",stdout)
using namespace std;
const int N=1e6+10;
const int mod=1e9+7;
ll sum[N];
void pre() {
	for(int i=1;i<N;i++) {
		sum[i]=sum[i-1]+i;
	}
}
int main()
{
	//cwk;
	pre();
	int n,k;
	cin>>n>>k;
	ll ans=0;
	for(int i=k;i<=n+1;i++) {
		ll l=sum[i-1],r=sum[n]-sum[n-i];
		ans=(ans+r-l+1)%mod;
	}	
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 11444
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i];}cout<<endl;
#define pprint(A,m,n) rep(j,0,m){print(A[j],n);}
const long mod=1e9+7;
const int size=1e5;
const long inf=1e9;
int main(){
	int X,Y;cin>>X>>Y;
	int ans=0;
	if(X<=3) ans+=(4-X)*100000;
	if(Y<=3) ans+=(4-Y)*100000;
	if(X==1&&Y==1) ans+=400000;
	cout<<ans<<endl;
}

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

#define int long long
#define ct(n) cout << n << endl;
#define cts(n) cout << n << " ";
#define cte cout << endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repo(i,o,n) for(int i=o;i<n;i++)
#define repm(i,n) for(int i=n-1;i>=0;i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define vcopy(v1,v2) copy((v1).begin(), (v1).end(), back_inserter((v2)));
#define pb(n) push_back(n);

int n;

main() {
    cin >> n;
    if (n%10 == 9 || n/10 == 9) ct("Yes")
    else ct("No")
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100000

int A[MAX], n;

int partition(int p, int r) {
  int x, i, j, t;
  x = A[r];
  i = p -1;
  for ( j = p; j < r; j++ ){
  if ( A[j] <= x ){
         i++;
   t = A[i]; A[i] = A[j]; A[j] = t;
   }
   }
  t = A[i+1]; A[i+1] =A[r]; A[r] = t;
  return i+1;
  }
  
  int main() {
  int i, q;
  
  scanf("%d", &n);
  for (  i = 0; i < n; i++) scanf("%d", &A[i]);
  
  q = partition(0, n-1);
  
  for ( i = 0; i < n; i++ ) {
    if ( i ) printf(" ");
    if ( i == q ) printf("[");
    printf("%d", A[i]);
    if ( i == q ) printf("]");
  }
  printf("\n");
  
  return 0;
  }    
  



Measured memory_bytes: 2148
import heapq

n, m = map(int, input().split())
A = list(map(int, input().split()))
k = len(A)
for i in range(k):
    A[i] = A[i] * -1

heapq.heapify(A)

for i in range(m):
    maxim = heapq.heappop(A)
    maxim /= 2
    heapq.heappush(A, maxim)

for i in range(k):
    A[i] = int(A[i] * -1)

ans = sum(A)
print(ans)


Measured memory_bytes: 94232
def main():
    N, K = (int(i) for i in input().split())
    H = [int(input()) for i in range(N)]
    H.sort()
    ans = 10**12
    for i in range(N-K+1):
        ans = min(ans, H[i+K-1] - H[i])
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 50656
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
ll mod = 998244353;
int d[101010];
ll gcd(ll a, ll b)
{
	if (a == 0)return b;
	if (b == 0)return a;
	for (;;)
	{
		if (a < b)swap(a, b);
		a %= b;
		if (a == 0)return b;
	}
}
int main()
{
	int num;
	scanf("%d", &num);
	for (int i = 0; i < num; i++)scanf("%d", &d[i]);
	sort(d, d + num);
	ll m = 1;
	for (int i = 0; i < num; i++)m = m*gcd(d[i], i) % mod;
	printf("%lld\n", m);
}

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

main() {
    string S; cin >> S;
    int a=(S[5]-'0')*10+(S[6]-'0');
    if(a>=5) cout << "TBD" << endl;
    else cout << "Heisei" << endl; 

    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Main{
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }



    public static void main(String[] args) {

    FastReader sc = new FastReader();

    int n = sc.nextInt();
    int dp[][] = new int[n][3];
    int cost[][] = new int[n][3];
    for(int i=0; i<n; i++){
        for(int j=0; j<3; j++){
            dp[i][j] = sc.nextInt();
        }
    }
    cost[n-1][0] = dp[n-1][0];
    cost[n-1][1] = dp[n-1][1];
    cost[n-1][2] = dp[n-1][2];
    for(int i= n-2;i>=0; i--){
        cost[i][0] = dp[i][0] + Math.max(cost[i+1][1],cost[i+1][2]);
        cost[i][1] = dp[i][1] + Math.max(cost[i+1][0],cost[i+1][2]);
        cost[i][2] = dp[i][2] + Math.max(cost[i+1][1],cost[i+1][0]);
    }
    System.out.println(Math.max(cost[0][0],Math.max(cost[0][1],cost[0][2])));
    }

}


Measured memory_bytes: 51264
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

int sum(int a, int b)
{
  return a + b;
}
int sub(int a, int b)
{
  return a - b;
}
int mul(int a, int b)
{
  return a * b;
}

int go(int a, int b, int c, int d)
{
  int  (*cal[])(int, int) = {sum, sub, mul};
  char op[] = {'+', '-', '*'};
  REP(i,3) {
    REP(j,3) {
      REP(k,3) {
        if (cal[k](cal[j](cal[i](a,b), c), d) == 10) {     // (((a . b) . c) . d)
          printf("(((%d %c %d) %c %d) %c %d)\n", a,op[i],b,op[j],c,op[k],d);
          return 1;
        } else if (cal[j](cal[i](a,b), cal[k](c,d)) == 10) {            // ((a . b) . (c . d))
          printf("((%d %c %d) %c (%d %c %d))\n", a,op[i],b,op[j],c,op[k],d);
          return 1;
        } else if (cal[k](cal[i](a,cal[j](b, c)), d) == 10) {
          printf("((%d %c (%d %c %d)) %c %d)\n", a,op[i],b,op[j],c,op[k],d);
          return 1;
        } else if (cal[i](a, cal[k](cal[j](b, c), d)) == 10) {
          printf("(%d %c ((%d %c %d) %c %d))\n", a,op[i],b,op[j],c,op[k],d);
          return 1;
        } else if (cal[i](a, cal[j](b, cal[k](c, d))) == 10) {
          printf("(%d %c (%d %c (%d %c %d)))\n", a,op[i],b,op[j],c,op[k],d);
          return 1;
        }
      }
    }
  }
  return 0;
}


int main() {
  int a[4];
  while (cin>>a[0]>>a[1]>>a[2]>>a[3],a[0]+a[1]+a[2]+a[3]) {
    int f = 0;
    sort(a,a+4);
    do {
      if (go(a[0],a[1],a[2],a[3]) == 1) {
        f = 1;
        break;
      }
    } while(next_permutation(a,a+4));
    if (f == 0)
      cout << 0 << endl;
  }
}

Measured memory_bytes: 0
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr=input.trim().split("\n");
while(true){
   var n=arr.shift()-0;
   if(n===0)break;
   var ary=[];
   for(var i=0;i<n;i++)ary.push(arr.shift().split(" ").map(Number));
   ary.sort(function(a,b){
      if(a[2]==b[2] && a[3]==b[3])return a[0]-b[0];
      else if(a[2]==b[2])return a[3]-b[3];
      else return b[2]-a[2];
   });
   var ans=[];
   var U=[];
   for(var i=0;i<=1000;i++)U[i]=0;
   ary.forEach(function(v){
      var len=ans.length;
      var id=v[0];
      var u=v[1];
      if(len<10){
         if(U[u]<3){ans.push(id);U[u]++;}
      }else if(len<20){
         if(U[u]<2){ans.push(id);U[u]++;}
      }else if(len<26){
         if(U[u]==0){ans.push(id);U[u]++;}
      }
   });
   console.log(ans.join("\n"));
}

Measured memory_bytes: 15704
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define all(x) x.begin(), x.end()

int main() {
  ll a, b;
  cin >> a >> b;
  if (a < 2 * b) {
    cout << 0 << endl;
  } else {
    cout << a - 2 * b << endl;
  }
}

Measured memory_bytes: 256
# #!/usr/bin/env python3
# # -*- coding: utf-8 -*-


def main():
    N = int(input())
    SP = []
    for i in range(N):
        S, P = input().split()
        SP.append([i + 1, S, int(P)])

    SP.sort(key=lambda x: (x[1], -x[2]))
    for sp in SP:
        print(sp[0])


if __name__ == "__main__":
    main()


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

int main()
{
	int64_t n;
	cin >> n;
	vector<int64_t> as(n);
	for (auto &&a : as)
	{
		cin >> a;
	}

	bool s = [&] {
		int64_t g = 0;
		for (auto &&a : as)
		{
			g = gcd(g, a);
		}
		return (g == 1);
	}();

	bool p = [&] {
		vector<int64_t> d(1000001, -1);
		for (int64_t i = 2; i <= 1000; i++)
		{
			if (d[i] == -1)
			{
				for (int64_t j = i; j <= 1000000; j += i)
				{
					d[j] = i;
				}
			}
		}
		for (int64_t i = 1000; i <= 1000000; i++)
		{
			if (d[i] == -1)
			{
				d[i] = i;
			}
		}

		vector<set<int64_t>> v(n);
		for (int64_t i = 0; i < n; i++)
		{
			while (as[i] != 1)
			{
				v[i].insert(d[as[i]]);
				as[i] /= d[as[i]];
			}
		}

		set<int64_t> st;
		for (auto &&xs : v)
		{
			for (auto &&x : xs)
			{
				if (st.find(x) != st.end())
				{
					return false;
				}

				st.insert(x);
			}
		}

		return true;
	}();

	if (p)
	{
		cout << "pairwise coprime" << endl;
	}
	else if (s)
	{
		cout << "setwise coprime" << endl;
	}
	else
	{
		cout << "not coprime" << endl;
	}

	return 0;
}

Measured memory_bytes: 301788
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<deque>
#include<bitset>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef pair<ll,ll> P;
template<class T> inline bool chmax(T&a , T b){ if(a<b){ a=b; return true; } else{ return false; } }
template<class T> inline bool chmin(T&a , T b){ if(a>b){ a=b; return true; } else{ return false; } } 

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main(){
    int a,b,h,m;
    cin >> a >> b >> h >> m;
    double jisin = 2.0*acos(-1)*(60.0*h+m)/(60.0*12.0);
    double funsin = 2.0*acos(-1)*m/60.0;
    double theta = fabs(jisin-funsin);
    if(theta>acos(-1)){
        theta = 2*acos(-1) - theta;
    }
    double ans = a*a + b*b -2*a*b*cos(theta);
    ans = sqrt(ans);
    printf("%.9f\n",ans);

}

Measured memory_bytes: 4164
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <random> // random_device rd; mt19937 mt(rd());
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.
// insert #if<tab> by my emacs. #if DEBUG == 1 ... #end

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

int main () {
  string S;
  cin >> S;
  stack<char> X;
  for (auto x : S) {
    if (x == 'B') {
      if (!X.empty()) {
        X.pop();
      }
    } else {
      X.push(x);
    }
  }
  string ans = "";
  while (!X.empty()) {
    string t{X.top()};
    ans += t;
    X.pop();
  }
  reverse(ans.begin(), ans.end());
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long x = sc.nextLong();
        double azuke = 100;
        int year = 0;
        if(x == 100){
            System.out.println(1);
            System.exit(0);
        }
        do{
            azuke = azuke + 0.01*azuke;
            azuke = Math.floor(azuke);
            year = year+1;
        } while(azuke < x);
        System.out.println(year);
    }
}

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

int main() {
  int a;
  int b;
  char c;
  cin >> a;
  cin >> c;
  cin >> b;
  int anser;
  if(c == '+'){
  	anser = a+b;
  }else{
  	anser = a-b;
  }
  cout << anser << endl;
}

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

int main(){
	int n;
	while (cin >> n) {
		int dp[4][51] = {}; //abcd, n
		for (int i = 0; i <= 9; ++i) {
			dp[0][i] = 1;
		}
		for (int i = 1; i < 4; ++i) {
			for (int j = 0; j < 50; ++j) {
				for (int k = 0; k <= 9; ++k) {
					dp[i][j+k] += dp[i-1][j];
				}
			}
		}
		cout << dp[3][n] << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include<iostream>
using namespace std;
long N,P,cnt[10101],T[2<<17],ans,mod,i;
string s;

int main()
{
    cin>>N>>P>>s;
    if(P==2||P==5)
    {
        for(int i =0;i<N;i++)
        {
            if((s[i]-'0')%P==0)
                ans+=i+1;
        }
        cout<<ans<<endl;return 0;
    }
    T[N-1]=1;
    for(int i=N-2;i>=0;i--) T[i]=T[i+1]*10%P;
    cnt[0]=1;
    for(int i=0;i<N;i++)
    {
        mod=(mod+(s[i]-'0')*T[i])%P;
        ans+=cnt[mod]++;
    }
    cout<<ans<<endl;
}








//int main()
//{
//    cin>>N>>P>>s;
//    if(P==2||P==5)
//    {
//        for(i=0; i<N; i++)
//        {
//            if((s[i]-'0')%P==0)
//            {
//                ans+=i+1;
//            }
//        }
//    }
//    else
//    {
//        T[N-1]=1;
//        for(i=N-1; i--;)T[i]=T[i+1]*10%P;
//        cnt[0]=1;
//        for(i=0; i<N; i++)
//        {
//            mod=(mod+(s[i]-'0')*T[i])%P;
//            ans+=cnt[mod]++;
//        }
//    }
//    for(int i=0;i<6;i++)cout<<T[i]<<endl;
//    cout<<ans<<endl;
//}


Measured memory_bytes: 2180
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = 1e9 + 7;
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    sort(all(s));
    if (s[0] == s[1] && s[1] != s[2] && s[2] == s[3]) {
        cout << "Yes" << endl;
    } else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
input=lambda: sys.stdin.readline().rstrip()
n=int(input())
A=sorted([int(i) for i in input().split()])
ma=max(A)
C=[True]*(ma+1)

import collections
AA=collections.Counter(A)

AS=list(set(A))
AS.sort()
for a in AS:
  if AA[a]>1:
    ct=1
  else:
    ct=2
  while a*ct<=ma:
    C[a*ct]=False
    ct+=1
ans=0
for a in AA.keys():
  if C[a]:
    ans+=AA[a]
print(ans)



Measured memory_bytes: 145820
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
char c1[1001],c2[1001];
int main()
{
	scanf("%s\n%s",c1,c2);
	int len=strlen(c1);
	bool f=1;
	for(int i=0;i<len;i++)
		if(c1[i]!=c2[i])
			f=0;
	if(f) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 3656
#include<stdio.h>
int main()
{
int x,ans,i;
  scanf("%d",&x);
for(i=1;i<=31;++i)
{
if(i*i<=x) ans=i*i;
}
  
for(i=1;i<=10;++i)
{
if(i*i*i<=x && ans < i*i*i) ans=i*i*i;
}
  
for(i=1;i<=5;++i)
{
if(i*i*i*i<=x && ans < i*i*i*i) ans=i*i*i*i;
}
  
for(i=1;i<=3;++i)
{
if(i*i*i*i*i<=x && ans < i*i*i*i*i) ans=i*i*i*i*i;
}
  
for(i=1;i<=3;++i)
{
if(i*i*i*i*i*i<=x && ans < i*i*i*i*i*i) ans=i*i*i*i*i*i;
}
  
if(128<=x && ans<128) ans=128;
if(256<=x && ans<256) ans=256;
if(512<=x && ans<512) ans=512;
  printf("%d",ans);
return 0;
}

Measured memory_bytes: 1732
#include <stdio.h>
#include <string.h>

int main(int argc, const char * argv[]) {
    int a,b,q;
    char str[1001];
    char order[1001];
    char p[1001];
    
    int i,j,k;//アクセス変数
    char tmp[1001];
    

    scanf("%s",str);
    scanf("%d",&q);
    
    for(i=0;i<q;i++){
        //初期化
//        order[0]='\n';
//        tmp[0]='\n';
        
        scanf("%s",order);
        scanf("%d %d",&a,&b);
        
        if(strcmp(order,"print")==0){
            for(j=a;j<=b;j++){
                printf("%c",str[j]);
            }
            printf("\n");
            
        }else if(strcmp(order,"reverse")==0){
            for(j=b,k=0;k<=b-a+1;j--,k++){
                tmp[k]=str[j];
            }
            strncpy(&str[a],tmp,b-a+1);
        }else if(strcmp(order,"replace")==0){
            scanf("%s",p);
            strncpy(&str[a],p,b-a+1);
        }
    }
    return 0;
}



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

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

    int N;
    cin >> N;
    vector<string> S(N);
    vector<int> T(N);

    for (int i = 0; i < N; i++)
        cin >> S[i] >> T[i];

    string X;
    cin >> X;
    int index = -1;

    for (int i = 0; i < N; i++)
        if (S[i] == X)
            index = i;

    int sum = 0;

    for (int i = index + 1; i < N; i++)
        sum += T[i];

    cout << sum << '\n';
}


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

int main(void){
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    
    int minus_count = 0;
    ll ans = 0;
    ll min_num = 1e10;
    rep(i, n) {
        if (a[i] < 0) {
            minus_count++;
            ans -= a[i];
            min_num = min(min_num, -a[i]);
        }
        else {
            ans += a[i];
            min_num = min(min_num, a[i]);
        }
    }
    
    if (minus_count % 2 == 1)
        ans -= 2*min_num;
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll n;
  R n;
  pr(180*(n-2));
}

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


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

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> S(H);
  for (int i = 0; i < H; i++) cin >> S[i];
  vector<vector<int>> L(H, vector<int>(W));
  vector<vector<int>> R(H, vector<int>(W));
  vector<vector<int>> U(H, vector<int>(W));
  vector<vector<int>> D(H, vector<int>(W));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (S[i][j] == '.') {
        if (j == 0) L[i][j] = 1;
        else L[i][j] = L[i][j-1] + 1;
      }
      else L[i][j] = 0;
    }
    for (int j = W-1; j >= 0; j--) {
      if (S[i][j] == '.') {
        if (j == W-1) R[i][j] = 1;
        else R[i][j] = R[i][j+1] + 1;
      }
      else R[i][j] = 0;
    } 
  }
  for (int i = 0; i < W; i++) {
    for (int j = 0; j < H; j++) {
      if (S[j][i] == '.') {
        if (j == 0) U[j][i] = 1;
        else U[j][i] = U[j-1][i] + 1;
      }
      else U[j][i] = 0;
    }
    for (int j = H-1; j >= 0; j--) {
      if (S[j][i] == '.') {
        if (j == H-1) D[j][i] = 1;
        else D[j][i] = D[j+1][i] + 1;
      }
      else D[j][i] = 0;
    }
  }

  int res = 1;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      int tmp = L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3;
      if (tmp > res) res = tmp;
    }
  }
  cout << res;
}


Measured memory_bytes: 67200
N = input()
S = set()
last = '.'
for i in xrange(N):
    s = raw_input()
    if s in S:
        print "No"
        exit()
    if last != '.' and s[0] != last:
        print "No"
        exit()
    last = s[-1]
    S.add(s)
print "Yes"


Measured memory_bytes: 2568
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>

using namespace std;


set<pair<int,string> > makeTree(string str){

	set<pair<int,string> > trees; 

	if(str.size()==1&&str[0]>='0'&&str[0]<='9'){
		trees.insert(make_pair((int)(str[0]-'0'),str));
		return trees;
	}
	else{
		for(int i = 0; i < str.size(); i++){
			if(str[i]=='*'||str[i]=='+'||str[i]=='-'){
				string str1 = str.substr(0,i);
				string str2 = str.substr(i+1);
				set<pair<int,string> > spis = makeTree(str1);
				set<pair<int,string> > spis2 = makeTree(str2);
				for(set<pair<int,string> >::iterator it = spis.begin(); it!=spis.end(); it++){
					for(set<pair<int,string> >::iterator iit = spis2.begin(); iit!=spis2.end(); iit++){
						if(str[i]=='*'){
							int ret=it->first*iit->first;
							string rets = '(' + it->second + ") * (" + iit->second + ')';
							trees.insert(make_pair(ret,rets));
						}
						else if(str[i]=='+'){
							int ret=it->first+iit->first;
							string rets = '(' + it->second + ") + (" + iit->second + ')';
							trees.insert(make_pair(ret,rets));
						}
						else if(str[i]=='-'){
							int ret=it->first-iit->first;
							string rets = '(' + it->second + ") - (" + iit->second + ')';
							trees.insert(make_pair(ret,rets));
						}
					}
				}
			}
		}
	}
	return trees;
}

int main(){

	int a,b,c,d;
	char op[3];
	op[0]='+';
	op[1]='-';
	op[2]='*';

	while((cin>>a>>b>>c>>d)&&!(a==0&&b==0&&c==0&&d==0)){
		bool f=false;
		vector<int> v;
		v.push_back(a);
		v.push_back(b);
		v.push_back(c);
		v.push_back(d);
		sort(v.begin(),v.end());
		do{
			for(int i = 0; i < 3; i++){
				for(int j = 0; j < 3; j++){
					for(int k = 0; k < 3; k++){
						string str="";
						str+=(char)(v[0]+'0');
						str+=(char)op[i];
						str+=(char)(v[1]+'0');
						str+=(char)op[j];
						str+=(char)(v[2]+'0');
						str+=(char)op[k];
						str+=(char)(v[3]+'0');
						set<pair<int,string> > spbs = makeTree(str);
						for(set<pair<int,string> >::iterator it = spbs.begin(); spbs.end()!=it; it++){
							if(it->first==10){
								cout<<'(' + it->second + ')'<<endl;
								f=true;
								break;
							}
						}
						if(f)
							break;
					}
					if(f)
						break;
				}
				if(f)
					break;
			}
			if(f)
				break;
		}while(next_permutation(v.begin(),v.end()));
		if(!f)
			cout<<0<<endl;
	}

	return 0;
}

Measured memory_bytes: 940
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int a,b,c;
int ans;
int main()
{
    scanf("%d%d%d",&a,&b,&c);
    ans=b/a;
    ans=min(ans,c);
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
a.sort()
flag = [True] * (a[-1]*3)
for i, num in enumerate(a):
    if a[(i-1)%n]==num or a[(i+1)%n]==num:
        if i-1>=0 or i+1<n:
            flag[num] = False
    for j in range(2, a[-1]//num+2):
        flag[j*num] = False
counter = 0
for i in a:
    if flag[i]:
        counter += 1
print(counter)

Measured memory_bytes: 168852
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde) FUNC(printdu);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ in >> p.first >> p.second; return in; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> as(n); cin >> as;
    int ans = 0;
    for(int i = 0; i < n; i++){
        ans += as[i] - 1;
    }
    cout << ans << '\n';
}


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

int main(void)
{
	int a,b,c,x,y;

	cin >> a >> b >> c >> x >> y;

	vector<int> cost;

	cost.push_back( a * x + b * y);
	
	if (x > y) {
		cost.push_back( a * (x - y) + 2 * c*y);
		cost.push_back( 2 * c*x);
	}
	else {
		cost.push_back( b * (y - x) + 2 * c*x);
		cost.push_back( 2 * c*y);
	}

	sort(cost.begin(), cost.end());
	cout << cost[0] << endl;



	return 0;
}

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

int main() {
  int64_t m,n,x,ans,a;
  cin>>n>>m>>x;
  a=0;
  ans=100000000;
    vector<vector<int64_t>> data(12, vector<int64_t>(13));
  for(int64_t i=0;i<n;i++){
   for(int64_t j=0;j<m+1;j++){
  cin>>data.at(i).at(j);}
  }
  vector<int64_t> vec(13); 
  
// すべての選び方を試して、総和がKになるものがあるかを調べる
  for (int64_t tmp = 0; tmp < (1 << 12); tmp++) {
    
    bitset<12> s(tmp);  // 最大20個なので20ビットのビット列として扱う
 for(int64_t j=0;j<13;j++){vec.at(j)=0;}
    // ビット列の1のビットに対応する整数を選んだとみなして総和を求める
    for (int64_t i = 0; i < n; i++) {
      if (s.test(i)) {
        for(int64_t j=0;j<13;j++){ vec.at(j) += data.at(i).at(j);}
      }
    }
   for(int64_t j=1;j<m+1;j++ ){ if(vec.at(j)<x){a=1;}}
    if(a==0){ans=min(ans,vec.at(0));}
   a=0;
  }
 
  if (ans==100000000) {
    cout <<-1 << endl;
  } else {
    cout << ans << endl;
  }
}


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

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

  vector<string> t(n);
  vector<int> s(n);
  rep(i,n) {
    cin >> t[i] >> s[i];
  }

  for (int i = 1; i < n; i++) {
    s[i] += s[i - 1];
  }

  string x;
  cin >> x;

  int sum = s[n - 1];
  for (int i = 0; i < n; i++) {
    if(t[i] == x) {
      sum = sum - s[i];
      break;
    }
  }

  cout << sum << '\n';

}

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

typedef long long int ll;
#define Nmax 100005
int N;

int col;

typedef struct arete{
	int destination, id;
	arete(){}
	arete(int d, int i){
		this->destination = d;
		this->id = i;
	}
}Arete;

vector<Arete> adj[Nmax];
int val[Nmax];

void dfs(int s, int appelant, int couleur){
	col = max(col, couleur);
	int tmp_couleur = 1;
	for(int i=0;i<(int)adj[s].size();i++){
		arete a = adj[s][i];
		if(a.destination!=appelant){
			if(tmp_couleur == couleur) tmp_couleur++;
			val[a.id] = tmp_couleur;
			dfs(a.destination,s, tmp_couleur);
			tmp_couleur++;
		}
	}
}

int main(){
	cin>>N;
	col = 0;
	for(int i=0;i<N-1;i++){
		int u, v; cin>>u>>v;
		adj[u].push_back(arete(v, i));
		adj[v].push_back(arete(u, i));
	}
	
	dfs(1,-1,-1);
	
	printf("%d\n",col);
	for(int i=0;i<N-1;i++){
		printf("%d\n",val[i]);
	}
}


Measured memory_bytes: 9344