akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cmath>
#include <climits>
#include <algorithm>
using namespace std;
typedef long long ll;
struct elem {
    ll x, y;
};
int w, h, n;
elem e[100000];
ll x[100000], y[100000];
ll px[3], py[3];
int main() {
    scanf("%d%d%d",&w,&h,&n);
    for (int i=0; i<n; i++) {
        scanf("%lld%lld",&x[i],&y[i]);
        e[i]=(elem){x[i],y[i]};
    }
    sort(x, x+n);
    sort(y, y+n);
    px[0]=x[(n-1)/2];
    px[1]=x[(n+1)/2];
    py[0]=y[(n-1)/2];
    py[1]=y[(n+1)/2];
    ll res=LLONG_MAX, rx=0, ry=0;
    for (int i=0; i<2; i++) {
        for (int j=0; j<2; j++) {
            ll calc=0, m=0;
            for (int k=0; k<n; k++) {
                ll temp=(abs(px[i]-e[k].x)+abs(py[j]-e[k].y));
                m=max(m, temp);
                calc+=temp;
            }
            if (res>calc*2-m) {
                res=calc*2-m;
                rx=px[i]; ry=py[j];
            }
        }
    }
    printf("%lld\n%lld %lld\n",res,rx,ry);
}

Measured memory_bytes: 3852
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
	int a, b, c, d, e;
	string s;
	cin >> s;
	cout << s[0] << s.size() - 2 << s[s.size() - 1] << "\n";
	cin >> e;
}

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

int seq[1000];
int n,k;
bool flag[1000];
int c[1000][1000];


bool check(int a){
  int sum = 0;
  for(int i=0;i<n/2;i++)sum += seq[c[a][i]-1];
  return (sum>=n/8)&&(sum<=3*n/8);
}

int main(){
  while(scanf(" %d %d ",&n,&k)!=EOF){

    for(int i=0;i<k;i++){
      for(int j=0;j<n/2;j++){
	scanf(" %d ",&c[i][j]);
      }
    }
    
    for(int i=0;i<n/2;i++)seq[i] = 1;
    for(int i=n/2;i<n;i++)seq[i] = 0;

    while(1){
      bool f = true;
      for(int i=0;i<k;i++)f &= check(i);
      if(f)break;
      random_shuffle(seq,seq+n);
    }

    for(int i=0;i<n;i++)printf("%d",seq[i]);
    printf("\n");
  }
}
	

Measured memory_bytes: 2732
import java.util.*;
public class Main {
	public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      String s = sc.next();
      int ans = 0;
      int zero = 0;
      int one = 0;
      for(int i=0;i<s.length();i++){if(s.charAt(i)=='0'){zero++;}
                                   else{one++;}
                                   }
      ans=Math.min(zero,one)*2;
	  System.out.println(ans);
  }
}


Measured memory_bytes: 25708
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
int GCD(int a,int b){return b?GCD(b,a%b):a;}
int LCM(int a,int b){return (a*b)/GCD(a,b);}
int abs(int x){return x>0?x:-x;}
 
//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

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


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

int main() {
    int N;
    long long K;
    cin >> N >> K;
    vector<long long> A(N);
    for(int i=0; i<N; ++i) cin >> A[i];

    long long res = 0;
    for(int d=60; d >= -1; --d) {
        if(d != -1 && !(K & (1LL << d))) continue;

        long long tmp = 0;
        for(int e = 60; e >= 0; --e) {
            long long mask = 1LL << e;
            int cnt = 0;
            for(int i=0; i<N; ++i) if(A[i] & mask) ++cnt;
            
            if(e > d) {
                if(K & mask) tmp += mask * (N - cnt);
                else tmp += mask * cnt;
            } else if(e == d) {
                tmp += mask * cnt;
            } else {
                tmp += mask * max(cnt, N - cnt);
            }
        }
        res = max(res, tmp);
    }
    cout << res << endl;
}

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

#define endl '\n'

using namespace std;

int main(){

  cin.tie(0);     // cout と cin の同期を切る
  ios::sync_with_stdio(false);  /* cの stdioストリーム (printfとか)と*/

  int N,A,B;

  cin>>N>>A>>B;

  cout<<min(A,B)<<" ";

  if(A+B<=N){
    cout<<0<<endl;
  }else{
    cout<<A+B-N<<endl;
  }

  return 0;

}


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

