akhauriyash/Code-Regression huggingface dataset:
N=int(input())
ANi=input().split()
AN=list(map(int,ANi))

Whairetsu={}
Xhairetsu={}
Yhairetsu={}


for i in range(len(AN)):
    if AN[i] not in Xhairetsu.keys():
        Xhairetsu[AN[i]]=1
    elif AN[i] in Xhairetsu.keys():
        Xhairetsu[AN[i]]+=1
    
    if AN[i] -1 not in Whairetsu.keys():
        Whairetsu[AN[i]-1]=1
    elif AN[i]-1 in Whairetsu.keys():
        Whairetsu[AN[i]-1]+=1
    
    if AN[i] +1 not in Yhairetsu.keys():
        Yhairetsu[AN[i]+1]=1
    elif AN[i]+1 in Yhairetsu.keys():
        Yhairetsu[AN[i]+1]+=1
    


anshairetsu={}
for i in range(10**5+1):
    if i in Whairetsu.keys():
        if i in anshairetsu.keys():
            anshairetsu[i]+=Whairetsu[i]
        else:
            anshairetsu[i]=Whairetsu[i]
            
    if i in Xhairetsu.keys():
        if i in anshairetsu.keys():
            anshairetsu[i]+=Xhairetsu[i]
        else:
            anshairetsu[i]=Xhairetsu[i]
            
    if i in Yhairetsu.keys():
        if i in anshairetsu.keys():
            anshairetsu[i]+=Yhairetsu[i]
        else:
            anshairetsu[i]=Yhairetsu[i]
print(max(anshairetsu.values()))
        

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

using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;

#define REPS(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (int i = (a); i >= n; --i)
#define DEP(i, n) DEPS(i, n, 0)

#define vint(v, n) vector<int> v(n); REP(i,n) cin >> v[i];
#define vvint(v, w, n) vector<int> v(n); vector<int> w(n); REP(i,n) cin >> v[i] >> w[i];
#define vlint(v, n) vector<ll int> v(n); REP(i,n) cin >> v[i];
#define vdouble(v, n) vector<double> v(n); REP(i,n) cin >> v[i];
#define vvdoube(v, n1, n2) vector<vector<double> > v(n1, vector<double>(n2, 0)); REP(i,n1) REP(j,n1) cin >> v[i][j];
#define string(x) string x; cin >> x;
#define vstring(v, n) vector<string> v(n); REP(i,n){string a; std::cin >> a; v.push_back(a); }

#define all(v) (v).begin(), (v).end()
#define rall(v) (v).begin(), (v).end(), std::greater<int>()
#define len(v) (v).length()
#define FIND(s, n) (s.find(n) != s.end())
#define SORT(a) sort(all(a))

static const string abet("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
static const long long MOD = 1000000007;
static const double PI=3.1415926535897932;
static const int INF = 0x3f3f3f3f;
static const int INFTY = (1 << 29);
static const long long LINFTY = (1LL << 32);

static const int dy4[]={0, 0, 1, -1};
static const int dx4[]={1, -1, 0, 0};
static const int dx8[] = {1, 1, 1, 0, 0, -1, -1, -1};
static const int dy8[] = {-1, 0, 1, -1, 1, -1, 0, 1};


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

  int N, M;
  cin >> N >> M;
  vector<string> A(N);
  vector<string> B(M);
  REP(i, N) cin >> A[i];
  REP(i, M) cin >> B[i];

  int ans = 0;
  REP(j, N) REP(i, A[j].length()-B[0].length()+1){
    if(A[j].substr(i, B[0].length()) == B[0]){
      int k = j;
      int l = 0;
      while(k < N && l < M){
        if(A[k].substr(i, B[l].length()) == B[l]){
          k++; l++;
          ans = 1;
          if(l == M){
            cout << "Yes" << endl;
            return 0;
          }else if(k == N){
            cout << "No" << endl;
            return 0;
          }
        }else{
          ans = 0;
          break;
        }
      }
      }
    }
  if(ans == 1) cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

ll dp[100005][2][110];

int main(void){
    string k;
    int d;
    cin >> k >> d;
    
    int n = k.size();
    dp[0][0][0] = 1;
    
    ll ans = 0,mod = 1e9+7;
    for(int i = 0;i < n;i++){
        int a = (k[i] - '0');
        for(int j = 0;j < d;j++){
            for(int l = 0;l < 10;l++){
                dp[i+1][1][(j+l)%d] += dp[i][1][j];
                dp[i+1][1][(j+l)%d] %= mod;
            }
            
            for(int l = 0;l < a;l++){
                dp[i+1][1][(j+l)%d] += dp[i][0][j];
                dp[i+1][1][(j+l)%d] %= mod;
            }
            
            dp[i+1][0][(j+a)%d] += dp[i][0][j];
            dp[i+1][0][(j+a)%d] %= mod;
            
        }
    }
    
    ans = (dp[n][0][0] + dp[n][1][0] - 1 + mod) % mod;
    cout << ans << endl;
}

Measured memory_bytes: 20796
#include <iostream>
using namespace std ;
int main()
{
	int a=0 , b=0 , c=0 ;
	cin >> a >> b >>c ;
	if (a<b&&b<c)
	{
		cout << "Yes" << endl ;
	}
	else
	{
		cout << "No" << endl ;
	}
	return 0 ;
}



Measured memory_bytes: 3080
#include <bits/stdc++.h>
#define ALL(A) (A).begin(),(A).end()
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)

