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

#define rep(i, n) for(int i = 0; i < (n); i++)
using ll = long long;
constexpr ll INF = 1000000000;

ll gcd(ll a, ll b) {
	if (b == 0)return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}

using namespace std;
int main() {
	int n; cin >> n;

	vector<int>s(n);
	for (int i = 0; i < n; i++)cin >> s[i];

	sort(s.begin(), s.end());
	
	int sum = 0;

	rep(i, n) {
		sum += s[i];
	}
	
	vector<int>x(n + 1);
	rep(i, n + 1) {
		if (i == 0) {
			x[i] = sum;
		}
		else {
			x[i] = sum - s[i - 1];
		}
	}
	
	sort(x.begin(), x.end());
	reverse(x.begin(), x.end());

		rep(i, n + 1) {
			if (x[i] % 10 != 0) {
				cout << x[i] << endl;
				return 0;
			}
			if (i == n && x[i] % 10 == 0) {
				cout << 0 << endl;
			}
		}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iostream>
#include <set>
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: 256
import bisect
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**7)

n = int(input())
l = [int(item) for item in input().split()]
l.sort()

ans = 0
for i, a in enumerate(l):
    for j in range(i+1, n):
        b = l[j]
        lower = max(a-b, b-a)
        upper = a + b
        d = bisect.bisect_right(l, lower)
        u = bisect.bisect_left(l, upper)
        double = 0
        if d <= i < u:
            double += 1
        if d <= j < u:
            double += 1
        ans += max(0, u - d - double)

print(ans // 3)

Measured memory_bytes: 52192
#D問題
import bisect
N = int(input())
L = list(map(int,input().split()))
L.sort()

ans = 0
for i in range(N):
    for j in range(N):
        if i >= j:
            continue
        a,b = L[i],L[j]
        left = bisect.bisect_left(L,b-a+1)
        right = bisect.bisect_right(L,a+b-1)
        if i >= left and i <= right:
            ans-=1
        if j >= left and j <= right:
            ans-=1
        ans+=right-left

print(ans//3)


Measured memory_bytes: 50172
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    int k = sc.nextInt();
    int a = sc.nextInt();
    int b = sc.nextInt();
    
    int n = b/k+1;
    int m = a/k;
    boolean f = false;
    for(int i=m; i<n; i++){
      if(a<=k*i && k*i<=b){
        f = true;
        break;
      }
    }
    
    if(f==true){
      System.out.println("OK");
    }
    else{
      System.out.println("NG");
    }
  }
}

Measured memory_bytes: 35752
#include <bits/stdc++.h>
using namespace std;
#define int long long
int MOD = (int)1e9 + 7;
int INF = (int)2e18;
// Comment out below and program paste
// #include "UnionFind.h"
// #include "power.h"

