akhauriyash/Code-Regression huggingface dataset:
#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>
#define pq priority_queue<ll>
#define rpq priority_queue<ll,vector<ll>,greater<ll>>
#define p_b push_back
    
ll n,cnt,a,b,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;};
U_MAP mp;
V ans;
    
//-------------------------↓↓↓↓↓↓------------------------
    
//------ 自分を天才だと信じる ------
    
int main(void){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>a>>b>>k;
    rrep(i,a,min(a+k,b+1)){
        if(mp[i]==1)continue;
        mp[i]=1;
        ans.p_b(i);
    }
    rrrep(i,b,max(b-k+1,a)){
        if(mp[i]==1)continue;
        mp[i]=1;
        ans.p_b(i);
    }
    sort(all(ans));
    rep(i,Size(ans))Cout(ans[i]);
    return 0;
}

Measured memory_bytes: 892
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define INF 1<<30
#define LINF 1LL<<60

/*
<url:http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2239>
?????????============================================================
????????????????????????????????±?????????n ????????£?????????. ?????±????????????????????????0 ??????n ??? 1 ?????§???????????????????????????, 
k ???????????±?????????????????¨, p???a^k + q???b^k ?§????????????¨?????§??????.

??????????????????????§???????m ?§???????????§???????????????????????£??????????????????????????????????,???????????????????????¢??????????????????.
?§????????????????????????§??????.
?????±?????????????????????????????§???????????¨???????????¨????????¨???, ????????????????°?????§???????????????§??????????????????.

1 ??? n, m, a, b, p, q ??? 10^12 (??´??°)
=================================================================
?§£??¬=============================================================
================================================================
*/

ll powmod(ll a, ll b) { ll res = 1; assert(b >= 0); for (;b;b >>= 1) { if (b & 1)res = res*a;a = a*a; }return res; }
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
	ll n, m, a, b, p, q; cin >> n >> m >> a >> b >> p >> q;
	ll res = m;
	if (a == 1 && b == 1) {
		ll k = m / (p + q);
		res = min({ m,abs(m - min(k,n)*(p + q)),abs(min((k + 1),n)*(p + q) - m )});
	}else {
		ll N = min(40LL, n);
		vector<ll> dist;
		for (int i = 0; i < N;i++) {
			ll d = p * powmod(a, i) + q*powmod(b, i);
			if (d > 2 * m)break;
			dist.push_back(d);
		}
		int n1 = (int)dist.size() / 2;
		int n2 = (int)dist.size() - n1;
		vector<ll> L;
		for (int i = 0; i < (1 << n1);i++) {
			ll T = 0;
			for (int j = 0; j < n1;j++) {
				if ((i >> j) & 1) {
					T += dist[j];
				}
			}
			if (T > 2 * m)continue;
			L.push_back(T);
		}
		sort(L.begin(), L.end());
		for (int i = 0; i < (1 << n2);i++) {
			ll T = 0;
			for (int j = 0; j < n2;j++) {
				if ((i >> j) & 1) {
					T += dist[n1 + j];
				}
			}
			if (T > 2 * m)continue;
			auto it = lower_bound(L.begin(), L.end(), m - T);
			if(it != L.end())res = min(res, abs(m - T - *it));
			if (it != L.begin()) res = min(res, abs(m - T - *(it - 1)));
		}
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 11264
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

// verified : http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_1_A
// 負辺があると動作しない?
// O(E log V)
vector<lint> h;

template<typename T>
vector<T> dijkstra(vector<vector<pair<int, T>>> &g, int s, lint x){
     
  int n = g.size();
  // numeric_limits がうまく使えない場合は自分で INF を定義する.
  const auto inf = INF;
  vector<T> dist(n, inf);

  using P = pair<T, int>;
  // 小さい順に取り出せる
  priority_queue<P, vector<P>, greater<P>> que;
  dist[s] = 0;
  que.emplace(dist[s], s);
  while(!que.empty()){
    T cost;
    int node;
    tie(cost, node) = que.top();
    que.pop();
    if(dist[node] < cost) continue;
    for(auto &e : g[node]){
      int next_node = e.first;

      // node -> next_node へ飛びたい
      // 現在の移動距離は cost
      // ってことは，今いる場所は
      lint curH = max(0LL, x - cost);

      lint next_cost;
      lint nxtH = curH - e.second;
      if (nxtH > h[next_node]) {
        next_cost = cost + e.second + nxtH - h[next_node];
      } else if (nxtH >= 0) {
        next_cost = cost + e.second;
      } else if (nxtH < 0) {
        if (curH - nxtH > h[node]) continue;
        next_cost = cost + e.second - nxtH;
      } else assert(false);
      // auto next_cost = cost + e.second;

      if(dist[next_node] <= next_cost) continue;
      dist[next_node] = next_cost;
      que.emplace(next_cost, next_node);
    }
  }

  return dist;
}

/* do your best */

int main() {

  lint n, m; cin >> n >> m;
  lint x; cin >> x;
  h.resize(n);
  for (int i = 0; i < n; i++) {
    cin >> h[i];
  }

  vector<vector<pair<int, lint>>> g(n);
  for (int i = 0; i < m; i++) {
    int a, b;
    lint t;
    cin >> a >> b >> t;
    a--;
    b--;

    g[a].push_back({b, t});
    g[b].push_back({a, t});
  }


  lint dist = dijkstra(g, 0, x)[n - 1];
  lint curH = max(0LL, x - dist);

  dist += h[n - 1] - curH;
  assert(h[n - 1] - curH >= 0);
  if (dist >= INF) dist = -1;

  cout << dist << endl;

  return 0;
}



Measured memory_bytes: 23092
/* Hello darkness my old friend, I've come to visit you again! */

#include<bits/stdc++.h>
#define lli long long int
#define FOR(i,a,b) for(i=a;i<b;i++)
#define FORB(i,b,a) for(i=b;i>=a;i--)
#define mod 1000000007
#define PI 2*acos(0.0)
#define gs getline(cin,s)
#define pii pair<int,int>
#define pli pair<long long int,int>
#define pil pair<int,long long int>
#define pll pair<long long int,long long int>
#define pb push_back
#define eb emplace_back
#define mem(a,b) memset(a,b,sizeof(a))
#define inf 1000000005
#define INF 1000000000000000005
#define io ios_base::sync_with_stdio(0);
#define ff first
#define ss second
using namespace std;

int main()
{
    io;
    cin.tie(0);
    cout.tie(0);
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(abs(c-a)<=d || (abs(b-a)<=d && abs(c-b)<=d))
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}

/* This is the end, beautiful friend! */


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }


