akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <boost/multiprecision/cpp_int.hpp>
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstring>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <set>
#include <numeric>
#include <sstream>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>
#include<iomanip>
namespace mp = boost::multiprecision;
using namespace std;
using ull = unsigned long long;
using ld = long double;
using lll = boost::multiprecision::cpp_int;
using ll = long long;
#define FOR(i, N) for(ll i = 0; i < N; ++i)

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
// using int = ll;
ll gcd(ll m, ll n) {
    if(n == 0)
        return abs(m);
    return (gcd(n, m % n));
}
void putYN(bool b) {
    if(b) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}
ll combi(ll n, ll k) {
    ll r = 1, rr = 1;
    for(ll i = 0; i < k; ++i) {
        r *= (n - i);
        rr *= (i + 1);
        // r %= 1000000007;
        // rr %= 1000000007;
    }
    r /= rr;
    // r %= 1000000007;
    return r;
}
int main(){
  ll X;
  cin>>X;
  vector<bool> A(200001,true);
  for(int i=2;i<=200000;++i){
    if(A[i]==false)continue;
    for(int j=i*2;j<=200000;j+=i){
      A[j]=false;
    }
  }
  for(int i=X;i<200000;++i){
    if(A[i]==true){
      cout<<i<<endl;
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
	string s;
	int a,b;
	
	cin>>a>>b;
	cin>>s;
	
	for(int i=0;i<s.size();i++)
	{
		if(i==a)
		{
			if(s[i]!='-')
			{
				cout<<"No";
				return 0;
			}
		}
		else if(!isdigit(s[i]))  
		{
	cout<<"No";		
			return 0;
		}
	}
	
	cout<<"Yes";
	return 0; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << '\n';
typedef int64_t Int;
Int mod = 1e9+7;
Int INF = 1e9+18;

int main() {
    ios::sync_with_stdio(false);
    Int n, x;
    cin >> n >> x;
    if (x == 1 || x == 2 * n - 1) {
        dump("No");
    }
    else {
        dump("Yes");
        vector<Int> res(2 * n, 0);
        for (Int i = 1; i <= 2 * n - 1; i++) res[i] = 0;
        if (n == 2) {            
            cout << 1 << " " << 2 << " " << 3 << endl;
        }
        else {
            Int a = 2 * n - 1;
            vector<bool> used(a + 1, false);
            
            if (x == a - 1) {
                res[a / 2] = x;
                res[a / 2 + 1] = x + 1;
                used[x] = used[x + 1] = true;
            }
            else {
                res[a / 2] = x - 1;
                res[a / 2 + 1] = x;
                res[a / 2 - 1] = x + 1;
                res[a / 2 + 2] = x + 2;
                for (Int i = -1; i <= 2; i++) used[x + i] = true;
            }
            priority_queue<Int> q;
            for (Int i = 1; i <= a; i++) {
                if (!used[i]) q.push(i);
            }
            for (Int i = 1; i <= a; i++) {
                if (res[i] == 0) {
                    cout << q.top() << " ";
                    q.pop();
                }
                else {
                    cout << res[i] << " ";
                }
            }
            cout << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 4848
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
    int n;
    cin >> n;
    int x[n],y[n];
    bool a[50]={};
    rep(i,n) cin >> x[i] >> y[i];
    map<pair<int,int>,int> mp;
    rep(i,n){
        rep(j,n){
            if(i==j) continue;
            mp[make_pair(x[j]-x[i],y[j]-y[i])]++;
        }
    }
    int cnt = 0,p=0,q=0,ans=n;
    for(auto i:mp){
        if(cnt < i.second){
            p = i.first.first;
            q = i.first.second;
            cnt = i.second;
        } 
    }
     rep(i,n){
        rep(j,n){
            if(i==j) continue;
            if(x[j]-x[i]==p&&y[j]-y[i]==q) a[j]=1;
        }
    }
    rep(i,n){
        if(a[i]==1) ans--;
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
n= int(input())
v = list(map(int, input().split()))

sv = sorted(v)

for i in range(n-1):
    new = (sv[0] + sv[1]) / 2
    if(i == n-1):
        break
    
    else:
        sva = sv[2:]
        sva.append(new)
        sv = sorted(sva)

print(sv[0])

Measured memory_bytes: 3060
// 🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤 //
// 🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤 //
// 🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤 //
// 🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤 //
// 🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤 //
// 🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤 //
// 🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤 //
// 🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤 //
// 🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤 //
// 🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤 //
// 🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤 //
// 🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤 //
// 🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤 //
// 🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤 //
// 🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤 //
// 🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤 //
// 🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤 //
// 🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤 //
// 🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤🖤 //

#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
#include <bits/stdc++.h>

using std::cerr;
using std::cin;
using std::cout;

using std::abs;
using std::min;
using std::max;
using std::swap;

using std::map;
using std::pair;
using std::set;
using std::string;
using std::vector;

using ll = long long;
using uint = unsigned int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define ff first
#define ss second
#define pb emplace_back
template<typename T> 
void _dbg(const char* _s, T _h) {
    cerr << _s << " = " << _h <<"\n"; 
}
template<typename T, typename... Ts>
void _dbg(const char* _s, T _h, Ts... _t) {
    int _b = 0;
    while (((_b += *_s == '(') -= *_s == ')') != 0 || *_s != ',')
        cerr << *_s++; 
    cerr << " = " << _h << ","; 
    _dbg(_s+1, _t...);
}
#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define dbg(...) 
#endif

struct init {
    init() {
        cin.tie(0);
        std::iostream::sync_with_stdio(0);
        cout << std::fixed << std::setprecision(10);
        cerr << std::fixed << std::setprecision(5);
    }
    ~init() {
        #ifdef LOCAL
        cerr << "Time elapsed: " << (double)clock() / CLOCKS_PER_SEC << "s.\n";
        #endif
    }
} init;

const int MAXN = 228;
pii a[MAXN], b[MAXN];

vector<int> g[MAXN];
int kl[MAXN], kr[MAXN];
bool used[MAXN];

bool dfs(int v) {
    if (used[v]) 
        return false;
    used[v] = true;
    for (int to : g[v]) 
        if (!kr[to]) 
            return kl[kr[to] = v] = to;
    for (int to : g[v]) 
        if (dfs(kr[to])) 
            return kl[kr[to] = v] = to;
    return false;
}

int main() {

    int n;
    cin >> n;

    for (int i = 1; i <= n; ++i)
        cin >> a[i].ff >> a[i].ss;
    for (int i = 1; i <= n; ++i)
        cin >> b[i].ff >> b[i].ss;


    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= n; ++j) {
            if (a[i].ff < b[j].ff && a[i].ss < b[j].ss) {
                g[i].pb(j  + n);
                g[j + n].pb(i);
            }
        }
    }

    for (int go = 1; go--;) {
        memset(used, 0, sizeof used);
        for (int i = 1; i <= n; ++i)
            if (!kl[i] && dfs(i))
                go = 1;
    }

    vector<pii> ans;
    for (int i = 1; i <= n; ++i)
        if (kl[i]) {
            ans.pb(kl[i], i);
            dbg(kl[i], i);
        }

    cout << ans.size() << '\n';


    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define P pair<int,double>
#define to first
#define cost second
#define PB push_back


void f(int n,int m,int p,int a,int b){
  vector<double> t(n);
  vector<vector<P>> es(m+1);

  for(int i=0;i<n;i++){
    cin>>t[i];
  }
  for(int i=0;i<p;i++){
    int x,y,z;
    cin>>x>>y>>z;
    es[x].PB(P(y,z));
    es[y].PB(P(x,z));
  }
  

  vector<vector<double>> dp(1<<n,vector<double>(m+1,DBL_MAX));

  dp[0][a]=0;


  for(int i=0;i<(1<<n);i++){
    for(int j=1;j<=m;j++){
      if(dp[i][j]==DBL_MAX) continue;
      for(int k=0;k<n;k++){
        if(i&(1<<k)) continue;
        for(auto e:es[j]){
          if(dp[i|(1<<k)][e.to]>dp[i][j]+e.cost/t[k]){
            dp[i|(1<<k)][e.to]=dp[i][j]+e.cost/t[k];
          }
        }
      }
    }
  }


  double ans=DBL_MAX;
  for(int i=0;i<(1<<n);i++)
    ans=min(ans,dp[i][b]);

  if(ans==DBL_MAX){
    cout<<"Impossible"<<endl;
  }else{
    printf("%.10lf\n",(ans==DBL_MAX?-1:ans));
  }
}



int main(){
  int n,m,p,a,b;
  while(true){
    cin>>n>>m>>p>>a>>b;
    if(n==0) break;
    f(n,m,p,a,b);
  }
}



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

int main() {
  int h, w;

  cin >> h >> w;

  for (int i = 0; i < w + 2; i++) cout << '#';

  cout << endl;

  for (int i = 0; i < h; i++) {
    string tmp;
    cin >> tmp;
    cout << '#' << tmp << '#' << endl;
  }

  for (int i = 0; i < w + 2; i++) {
    cout << '#';
  }

  return 0;
}

Measured memory_bytes: 256
//AnkitCode99 here....
//every ups and downs matter!

#include<bits/stdc++.h>

#define endl "\n"
typedef long long int ll;
#define MOD 1000000007
#define pll pair<ll,ll>
#define pb push_back
//max xor btw range of two numbers..
#define max_XOR(a,b) (1 << int(log2(a ^ b) + 1)) - 1
#define vl vector<ll>
#define inf ll(1e18)
#define all(v) v.begin(),v.end()
#define Ryuga ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i,a,b) for(long long int i=a;i<b;i++)
#define nrep(i,a,b) for(long long int i=a;i>=b;i--)
#define ceil(a,b) a/b+((a%b ==0 )?0:1)

using namespace std;

const ll sz=100005;
const ll szz=1000006;

int main()
{
    Ryuga;
     

    ll t;
    cin>>t;
    set<string> st;
    while(t--)
    {
        string s;
        cin>>s;
        st.insert(s);
    }
    cout<<st.size();
    
}//Goodbye...

Measured memory_bytes: 19236
#include <iostream>
#include <string>
#include <vector>
#define ll long long

using namespace std;

int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }

int main(){
    int N; cin >> N;
    vector<char> S(N);
    long long ans = 0;
    ll r = 0;
    ll  g = 0;
    ll b = 0;

    for (int l = 0; l < N; l++)
    {
      cin >> S[l];
      if (S[l] == 'R') r++;
      if (S[l] == 'G') g++;
      if (S[l] == 'B') b++;
    }

    ans = r*g*b;

    for (int i = 0; i < N-2; i++)
    {
      for (int j = i+1; j < N-1; j++)
      {
        int d = j-i;
        if ((S[i]!=S[j]) && (S[i]!=S[j+d]) && (S[j]!=S[j+d]) && (j+d < N)) ans--;
      }
    }
    
    cout << ans << endl;
    return 0;
    
}

Measured memory_bytes: 3576
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("-Ofast")
#include <bits/stdc++.h>
using namespace std;

typedef int in;
#define int long long
#define f first
#define s second
#define pb push_back
#define pp push
#define RETURN exit(0)
#define pow(x,y) (int)(pow(x,y))
#define ceil(x) (int)(ceil(x))
#ifndef ONLINE_JUDGE
#define debug(x) cout<<x<<endl;
#else
#define debug(x) 42
#endif
const int MAX=1e7;
const int MOD=1e9+7;
const int MAAX=1e15;
const long double EPS=1e-6;
const int N=1e6;
int power(int x,int y)
{
    if (y == 0)
        return 1;
    int a=power(x,y/2)%MOD;
    if (y % 2 == 0)
        return a * a % MOD;
    else
        return x * a % MOD * a % MOD;
}
long double sq(int x){
    long double s=0,e=x,mid;
    while(e-s>=EPS){
        mid=(s+e)/2;
        if(mid*mid<=x){
            s=mid;
        }
        else{
            e=mid-EPS;
        }
    }
    return s;
}
vector<int> primes;
bool visted[N+5];
void sieve(){
    visted[0]=visted[1]=1;
    for(int i=2;i*i<=N;i++){
        if(visted[i]==0){
            primes.pb(i);
            for(int j=i*i;j<=N;j+=i){
                visted[j]=1;
            }
        }
    }
    for(int i=sqrt(N)+1;i<=N;i++){
        if(visted[i]==0)
            primes.pb(i);
    }
    return;
}



in main()
{
    //freopen("in.in","r",stdin);
    //freopen("out.out","w",stdout);
    int tc=1;
    //sieve();
    //scanf("%lld",&tc);
    while(tc--)
    {
        int n,m;
        cin>>n>>m;
        int l=1,r=n;
        while(m--){
            int x,y;
            cin>>x>>y;
            if(x>l)
                l=x;
            if(y<r)
                r=y;
        }
        cout<<max(0ll,r-l+1)<<endl;
    }
    RETURN;
}


Measured memory_bytes: 256
N=input()
A=[]
B=[]
for i in range(N):
    a,b=map(int,raw_input().split())
    A.append(a)
    B.append(b)

ans=[0 for i in range(N)]
SUM=0

ans[0]=(B[N-1]-(A[N-1]%B[N-1]))%B[N-1]
SUM+=ans[0]

for i in range(N-1):
    ans[i+1]=(B[N-2-i]-((A[N-2-i]+SUM)%B[N-2-i]))%B[N-2-i]
    SUM+=ans[i+1]

    
print SUM


Measured memory_bytes: 15396
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m; i >= n; --i)
#define ALL(v) (v).begin(),(v).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; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m,x;cin >> n >> m >> x;
    vector<int> c(n);
    vector<vector<int>> a(n,vector<int>(m));
    REP(i,n){
        cin >> c[i];
        REP(j,m){
            cin >> a[i][j];
        }
    }
    int ans=inf;
    REP(t,1<<n){
        vector<int> b(m);
        int res=0;
        REP(i,n){
            if(t&(1<<i)){
                res+=c[i];
                REP(j,m){
                    b[j]+=a[i][j];
                }
            }
        }
        bool f=true;
        REP(i,m){
            if(b[i]<x) f=false;
        }
        if(f) chmin(ans,res);
    }
    cout << (ans==inf?-1:ans) << endl;
}

Measured memory_bytes: 3608
using System;

namespace AtcoderPractice
{
    class Program
    {
        static void Main(string[] args)
        {
            string st = Console.ReadLine();
            string[] s = st.Split();
            int[] n = new int[4];
            for(int i = 0; i < s.Length; i++)
            {
                n[i] = int.Parse(s[i]);
            }
            int a = n[0] * n[1];
            int b = n[2] * n[3];
            if (a > b)
            {
                Console.WriteLine(a);
            }
            else
            {
                Console.WriteLine(b);
            }
        }
    }
}


Measured memory_bytes: 13140
pattern = gets.split('').map(&:to_i)
pattern = [pattern[0]].product(*pattern[1..3].map{|x|[x, -x]})
print(pattern.map{|ary| ary + [ary.inject(:+)]}.keep_if{|ary| ary[4] == 7 }[0].map.with_index{|n, i| (i==0 ? '' : (i==4 ? '=' : (n<0 ? '' : '+'))) + n.to_s}.join(''))


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);i++)
#define int long long  
signed main(){
    int a,b;
    cin >> a >> b;
    if(a<=0 && 0<=b){
        cout << "Zero" << endl;
    }else if(0<a || (b<0 && abs(a-b)%2==1)){
        cout << "Positive" << endl;
    }else{
        cout << "Negative" << endl;
    } 
	return 0;
}


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

const int MAX = 1000000;
const int MOD = 1000000007;

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 main() {
    int X, Y; cin >> X >> Y;
    if ((X + Y) % 3 != 0 || X / Y > 2 || Y / X > 2) {
        cout << 0 << endl;
    } else {
        int k = (X + Y) / 3;
        int n = X - k;

        COMinit();

        cout << COM(k, n) << endl;
    }
}



Measured memory_bytes: 23680
#include <bits/stdc++.h>
using namespace std;
int main(){
    int arr[5];
    int sum=0;
    for(int i=0;i<5;i++)
    cin>>arr[i];
    for(int i=0;i<5;i++)
    sum+=arr[i];
    cout<<15-sum<<endl;
}

Measured memory_bytes: 3552
#include <bits/stdc++.h>
using namespace std;
int main(){
  int d,s;
  double t;
  cin>>d>>t>>s;
  double time=(double)d/s;
  if(time<=t){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}

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

using ll = long long;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  
  vector<int> a(n), b(n), c(n);
  for (int i = 0; i < n; i++) cin >> a.at(i);
  for (int i = 0; i < n; i++) cin >> b.at(i);
  for (int i = 0; i < n; i++) cin >> c.at(i);
  
  sort(a.begin(), a.end());
  sort(c.begin(), c.end());
  
  ll ans = 0;
  for (int i = 0; i < n; i++) {
    ll counta = lower_bound(a.begin(), a.end(), b.at(i)) - a.begin();
    ll countc = c.end() - upper_bound(c.begin(), c.end(), b.at(i));
    ans += counta * countc;
  }
  
  cout << ans << '\n';
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod107 1000000007
#define rep(i, n) for (int i = 0; i < n; ++i)
#define Graph vector<vector<int>>
#define grepq priority_queue<double, std::vector<double>, std::greater<double>>
#define all(v) v.begin(), v.end()
#define PI acos(-1)
#define inf 1000000321
#pragma GCC optimize("Ofast")
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i = 0;i < N;i++){
        cin >> A[i];
    }
    ll ans = 0;
    vector<ll> csum(N);
    csum[0] = 0;
    ll sum = 0;
    for(int i = 0;i < N;i++){
        //csum[i+1] = csum[i] + A[i];
        sum += A[i];
    }
    for(int i = 0;i < N;i++){
        ans %= mod107;
        sum -= A[i];
        //cout << sum << endl;
        ans += (sum%mod107)*A[i];
        ans %= mod107;
    }
    ans %= mod107;
	cout << ans << endl;
}   