const ll mod = 1e9+7;
const ll INF = -1*((1LL<<63)+1);
const int inf = -1*((1<<31)+1);

using namespace std;
int cnt[100005];
int data[100005];
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(20);
    int N,M,ans = 0;
    cin >> N >> M;
    map<int,int> mp;
    rep(i,N){
        int a;
        cin >> a;
        mp[a]++;
        cnt[a%M]++;
    }
    for(int i=0;i<=M;i++){
        if(i==0){
            ans += cnt[0]/2;
            cnt[0] = 0;
            continue;
        }
        if(i==M-i){
            ans += cnt[i]/2;
            cnt[i] = 0;
            continue;
        }
        //iについてペアとなるのはM-i;
        int t = min(cnt[i],cnt[M-i]);
        ans += t;
        cnt[i] -= t;
        cnt[M-i] -= t;
        //cout << cnt[i] << " " << cnt[M-i] << endl;
        //この操作によって、とりあえずペアは作り終えた
        //後は残った数同士で同じ値があったらペアを作る
        //cout << "i = " << i << " " << cnt[i] << endl;
    }
    for(auto &x:mp){
        int now = x.first;
        int num = x.second;
        if(cnt[now%M]>=2 && num >=2){
            int t = min(cnt[now%M]/2,num/2);
            ans += t;
            cnt[now%M]-=2*t;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 5376
import static java.lang.Math.*;
import java.util.Scanner;



public class Main {
    public static void main(String[] args)  {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt(), l = 0;
        long a[] = new long[n];
        for(int i = 0; i < n; i++) a[i] = sc.nextInt();
        double lg1 = 0;
        for(int i = 0; i < k; i++) lg1 += log(a[i]);
        for(int i = k; i < n; i++){
            double lg2 = lg1 - log(a[l++]) + log(a[i]);
            if(lg2 > lg1)System.out.println("Yes");
            else System.out.println("No");
            lg2 = lg1;
        }
    }
}


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

long long pow(long long a, long long n) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a;
        a = a * a;
        n >>= 1;
    }
    return res;
}

int main() {
  ll h,n = 1;
  cin >> h;
  int cnt = 1;
  while(true){
    n *= 2;
    if(n > h) break;
    cnt++;
  }
  ll ans = pow(2,cnt)-1;
  cout << ans << endl;
}

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

int N,M;
vector< vector < int > > st;
vector< int > nis;

bool checkbib(int v, int x) {
    if (nis[v] != -1) return nis[v] == x;
    nis[v] = x;
    for (int i : st[v]) if (!checkbib(i, 1-x)) return false;
    return true;
}

int main(void) {
    cin >> N >> M;
    st.assign(N, vector< int > ());
    for (int i=0; i<M; i++) {
        int a,b;
        cin >> a >> b;
        --a; --b;
        st[a].push_back(b);
        st[b].push_back(a);
    }
    nis.assign(N, -1);
    if (checkbib(0, 0)) {
        int A = accumulate(nis.begin(), nis.end(), 0);
        int B = N - A;
        cout << (ll)A * B - M << endl;
    } else cout << (ll)N * (N-1) / 2 - M << endl;
    return 0;
}


Measured memory_bytes: 6400
a = int(raw_input())
b = int(raw_input())
c = int(raw_input())
x = int(raw_input())

def dfs(x, i, m, v):
  	if x < 0: return 0
  	if x == 0 or i == 3: 
  		return 1 if x == 0 else 0   	
  	r = 0
  	for k in range(0, m[i] + 1): r += dfs(x - k * v[i], i + 1, m, v)
  	return r
m,v = {0:a,1:b,2:c}, {0:500,1:100,2:50}
print dfs(x,0,m,v)


Measured memory_bytes: 90820
#include <bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp> 
using namespace std;
using namespace __gnu_pbds;
// Policy based data structure 
typedef tree<int, null_type, 
			less_equal<int>, rb_tree_tag, 
			tree_order_statistics_node_update> 
	indexed_set;  
#define ll long long int
#define pii pair<ll,ll>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define vi vector<ll>
#define vii vector<pii>
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define yes cout<<"YES"<<endl; return;
#define no cout<<"NO"<<endl; return;
#define flus fflush(stdin); fflush(stdout);
#define F first
#define S second
#define np next_permutation
#define inf 1e18
#define mod 1000000007
#define N 200009
#define pi (double)2*acos(0.0)
#define minpq priority_queue <ll, vector<ll>, greater<ll>>
#define maxpq priority_queue<ll> 
void sout(){
	cout<<endl;
}
template <typename T,typename... Types>
void sout(T var1,Types... var2){
	cout<<var1<<" ";
	sout(var2...);
}
/*******************************************************************/