int
main(void){  
  int n;
  ll a;
  cin >> n;

  map<ll, int> mp;
  
  REP(i, n){
    cin >> a;
    ++mp[a];
  }

  int count = 0;
  for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
    if(itr->second%2 == 1) ++count;
  }

  cout << count << endl;
  
  return 0;
}


Measured memory_bytes: 6528
#include <iostream>
#include <string.h>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;

long rain(int i, int n, vector< int> c, unsigned long long sum_ ) {
	for (int k = 0; k < (n - 1) / 2; k++) {
		sum_ -= c.at((2*k + 1 + i)%n);
	}
	return 2*sum_;
}
int main(){
	int n;
	unsigned long long sum = 0;
	cin >> n;
	vector< int> a;
	for (int i = 0; i < n; i++) {
		int h;
		cin >> h;
		a.push_back(h);
		sum += h;
	}
	sum /= 2;
		cout << rain(0, n, a, sum) << "\n";
		int pred = rain(0, n, a, sum) / 2;
		for (int i = 0; i < n-1; i++) {
			pred = a.at(i) - pred;
			cout << pred*2 << "\n";
	}
};


Measured memory_bytes: 2032
-- ABC 136 A
import Data.Maybe
import Data.Char
import Data.Bool
import Data.List
import qualified Data.ByteString.Char8 as BS
import qualified Data.Vector.Unboxed as VU

main :: IO()
main = do
  [a, b, c] <- getIntList
  print $ solve a b c

solve :: Int -> Int -> Int -> Int
solve a b c = bool id (const 0) =<< (<0) $ c - (a - b)

-- ByteStringを用いた入力
readInt = fst . fromJust . BS.readInt

-- 空白区切りの整数列をListで受け取る
getIntList = unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

Measured memory_bytes: 380
use text_io::*;
use std::collections::*;
use std::process::exit;
use std::cmp::max;

fn main() {
    let mut n:usize = read!();
    let mut sum = 0;
    for i in 1..n+1 {
        if i<10||(100<=i&&i<1000)||(10000<=i&&i<100000) {
            sum+=1;
        }
    }
    println!("{}",sum);
}

Measured memory_bytes: 2084
#include <iostream>
#include <algorithm>


using namespace std;

int main(void){
    int n;
    cin >> n;
    long a[3*n];
    
    for (int i = 0; i < 3 * n; i++) cin >> a[i];
    
    sort(a, a + 3 * n, greater<long>());
    
    long sum = 0;
    for (int i = 1; i < 2*n; i+=2){
        sum += a[i];
        // cout << a[i] <<endl;
    }
    cout << sum << endl;
    return 0;
}



Measured memory_bytes: 2560
import java.util.*;

public class Main {    
    
  public static void main(String[] args) {
   
     Scanner sc = new Scanner(System.in);          
      
     int N = sc.nextInt();
     
     int a[] = new int[N];
     
     for(int i = 0;i < N;i++){
      a[i] = sc.nextInt();
     }
     
     Arrays.sort(a);
     
     int start = a[0];
     int end   = a[N-1];
     
     int sum = Integer.MAX_VALUE;
     
     for(int i = start;i <= end;i++){         
         int ans = 0;
         for(int j = 0;j < N;j++){
             ans += (a[j] - i)*(a[j] - i);
         }
         sum = Math.min(sum,ans);
     }
     
     System.out.println(sum);
     
  }                            
}
    

Measured memory_bytes: 23764
#include<iostream>
#include<cstring>
#include<cstdio>
#include<vector>
#define MN 100000
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
    return x*f;
}
int num[MN+5],tot,n;
int main()
{
    n=read();
    for(int i=1;i<=n;++i) ++num[read()];
    for(int i=1;i<=MN;++i) tot+=max(0,num[i]-1);
    if(tot&1) printf("%d\n",n-tot-1);
    else printf("%d\n",n-tot);
    return 0;
}


Measured memory_bytes: 640
from scipy.sparse import*
i=lambda:map(int,input().split())
f=csgraph.floyd_warshall
I=9e9
n,m,l=i()
d=eval('[I]*-~n,'*-~n)
exec('a,b,c=i();d[a][b]=c;'*m)
d=f(d,0)
d[d>l]=I
d[d<I]=1
d=f(d)
d[d>I]=I
q,=i()
while q:s,t=i();print(int(d[s,t]%I)-1);q-=1

Measured memory_bytes: 352788
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include<functional>
#include <tuple>
#include <map>
#include<set>
#include <cmath>
#include <stack>
#include<cstdio>
#include<stdio.h>
using namespace std;

int main() {
	int a, b, c, cnt=0;
	cin >> a >> b >> c;
	while (a%2==0&&b%2==0&&c%2==0) {
		if (a == b && a== c) { cnt = -1;break; }
		int d = a, e = b, f = c;
		a = e / 2 + f / 2;
		b = d / 2 + f / 2;
		c = d / 2 + e / 2;
		cnt += 1;
	}
	cout << cnt << endl;
}

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

namespace Contest
{
    class Program
    {
        static int Main(string[] args)
        {
            new Program().Process();

            return 0;
        }

        private CommonInput cin;

