akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <chrono>
#include <random>
#include <cmath>
using namespace std;
using namespace __gnu_pbds;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define uid uniform_int_distribution<lli>
#define lli long long int
#define ff first
#define ss second
#define pb push_back
#define popf pop_front()
#define popb pop_back()
#define all(vec) vec.begin(), vec.end()
#define fol(i,a,b) for(int i=a;i<b;i++)
#define forr(x,arr) for(auto& x:arr)
#define sz(x) (x.size())
#define mod 1000000007
#define INF 1000000000000000010
#define vi vector<int>
#define vlli vector<lli>
#define endl "\n"
#define ofk order_of_key
#define fbo find_by_order
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

template<class my>
using indexed_set = tree<my,null_type,less<my>,rb_tree_tag,tree_order_statistics_node_update>;

template <class my>
inline my aabs (const my &a)   { return (a > 0)  ? a : -a;         }
inline lli gcd(lli a, lli b)   { return (b == 0) ? a : gcd(b,a%b); }
inline lli LSOne(lli k)        { return (k&(-k));                  }

inline int inv(lli o, int m = mod) {
  int b = m, u = 0, v = 1, t, a=o%m;
  while (a) {
    t = b / a;
    b -= t * a; swap(a, b);
    u -= t * v; swap(u, v);
  }
  if (u < 0) u += m;
  return u;
}
inline int add(const int &a, const int &b, int m=mod) { return ( a + b ) % m;           }
inline int sub(const int &a, const int &b, int m=mod) { return ( a - b + m ) % m;       }
inline int mul(const int &a, const int &b, int m=mod) { return int ( 1LL * a * b % m ); }
inline int mpow(int a, int b, int m=mod) {
    int ans = 1;
    a=((a%m)+m)%m;
    while (b) {
        if (b & 1) ans = mul(ans, a, m);
        a = mul(a, a, m);
        b >>= 1;
    }
    return ans;
}

void tejas_919()
{
    lli n, k, m, q, u=0, v=0, temp=1, max1=-1, max2=-1, ans=0, a, b, val=0;
    cin>>n;
    int arr[n+5]={};
    fol(i,0,n) cin>>arr[i];
    fol(i,0,n)
    {
        if(arr[i]>=max1)
        {
            max2=max1;
            max1=arr[i];
        }
        else if(arr[i]>max2)
        {
            max2=arr[i];
        }
    }
    fol(i,0,n)
    {
        if(arr[i]==max1)
        {
            cout<<max2<<endl;
        }
        else cout<<max1<<endl;
    }
}

int main()
{
    fastio cout<<endl;
    cout << fixed << setprecision(10);
    int t=1;
    //cin>>t;
    while(t--)
        tejas_919();
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

//typedef vector<int> vi;

int main() {FIN
  int n, i, _min, c = 0, e;
            cin >> n;
            _min = n + 1;
            //vi ns(n);
            for (i = 0; i < n; i++) {
              cin >> e;
              if (e < _min)
                c++;
              _min = min(_min, e);
            }
            cout << c << "\n";
  return 0;
           }

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

int Coin(int& A, int& B)
{
    int ret;
    if(A>B)
    {
        ret = A;
        A--;
    }
    else
    {
        ret = B;
        B--;
    }
    return ret;
}

int main(int argc, char const *argv[])
{
    int A,B;
    cin >> A >> B;

    int ans = Coin(A,B) + Coin(A,B);
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
int main () {
	int n, m;
	cin >> n >> m;
	int penalty[n + 1];
	for(int i = 1; i <= n; i++) penalty[i] = 0;
	int ans1 = 0;
	int ans2 = 0;
	for(int i = 0; i < m; i++) {
		int p;
		string res;
		cin >> p;
		cin >> res;
		if(res == "WA") {
			if(penalty[p] != -1) penalty[p] += 1;
		}else {
			if(penalty[p] != -1) {
				ans1 += 1;
				ans2 += penalty[p];
				penalty[p] = -1;
			}
		}
	}
	cout << ans1 << " " << ans2 << "\n";
	return 0;
}

Measured memory_bytes: 640
# 2butan renshuu 0812

def f(m):
  cut=0
  for aa in a:
    cut+=(aa-1)//m
    if cut > k:
      return False
  return True

n,k=map(int,input().split())
a=list(map(int,input().split()))

l=0
r=10**9+1
while r-l>1:
  m=(l+r)//2
  # right move
  if f(m):
    r=m
  else:
    l=m

print(r)


Measured memory_bytes: 31024
use proconio::{fastout, input};

#[fastout]
fn main() {
    input!{
        n:usize,
        m:[i32; n],
    }
    let mut counter = 1;
    for i in 1..n {
        let target = &m[i];
        let mut tc = 0;
        for l in &m[0..i] {
            if target > l {
                tc += 1
            }
        }
        if tc > 0 {
            continue
        }
        counter += 1
    }
    print!("{}",counter)
}


Measured memory_bytes: 3952
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <cctype>
#include <cstdlib>
#include <set>
#include <map>
#include <sstream>
using namespace  std;
#define  ll long long
#define mINF(a) memset(a,0x3f3f3f3f,sizeof(a))
#define m0(a) memset(a,0,sizeof(a))
#define mf1(a) memset(a,-1,sizeof(a))
#define lowbit(x) (x&(-x)) 
#define lson i<<1,l,l+r>>1
#define rson i<<1|1,((l+r)>>1)+1,r
typedef pair<ll,ll>P;
static const ll INF=0x3f3f3f3f;
static const ll len=1e5+5;
int main()
{  
	ll n,c,k;
	while(cin>>n>>c>>k)
	{
		ll ans[len];
		for(ll i=0;i<n;++i)
		{
			scanf("%lld",ans+i);
		}
		sort(ans,ans+n);
		ll sum=0;
		for(ll i=0;i<n;++i)
		{
			ll x=ans[i]+k;
			ll c1=0;
			ll w=0;
			while(ans[i]<=x&&i<n)
			{
				w=1;
				c1++;
				i++;
				if(c1==c)
					break;
			}
			i--;
			sum++;
		}
		cout<<sum<<endl;
	}
    return 0;
}

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


int main(){
    int n; 
    scanf("%d", &n);
    int m=n, a=0;
    while(n){ a+=n%10; n/=10; }
    if(m%a==0) printf("Yes\n");
    else printf("No\n");
}

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

const int INF = 1000000;
const int town_max = 10;

int main()
{
	while(true){
		int n;
		cin >> n;
		if(n==0)
			break;

		int T[town_max][town_max];
		for(int i=0;i<town_max;i++){
			for(int j=0;j<town_max;j++){
				if(i==j)
					T[i][j] = 0;
				else
					T[i][j] = INF;
			}
		}

		int m = 0;	//頂点の数
		for(int i=0;i<n;i++){
			int a, b, c;	//町の番号は0から
			cin >> a >> b >> c;
			T[a][b] = T[b][a] = c;
			if(a+1>m)
				m = a+1;
			if(b+1>m)
				m = b+1;
		}

		for(int i=0;i<m;i++){
			for(int j=0;j<m;j++){
				for(int k=0;k<m;k++){
					if(T[j][k]>T[j][i]+T[i][k])
						T[j][k] = T[j][i]+T[i][k];
				}
			}
		}


		int T_min = INF;
		int town_min = -1;
		for(int i=0;i<m;i++){
			int T_sum = 0;
			for(int j=0;j<m;j++){
				T_sum += T[i][j];
			}
			if(T_sum<T_min){
				T_min = T_sum;
				town_min = i;
			}
		}

		cout << town_min << " " << T_min << endl;
	}
}


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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)x.size())
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