Measured memory_bytes: 5564
-module('Main').
-export([main/1]).

main(_) ->
    {ok, [S, T]} = io:fread("", "~s ~s"),
    C = count_difference(S, T),
    io:format("~p~n", [C]),
    halt().

count_difference(S, T) ->
    count_difference(S, T, 0).
count_difference([], [], C) ->
    C;
count_difference([SH|ST], [TH|TT], C) ->
    case SH /= TH of
        true ->
            count_difference(ST, TT, C + 1);
        false ->
            count_difference(ST, TT, C)
    end.



Measured memory_bytes: 84916
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include "bits/stdc++.h"
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

int main() {
    string s;
    cin>>s;
    int p=0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='p')
        p++;
    }
    cout<<s.size()/2-p<<endl;
    }

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int s[300];
int main()
{ int Min;Min=1000000000;
int n;
cin>>n;
 for(int i=1;i<=n;i++)
    cin>>s[i];
    sort(s+1,s+1+n);
for(int i=s[1];i<=s[n];i++)
{ int sum;sum=0;for(int j=1;j<=n;j++)
{
    sum+=(i-s[j])*(i-s[j]);
}Min=min(Min,sum);}cout<<Min;

}


Measured memory_bytes: 256
let input = readLine()!.split(separator: " ").map { Int($0)! }