        private void Process()
        {
            this.cin = new CommonInput();

            int n;
            string line = "";
            string output;
            string[] buf = new string[10] { "", ".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz" };
            int[] nBuf = new int[10] { 0, 5, 3, 3, 3, 3, 3, 4, 3, 4 };
            int num;

            n = this.cin.GetNextToInt();

            for (int i = 0; i < n; i++)
            {
                output = "";
                line = this.cin.GetNext();

                for (int j = 0; j < line.Length; j++)
                {
                    num = int.Parse(line[j].ToString());
                    var y = line.Skip(j).TakeWhile(x => x == line[j]).ToArray();
                    if (num != 0)
                        output += buf[num][(y.Length - 1) % nBuf[num]].ToString();
                    j += y.Length - 1;
                }

                Console.WriteLine(output);
            }
        }
    }

    public class CommonInput
    {
        public CommonInput()
        {
            this._s = new string[0];
            this._i = 0;
        }

        public string Line { get; set; }
        private string[] _s;
        private int _i;
        private char[] _sep = { ' ' };

        public void GetLine()
        {
            this._i = 0;
            do
            {
                this.Line = Console.ReadLine();
            } while (this.Line == "");

            if (this.Line != null)
                this._s = this.Line.Split(this._sep, StringSplitOptions.RemoveEmptyEntries);
        }

        public string GetNext()
        {
            if (this._i < this._s.Length)
                return this._s[this._i++];

            this.GetLine();

            return this._s[this._i++];
        }

        public int GetNextToInt()
        {
            return int.Parse(this.GetNext());
        }

        public long GetNextToLong()
        {
            return long.Parse(this.GetNext());
        }

        public double GetNextToDouble()
        {
            return double.Parse(this.GetNext());
        }
    }
}

Measured memory_bytes: 5908
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

ll MOD = (ll)pow(10, 9) + 7;

ll power_mod(ll bs, ll ex){
  if(ex == 0){
    return 1;
  } else{
    if(ex % 2 == 0){
      return power_mod((bs % MOD) * (bs % MOD), ex / 2) % MOD;
    } else{
      return (bs % MOD) * power_mod((bs % MOD), ex - 1) % MOD;
    }
  }
}

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

  vl fact(N + 1, 0);
  vl fact_inv(N + 1, 0);

  fact[0] = 1;
  rep2(i, 1, N + 1) fact[i] = fact[i - 1] * i % MOD;

  fact_inv[N] = power_mod(fact[N], (ll)pow(10, 9) + 5);
  rep_inv(i, N - 1, -1) fact_inv[i] = fact_inv[i + 1] * (i + 1) % MOD;

  ll comb1, comb2, ans;

  rep2(i, 1, K + 1){
    if(N - K + 1 < i){
      cout << 0 << "\n";
    } else{
      comb1 = fact[K - 1] * fact_inv[i - 1] % MOD * fact_inv[K - i] % MOD;
      comb2 = fact[N - K + 1] * fact_inv[i] % MOD * fact_inv[N - K + 1 - i] % MOD;
      
      ans = comb1 * comb2 % MOD;
      
      cout << ans << "\n";
    }    
  }
  
  return 0;
}


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

int main() {
	string s;
	cin >> s;
	int ans = 110;
	for (char a = 'a'; a <= 'z'; a++) {
		string t = s, now = "";
		for (int i = 0; i < s.size(); i++) {
			bool flag = true;
			for (int j = 0; j < t.size() - 1; j++) {
				if (t[j] != a && t[j + 1] == a)now = now + a;
				else now = now + t[j];
				if (t[j] != a && t[j + 1] != a)flag = false;
			}
			if (flag == true) {
				ans = min(i, ans);
				//if(ans == s.size() - i)cout << a << endl;
				break;
			}
			t = now, now = "";
		}
	}
	if (ans == 0)cout << ans << endl;
	else cout << ans + 1 << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
using namespace std;
#define DEBUG(x) cout<<#x<<"="<<x<<endl
#define DEBUG2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl
typedef long long ll;
class Cake{
public:
    ll x,y,z;
    Cake(){}
    Cake(ll xx,ll yy,ll zz)
    :x(xx),y(yy),z(zz){}
};
ll u,v,w;
vector<Cake>cks;
bool cmp(Cake &c1,Cake &c2){
    return c1.x*u+c1.y*v+c1.z*w>c2.x*u+c2.y*v+c2.z*w;
};
int main()
{
    // freopen("in.txt","r",stdin);
    ios::sync_with_stdio(false);
    int N,M;
    cin.tie(0);
    cin>>N>>M;
    for(int t=0;t<N;t++){
        ll x,y,z;
        cin>>x>>y>>z;
        cks.push_back(Cake(x,y,z));
    }
    ll ans=-1e18;
    for(u=-1;u<=1;u+=2)
    for(v=-1;v<=1;v+=2)
    for(w=-1;w<=1;w+=2){
        sort(cks.begin(),cks.end(),cmp);
        ll xsum=0,ysum=0,zsum=0;
        for(int t=0;t<M;t++){
            xsum+=cks[t].x
            ,ysum+=cks[t].y
            ,zsum+=cks[t].z;
        }
        ans=max(ans,u*xsum+v*ysum+w*zsum);
    }
    cout<<ans;
}

Measured memory_bytes: 256
import collections

N = int(input())
A = list(map(int, input().split()))

sum = 0
sumA = []
for a in A:
    sum += a
    sumA.append(sum)

colA = collections.Counter(sumA)

ans = 0
for key, val in colA.items():
    if key == 0:
        ans += val*(val+1)//2
    else:
        ans += (val-1)*val//2

print(ans)


Measured memory_bytes: 41720
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i <(n) ; ++i)
#define PI 3.14159265
#define pb push_back
#define pr pair<int,int>
using namespace std;
using ll = long long;
// using mod = 1000000000 + 7;
void self_max(int &a,int b){
	a = max(a,b);
}

void self_min(int &a,int b){
	a = min(a,b);
}
int main(){
	int a,b,c; cin >> a >>b >> c;

	int a1 = min(a,min(b,c));
	int a3 = max(a,max(b,c));
	int a2 = a + b + c - a1 - a3;

	cout << a1 << " " << a2 << " " << a3 << endl; 

	return 0;
}



