akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
#define countof(a) (sizeof(a)/sizeof((a)[0]))
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define all(a) begin(a),end(a)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_v(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << endl; }
template<class T> void cout_h(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << (i==c.size()-1?"\n":" "); }
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
void Yes(bool f){cout<<(f?"Yes":"No")<<endl;}
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 

const ll MOD = 1000000007;

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

    ll N, M;
    cin >> N >> M;

    ll ans = 0;

    if (abs(N-M) <= 1) {
        ans = 1;
        for (int i = 2; i <= N; i++) ans = ans * i % MOD;
        for (int i = 2; i <= M; i++) ans = ans * i % MOD;
        if (M == N) ans = ans * 2 % MOD;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
import itertools
import numpy as np

D, G = [int(x) for x in input().split()]

level = np.arange(1, D + 1)
P = np.ndarray(D, dtype=int)
C = np.ndarray(D, dtype=int)
for i in range(D):
    P[i], C[i] = [int(x) for x in input().split()]

complete_scores = level * 100 * P + C

min_problems = P.sum()
for bits in itertools.product([0, 1], repeat=D):
    bits = np.array(bits)
    score_rest = G - (bits * complete_scores).sum()
    if score_rest <= 0:
        min_problems = min(min_problems, (bits * P).sum())
    else:
        for i in reversed(range(D)):
            n_problems = (score_rest + (level[i] * 100) - 1) // (level[i] * 100)
            if bits[i] == 0 and n_problems < P[i]:
                min_problems = min(min_problems, (bits * P).sum() + n_problems)
                break

print(min_problems)


Measured memory_bytes: 12460
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define scan(n) scanf("%d",&n)
#define ls(n) scanf("%lld",&n)
#define print(n) printf("%d",n)
#define pln(n) printf("%d\n",n)
#define lpln(n) printf("%lld\n",n)
#define rep(i,a,n) for(int i=a;i<n;i++)
#define rev(i,a,n) for(int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define gcd __gcd
#define tc           ll t1; cin>>t1; while(t1--)
#define inp         ll n; cin>>n; ll arr[n]; rep(i,0,n) cin>>arr[i];
#define vect vector<ll>
#define sortv(v)       sort(v.begin(),v.end())
#define lower(v,n)    lower_bound(v.begin(),v.end(),n)-v.begin()
#define upper(v,n)    upper_bound(v.begin(),v.end(),n)-v.begin()
#define all(v)        v.begin(),v.end()
#define bitcount(n) __builtin_popcount(n)
#define ln <<endl
#define inf          1e12+5
#define ninf         -1e17
#define fast()         ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
const   ll mod=1e9+7;
const ll N=1e5+5;



int main() 
{ 
          fast();
         

          ll d,t,s;
          cin >> d >> t >> s;
          if((t*s)>=d) cout<<"Yes";
          else cout<<"No";
          
           return 0; 

} 

Measured memory_bytes: 3652
s=input()
k=int(input())
t=list(s)
ans=0

if(len(set(list(s)))==1):
    ans=(len(s)*k)//2
elif(s[0] != s[-1]):
    for i in range(len(t)-1):
        if(t[i] == t[i+1]):
            ans+=1
            t[i+1]="*"
    ans*=k
else:
    s_first=s[0]
    first=0
    end=len(s)-1

    while(s[first] == s_first):
        first+=1

    while(s[end] == s_first):
        end-=1

    len_first=first
    len_end=len(s[end+1:])

    rest_s=list(s[first:end+1])
    rest_ans=0
    for i in range(len(rest_s)-1):
        if(rest_s[i] == rest_s[i+1]):
            rest_ans+=1
            rest_s[i+1]="*"

    ans+=len_first//2
    ans+=rest_ans*k
    ans+=((len_first+len_end)//2)*(k-1)
    ans+=len_end//2
print(ans)

Measured memory_bytes: 3064
module Main where

    import Data.List
    import Control.Monad
    import Debug.Trace
    import qualified Data.Vector.Mutable as MV
    import Control.Monad.ST (runST)
    import qualified Data.ByteString.Char8 as BC
    import Data.Maybe (fromJust)

    solve :: [(Int, Int, Int)] -> Int -> [Char]
    solve ((from, to, dist) : routes) nums = runST $ do
        let root = from - 1
        distantVec <- MV.replicate nums []
        MV.write distantVec root [((to -1), dist)]
        forM_ routes $ \(from, to, distance) -> do
            MV.modify distantVec (((to-1),distance):) (from  -1)
            MV.modify distantVec (((from -1 ),distance):) (to -1)
        distanceFromRootVec <- MV.replicate nums (Nothing :: Maybe Int)
        let search point distAccum = do
                MV.write distanceFromRootVec point (Just distAccum)
                routes <- MV.read distantVec point
                forM_ routes $ \(nextPoint, distance) -> do
                    dist <- MV.read distanceFromRootVec nextPoint 
                    case dist of
                        Just n -> pure ()
                        Nothing -> search nextPoint (distAccum + distance)
        search root 0
        forM [0..(nums-1)] $ \point -> do
            dist <- MV.read distanceFromRootVec point
            case dist of
                Nothing -> pure undefined
                Just n -> pure $ if even n then '0' else '1'
    
    readTuple2 :: IO (Int, Int)
    readTuple2 = do
        [a, b] <- words <$> getLine
        return (read a, read b)
    
    readTuple3 :: IO (Int, Int, Int)
    readTuple3 = do
        [a, b, c] <- fmap (fst. fromJust . BC.readInt) . BC.words <$> BC.getLine
        return (a, b, c)
    
    main = do
        n <- readLn
        routes <- replicateM (n - 1) readTuple3
        forM_ (solve routes n) (\n -> putChar n >> putStrLn "")

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

template <class Info>
struct edge {
    int from, to;
    Info info;
    edge(int to, Info info) : to(to), info(info) {}
    edge(int from, int to, Info info) : from(from), to(to), info(info) {}
};

struct normal_edge {
    normal_edge() {}
};

template <class Info>
class graph {
   protected:
    using edge_type = edge<Info>;
    ::std::size_t N;
    ::std::vector<::std::vector<edge_type>> edges;

   public:
    graph(::std::size_t N_) : N(N_), edges(N_) {}
    virtual void add_edge(int x, int y, Info info) = 0;
    const ::std::vector<edge_type> &delta(int v) const {
        assert(v < N);
        return edges[v];
    }
    const ::std::vector<edge_type> &operator[](int v) const {
        return this->delta(v);
    }
    ::std::size_t size() const { return N; }
};

template <class Info>
class undirected_graph : public graph<Info> {
   public:
    undirected_graph(::std::size_t N) : graph<Info>(N) {}
    void add_edge(int x, int y, Info info) {
        this->edges[x].push_back(edge<Info>(x, y, info));
        this->edges[y].push_back(edge<Info>(y, x, info));
    }
};

template <class Info>
class directed_graph : public graph<Info> {
   public:
    directed_graph(::std::size_t N) : graph<Info>(N) {}
    void add_edge(int x, int y, Info info) {
        this->edges[x].push_back(edge<Info>(x, y, info));
    }
};

template <class Info>
class bipartite_graph : public undirected_graph<Info> {
    ::std::size_t A;
    ::std::size_t B;

   public:
    bipartite_graph(::std::size_t A_, ::std::size_t B_)
        : A(A_), B(B_), undirected_graph<Info>(A_ + B_) {}
    void add_edge(int x, int y, Info info) {
        undirected_graph<Info>::add_edge(x, y + A, info);
    }
};

template <typename T>
pair<vector<T>, vector<bool>> bellman_ford(graph<T> &g, int s) {
    const auto INF = numeric_limits<T>::max();
    const int N = g.size();
    vector<T> dist(N, INF);
    vector<bool> negative(N, false);
    dist[s] = 0;
    for(int i = 0; i < N - 1; i++) {
        for(int j = 0; j < N; j++) {
            for(auto &e : g[j]) {
                if(dist[e.from] == INF) continue;
                dist[e.to] = min(dist[e.to], dist[e.from] + e.info);
            }
        }
    }
    for(int i = 0; i < N; i++) {
        for(auto &e : g[i]) {
            if(dist[e.from] == INF) continue;
            if(dist[e.from] + e.info < dist[e.to]) negative[e.to] = true;
        }
    }
    for(int i = 0; i < N; i++) {
        for(int j = 0; j < N; j++) {
            for(auto &e : g[j]) {
                if(negative[e.from]) negative[e.to] = true;
            }
        }
    }
    return make_pair(dist, negative);
}

int main() {
    int N, M;
    cin >> N >> M;
    directed_graph<int_fast64_t> g(N);
    for(int i = 0; i < M; i++) {
        int a, b;
        int_fast64_t c;
        cin >> a >> b >> c;
        --a, --b;
        g.add_edge(a, b, -c);
    }
    auto ans = bellman_ford(g, 0);
    if(ans.second[N - 1])
        cout << "inf" << endl;
    else
        cout << -ans.first[N - 1] << endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
    ll n;
    cin>>n;
    vector<ll> a(n);
    rep(i,n){
        cin>>a[i];
    }
    ll i,j,k;
    ll co=0;
    sort(a.begin(),a.end());
    for(i=0;i<n-2;i++){
        for(j=i+1;j<n-1;j++){
            for(k=j+1;k<n;k++){
                if(a[i]+a[j]<=a[k]){
                    break;
                }
                co++;
            }
        }
    }
  cout<<co<<endl;
}

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

int main() {
  long int a, b, x;
  cin >> a >> b >> x;

  long int b_multiple = b / x ;
  long int a_multiple;

  if(a == 0){
    b_multiple = b / x + 1;
  }else{
    b_multiple = b / x ;
  } 

  if(a == 0){
    a_multiple =  0;
  }else{
    a_multiple =  (a - 1) / x;
  } 
  cout << b_multiple - a_multiple << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>

ll n,cnt,ans,a[ohara],b[ohara],c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

//------ 自分を天才だと信じる ------

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

    cin>>n;
    rep(i,n+1)cin>>a[i];
    rep(i,n)cin>>b[i];
    rep(i,n){
        tmp=min(a[i],b[i]);
        a[i]-=tmp;
        b[i]-=tmp;
        ans+=tmp;
        tmp=min(a[i+1],b[i]);
        a[i+1]-=tmp;
        b[i]-=tmp;
        ans+=tmp;
    }
    Cout(ans);
    return 0;
}


Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define pb push_back
#define fori(a,b) for(int i=a;i<b;i++)
#define forj(a,b) for(int j=a;j<b;j++)
#define ford(b,a) for(int i=b;i>=a;i--)
typedef pair<int, int> pi;
#define PI 3.14159265359
#define vi vector<int>
long long mod=1000000007;
//int count=INT_MAX;
 
struct hash_pair { 
    template <class T1, class T2> 
    size_t operator()(const pair<T1, T2>& p) const
    { 
        auto hash1 = hash<T1>{}(p.first); 
        auto hash2 = hash<T2>{}(p.second); 
        return hash1 ^ hash2; 
    } 
};

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int testcases=1;
    //cin>>testcases;
    //cout<<t;
    //scanf("%d",&t);
    while(testcases--){  
        ll n,d;
        cin>>n>>d;
        ll val=d*d;
        int c=0;
        fori(0,n){
            ll x,y;
            cin>>x>>y;
            ll dist=(x*x)+(y*y);
            //cout<<dist<<endl;
            if(dist<=val) c++;
        }
        cout<<c<<endl;
    }                                                                                          
    
    return 0;
}

Measured memory_bytes: 3652
# coding: utf-8
from sys import stdin
import sys

N = int(stdin.readline().rstrip())
Ws = [ stdin.readline().rstrip() for _ in range(N) ]

def main():
    for i in range(1,len(Ws)):
        if Ws.count(Ws[i]) > 1 or Ws[i-1][-1:] != Ws[i][0:1] :
            print("No")
            sys.exit()
    print("Yes")
if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
import java.util.*;
public class Main{
    public static void main(String[] args){
        new Main().run();
    }
    Scanner sc = new Scanner(System.in);
    long m, n;
    long INF = 1000000007;
    
    void run(){
        while(sc.hasNext()){
            m = sc.nextLong();
            n = sc.nextLong();
            if(m!=0 && n!=0) 
                System.out.println(solve(m, n));
        }
    }
    
    long solve(long m, long n){
        if(n==0)
            return 1;
        
        if(n%2==0){
            long a = solve(m, n/2);
            if(a>=INF) a %= INF;
            a = a*a;
            if(a>=INF) a %= INF;
            return a;
        }
        else{
            long a = solve(m, n/2);
            if(a>=INF) a %= INF;
            a = a*a%INF*m%INF;
            if(a>=INF) a %= INF;
            return a;
        }
    }
}

Measured memory_bytes: 17236
# 1の位が一番小さいものを最後に頼む（0を除く）

A_E = [input() for _ in range(5)]

# 1の位だけ抜き出して整数に
unit_place_lst = [int(x[-1]) for x in A_E]
min_except0 = 10
min_index = 0
for i, n in enumerate(unit_place_lst):
    if 0 < n < min_except0:
        min_except0 = n
        min_index = i

ans = 0
for i, x in enumerate(A_E):
    if i == min_index:
        ans += int(x)
    elif (int(x) % 10) == 0:
        ans += int(x)
    else:
        ans += int(x) - (int(x) % 10) + 10

print(ans)

Measured memory_bytes: 3188
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() /4;
const ll linf = numeric_limits<ll>::max() /4;
const ull ulinf = numeric_limits<ull>::max()/4;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////

int n,m,a,b,c,d[100005] = {};
string s,t;

int main(){
    cin >> n >> m;
	n--;
	m--;
	P(n*m);
	return  0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

#define MAX 200

using namespace std;

int main()
{
    string s, t;
    cin >> s;
    cin >> t;
    s += s;
    int fd = s.find(t);
    if (fd == -1)
    	cout << "No\n";
    else
    	cout << "Yes\n";
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int s,t,n; cin>>n;
	while(n--){
		cin>>s>>t;
		if(s<t){
			while(s!=t)cout<<s++<<" ";
			cout<<t<<endl;
		}else{
			if(0<=t&&t<=5){
				while(s!=t){
					cout<<s<<" ";
					s=s>5?s>8?5:s+1:s-1;
				}
				cout<<t<<endl;
			}else{
				while(s!=t){
					cout<<s++<<" ";
					if(s==10){
						s=6;
						cout<<"5 4 3 2 1 0 1 2 3 4 5 ";
					}
				}
				cout<<t<<endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    if(a==1&&b==2||a==2&&b==1)
        cout<<3<<endl;
    else if(a==1&&b==3||a==3&&b==1)
        cout<<2<<endl;
    else
        cout<<1<<endl;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int,int>


template <class T> void chmin(T&a, const T&b) { a = min(a,b); }
template <class T> void chmax(T&a, const T&b) { a = max(a,b); }

const double EPS =1e-9;
const long INF =2147483647;//32bit 2*1e+9
const long MOD =1e+9+7;
#define PI 3.14159265258979

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

int main(void){
	int a,b,h;
	cin>>a>>b>>h;
	cout<<(a+b)*h/2<<endl;
	return 0; 
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define cinf(n,x) for(int i=0;i<(n);I++) cin >> x[i];

int main(){
  int N,A[110];
  cin >> N;
  int ans;
  const int INF = 10000000000 ;
  int min = INF ;
  int max = 0 ;
  for(int i=0;i<N;i++){
    cin >> A[i] ;
    if(A[i] < min )
      min = A[i] ;
    if(A[i] > max)
      max = A[i] ;
  }
  ans = max - min ;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

vector<ll> ans;

int main(void){
	int n,k,i;
	ll s;
	cin >> n >> k >> s;
	for(i=0; i<k; ++i){
		ans.push_back(s);
	}
	if(s<3){
		++s;
	}else{
		--s;
	}
	for(i=k; i<n; ++i){
		ans.push_back(s);
	}
	for(i=0; i<n; ++i){
		cout << ((i)?" ":"") << ans[i];
	}
	cout << endl;
	return 0;
}


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

(T, A) = map(int, input().split())
H = list(map(int, input().split()))

mindiff = 1000000.0
ans = 0
for i in range(N):
    t = T-H[i]*0.006
    if abs(t-A) < mindiff:
        mindiff = abs(t-A)
        ans = i+1

print(ans)



Measured memory_bytes: 3060
#include<iostream>
#include<queue>
#include<vector>
#include<algorithm>
#include<functional>

using namespace std;
typedef pair<int, int> P;

int N, L;
int length[100000];

bool nobiruka(int x) {
	if (x < 0 || x >= N)return false;
	if (x == 0 && length[0] < length[1])return true;
	else if (x == N - 1 && length[N - 1] < length[N - 2])return true;
	else if (length[x] < length[x + 1] && length[x] < length[x - 1])return true;
	return false;
}

int main() {
	cin >> N >> L;
	for (int i = 0; i < N; i++)
		cin >> length[i], length[i] = L - length[i];
	priority_queue<P, vector<P>, greater<P>> pq;
	for (int i = 0; i < N; i++) {
		if (nobiruka(i))pq.push(P(length[i], i));
	}
	int ans = 0;
	while (pq.size()) {
		auto tmp = pq.top(); pq.pop();

		ans = tmp.first;

		length[tmp.second] = 10000000;

		if (nobiruka(tmp.second + 1)) {
			pq.push(P(length[tmp.second + 1] + ans, tmp.second + 1));
		}

		if (nobiruka(tmp.second - 1)) {
			pq.push(P(length[tmp.second - 1] + ans, tmp.second - 1));
		}

	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3876
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let a: Vec<isize> = (0..n).map(|_| iterator.next().unwrap().parse().unwrap()).collect();

    let mut s: Vec<isize> = vec![0; n + 1];
    for i in 1..(n + 1) {
        s[i] = s[i - 1] + a[i - 1];
    }

    let mut counts = std::collections::HashMap::new();
    for si in s {
        *counts.entry(si).or_insert(0_usize) += 1;
    }

    let mut ans: usize = 0;
    for (_, count) in counts {
        if count >= 2 {
            ans += count * (count - 1) / 2;
        }
    }
    return ans.to_string();
}


Measured memory_bytes: 21404
#include<iostream>
#define MAX(A,B) ((A>B)?A:B)
#define MIN(A,B) ((A<B)?A:B)
using namespace std;

long long a[110],n,maxn,minn;

int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	maxn=minn=a[1];
	for(int i=1;i<=n;i++){
		maxn=MAX(maxn,a[i]);
		minn=MIN(minn,a[i]);
	}
	cout<<maxn-minn;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class Program
{
    public static string ans;
    public static string[] a;
    static void Main(string[] args)
    {
        a = Console.ReadLine().Split();
        if(a[0][a[0].Length-1]==a[1][0]&&(a[1][a[1].Length-1]==a[2][0]))
        {
            ans = "YES";
        }
        else { ans = "NO"; }
        Console.WriteLine(ans);
    }
    
}

Measured memory_bytes: 11092
Sa = list(input())[::-1]
Sb = list(input())[::-1]
Sc = list(input())[::-1]

next_turn = Sa.pop()


while True:
    if next_turn == "a":
        if not Sa:
            print("A")
            quit()
        next_turn = Sa.pop()
    elif next_turn == "b":
        if not Sb:
            print("B")
            quit()
        next_turn = Sb.pop()
    elif next_turn == "c":
        if not Sc:
            print("C")
            quit()
        next_turn = Sc.pop()


Measured memory_bytes: 62040
import java.util.*;

public class Main{
	
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
  	int x=sc.nextInt(),y=sc.nextInt();
    if((x==1||x==3||x==5||x==7||x==8||x==10||x==12)&&(y==1||y==3||y==5||y==7||y==8||y==10||y==12)){
      System.out.println("Yes");
    }else if((x==4||x==6||x==9||x==11)&&(y==4||y==6||y==9||y==11)){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
    
  }
}


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

using namespace std;

int mark[200100];

int main()
{
	int n , m;
	cin >> n >> m;
	mark[1] = 1;
	mark[n] = 1;
	for(int i = 1; i <= m; i++)
	{
		int x , y;
		cin >> x >> y;
		if(x == 1 or x == n)
		{
			mark[y]++;
		}
		if(y == 1 or y == n)
		{
			mark[x]++;
		}
	}
	for(int i = 1; i <= n; i++)
	{
		if(mark[i] >= 2)
		{
			cout << "POSSIBLE";
			return 0;
		}
	}
	cout << "IMPOSSIBLE";
	
}

Measured memory_bytes: 1024
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;

public class Main {


    public static void main(String[] args) {
    	
        Scanner in = new Scanner(System.in);
        long n = in.nextInt();
        int m = in.nextInt();
        long ans = 0;
        
        if(m==0){
        	ans =n*n;
        }else{
        
        	for(int i=m+1;i<=n;i++){
        		ans += n/i*(i-m) + Math.max(n%i-(m-1), 0);
//        		System.out.println(n/i*(i-m) +" "+ Math.max(n%i-(m-1), 0));
        	}
        }
        
        System.out.println(ans);


        in.close();
    }
}


Measured memory_bytes: 21844
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

template<typename T>
istream& operator >> (istream& is, vector<T>& vs){
  for(T& v: vs) is >> v;
  return is;
}

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vs){
  for (const T& v : vs) os << v << " ";
  return os;
}

int main() {
  LL N; cin >> N;
  vector<LL> A(N); cin >> A;
  LL sum = accumulate(A.begin(), A.end(), 0LL);
  LL num = N * (N + 1LL) / 2LL;

  if (sum % num != 0) {
    cout << "NO" << endl;
    return 0;
  }
  LL k = sum / num;

  for (int i = 0; i < N; ++i) {
    LL d = A[(i + 1) % N] - A[i] - k;
    if (d > 0 || (-d) % N != 0) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
}


Measured memory_bytes: 3940
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long llong;
typedef unsigned long long ullong;

using namespace std;


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

	int ans = n * (n - 1) / 2 + m * (m - 1) / 2;
	cout << ans;
}

Measured memory_bytes: 256
MOD = 10 ** 9 + 7

n = int(input())
alst = list(map(int, input().split()))
total = sum(alst)
ans = 0
for a in alst:
    ans += a * (total - a)
    ans %= MOD
ans *= pow(2, MOD - 2, MOD)
ans %= MOD
print(ans)

Measured memory_bytes: 31436
MAX = 1000
prime = Array.new(1000001,true)
prime[0],prime[1] = false,false
(2..MAX).each do |i|
	j = i * i
	while j < 1000000 do
		prime[j] = false
		j += i
	end
end

while gets
	n = $_.to_i
	ans = 0
	(2..n).each do |i|
		ans += 1 if prime[i]
	end
	puts ans
end

Measured memory_bytes: 13904
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

 size_t strlen(const char *s);
#define rep(i,n) for(long long int i=0;i<n;i++)
#define sz(x) ((int)(x).size())

using namespace std;
std::vector<int> graph[10050];//graph頂点数のsize
const int N=200010;
const int P=1000000007;
using ll = long long;
vector<ll> prime;

//絶対値
int ze(int a, int b){
	if(a>b){
		return a-b;
	}else{
		return b-a;
	}
}
//小さい方
long long int min(long long int a,long long int b){
	if(a>b){
		return b;
	}else{
		return a;
	}
}
//大きい方
long long int max(long long int a,long long int b){
	if(a>b){
		return a;
	}else{
		return b;
	}
}
// a^n mod 
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

// a^{-1} mod 
long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

//mod掛け算
long long mt(long long a, long long b, long long mod){
	return (a*b)%mod;
}

//メモ

/*
	memset(b, '\0', sizeof(b));
初期化*/


/*
	string s;
	s.size()
*/

/*
	char s[N];
	strlen(s)
*/
/*
	if(  <  )puts("Yes");
	else puts("No");
*/

/*文字列比較
if(strcmp(name[i],s)==0)
*/

/*
	graph[a].push_back(b);//graph[a][i番目に入れた]==b
	graph[j].size()	//forで回すときとか

*/


int main(){
  ll x;
  cin>>x;
  bool finish=false;
  ll n=1000;
  for(ll i=-n;!finish&&i<n;i++){
    for(ll j=-n;!finish&&j<n;j++){
      if(i*i*i*i*i-j*j*j*j*j==x){
        cout<<i<<" "<<j<<endl;
        finish=true;
      }
    }
  }
}


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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

int ch[50][26];

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

  rep(i, n) {
    string s;
    cin >> s;
    rep(j, s.size()) ch[i][s[j] - 'a']++;
  }

  rep(i, 26) {
    int k = 10000;
    rep(j, n) k = min(k, ch[j][i]);
    rep(j, k) cout << char('a' + i);
  }
  cout << endl;
}


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <iterator>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <random>
#include <cassert>
#include <limits>

using namespace std;

#define mp make_pair
#define pb push_back
#define repi(i, p, q) for (long i = p; i < q; i++)
#define repd(i, p, q) for (long i = p; i >= q; i--)
#define sz(x) x.size()
#define INF 2000000000
#define MOD 1000000007

typedef map<int, int> MI;
typedef pair<int, int> PI;
typedef long long int LLI;
typedef long int LI;
typedef int I;

int main()
{
    int a[5];
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a + 3);
    cout << (a[1] + (10 * a[2]) + a[0]);
    return 0;
}

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

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define RFOR(i, a, b) for(int i=(a); i>=(b); i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define CEIL(n, m) ceil(n/pow(10.0, m))*pow(10.0, m)
#define FLOOR(n, m) floor(n/pow(10.0, m))*pow(10.0, m)
#define ROUND(n, m) round(n/pow(10.0, m))*pow(10.0, m)
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define RSORT(x) sort((x).begin(),(x).end(),greater<int>())
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define llong long long
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) " (L" << __LINE__ << ") " << __FILE__ << endl;

const int MOD = 1000000007;

void solve()
{
  int n; cin >> n;
  vector<int> a(n); REP(i, n) cin >> a[i];
  vector<int> d(ceil(n/2.0), 0);

  REP(i,n) {
    d[a[i]/2] += 1;
  }
  REP(i,ceil(n/2.0)) {
    if (i==0) {
      if (n%2==1&&d[i]!=1) {
        cout << 0 << endl;
        return;
      }
    } else {
      if (d[i]!=2) {
        cout << 0 << endl;
        return;
      }
    }
  }
  llong ans=1;
  REP(i,n/2) {
    ans *= 2;
    ans %= MOD;
  }

  cout << ans%MOD << endl;
}

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


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

int main(){
  int N;
  cin >> N;
  
  long int power = 1;
  int a = 1000000007;
  for(int i = 1; i <= N; i++){
    power = power * i % a;
  }
  cout << power << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>

using namespace std;

#define MAX 72

string ans;
char b[MAX][MAX];
int w,h;
vector<vector<string> > m;

static inline string maxstr(const string &a,const string &b){
  if(a.length()!=b.length()){
    if(a.length()>b.length()) return a;
    else return b;
  }else return max(a,b);
}

string memo(int x,int y,int d){
  if(x>=w||y>=h) return "";
  if(!isdigit(b[y][x])) return "";
  if(!m[y][x].empty()) return m[y][x];
  if(b[y][x]!='0') d++;
  m[y][x]=b[y][x]+maxstr(memo(x+1,y,d),memo(x,y+1,d));
  if(d==1&&b[y][x]!='0') ans=maxstr(ans,m[y][x]);
  return m[y][x];
}

int main(){
  while(scanf("%d%d ",&w,&h),w+h){
    m=vector<vector<string> >(h,vector<string>(w));
    for(int i=0;i<h;i++)
      cin>>b[i];
    ans="";
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
        if(!isdigit(b[i][j])||!m[i][j].empty()||(h-i+w-j)<ans.length())
	  continue;
        memo(j,i,0);
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
clock_t t=clock();
namespace my_std{
	using namespace std;
	#define pii pair<int,int>
	#define pli pair<ll,int>
	#define fir first
	#define sec second
	#define MP make_pair
	#define rep(i,x,y) for (int i=(x);i<=(y);i++)
	#define drep(i,x,y) for (int i=(x);i>=(y);i--)
	#define go(x) for (int i=head[x];i;i=edge[i].nxt)
	#define templ template<typename T>
	#define sz 101010
	typedef long long ll;
	typedef double db;
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	templ inline T rnd(T l,T r) {return uniform_int_distribution<T>(l,r)(rng);}
	templ inline bool chkmax(T &x,T y){return x<y?x=y,1:0;}
	templ inline bool chkmin(T &x,T y){return x>y?x=y,1:0;}
	templ inline void read(T& t)
	{
		t=0;char f=0,ch=getchar();double d=0.1;
		while(ch>'9'||ch<'0') f|=(ch=='-'),ch=getchar();
		while(ch<='9'&&ch>='0') t=t*10+ch-48,ch=getchar();
		if(ch=='.'){ch=getchar();while(ch<='9'&&ch>='0') t+=d*(ch^48),d*=0.1,ch=getchar();}
		t=(f?-t:t);
	}
	template<typename T,typename... Args>inline void read(T& t,Args&... args){read(t); read(args...);}
	char __sr[1<<21],__z[20];int __C=-1,__zz=0;
	inline void Ot(){fwrite(__sr,1,__C+1,stdout),__C=-1;}
	inline void print(register int x)
	{
		if(__C>1<<20)Ot();if(x<0)__sr[++__C]='-',x=-x;
		while(__z[++__zz]=x%10+48,x/=10);
		while(__sr[++__C]=__z[__zz],--__zz);__sr[++__C]='\n';
	}
	void file()
	{
		#ifdef NTFOrz
		freopen("a.in","r",stdin);
		#endif
	}
	inline void chktime()
	{
		#ifdef NTFOrz
		cout<<(clock()-t)/1000.0<<'\n';
		#endif
	}
	#ifdef mod
	ll ksm(ll x,int y){ll ret=1;for (;y;y>>=1,x=x*x%mod) if (y&1) ret=ret*x%mod;return ret;}
	ll inv(ll x){return ksm(x,mod-2);}
	#else
	ll ksm(ll x,int y){ll ret=1;for (;y;y>>=1,x=x*x) if (y&1) ret=ret*x;return ret;}
	#endif
//	inline ll mul(ll a,ll b){ll d=(ll)(a*(double)b/mod+0.5);ll ret=a*b-d*mod;if (ret<0) ret+=mod;return ret;}
}
using namespace my_std;

int n;
ll a[sz];
pli p[sz];
map<ll,int>mp;

int fa[sz],size[sz];
int getfa(int x){return x==fa[x]?fa[x]:fa[x]=getfa(fa[x]);}
void merge(int x,int y){x=getfa(x),y=getfa(y);fa[x]=y,size[y]+=size[x];}

pii ans[sz];

struct hh{int t,nxt;}edge[sz<<1];
int head[sz],ecnt;
void make_edge(int f,int t)
{
	edge[++ecnt]=(hh){t,head[f]};
	head[f]=ecnt;
	edge[++ecnt]=(hh){f,head[t]};
	head[t]=ecnt;
}

ll up[sz],dn[sz];
#define v edge[i].t
void dfs1(int x,int fa){size[x]=1;go(x) if (v!=fa) dfs1(v,x),dn[x]+=dn[v]+size[v],size[x]+=size[v];}
void dfs2(int x,int fa){go(x) if (v!=fa) up[v]=up[x]+dn[x]-(dn[v]+size[v])+(n-size[v]),dfs2(v,x);}
#undef v

int main()
{
	file();
	read(n);
	rep(i,1,n) read(a[i]),p[i]=MP(a[i],i),mp[a[i]]=i;
	sort(p+1,p+n+1);
	rep(i,1,n) fa[i]=i,size[i]=1;
	drep(k,n,2)
	{
		int x=p[k].sec;
		ll w=a[x]-(n-size[getfa(x)])+size[getfa(x)];
		if (!mp.count(w)||mp[w]==x) return puts("-1"),0;
		ans[k-1]=MP(x,mp[w]);
		merge(x,mp[w]);
		make_edge(x,mp[w]);
	}
	dfs1(1,0);dfs2(1,0);
	rep(i,1,n) if (up[i]+dn[i]!=a[i]) return puts("-1"),0;
	rep(i,1,n-1) printf("%d %d\n",ans[i].fir,ans[i].sec);
	return 0;
}

Measured memory_bytes: 20480
#include<stdio.h>
#include<string.h>
#include<math.h>
#define FOR(n) for(int i = 0;i < n;i++)
#define PRN(n) printf("%d\n",n)
#define PRS(s) printf("%s\n",s)
int max(int a,int b){
  if(a > b)return a;
  return b;
}
int min(int a,int b){
  if(a > b)return b;
  return a;
}
int zet(int a){
  if(a < 0)return -a;
  return a;
}
int main(void){
  int n,a,b;
  scanf("%d",&n);
  scanf("%d %d",&a,&b);
  PRN(min(b,a*n));
  return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

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

	int n;
	cin >> n;

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

	sort(begin(a), end(a), greater<int>());

	int diff = INF;
	int r = INF;
	for (int i = 1; i < n; i++) {
		if (diff > abs((a[0] / 2) - a[i])) {
			r = a[i];
			diff = abs((a[0] / 2) - a[i]);
		}
	}

	cout << a[0] << " " << r << endl;
	return 0;
}


Measured memory_bytes: 640
import java.io.*;
import java.math.*;
import java.util.*;
 
public class Main {
    private static boolean debug = false;
    private static boolean elapsed = false;
 
    private static PrintWriter _out = new PrintWriter(System.out);
    private static PrintWriter _err = new PrintWriter(System.err);
 
    private void solve(Scanner sc) {
        int N = sc.nextInt();
        int M = sc.nextInt();
        boolean[] flg = new boolean[N + 1];
        for (int i = 0; i < M; ++i) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            flg[a] = !flg[a];
            flg[b] = !flg[b];
        }
 
        for (int i = 0; i <= N; ++i) {
            if (flg[i]) {
                _out.println("NO");
                return;
            }
        }
        _out.println("YES");
    }
    private static BigInteger C(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        for (long i = r; i > 1; --i) {
            res = res.divide(BigInteger.valueOf(i));
        }
        return res;
    }
    private static BigInteger P(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        return res;
    }
    /*
     * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
     * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
     */
    public static void main(String[] args) {
        long S = System.currentTimeMillis();
 
        Scanner sc = new Scanner(System.in);
        new Main().solve(sc);
        _out.flush();
 
        long G = System.currentTimeMillis();
        if (elapsed) {
            _err.println((G - S) + "ms");
        }
        _err.flush();
    }
}

Measured memory_bytes: 64312
#include <bits/stdc++.h>
using namespace std;
using ll         = long long;
constexpr ll MOD = 1000000007;
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define REP2(i, x, n) for (ll i = x; i < (n); i++)
#define PR(x) cout << (x) << "\n"
#define PS(x) cout << (x) << " "
const long long INF = numeric_limits<long long>::max();

ll GCD(ll a, ll b) {
    if (a > b) swap(a, b);
    while (b != 0) {
        ll c = b;
        ll d = a % b;
        a    = c;
        b    = d;
    }
    return a;
}

int main() {
    ll N;
    cin >> N;

    ll ans = 0;
    REP(i, N) {
        ll x;
        cin >> x;
        ans = GCD(ans, x);
    }
    PR(ans);
    return 0;
}

Measured memory_bytes: 3576
n,m,c=list(map(int,input().split()))
b=list(map(int,input().split()))
counter=0

for _ in range(n):
  a=list(map(int,input().split()))
  x = [a[i]*b[i] for i in range(m)]
  if sum(x)+c > 0:
    counter +=1
    
print(counter)
    

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

using namespace std;

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

		int time = 1e9;
		for (int i = 0; i < N - K + 1; i++) {
				int t = min(abs(x[i]), abs(x[i+K-1])) + abs(x[i+K-1] - x[i]);
				if (time > t) time = t;
		}

		cout << time << endl;

		return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef unsigned long long ull;

const int MOD =  1000000007; //   1000000009 , 1000000023 ,1000000007 , 998244353
const ll INF = ll(1e18);
const ld PI = 4*atan((ld)1);

using namespace __gnu_pbds;
template<typename T, class cmp = std::less<T>>
using Tree = tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;

bool isprime(ll n){
  for(ll i=2 ; i*i<=n ; i++){
    if(n%i==0)return false;
  }
  return true;
}

int main() {
  #ifndef ONLINE_JUDGE
    freopen("input.txt" , "r" , stdin);
  #endif
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.precision(10);

  ll n;
  cin >> n;
  vector<ll>ar(n);
  for(auto &x:ar)cin >> x;
  ll res = 0;
  for(ll i=1 ; i<n ; i++){
    if(ar[i-1]<=ar[i])continue;
    res += ar[i-1] - ar[i];
    ar[i] = ar[i-1];
  }
  cout << res;
}


Measured memory_bytes: 4728
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
//#pragma GCC target("avx,tune=native")
#include<bits/stdc++.h>
#define int long long
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
inline string getstr(string &s,int l,int r){string ret="";for(int i=l;i<=r;i++)ret.push_back(s[i]);return ret;}
int modpow(int x,int y,int md=mod){if(y==0)return 1;int ret=modpow(x,y>>1,md);ret=(ll)ret*ret%md;if(y&1)ret=(ll)ret*x%md;return ret;}
int n,k;
inline int inv(int x){
	return modpow(x,mod-2,mod);
}
int dp[105][205*105];
int sum;
inline void add(int &x,int y){
	(x+=y)%=mod; 
}
inline void sub(int &x,int y){
	(x-=y)%=mod;(x+=mod)%=mod;
}
signed main(){
	cin>>n>>k;
	sum=n*modpow(k+1,n-1,mod)%mod*k%mod*(k+1)%mod*inv(2)%mod;
	dp[k+1][0]=1;
	for(int i=k+1;i>1;i--){
		for(int j=0;j<=200*100;j++){
			for(int v=0;v<=k;v++){
				if(v>i-1)add(dp[i-1][j],dp[i][j]);
				else add(dp[i-1][j+(j+v)/(i-1)],dp[i][j]);
			}
		}
	}
	for(int i=1;i<=200*100;i++){
		sub(sum,dp[1][i]*i%mod*modpow(k+1,n-k,mod)%mod);
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 17024
n, m, l =map(int, input().split())
A = []
B = []
C = []
for i in range(n):
    i = list(map(int, input().split()))
    A.append(i)

for i in range(m):
    i = list(map(int, input().split()))
    B.append(i)
#積を求める

for i in range(n):
    line = []
    for j in range(l):
        c = 0
        for k in range(m):
            c += A[i][k] * B[k][j]
        line.append(c)
    C.append(line)
#形式に合わせて出力する
for line in C:
    print(*line)


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------


string S,T;
int A,B;
int memo[3030][3030];

int dfs(int x,int y) {
	if(memo[x][y]>=0) return memo[x][y];
	if(x==A||y==B) return memo[x][y]=0;
	
	if(S[x]==T[y]) return memo[x][y]=dfs(x+1,y+1)+1;
	
	return memo[x][y]=max(dfs(x+1,y),dfs(x,y+1));
	
	
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	MINUS(memo);
	cin>>S>>T;
	A=S.size();
	B=T.size();
	
	dfs(0,0);
	
	x=y=0;
	while(x<A && y<B) {
		if(memo[x][y]==0) break;
		if(S[x]==T[y]) {
			cout<<S[x];
			x++;
			y++;
		}
		else if(memo[x+1][y]>memo[x][y+1]) {
			x++;
		}
		else {
			y++;
		}
	}
	cout<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 36352
// #include <bits/stdc++.h>
#include <string>
#include <iostream>
using namespace std;
#define f(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define rf(i, a, b) for (int(i) = (a)-1; (i) >= (b); (i)--)
#define CLEAR(a) memset((a), 0, sizeof(a))
#define INF 1000000000
#define lli long long int
#define ull unsigned long long int
#define ALL(c) (c).begin(), (c).end()

#define mod 1000000007

int abs(int a, int b)
{
    return a - b < 0 ? b - a : a - b;
}
int main(void)
{
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif
    int n;
    cin >> n;
    int a[n],count=0;
    f(i, 0, n) cin >> a[i];
    f(i, 0, n) f(j, i + 1, n) f(k, j + 1, n) if (a[i] + a[j] > a[k] && a[i] + a[k] > a[j] && a[k] + a[j] > a[i] && a[i] != a[j] && a[i] != a[k] && a[k] != a[j]) count++;
    cout<<count;
    return 0;
}


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


def solve(N: int, S: str):
    p = S[0]
    r = [S[0]]
    for i in range(1, N):
        if p != S[i]:
            r.append(S[i])
            p = S[i]
    return r


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    print(len(solve(N, S)))

if __name__ == '__main__':
    main()


Measured memory_bytes: 4072