void solve(){
	double d,t,s;
	cin>>d>>t>>s;
	double t1=d/s;
	if(t1<=t){
		sout("Yes");
	} else{
		sout("No");
	}

}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t;
	// cin>>t;
	t=1;
	while(t--){
		solve();
	}
}

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

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,x) for(int i=0;i<(int)(x);++i)
#define rep1(i,x) for(int i=1;i<=(int)(x);++i)
#define rrep(i,x) for(int i=(int)x-1;i>=0;--i)
#define rrep1(i,x) for(int i=(int)x;i>=1;--i)

using ll=long long;
using ld=long double;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int, int>;
using vpii=vector<pii>;

template<class T,class U>ostream&operator<<(ostream&os,const pair<T,U>p){os<<"("<<p.fst<<", "<<p.scd<<")";return os;}
template<class T>ostream&operator<<(ostream&os,const vector<T>v){rep(i,v.size()){if(i)os<<", ";os<<v[i];}return os;}
template<typename T>T&max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T&min(T&a,T&b){if(a < b)return a;return b;}
template<typename T>bool chmax(T&a,T b){if(a < b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a > b){a=b;return true;}return false;}

constexpr int inf = 1e9;
constexpr ll linf = 3e18;
constexpr double eps = 1e-9;

int N, M;
int ac[100010];
int wa[100010];


signed main()
{
    cin >> N >> M;

    rep(i, M) {
        int p; 
        string s;
        cin >> p >> s;

        p--;
        if (s == "AC") {
            ac[p]++;
        } else { // "WA"
            if (ac[p] == 0) wa[p]++;
        }
    }

    int solved = 0, penalty = 0;

    rep(i, N) {
        if (ac[i] >= 1) {
            solved++;
            penalty += wa[i];
        }
    }

    printf("%d %d\n", solved, penalty);

    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
int main()
{
	string n;
	cin>>n;
	ll ans=0;
	for(auto ch:n)
	{
		ans+=ch-'0';
	}	
	if(ans%9==0)
	cout<<"Yes\n";
	else
	cout<<"No\n";
}



Measured memory_bytes: 3708
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T> &p){ cout << "[" << p.first << ", " << p.second << "]"; return os; }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define Return(expr) { Cout(expr); return 0; }
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(string, s);
    CoutYn(!(s[0] == s[1] && s[1] == s[2]));
}

Measured memory_bytes: 256
//Problem: ABC 170A
//Progress:
#include <iostream>
#include <algorithm>
typedef long long int ll;
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll a, b, c, d, e;
    cin >> a >> b >> c >> d >> e;
    if(a == 0)
    	cout << 1;
    else if(b == 0)
    	cout << 2;
    else if(c == 0)
    	cout << 3;
    else if(d == 0)
    	cout << 4;
    else
    	cout << 5;
    return 0;
}

Measured memory_bytes: 3664
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
using namespace std;

const int maxn=1e5+10;

int a[maxn];

bool cmp(int x,int y){
	return x>y;
}

int main(){
	std::ios::sync_with_stdio(false);
	int n;
	cin>>n;
	for(int i=1;i<=n;++i){
		cin>>a[i];
	}
	sort(a+1,a+n+1,cmp);
	int pos=0;
	for(int i=1;i<=n;++i){
		if(a[i]>=i && a[i+1]<=i){
			pos=i;
			break;
		}
	}
	int len1=0;
	for(int i=pos+1;i<=n;++i){
		if(a[i]>=pos) len1++;
	}
	int len2=a[pos]-pos;
	if((!(len1&1)) && (!(len2&1))) cout<<"Second\n";
	else cout<<"First\n";
} 

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

const int N=205;
typedef long long int lint;


int main()
{
	int n;
	string a;
	scanf("%d",&n);
	cin >> a;
	int fl=1;
	for (int i = 0; i < n/2; ++i)
		if(a[i]!=a[i+n/2])
			fl=0;
	if(fl==0 || n%2)
		printf("No\n");
	else
		printf("Yes\n");

}

Measured memory_bytes: 384
N=int(input())
i=1

yakusu=0
while i<=N:
	j=1
	k=0
	
	while j<=i:
		if i%j==0:
			k=k+1
		j=j+1	
		if k==8:
			yakusu=yakusu+1
	i=i+2
print(yakusu)


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

  
  int main(){
    int n;
    cin >> n;
    map<int,int> m;
    int ans=0;

    rep(i,n){
      int tmp;
      cin >> tmp;
      m[tmp]++;
      if (m[tmp] == 3) {
        m[tmp]=1;
        ans++;
      } 
    }
    int kind=0;
    int one=0;
    int two=0;
    for (auto q:m){
      kind++;
      if (q.second == 1) one++;
      else two++;
    }
    if (two%2==0) cout << kind << endl;
    else if (two%2==1) cout << kind-1 << endl;
    return 0;
  }


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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
  int h,w;
  cin>>h>>w;
  vector<vi> g(10,vi(10));
  REP(i,10)REP(j,10)cin>>g[i][j];
  REP(k,10)REP(i,10)REP(j,10)CHMIN(g[i][j], g[i][k]+g[k][j]);
  int ans = 0;
  REP(i,h)REP(j,w){
    int a;
    cin>>a;
    if(a==-1)continue;
    ans += g[a][1];
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
/*
[arc099] E - Independence
*/

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

const int MAX_N = 700;

int N, M;
bool g[MAX_N][MAX_N];
int colors[MAX_N];
int cnt[2];

bool dfs(int n, int color = 0) {
    if (colors[n] != -1) {
        return colors[n] == color;
    }
    colors[n] = color;
    cnt[color]++;

    bool ret = true;
    for (int i = 0; i < N; i++) {
        if (g[n][i]) {
            ret = ret && dfs(i, color ^ 1);
        }
    }
    return ret;
}

ll solve() {
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            g[i][j] = !g[i][j];
        }
        g[i][i] = false;
    }

    memset(colors, -1, sizeof(colors));
    bitset<MAX_N + 1> dp;
    dp[0] = true;
    for (int i = 0; i < N; i++) {
        cnt[0] = 0;
        cnt[1] = 0;
        if (colors[i] == -1 && !dfs(i)) {
            return -1;
        }
        dp = (dp << cnt[0]) | (dp << cnt[1]);
    }

    int ans = N * N;
    for (int i = 0; i <= N; i++) {
        if (dp[i]) {
            ans = min(ans, (i * (i - 1) + (N - i) * (N - i - 1)) / 2);
        }
    }

    return ans;
}