Measured memory_bytes: 3088
#include<stdio.h>
int main(){
  int a,b;
  scanf("%d %d",&a,&b);
  int cnt = a + b;
  char s[a + b + 2];
  scanf("%s",&s);
  for(int i = 0;i < a + b + 1;i++){
    if(i != a && 47 < s[i] && s[i] < 58){
      cnt--;
    }
  }
  if(s[a] == '-' && cnt == 0){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  return 0;
}

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

int main()
{
    int n, *a, max[2]{};
    scanf("%d", &n);
    a = new int[n];
    for (int i = 0; i < n; i++)
    {
        scanf("%d", a + i);
    }
    {
        auto tmp = std::max_element(a, a + n);
        max[1] = *tmp;
        *tmp *= 2;
    }
    int med = max[1] / 2;
    for (int i = 0; i < n; i++)
    {
        if (std::abs(med - a[i]) < std::abs(med - max[0]))
            max[0] = a[i];
    }
    printf("%d %d\n", max[1], max[0]);

    delete[] a;
    return 0;
}

Measured memory_bytes: 640
package main

import "fmt"

func main() {
	var n, m, c int
	fmt.Scan(&n, &m, &c)
	br := make([]int, m)
	for i := range br {
		fmt.Scan(&br[i])
	}
	ans := 0
	for i := 0; i < n; i++ {
		sum := 0
		for j := 0; j < m; j++ {
			var a int
			fmt.Scan(&a)
			sum += a * br[j]
		}
		if sum+c > 0 {
			ans++
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
vector<pair<int,int> >G;
int dp[1001][1001];
int n;
main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		int a,b;cin>>a>>b;
		G.push_back(make_pair(b,a));
	}
	sort(G.begin(),G.end());
	for(int i=0;i<=n;i++)
	{
		for(int j=0;j<=n;j++)
		{
			dp[i][j]=1<<28;
		}
	}
	dp[0][0]=0;
	for(int i=0;i<n;i++)
	{
		dp[i+1][n]=dp[i][n];
		for(int j=n-1;j>=0;j--)
		{
			dp[i+1][j]=dp[i][j];
			if(dp[i][j]+G[i].second<=G[i].first)
				dp[i+1][j+1]=min(dp[i+1][j+1],dp[i][j]+G[i].second);
		}
	}
	int ans=0;
	for(int i=0;i<=n;i++)
	{
		if(dp[n][i]!=1<<28)ans=i;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3156
N, H = map(int, input().split())
ls = []
for i in range(N):
  a, b = map(int, input().split())
  ls += [(a,-b)]
ls.sort(key=lambda x:x[0])
a = ls[-1][0]
ls.sort(key=lambda x:x[1])
ans = 0
for i in range(N):
  if ls[i][1]>=-a:
    break
  H += ls[i][1]
  ans += 1
  if H<=0:
    print(ans)
    break
if H>0:
  n = H//a if H%a==0 else H//a+1
  ans += n
  print(ans)

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

//#pragma GCC optimize("O3")
//#pragma GCC target("sse4")

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ITER(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a))

#define SZ(a) (int)((a).size())
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = (LL)INF * INF;

const int mod = 998244353;
const int MAX = 1 << 18;

int add(int a, int b)
{
	return a + b < mod ? a + b : a + b - mod;
}

int sub(int a, int b)
{
	return a - b >= 0 ? a - b : a - b + mod;
}

int mult(int a, int b)
{
	return (LL)a * b % mod;
}

int n;
string s;
int pw[MAX];
int cnt[MAX];

void upd(int d)
{
	if((n / d) % 2 == 0)
		return;
	FOR(i, 0, d)
		if(s[i] == '1')
			cnt[d] = add(cnt[d], pw[d - 1 - i]);
	string t = s.substr(0, d), r(d, '0');
	FOR(i, 0, d)
		r[i] = t[i] == '1' ? '0' : '1';
	string q;
	FOR(i, 0, n / d)
	{
		if(i & 1)
			q += r;
		else
			q += t;
	}
	if(q <= s)
		cnt[d] = add(cnt[d], 1);
}

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> n >> s;
	pw[0] = 1;
	FOR(i, 1, n)
		pw[i] = add(pw[i - 1], pw[i - 1]);
	for(int i = 1; i * i <= n; i++)
		if(n % i == 0)
		{
			upd(i);
			if(i * i < n)
				upd(n / i);
		}
	FOR(i, 2, n + 1)
		if(n % i == 0)
			for(int j = 1; j * j <= i; j++)
				if(i % j == 0)
				{
					cnt[i] = sub(cnt[i], cnt[j]);
					if(j * j < i && j > 1)
						cnt[i] = sub(cnt[i], cnt[i / j]);
				}
	int ans = 0;
	FOR(i, 1, n + 1)
		ans = add(ans, mult(2 * i, cnt[i]));
	cout << ans << "\n";
	return 0;
}


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

int main() {
  string s;
  
  cin >> s;
  
  int count = 0;
  int flag = 0;
  
  
  for(int i =0;i<s.size(); i++){
    if(s.at(i) == 'A' || s.at(i) == 'C' || s.at(i) == 'G' || s.at(i) == 'T'){
      flag++;
      count = max(count,flag);
    }
    else{
      flag = 0;
    }  
  }
  cout << count;

}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
#include<stack>
using namespace std;
#define int long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define dup(x,y) (((x)+(y)-1)/(y))
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e18;
const long double PI = (acos(-1));


signed main() {
	int N, K;
	cin >> N >> K;
	vector<int>V(N);
	rep(i, N)cin >> V[i];
	int sum = 0;
	rep(i, N)sum += V[i];
	vector<int>d(N + 1);
	d[0] = 0;
	rep(i, N)d[i + 1] += d[i];
	int ans = 0;
	for (int i = 1; i <= K; i++) {  // 操作を行う回数
		for (int j = 0; j <= i / 2; j++) {  // 詰める操作を行う回数
			int take = i - j;  // 取り出す回数
			if (take < j)continue;
			if (take > N)continue;
			for (int k = 0; k < N; k++) {
				priority_queue<int, vector<int>, greater<int>>q;
				int sum = 0;
				bool isOK = false;
				for (int l = 0; l < take; l++) {
					sum += V[(k + l) % N];
					q.push(V[(k + l) % N]);
					if ((k + l) % N == 0 || (k + l) % N == N - 1)isOK = true;
				}
				if (!isOK)continue;
				for (int l = 0; l < j; l++) {
					sum -= q.top();
					q.pop();
				}
				chmax(ans, sum);
			}
		}

	}
	cout << ans << endl;
}

Measured memory_bytes: 3612
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
using namespace std;

int main()
{
	unsigned long long N, K;
	cin >> N >> K;

	auto result = 0ull;
	for (auto i = 1; i <= N; ++i)
	{
		auto temp = (i % K);
		if (temp * 2 == K || temp == 0)
		{
			auto count = (N + temp) / K;
			result += count * count;
		}
	}

	cout << result << endl;

	return 0;
}


Measured memory_bytes: 256
// SeeAlso: 

#include <bits/stdc++.h>

using namespace std;

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

#define MAX 100000
#define NIL -1
#define MOD 1000000007

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

#define debug(x) cout<<#x<<": "<<x<<endl
#define debig_vec(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

// 最大公約数
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
// 最小公倍数
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

#define print2D(h, w, arr) rep(i, h) { rep(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << setprecision(12) << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }

int main() {
    ll n;
    cin >> n;
    ll a[n];
    ll buka[n];
    memset(buka, 0, sizeof(buka));
    rep(i, n-1) {
        ll t;
        cin >> t;
        buka[t-1]++;
    }

    rep(i, n) {
        print(buka[i]);
    }
    return 0;
}


Measured memory_bytes: 5184
#include<bits/stdc++.h>
using namespace std;
typedef complex<double> P;
 
double eps = 1e-9;
 
string ccw(P a,P b,P c){
  P ab=b-a;
  P ac=c-a;
  P k=ac/ab;
  if( k.imag() > eps ){
    return "COUNTER_CLOCKWISE";
  }
  if( k.imag() < -eps ){
    return "CLOCKWISE";
  }
  if( k.real() < -eps ){
    return "ONLINE_BACK";
  }
  if( 1+eps < k.real() ){
    return "ONLINE_FRONT";
  }
  return "ON_SEGMENT";
}
 
int main(){
 
  double x0,y0,x1,y1,x2,y2;
  cin>>x0>>y0>>x1>>y1;
  P a(x0,y0);
  P b(x1,y1);
  int n;
  cin>>n;
  while(n--){
    cin>>x2>>y2;
    P c(x2,y2);
    cout<< ccw(a,b,c) <<endl;
  }
  return 0;
}

Measured memory_bytes: 1244
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repo(i, n) for(int i=1; i<=n; i++)
#define MAX 200005
#define INF 1001001001

using namespace std;
using ull = unsigned long long;
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;

int main(){
  int d, g;
  cin >> d >> g;
  vector<int> p(d);
  vector<int> c(d);
  rep(i, d){
    cin >> p[i] >> c[i];
  }


  priority_queue<ll> PQ;
  for(int bit=0; bit< (1<<d); bit++){
    vector<bool> uncomplete(d);
    ll sum=0;
    ll ans=0;
    rep(i, d){
      if(bit&(1<<i)){
        sum+=c[i]+p[i]*100*(i+1);
        ans+=p[i];
      } else {
        uncomplete[i]=true;
      }
    }
    int j=d-1;
    for(int j=d-1; j>=0 && sum<g; j--){
      if(uncomplete[j]){
        int num=(g-sum-100)/(100*(j+1))+1;
        if(num<=p[j]-1){
          ans+=num;
          sum+=100*(j+1)*num;
          break;
        } else {
          ans+=p[j]-1;
          sum+=100*(p[j]-1);
        }
      }
    }
    if(sum<g)continue;
    PQ.push(-ans);
  }
  cout << -PQ.top() << endl;
  return 0;
}


Measured memory_bytes: 256
def main():
    n,m,x = map(int,input().split())
    costs = [0] * n
    level_up = [[] for _ in range(n)]


    for i in range(n):
        c,*exp = map(int,input().split())
        #print(exp)
        costs[i] = c
        level_up[i] = list(exp)

    mn = 99999999999999999999999999999999999999999999999

    for i in range(2 ** n):
        cost = 0
        x_check = [0] * m
        for j in range(n):
            if i >> j & 1:
                cost += costs[j]
                for k,point in enumerate(level_up[j]):
                    x_check[k] += point
        #print(cost,x_check)
        if all(map(lambda o:o>=x,x_check)):
            mn = min(mn,cost)

    if mn == 99999999999999999999999999999999999999999999999:
        print(-1)
    else:
        print(mn)





if __name__ == '__main__':
    main()


Measured memory_bytes: 9232
#include <iostream>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <string>
#include <cmath>
#include <math.h>
using namespace std;

class Dice{
public:
	int face[6];
	Dice(){}
	void north(){
		int t=face[0];
		face[0]=face[1];
		face[1]=face[5];
		face[5]=face[4];
		face[4]=t;
	}
	void south(){
		int t=face[0];
		face[0]=face[4];
		face[4]=face[5];
		face[5]=face[1];
		face[1]=t;
	}
	void east(){
		int t=face[0];
		face[0]=face[3];
		face[3]=face[5];
		face[5]=face[2];
		face[2]=t;
	}
	void west(){
		int t=face[0];
		face[0]=face[2];
		face[2]=face[5];
		face[5]=face[3];
		face[3]=t;
	}
};

int main(){
	int nums[6];
	Dice dice = Dice();
	for(int i=0; i<6; i++){
		cin >> dice.face[i];
	}
	string order;
	cin >> order;
	for(int i=0; i < order.size(); i++){
		if(order[i]=='N'){
			dice.north();
		}else if(order[i]=='S'){
			dice.south();
		}else if(order[i]=='E'){
			dice.east();
		}else if(order[i]=='W'){
			dice.west();
		}
	}

	printf("%d\n",dice.face[0]);
}


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

// Loops
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define _rrep(i, n) rrepi(i, n, 0)
#define rrepi(i, a, b) for (int i = int(a) - 1; i >= int(b); --i)

#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__, rrepi, _rrep, )(__VA_ARGS__)
#define each(xi, x) for (auto &&xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)

// typedef
template <class T> using vec = vector<T>;
using ll = long long;
using vi = vec<ll>;
using vvi = vec<vi>;
using vvvi = vec<vvi>;
using pii = pair<ll, ll>;

// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define mp make_pair

// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase(unique(all(v)), v.end())
#define perm(c)                                                                \
  sort(all(c));                                                                \
  for (bool c##p = 1; c##p; c##p = next_permutation(all(c)))

template <class T> pair<T, size_t> max(vector<T> &x) {
  auto it = max_element(all(x));
  return mp(*it, it - x.begin());
}
template <class T> pair<T, size_t> min(vector<T> &x) {
  auto it = min_element(all(x));
  return mp(*it, it - x.begin());
}

template <class T> inline bool chmax(T &maxval, const T &newval) {
  if (maxval < newval) {
    maxval = newval;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &minval, const T &newval) {
  if (minval > newval) {
    minval = newval;
    return 1;
  }
  return 0;
}

// Utilities
// Grid world utilities
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
#define inside(H, W, y, x) 0 <= (x) && (x) < (W) && 0 <= (y) && (y) < (H)

// Debug
#ifdef LOCAL
#include "dump.hpp"
#define debug(x) cerr << #x << ": " << x << '\n'
#else
#define dump(...)
#define debug(x)
#endif

// Paste snippets here!!
bool parind(string &s){
  string t = s;
  reverse(all(t));
  return s==t;
}
//

void solve(std::string S) {
  if(!parind(S)){ cout << "No" << endl; return; }
  string s;
  int N = S.size();
  for(int i=0;i<(N-1)/2;++i) s += S[i];

  string t;
  for(int i=(N+3)/2-1; i<N;++i) t += S[i];

  if(!parind(s)){ cout << "No" << endl; return; }
  if(!parind(t)){ cout << "No" << endl; return; }

  cout << "Yes" << endl;
  
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false); // Magic for faster cin
  cout.precision(12);
  std::string S;
  std::cin >> S;
  solve(S);
  return 0;
}


Measured memory_bytes: 3620
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int main(){
  string s,t;
  cin>>s>>t;
  sort(s.begin(),s.end());
  sort(t.begin(),t.end());
  reverse(t.begin(),t.end());
  if(s<t)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}

Measured memory_bytes: 3604
def gcd(a,b):
  while b:a,b=b,a%b
  return a
n,m=map(int,input().split())
s,t=input(),input()
a=gcd(n,m)
m//=a
for i in range(a):
  if s[(n//a)*i]!=t[m*i]:print(-1);exit()
print(m*n)

Measured memory_bytes: 3316
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

bool dp[85][85][2*80*80 + 100];  // dp[i][j][k] : (i,j)の偏りをkにできるならtrue
 
int main() {
    ll h, w;
    cin >> h >> w;

    vvl a(h, vl(w));
    rep(i, h) {
        rep(j, w) {
            cin >> a[i][j];
        }
    }

    vvl b(h, vl(w));
    rep(i, h) {
        rep(j, w) {
            cin >> b[i][j];
        }
    }

    dp[0][0][abs(a[0][0] - b[0][0])] = true;
    rep(i, h) {
        rep(j, w) {
            exrep(k, 0, 2*80*80) {
                if(dp[i][j][k]) {
                    if(i+1 < h) {
                        dp[i+1][j][abs((a[i+1][j] + k) - b[i+1][j])] = true;
                        dp[i+1][j][abs((b[i+1][j] + k) - a[i+1][j])] = true;
                    }
                    if(j+1 < w) {
                        dp[i][j+1][abs((a[i][j+1] + k) - b[i][j+1])] = true;
                        dp[i][j+1][abs((b[i][j+1] + k) - a[i][j+1])] = true;
                    }
                }
            }
        }
    }

    exrep(k, 0, 2*80*80) {
        if(dp[h-1][w-1][k]) {
            out(k);
            re0;
        }
    }
    
    re0;
}

Measured memory_bytes: 85376
#include <stdio.h>
#include <vector>
using namespace std;
vector<int>g[100000];
int n, u, v, a, b, ans;
int du[100000], dv[100000];
void dfs(int x, int y, int z) {
	dv[x] = z;
	for (int i = 0; i < g[x].size(); i++) {
		if (g[x][i] != y)dfs(g[x][i], x, z + 1);
	}
}
int main() {
	scanf("%d%d%d", &n, &u, &v);
	u--; v--;
	for (int i = 0; i < n - 1; i++) {
		scanf("%d%d", &a, &b);
		a--; b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	dfs(u, -1, 0);
	for (int i = 0; i < n; i++)du[i] = dv[i];
	dfs(v, -1, 0);
	for (int i = 0; i < n; i++) {
		if (dv[i] > du[i]) {
			if (dv[i] > ans)ans = dv[i];
		}
	}
	printf("%d\n", ans - 1);
}


Measured memory_bytes: 13248
#include<iostream>
#include<string>
#include<algorithm>
#include<functional>
#include<cstring>
#include<set>
#include<map>
#include<vector>
#include<cmath>
#include<queue>
#include<cstdio>
#include<cstdlib>
#define reep(n1,n2,n3) for(int n1=n3;n1<n2;n1++)
#define rep(n1,n2) reep(n1,n2,0)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define INF 1e9
using namespace std;
typedef long long int lint;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<pair<int,int> > vp;
typedef pair<int,int> pi;
typedef pair<int,pair<int,int> > pii;
typedef vector<string> vs;
const double PI  = acos(-1.0);
int main(){
    int p=INF,j=INF;
    rep(i,3){
        int a;
        cin>>a;
        p=p<a?p:a;
    }
    rep(i,2){
        int a;
        cin>>a;
        j=j<a?j:a;
    }
    cout<<p+j-50<<endl;
}

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

#define pb push_back
#define ppp pop_back
#define pii pair<int,int>
#define fi first
#define se second

const int N = 1e5 + 5;

vector<int> g[N];
int dp[N];
bool used[N];

void dfs(int v) {
    used[v] = 1;
    for (int u : g[v]) {
        if (!used[u]) dfs(u);
        dp[v] = max(dp[v], dp[u] + 1);
    }
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif
    int n, m;
    cin >> n >> m;
    for (int i=1; i<=m; i++) {
        int u, v;
        cin >> u >> v;
        g[u].pb(v);
    }
    int ans = 0;
    for (int i=1; i<=n; i++) {
        if (!used[i]) {
            dfs(i);
            ans = max(ans, dp[i]);
        }
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 8320
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

long long x,rj;

int main () {
ios_base::sync_with_stdio(false);
cin.tie(NULL);

cin >> x;

long long i = x;

if (x==2 || x==3 || x==5 || x==7){
	cout << x;
	return 0;
}

while (rj==0){	
	if (i%2!=0 && i%3!=0 && i%5!=0 && i%7!=0){
		long long dj = 0;
		for (int k = 1;k<=i;k++){
			if (i%k==0)
				dj++;
		}
		if (dj == 2)
			rj = i;
	}
i++;
}

cout << rj;



return 0;
}



Measured memory_bytes: 256
from math import floor, sqrt
from collections import defaultdict
def factors(n):
    d = defaultdict(int)
    for i in range(2,floor(sqrt(n))+1):
        while n % i == 0:
            n //= i
            d[i] += 1
        if n == 1:
            break
    if n != 1:
        d[n] += 1
    return d
N = int(input())
mod = 10**9+7
d = defaultdict(int)
for i in range(1,N+1):
    e = factors(i)
    for k in e:
        d[k] += e[k]
ans = 1
for k in d:
    ans = (ans*(d[k]+1)) % mod
print(ans)

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

int const MAX = 200005;
int order[MAX];
int length[MAX];

int main() {
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		int a;
		cin >> a;
		order[a] = i;
	}
	int lengest = 0;
	int s, t;
	s = t = 1;
	while (1) {
		while (t <= n - 1 && order[t] < order[t + 1]) {
			t++;
			lengest = max(lengest, t - s);
		}
		if (t == n) { break; }
		t++;
		s = t;
	}
	cout << n - lengest - 1 << endl;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define pb push_back
#define ALL(s) s.begin(),s.end()
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define SZ(s) int(s.size())

typedef long long ll;
typedef unsigned long long ull;

using namespace std;


int main() {FIN;
    int r;
    cin>>r;
    cout<<(r*r)<<"\n";
}


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

#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
#define e_b emplace_back
#define all(x) (x).begin(),(x).end()
#define uniq(x) ((x).erase(unique(all(x)),(x).end()))
#define sz(x) ((int)(x).size())

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

#ifdef LOCAL//compile with -DLOCAL
#define debug(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = "<<(x)<<endl
#define debug_vec(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = ";\
  rep(i,sz(x)){cerr<<x[i]<<" ";}cerr<<endl
#define debug_mat(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = "<<endl;\
  rep(i,sz(x)){rep(j,sz(x[i])){cerr<<x[i][j]<<" ";}cerr<<endl;}cerr<<endl
#else
#define debug(x) void(0)
#define debug_vec(x) void(0)
#define debug_mat(x) void(0)
#endif

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


int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  string S;
  cin >> S;
  int N=sz(S);

  vector<int> dp_same(N+1,1e9);
  vector<int> dp_over(N+1,1e9);
  dp_same.at(0)=0;
  dp_over.at(0)=1;
  rep(i,N){
    int now=S.at(i)-'0';
    dp_same.at(i+1) = min(dp_same.at(i)+now,dp_over.at(i)+10-now);
    dp_over.at(i+1) = min(dp_same.at(i)+now+1,dp_over.at(i)+10-(now+1));
  }
  cout << dp_same.at(N) << endl;

  return 0;
}

Measured memory_bytes: 12200
n = int(input())
a = [int(input()) for i in range(n)] 

m = max(a)
m_num = a.count(m)
if m_num > 1:
    for i in range(n):
        print(m)
else:
    ind_m = a.index(m)
    a.pop(ind_m)
    sec_m = max(a)
    for i in range(n):
        print(m) if i != ind_m else print(sec_m)

Measured memory_bytes: 12520
#include<stdio.h>
#include<stdlib.h>
int main()
{
	long a[200000],n,i;
	long long min,sum,x;
	while(scanf("%ld",&n)==1)
	{
		for(i=0,sum=0;i<n;i++)
		{
			scanf("%ld",&a[i]);
			sum+=a[i];
		}
		for(i=0,min=llabs(sum-2*a[0]),x=0;i<n-1;i++)
		{
			x+=a[i];
			if(min>llabs(sum-2*x)) min=llabs(sum-2*x);
		}
		printf("%lld\n",min);
	}
}

Measured memory_bytes: 1664
def find(u, find_root):
    find_root[u] = u if u == find_root[u] else find(find_root[u], find_root)
    return find_root[u]

def main():
    n, q = map(int, input().split())
    find_root = list(range(n))
    for i in range(q):
        t, u, v = map(int, input().split())
        u_root, v_root = find(u, find_root), find(v, find_root)
        if t:
            print(1 if u_root == v_root else 0)
        else:
            find_root[u_root] = v_root

if __name__ == "__main__":
    main()

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

namespace ConsoleApp11
{
    class Class26
    {
        static void Main()
        {
            var I = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = I[0], A = I[1], B = I[2];
            string S = Console.ReadLine();

            int count = 0,countB = 0;
            for(int i = 0; i < N; i++)
            {
                if (S[i] == 'a')
                {
                    if (count < A + B)
                    {
                        Console.WriteLine("Yes");
                        count += 1;
                    }
                    else
                        Console.WriteLine("No");
                }
                else if (S[i] == 'b')
                {
                    if (count < A+B&countB<B)
                    {
                        Console.WriteLine("Yes");
                        count += 1;
                        countB += 1;
                    }
                    else
                        Console.WriteLine("No");
                }
                else
                    Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 15840
def main():
    n = int(input())
    a = tuple(map(int, input().split()))

    ans = 0
    mx = max(a) + 1
    dp = [0] * mx
    for i in a:
        for j in range(i, mx, i):
            dp[j] += 1
    for i in a:
        if dp[i] == 1:
            ans += 1

    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 33036
#include <stdio.h>

int main(void)
{
	int n,T;
	scanf("%d %d",&n,&T);
	
	int c[n],t[n],i;
	
	for(i = 0; i < n; i++){
		scanf("%d %d",&c[i],&t[i]);
	}
	
	int count = 0;
	int min = 1000;
	for(i = 0; i < n; i++){		
		if(T >= t[i]){
			if(min > c[i]){
				min = c[i];
			}
		}else{
			count++;
		}
	}
	
	if(count == n){
		printf("TLE\n");
	}else{
		printf("%d\n",min);
	}
	
	return 0;
}
			
	
	

Measured memory_bytes: 128
n=int(input())
king=int(0)
ans=int(1)
for i in range(1,n+1):
    a=i
    count=int(0)
    while a:
        if a%2==0:
            a/=2
            count+=1
        
        else:
            break

    if king<count:
        king=count
        ans=i

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main() {
	// your code goes here
	string s;
	cin >> s;
	if (s[s.length() - 1] == 's') {
	    cout << s;
	    cout << "es";
	}
	else {
	    cout << s;
	    cout << "s";
	}
	cout << endl;
}


Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#define INF 1000000001

using namespace std;

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

    int A[N+2];
    A[0] = 0;
    A[N+1] = INF;
    for(int i=1; i<N+1 ;i++){
        cin >> A[i];
    }
    sort(A, A+N+2);

    int B[N+2];
    B[0] = 0;
    B[N+1] = INF;
    for(int i=1; i<N+1 ;i++){
        cin >> B[i];
    }
    sort(B, B+N+2);

    int C[N+2];
    C[0] = 0;
    C[N+1] = INF;
    for(int i=1; i<N+1 ;i++){
        cin >> C[i];
    }
    sort(C, C+N+2);

    long ans = 0;
    for(int i=1; i<N+1; i++){
        long a = lower_bound(A, A+N+2, B[i]) - 1 - A;
        auto t = upper_bound(C, C+N+2, B[i]);
        long c;
        if(*t == B[i]) c = C+N+1-(t+1);
        else c = C+N+1-t;
        ans += a*c;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>

using namespace std;
using ll = long long;

int main(){
    vector<int> a(9);
    for(int i=0; i<9; i++){
        cin >> a[i];
    }
    vector<bool> b(9, false);
    int n;
    cin >> n;
    int bi;
    for(int i =0; i<n; i++){
        cin >> bi;
        for(int j=0; j<9; j++){
            if(a[j] == bi){
                b[j] = true;
            }
        }
    }

    if((b[0] and b[1] and b[2]) or (b[3] and b[4] and b[5]) or (b[6] and b[7] and b[8]) or (b[0] and b[3] and b[6]) or (b[1] and b[4] and b[7]) or (b[2] and b[5] and b[8]) or (b[0] and b[4] and b[8]) or (b[2] and b[4] and b[6])){
        cout << "Yes" << endl;
    }    else{
        cout << "No" << endl;
    }
}

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

lli strikes(int *a, int n, int k){
  if(n<=k)return 0;
  sort(a, a+n);
  int rem = n-k;
  lli sum =0;
  for(int i=0; i<rem; i++)sum+=a[i];
  return sum;
}
int main(){
  int n, k; cin>>n>>k;
  int i, a[n];
  for(i=0; i<n; i++) cin>>a[i];
  cout<<strikes(a, n, k);
  return 0;
}
  

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

int main(){
    int H, W;  cin >> H >> W;
    vector<vector<int>> a;
    a = vector<vector<int>>(H+1, vector<int>(W+1,0));
    for(int i=1; i<=H; i++)
        for(int j=1; j<=W; j++)
            cin >> a[i][j];
    
    vector<tuple<int, int, int, int>> ans;
    for(int i=1; i<=H; i++){
        for(int j=1; j<W; j++){
            if(a[i][j]%2==1){
                ans.push_back(make_tuple(i, j, i, j+1));
                a[i][j]--;
                a[i][j+1]++;
            }
        }
    }
    for(int i=1; i<H; i++){
        if(a[i][W]%2==1){
            ans.push_back(make_tuple(i, W, i+1, W));
            a[i][W]--;
            a[i+1][W]++;
        }
    }

    cout << ans.size() << endl;
    for(int i=0; i<ans.size(); i++){
        cout << get<0>(ans[i]) << " " << get<1>(ans[i]) << " " << get<2>(ans[i]) << " " << get<3>(ans[i]) << endl;
    }
}


Measured memory_bytes: 5232
#include <stdio.h>

int main()
{	 
	int a, b, c, s = 0; 
	
	scanf("%d%d%d", &a, &b, &c);
	if(a > b) a ^= b, b ^= a, a ^= b;
	if(b > c) b ^= c, c ^= b, b ^= c;
	if(a > b) a ^= b, b ^= a, a ^= b;
	if((b - a) & 1) b++, c++, s++;
	s += ((b - a) >> 1) + c - b;
	printf("%d\n", s);
		
	return 0;
}

Measured memory_bytes: 1668