int main(){
  	int n,memo = 0;
  	cin >> n;
  
  	int a[n];
  
  	rep(i,0,n){
      cin >> a[i];
    }
  
  	rep(i,0,n){
      if(i == a[a[i]-1]-1){
        memo++;
      }
    }
  
  	cout << memo / 2 << endl;
 	return 0; 
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cmath>
#include <numeric>
#include <utility>
#include <iomanip>

using namespace std;
using int64 = long long;

struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;

int main() {
    string s;
    cin >> s;
    cout << s.substr(0, 3) << endl;
}


Measured memory_bytes: 3124
#include<iostream>
using namespace std;
int main(){
    int a,b,c;
    cin >>a >>b >>c;
    int i=0;

    
    for (int x=a; x<=b ;x++){
        if (c % x == 0){
            i = i+1;
        }
    }
    cout<<i<<endl;
    return 0;
    
}


Measured memory_bytes: 3112
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
typedef long long int l;
using namespace std;


int main(){
   string str;
   cin>>str;
   if(str=="Sunny")
   cout<<"Cloudy";
   if(str=="Cloudy")
   cout<<"Rainy";
   if(str=="Rainy")
   cout<<"Sunny";
    return 0;
}

Measured memory_bytes: 256
a,b,m = map(int,input().split())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
ans = min(a) + min(b)
for i in range(m):
    x,y,c = map(int,input().split())
    ans = min(ans, a[x-1] + b[y-1] - c)
print(ans)

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

int main(){
  string S,T;
  cin >> S >> T;
  vector<vector<int>> v(26);
  int s=S.size();
  for (int i=0;i<s;i++){
    v[S[i]-'a'].push_back(i);
    v[S[i]-'a'].push_back(i+s);
  }
  for (int i=0;i<26;i++){
    if (v[i].size()>3){
      sort(v[i].begin(),v[i].end());
    }
  }
  long long ans=0,now=-1;
  for (int i=0;i<T.size();i++){
    auto itr=upper_bound(v[T[i]-'a'].begin(),v[T[i]-'a'].end(),now);
    if (itr==v[T[i]-'a'].end()){
      ans=-1;
      break;
    }
    else {
      ans+=*itr-now;
      now=*itr%s;
    }
  }
  cout << ans << endl;
}

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


int main() {
    int N, X;
    cin >> N >> X;
    int cnt=0, sum=0, m=0;
    for (int i = 0; i < N; ++i) {
        int a;
        cin >> a;
        sum += a;
        if (m == 0) {
            m = a;
        } else {
            m = min(m, a);
        }
    }
    cnt = N;
    cnt += (X - sum) / m;
    cout << cnt << endl;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
x = [0 for _ in range(n)]
for i in range(1, n + 1):
    tmp = 1
    m = i
    while (m < k):
        tmp /= 2
        m *= 2
    x[i - 1] = tmp
print(sum(x) / n)


Measured memory_bytes: 3864
import java.util.Scanner;

//Plastic Board
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int c1 = 0;
		int c2 = 0;
		while(sc.hasNext()){
			String[] s = sc.next().split(",");
			int a = Integer.parseInt(s[0]);
			int b = Integer.parseInt(s[1]);
			int c = Integer.parseInt(s[2]);
			c1 += c*c==a*a+b*b?1:0;
			c2 += a==b?1:0;
		}
		System.out.println(c1+"\n"+c2);
	}
}

Measured memory_bytes: 12000
#!/usr/bin/env python3
import sys


def solve(A: int, B: int, K: int):
    s = set()
    for i in range(A, min(A + K, B + 1)):
        s.add(i)
    for i in range(max(B - K + 1, A + K - 1), B + 1):
        s.add(i)
    ret = sorted(list(s))
    for n in ret:
        print(n)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(A, B, K)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in  = new Scanner(System.in);
        int a = in.nextInt();
        int b = in.nextInt();
        int area = area(a, b);
        int perimeter = perimeter(a, b);
        System.out.println(area + " " + perimeter);
    }

    private static int area(int a, int b) {
        return a * b;
    }

    private static int perimeter(int a, int b) {
        return (2 * a) + (2 * b);
    }
}


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

using namespace std;

//#define MD 100010

long long int dfs(int i,int j,int k,string s,long long int sum){//初期値i=1,j=0
    if(s.length()==1){
        return s[0]-'0';
    }else if(i==s.length()){
        return 0;
    }else if(k==1){//分割
        sum+=stoll(s.substr(j,i-j));
        if(i==s.length()-1){
            sum+=(s[i]-'0');
        }
        i++;j=i-1;
        return (sum+dfs(i,j,0,s,sum)+dfs(i,j,1,s,sum));
    }else if(k==0){//非分割
        if(i==s.length()-1){
           long long int tmp=stoll(s.substr(j,i-j+1));
            i++;
            return (tmp+dfs(i,j,0,s,sum)+dfs(i,j,1,s,sum));
        }else{
            i++;
            return (dfs(i,j,0,s,sum)+dfs(i,j,1,s,sum));
        }
    }
}