let N = input[0]
let M = input[1]

var graph: [[Int]] = .init(repeating: [], count: N)

for _ in 0..<M {
  let inp = readLine()!.split(separator: " ").map { Int($0)! }
  let start = inp[0]
  let end = inp[1]
  
  graph[start - 1].append(end - 1)
}

var dp: [Int] = .init(repeating: -1, count: N)

func dfs(_ i: Int) -> Int {
  if dp[i] != -1 {
    return dp[i]
  }
  var count = 0
  
  for nei in graph[i] {
    count = max(count, dfs(nei) + 1)
  }
  dp[i] = count
  return dp[i]
}
var ans = 0
for i in 0..<N {
  ans = max(ans, dfs(i))
}
print(ans)

Measured memory_bytes: 16976
#include<stdio.h>
int main(void)
{
    int kai,i;
    double v,t,y;
    while(scanf("%lf",&v) != EOF){
        t = v / 9.8;
        y = 4.9 * t * t;
        for(i = 1;; i++){
            kai = 5 * i - 5;
            if(kai > y){
                printf("%d\n",i);
                break;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 628
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

// CHECK THE LIMITS
typedef long long ll;

const int MOD = 1000000007;
const ll INFLL = 1e18;
const int INF = 1e9;
const int NMAX = 1000001;

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

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
	ll n;
	cin >> n;

	ll res = 0;
	if(n % 2 == 1)
	{
		cout << 0;
		return 0;
	}

	for(ll i = 5; n / i >= 1; i*=5LL)
	{
		res+=(n/i)/2;
	}
	cout <<1LL*res;

    return 0;
}

Measured memory_bytes: 256
import numpy as np

X,N = map(int, input().split())
if N == 0:
    print(X)

else:
    p = list(map(int, input().split()))
    main = set(np.arange(102))
    main = main - set(p)

    main1 = abs(np.array(list(main)))
    idx = abs(main1 - X).argmin()
    print(main1[idx])

Measured memory_bytes: 27172
#include<bits/stdc++.h>
using namespace std;
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
const int MOD = 1000000007;

int n, m;
vector<vector<int>> to;
vector<vector<int>> z;
vector<int> cnt;

void dfs(int i) {
  for(int u: to[i]) {
    if (cnt[u]) continue;
    cnt[u] = 1;
    dfs(u);
  }
}

void solve() {
  cin >> n >> m;
  to.resize(n);
  z.resize(n);
  cnt.resize(n);
  rep(i,m) {
    int a, b, c;
    cin >> a >> b >> c;
    a--, b--;
    to[a].push_back(b);
    to[b].push_back(a);
    z[a].push_back(m);
    z[b].push_back(m);
  }

  int ans = 0;

  rep(i,n) {
    if (cnt[i]) continue;
    ans++;
    dfs(i);
  }
  cout << ans << endl;
}

int main() {
  solve();
  return 0;
}

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

const int N = 1e5+5;
int n, a[N], b[N];

int main()
{
    //freopen("a.inp","r",stdin);
    scanf("%d",&n);
    for(int i=1; i<=n; ++i) scanf("%d",a+i);
    for(int i=1; i<=n; ++i) b[1] += i&1 ? +a[i] : -a[i];
    for(int i=1; i<n; ++i) b[i+1] = a[i]+a[i] - b[i];
    for(int i=1; i<=n; ++i) printf("%d ",b[i]);
}


Measured memory_bytes: 2048
# -*- coding: utf-8 -*-
"""
Created on Sat Apr 13 09:52:51 2019

@author: Owner
"""

import collections
import scipy.misc
import sys
import numpy as np
import math
from operator import itemgetter
import itertools
import copy
import bisect

#素因数を並べる
def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(int(i))
    i += 1
  if n > 1:
    table.append(int(n))
  return table   
# 桁数を吐く
def digit(i):
    if i > 0:
        return digit(i//10) + [i%10]
    else:
        return []
    
def getNearestValueIndex(list, num):
    """
    概要: リストからある値に最も近い値のインデックスを取得する関数
    @param list: データ配列
    @param num: 対象値
    @return 対象値に最も近い値
    """

    # リスト要素と対象値の差分を計算し最小値のインデックスを取得
    idx = np.abs(np.asarray(list) - num).argmin()
    return idx

def find_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default


"""
N, X = map(int, input().split())

x = list(map(int, input().split()))

P = [0]*N
Y = [0]*N
for n in range(N):
    P[n], Y[n] = map(int, input().split())

    
all(nstr.count(c) for c in '753')

# 複数配列を並び替え
ABT = zip(A, B, totAB)
result = 0
# itemgetterには何番目の配列をキーにしたいか渡します
sorted(ABT,key=itemgetter(2))
A, B, totAB = zip(*ABT)
A.sort(reverse=True)

#setの宣言
opn = set()
opn.add(start)
opn.remove(start)

# 2進数のbit判定
(x >> i) & 1

# dp最小化問題
dp = [np.inf]*N
for n in range(N):
    if n == 0:
        dp[n] = 0
    else:
        for k in range(1,K+1):
            if n-k >= 0:
                dp[n] = min(dp[n], dp[n-k] + abs(h[n]-h[n-k]))
            else:
                break

"""
A, B = map(int, input().split())

def main():    
    print(max(A+A-1, A+B, B+B-1))    
 
if __name__ == '__main__':
    main()

Measured memory_bytes: 24540
using System;
using System.IO;

namespace Contest
{
    class Program
    {
        private Scanner sc;
        public void Solve()
        {
            sc = new Scanner();
            string S = sc.Next();
            int[] a = new int[255];
            foreach (char c in S)
            {
                a[c]++;
            }

            int cnt = 0;

            for (char c = 'A'; c <= 'Z'; c++)
            {
                if (a[c] == 2)
                {
                    cnt++;
                }
            }
            Console.WriteLine(cnt == 2 ? "Yes" : "No");
        }

        static void Main() => new Program().Solve();
    }
}

class Scanner
{
    public Scanner()
    {
        _stream = new StreamReader(Console.OpenStandardInput());
        _pos = 0;
        _line = new string[0];
        _separator = ' ';
    }
    private readonly char _separator;
    private readonly StreamReader _stream;
    private int _pos;
    private string[] _line;
    #region get a element
    public string Next()
    {
        if (_pos >= _line.Length)
        {
            _line = _stream.ReadLine().Split(_separator);
            _pos = 0;
        }
        return _line[_pos++];
    }
    public int NextInt()
    {
        return int.Parse(Next());
    }
    public long NextLong()
    {
        return long.Parse(Next());
    }
    public double NextDouble()
    {
        return double.Parse(Next());
    }
    #endregion
    #region convert array
    private int[] ToIntArray(string[] array)
    {
        var result = new int[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = int.Parse(array[i]);
        }

        return result;
    }
    private long[] ToLongArray(string[] array)
    {
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = long.Parse(array[i]);
        }

        return result;
    }
    private double[] ToDoubleArray(string[] array)
    {
        var result = new double[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = double.Parse(array[i]);
        }

        return result;
    }
    #endregion
    #region get array
    public string[] Array()
    {
        if (_pos >= _line.Length)
            _line = _stream.ReadLine().Split(_separator);
        _pos = _line.Length;
        return _line;
    }
    public int[] IntArray()
    {
        return ToIntArray(Array());
    }
    public long[] LongArray()
    {
        return ToLongArray(Array());
    }
    public double[] DoubleArray()
    {
        return ToDoubleArray(Array());
    }
    #endregion
}

Measured memory_bytes: 13140
from collections import defaultdict

n=int(input())
h=defaultdict(int)
for i in range(n):
  s=list(input().strip())
  s.sort()
  h["".join(s)]+=1

ans=0
for v in h.values():
  if v>1:
    ans += v*(v-1)//2
print(ans)

Measured memory_bytes: 97216
#include <iostream>
#include <cmath>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <cassert>
#include <random>
#include <bitset>
using namespace std;
 

#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define all(x) x.begin(), x.end()
#define ff first
#define ss second
#define pb push_back
#define forn(i, n) for (int i = 0; i < n; ++i)
// #define int long long

 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
 
 
const int MAXN = 2e5 + 5;
const ll MOD = 1e9 + 7;
const ll INF = INT64_MAX;


random_device rd;
mt19937 rnd(rd());


signed main() {
	FAST_IO;
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	forn(i, n) {
		cin >> a[i];
	}
	sort(all(a));
	int ans = 0;
	forn(i, k) {
		ans += a[i];
	}
	cout << ans << "\n";
 	return 0;
}

Measured memory_bytes: 3652
#ABC167
N,M,X=map(int,input().split())
c = []  #参考書の値段
a = []  #各参考書に入る理解度
for i in range(N):
    c_temp, *a_temp = list(map(int, input().split()))  # こうすると、2つ目以降をリストで受け取れる
    c.append(c_temp)
    a.append(a_temp)
price_min = 10000000
for i in range(2**N):
    price_total = 0  #値段の合計
    learn_total = [0] * M #理解度の合計
    for j in range(N):
        if (i >> j) & 1:  # j桁目が0か1か見て、j冊目を買うか買わないか判定します
            price_total += c[j]  # 買うので、j冊目の値段を加算します
            learn = a[j]  # 「j冊目の参考書を読んで増える、各アルゴリズムの理解度」のリストです
            for k, la in enumerate(learn):  # 理解度を加算します enumerateを使うと、range(n)よりスマートです
                learn_total[k] += la
    if all(learn_total[k] >= X for k in range(M)):
        if price_min > price_total:
            price_min=price_total
            
if price_min==10000000:
    print (-1)
else:
    print (price_min)

Measured memory_bytes: 9236
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;

public class Main {

	public static void main(String[] args) throws Exception {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String W = in.readLine();
		String[] Ws = W.split(" ");
		int N = Integer.parseInt(Ws[0]);
		int Q = Integer.parseInt(Ws[1]);

		long[] p = new long[N];
		Arrays.fill(p, 0);
		ArrayList<int[]> link = new ArrayList<int[]>();

		for(int i=0;i<N-1;i++){
			W = in.readLine();
			Ws = W.split(" ");
			int[] tmp = new int[2];
			tmp[0] = Integer.parseInt(Ws[0])-1;
			tmp[1] = Integer.parseInt(Ws[1])-1;
			link.add(tmp);
		}

		link.sort(new Comparator<int[]>(){
			public int compare(int[] a , int[] b){
				return a[1] - b[1];
			}
		});


		//各頂点に指定された点数を加算
		for(int i=0;i<Q;i++){
			W = in.readLine();
			Ws = W.split(" ");
			p[Integer.parseInt(Ws[0])-1]+=Integer.parseInt(Ws[1]);
		}

		StringBuffer sb = new StringBuffer();
		//頂点１については自分の数値のみのため、そのまま出力
		sb.append(p[0]+" ");
		//各頂点を２から順に出力する
		for(int i=1;i<N;i++){
			p[i]+=p[link.get(i-1)[0]];
			sb.append(p[i]+" ");
		}
		sb.delete(sb.length()-1, sb.length());
		System.out.println(sb.toString());

	}




}


Measured memory_bytes: 101652
#include <bits/stdc++.h>
 
using namespace std;
 
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble
 
 
//typedef tuple <int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;
typedef vector<int> vi;
typedef vector<ll> vll;
 
#define siz(x) (int)(x).size()
#define Y second
#define X first
#define IN insert
#define PB push_back
#define P pop_back
#define PU push
#define PO pop
//#define F find
#define ED end()
#define MP( a, b) make_pair( a, b )
 
//#define MOD 1000000007ll
#define INF 1000000000
#define endl "\n"
#define rep(a,i,b) for (ll i = (a); i < (b); ++i)
#define reps(a,i,b) for (ll i = (a); i <= (b); ++i)
#define repd( num, i, ed ) for(ll (i)= (num)-1; (i) >= ed; --(i))
#define repkt( bg, i, num, kt ) for(ll (i)= (bg); (i) < (num) && (kt); ++(i))
#define repchar( i ) for(char (i)= 48; (i) <= 122; (i)++)   
#define in(n) scanf("%lld", &n)
#define out(n) printf("%lld\n", n)
#define outS(s) printf("%s\n", s)
#define setA(a,n) for(ll i= 0, j= sizeof(a)/sizeof(a[0]); i < j; ++i) a[i]= n;
#define repe(num,i,ed) for(ll (i)= (num); (i) >= ed; --(i))
// const int INF=0x3f3f3f3f;
const ll mod=1e9+7;
const ll N=1e5+5,K=105;
const int si=(1<<20);
const ll M=50+5;
const ll oo=1e18+5;
const double INFdb=1e10;

int n;
int h[N];
int dp[N];

int main(){
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
    #ifndef ONLINE_JUDGE
        // freopen("input.txt", "r", stdin);
    #endif
    cin>>n;
    for(int i=1;i<=n;++i) cin>>h[i];
    h[0]=h[1];
    dp[0]=dp[1]=0;
    for(int i=2;i<=n;++i){
		dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
	}
	cout<<dp[n];
    cerr<<"\nTime elapsed: "<<1000*clock()/CLOCKS_PER_SEC<<"ms\n";                                                                          
    return 0;
}



Measured memory_bytes: 1024
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();
        int b = sc.nextInt();

        int smaller = Math.min(a, b);
        int bigger = Math.max(a, b);

        StringBuilder result = new StringBuilder();
        for (int i = 0; i < bigger; i++) {
            result.append(smaller);
        }

        System.out.println(result);
    }
}

Measured memory_bytes: 21716
#include<stdio.h>
int main()
{
	int r=0;
	double a,i=1.0;
	scanf("%lf",&a);
	if(a==0.0){
		printf("%d\n",0);
	}else{
		while(a>=i){
			r++;
			i*=2.0;
		}
		printf("%d\n",r);
	}
	return 0;
}

Measured memory_bytes: 1860
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      	int K = sc.nextInt();
        long sum = (long) 0;
      	for(int i=1; i<K+1;  i++){
          for(int j=1; j<K+1;  j++){
            for(int l=1; l<K+1;  l++){
              sum += gcd(gcd(i,j),l);
            }
          }
        }
      
      	System.out.println(sum);
        return;
	}
       static int gcd (int a, int b) {return b>0?gcd(b,a%b):a;}
}