/*{
}*/

using vi = vector<int>;
using vvi = vector<vi>;
using P = pair<int,int>;

//constexpr int mod = 1e9+7;
//constexpr int inf = 1LL<<60;

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

  int sum = 0, n = 0;
  rep(i, 0, m){
    int d, c;
    cin >> d >> c;
    sum += d*c;
    n += c;
  }

  cout << (n-1 + (sum-1)/9) << endl;

  return 0;
}



Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Sat Jun 17 09:19:58 2017

@author: syaga
"""


if __name__ == "__main__":
    N = int(input())
    A = list(map(int, input().split()))
    print(" ".join(map(str, A)))
    for i in range(1, N):
        v = A[i]
        j = i - 1
        while j >= 0 and A[j] > v:
            A[j+1] = A[j]
            j -= 1
        A[j+1] = v
        print(" ".join(map(str, A)))

Measured memory_bytes: 7676
import java.io.*;
class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out));
		String s = br.readLine();
		for(int i=0;i<s.length();++i) {
			if(s.charAt(i)==',') pw.print(' ');
			else pw.print(s.charAt(i));
		}
		pw.print('\n');
		pw.flush();
	}
} 

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

int main()
{
    int h1,m1,h2,m2,k,out;
    scanf("%d %d %d %d %d",&h1,&m1,&h2,&m2,&k);
    if(m2>=m1) out=(h2-h1)*60+(m2-m1)-k;
    if(m2<m1) out=(h2-h1-1)*60+(m2+60-m1)-k;
    printf("%d\n",out);
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> a(3*N);
  for (int i = 0; i < 3*N; i++) cin >> a.at(i);
  priority_queue<int, vector<int>, greater<int>> pq_l;
  priority_queue<int> pq_r;
  long long sum_l = 0, sum_r = 0;
  vector<long long> sum_l_lst(N+1), sum_r_lst(N+1);
  for (int i = 0; i < N; i++) {
    pq_l.push(a.at(i));
    sum_l += a.at(i);
    pq_r.push(a.at(2*N+i));
    sum_r += a.at(2*N+i);
  }
  sum_l_lst.at(0) = sum_l;
  sum_r_lst.at(N) = sum_r;
  for (int i = 0; i < N; i++) {
    pq_l.push(a.at(N+i));
    sum_l += a.at(N+i) - pq_l.top();
    sum_l_lst.at(1+i) = sum_l;
    pq_l.pop();
    pq_r.push(a.at(2*N-1-i));
    sum_r += a.at(2*N-1-i) - pq_r.top();
    sum_r_lst.at(N-1-i) = sum_r;
    pq_r.pop();
  }
  long long ans = -1LL << 60;
  for (int i = 0; i <= N; i++) {
    ans = max(ans, sum_l_lst.at(i) - sum_r_lst.at(i));
  }
  cout << ans << endl;
}

Measured memory_bytes: 3964
#include<bits/stdc++.h>
  
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define pow2(a) ((a)*(a))
#define MAX_N 11
#define MAX_M 1010
#define IINF (INT_MAX)
#define EPS (1e-7)
#define equals(a,b) (fabs((a)-(b)) < EPS)
  
using namespace std;
  
class Point{
public:
  double x,y;

  Point(double x = -IINF,double y = -IINF): x(x),y(y){}

  Point operator + (Point p){return Point(x+p.x,y+p.y);}
  Point operator - (Point p){return Point(x-p.x,y-p.y);}
  Point operator * (double a){return Point(a*x,a*y);}
  Point operator / (double a){return Point(x/a,y/a);}
  Point operator * (Point a){ return Point(x * a.x - y * a.y, x * a.y + y * a.x); }

  bool operator < (const Point& p) const{ return !equals(x,p.x)?x<p.x:y<p.y; }

  bool operator == (const Point& p)const{ return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS; }

};
  
typedef Point Vector;

inline double norm(Point a){
  return a.x*a.x + a.y*a.y;
}

inline double abs(Point a){
  return sqrt(norm(a));
}
  
int N,M,Frisbee[MAX_N];
Point D[MAX_N],FP;
double V[MAX_N],FV_x,FV_y;
  
int main(){
  while( cin >> N >> M, N|M ){
    rep(i,N){
      cin >> D[i].x >> D[i].y >> V[i];
      Frisbee[i] = 0;
    }
  
    rep(_,M){
      cin >> FP.x >> FP.y >> FV_x >> FV_y;
      double timer[N];
      double minimum_time = IINF;
      rep(i,N)timer[i] = IINF;
      rep(i,N){
	double DIFF_X = FP.x - D[i].x;
	double DIFF_Y = FP.y - D[i].y;
	double a = FV_x * FV_x + FV_y * FV_y - V[i] * V[i];
	double b = 2 * DIFF_X * FV_x + 2 * DIFF_Y * FV_y;
	double c = DIFF_X * DIFF_X + DIFF_Y * DIFF_Y;
	
	if( equals(a,0) ){
	  if( - c / b ) timer[i] = - c / b;
	} else{
	  if( equals(b*b-4*a*c,0) || b*b-4*a*c > 0 ){
	    double t = ( -b + sqrt( b*b - 4*a*c ) ) / ( 2.0 * a );
	    if( equals(t,0) || t > 0 ) timer[i] = min(timer[i],t);
	    t = ( -b - sqrt( b*b - 4*a*c ) ) / ( 2.0 * a );
	    if( equals(t,0) || t > 0 ) timer[i] = min(timer[i],t);
	  }
	}
	minimum_time = min(minimum_time,timer[i]);
      }

      //cout << "MINTIME = " << minimum_time << endl;
      rep(i,N){
	if( timer[i] == IINF ) continue;
	//cout << "t[" << i << "] = " << timer[i] << endl;
	if( equals(timer[i],minimum_time) ) Frisbee[i]++;
	Point next_FP = Point(FP.x+FV_x*timer[i],FP.y+FV_y*timer[i]);
	//cout << "next_FP = " << next_FP.x << "," << next_FP.y << endl;
	Vector v = next_FP - D[i];
	Vector e = v / abs(v);
	//cout << e.x << "," << e.y << endl;
	D[i] = D[i] + e * ( minimum_time * V[i] );

      }
      //rep(i,N)cout << "(" << D[i].x << "," << D[i].y << ")" << endl;
    }
  
    rep(i,N){
      if( i ) cout << ' ';
      cout << Frisbee[i];
    } cout << endl;
  
  }
  return 0;
}

Measured memory_bytes: 1236
class UnionFind:
    def __init__(self, n):
        self.parents = [i for i in range(n)]
        self.sizes = [1] * n
        self.rank = [0] * n

    def find(self, i):
        if self.parents[i] == i:
            return i
        else:
            self.parents[i] = self.find(self.parents[i]) # 経路圧縮
            return self.parents[i]

    def unite(self, i, j):
        pi = self.find(i)
        pj = self.find(j)
        if pi != pj:
            if self.rank[pi] < self.rank[pj]:
                self.sizes[pj] += self.sizes[pi]
                self.parents[pi] = pj
            else:
                self.sizes[pi] += self.sizes[pj]
                self.parents[pj] = pi
                if self.rank[pi] == self.rank[pj]:
                    self.rank[pi] += 1
    def same(self, i, j):
        return self.find(i)==self.find(j)

# if __name__=="__main__":
#     n, Q = map(int,input().split())
#     uf = UnionFind(n)
#     for q in range(Q):
#         cmd, i, j = map(int,input().split())
#         if cmd == 0:
#             uf.unite(i,j)
#         else:
#             print(int(uf.same(i,j)))
#     print (uf.sizes)
#     print (uf.parents)
#     print (uf.rank)

adj = []
N, M = map(int,input().split())
for m in range(M):
    a,b = map(int,input().split())
    adj.append([a-1,b-1])

ans = 0
for i in range(M):
    uf = UnionFind(N)
    for j in range(M):
        if (i==j):
            continue
        uf.unite(*adj[j])
    
    for n in range(N):
        uf.find(n)
    #print (uf.parents)
    if len(set(uf.parents))!=1:
        ans += 1
    #break
print (ans)

Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(int argc, char *argv[])
{
  int N;
  cin >> N;
  vector<string> S(N);
  for (int i = 0; i < N; i++) {
    cin >> S.at(i);
  }

  sort(S.begin(), S.end());
  vector<int> count(N);
  count.at(0) = 1;
  for (int i = 1; i < N; i++) {
    if (S.at(i) == S.at(i - 1)) {
      count.at(i) = count.at(i - 1) + 1;
    } else {
      count.at(i) = 1;
    }
  }
  int max_count = 0;
  for (int i = 0; i < N; i++) {
    max_count = max_count < count.at(i) ? count.at(i) : max_count;
  }
  for (int i = 0; i < N; i++) {
    if (count.at(i) == max_count) {
      cout << S.at(i) << endl;
    }
  }
  return 0;
}


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

def div_count(i):
    count = 0
    for div in range(1, i+1):
        if i % div == 0:
            count += 1

    return count

ans = 0
for i in range(1, N+1, 2):
    if div_count(i) == 8:
        ans += 1

print(ans)

Measured memory_bytes: 3060
from math import sqrt

def is_prime(x):
    if x == 2:
        return True

    if x % 2 == 0 or x < 2:
        return False

    i = 3 
    x_sqrt = sqrt(x)
    while i <= x_sqrt:
        if x % i == 0:
            return False
        i += 2

    return True

def prime_numbers(x):
    i_a = list(range(2, x+1))
    p_a = list()
    e_a = sqrt(x)
    h = i_a[0]
    while h < e_a:
        h = i_a[0]
        p_a.append(h)
        for j in i_a:
            if j % h == 0:
                i_a.remove(j)
    p_a += i_a
    p_a.sort()

    return p_a

if __name__ == "__main__":
    i = int(input())
    n = i
    f = list()
    p_ns = prime_numbers(int(sqrt(n)))

    while not is_prime(n):
        for p in p_ns:
            if n % p == 0:
                f.append(p)
                n = int(n / p)
                break
    f.append(n)
    f.sort()

    print(str(i)+":", " ".join(map(str, f)))

Measured memory_bytes: 8940
#include <bits/stdc++.h>
using namespace std;
#define Sz(a) ((int)(a).size())
const int maxn = 1<<19;
const int MOD = 1e9 + 7;
int V[maxn],W[maxn],n,q,dp[555][100009];
int main(){
#ifdef DEBUG
  freopen("a.in", "r", stdin);
#endif
  ios_base::sync_with_stdio(false);cout.tie(0);cin.tie(0);
  cin>>n;
  for(int i=1;i<=n;++i)cin>>W[i]>>V[i];
  for(int i=1;i<=512;++i){
    for(int j=0;j<=100000;++j)dp[i][j]=dp[i>>1][j];
    for(int j=0;j<=100000;++j)if(j>=V[i])dp[i][j]=max(dp[i>>1][j-V[i]]+W[i],dp[i][j]);
  }
  cin>>q;
  for(int ts=1;ts<=q;++ts){
    int v,l,ans=0;cin>>v>>l;
    if(v<=512){
      ans=dp[v][l];
    }else{
      vector<int> idx;
      for(;v>512;v>>=1)idx.push_back(v);
      int totv,totw;
      for(int i=0;i<(1<<Sz(idx));++i){
        totv=totw=0;
        for(int j=0;j<Sz(idx);++j)if(i>>j&1)totv+=V[idx[j]],totw+=W[idx[j]];
        if(totv<=l){
          ans=max(dp[v][l-totv]+totw,ans);
        }
      }
    }
    cout<<ans<<'\n';
  }
  return 0;
}
//2020.06.14 10:06:45


Measured memory_bytes: 205724
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i = (a); i < (b); ++i)
#define rrep(i,a,b) for(int i = (b); i --> (a);)
#define all(v) (v).begin(),(v).end()
#define trav(x,v) for(auto &x : v)
#define sz(v) int(v.size())
typedef vector<int> vi;
typedef long long ll;
typedef pair<int,int> pii;

const int mx = 2e5+1;
const ll md = 1e9+7;

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

	int n;
	cin >> n;

	vi cs;
	rep(_,0,n){
		int c;
		cin >> c;
		if(cs.empty() || cs.back() != c)
			cs.push_back(c);
	}
	n = sz(cs);

	vector<ll> dp(n+1);
	dp[n] = 1;
	vi nx(mx,-1);
	rrep(i,0,n){
		dp[i] = dp[i+1];
		if(nx[cs[i]] != -1)
			dp[i] = (dp[i] + dp[nx[cs[i]]]) % md;
		nx[cs[i]] = i;
	}
	cout << dp[0] << endl;
}


Measured memory_bytes: 3572
// Bismillahir Rahmanir Rahim
// Mr_Emrul

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

typedef long long int ll;
typedef pair <ll, ll> pll;
typedef pair <ll, pll> plp;
typedef pair <int, int> pii;
typedef pair <int, pii> pip;
const ll MX = 1000005;

#define LCM(a,b)        (a / __gcd(a,b) ) *-b
#define gcd(a,b)        __gcd(a,b)
#define all(x)          (x).begin(), (x).end()
#define mem(a, n)       memset(a,n,sizeof(a))
#define for1(i, n)      for(i=1; i<=n; i++)
#define for0(i, n)      for(i=0; i<n; i++)
#define rof0(i, n)      for(i=n-1; i>=0; i--)
#define rof1(i, n)      for(i=n; i>=1; i--)
#define forab(i, a, b)  for(i=a; i<=b; i++)
#define rofab(i, a, b)  for(i=b; i>=a; i--)
#define pb              push_back
#define pbb             pop_back
#define YES             cout << "YES" << endl
#define NO              cout << "NO" << endl
#define sin(s)          getline(cin, s)
#define scf(a)          cin >> a
#define scf2(a, b)      cin >> a >> b
#define scf3(a, b, c)   cin >> a >> b >> c
#define scf4(a,b,c,d)   cin >> a >> b >> c >> d
#define pnf(a)          cout << (a) << endl
#define pnf2(a, b)      cout << (a) << " " << (b) << endl
#define pnf3(a, b, c)   cout << (a) << " " << (b) << " " << (c) << endl
#define pnfa(a)         cout << (a) << " "
#define pf(a)           cout << (a)
#define sp              cout << " "
#define nl              cout << endl
#define sz(n)           n.size()
#define clear(v)        v.clear()
#define bug(n)          cout << ">> " << n << " <<" << endl
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define in              freopen("in.txt", "r", stdin)
#define out             freopen("out.txt", "w", stdout)
#define fast            {ios_base::sync_with_stdio(false); cin.tie(0);}
#define F               first
#define S               second
#define mpp             make_pair

int main()
{
    ll n, m, t,x=0, i, j, cnt=0;
    ll a, b, c;
    scf3(a, b, c);
    for0(i, 100)
    {
        x += a;
        if((x-c) % b == 0)
        {
            YES;
            return 0;
        }
    }
    NO;
}


Measured memory_bytes: 256
#include<cstdio>
int main() {
	int n[26];
	char w[101];
	scanf("%s", w);
	for (int i = 0; i < 26; i++) {
		n[i] = 0;
	}
	for (int i = 0; w[i] != '\0'; i++) {
		n[w[i] - 'a']++;
	}
	for (int i = 0; i < 26; i++) {
		if (n[i] % 2 != 0) {
			printf("No");
			return 0;
		}
	}
	printf("Yes");
	return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int i = sc.nextInt();
        int j = sc.nextInt();
        
        int g = j - i;
        
        for(int f = 1;f < j - i;f++) {
            g += f;
        }
        System.out.print(g - j);
    }
}

Measured memory_bytes: 23892
/*|In The Name Of Allah|*/

#include <bits/stdc++.h>

using namespace std;

const int N = 3e5 + 5;

int n;
string s;
int pr[N];
int sf[N];

int main(){
    cin >> n >> s;
    for(int i = 0; i < n; i++){
        pr[i] = (s[i] == 'E') + ((i == 0) ? 0 : pr[i - 1]);
    }
    for(int i = n-1; i >= 0; i--){
        sf[i] = (s[i] == 'W') + sf[i+1];
    }
    int best = N;
    for(int i = 0; i < n; i++){
        if(i == 0){
            int now = (n-1) - sf[1];
            best = min(best , now);
            continue;
        }
        int now = i - pr[i - 1];
        now += (n - (i+1)) - sf[i+1];
        best = min(best , now);
    }
    cout << best << endl;
}


Measured memory_bytes: 3076
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename X> ostream& operator << (ostream& x,const vector<X>& v){for(ll i=0;i<v.size();++i) x<<v[i]<<" ";return x;}
template <typename X> ostream& operator << (ostream& x,const set<X>& v){for(auto it:v) x<<it<<" ";return x;}
template <typename X, typename Y> ostream& operator << (ostream& x, const pair<X,Y>& v) {x<<v.ff<<" "<<v.ss;return x;}
template <typename T, typename S> ostream& operator << (ostream& os, const map<T, S>& v) { for (auto it : v) os << it.first << "=>" << it.second << endl; return os; }
struct pair_hash {inline std::size_t operator()(const std::pair<ll, ll> & v) const {return v.first*31+v.second;}};
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pb push_back
#define fr first
#define sc second
#define prnt(m) for(auto it = m.begin() ; it != m.end() ; ++it){cout<<*it<<endl;}
#define tra(it,m) for(auto it=m.begin();it!=m.end();++it)
#define DBG(x) cout<<"# # #     "<<x<<'\n';
#define fri(i,s,n) for(long long i=s;i<n;i++)
#define mod 1000000007LL
#define mod2 998244353
#define vct2 vector<vector<ll>>
#define vct vector<ll>
#define pll pair<ll,ll>
#define rz(n) resize(n)
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define arrin(a,n) for(ll i = 0; i < n ; i++){cin>>a[i];}
#define arrout(a,n) for(ll i = 0;i < n; i++){cout<<a[i]<<" ";}
#define ex(s) cout<<s<<endl,exit(0);
#define infy 2e18
#define five 100005;
#define six 1000005;
#define prllclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
//___________________________________________________________________________________________________________________
int main()
{
       string s;
       cin>>s;
       int n = s.size();
       if(n%2){
              cout<<"No"<<endl;
              return 0;
       }
       n /= 2;
       string ss = "";
       fri(i,0,n){
              ss += "hi";
       }
       if(ss == s){
              cout<<"Yes"<<endl;
       }
       else{
              cout<<"No"<<endl;
       }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
using namespace std;
long long n, d, hasil;
int main(){
	while(cin >> d){
		hasil = 0;
		for(int i = d; i <= 600-d; i += d){
			hasil += d * pow(i, 2);
		}
		cout << hasil << endl;
	}
	return 0;
}

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


int main() {
    string S;
    cin>>S;
    int N=S.size();
    for(int i=1; i<=N; i++) {
        string w=S.substr(0,N-i);
        if(w.size()%2==1) continue; //奇数列だったら第イイを満たさないから次のループ
        else {
            int n=w.size();
            bool ok=true;
            for(int j=0; j<(n/2); j++)  {
                if(w[j]!=w[j+(n/2)]) ok=false;
            }
            if(ok) {
                cout<<n<<endl;
                return 0;
            }
            else {
                continue;
            }
        }
    }
}

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

struct data{
  int h,w,len;
  void set(int a,int b){
    h=a,w=b,len=a*a+b*b;
  }
  bool operator < (const data& p)const{
    return (len==p.len? h<p.h:len<p.len);
  }
};

int h,w;
vector<data> t;
void make_table(){
  t.clear();
  data a;
  for(int i=1;i<=150;i++){
    for(int j=i+1;j<=150;j++){
      a.set(i,j);
      t.push_back(a);
    }
  }
  sort(t.begin(),t.end());
}

int main(){  
  int h,w;
  data d;
  make_table();
  while(cin>>h>>w&&h&&w){
    d.set(h,w);
    vector < data > :: iterator it;
    it = upper_bound(t.begin(),t.end(),d);
    cout<<it->h<<' '<<it->w<<endl;
  }
  return 0;
}

Measured memory_bytes: 1348
L,R = map(int,input().split())

mod = 10**9+7
m = 64 +1
fac = [1]*m
ninv = [1]*m
finv = [1]*m
for i in range(2,m):
    fac[i] = fac[i-1]*i%mod
    ninv[i] = (-(mod//i)*ninv[mod%i])%mod
    finv[i] = finv[i-1]*ninv[i]%mod

def comb(n,k):
    return (fac[n]*finv[k]%mod)*finv[n-k]%mod

def f(L,R):
    if L>R : return 0
    R = bin(R)[2:]
    N = len(R)
    ret = f(L,int("0"+"1"*(N-1),2))
    L = bin(L)[2:]
    if len(L) != N : L = "1"+"0"*(N-1)
    for i in range(N):
        if R[i] == "0" : continue
        R2 = R[:i] + "0" + "?"*(N-i-1)
        if i==0: R2 = R
        for j in range(N):
            if L[j] == "1" and j!=0 : continue
            L2 = L[:j] + "1" + "?"*(N-j-1)
            if j==0 : L2 = L
            if L2[0] == "0" : break
            tmp = 1
            for r,l in zip(R2[1:],L2[1:]):
                if r=="0" and l=="1" : tmp *= 0
                if r=="?" and l=="?" : tmp *= 3
                if r=="?" and l=="0" : tmp *= 2
                if r=="1" and l=="?" : tmp *= 2
            ret += tmp
            ret %= mod
    return ret%mod

print(f(L,R))

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define ll long long int
#define pii pair<ll,ll>
#define mp make_pair
#define pb push_back
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define M 500005
#define mod 1000000007
#define inf LLONG_MAX
#include<string>
using namespace std;
ll n,W,a[105][2],dp[105][100008];
ll f(ll i,ll w)
{
	if(i==n)
		return 0;
	if(w>W)
		return 0;
	if(dp[i][w]==-1)
	{
		dp[i][w]=0;
		for(ll j=i;j<n;j++)
		{
			if(a[j][0]+w<=W)
			dp[i][w]=max(dp[i][w],a[j][1]+f(j+1,w+a[j][0]));
		}
	}
	return dp[i][w];
}
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n>>W;
	for(ll i=0;i<n;i++)
		cin>>a[i][0]>>a[i][1];
	memset(dp,-1,sizeof(dp));
	cout<<f(0,0)<<endl;
	return 0;
}

Measured memory_bytes: 82304
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <utility>
#include <deque>
#include <stack>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<ll> vl;
typedef queue<int> qi;
typedef queue<ll> ql;
typedef pair<ll,ll> pll;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
#define rep(i,n) for (int i=0;i<n;i++)
#define mp make_pair
#define pb push_back
#define pf push_front
#define F first
#define S second
#define INF 200000009
int n,k;
int main(){
	ios::sync_with_stdio(false);
	cin>>n>>k;
	if (k<=(n+1)/2) cout<<"YES";
	else cout<<"NO";
	return 0; 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MAX 1000000005
int main()
{
    int n,k;
    cin>>n>>k;
    int *arr=new int[n];
    for(int i=0;i<n;i++)
        cin>>arr[i];
  //  cout<<arr[0]<<" "<<arr[1]<<" "<<arr[2]<<endl;
    int *dp=new int[n];
    for(int i=0;i<n;i++)
        dp[i]=MAX;
    dp[0]=0;
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<=(k+i);j++)
        {if(j<n)
            dp[j]=min(dp[j],dp[i]+abs(arr[i]-arr[j]));
        }
    }
  // for(int i=0;i<n;i++)
    //   cout<<dp[i]<<" ";
    //cout<<endl;
    cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 4416
/*input

*/
/*
Contest: 
Problem: 
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

#define F first
#define S second
#define mp make_pair
#define append push_back
#define vi vector<ll>
#define pii pair<ll,ll>
#define qi queue<ll>
#define mem(a,b) memset(a,b,sizeof(a))
#define ll long long int
#define print(a) cout<<a<<endl
#define sorted(a) sort(arr.begin(), arr.end())
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define read(a) scanf("%d", &a)
 
const int MOD = 1e9 + 7;

signed main(){
    
    int n, k;
    cin>> n >> k;
    vector<int> dp(n, INT_MAX);
    dp[0] = 0;
    vector<int> h(n);
    for(int i = 0; i < n; i++)
        cin>> h[i];
    for(int i = 1; i < n; i++)
        for(int j = max(0, i - k); j  < i; j++)
            dp[i] = min(dp[i], abs(h[j] - h[i]) + dp[j]);

    print(dp[n-1]);

    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
} 

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;

int main()
{
    int N;
    cin >> N;
    vll A(N + 1),X(N+1);
    ll sum = 0,sum2=0;
    rep(i, N)
    {
        cin >> A[i + 1];
        sum += A[i + 1];
        if((i+1)%2==0)
        {
            sum2 += A[i + 1];
        }
    }
    X[1] = sum - 2*sum2;
    cout << X[1] << " ";
    rep2(i,1, N)
    {
        X[i + 1] = 2 * A[i] - X[i];
        cout << X[i + 1] << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 2944
import sys
input=sys.stdin.readline
n=int(input())
G=[[] for i in range(n)]
for i in range(n-1):
    a,b=map(int,input().split())
    G[a-1].append((b-1,i))
    G[b-1].append((a-1,i))
check=[False]*n
p=0
stack=[(0,0)]
ans=[0]*(n-1)
while len(stack)>0:
    now=stack.pop()
    x=now[0]
    y=now[1]
    check[x]=True
    if len(G[x])>p:
        p=len(G[x])
    j=1
    for i in G[x]:
        if check[i[0]]:
            continue
        if j==y:
            j+=1
        ans[i[1]]=j
        stack.append((i[0],j))
        j+=1
print(p)
for i in ans:
    print(i)

Measured memory_bytes: 68384
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;

int main(){
	int n;
	int a[100][100];
	bool r[100][100],c[100][100];
	
	while(cin >> n && n){
		for(int i=0;i<n;i++)
			for(int j=0;j<n;j++){
				cin >> a[i][j];
				r[i][j] = c[i][j] = false;
			}
		
		for(int i=0;i<n;i++){
			int m = -1;
			for(int j=0;j<n;j++)
				if(m<0 || m>a[i][j])m = a[i][j];
			for(int j=0;j<n;j++)
				if(a[i][j] == m)r[i][j] = true;
				
			m = -1;
			for(int j=0;j<n;j++)
				if(m<0 || m<a[j][i])m = a[j][i];
			for(int j=0;j<n;j++)
				if(a[j][i] == m)c[j][i] = true;
		}
		int res = 1<<30;
		for(int i=0;i<n;i++)
			for(int j=0;j<n;j++)
				if(r[i][j] && c[i][j])res = min(res,a[i][j]);

		cout << ( (res==1<<30)?0:res ) << endl;
	}
}

Measured memory_bytes: 0
import math

def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True

x=int(input())

for i in range(x,(10**5+10)):
    if is_prime(i)==True:
        print(i)
        break
    else:
        continue

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
typedef vector<int> vi;

int main() {
  int N;
  cin >> N;
  vi v(N);
  rep(i,N) {
    cin >> v[i];
  }
  sort(v.begin(), v.end());
  double ans = v[0];
  rep(i,N) {
    ans = (ans + v[i])/2;
  }
  cout << ans << endl;

  return 0;
}

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

int main(void){
    int N, x;
    int a, p;
    ll ans = 0;
    cin >> N >> x;
    cin >> p;
    for(int i = 1; i < N; i++){
        cin >> a;
        if(p+a > x){
            ans += (p+a) - x;
            a -= min(a, (p+a) - x);
        }
        p = a;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	void run() {
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		
		int cnt = 1;
		if (b != a) {
			cnt++;
		}
		if (c != a && c != b) {
			cnt++;
		}
		System.out.println(cnt);
	}

	public static void main(String[] args) {
		new Main().run();
	}
}


Measured memory_bytes: 8916
// #include <cstdio>
// #include <iostream>
// #include <vector>
// #include <map>
// #include <algorithm>
// using namespace std;
// typedef long long ll;
// typedef pair<ll, int> P;
// map<string, int> hash;
// int key;
// int findkey(string str) {
//   if (hash.find(str) != hash.end()) return hash[str];
//   return hash[str]=key;
// }

// int n, m, k;
// P p[100];
// ll dp[100];
// vector<int> rec[100];
// string ins;

// ll dfs(int ks) {
//   if (rec[ks].size()==0) return dp[ks];
//   ll sum = 0;
//   for (int i=0; i<rec[ks].size(); i++) {
//     sum += dfs(rec[ks][i]);
//   }
//   if (sum < dp[ks]) dp[ks] = sum;
//   return dp[ks];
// }

// int main() {
//   while (scanf("%d",&n)) {
//     if (!n) break;
//     key=0;
//     for (int i=0; i<n; i++) {
//       cin>>ins>>p[i].first;
//       dp[i]=p[i].first;
//       p[i].second=findkey(ins);
//       key++;
//     }
//     scanf("%d",&m);
//     for (int i=0; i<m; i++) {
//       cin>>ins>>k;
//       int o = findkey(ins);
//       for (int j=0; j<k; j++) {
//         cin>>ins;
//         rec[o].push_back(findkey(ins));
//       }
//     }
//     cin>>ins;
//     int need = findkey(ins);
//     // sort(p, p+n);
//     ll ans = dfs(need);
//     printf("%lld\n",ans);
//   }
// }
#include <cstdio>
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;
map<string, int> it;
map<string, vector<string> > rec;
int n, m, p, k;
string str;
int dfs(string s) {
  if (rec[s].size()==0) return it[s];
  int sum = 0;
  for (int i=0; i<rec[s].size(); i++) {
    sum+=dfs(rec[s][i]);
  }
  return it[s]=min(it[s], sum);
}
int main() {
  while (scanf("%d",&n)) {
    if (!n) break;
    it.clear(); rec.clear();
    for (int i=0; i<n; i++) {
      cin>>str>>p;
      it[str] = p;
    }
    scanf("%d",&m);
    for (int i=0; i<m; i++) {
      cin>>str>>k;
      string need = str;
      for (int j=0; j<k; j++) {
        cin>>str;
        rec[need].push_back(str);
      }
    }
    cin>>str;
    cout<<dfs(str)<<endl;
  }
}

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

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


Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
typedef long long int ll;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
// clang-format on

template<typename T>
void chmax(T &a, T b) {
    a = max(a, b);
}

#include <functional>

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    string s, t;
    cin >> s >> t;
    auto dp = make_v(n + 1, m + 1, 2, -1);

    function<int(int, int, int)> rec = [&](int i, int j, int k) {
        if (dp[i][j][k] != -1) return dp[i][j][k];
        int ans = 0;
        if (k == 0) {
            if (s[i] == 'I') {
                chmax(ans, rec(i + 1, j, !k) + 1);
            }
            if (t[j] == 'I') {
                chmax(ans, rec(i, j + 1, !k) + 1);
            }
        } else {
            if (s[i] == 'O') {
                int res = rec(i + 1, j, !k);
                if (res > 0) {
                    chmax(ans, res + 1);
                }
            }
            if (t[j] == 'O') {
                int res = rec(i, j + 1, !k);
                if (res > 0) {
                    chmax(ans, res + 1);
                }
            }
        }
        return dp[i][j][k] = ans;
    };

    int ans = 0;
    REP(i, 0, n) {
        REP(j, 0, m) {
            chmax(ans, rec(i, j, 0));
        }
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 222444
N = list(map(int,input().split()))
p = []
for i in range(N[0]):
  p.append(int(input()))
max = 0
sum = 0
for i in range(N[0]):
    sum += p[i]
    a = p[i]
    if max < a :
        max = a
print(int(sum-(int(max/2))))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  int count = 0;
  for(int i = 357; i <= N; i+=2){
    if(((i / 100) % 2) == 0) i += 100;
    int a[3] = {0};
    int temp = i;
    bool ok = true;
    while(temp >= 1){
      if(temp % 10 == 7){
        a[0]++;
      }else if(temp % 10 == 5){
        a[1]++;
      }else if(temp % 10 == 3){
        a[2]++;
      }else{
        ok = false;
        break;
      }
      temp = temp / 10;
    }
    
    if(ok && a[0] * a[1] * a[2] != 0){
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<set>
#include <bitset>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include <cstdio>
#include<algorithm>
#include <sstream>
#include<string>
#include<string.h>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
#include <limits>
#include <numeric>
#include <type_traits>
#define int long long
#define ll long long
#define mod  1000000007
#define inf 1e17
#define rep(i,j,n) for(int i=j;i<n;i++)
#define P pair<int,int>
double pi = 3.141592653589793;
using namespace std;
//ここから始めよう
int dp[55][500][500];//iまででaをjg,bをkg生成するコスト
signed main(){
    int n,ma,mb;cin>>n>>ma>>mb;
    int a[55],b[55],c[55];
    rep(i,1,n+1)cin>>a[i]>>b[i]>>c[i];
    rep(i,0,n+1){
        rep(j,0,500){
            rep(k,0,500){
                dp[i][j][k]=inf;
            }
        }
    }
    dp[0][0][0]=0;
    rep(i,1,n+1){
        rep(j,0,500){
            rep(k,0,500){
                if(j<a[i]||k<b[i])dp[i][j][k]=dp[i-1][j][k];
                else dp[i][j][k]=min(dp[i-1][j][k],dp[i-1][j-a[i]][k-b[i]]+c[i]);
                //if(dp[i][j][k]!=inf)cout<<dp[i][j][k]<<" ";
            }
        }
    }
    int ans=inf;
    for(int i=ma;i<450;i+=ma){
        int j=(i/ma)*mb;
        //cout<<i<<" "<<j<<" "<<dp[n][i][j]<<endl;
        if(dp[n][i][j]==0)continue;
        ans=min(ans,dp[n][i][j]);
    }
    if(ans==inf)cout<<-1<<endl;
    else cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 82176
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  ll x,k,d;
  cin >> x >> k >> d;
  x=abs(x);
  if(x/d<=k) {
    if((x+d-1)/d<=k) {
      if(x/d%2==k%2) {
        cout << x%d << endl;
      }
      else {
        cout << abs(x%d-d) << endl;
      }
    }
    else cout << x%d << endl;
  }
  else {
    cout << x-d*k << endl;
  }
}

Measured memory_bytes: 3616
const main = input => input.split('\n').slice(1).filter(x => x)
    .map(line => line.split('').map(x => x === '#' ? 1 : 0))
    .find((vs, i, matrix) => vs
        .find((v, j) => v &&
            [[i - 1, j], [i + 1, j], [i, j - 1], [i, j + 1]]
                .map(t => (matrix[t[0]] && matrix[t[0]][t[1]]))
                .filter(x => x)
                .length === 0
        ) !== undefined
    ) ? 'No' : 'Yes';

console.log(main(require('fs').readFileSync('/dev/stdin', 'utf8')));


Measured memory_bytes: 9348
from collections import Counter
from collections import deque
from functools import reduce
from pprint import pprint
import bisect
import copy
import fractions
import itertools
import math
import queue
import random
import sys
import time
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def MI(): return map(int, sys.stdin.readline().split())
def II(): return int(sys.stdin.readline())
def IS(): return input()
def C(x): return Counter(x)
def GCD_LIST(numbers): return reduce(fractions.gcd, numbers)
def LCM_LIST(numbers): return reduce(LCM, numbers)
def LCM(m, n): return (m * n // fractions.gcd(m, n))


n = II()
a = LI()
evencnt = 0
oddcnt = 0
for num in a:
    if num % 2 == 0:
        evencnt += 1
    else:
        oddcnt += 1
print((3 ** n) - (2 ** evencnt))


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

int main()
{
  int n;
  cin >> n;
  vector<int> p(n), s(n);
  for (int i = 0; i < n; i++)
  {
    cin >> p[i];
    s[i] = p[i];
  }
  
  sort(s.begin(), s.end());
  
  int cnt = 0;
  for (int i = 0; i < n; i++)
  {
    if (s[i] != p[i])
    {
      cnt++;
    }
  }
  if (cnt <= 2)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}

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

int main()
{
    long long x,c=0;
    cin>>x;
    while(x!=0)
    {
        if(x>=500)
        {
            c+=1000;
            x-=500;
        }
        else if(x>=100)
        {
            c+=100;
            x-=100;
        }
        else if(x>=50)
        {
            c+=50;
            x-=50;
        }
        else if(x>=10)
        {
            c+=10;
            x-=10;
        }
        else if(x>=5)
        {
            c+=5;
            x-=5;
        }else{
        x=0;
        }
    }
    cout<<c;
    return 0;
}


Measured memory_bytes: 256
import math

n = int(input())
hL = list(map(int, input().split(" ")))

cnt = 0
_max = 0
for i in range(len(hL) - 1):
    if hL[i] >= hL[i + 1]:
        cnt += 1
    else:
        _max = max(cnt, _max)
        cnt = 0

print(max(cnt, _max))

Measured memory_bytes: 15020
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<numeric>
#include<string>
#include<vector>
using namespace std;
int main(){
    int N,M,C;
    cin>>N>>M>>C;
    vector<int>B(M,0);
    for(int i=0;i<M;i++){
        cin>>B[i];
    }
    //N*Mの配列を作成
    //Aはvector<int>(M)で初期化
    //これをvector<int>(M)で初期化
    vector<vector<int>>A(N,vector<int>(M));
    for(int i=0;i<N;i++){
        for (int j=0;j<M;j++){
            cin>>A[i][j];
        }
    }
    int ans=0;
    for(int i=0;i<N;i++){
        int sum=0;
        for(int j=0;j<M;j++){
            sum+=A[i][j]*B[j];
        }
        sum+=C;
        if(0<sum)ans++;
    }
    cout<<ans<<endl;
    return 0;
}

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


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String input = br.readLine();
		
		String output = input.substring(0, input.length() - 8);
		System.out.println(output);
	}

}


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

long long n;

int main() {
	cin>>n;
	long long a[n+1], b[n+1];
	memset(b, 0, sizeof(b));
	for (int i=1; i<=n; i++) {
		cin>>a[i];
		b[a[i]]++;
	}
	long long total=0;
	for (int i=1; i<=n; i++) {
		if (b[i]>1) {
			total+=(b[i]*b[i]-b[i])/2;
		}
	}
	for (int i=1; i<=n; i++) {
		cout<<total-b[a[i]]+1<<endl;
	}
}



Measured memory_bytes: 5760
/*
*          Name : chaitanya
*
*     Institute : ANITS,Visakhapatnam
*
*/
#include<cstdio>
#include<iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include<cstring>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>
#define infy  1000000000
#define all(x) begin(x),end(x)
#define ll long long int
#define ff first
#define ss second
#define pb push_back
const ll mod = 1000000007;
#pragma GCC optimization ("O3")
const int N = 1000010;
using namespace std;
int main()
{
 
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
  //ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  ll a,b,k;
  cin >> a >> b >> k;
  if (a >= k)
  {
    a = a-k;
  }
  else
  {
    b = max(0LL,b-(k-a));
    a = 0;
  }
  cout << a << " " << b;
  return 0;
} 


Measured memory_bytes: 256
s = input()
n = len(s)
if n%2 == 0:
    s1 = '10'*(n//2)
else:
    s1 = '10'*(n//2) +'1'

s1cnt = 0

for i in range(n):
        if s1[i] == s[i]:
            s1cnt +=1
s2cnt = n - s1cnt
print(min(s1cnt,s2cnt))

Measured memory_bytes: 3188
#include<stdio.h>

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

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

    if(a>b){
        x=a;
        a=b;
        b=x;
    }
    if(b>c){
        x=b;
        b=c;
        c=x;
    }
    if(a>b){
        x=a;
        a=b;
        b=x;
    }

    printf("%d %d %d\n",a,b,c);
    
    return 0;
}


Measured memory_bytes: 2044
N,x=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
for i in range(N):
  x-=a[i]
  if x==0:
    print(i+1)
    break
  elif x<0:
    print(i)
    break
  elif i==N-1and x>0:
    print(N-1)
    break


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <map>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
#define all(a) a.begin(),a.end()
#define P pair<int,int>

//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

const int maxn=100000;

int main(){
    int a,b;
    cin >> a>>b;
    if(a<b)cout << 0<<endl;
    else cout << 10<<endl;
    
    
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int i,j,v,V,k,u;

  scanf("%d",&V);
  int a[V+1][V+1];
  for(i=1;i<=V;i++){
     for(j=1;j<=V;j++){
       a[i][j]=0;
     }
  }
  for(i=1;i<=V;i++){
    scanf("%d%d",&u,&k);
    if(k!=0){
      for(j=1;j<=k;j++){
	scanf("%d",&v);
	a[i][v]=1;
      }
    }
  }
  for(i=1;i<=V;i++){
    for(j=1;j<=V;j++){
      if(j!=V){
      printf("%d ",a[i][j]);
      }
      else  printf("%d",a[i][j]);
    }
    printf("\n");
  }
  
  return 0;
}



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

using namespace std;

int main() {
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        int l, r;
        cin >> l >> r;
        ans += r - l + 1;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256