signed main() {
    int N, M, C;
    cin >> N >> M >> C;
    vector<int> B(M);
    for (int i = 0; i < M; ++i) {
        cin >> B[i];
    }
    int ans = 0;
    for (int i = 0; i < N; ++i) {
        int temp = 0;
        for (int j = 0; j < M; ++j) {
            int A;
            cin >> A;
            temp += (A * B[j]);
        }
        temp += C;
        if (temp > 0) ++ans;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
//https://atcoder.jp/contests/abc044/tasks/abc044_b
//044-BをC++でといてみる
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
using namespace std;

int main(void){
    string w; cin >> w;
    map<char,int> mp;
    int i;
    for (i = 0; i < w.size(); i++){
        mp[w[i]] += 1;
    }

    for (pair<char,int> x :mp){
        if (x.second%2 != 0){
            cout << "No" << endl; return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main ()
{
	int a,b,temp,i;
	scanf("%d%d",&a,&b);
	temp=a/b;
	for(i=1;temp!=0;)
    {
        i++;
        temp=temp/b;
    }
    printf("%d\n",i);
 
 
	return 0;
}

Measured memory_bytes: 128
#

import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop


def solve(positions, s, t):

    if not set(t) <= set(s):
        return -1

    loop = 0
    prev = -1

    for tchar in t:
        candidates = positions[tchar]
        pos = bisect.bisect_right(candidates, prev)

        if pos == len(candidates):
            loop += 1
            pos = 0
        prev = candidates[pos]

    return loop * len(s) + prev + 1


def main():
    s = input()
    t = input()

    positions = defaultdict(list)
    for i in range(len(s)):
        positions[s[i]].append(i)

    print(solve(positions, s, t))


if __name__ == '__main__':
    main()


Measured memory_bytes: 58064
N = int(input())
P = list(map(int, input().split()))

mins = [P[0]]
for i in range(1, N):
    x = min(mins[-1], P[i])
    mins.append(x)

# print(mins)

c = 0
for i in range(N):
    if P[i] <= mins[i]:
        c += 1

print(c)

Measured memory_bytes: 24744
#include<cstdio>
#include<algorithm>
using namespace std;
#define mod 1000000007
#define N 505
typedef long long LL;
LL n,c,f[N][N],f1[N][N],a[N],b[N];
inline LL pow(LL x,LL y) 
{
    LL k=1;
    while(y) 
	{
        if(y&1)
            k=(k*x)%mod;
        x=(x*x)%mod;
        y>>=1;
    }
    return k;
}
inline void prepare() 
{
    for(LL i=0;i<=400;i++) 
        for(LL j=0;j<=400;j++) 
            f1[i][j]=pow(i,j);
    for(LL j=0;j<=400;j++) 
        for(LL i=0;i<=400;i++) 
            f1[i][j]=(f1[i][j]+f1[i-1][j])%mod;
}
int main() 
{
    prepare();
    scanf("%lld%lld",&n,&c);
    for(LL i=1;i<=n;i++)
        scanf("%lld",&a[i]);
    for(LL i=1;i<=n;i++)
        scanf("%lld",&b[i]);
    f[0][0]=1;
    for(LL i=1;i<=n;i++)
        for(LL j=0;j<=c;j++)
            for(LL l=0;l<=j;l++)
			{
                f[i][j]+=(f[i-1][j-l]*(f1[b[i]][l]-f1[a[i]-1][l]))%mod;
                f[i][j]%=mod;
            }
    printf("%lld\n",(f[n][c]+mod)%mod);
}


Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <climits>
#include <functional>
#include <map>
#include <stack>
#include <cstdlib>
#include <queue>
#define endl '\n'
#define ll long long
#define NCONS 100001

using namespace std;

int main(void)
{
    cin.tie(NULL); ios_base::sync_with_stdio(false);
    int N, A; cin >> N >> A;
    N %= 500;
    if(N <= A)
        cout << "Yes";
    else
        cout << "No";
    
    return 0;
}


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

int main()
{
    int n,i;
    cin >> n;
    vector<string> s(n);
    string temps;
    for(i = 0;i < n;++i){
        cin >> temps;
        sort(temps.begin(),temps.end());
        s.at(i) = temps;
    }
    sort(s.begin(),s.end());
    long long ans = 0;
    long long temp = 1;
    i = 1;
    while(i < n){
        if(s.at(i) == s.at(i-1)){
            temp += 1;
            ++i;
        }else{
            ans += temp*(temp-1)/2;
            temp = 1;
            ++i;
        }
    }    
    ans += temp*(temp-1)/2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5760
#include<iostream>
using namespace std;
int main()
{
    int n, m, c, t, cnt = 0;
    cin >> n >> m >> c;
    int str[m]{0};
    for(int i = 0; i < m; i++) cin>>str[i];
    for(int i = 0; i < n; i++)
    {
        int sum = c;
        for(int j = 0; j < m; j++){
            cin>>t;
            sum+=str[j]*t;
        }
        if(sum>0){
                cnt++;
        }
    }
    cout<<cnt<<endl;
    return 0;
}


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

using ll = long long;
using namespace std;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)

int main() {
  ll n,m; cin>>n>>m;
  vector<ll> h(n); rep(i,n)cin>>h[i];
  vector<vector<ll>> g(n);
  rep(i,m){
    ll a,b; cin>>a>>b;
    a--; b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  ll cnt=0;
  rep(i,n){
    bool f=true;
    for(auto &x: g[i]){
      f&=h[i] > h[x];
    }
    if(f) cnt++;
  }
  cout<<cnt<<endl;
  return 0;
}

Measured memory_bytes: 9788
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"

using namespace std;

typedef long int li;
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pt;

#define fi first
#define se second
#define dump(x) cout << #x << " = " << x << endl
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

li n, a[107], x, y, mn;

int main () {
    fastIO;
    cin >> n;
    for(li i = 0; i < n; i ++) { cin >> a[i]; y+=a[i]; }
    mn = 1e9;
    for(li i = 0; i < n-1; i ++) {
        y-=a[i];
        x+=a[i];
        if(abs(x-y)<mn) mn = abs(x-y);
    }
    cout << mn;
}


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

int main(){
  int n;
  cin >> n;
  
  vector<int> a(n-1);
  for(int i=0; i<n-1; i++){
    cin >> a[i];
  }
  
  vector<int>  ans(n,0);
  for(int i=0; i<n-1; i++){
    ans[a[i]-1]++;
  }
  
  for(int i=0; i<n; i++){
    cout << ans[i] << endl;
  }
  
}

Measured memory_bytes: 4856
#include<bits/stdc++.h>
#define rep(i,l,r) for (int i=l;i<=r;i++)
using namespace std;
typedef long long ll;
int a,b,c,ans,N,K,M,tt;
int main(){
	scanf("%d%d",&N,&K);
	if (K==1) printf("0\n");
	else printf("%d\n",N-K);
	return 0;
}


Measured memory_bytes: 256
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

int n;
vector<int> G[200020];
vector<ll> P(200020),A(200020);
vector<ll> par(200020,-1);

void dfs(int u){
  A[u]=P[u]+A[par[u]];
  for(int i=0;i<G[u].size();i++){
    if(par[G[u][i]]!=-1) continue;
    par[G[u][i]]=u;
    dfs(G[u][i]);
  }
}

int main() {
  int q;
  cin>>n>>q;
  
  par[0]=0;

  int a,b;
  rep(i,n-1){
    cin>>a>>b;
    a--,b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  
  ll p,x;
  rep(i,q){
    cin>>p>>x;
    p--;
    P[p]+=x;
  }
  
  dfs(0);
  
  rep(i,n){
    if(i) cout<<" ";
    cout<<A[i];
  }
  cout<<endl;
  
  return 0;
}

Measured memory_bytes: 25080
while True:
    n, x = map(int, input().split())
    if not n and not x:
        break
    li = []
    for i in range(1,x//3):
        y = x - i
        li.append((y-1)//2 - max(i, y-n-1))
    print(sum([comb for comb in li if comb > 0]))

Measured memory_bytes: 7680
taro = 0
hana = 0

n = gets.chomp.to_i
n.times do
  t, h = gets.chomp.split
  if t == h
    taro += 1
    hana += 1
  elsif t > h
    taro += 3
  else
    hana += 3
  end
end
puts "#{taro} #{hana}"



Measured memory_bytes: 6876
S = input()
now = 0
ans = 0
las = ""
lasstr = 0

lis  = [0] * (len(S)+1)

for i in range(len(S)):

    if S[i] == "<":
        lis[i+1] = max(lis[i+1],lis[i]+1)

#print (lis)

for i in range(len(S)):

    i = len(S)-1 - i

    if S[i] == ">":
        lis[i] = max(lis[i],lis[i+1]+1)

#print (lis)
print (sum(lis))
        

Measured memory_bytes: 46576
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T>
using vec = std::vector<T>;

int dfs(int n, vec<vec<int>> &from, vec<int> &c, vec<bool> &visited) {
    if (c[n] != -1) return c[n];
    if (visited[n]) return -1;
    visited[n]   = true;
    int tmpOrder = -1;
    for (auto e : from[n]) {
        int tmp = dfs(e, from, c, visited);
        if (tmp == -1) return -1;
        tmpOrder = max(tmpOrder, tmp + 1);
    }
    if (tmpOrder == -1)
        c[n] = 1;
    else
        c[n] = tmpOrder;
    return c[n];
}

int main() {
    int N;
    cin >> N;
    vec<vec<int>> A(N, vec<int>(N - 1));
    rep(i, N) rep(j, N - 1) {
        cin >> A[i][j];
        --A[i][j];
    }

    vec<vec<int>> gameid(N, vec<int>(N, -1));
    int now = 0;
    rep(i, N) rep(j, N) {
        if (i == j || i >= j) continue;
        gameid[i][j] = now;
        ++now;
    }

    vec<vec<int>> games(N, vec<int>(N - 1));
    rep(i, N) rep(j, N - 1) {
        int aa = i;
        int vs = A[i][j];
        if (aa > vs) swap(aa, vs);
        games[i][j] = gameid[aa][vs];
    }

    vec<vec<int>> from(now, vec<int>());
    rep(i, N) rep(j, N - 2) {
        from[games[i][j + 1]].push_back(games[i][j]);
    }

    vec<int> c(now, -1);
    vec<bool> visited(now, false);
    int ans = 0;
    rep(i, now) {
        int sortOrder = dfs(i, from, c, visited);
        if (sortOrder == -1) {
            cout << -1 << endl;
            return 0;
        }
        ans = max(ans, sortOrder);
    }

    cout << ans << endl;
}

Measured memory_bytes: 41472
import java.io.*;
import java.util.*;
import static java.lang.Math.*;

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

    public void solve(String[] args) {
        MyScanner scanner = new MyScanner();
        int N = scanner.nextInt();
        String S = scanner.next();
        int[] E = new int[N];
        int[] W = new int[N];
        int e = 0;
        int w = 0;
        for (int i = 0; i < N; i++) {
            if (S.charAt(i) == 'E') {
                e++;
            } else {
                w++;
            }
            E[i] = e;
            W[i] = w;
        }

        int ans = Integer.MAX_VALUE;
        for (int i = 0; i < N; i++) {
            int change = 0;
            if (i != 0) {
                change += W[i-1];
            }
            change += E[N-1] - E[i];
            ans = Math.min(ans, change);
        }
        System.out.println(ans);
    }

    private class MyScanner {
        String[] s;int i;BufferedReader br;String reg = " ";
        MyScanner () { s = new String[0];i = 0;br = new BufferedReader(new InputStreamReader(System.in)); }
        public String next() {
            try {
                if (i < s.length) return s[i++]; String line = br.readLine();
                while (line.equals("")) {line = br.readLine();}
                s = line.split(reg, 0); i = 0;return s[i++];
            } catch (Exception e) {e.printStackTrace();}
            return null;
        }
        public int nextInt() {
            try {return Integer.parseInt(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public double nextDouble() {
            try {return Double.parseDouble(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public long nextLong()  {
            try {return Long.parseLong(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
    }
}


Measured memory_bytes: 28172
object Main extends App {

  override def main(args: Array[String]): Unit = {
    val str = io.StdIn.readLine.split(' ')

    val init = new Dice(str(0), str(1), str(2), str(3), str(4), str(5))
    val q = io.StdIn.readLine.toInt

    (1 to q).map(_ => io.StdIn.readLine.split(' ')).map(i => (i(0), i(1)))
      .map(topSouth => init.getAsTopAndSouthIs(topSouth._1, topSouth._2))
      .foreach(d => println(d.east));

  }

  case class Dice(top: String, south: String, east: String, west: String, north: String, buttom: String) {

    def toNorth: Dice = {
      new Dice(south, buttom, east, west, top, north)
    }
    def toSouth: Dice = {
      new Dice(north, top, east, west, buttom, south)
    }
    def toEast: Dice = {
      new Dice(west, south, top, buttom, north, east)
    }
    def toWest: Dice = {
      new Dice(east, south, buttom, top, north, west)
    }
    def rotRight: Dice = {
      new Dice(top, east, north, south, west, buttom)
    }
    def rotLeft: Dice = {
      new Dice(top, west, south, north, east, buttom)
    }

    def getAsTop(toTop:String):Dice = {
       toTop match{
         case str if str==top => this
         case str if str==east => toWest
         case str if str==west => toEast
         case str if str==south => toNorth
         case str if str==north => toSouth
         case str if str==buttom => toNorth.toNorth
       }
    }
    
    def getAsSouthByRot(toSouth:String) :Dice = {
      toSouth match{
        case str if str==south => this
        case str if str==east => rotRight
        case str if str==west => rotLeft
        case str if str==north => rotRight.rotRight
      }
    }
    
    def getAsTopAndSouthIs(top: String, south: String): Dice = {
      getAsTop(top).getAsSouthByRot(south)
    }

  }

}

Measured memory_bytes: 43796
// E.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>
#include <numeric>

using namespace std;

vector<int> a;

bool possible(int x, int k) {
	int pp = k, mm = k;
	int n = (int)a.size();
	vector<int> rr = a;
	for (int i = 0; i < n; ++i) {
		rr[i] %= x;
	}
	sort(rr.begin(), rr.end());
	int left = 0;
	for (int right = n - 1; right >= 0; --right) {
		int r = (x - rr[right]) % x;
		pp -= r;
		while (r > 0 && left < right) {
			int m = min(r, rr[left]);
			r -= m;
			rr[left] -= m;
			mm -= m;
			if (rr[left] <= 0) {
				++left;
			}
		}
		if (pp < 0 || mm < 0 || r > 0) return false;
	}
	return true;
}

int main(int argc, char *argv[]) {
	int n, k;
	cin >> n >> k;
	a.resize(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	int sum = accumulate(a.begin(), a.end(), 0);
	vector<int> r(1, sum);
	for (int i = 2; i * i <= sum; ++i) {
		if ((sum % i) == 0) {
			r.push_back(i);
			if (i * i != sum) {
				r.push_back(sum / i);
			}
		}
	}
	sort(r.rbegin(), r.rend());
	int ans = 1;
	for (int x : r) {
		if (possible(x, k)) {
			ans = x;
			break;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;

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

    int n;
    cin >> n;
    vector<long long> A(n);
    for(int i = 0; i < n; i++){
        cin >> A[i];
    }

    long long now = 1, ans = 0;
    for(int i = 0; i <= 60; i++){
        long long x = 0;
        for(int j = 0; j < n; j++){
            if(A[j] >> i & 1){
                x++;
            }
        }
        ans += ((x * (n - x)) % MOD * now) % MOD;
        ans %= MOD;

        now *= 2;
        now %= MOD;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2560
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
typedef long long ll ;
#define rep(i, a, b) for (int i = a; i <= b; ++ i) 
const int N = 2e5 + 5 ;
using namespace std ;

char s[N] ;
int p[N], n, f[N][26], top = 0 ;
struct poi {
	ll sum[26], cnt ;
} a[N] ;

void solve(int c, ll x, ll (&ret)[26]) {
	rep(i, 0, 25) ret[i] = 0 ;
	if (x <= (ll) n) {
		rep(i, 1, x) ++ ret[s[i] - 'a'] ;
		return ;
	}
	if (x <= a[c - 1].cnt) {
		solve(c - 1, x, ret) ;
		return ;
	}
	solve(c - 2, x - a[c - 1].cnt, ret) ;
	rep(i, 0, 25) ret[i] += a[c - 1].sum[i] ;
}

int main() {
	scanf("%s", s + 1) ;
	n = strlen(s + 1) ; n /= 2 ;
	p[1] = 0 ; int j = 0 ;
	rep(i, 2, n) {
		for ( ; j && s[j + 1] != s[i] ; ) j = p[j] ;
		if (s[j + 1] == s[i]) ++ j ; 
		p[i] = j ;
	}
	rep(i, 1, n) {
		rep(j, 0, 25) f[i][j] = f[i - 1][j] ;
		++ f[i][s[i] - 'a'] ;
	}
	top = 1 ;
	a[1].cnt = n ;
	rep(i, 0, 25) a[1].sum[i] = f[n][i] ;
	a[0].cnt = n - p[n] ;
	rep(i, 0, 25) a[0].sum[i] = f[a[0].cnt][i] ;
	for ( ; ; ) {
		++ top ;
		a[top].cnt = a[top - 1].cnt + a[top - 2].cnt ;
		rep(i, 0, 25) a[top].sum[i] = a[top - 1].sum[i] + a[top - 2].sum[i] ;
		if (a[top].cnt > 1e18) break ;
	}
	ll A[26], B[26], l, r ;
	scanf("%lld%lld", &l, &r) ;
	solve(top, r, A), solve(top, l - 1, B) ;
	rep(i, 0, 25) printf("%lld ", A[i] - B[i]) ; puts("") ;
	return 0 ; 
}

Measured memory_bytes: 14592
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		
		try(Scanner scan = new Scanner(System.in)){

			int n = scan.nextInt();
			int[] array = new int[n];
			for(int i=0; i<n; i++) {
				array[i] = scan.nextInt();
			}
			
			int dice = 0;
			int counter = 0; 
			
			for(int i=0; i<array.length; i++) {

				if(array[i] == 1) {
					counter++;
				}else {
					dice = Math.max(dice, counter);
					counter = 0;
				}
			}
			dice = Math.max(dice, counter);
			System.out.println(dice+1);
		}
	}
}


Measured memory_bytes: 26340
K = int(input())
a = set([1,2,3,4,5,6,7,8,9])
prev = set([1,2,3,4,5,6,7,8,9])

while len(a) < K:
    temp = set()
    for now in prev:
        c = now%10
        if c == 0:
            temp.add(now*10)
            temp.add(now*10+1)
        elif c == 9:
            temp.add(now*10+9)
            temp.add(now*10+8)
        else:
            temp.add(now*10+c-1)
            temp.add(now*10+c)
            temp.add(now*10+c+1)
    prev = temp
    a = a|temp
print(sorted(list(a))[K-1])


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

using namespace std;

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

  int n;
  cin >> n;
  vector<vector<int>> g(n);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      char c;
      cin >> c;
      if (c == '1') {
        g[i].push_back(j);
      }
    }
  }
  vector<int> mark(n);
  function<bool(int)> dfs = [&](int v) {
    for (int to : g[v]) {
      if (mark[to] == 0) {
        mark[to] = 3 - mark[v];
        if (!dfs(to)) {
          return false;
        }
      } else if (mark[to] == mark[v]) {
        return false;
      }
    }
    return true;
  };
  mark[0] = 1;
  if (!dfs(0)) {
    cout << -1;
    return 0;
  }
  vector<vector<int>> dist(n, vector<int>(n, 1e9));
  for (int i = 0; i < n; ++i) {
    dist[i][i] = 0;
    for (int to : g[i]) {
      dist[i][to] = 1;
    }
  }
  for (int k = 0; k < n; ++k) {
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < n; ++j) {
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      ans = max(ans, dist[i][j]);
    }
  }
  cout << ans + 1;

  return 0;
}

Measured memory_bytes: 512
if __name__ == '__main__':
    while True:
        try:
            x1, y1, x2, y2, x3, y3, xp, yp = map(float, input().split())
            ab = [x2-x1, y2-y1]
            bp = [xp-x2, yp-y2]
            bc = [x3-x2, y3-y2]
            cp = [xp-x3, yp-y3]
            ca = [x1-x3, y1-y3]
            ap = [xp-x1, yp-y1]
            c1 = ab[0]*bp[1] - ab[1]*bp[0]
            c2 = bc[0]*cp[1] - bc[1]*cp[0]
            c3 = ca[0]*ap[1] - ca[1]*ap[0]
            if (c1 > 0 and c2 > 0 and c3 > 0) or (c1 < 0 and c2 < 0 and c3 < 0):
                print("YES")
            else:
                print("NO")
        except EOFError:
            break


Measured memory_bytes: 5584
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <ctime>

#define inf 0x3f3f3f3f
#define Inf 0x3FFFFFFFFFFFFFFFLL
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define Rep(i, n) for (int i = 1; i <= (n); ++i)
#define clr(x, a) memset(x, (a), sizeof x)
using namespace std;
typedef long long ll;

int main() {
  int x, y, z; scanf("%d%d%d", &x,&y,&z);
  swap(x,y);swap(x,z);
  cout<<x<<" "<<y<<" "<<z<<endl;
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int x,a,b,mai,sono;
  cin>>x>>a>>b;
  
  if(x>a){
    mai=x-a;
  }else{
    mai=a-x;
  }
  if(x>b){
    sono=x-b;
  }else{
    sono=b-x;
  }
  if(mai<sono){
    cout<<"A"<<endl;
  }else{
    cout<<"B"<<endl;
  }
  return 0;
}


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

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

    int n,d,x;

    cin>>n>>d>>x;

    int ans=x;

    for(int i=0;i<n;i++)
    {
        int a;
        cin>>a;

        ans+=1+(d-1)/a;
    }

    cout<<ans<<"\n";

    return 0;
}


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

int32_t main(){
    ios::sync_with_stdio(0),cin.tie(0);
    int n;
    cin >> n;
    int a[n+1]={0};
    for(int i=1;i<=100;i++){
        for(int j=1;j<=100;j++){
            for(int k=1;k<=100;k++){
                int x=i*i+j*j+k*k+i*j+j*k+k*i;
                if(x<=n)a[x]++;
            }
        }
    }
    for(int i=1;i<=n;i++)
        cout << a[i] << '\n';
}

Measured memory_bytes: 3620
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>

using namespace std;

const int da[9] = {0, 1, 1, 0, -1, -1, -1,  0,  1};
const int db[9] = {0, 0, 1, 1,  1,  0, -1, -1, -1};

int main() {
	int h, w, n, a, b;
	scanf("%d %d %d", &h, &w, &n);

	map<pair<int, int>, int> centers;

	for (int i = 0; i < n; i++) {
		scanf("%d %d", &a, &b);
		for (int i = 0; i < 9; i++) {
			centers[make_pair(a+da[i], b+db[i])]++;
		}
	}

	vector<long long> blacks(10, 0);
	blacks[0] = 1LL * (h - 2) * (w - 2);

	for (auto p : centers) {
		int aa = p.first.first;
		int bb = p.first.second;
		long long val = p.second;

		if (1 < aa && aa < h && 1 < bb && bb < w) {
			blacks[val]++;
			blacks[0]--;
		}
	}

	for (auto e : blacks) {
		printf("%lld\n", e);
	}


	return 0;
}


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

/*** Template Begins ***/
#define int ll
typedef long long                   ll;
typedef pair<int,int>               PII;
typedef pair<ll, pair<int, int> >   PIII;
typedef vector<int>                 vi;
typedef vector<pair<int, int> >     vii;

#define endl         '\n'
#define pb           push_back
#define INF          INT_MAX/10
#define F            first
#define S            second
#define mp           make_pair
#define ios          ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define hell         1000000007
#define all(a)       (a).begin(),(a).end()
#define fr(i,a,b)    for(int i=a;i<=b;i++)
#define lp(i,a)      for(int i=0;i< a;i++)

// Debug //

#define trace(x)                 cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

// Constants //

const int N = 1e5+7;
const int xinc[] = {0, 0, 1, -1};
const int yinc[] = {1, -1, 0, 0};
const long double PI = acos(-1.0);

/*** Template Ends ***/
int n, dp[N], prv, ans[N];
string s;

int add(int a, int b) {
    return (a+b)%hell;
}
int mul(int a, int b) {
    return (a*b)%hell;
}
ll power(ll x, ll y, ll p){ ll res = 1;x = x % p;while (y > 0){ if (y & 1) res = (res*x) % p;y = y>>1;x = (x*x) % p;} return res; } 
void solve() {
    
    cin >> s;
    reverse(all(s));

    int ret = 0;
    int ml = 1;

    for (int i = s.size()-1; i >= 0; i--) {

        if (s[i] == '1') {
            ret = add(ret, mul(ml,power(3, i, hell)));
            ml = mul(ml, 2);        
        }
    }

    cout << add(ret,ml) << endl;
}

signed main() {
    
    ios;
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    int t;
    //cin >> t;
    t = 1;
    while(t--)
        solve();

    return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{

    char T[4];
    scanf("%s",&T);
    char A[4];
    scanf("%s",&A);

    int count=0;
    for (int i=0;i<3;i++){
        if (A[i]==T[i])count++;
    }
 printf("%d",count);
    return 0;
}


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

using namespace std;
int n,cnt,ans;
string s;
int main() {
    scanf("%d",&n);
    cin>>s;
    for(int i=0;i<n;i++)
        if(s[i]=='W')
            cnt++;
    for(int i=n-cnt;i<n;i++)
        if(s[i]!='W')
            ans++;
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 3908
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int n;
bool ok[25][25];
int dp[5000010];
int mod=1e9+7;

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

    cin>>n;
	for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)
            cin>>ok[i][j];

    dp[0]=1;
    for(int i=1;i<(1<<n);i++)
    {
        int m=__builtin_popcount(i)-1;
        for(int j=0;j<n;j++)
        {
            if(ok[m][j] && (i&(1<<j)))
                dp[i]=(dp[i]+dp[i^(1<<j)])%mod;
        }
    }
    cout<<dp[(1<<n)-1];

	return 0;
}


Measured memory_bytes: 10624
a, b, c = [int(i) for i in input().split()]

ans='NO'

i = 1
f = a % b
while(1):
    tmp = a * i
    mod = tmp % b

    if mod == c:
        ans = 'YES'
        break

    if i != 1 and mod == f:
        break

    i += 1


print(ans)


Measured memory_bytes: 2940
n,k=map(int,input().split())
L=[]
for i in range(n):
      a,b=map(int,input().split())
      L+=[[a,b]]
L.sort(key=lambda x:x[0])

sm=0
for i in range(n):
      sm+=L[i][1]
      if sm>=k:
            print(L[i][0])
            exit()

Measured memory_bytes: 21336
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
using namespace std;
typedef long long ll;
int main(){
  ll kazu = 0;
  ll teiinn = 0;
  ll wait = 0;
  cin >> kazu >> teiinn >> wait;
  vector<ll> time(kazu);
  for(int i = 0;i <= kazu - 1;i++){
    cin >> time[i];
  }
  sort(time.begin(),time.end());
  ll now = 0;
  ll kotae = 0;
  while(kazu > now){
    ll gennkai = 0;
    gennkai = time[now] + wait;
    ll a = 0;
    a = min(teiinn - 1,kazu - 1);
    ll nowc= 0;
    nowc = now;
    for(int i = nowc;i <= nowc + a;i++){
      //cout << "a" << endl;
      if(time[i] <= gennkai){
        //cout << i << "a" << a << " time[i]" << time[i] << " gennkai" << gennkai << endl;
        now++;
      }
      else{
        //cout << i << "b" << endl;
        break;
      }
    }
    kotae++;
    //cout << now << endl;
  }
  cout << kotae  << endl;
  return 0;
}

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

int main(void){
    string S;
    cin >> S;
    int counter = 0;
    if(S[0] == 'o')  counter++;
    if(S[1] == 'o') counter++;
    if(S[2] == 'o') counter++;
    cout << 700 + (100 * counter) << endl;
    return 0;
}

Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
string s;
long long flag=0;
int main()
{
    cin>>s;
    for(int i=0;i<=s.size()-1;i++)
    {
        if(flag==0&&s[i]=='C')
        {
            flag=1;
        }
        if(flag==1&&s[i]=='F')
        {
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ALL(x) x.begin(), x.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
random_device rnd;
mt19937 mt(rnd());
using ll = long long;
using lld = long double;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using PII = pair<int, int>;
const int IINF = 1 << 30;
const ll INF = 1ll << 60;
const ll MOD = 1000000007;

int main()
{
    int n;
    cin >> n;
    VVI v(n, VI(2));
    rep(i, n) cin >> v[i][0] >> v[i][1];

    int cur = 0;
    rep(i, n)
    {
        if (v[i][0] == v[i][1])
        {
            cur++;
        }
        else
        {
            cur = 0;
        }
        if (cur == 3)
        {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;

    return 0;
}

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

int main() {
  int N, x;
  cin >> N;
  x = 0;
  // ここにプログラムを追記
  for(int i = 0; i < N; i++) {
    int A, B;
    cin >> A >> B;
    x += B - A + 1;
  }
  
  cout << x << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;

int main(void){
  int n;
  cin >> n;
  if(n == 3 || n == 5 || n == 7){
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
 
#define REP(i,n) for(int i=0;i<(int)(n);i++)
 
 
int main()
{
    int d,n;
    scanf("%d %d",&d,&n);
    if(n==100)n++;
    long long int ans=n;
    REP(i,d)ans*=100;
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm> 
#include <cstdlib>
#include <map>
#include <queue>
#include <vector>
#define ll long long
using namespace std;
int main(){
	ll N,T;
	cin >> N >> T;
	ll t[N];
	for(ll i=0;i<N;i++){
		cin >> t[i];
	}
	ll ans=0;
	for(ll i=0;i<N;i++){
		if(t[i+1]-t[i]>=T){
			ans = ans + T;
		}else{
			ans = ans + t[i+1] - t[i];
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1792
import sys
if sys.argv[-1] == 'ONLINE_JUDGE':
    import os, zlib, base64
    open('solve.pyx', 'wb').write(zlib.decompress(base64.b85decode("c${@p+is&U5Pe7DA4Xbjg}0;ysg)|!>{s+H$^#gajF#A`FSPypj<G3D+MO57oWq$j<KY+Z4|`Oy0p8<;29?~tXeaV)(CQSyyK}4CaTFtPJe`%caMrCnETj=TerIft>I**z%a5%t;q2nU2-~@Vp0-!c<{9tB0HczJ-D5>j@1c)L&)?Nmh&|9(7r>)W<yp`xf?VlYEYeU~@*xWbQXOz?@(d`xpsoZCTc|?%?TDj*I+A>J1V;M>ThllY@(d484Rl(x|5n7Sargsu1-Hc65GR0ISf?fM=xb8g11GnIZyU^i{Nc4ZlbUlo+!MjT?@({4HCu$+E!69~f%|((L@{ar6Q!V?W`e}#Lc&M9!eXu+Cn828l1~@P!&AhUL|w78`?l|kxyN#D_5E@L(GomwK_=q8Z<#uKzv>j>1~!;%5*T+1@;{6=5Uyv7@E58k9T^Gxf@!VIS}VC$ldPNcE8thIgxB>*UD9T{5~e(RLwme1H7HH0DC4hGNY;e$(52R8kYGPkUs>YVF7?)w`<|M<r)VE+6ZX;1ZDO>!{@_?bn(uk`<$|w?z)#J>6B_")))
    os.system('cythonize -i -3 -b solve.pyx')
import solve

Measured memory_bytes: 12936
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // min, max, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(int)>
using namespace std;
#define rep(i,n) rep1(i,0,n)
#define rep1(i,m,n) for(int i=m;i<(n);i++)
#define All(v) (v).begin(),(v).end()
using ll = long long;
const int inf = 1<<30;
const ll mod = 1000000007;
const ll INF = 100000000000000000LL;
const double PI = acos(-1);
int main(){
    int n;
    cin>>n;
    vector<int> x(n), s(n);
    rep(i,n){
        cin >> x[i];
        s[i] = x[i];
    }
    sort(All(s));
    int M1 = s[n / 2-1], M2 = s[n / 2];
    rep(i,n){
        if(x[i]<=M1){
            cout << M2 << endl;
        }
        else{
            cout << M1 << endl;
        }
    }
}

Measured memory_bytes: 3712
import sys
from math import factorial
from collections import Counter
from fractions import Fraction
import heapq, bisect, fractions
import math
import itertools
sys.setrecursionlimit(10 ** 5 + 10)
INF = 10**15 +5
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
MOD = 10**9 + 7

n = input()
hon = [2,4,5,7,9]
pon = [0,1,6,8]
bon = [3,]
if int(n[-1]) in hon:
    print('hon')
elif int(n[-1]) in pon:
    print('pon')
else:
    print('bon')


Measured memory_bytes: 72548
#include <stdio.h>

int main()
{
        int i;
        int j;
        for (i = 1; i < 10; i++)
        {   
                for(j = 1; j < 10; j++)
                {   
                        printf("%dx%d=%d\n", i, j, i*j);
                }    
        }   
        return (0);
}


Measured memory_bytes: 2048
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int s = input.nextInt();
        int w = input.nextInt();
        if (s <= w){
            System.out.println("unsafe");
        } else {
            System.out.println("safe");
        }
    }
}

Measured memory_bytes: 35704
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){
  unsigned short *A, *B;
  int C[VMAX+1];
  int n, i, j;

  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);
  for(i=0;i<VMAX;i++){
    C[i]=0;
  }
  for(j=1;j<=n;j++){
    scanf("%d",&A[j]);
    C[A[j]]++;
  }
  for(i=1;i<VMAX;i++){
    C[i]=C[i]+C[i-1];
  }
  for(j=n;j>0;j--){
    B[C[A[j]]]=A[j];
    C[A[j]]--;
  }

  for(i=1;i<=n;i++){
    if(i!=1) printf(" ");
    printf("%d",B[i]);
  }
  printf("\n");
  return 0;
}



Measured memory_bytes: 9592
#pragma target("avx")
#include<bits/stdc++.h>
using ll = int_fast64_t;
using P = std::pair<ll,ll>;
using V = std::vector<ll>;
template<typename T> using pq = std::priority_queue<T>;
template<typename T> using rpq = std::priority_queue<T, std::vector<T>, std::greater<T>>;

#define rep(i,b,e) for(ll i=b; i<e; i++)
#define be(vec) vec.begin(),vec.end()
#define print(vec) printf("[ ");for(auto &i:vec)printf("%ld ",i);puts("]");
#define scan(vec) for(auto &i:vec)scanf("%ld",&i)
#define fi first
#define se second

const int MOD = 1e9+7;
const ll INF = 1e18;
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

ll n;
ll dfs(ll x){
	if(x>n) return 0l;
	ll tmp = x;
	bool sev=0, fiv=0, thr=0;
	while(tmp){
		if(tmp%10==7) sev = 1;
		if(tmp%10==5) fiv = 1;
		if(tmp%10==3) thr = 1;
		tmp /= 10;
	}
	return (ll)(sev && fiv && thr) + dfs(x*10+7) + dfs(x*10+5) + dfs(x*10+3);
}

int main(){
	scanf("%ld", &n);
	printf("%ld\n", dfs(0));
	return 0;
}


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

int main(){
	int out[100], car[100];
	int x, k = 0, i = 0;
	while(cin >> x){
		if(x != 0){
			car[i] = x;
		}
		else{
			out[k] = car[i-1];
			i = i-2;
			k++;
		}
		i++;
	}
	for(int j = 0; j < k; j++){
		cout << out[j] << endl;
	}
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;

int main() {
string s;
cin >> s;
string ans;
for (int i = 0;i < s.size();i += 2) {
  ans += s.at(i);
}
cout << ans << endl;
return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin >> S;
  map<char,bool> mp;
  for(int i=0; i<S.size();i++){
    if(mp.count(S.at(i))){
      continue;
    }
    else{
      mp[S.at(i)] = true;
    }
  }
  
  if(S.size() <26){
    for(int i=0; i<26; i++){
      char x = 'a' + i;
      if(mp.count(x)){
        continue;
      }
      else{
        S += x;
        break;
      }
    }
    cout << S << endl;
  }
  else{
    int over = -1;
    for(int i=25; i>0; i--){
      if(S.at(i) > S.at(i-1)){
        over = i-1;
        break;
      }
    }
    if(over == -1){
      cout << over << endl;
    }
    else{
      for(int i=0; i<over; i++){
        cout << S.at(i);
      }
      for(int i=25; i>over; i--){
        if(S.at(i) > S.at(over)){
          cout << S.at(i);
          break;
        }
      }
    }
    cout << endl;
  }     
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b , a % b);
}

const ll MOD = 1000000007;
const ll MAX = 2000001;

ll mod(ll a){
  return a % MOD;
}

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

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

void nCrprep() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll nCr(ll n, ll r){
    if (n < r) return 0;
    if (n < 0 || r < 0) return 0;
    return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}

ll nCrcheep(ll n,ll r){
  if(r == 0) return 1;
  else if(r == 1) return n;
  else return nCrcheep(n-1,r-1)*n/r;
}

vector<pair<ll,ll>> prime_factorize(ll n){
  vector<pair<ll,ll>> res;
  
  for(ll i=2; i*i <= n; i++){
    if(n % i != 0) continue;
    
    ll ex = 0;
    while(n % i == 0){
      ex++;
      n /= i;
    }
    
    res.push_back({i,ex});
  }
  
  if(n != 1) res.push_back({n,1});
  
  return res;
  
}




int main(){
  ll a; string b; cin >> a >> b;
  string bd = "";
  
  rep(i,ll(b.size())){
    if(b[i] != '.'){
      bd.push_back(b[i]);
    }
  }
  
  ll c = stoi(bd);
  
  cout << a*c/100 << endl;
  
}
      

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

map<ll, ll> mp;
void ad(ll idx, ll x){
  auto itr = mp.find(idx);
  if(itr==mp.end()) mp.emplace(idx, x);
  else (*itr).second += x;
}
int main(int argc, char const *argv[]) {
  ll n;std::cin >> n;

  vll a(n+1);
  ll ans = 0;
  for(int i=1;i<=n;i++){
    scanf("%lld", &a[i]);
    ll need = 1-a[i]+i-1;
    auto itr = mp.find(need);
    if(itr!=mp.end()) ans += (*itr).second;
    a[i] += i;
    ad(a[i], 1);
  }
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 16828
#include <cstdio>
#include <queue>
using namespace std;
const long long NR=114514;
char s[NR],c;
long long l,q,t,f,cs;
deque<char> ans;
int main()
{
	scanf("%s",s);
	while(s[l])
	{
		l++;
	}
	for(long long i=0;i<l;i++)
	{
		ans.push_back(s[i]);
	}
	scanf("%lld",&q);
	for(long long i=1;i<=q;i++)
	{
		scanf("%lld",&t);
		if(t==1)
		{
			cs++;
		}
		else
		{
			scanf("%lld %c",&f,&c);
			if((f+cs)&1==1)
			{
				ans.push_front(c); 
			}
			else
			{
				ans.push_back(c);
			}
		}
	}
	if(cs&1)
	{
		while(!ans.empty())
		{
			printf("%c",ans.back());
			ans.pop_back();
		}
	}
	else
	{
		while(!ans.empty())
		{
			printf("%c",ans.front());
			ans.pop_front();
		}
	}
	return 0;
}

Measured memory_bytes: 896
import math
A, B, H, M = map(int, input().split())
x1 = A*math.sin((H+M/60)/6*math.pi)
y1 = A*math.cos((H+M/60)/6*math.pi)
x2 = B*math.sin(M/30*math.pi)
y2 = B*math.cos(M/30*math.pi)
print(((x1-x2)**2+(y1-y2)**2)**0.5)



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

int main(void){
    int N;
    cin >> N;
    
    int n = N % 1000;
    if(n == 0){
        cout << 0 << endl;
        return 0;
    }
    cout << 1000 - n << endl;
    
}

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")

int main()
{
int X;
	cin >> X;
	int ans = 1;
	while ((X*ans)%360!=0) {
		ans++;
	}
	ce(ans)
    return 0;
}



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

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

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

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;}

int main() {
  int n;
  cin >> n;
  map<string, int> mp;
  string prev;
  bool byes = true;
  rep(i,n){
    string s;
    cin >> s;
    mp[s]++;
    if(i != 0){
      if(prev[prev.size()-1] != s[0]){
        byes = false;
      }
    }
    if(mp[s] > 1){
      byes = false;
    }
    prev = s;
  }

  if(byes) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb(x) push_back(x)
#define PI pair<int,int>
#define PL pair<long int,long int>
#define PLL pair<ll,ll>
#define Tcase int t;cin>>t;while(t--)   
int main(){
int a,b,c,d;
  cin>>a>>b>>c>>d;
  int t,A;
  if(a%d!=0)
    A=(a/d)+1;
  else
    A=(a/d);
  if(c%b!=0)
    t=(c/b)+1;
  else
    t=c/b;
  if(t<=A)
    cout<<"Yes"<<"\n";
  else
    cout<<"No"<<"\n";
return 0;
}

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

int main(){

    double w, h, x, y;
    cin >> w >> h >> x >> y;

    double ans = (w*h)/2.0;
    bool flg = (2.0*x == w) && (2.0*y == h);

    cout << fixed << setprecision(10);
    cout << ans << " " << flg << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MAXN 100010
int n,m,ans; int Adj[MAXN],V[MAXN*2],nxt[MAXN*2],c; int Sum[MAXN],vis[MAXN],flag[MAXN],cir,cx,cy,tot; int st[MAXN],r;
void AddEdge(int u,int v) { c++;V[c]=v,nxt[c]=Adj[u];Adj[u]=c; }
void dfs(int u,int p) {
	tot+=Sum[u]; vis[u]=1;
	for(int i=Adj[u];i;i=nxt[i])
		if(V[i]!=p) {
			if(vis[V[i]]) { cx=u,cy=V[i]; cir=(Sum[V[i]]==Sum[u]); continue; }
			Sum[V[i]]=-Sum[u]; dfs(V[i],u);
		}
}
void Solve(int u,int p) { vis[u]=0; for(int i=Adj[u];i;i=nxt[i]) if(V[i]!=p&&vis[V[i]]) { Solve(V[i],u); Sum[u]+=Sum[V[i]]; flag[u]+=flag[V[i]]; } }
int main() {
	scanf("%d%d",&n,&m); int u,v; for(int i=1;i<=m;i++) { scanf("%d%d",&u,&v); AddEdge(u,v); AddEdge(v,u); } Sum[1]=1; dfs(1,0);
	if(m==n-1) { if(tot!=0) { printf("-1\n"); return 0; } }
	else if(cir) { if(tot%2!=0) { printf("-1\n"); return 0; } Sum[cx]-=tot/2; Sum[cy]-=tot/2; ans+=abs(tot)/2; }
	else { if(tot!=0) { printf("-1\n"); return 0; } flag[cx]=-1,flag[cy]=1; }
	Solve(1,0); for(int i=1;i<=n;i++) { if(flag[i]==0) ans+=abs(Sum[i]); else { if(flag[i]==1) Sum[i]=-Sum[i]; st[++r]=Sum[i]; } }
	sort(st,st+r+1); int K=st[r/2]; for(int i=0;i<=r;i++) ans+=abs(st[i]-K);
	printf("%d\n",ans);
}

Measured memory_bytes: 8448
use std::io::*;
use std::str::FromStr;
 
/* 
The read function reads a string according to each one. 
*/
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

//main function
fn main() {
    let mut vec: Vec<i32> = vec![1;3];
    for i in 0..3 {
	let a:i32 = read();
	vec[i] = a;
    }
    vec.sort();
    println!("{}",vec[2]-vec[0]);
}


Measured memory_bytes: 4352