Measured memory_bytes: 35804
#include <bits/stdc++.h>
using namespace std;
using edge = struct{int to; int cost;};
vector<edge> tree[100000];
long long dist[100000];

void dfs(int v, int p, long long d) {
    dist[v] = d;
    for(edge &e : tree[v]) {
        if(e.to == p) continue;
        dfs(e.to, v, d + e.cost);
    }
}

int main() {
    int N;
    cin >> N;
    for(int i=0; i+1<N; ++i) {
        int a,b,c;
        cin >> a >> b >> c;
        tree[a-1].push_back({b-1, c});
        tree[b-1].push_back({a-1, c});
    }
    int Q, K;
    cin >> Q >> K;
    --K;
    dfs(K, -1, 0);

    for(int i=0; i<Q; ++i) {
        int x,y;
        cin >> x >> y;
        --x; --y;
        cout << dist[x] + dist[y] << endl;
    }
    return 0;
}

Measured memory_bytes: 12800
#pragma GCC target ("avx2")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#include <bits/stdc++.h>
#define int long long
#define ld long double
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define rt return
#define yy cout<"Yes\n"
#define nn cout<<"No\n"
#define er erase
#define cl clear
#define bg begin
#define bk break
#define ct continue
using namespace std;
struct st{
    
};
bool cmp(){
    
    return 1;
}
int go(){
    
    return 0;
}
void recur(){
    
}
void solve(){
    int n;
    cin>>n;
    int a[n];
    for (int i=0; i<n; i++) cin>>a[i];
    sort(a,a+n);
    int ans=0;
    for (int i=0; i<n-2; i++){
        for (int j=i+1; j<n-1; j++){
            for (int k=j+1; k<n; k++){
                if (a[i]==a[j]||a[j]==a[k]||a[i]==a[k]) continue;
                if (a[i]+a[j]>a[k]) ans++;
            }
        }
    }
    cout<<ans;
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t=1;
    //cin>>t;
    while (t--) solve();
}