int main() {
    cin >> N >> M;
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        g[a][b] = g[b][a] = true;
    }

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 768
import math

n = int(input())

a = int(math.floor(n / 1.08))

aa = int(math.floor(a * 1.08))
if n == aa:
  print(a)
  exit()
else:
  aa = (a+1) * 1.08
  aa = int(math.floor(aa))
  if n == aa:
    print(a+1)
  else:
    print(':(')


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P std::pair<int,int>
#define PiP std::pair<int,std::pair<int,int>>
#define all(v) v.begin(),v.end()
#define mkp std::make_pair
#define prique(T) std::priority_queue<T,vector<T>,greater<T>>
using namespace std;
template<class T> inline void chmax(T& a, T b) { a = std::max(a, b); }
template<class T> inline void chmin(T& a, T b) { a = std::min(a, b); }

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
int get_rand(int MIN, int MAX) {
	std::random_device rnd;
	std::mt19937 mt32(rnd());
	std::uniform_int_distribution<int>engine(MIN, MAX);
	return engine(mt32);
}
/*--------Library Zone!--------*/


signed main() {
	int n; cin >> n;
	cout << n * n << endl;
}


Measured memory_bytes: 256
# Swapping Two Numbers

zeroCount = 0
while zeroCount == 0:
    numbers = [int(i) for i in input().rstrip().split()]
    # print(numbers)
    if numbers[0] == 0 and numbers[1] == 0:
        zeroCount += 1
    else:
        swap = sorted(numbers)
        # print(swap)
        a = [str(n) for n in swap]
        print(" ".join(a))



Measured memory_bytes: 5616
#include <bits/stdc++.h>
#define rep(i, n) for(ll i=0;i<n;i++)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (b>a) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const long long INF = 2LL << 60;
using ll = long long;
using P = pair<ll, ll>;

int main(int argc, char const *argv[]){
    int a, b;
    cin >> a >> b;
    cout << a*b << endl;
    return 0;
}




Measured memory_bytes: 3640
#!/usr/bin/env python3
import collections


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

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

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

    if arr[0] == [1, 1]:
        return []

    return arr


n = int(input())
fact_list = factorization(n)

# print(fact_list)
ans = 0
for num, exp in fact_list:

    for i in range(1, exp+1):
        if exp-i >= 0:
            ans += 1
            exp -= i
        else:
            break

print(ans)


Measured memory_bytes: 9724
#include<iostream>
#include<algorithm>
int main(){
  int n;
  std::cin >> n;
  int l[n];
  int i,j,k;
  int cnt = 0;
  for(i=0;i<n;i++){
    std::cin >> l[i];
  }
  
  std::sort(l,l+n,std::greater<>());
  for(i=0;i<n-2;i++){
    for(j=i+1;j<n-1;j++){
      for(k=j+1;k<n;k++){
        if(l[i]<l[j]+l[k]) cnt++;
        else break;
      }
    }
  }
  
  std::cout << cnt;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

string S;

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

	string y = S.substr(0,4) , m = S.substr(5,2),d = S.substr(8,2);
	if(stoi(y) < 2019){
		cout << "Heisei" << endl;
	}else if(stoi(y) == 2019){
		if(stoi(m) <= 4){
			cout << "Heisei" << endl;
		}else{
			cout << "TBD" << endl;
		}
	}else{
		cout << "TBD" << endl;
	}
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	static final long MOD = 1000000007L;
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		char[] arr = sc.next().toCharArray();
		long[] counts = new long[26];
		Arrays.fill(counts, 1);
		for (char c : arr) {
			counts[c - 'a']++;
		}
		long total = 1;
		for (long x : counts) {
			total *= x;
			total %= MOD;
		}
		total -= 1;
		System.out.println(total);
	}
}


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

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

int main() {
	while (true) {
		int a, b, c;
		cin >> a >> b >> c;
		bool sleep = false;
		int cnt = 0;
		int ans = -1;
		for (int t = 1; t <= 1000000; t++) {
			if (t % 60 == c and !sleep) {
				ans = t;
				break;
			}
			cnt++;
			if (sleep and cnt == b) {
				sleep = false;
				cnt = 0;
			}
			else if (not sleep and cnt == a) {
				sleep = true;
				cnt = 0;
			}
		}
		cout << ans << endl;
		break;
	}
}