int main(){
    string s;
    cin>>s;
    long long int ans=0;
    if(s.length()!=1){
         ans=dfs(1,0,1,s,0)+dfs(1,0,0,s,0);
    }else{
         ans=dfs(1,0,1,s,0);
    }
    cout<<ans<<endl;
    
   return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define mod 1000000007
#define MAX 1000000000000000
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revrep(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define ii pair<ll,ll>
#define MP make_pair
#define pb push_back
#define f first
#define se second
#define ll int
#define vi vector<ll>
ll modexp(ll a,ll b){ ll res = 1; while(b > 0){  if(b & 1) res = (res * a)%mod;  a = (a * a)%mod;  b/=2;  }  return res; }
#define rs resize
typedef tree< ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update > OST;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

const ll N = 353;
ll i,n;
int main()
{
    std::ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin>>n;
    cout<<"Christmas ";
    rep(i,0,25 - n) cout<<"Eve ";
    return 0;
}

Measured memory_bytes: 256
import sys,math
input = sys.stdin.readline
a,b,x = list(map(int,input().split()))
if b*a**2 >= x*2:
    print(90-math.degrees(math.atan(2*x/(a*b**2))))
else:   
    print(math.degrees(math.atan(2*(a**2*b-x)/a**3)))


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

#define gcd(a,b)     __gcd(a,b)
#define lcm(a,b)     (a*(b/gcd(a,b)))

#define pb   push_back
#define endl "\n"

#define ll  long long
#define ull unsigned long long

#define W(t)            while(t--)
#define rep(i,n)      for(i = 0; i < n; i++)
#define repit(it,type)  for(auto it = type.begin(); it != type.end(); it++)
#define IOS ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
using namespace std;

int main()
{
    IOS
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ll n,d,i,x;
    cin>>n>>d;

    ll a,b,cnt=0;

    rep(i,n)
    {
    	cin>>a>>b;
    	if(ceil(sqrt(a*a+b*b)) <= d)
    		cnt++;
    }
    cout<<cnt;

     return 0;
}

Measured memory_bytes: 3696
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " is " << x << endl

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

const int INF = 1e9 + 7;

signed main()
{
	IO_OP;
	
	ll n, d;
	cin >> n >> d;
	int cnt = 0;
	for(int i = 0; i < n; i++) {
		ll x, y;
		cin >> x >> y;
		if(x*x+y*y <= d*d) cnt++;
	}
	cout << cnt << endl;

}





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

typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define ALL(obj) (obj).begin(), (obj).end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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


int main() {
    cout<<fixed<<setprecision(10);

    ll n,m; cin>>n>>m;
    vint x(n); rep(i,n) cin>>x[i];
    map<ll,ll> tmp;
    rep(i,n){
        tmp[x[i]]++;
    }

    map<ll,ll> num, num_pair;

    for(auto p:tmp){
        num[p.first%m] += p.second;
        num_pair[p.first%m] += p.second/2;
    }

    // rep(i,m) cout<<num[i]<<" ";
    // puts("");

    ll ans = 0;

    // 0
    num_pair[0] = num[0]/2;
    if(m%2==0) num_pair[m/2] = num[m/2]/2;


    rep(i,m){
        if(i == ( m-i )%m) continue;
        // cout<<i<<": ";
        ll tmp = min(num[i], num[m-i]);
        ans += tmp;
        num_pair[i] -= max(0ll, (1 + tmp - (num[i] - 2*num_pair[i]))/2);
        num_pair[m-i] -= max(0ll, (1 + tmp - (num[m-i] - 2*num_pair[m-i]))/2);
        num[i] -= tmp;
        num[m-i] -= tmp;
        // cout<<ans<<endl;
    }

// puts("");
//     rep(i,m) cout<<num[i]<<" ";
// puts("");
//     rep(i,m) cout<<num_pair[i]<<" ";
// puts("");

    rep(i,m){
        // if(i==0 || (i == m-i)) continue;
        // cout<<num_pair[i]<<endl;
        ans += max(0ll, num_pair[i]);
        // cout<<ans<<endl;
    }

    cout<<ans<<endl;

    return 0;

}

Measured memory_bytes: 19840
#include <iostream>
#include <vector>
using namespace std;
const int INF = (1e9);

int main(){
  int N;
  cin >> N;
  vector<int> H(N), dp(N,INF);
  for(int i = 0; i < N; ++i) cin >> H[i];
  dp[0] = 0;
  for(int i = 1; i < N; ++i){
    dp[i] = dp[i-1]+abs(H[i]-H[i-1]);
    if(i > 1) dp[i] = min(dp[i],dp[i-2]+abs(H[i]-H[i-2]));
  }
  cout << dp[N-1] << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
template<class T, class U> inline bool chmin(T& a, U b){T bb = b;if(a>bb){a = bb;return 1;}return 0;}
template<class T, class U> inline bool chmax(T& a, U b){T bb = b;if(a<bb){a = bb;return 1;}return 0;}
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define int long long
#define double long double
#define PI 3.141592653589793
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1e16;
const double EPS = 1e-10;
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

vector<int> divisor(int n){
  vector<int> ret;
  for(int i = 1;i*i <= n;i++){
    if(n%i == 0){
      ret.push_back(i);
      if(i*i != n)ret.push_back(n/i);
    }
  }
  sort(ret.begin(), ret.end());
  return ret;
}

/*
void dijkstra(){
  priority_queue<pair<int,int>, vector<pair<int,int>>, greater<pair<int,int>>> pq;pq.push(make_pair(0,0));
  rep(i,110000)d[i] = INF;d[0] = 0;
  while(!pq.empty()){
    pair<int,int> from = pq.top();pq.pop();
    int fromV = from.second, fromC = from.first;
    if(d[fromV] < fromC)continue;
    rep(i,g[fromV].size()){
      int to = g[fromV][i];
      if(d[to] <= fromC+costs[to])continue;
      d[to] = fromC+costs[to];
      pq.push(make_pair(d[to], to));
    }
    //cout << fromV << " " << fromC << endl;
  }
}*/

const int MAX = 1000000;

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

// テーブルを作る前処理
void COMinit() {
    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] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int n,t,a[3100],b[3100],dp[3100][3100], pre[3100][3100];bool used[3100];//i番目までの料理でT分目までに食べ始められる最大値
signed main(){
  cin>>n>>t;rep(i,n)cin>>a[i+1]>>b[i+1];
  repd(i,1,n+1){
    repd(j,1,t+1){
      dp[i][j] = dp[i-1][j];
      pre[i][j] = j;
      if(j >= a[i] && dp[i][j] < dp[i-1][j-a[i]]+b[i]){
        dp[i][j] = dp[i-1][j-a[i]]+b[i];
        pre[i][j] = j-a[i];
      }
    }
  }
  int ans = 0;
  int c = t-1;
  for(int i = n; i > 0; --i){
    if(pre[i][c] == c - a[i]){
      used[i] = true;
    }
    c = pre[i][c];
  }
  repd(i,1,n+1){
    if(used[i])continue;
    chmax(ans, b[i]);
  }
  //cout << used[0] << " " << used[1] << " " << used[2] << " " << used[3] << endl;
  cout << max(dp[n][t], dp[n][t-1]+ans) << endl;;
}



Measured memory_bytes: 151808
#include <iostream>
#include <vector>
#include <utility>
#include <cmath>
#include <algorithm>
#include <string>
using namespace std;
typedef long long ll;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

int main() {
	int a, b;
	string op;
	do {
		cin >> a >> op >> b;
		if (op == "+") {
			cout << (a + b) << endl;
		}
		else if (op == "-") {
			cout << (a - b) << endl;
		}
		else if (op == "*") {
			cout << (a * b) << endl;
		}
		else if (op == "/") {
			cout << (a / b) << endl;
		}
	} while (op != "?");
}


Measured memory_bytes: 3140
//Dragon_warrior7(IITK)
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define pb push_back
#define nl cout << '\n'
#define sor(x) sort(x.begin(), x.end())
#define rev(v) reverse(v.begin(), v.end())
#define lb(v, temp) lower_bound(v.begin(), v.end(), temp)
#define ub(v, temp) upper_bound(v.begin(), v.end(), temp)
#define fi first
#define se second
#define llmax 1000000000000000000
#define pll pair<ll, ll> 
#define vll vector<ll> 
#define rub cout << "\n------------------------------------\n"
#define deb(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) 
{
	cout << *it << " = " << a;
	nl;
	err(++it, args...);
}
typedef  tree < int ,  null_type ,  greater<int> ,  rb_tree_tag ,  tree_order_statistics_node_update > oset;
void read(vector<ll> &v)
{
	for (int i = 0; i < v.size(); i++)
		cin >> v[i];
}
const int mod=1e9+7;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modInverse(ll a){return power(a,mod-2);}
ll binpow(ll a, ll b, ll m) 
{a %= m;b%=(m-1);ll res = 1;while (b > 0) {if (b & 1)res = res * a % m;a = a * a % m;b >>= 1; }return res;}
void print(vector<ll> v)
{
	for (int i = 0; i < v.size(); i++)
		cout << v[i] << " ";
}
ll n,m,a,b,c,temp,x,y;
string str;
void solveforthiscase(const int & test)
{//deb(test);
cin>>n>>b;
if(n>=10)
{
    cout<<b;
    return ;
}
else
{
    cout<<b+100*(10-n);
}






return ;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int test=1;
// 	cin>>test;
    for(int i=1;i<=test;i++)
    {
        solveforthiscase(i);
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define REP(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
const ll MOD = 1000000007;
using namespace std;

int main(){
    int n, m; cin >> n >> m;
    vector<int> a(n);
    vector<pair<int, int>> x(m);
    REP(i, n) cin >> a[i];
    REP(i, m){
        int b, c; cin >> b >> c;
        x[i] = make_pair(c, b);
    }
    sort(x.rbegin(), x.rend()); //降順にするために逆イテレータ
    int cnt = n;
    for(auto c: x){
        while(cnt && c.second){
            a.push_back(c.first);
            --cnt; --c.second;
        }
    }
    sort(a.begin(), a.end(), greater<int>());
    ll ans = 0;
    REP(i, n) ans += a[i];
    cout << ans << endl;
    return 0;
}


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

int main() {
  int h, w;
  cin >> h >> w;
  int g[10][10];
  for (int i = 0; i < 10; ++i) {
    for (int j = 0; j < 10; ++j)
      cin >> g[i][j];
  }
  for (int k = 0; k < 10; ++k) {
    for (int u = 0; u < 10; ++u) {
      for (int v = 0; v < 10; ++v)
        g[u][v] = min(g[u][v], g[u][k] + g[k][v]);
    }
  }
  int64_t ans = 0;
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      int x;
      cin >> x;
      if (x >= 0)
        ans += g[x][1];
    }
  }
  cout << ans << '\n';
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <fstream> //ofstream
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
int h,a,ct=0;

void solve(){
        while(h>0) {
                h-=a;
                ct++;
        }
        cout<<ct<<endl;
}

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

        solve();
        return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
 
using namespace std;
using ll = long long;

auto main() -> int
{
	int a, b; cin >> a >> b;
    cout << (a * b);
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
int gcd(int a, int b) 
{ 
	if (a == 0) 
		return b; 
	return gcd(b % a, a); 
} 
int invertBits(int num) 
{  
    int x = log2(num) + 1; 
    for (int i = 0; i < x; i++)  
       num = (num ^ (1 << i));  
   
    return num; 
} 
///////////////////////////////////////////////////////////////////////////////////////////////////////////
int a[100001];
int k;
int solve(int *h,int curr,int prev,int n)
{
	//cout<<"a"<<endl;
	if(curr==n-1)
	{
		a[curr]=0;
		return abs(h[curr]-h[prev]);
	}
	if(a[curr]!=-1)
	{
		return abs(h[curr]-h[prev])+a[curr];
	}
	int t=abs(h[curr]-h[prev]);
	int ans=INT_MAX;
	int i;
	for(i=1;i<=min(n-curr-1,k);i++)
	{
		int temp=solve(h,curr+i,curr,n);
		ans=min(ans,temp);
	}
    a[curr]=ans;
	return t+ans;
}
int main()
{
	int n;
	cin>>n>>k;
	int h[n];
	int i;
	memset(a,-1,sizeof(a));
	for(i=0;i<n;i++)
	{
		cin>>h[i];
	}
	cout<<solve(h,0,0,n);
	return 0;
}

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

namespace ABC066A
{
	class Program
	{
		static void Main(string[] args)
		{
			int a, b, c, s;

			string[] word = Console.ReadLine().Split(' ');

			a = int.Parse(word[0]);
			b = int.Parse(word[1]);
			c = int.Parse(word[2]);

			//アルゴリズム１
			int x = a + b;
			int y = b + c;
			int z = c + a;

			// x, y, zの最小値
			s = x;
			if (y < s) s = y;
			if (z < s) s = z;
			
			
			
			
			//アルゴリズム２
			//a, b, cの最大値を求める
			//int m = a;
			//if (b > m) m = b;
			//if (c > m) m = c;

			//最大値を除く金額の和
			//s = a + b + c - m;

			Console.WriteLine(s);

			Console.ReadLine();
				
				
		}
	}
}

Measured memory_bytes: 27480
#include <fstream>
#include <iostream>
#include <functional>
#include <algorithm>
#include <sstream>
#include <cstring>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <ctime>
#include <list>
#include <set>
#include <map>
#include <bitset>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define EPS 1e-8
#define LL_INF 0x3fffffffffffffff
#define INF 0x3f3f3f3f3f3f3f3f
#define MEM(a, b) memset(a, b, sizeof(a))
#define PPER(i, n, m) for (int i = n; i >= m; i--)
#define REPP(i, n, m) for (int i = n; i <= m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)
#define PER(i, n, m) for (int i = n; i > m; i--)
#define SA(n) scanf("%d", &(n))
#define SLLA(n) scanf("%lld", &(n))
#define MP make_pair
#define FF first
#define SS second
#define PB push_back
#define DE(val) cout << #val << ": " << val << endl;

const int dx44[6] = {0, -1, -1, 1, 1};
const int dy44[6] = {0, -1, 1, -1, 1};
const int dx4[6] = {0, 1, 0,-1};
const int dy4[6] = {-1, 0, 1,0};
const int dx8[9] = {0, -1, 0, 1, 0, 1, 1, -1, -1};
const int dy8[9] = {0, 0, 1, 0, -1, 1, -1, 1, -1};
const int dx82[9] = {0, -1, -1, 1, 1, 2, 2, -2, -2};
const int dy82[9] = {0, 2, -2, 2, -2, 1, -1, 1, -1};
void update(ll& x,ll v){
    if(x==-1)x=v;
    else if(x>v)x=v;
}

ll po(ll a, ll b, ll mod)
{
    ll res = 1;
    a %= mod;
    for (; b; b >>= 1)
    {
        if (b & 1)
            res = res * a % mod;
        a = a * a % mod;
    }
    return res;
}
ll gcd(ll a, ll b)
{
    if (a == 0)
    {
        return b;
    }
    else
    {
        return gcd(b % a, a);
    }
}
void extgcd(ll a, ll b, ll &d, ll &x, ll &y)
{
    if (!b)
    {
        d = a;
        x = 1;
    }
    else
    {
        extgcd(b, a % b, d, y, x);
        y -= x * (a / b);
    }
}
ll inverse(ll a, ll n)
{
    ll d, x, y;
    extgcd(a, n, d, x, y);
    return d == 1 ? (x + n) % n : -1;
}
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
const int maxn = 6e5 + 5;
const double PI = acos(-1.0);
const ll mod = 1000000007;
/*************************************************************************/

std::set<string> v;

void dfs(string x, int n) {
    if(x.length() == n) {
        v.insert(x);
        return;
    }
    char f = 'a';
    for(int i=0;i<x.length();i++) {
        f = max(x[i], f);
    }
    f++;
    for(char d = 'a'; d <= f; d++) {
        string tmp = x;
        tmp.push_back(d);
        dfs(tmp, n);
    }
}

void solve() {
    int n;
    cin>>n;
    dfs("a", n);
    for(auto g: v) {
        cout<<g<<endl;
    }
}


int main()
{
// #ifndef ONLINE_JUDGE
//   freopen("i.txt", "r", stdin);
//   freopen("o.txt", "w", stdout);
// #endif
  solve();
  return 0;
}





Measured memory_bytes: 14208
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <fstream>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <string>
#include <cstring>
#include <cctype>
#include <numeric>
#include <cstdio>
#include <math.h>
#include <functional>
using namespace std;
struct initon
{
    initon()
    {
        cin.tie(0);
        ios::sync_with_stdio(false);
    };
};
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvi = vector<vi>;
using vs = vector<string>;
using vl = vector<ll>;
using vvl = vector<vl>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using f80 = __float80;
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for (i64 i = m; i < n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define RS(x) rsort(x.begin(),x,end()))
#define REVE(x) reverse(x.begin(), x.end())
#define all(x) (x).begin(), (x).end()
#define fst first
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#define sw swap
#define UP(x) transform(x.begin(), x.end(), x.begin(), ::toupper);
#define LOW(x) transform(x.begin(), x.end(), x.begin(), ::tolower);
#define na(a, n) rep(i, n) cin >> a[i];
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
vb d(10);
int ans(int x)
{
    while (x)
    {
        if (d[x % 10])
            return 0;
        x /= 10;
    }
    return 1;
}
//ここからメイン
int main()
{
    vi x(2);
    rep(i,2){cin >> x[i];}
        cout << (x[0]%3==0||x[1]%3==0||(x[0]+x[1])%3==0?"Possible":"Impossible");
    }

Measured memory_bytes: 256
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import dijkstra
N, X, Y = map(int, input().split())
# 距離行列の生成
dist_matrix = [[0] * (N) for _ in range(N)] 
for i in range(1, N):
    dist_matrix[i][i-1] = 1
dist_matrix[X-1][Y-1] = 1

graph = csr_matrix(dist_matrix)

dist_matrix = dijkstra(csgraph=graph, directed=False)
ans = [0] * N

for idx, row in enumerate(dist_matrix):
    for item in row[idx + 1:]:
        ans[int(item)] += 1

for k in ans[1:]:
    print(k)


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

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define fst first
#define snd second
#define ALL(obj) (obj).begin(), (obj).end()
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
//#define int long long int
const int MOD = 1000000007;
const ll LINF = (ll)1e18;
const int INF = 1e9;
const double EPS = 0.000000001;

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

bool pC(const P& pair1, const P& pair2) {
    return pair1.second > pair2.second;
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  string s;
  cin >> s;
  int x = 0;
  VI d(n+1, 0);
  d[0] = 0;
  REP(i, n){
    if(s[i] == '(') {
      x++;
      d[i+1] = d[i] + 1;
    }
    else {
      x--;
      d[i+1] = d[i] - 1;
    }
  }
  int d_min = *min_element(ALL(d));
  int insert = x - 2 * d_min;
  REP(i, n + insert){
    if(i < -d_min) cout << '(';
    else if (i >= -d_min + n) cout << ')';
    else cout << s[i + d_min];
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define qwq(x) cerr<<" #"<<#x<<" = "<<x<<endl;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
 
template<class T> inline void read(T &x){
	int f=0;x=0;char ch=getchar();
	for(;!isdigit(ch);ch=getchar())f|=(ch=='-');
	for(;isdigit(ch);ch=getchar())x=x*10+ch-'0';
	if(f)x=-x;
}

const int N=100005;
int f[N],c[N],n,m,x,y;

int main(){
	read(n),read(m);
	rep(i,1,n){
		f[i]=(i==1);
		c[i]=1;
	}
	rep(i,1,m){
		read(x),read(y);
		if(c[x]==1){
			f[y]|=f[x];
			c[y]++,c[x]--;
			f[x]=0;
		}
		else{
			f[y]|=f[x];
			c[y]++,c[x]--;
		}
	}
	int ans=0;
	rep(i,1,n)
		ans+=f[i];
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
int main(void)
{
	int i,j,w[31],a,d;
	
	for(a=0;a<=30;a++){
		w[a]=0;
	}
	for(i=0;i<28;i++){
		scanf("%d",&j);
		w[j]=1;
	}
	for(d=1;d<=30;d++){
		if(w[d]==0){
			printf("%d\n",d);
		}
	}
	return 0;
}

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

#define NMAX 100000
#define INF 2000000000

#define MOD 2019

using namespace std;

int n;
long long water[NMAX];
long long rain[NMAX];

int main()
{
    cin >> n;
    for(int i = 1; i <= n; i++)
        cin >> water[i];

    for(int i = 1; i <= n; i++)
    {
        if(i % 2 == 0)
            rain[1] -= water[i];
        else
            rain[1] += water[i];
    }

    for(int i = 2; i <= n; i++)
        rain[i] = 2 * water[i - 1] - rain[i - 1];

    for(int i = 1; i <= n; i++)
        cout << rain[i] << ' ';

    return 0;
}


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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = int_fast64_t;
using pll = pair<ll,ll>;
constexpr ll INF = 1LL<<60;
constexpr ll MOD = 1e9+7;
template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
#if loc||local
void dump(){cerr<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
void dump(){}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T,class U> ostream &operator<<(ostream& os,pair<T,U>const& p){os<<p.first<<","<<p.second;return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}

signed main(){

  int n;
  cin>>n;
  vector<ll> a(n);
  cin>>a;

  int ans = 1<<28;
  for(int x=-100;x<=100;++x){
    int tmp = 0;
    for(auto y:a){
      tmp += (x-y)*(x-y);
    }
    chmin(ans,tmp);
  }
  cout<<(ans)<<endl;

}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define rep(i,l,r)for(int i=(l);i<(r);i++)
#define min(p,q)((p)<(q)?(p):(q))
#define chmin(p,q)(p=min(p,q))

char ss[210],t[110],*s;
int dp[110][110];
int main(){
	while(scanf(" %s %s",ss,t),ss[0]!='#'){
		int a,b,c,d;
		scanf("%d%d%d%d",&a,&b,&c,&d);
		int sn=strlen(ss);
		int tn=strlen(t);
		rep(i,0,sn)ss[sn+i]=ss[i];
		int ans=2e9;
		rep(p,0,sn){
			s=ss+p;
			dp[0][0]=0;
			rep(i,0,sn+1)dp[i][0]=b*i;
			rep(j,0,tn+1)dp[0][j]=a*j;
			rep(i,1,sn+1)rep(j,1,tn+1){
				dp[i][j]=2e9;
				chmin(dp[i][j],dp[i-1][j]+b);
				chmin(dp[i][j],dp[i][j-1]+a);
				chmin(dp[i][j],dp[i-1][j-1]+(s[i-1]!=t[j-1]?c:0)+(i-1>=sn-p?d:0));
			}
			chmin(ans,dp[sn][tn]);
		}
		printf("%d\n",ans);
	}
}


Measured memory_bytes: 2060
#include <iostream>
#include <vector>

using namespace std;

int main() {
	int N, K;

	cin >> N >> K;

	vector<int> child_vec(N, 0);
	vector<int> d_vec;
	vector<vector<int>> A_vec;

	int d_temp;
	int di_temp;
	for (int i = 0; i < K; i++) {
		cin >> d_temp;

		d_vec.push_back(d_temp);

		for (int j = 0; j < d_temp; j++) {
			cin >> di_temp;

			child_vec[di_temp-1] = 1;
		}
	}

	int ans = 0;

	for (int i = 0; i < N; i++) {
		if(child_vec[i] == 0){
			ans++;
		}
	}


	cout << ans << endl;
}


Measured memory_bytes: 3632
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] nums = new int[n];
        for (int i = 0; i < n; i++) {
            nums[i] = sc.nextInt();
        }
        boolean flag = true;
        for (int i = 0; i < n; i++) {
            if (nums[i] % 2 == 0) {
                if (!(nums[i] % 3 == 0 || nums[i] % 5 == 0)) {
                    flag = false;
                    break;
                }
            }
        }
        System.out.println(flag ? "APPROVED" : "DENIED");
    }
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,k;cin>>n>>k;
    vector<ll> c(40,0),kb(40);
    rep(i,40){
        kb[40-i-1]=k%2;
        k/=2;
    }
    rep(i,n){
        ll a;cin>>a;
        rep(j,40){
            c[40-j-1]+=a%2;
            a/=2;
        }
    }
    vector<ll> dp0(41,0),dp1(41,-1);
    rep(i,40){
        if(kb[i]==0){
            dp0[i+1]=dp0[i]*2+c[i];
            if(dp1[i]!=-1)dp1[i+1]=dp1[i]*2+max(c[i],n-c[i]);
        }else{
            dp0[i+1]=dp0[i]*2+n-c[i];
            if(dp1[i]!=-1)dp1[i+1]=max(dp0[i]*2+c[i],dp1[i]*2+max(c[i],n-c[i]));
            else dp1[i+1]=dp0[i]*2+c[i];
        }
    }
    cout<<max(dp0[40],dp1[40])<<endl;
    return 0;
}

Measured memory_bytes: 256
/*****And nothing else matters!******/

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

#define pi 3.1415926535
#define endl "\n"
#define yes cout << "YES\n"
#define no cout << "NO\n"
#define ll long long
#define llu unsigned long long
#define setbits(x) __builtin_popcountll(x)
#define pb push_back
#define mp make_pair
#define sz(x) (int)x.size()
#define tc int test_case; cin >> test_case; while(test_case--)
#define f(i,a,n) for(int i = a ; i < n ; i++)
#define rf(i,n,a) for(int i = n-1 ; i >= a ; i--)
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
#define get(a,n) f(i,0,n) cin >> a[i];
#define show(a,n) f(i,0,n) cout << a[i] << " "; cout << endl;
#define sp(x) fixed << setprecision(10) << x
#define fast ios:: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define trace(x) cerr << '>' << #x << ':' << (x) << "\n"
#define trace2(x,y) cerr<< '>' << #x << ':' << (x) << " | " << #y << ':' << (y) << "\n"
#define trace3(a,b,c) cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n"
#define trace4(a,b,c,d) cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<"\n"

typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;
typedef map<int,int> mii;
typedef map<ll,ll> mll;

const int inf = 1e9;
const ll inf64 = 1e18;
const int mod = inf + 7;
const int N = 3e5 + 10;

int main()
{
    fast;
    int n;
    cin >> n;
    vl a(n);
    get(a,n);

    vl suf(n);
    suf[n-1] = a[n-1];
    rf(i,n-1,0)
        suf[i] = (suf[i+1] + a[i]) % mod;

    ll ans = 0;
    f(i,0,n-1)
    {
        ll cur = (suf[i+1] * a[i]) % mod;
        ans = (ans + cur) % mod;
    }
    cout << ans;
}


Measured memory_bytes: 6356
// F - Minimum Bounding Box
#include <bits/stdc++.h>

using namespace std;

#define	EPS	1e-9

int n;
vector<pair<long long, long long> > p, m;

double calc(double t)
{
	double minx = 1e18, miny = 1e18, maxx = -1e18, maxy = -1e18;
	for (int i = 0; i < n; i++) {
		double x = p[i].first + t * m[i].first, y = p[i].second + t * m[i].second;
		minx = min(minx, x); maxx = max(maxx, x);
		miny = min(miny, y); maxy = max(maxy, y);
	}
	return (maxx - minx) * (maxy - miny);
}

int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

	cin >> n;
	for (int i = 0; i < n; i++) {
		long long x, y;
		string s;
		cin >> x >> y >> s;
		p.resize(n), m.resize(n);
		p[i] = make_pair(x, y);
		if (s[0] == 'R')      m[i] = make_pair(1, 0);
		else if (s[0] == 'L') m[i] = make_pair(-1, 0);
		else if (s[0] == 'U') m[i] = make_pair(0, 1);
		else if (s[0] == 'D') m[i] = make_pair(0, -1);
	}

	double l = 0, r = 1e9;
	for (int k = 0; k < 200; k++) {
		double m1 = l + (r - l) / 3, m2 = r - (r - l) / 3;
		double r1 = calc(m1), r2 = calc(m2);
		if (r1 > r2) l = m1;
		else r = m2;
	}
	double ans = calc((l + r) / 2);
	cout << fixed << setprecision(15) << ans << endl;

	return 0;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define pi pair<int,int>
#define pl pair<long long,long long>
#define lg length()
#define pb push_back
ifstream in("file.in");
ofstream out("file.out");
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005

long long n,a[100005],b[100005],d;

int main() {
    cin >> n;
    for(int i=1;i<=n;i++) cin >> a[i] >> b[i];
    for(int i=n;i>=1;i--){
        a[i]+=d;
        if(a[i]%b[i]){
            d+=b[i]-a[i]%b[i];
            a[i]+=b[i]-a[i]%b[i];
        }
    }
    cout << d;
}


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

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return b/gcd(a,b)*b;}

int main() {
  set<char> st;
  rep(i, 3) {
    char c;
    cin >> c;
    st.insert(c);  
  }
  if (st.size() == 1) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        int a1 = Integer.parseInt(sc.next());
        int a2;
        for(int i = 1; i < n; i++){
            a2 = Integer.parseInt(sc.next());
            a1 = gcd(a1, a2);
        }
        
        System.out.println(a1);
    }
    
    private static int gcd(int a, int b){
        
        if(b == 0){
            return a;
        }else{
            return gcd(b, a % b);
        }
    }
}

Measured memory_bytes: 44748
#include<stdio.h>
int main(){
    long long n,i,a,b,c,d,max,s=0,s1,m,p=1;
    scanf("%lld",&n);
    if(n==1){
        printf("YES\n");
        return 0;
    }
    scanf("%lld%lld",&a,&b);
    s+=a+b;
    d=(b-a)%n;
    max=b-a;
    for(i=2;i<n;i++){
        scanf("%lld",&c);
        if((c-b-d)%n!=0){
            p=0;
            break;
        }
        if(c-b>max) max=c-b;
        s+=c;
        b=c;
    }
    if((a-b-d)%n!=0) p=0;
    if(a-b>max) max=a-b;
    if(p){
        s1=n*(n+1)/2;
        if(s%s1!=0){
            p=0;
        }else{
            m=s/s1;
            if((m-d)%n!=0 || max>m) p=0;
        }
    }
    if(p) printf("YES\n"); else printf("NO\n");
}


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

int main()
{
    int N;
    int A[201];
    cin >> N;
    
    for(int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
    
    int answer = 0;
    bool flag = false;
    while(true){
        for(int i = 0; i < N; i++){
        if (A[i] % 2 == 0) {
        }
        else{
            flag = true;
            break;
        }
        }

        if (flag) {
            break;
        }
        
        
        for(int i = 0; i < N; i++){
            A[i] /= 2;
        }

         ++answer;
    } 
    
   cout << answer << endl;
    
}



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

int main(){
    using namespace std;
    unsigned long X, Y, Z, K;
    cin >> X >> Y >> Z >> K;
    vector<unsigned long> A(X), B(Y), C(Z);
    for(auto& i : A)cin >> i;
    for(auto& i : B)cin >> i;
    for(auto& i : C)cin >> i;
    
    vector<unsigned long> AB(min(X * Y, K) + 1), ABC(K + 1);
    auto begin = AB.begin(), middle = AB.begin(), end = AB.end();
    auto comp = greater<>();
    for(auto i : A)
        for(auto j : B){
            *middle = i + j;
            push_heap(begin, ++middle, comp);
            if(end == middle)pop_heap(begin, middle--, comp);
        }
    
    begin = ABC.begin(), middle = ABC.begin(), end = ABC.end();
    for(auto i : AB)
        for(auto j : C){
            *middle = i + j;
            push_heap(begin, ++middle, comp);
            if(end == middle)pop_heap(begin, middle--, comp);
        }
    
    sort(ABC.rbegin(), ABC.rend());
    for_each(ABC.begin(), ABC.end() - 1, [](auto i){cout << i << endl;});
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include <string>
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define endl "\n"
#define mp make_pair
#define sz(v) (int)(v.size())
#define len(s) (int)(s.length())
#define M (ll)(1e9+7)
#define all(v) v.begin(),v.end()
#define fr(a,b,c) for(ll i=a;i<=b;i+=c)
#define inarr(arr,n); for(ll i=0;i<n;i++) cin >> arr[i];
#define outarr(arr,n); for(ll i=0;i<n;i++) cout<<arr[i]<<" ";
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
const ll inf = 9e18;
const ld pi = 2*acos(0.0); 
using namespace std;
ll power(ll a,ll n) 
{
    if(n==0){
        return 1;
    }
    ll p=power(a,n/2) % M;
    p = (p * p) % M;
    if (n%2==1)
    {
        p=(p*a)%M;
    }
    return p;
}
ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
}
const int N=1e6;
vector <ll> sieve(N,0); 
void si() 
{
    sieve[1]=1;
    for(int i=2;i<N;i++){
        if(sieve[i]==0){
            for(int j=i;j<N;j+=i){
                sieve[j]=i;
            }
        }
    }
}
int main(){
    ios;
    vector <ll> fact(4005,0);
    fact[0]=1;
    for(ll i=1;i<=4000;i++){
        fact[i]=(fact[i-1]*i)%M;
    }
    ll s;
    cin>>s;
    ll ans=0;
    for(ll i=1;i<=666;i++){
        ll z=3*i;
        ll n=s-z;
        if(n<0){
            break;
        }
        ll k=fact[n+i-1];
        ll div1=power(fact[i-1],M-2)%M;
        ll div2=power(fact[n],M-2)%M;
        ll add=(((k*div1)%M)*div2)%M;
        ans+=add;
        ans=ans%M;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 10992
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int K=sc.nextInt();
        String S=sc.next();
        if(S.length()<=K){
            System.out.println(S);
        }else{
            System.out.println(S.substring(0,K)+"...");
        }

    }
}


Measured memory_bytes: 38568