Measured memory_bytes: 3696
#include <bits/stdc++.h>
using namespace std;
//Author: Ezio Sam
/* Shorthands */
#define ll long long
#define pb push_back 
#define mp make_pair
#define sp ": "
#define cs "Case "
#define fi first
#define sn second 
#define po(x) x*x
/* STL */
#define vi vector<int>v
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mem(a,n) memset(a, n, sizeof(a));
#define all(x) x.begin(),x.end()
#define sz(x)  (int)x.size()
#define mx(v)  *max_element(v.begin(),v.end())
#define mxa(a) *max_element(a, a.size())
#define r(a) reverse(a.begin(),a.end())
/* loops */
#define fr(i,n)   for(__typeof(n) i=0;i<(n);i++)
#define fn(i,n)   for(__typeof(n)i=1;i<=(n);i++)
#define fa(i,a,n) for(__typeof(a)i=(a);i<=(b);i++)
/*Special*/
#define Ezio ios::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
#define db(something)   cerr<<#something<<" - "<<something<<"\n";         
int main()
{
  
   Ezio
   /*Variables*/
   /*Code*/
   ll n;
   cin>>n;
   ll m=n/500;
   ll x=(n%500)/5;
   cout<<(m*1000)+(x*5)<<endl;
   return 0;
}
    