Measured memory_bytes: 3124
import math
n=int(input())
kouho = []
ans = []
for i in range(1,math.ceil(math.sqrt(n)+1)):
    if n % i == 0 :
        kouho.append([i,n//i])
for j in range(len(kouho)):
    ans.append(kouho[j][0]+kouho[j][1]-2)
print(min(ans))

Measured memory_bytes: 3720
#include <iostream>//cout<<right で右揃え
#include <iomanip>//cout<<setw(数字) で空白による桁揃え
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <cstdlib>//abs()で整数絶対値
#include <cmath>//abs()かfabs()で少数絶対値

using namespace std;
using ll = long long int;

int main(void){
    int N;cin>>N;
    vector<int> A(N),B(N);
    for(int i=0;i<N;i++){
        cin >> A[i];
        A[i]--;
        B[A[i]]++;
    }
    ll sum = 0;
    for(int i=0;i<N;i++){
        sum += (long)B[i]*((long)B[i]-1)/2;
    }
    ll ans;
    for(int i=0;i<N;i++){
        ans = sum - (B[A[i]]-1);
        cout << ans << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 4096
n,x=map(int,input().split())
ans=n
n-=x
n,x=max(n,x),min(n,x)
ans+=2*(n//x)*x
n%=x
n,x=x,n
while x:
    ans+=2*(n//x)*x
    n%=x
    n,x=x,n
print(ans-n)

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

signed main(void)
{
	string s, t;
	cin >> s >> t;
	s += s;
	rep(i, s.size())
	{
		if (t == s.substr(i, t.size()))
		{
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <stdint.h>
#include <vector>

using namespace std;

const int MAX = 1000001;
const int MOD = 1000000007;

uint32_t fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit(uint32_t max) {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i <= max; i++){
      fac[i] = fac[i - 1] * uint64_t(i) % MOD;
      inv[i] = MOD - uint64_t(inv[MOD%i]) * (MOD / i) % MOD;
      finv[i] = uint64_t(finv[i - 1]) * inv[i] % MOD;
    }
}

// 二項係数計算
uint32_t COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return uint64_t(fac[n]) * (finv[k] * uint64_t(finv[n - k]) % MOD) % MOD;
}

int main()
{
  int X, Y;
  cin >> X >> Y;

  int n = X+Y;
  int nb = 2*X-Y;
  if (n%3!=0 || nb%3!=0) {
    cout << 0 << endl;
    return 0;
  }

  nb /= 3;
  n /= 3;
  int na = n - nb;
  int r = min(na,nb);

  COMinit(n);
  cout << COM(n,r) << endl;

  return 0;
}


Measured memory_bytes: 10624
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T> using vv=vector<vector<T>>;
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
const ll MOD=1e9+7;

int main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
  int T;
  cin>>T;
  while(T--){
    int n,x;
    ll re=0;
    cin>>n>>x;
    for(int i=1;i<128;i<<=1){
      re+=1ll*i*(n-(n+!!(x&i))%2);
      //cout<<1ll*i*(n-(n+!!(x&i))%2)<<endl;
    }
    cout<<re<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var A = sc.ReadLong();
        var B = sc.ReadLong();
        var gcd = Gcd(A, B);
        var ans = 1 + PrimeFactors(gcd).Distinct().Count();
        Console.WriteLine(ans);
    }
    static long Gcd(long a, long b)
    {
        var v = new[] { a, b };
        while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
        return v[0];
    }
    static List<long> PrimeFactors(long n)
    {
        var res = new List<long>();
        var tmp = n;
        for (long x = 2; x * x <= n; x++)
        {
            while (tmp % x == 0)
            {
                tmp /= x;
                res.Add(x);
            }
        }
        if (tmp != 1) res.Add(tmp);
        return res;
    }

    static Scanner sc = new Scanner();
}

class Scanner
{
    string[] S = new string[0];
    int Index = 0;
    char[] Separators = new char[] { ' ' };

    public string Next()
    {
        if (this.Index < this.S.Length) return this.S[this.Index++];
        var line = "";
        while (line == "") line = Console.ReadLine();
        this.S = line.Split(this.Separators, StringSplitOptions.RemoveEmptyEntries);
        if (this.S.Length == 0) return this.Next();
        this.Index = 0;
        return this.S[this.Index++];
    }
    public string ReadStr()
    {
        return this.Next();
    }
    public char ReadChar()
    {
        return this.Next()[0];
    }
    public int ReadInt()
    {
        return int.Parse(this.Next());
    }
    public uint ReadUInt()
    {
        return uint.Parse(this.Next());
    }
    public long ReadLong()
    {
        return long.Parse(this.Next());
    }
    public double ReadDouble()
    {
        return double.Parse(this.Next());
    }
    public int[] ReadIntArray(int n)
    {
        var array = new int[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadInt();
        }
        return array;
    }
    public long[] ReadLongArray(int n)
    {
        var array = new long[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadLong();
        }
        return array;
    }
    public double[] ReadDoubleArray(int n)
    {
        var array = new double[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadDouble();
        }
        return array;
    }
    public char[] ReadCharArray(int n)
    {
        var array = new char[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadChar();
        }
        return array;
    }
    public string[] ReadStrArray(int n)
    {
        var array = new string[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadStr();
        }
        return array;
    }
}


Measured memory_bytes: 13280
#include <stdio.h>

int main(void)
{
    int x[10000], y[10000];
    int i = 0, j;
    
    do{
       scanf("%d %d", &x[i], &y[i]);
       i++;
    }while(x[i-1] || y[i-1]);
    
    i--;
    
    for(j=0; j<i; j++){
        if(x[j] < y[j]){
            printf("%d %d\n", x[j], y[j]);
        }
        else{
            printf("%d %d\n", y[j], x[j]);
        }
    }
    
    return 0;
}

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

int f(int n){
        if(n%2 == 0) return n/2;
        else return 3*n + 1;
}
int main(){
        int a[1000001];
        bool flag[1000001];
        cin >> a[1];
        flag[a[1]] = true;
        for(int i = 1; ;i++){
                a[i+1] = f(a[i]);
                if(flag[a[i+1]] == true){
                        cout << i + 1 << endl;
                        return 0;
                }
                flag[a[i+1]] = true;
        }
        return 0;
}


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

int main()
{
  int N;
  int Y;
  cin >> N >> Y;
  int pair[3] = {-1, -1, -1};
  for (int i = 0; i <= N; i++)
  { //10000円
    for (int j = 0; j <= N; j++)
    { //5000円
      if (i + j > N)
      {
        continue;
      }
      int k = N - i - j;
      if (k >= 0 && k <= N)
      {
        if (i * 10000 + j * 5000 + k * 1000 == Y)
        {
          pair[0] = i;
          pair[1] = j;
          pair[2] = k;
          break;
        }
      }
    }
  }
  cout << pair[0] << " " << pair[1] << " " << pair[2] << endl;
}


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

int main() {
  int N;  cin >> N;
  string S;  cin >> S;
  int K;  cin >> K;
  
  char moji = S[K-1];
  
  for (int i = 0; i < N; i++) {
    if (S[i] == moji) {
      cout << moji;
    } else {
      cout << '*';
    }
  }
  cout << endl;

}

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

vector<int> v;
int N;

int gcd(int a, int b) {
    return ( b % a ? gcd(b % a,a) : a);
}

int main (){
    cin >> N;
    for(int i=0; i<N; i++) {
        int x;
        cin >> x;
        v.push_back(x);
    }
    sort(v.begin(),v.end());
    int g = 1023456789;
    for(int i=0; i<N-1; i++) {
        int gd = gcd(v[i],v[i+1]);
        g = min(g,gd);
    }
    cout << g << endl;
    return 0;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;

int main() {
  int n;
  cin >> n;
  vi s(n);
  rep(i,n) cin >> s.at(i);
  bool ok = false;
  rep(i,n) if(s[i]%10!=0) ok = true;
  if(!ok) {
    cout << 0 << endl;
    return 0;
  }
  int sum = 0;
  rep(i,n) sum += s[i];
  if(sum%10!=0) {
    cout << sum << endl;
    return 0;
  }
  sort(s.begin(),s.end());
  rep(i,n) if(s[i]%10!=0) {
    cout << sum - s[i] << endl;
    return 0;
  }
}

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
// constexpr int MOD = 1e9 + 7;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;

constexpr int MOD = 998244353;

long long inv(long long n) {
    long long res = 1;
    while (n > 1) {
        res *= (MOD - MOD/n);
        res %= MOD;
        n = MOD % n;
    }
    return res;
}

void solve() {
    ll n, a, b, k;
    cin >> n >> a >> b >> k;

    vector<ll> comb(n+1);
    ll nume = 1, deno = 1;
    for (int i=0; i<n+1; ++i) {
        comb.at(i) = nume * inv(deno) % MOD;
        nume *= n - i;
        deno *= i + 1;
        nume %= MOD;
        deno %= MOD;
    }

    ll res = 0;
    for (ll i=0; i<=n; ++i) {
        if (a * i > k) break;
        if ((k - a * i) % b == 0) {
            ll j = (k - a * i) / b;
            if (j > n) continue;
            res += comb.at(i) * comb.at(j);
            res %= MOD;
        }
    }
    cout << res << '\n';
}

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

    solve();

    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#include <cstdlib>
#include <string>
#include <vector>
#include <cmath>
#include <iomanip>
#include <ios>
#include <sstream>
using namespace std;

int triple_max(int x, int y, int z){
    int ans = x;
    if (y > x && y > z) ans = y;
    else if (z > x && z > y) ans = z;

    return ans;
}


int main(){
    int a, e, k;
    cin >> a;
    for (int i = 0; i < 4; ++i) {
        cin >> e;
    }
    cin >> k;
    cout << (e-a <= k ? "Yay!" : ":(") << endl;
    return 0;
}


Measured memory_bytes: 256
import Data.List (nub)
import Control.Monad (replicateM)

import qualified Data.ByteString.Char8 as C
import Data.Maybe ( fromJust )

readInt :: IO Int
readInt = fst . fromJust . C.readInt <$> C.getLine

readInts :: IO [Int]
readInts = map (fst . fromJust . C.readInt) . C.words <$> C.getLine

main :: IO ()
main = do
  n  <- readInt
  ds <- replicateM n readInt
  print $ mochi ds

mochi
  :: [Int] -> Int
mochi = length . nub 

Measured memory_bytes: 508
from numpy import *
I=lambda:map(int,input().split())
F=lambda x:flipud(a.cumsum(x))
n,m,q=I()
a=zeros((n+2,n+2))
for i in [0]*m:
  s,e=I()
  a[s,e]+=1
a=F(1)
a=F(0)
for i in [0]*q:
  s,e=I()
  print(int(a[s,e]))

Measured memory_bytes: 17940
//Never stop trying
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

typedef string str;
typedef long long ll;
#define int ll
typedef double db;
typedef long double ld;

typedef pair<int,int> pi;
#define fi first
#define se second

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<pi> vpi;

#define pb push_back
#define eb emplace_back
#define pf push_front

#define lb lower_bound
#define ub upper_bound

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define endl "\n"

const int MOD = 1e9+7; //998244353
const ll INF = 1e18;
const int nx[4]={0,0,1,-1}, ny[4]={1,-1,0,0}; //right left down up

void IO(){
#ifndef ONLINE_JUDGE 
    freopen("input.txt", "r", stdin); 
    freopen("output.txt", "w", stdout); 
#endif 
}

const int MX=1e5+10;

int N;
vi adj[MX];
int p[MX];

int memo[MX][2];

int solve(int u, int l){
	if(memo[u][l]!=-1) return memo[u][l];
	int ans=1,ans2=1;
	bool found=false;
	for(auto v: adj[u]) if(v!=p[u]){
		ans*=solve(v,0);
		if(l==0) ans2*=solve(v,1);
		ans%=MOD; ans2%=MOD;
		found=true;
	}
	if(!found){
		if(l==0) return 2;
		else return 1;
	}
	return memo[u][l]=(ans+ans2-(l==1)+MOD)%MOD;
}

void dfs(int u, int pr){
	p[u]=pr;
	for(auto v: adj[u]) if(v!=pr) dfs(v,u);
}


int32_t main(){
   boost;
   IO();

   memset(memo,-1,sizeof(memo));
   cin>>N;
   for(int i=0; i<N-1; i++){
   	int u,v; cin>>u>>v;
   	adj[u].pb(v); adj[v].pb(u);
   }

   dfs(1,1);

   cout << solve(1,0) << endl;

   

   return 0;
}



Measured memory_bytes: 18272
/**********************************************
 * author : deepak nayan
 * file   : e:/Solutions/atcoder/abc157_a.cpp
 * time   : Sat May  2 19:38:01 2020
 * quest  : A - Duplex Printing
 *********************************************/
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  cout << ((n % 2) ? n / 2 + 1 : n / 2) << "\n";
  return 0;
}


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

using namespace std;

int main(){
    int a, b, c;
    cin >> a >> b >> c;

    if(a + b == c || b + c == a || c + a == b) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, char* argv[]) {
  int a, b, c;

  scanf("%d %d %d", &a, &b, &c);

  int c1 = c - (a - b);

  if (c1 < 0) printf("0\n");
  else printf("%d\n", c1);

  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main(){

  long long N;
  cin>>N;
  vector <long long> a;
  for(int i = 0;i<N;i++){
    long long b;
    cin >> b;
    a.push_back(b);
  }
  long long sum = 0;
  for(int i = 0;i<a.size();i++){
    sum+=a[i];
  }
  long long c = 0,d = 0;
  long long mi = 2*a[0] - sum;
  if(mi < 0)
    mi = -mi;
  for(int i = 0;i<a.size()-1;i++){
    c+=a[i];
    d=2*c-sum;
    if(d<0)
      d=-d;
   
    mi=min(mi,d);
  }
  cout <<mi<<endl;
  return 0;
}


Measured memory_bytes: 2420
#include <iostream>
#include <string>
using namespace std;
int main(){
  int N;
  while(cin >> N, N){
    string A[N];
    bool g = true;
    for(int i = 0; i < N; ++i){
      cin >> A[i];
    }
    long long int INF = 10000000000, m = -INF, M = INF;
    for(int i = 0; i < N; ++i){
      if(i > 0 && A[i] != "x" && A[i-1] != "x"){
	if(i%2 && stoi(A[i]) <= stoi(A[i-1])) g = false;
	else if(i%2 == 0 && stoi(A[i]) >= stoi(A[i-1])) g = false;
      }
      if(i > 0 && A[i] == "x" && A[i-1] == "x") g = false;
      if(A[i] == "x"){
	if(i%2){
	  if(i > 0 && A[i-1] != "x") m = max(m, (long long int)stoi(A[i-1]));
	  if(i < N-1 && A[i+1] != "x") m = max(m, (long long int)stoi(A[i+1]));
	}else{
	  if(i > 0 && A[i-1] != "x") M = min(M, (long long int)stoi(A[i-1]));
	  if(i < N-1 && A[i+1] != "x") M = min(M, (long long int)stoi(A[i+1]));	
	}
      }
    }
    //cout << M << " " << m << endl;
    if(g && M - m == 2) cout << m+1 << endl;
    else if(g && M - m > 2) cout << "ambiguous" << endl;
    else cout << "none" << endl;
  }
  return 0;
}

Measured memory_bytes: 3272
N = int(input())
A = [0] + list(map(int, input().split()))+[0]
S = sum([abs(A[i+1]-A[i]) for i in range(N+1)])

for i in range(1,N+1):
  print (S - abs(A[i]-A[i+1]) - abs(A[i]-A[i-1]) + abs(A[i+1]-A[i-1]))

Measured memory_bytes: 13920
a=[]
for t in range(3):
    d,e,f=map(int,input('').split(' '))
    a.append([d,e,f])

n=int(input(''))
b=[]
for t in range(n):
    r=int(input(''))
    b.append(r)

hit=[[0,0,0],[0,0,0],[0,0,0]]

for t in b:
    for i in range(3):
        for j in range(3):
            if a[i][j]==t:
                hit[i][j]=1

h=0
if hit[0][0]==1 and hit[0][1]==1 and hit[0][2]==1:
    h=1
elif hit[1][0]==1 and hit[1][1]==1 and hit[1][2]==1:
    h=1
elif hit[2][0]==1 and hit[2][1]==1 and hit[2][2]==1:
    h=1
elif hit[0][0]==1 and hit[1][0]==1 and hit[2][0]==1:
    h=1
elif hit[0][1]==1 and hit[1][1]==1 and hit[2][1]==1:
    h=1
elif hit[0][2]==1 and hit[1][2]==1 and hit[2][2]==1:
    h=1
elif hit[0][0]==1 and hit[1][1]==1 and hit[2][2]==1:
    h=1
elif hit[0][2]==1 and hit[1][1]==1 and hit[2][0]==1:
    h=1
else:
    h=0

if h==1:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3192
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <cstdio>

using namespace std;

const long long INF = 100000000;
const long long MOD = 1000000007;

std::vector<bool> IsPrime;

void sieve(size_t max)
{
  if (max + 1 > IsPrime.size())
  {                                // resizeで要素数が減らないように
    IsPrime.resize(max + 1, true); // IsPrimeに必要な要素数を確保
  }
  IsPrime[0] = false; // 0は素数ではない
  IsPrime[1] = false; // 1は素数ではない

  for (size_t i = 2; i * i <= max; ++i)     // 0からsqrt(max)まで調べる
    if (IsPrime[i])                         // iが素数ならば
      for (size_t j = 2; i * j <= max; ++j) // (max以下の)iの倍数は
        IsPrime[i * j] = false;             // 素数ではない
}

class Pointer{
public:
  long long p;
  long long w;
};

int main()
{
  string s;
  cin >> s;
  for (int i = 'a'; i <= 'z';i++){
    bool ans = true;
    for (int j = 0; j < s.length(); j++)
    {
      if(s[j]==i)
        ans = false;
      if(!ans)
        break;
    }
    if(ans){
      cout << (char)i << endl;
      return 0;
    }
  }
  cout << "None" << endl;
}


Measured memory_bytes: 512
def main():
    N = int(input())
    memo = dict()
    def f(i):
        if i not in memo:
            if i == 0:
                memo[i] = 2
            elif i == 1:
                memo[i] = 1
            else:
                memo[i] = f(i-1) + f(i-2)
        return memo[i]
    return f(N)

if __name__ == '__main__':
    print(main())


Measured memory_bytes: 3060
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <utility>
#include <memory>
#include <functional>
#include <deque>
#include <cctype>
#include <ctime>
#include <numeric>
#include <list>
#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


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

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll;
typedef vector<vector<long long> > vvll;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _rep(i,n) _rep2((i),0,(n))
#define _rep2(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) GET_MACRO(__VA_ARGS__, _rep2, _rep)(__VA_ARGS__)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define fi first
#define se second
#define mkp make_pair
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

void mainmain(){
	ll n,a,b;
	cin>>n>>a>>b;
	if(a>b){
		cout<<0<<endl;
	}
	else if(n==1){
		cout<<(b==a?1:0)<<endl;
	}
	else{
		cout<<(b-a)*(n-2)+1<<endl;
	}
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    mainmain();
}

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

int main() {
  int n;
  cin >> n;
  map<ll,int> mp;
  rep(i,n){
    ll num;
    cin >> num;
    mp[num]++;
  }
  ll ans = 0;
  for(auto i: mp){
    if(i.second % 2 == 1) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 6528
#include<iostream>
#include<cstdio>
using namespace std;
int main ()
{
    int a, b, r;
    while(cin>>a>>b)
    {
        if(a>=2 && a<=100 && b>=2 && b<=100)
        {
        r=(a-1)*(b-1);
        cout<<r<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);

        int a = s.nextInt();
        int b = s.nextInt();
        int answer;

        if (a >= 10 || b >= 10)
            answer = -1;
        else
            answer = a * b;

        System.out.println(answer);
    }
}

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

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


int main()
{
    int a,b;
    cin>>a>>b;
    int ans = max(a+b, max(a-b,a*b));
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256