Measured memory_bytes: 3580
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author anand.oza
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BATCoder solver = new BATCoder();
        solver.solve(1, in, out);
        out.close();
    }

    static class BATCoder {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String s = in.next();

            int answer = 0;
            int count = 0;

            for (char c : s.toCharArray()) {
                if ("ACGT".indexOf(c) != -1) {
                    count++;
                    answer = Math.max(answer, count);
                } else {
                    count = 0;
                }
            }

            out.println(answer);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

    }
}



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

int main(){
  long long n,x,y = 0,z;
  cin >> n;
  long long A[n-1],X[n] = {};
  for(int i = 0;i < n-1;i++){
    cin >> A[i];
  }
  for(int i = 0;i < n-1;i++){
    if(i == 0)X[i] = A[i]; 
    if(A[i] == A[i+1])X[i+1] = A[i];
    if(A[i] < A[i+1]){
      X[i+1] = A[i];
    }
    if(A[i] > A[i+1]){
      X[i+1] = A[i+1];
    }
    //cout << X[i] << endl;
  }
  for(int i = 0;i < n;i++){
    y += X[i];
  }
  cout << y << endl;
}


Measured memory_bytes: 256
import           System.IO
import           Control.Monad
import           Control.Applicative
import           Control.Monad.State
import           Data.List

calc :: String -> String
calc str = show $ length $ show $ sum $ take 2 $ map read (words str)

main = do
  line <- getLine
  putStrLn $ calc line
  eof <- isEOF
  unless eof $ main



Measured memory_bytes: 4000
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;

int main()
{
	int n, T;
	cin >> n >> T;
	int k = 1000000;
	for (int i = 0; i < n; ++i)
	{
		int c, t;
		cin >> c >> t;
		if (t <= T)
			k = min(k, c);
	}
	if (k == 1000000)
		cout << "TLE";
	else
		cout << k;
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def main():
    a,b,c=MI()
    if a<=c<=b:print("Yes")
    else:print("No")
main()

Measured memory_bytes: 3064
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
from bisect import bisect_left 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,k = inpl()
print(min(n%k, k-(n%k)))

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

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
// combination mod prime
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

// dp、13で割ったあまり

int main() {
  string s;
  cin >> s;
  int m = 13;
  vector<mint> dp(m);
  dp[0] = 1;
  for (char c : s) {
    vector<mint> prev(m);
    rep(i, m) prev[i] = 0;
    swap(prev, dp);
    rep(i, 10) {
      if (c == '0' + i || c == '?') {
        rep(j, m) {
          dp[(j*10+i)%m] += prev[j];
        }
      }
    }
  }
  mint ans = dp[5];
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
#define _MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) _MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define pb push_back
#define all(x) begin(x),end(x)
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cerr<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cerr<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.first<<","<<p.second<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
#else
#define dbg(...) {}
#endif

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

  long ans = 0;
  int pre = 0;

  auto ap = [&](int d){
    pre = pre*10 + d;
    while(pre >9) {
      ans++;
      pre = pre/10 + pre%10;
    }
  };

  rep(i,m){
    int d;
    long c;
    cin>>d>>c;
    while(c>0) {
      if(c%2 == 1) {
        ap(d);
        c--;
      }
      else {
        long cur = (d >= 5) ? 2 : 1;
        ans += c/2 * cur;
        if(d>=5){d = (d*2)%10 + 1;}
        else d = d*2;
        c /= 2;
      }
    }
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
from collections import deque
N,Q=map(int,input().split())
tr=[[] for _ in range(N)]
for _ in range(N-1):
    a,b=map(int,input().split())
    tr[a-1].append(b-1)
    tr[b-1].append(a-1)
k=[0]*N
for _ in range(Q):
    p,x=map(int,input().split())
    k[p-1]+=x
q=deque([0])
v=[True]*N
while q:
    t=q.popleft()
    if v[t]:
        v[t]=False
        for j in tr[t]:
            if v[j]:
                k[j]+=k[t]
                q.append(j)
print(*k)

Measured memory_bytes: 56172
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
ll a,b,n;
ll f(ll x0){
    return (a*x0)/b-a*(x0/b);
}
int main(void){
    cin>>a>>b>>n;
    ll x=min(n,b-1);
    //cout<<x<<endl;
    cout<<f(x);
}


Measured memory_bytes: 3552
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define uint unsigned int
#define ull  unsigned long long
typedef string str;
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef vector<int> vi;
typedef vector<bool> vb;
#define pb push_back
#define fi first
#define se second
#define in insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
const int INF = 1e9 + 5;
const int N = 2e5 + 123;
int main(){
    speed;
    int n, x;
    cin >> n >> x;
    vi v(n);
    for(int i = 0; i < n; ++i){
        cin >> v[i];
    }
    ll ans = 0;
    if(v[0] > x){
        ans += v[0] - x;
        v[0] = x;
    }
    for(int i = 1; i < n; ++i){
        if(v[i] + v[i - 1] > x){
            ans += v[i] + v[i - 1] - x;
            v[i] -= v[i] + v[i - 1] - x;
        }
    }
    cout << ans;
}

Measured memory_bytes: 3700
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,M=0;
  char p[20]={0};
  char ans[20]={0};
  cin >> N;
  char *adr;
  for(int a=0;a<=9;a++){ 
    p[11]=a;
    if(abs(p[12]-p[11])>1)
      continue;
    for(int b=0;b<=9;b++){ 
      p[10]=b;
      if(abs(p[11]-p[10])>1 && a)
        continue;
      for(int c=0;c<=9;c++){ 
        p[9]=c;
        if(abs(p[10]-p[9])>1 && a+b)
          continue;
        for(int d=0;d<=9;d++){ 
          p[8]=d;
          if(abs(p[9]-p[8])>1 && a+b+c)
            continue;
          for(int e=0;e<=9;e++){
            p[7]=e;
            if(abs(p[8]-p[7])>1 && a+b+c+d)
              continue;
            for(int f=0;f<=9;f++){ 
              p[6]=f;
              if(abs(p[7]-p[6])>1 && a+b+c+d+e)
                continue;
              for(int g=0;g<=9;g++){ 
                p[5]=g;
                if(abs(p[6]-p[5])>1 && a+b+c+d+e+f)
                  continue;
                for(int h=0;h<=9;h++){ 
                  p[4]=h;
                  if(abs(p[5]-p[4])>1 && a+b+c+d+e+f+g)
                    continue;
                  for(int i=0;i<=9;i++){ 
                    p[3]=i;
                    if(abs(p[4]-p[3])>1 && a+b+c+d+e+f+g+h)
                      continue;
                    for(int j=0;j<=9;j++){ 
                      p[2]=j;
                      if(abs(p[3]-p[2])>1 && a+b+c+d+e+f+g+h+i)
                        continue;
                      for(int k=0;k<=9;k++){ 
                        p[1]=k;
                        if(abs(p[2]-p[1])>1 && a+b+c+d+e+f+g+h+i+j)
                          continue;
                        for(int l=0;l<=9;l++){ 
                          p[0]=l;
                          if(abs(p[0]-p[1])>1 && a+b+c+d+e+f+g+h+i+j+k)
                            continue;
                          if(M++==N){
                            int ss[12]={a,b,c,d,e,f,g,h,i,j,k,l};
                            for(int uu=0;uu<12;uu++){
                              if(ss[uu]){
                                for(int ansp=uu;uu<12;uu++){
                                  ans[uu-ansp]=p[11-uu]+='0';
                                }
                            goto endend;
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
  endend:
  puts(ans);
}

Measured memory_bytes: 256