akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
 
ll gcd(ll a, ll b){
      return (a%b==0)? b: gcd(b,a%b);
}
ll lcm(ll a, ll b){
      return a/gcd(a,b)*b;
}
 
int main(){
 
      int n; cin >> n;
      int a[n];
      for(int i=0; i<n; i++) cin >> a[i];
 
      int ans = a[0];
      for(int i=0; i<n; i++) ans = lcm(ans,a[i]);
      cout << ans << endl;
       
 
}

Measured memory_bytes: 3084
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<ctime>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<cstring>
#include<map>
#include<vector>
#include<set>
#define rep(i,j,k) for(register int i = j; i <= k; i++) 
#define dow(i,j,k) for(register int i = j; i >= k; i--)
#define fi first
#define se second
//#define P pair<ll,ll>
#define mp(a,b) make_pair(a,b)
#define ll long long
#define ull unsigned long long
using namespace std;

inline int read() { 
	int s = 0, t = 1; char c = getchar();
	while( !isdigit(c) ) { if( c == '-' ) t = -1; c = getchar(); }
	while( isdigit(c) ) s = s * 10 + c - 48, c = getchar();
	return s * t;
}

const int N = 1e5+5;
int a[N], b[N], c[N], ret = 0;

int main() {
	int n = read(), m = read(), x;
	rep(i,1,m) { 
		x = read();
		if( x & 1 ) a[++a[0]] = x;
		else b[++b[0]] = x;
	}
	
	if( n == 1 ) { 
		puts("1");
		puts("1");
		puts("1");
		return 0;
	}
	if( m == 1 ) { 
		printf("%d\n", n);
		puts("2");
		printf("%d %d\n", n-1,1);
		return 0;
	}
	
	if( a[0] >= 3 ) puts("Impossible");
	else { 
		if( !a[0] ) { 
			rep(i,1,b[0]) printf("%d ", b[i]); puts("");
			
			ret = b[0];
			printf("%d\n", ret);
			
			rep(i,1,b[0]) printf("%d ", i == 1 ? b[i] - 1 : (i == b[0] ? b[i] + 1 : b[i]));
			puts("");
		} else if( a[0] == 1 ) { 
			printf("%d ", a[1]); rep(i,1,b[0]) printf("%d ", b[i]); puts("");
			
			ret = ((a[1] - 1) > 0) + b[0];
			printf("%d\n", ret);
			
			if( a[1] - 1 ) printf("%d ", a[1] - 1);
			rep(i,1,b[0]) printf("%d ", i == b[0] ? b[i] + 1 : b[i]);
			puts("");
		} else { 
			printf("%d ", a[1]); rep(i,1,b[0]) printf("%d ", b[i]); printf("%d ", a[2]); puts(""); 
			
			ret = ((a[1] - 1) > 0) + b[0] + 1;
			printf("%d\n", ret);
			
			if( a[1] - 1 ) printf("%d ", a[1] - 1);
			rep(i,1,b[0]) printf("%d ",b[i]);
			printf("%d ", a[2] + 1);
			puts("");
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<queue>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int inf=0x7fffffff;
int n,m,cnt,etot,tot=1,sx,sy,tx,ty,S,T,idx[110][110],idx1[110],idx2[110],num1[110],num2[110],dep[20510],cur[20510],head[20510],to[100010],nxt[100010],val[100010];
char s[110];
void add_edge(int u,int v,int w){
	nxt[++tot]=head[u];
	to[tot]=v;
	val[tot]=w;
	head[u]=tot;
	return;
}
void Add_edge(int u,int v,int w){
	add_edge(u,v,w);
	add_edge(v,u,0);
	return;
}
bool bfs(){
	queue<int>q;
	q.push(S);
	memset(dep,0,sizeof(dep));
	dep[S]=1;
	while(!q.empty()){
		int u=q.front();
		q.pop();
		cur[u]=head[u];
		for(int i=head[u];~i;i=nxt[i]){
			int v=to[i];
			if(!dep[v]&&val[i]){
				dep[v]=dep[u]+1;
				q.push(v);
			}
		}
	}
	if(dep[T])
		return 1;
	return 0;
}
int dfs(int u,int now){
	if(u==T||!now)
		return now;
	int ret=0;
	for(int &i=cur[u];~i;i=nxt[i]){
		int v=to[i];
		if(dep[v]!=dep[u]+1&&val[i])
			continue;
		int dist=dfs(v,min(val[i],now));
		if(dist){
			val[i]-=dist;
			val[i^1]+=dist;
			now-=dist;			
			ret+=dist;
			if(!now)
				break;
		}
	}
	return ret;
}
int Dinic(){
	int ret=0;
	while(bfs())
		ret+=dfs(S,0x7fffffff);
	return ret;
}
int main(){
	memset(head,-1,sizeof(head));
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++){
		scanf("%s",s+1);
		for(int j=1;j<=m;j++)
			if(s[j]=='o'||s[j]=='S'||s[j]=='T'){
				idx[i][j]=++etot;
				if(s[j]=='S'){
					S=etot;
					sx=i;
					sy=j;
				}
				else if(s[j]=='T'){
					T=etot;
					tx=i;
					ty=j;
				}
			}
	}
	if(sx==tx||sy==ty){
		puts("-1");
		return 0;
	}
	cnt=etot;
	etot<<=1;
	for(int i=1;i<=n;i++)
		idx1[i]=++etot;
	for(int i=1;i<=m;i++)
		idx2[i]=++etot;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(idx[i][j]){
				Add_edge(idx[i][j]+cnt,idx1[i],inf);
				Add_edge(idx[i][j]+cnt,idx2[j],inf);
				Add_edge(idx1[i],idx[i][j],inf);
				Add_edge(idx2[j],idx[i][j],inf);
				if(idx[i][j]!=S&&idx[i][j]!=T)
					Add_edge(idx[i][j],idx[i][j]+cnt,1);
			}
		}
	}
	S+=cnt;
	printf("%d",Dinic());
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define int long long
#define double long double
#define all(a) a.begin(), a.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

//ABC137
signed main(void){

    int n; cin >> n;
    vector<vector<char>> a(n, vector<char>(10));
    rep(i, n){
        rep(j, 10)cin >> a[i][j];
        sort(all(a[i]));
    }

    map<vector<char>, int> mp;
    rep(i, n){
        mp[a[i]]++;
    }

    int ans = 0;
    for(auto p : mp){
        ans += p.second * (p.second - 1) / 2;
    }
    cout << ans << endl;

}

Measured memory_bytes: 16640
n = int(input())
A = list(map(int, input().split()))

#%%
setA = set(A)
if len(setA) == 1:
    if sum(A) == 0:
        ans = 'Yes'
    else:
        ans = 'No'

elif len(setA) == 2:
    a1, a2 = sorted(setA)
    if (a1 == 0) and (A.count(a1) * 3 == n):
        ans = 'Yes'
    else:
        ans = 'No'

elif len(setA) == 3:
    a1, a2, a3 = setA
    if (a1 ^ a2 ^ a3 == 0) and (A.count(a1) == A.count(a2) == A.count(a3)):
        ans = 'Yes'
    else:
        ans = 'No'
else:
    ans = 'No'

print(ans)

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

using namespace std;

int n,m,ans;

int a[110];

int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	for (int i=1;i<=n;i++){
		if (m<a[i]) break;
		if (m>=a[i]) m-=a[i],ans++;
	}
	if (m!=0 && ans==n) ans--;
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 256
import math
def primes(n):
    a = list(range(2, n+1))
    primes = [2]
    for i in a:
        flag = True
        m = math.sqrt(i)
        for j in primes:
            if j > m:
                break
            else:
                if i % j == 0:
                    flag = False
                    break
        if flag:
            primes.append(i)
    return primes
primes = primes(10**5)
dp = [0]*(10**5+1)
cnt = 0
for i in range(1, 10**5+1, 2):
    if i in primes:
        if (i+1)//2 in primes:
            cnt += 1
    dp[i] = cnt
 
    
Q = int(input())
for _ in range(Q):
    l, r = map(int, input().split())
    print(dp[r]-dp[l-2])

Measured memory_bytes: 52312
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// container util
#define all(x) (x).begin(), (x).end()

// debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x)                                         \
  cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
       << " " << __FILE__ << endl;

// typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

// constant
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

// conversion
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
//

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

  string s;
  cin >> s;

  if (s[0] == 'S')
    cout << "Cloudy" << endl;
  else if (s[0] == 'C')
    cout << "Rainy" << endl;
  else if (s[0] == 'R')
    cout << "Sunny" << endl;

  return 0;
}

Measured memory_bytes: 256
D, G=map(int, input().split())
pc=[list(map(int, input().split())) for i in range(D)]

def num2bi(x, k):
  #10進数xを2進数k桁(string)で出力
  out=format(x, '0'+str(k)+'b')
  return out
  
n=2**D
counter=sum(pc[i][0] for i in range(D))
for i in range(n):
  a=num2bi(i, D)
  c=0
  p=0
  for j in range(D):
    if a[j]=='1':
      p+=pc[j][0]*(j+1)*100+pc[j][1]
      c+=pc[j][0]
      
  if p<G:
    j=D
    while j>0 and p<G:
      j-=1
      if a[j]=='0':
        temp=(G-p)//(100*(j+1))
        if (G-p)%(100*(j+1))>0:
          temp+=1
          
        if temp<=pc[j][0]-1:
          p+=100*(j+1)*temp
          c+=temp
        else:
          p+=100*(j+1)*(pc[j][0]-1)
          c+=(pc[j][0]-1)
          
  if p>=G:
    counter=min(counter, c)
  
print(counter)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using ull = uint64_t;

void print() { cout << endl; }
template <typename Head, typename... Tail>
void print(Head head, Tail... tail) {
    int size = sizeof...(Tail);
    cout << head;
    if (size > 0) {
        cout << " ";
    }
    print(tail...);
}

void print0() {}
template <typename Head, typename... Tail>
void print0(Head head, Tail... tail) {
    cout << head;
    print0(tail...);
}

struct xstruct {
    ll val;
};
bool operator<=(const xstruct& lhs, const xstruct& rhs) {
    return lhs.val <= rhs.val;
}
bool operator<(const xstruct& lhs, const xstruct& rhs) {
    return lhs.val < rhs.val;
}
bool operator>=(const xstruct& lhs, const xstruct& rhs) {
    return lhs.val >= rhs.val;
}
bool operator>(const xstruct& lhs, const xstruct& rhs) {
    return lhs.val > rhs.val;
}
bool operator==(const xstruct& lhs, const xstruct& rhs) {
    return lhs.val == rhs.val;
}
bool operator!=(const xstruct& lhs, const xstruct& rhs) {
    return lhs.val != rhs.val;
}
ostream& operator<<(ostream& os, xstruct const& xst) {
    return os << xst.val;
}

int main() {
    string sa, sb;
    getline(cin, sa);
    getline(cin, sb);

    ll la = sa.length();
    ll lb = sb.length();

    // edit_distance
    vector<vector<ll>> edit_distance(la + 1, vector<ll>(lb + 1));
    for (ll a = 0; a <= la; a++) {
        for (ll b = 0; b <= lb; b++) {
            edit_distance[a][b] = -1;
        }
    }
    for (ll a = 0; a <= la; a++) {
        edit_distance[a][0] = a;
    }
    for (ll b = 0; b <= lb; b++) {
        edit_distance[0][b] = b;
    }
    for (ll a = 1; a <= la; a++) {
        for (ll b = 1; b <= lb; b++) {
            ll minval = la + lb;
            if (sa.at(a - 1) == sb.at(b - 1)) {
                minval = min(minval, edit_distance[a - 1][b - 1]);  // same
            }
            minval = min(minval, 1 + edit_distance[a - 1][b - 1]);  // replace
            minval = min(minval, 1 + edit_distance[a - 1][b]);      // insert
            minval = min(minval, 1 + edit_distance[a][b - 1]);      // delete
            edit_distance[a][b] = minval;
        }
    }

    print(edit_distance[la][lb]);
}



Measured memory_bytes: 10864
#include<bits/stdc++.h>
#include<cmath>
#include<string>
using namespace std;
#define f first
#define s second
#define MOD 1000000007
#define fast ios::sync_with_stdio(0),cout.tie(0),cin.tie(0)
#define pb push_back
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define mp make_pair
#define mkt make_tuple
#define deb(x) cerr<<#x<<" "<<x<<"\n"
typedef long long ll;
typedef unsigned long long ull;
class solution{
public:
	void solve(){
		int a,b,c;
		cin>>a>>b>>c;
		bool ok = false;
		if(a == b){
			if(b != c){
				cout<<"Yes";
			}
			else{
				cout<<"No";
			}
			return ;
		}
		else if(b == c){
			if(a != c){
				cout<<"Yes";
			}
			else{
				cout<<"No";
			}
			return ;
		}
		else if(a == c){
			if(b != c){
				cout<<"Yes";
			}
			else{
				cout<<"No";
			}
			return ;
		}
		else{
			cout<<"No";
		}
	}

};

int main()
{
    fast;
	ll i=0;
	solution s;
	s.solve();

 return 0;
}



Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    if(Integer.parseInt(sc.next())==0){
      System.out.println(1);
    }
    if(Integer.parseInt(sc.next())==0){
      System.out.println(2);
    }
    if(Integer.parseInt(sc.next())==0){
      System.out.println(3);
    }
    if(Integer.parseInt(sc.next())==0){
      System.out.println(4);
    }
    if(Integer.parseInt(sc.next())==0){
      System.out.println(5);
    }
  }
  
}



Measured memory_bytes: 35688
/*
 *
 */
#include <cstdio>
#include <iostream>

using namespace std;

int main(){
    //freopen("a.in", "r", stdin);
    string s;
    cin >> s;

    string string_like = "YAKI";
    bool flag = true;
    if (s.size() < string_like.size()) {
        flag = false;
    } else {
        for (int i = 0; i < string_like.size(); ++i) {
            if (s[i] != string_like[i]) {
                flag = false;
                break;
            }
        }
    }
    if (flag) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.lang.String;
import java.lang.StringBuilder;
import java.lang.System;
import java.util.HashSet;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);

        int lineNum = sc.nextInt();
        sc.nextLine(); // Skip /n

        for (int i = 0; i < lineNum; i++) {
            String str = sc.nextLine();
            str = findEncodedString(str);
            System.out.println(str);
        }
    }

    public static String findEncodedString(String s) {
        for (int a = 1; a < 26; a++) {
            for (int b = 0; b < 26; b++) {
                String encStr = encode(s, a, b);
                for (String word : encStr.split(" ")) {
                    if (word.length() == 4) {
                        if (word.equals("this") || word.equals("that")) { return encStr; }
                    } else {
                        continue;
                    }
                }
            }
        }
        return s;
    }

    public static String encode(String s, int a, int b) {
        StringBuilder sb = new StringBuilder();
        for (char ch : s.toCharArray()) {
            if('a' <= ch && ch <= 'z') {
                int x = (a * (ch - 'a') + b) % 26;
                sb.append((char)('a' + x));
            } else {
                sb.append(ch);
            }
        }
        return sb.toString();
    }
}

Measured memory_bytes: 45292
#include <string>
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
int main()
{
    vector<bool> table(1000000000);
    int n;
    cin >> n;
    rep(i,n){
        long long a;
        cin >> a;
        if(table[a]){
            cout << "NO" << endl;
            return 0;
        }
        table[a] = true;
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 125032
n, z, w = list(map(int, input().split()))
a = list(map(int, input().split()))

if n == 1:
    print(abs(a[0]-w))
else:
    ans1 = abs(a[-1] - w)
    ans2 = abs(a[-2] - a[-1])
    print(max(ans1, ans2))


Measured memory_bytes: 3188
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
      int K,A,B;
      cin >> K >> A >> B ;
      long x=0;
      long y=0;
      long z= 0;
      long w= 0;
      long q= 0;
      x=K/2;
      y=(B-A);
      z=(K-A+1);
      w=z/2;
      q = w*y;
      if (y <3 || z < 0){
      cout << K+1 << endl;}
     else if (z % 2  == 0){
     cout << A + q << endl;}
      else {cout << A +q  +1 <<  endl;}
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int a,b,c,n,tmp;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a>>b>>c;
    if(a<b){
      tmp=a;
      a=b;
      b=tmp;
    }
    if(a<c){
      tmp=a;
      a=c;
      c=tmp;
    }
    if(a*a==b*b+c*c){
      cout<<"YES"<<endl;
    }else{
      cout<<"NO"<<endl;
    }
  }
  return 0;
}


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

int main()
{
    string s;
    cin >> s;
    int count = 0;
    rep(i, s.size() / 2)
    {
        if (s.at(i) != s.at(s.size() - 1 - i)) {
            count++;
        }
    }
    cout << count << endl;
}



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

int main(){
    string s;
    cin >> s;

    ll len = s.length();
    ll ans = 0;
    ll flag = 0;
    ll cou = 0;
    if(s[len - 1] == 'B'){
        flag = 0;
    }else{
        flag = 1;
        cou++;
    }

    for(ll i = len - 2; i >= 0; i--){
        if(s[i] == 'B'){
            if(flag = 1){
                ans += cou;
            }
        }else{
            flag = 1;
            cou++;
        }
    }

    cout << ans << endl;
}

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

#define REP(i,n) for(ll i=0; i < (n); ++i)
#define REPR(i,n) for(ll i=(n); i >= 0; --i)
#define FOR(i, m, n) for(ll i = (m); i < (n); ++i)

#define INF 1e9



int main(){
  string S;
  ll K;
  cin >> S >> K;
  ll pre = 0, back = 0;
  while(S[0] == S[pre]){
    pre++;
  }
  while(back != S.size() && S.back() == S[S.size()-1-back]){
    back++;
  }
  ll ans = 0;
  ll cnt = 0;
  if(pre == S.size()){
    ans = (ll)K*(ll)S.size()/2;
    cout << ans << endl;
    return 0;
  }
  else if(S[0] == S.back()){
    ans += pre/2;
    ans += back / 2;
    ans += (K-1) * ((pre+back)/2);
    char c = S[pre];
    FOR(i, pre, S.size()-back){
      if(S[i] == c){
        cnt++;
      }
      else{
        ans += K * (cnt/2);
        cnt = 1;
      }
      c = S[i];
    }
    ans += K*(cnt/2);
  }
  else{
    char c = S[0];
    REP(i, S.size()){
      if(S[i] == c){
        cnt++;
      }
      else{
        ans += K*(cnt/2);
        cnt = 1;
      }
      c = S[i];
    }
    ans += K*(cnt/2);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
sx, sy, tx, ty = map(int, input().split())
x, y = tx-sx, ty-sy
print('R'*x + 'U'*y + 'L'*x + 'D'*y
      + 'D' + 'R'*(x+1) + 'U'*(y+1) + 'L' + 'U' + 'L'*(x+1) + 'D'*(y+1) + 'R')

Measured memory_bytes: 3060
import collections
n,s = int(raw_input()), raw_input()

def f(k, s):	
 	cc,q = collections.Counter(), collections.deque()
	for j in range(k - 1, len(s)):
		q.append(s[j - k + 1:j+1])
		if len(q) == k + 1: cc[q.popleft()] += 1
		if q[-1] in cc: return True	
	return False

lo,hi = 0, n/2
while(lo < hi):
	med = (lo + hi + 1) / 2
	if f(med, s):  lo = med
	else:hi = med - 1
print lo

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

void solve(string s, string t, int m, int n){
    int dp[m+1][n+1];
    for(int i = 0; i <= m; i++)dp[i][0] = 0;
    for(int j = 0; j <= n; j++)dp[0][j] = 0;
    
    for(int i = 1; i <= m; i++){
        for(int j = 1; j <= n; j++){
            if(s[i-1] == t[j-1])dp[i][j] = 1 + dp[i-1][j-1];
            else{
                dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
            }
        }
    }
    
    int index = dp[m][n];
    char ans[index+1];
    ans[index] = '\0';
    int i = m, j = n;
    while(i > 0 && j > 0){
        if(s[i-1] == t[j-1]){
            ans[index-1] = s[i-1];
            i--;
            j--;
            index--;
        }
        else if(dp[i-1][j] > dp[i][j-1]){
            i--;
        }
        else {
            j--;
        }
    }
    cout<<ans;
}

int main() {
	string s,t;
	cin>>s>>t;
	solve(s,t,s.length(),t.length());
	//cout<<tans<<" "<<ans;
	return 0;
}

Measured memory_bytes: 35456
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<ll> >;

const ll INF = 1e18;
const ll MOD = 1000000007;
const ll MX = 0; //最大値

#define rep(i,n) for(ll i=0; i<(ll)(n); i++)
#define ALL(x) (x).begin(),(x).end()
#define MAX(x) *max_element(ALL(x))
#define PB push_back
#define F first
#define S second

int main(){
    ll n, x, t; cin >> n >> x >> t;
    ll ans = n / x;
    if (n % x != 0) ans++;
    cout << t*ans << endl;
    return 0;
}

Measured memory_bytes: 3632
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#include<map>
#include<vector>
using namespace std;
const int MaxN = 1e5;

int main()
{
	long long a,b,c,k;
	while(~scanf("%lld %lld %lld %lld",&a,&b,&c,&k))
	{
		if(k %2 == 0) printf("%d\n",a - b);
		else printf("%d\n",b - a);
	}
	return 0;
}

Measured memory_bytes: 128
from itertools import product
import numpy as np

N, M, X = list(map(int, input().split()))

costs = np.zeros(N, dtype=int)
up = np.zeros((N, M), dtype=int)
for i in range(N):
  l = list(map(int, input().split()))
  costs[i] = l[0]
  up[i, :] = l[1:]

# print(f"cost \n{costs}")
# print(f"up \n{up}")

b = [[False, True]] * N
min_cost = np.inf
# print(f"pattern : {len(list(product(*b)))}")
for p in product(*b):
  # print("===--" * 10)
  p = list(p)
  case_cost = np.sum(costs[p])
  case_up = np.sum(up[p, :], axis=0)
  if (case_up >= X).all() and min_cost > case_cost:
    min_cost = case_cost
if min_cost == np.inf:
  print(-1)
else:
  print(min_cost)


Measured memory_bytes: 27332
import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 19
MOD = 10 ** 9 + 7

x, N = MAP()
A = LIST()

S = set(A)
i = 0
if x not in S:
    print(x)
    exit()
l = r = x
while 1:
    l -= 1
    r += 1
    if l not in S:
        print(l)
        break
    if r not in S:
        print(r)
        break


Measured memory_bytes: 9288
#include<stdio.h>

int A[1000000],n;

int binarySearch(int key){
  int left = 0;
  int right = n;
  int mid;
  while(left<right){
    mid = (left + right)/2;
    if(key == A[mid]) return 1;
    if(key > A[mid]) left = mid + 1;
    else if(key < A[mid])right = mid;
  }
  return 0;
}

int main(){
  int i,q,k;
  int sum=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
  scanf("%d",&A[i]);
}
scanf("%d",&q);
for(i=0;i<q;i++){
  scanf("%d",&k);
  if(binarySearch(k))sum++;
 }
printf("%d\n",sum);
return 0;
}



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



int main()
{
  string S;cin>>S;
  if(S[0]!='A'||S.size()<3){printf("WA");return 0;}
  int countc=0;
  for(int i=2;i<S.size()-1;i++)if(S[i]=='C')countc++;
  if(countc!=1){printf("WA");return 0;}
  for(int i=1;i<S.size();i++)if(S[i]!='A'&&S[i]!='C'&&S[i]-'A'>=0&&S[i]-'A'<=26){printf("WA");return 0;}
  printf("AC");
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define SPEED ios_base::sync_with_stdio(false); cin.tie(NULL)
#define REP(i,a,b) for(int i=a,_b=b;i<=_b;i++)
#define rep(i,n) REP(i,0,n-1)
#define FORD(i,b,a) for(int i=b,_a=a;i>=_a;i--)
#define ford(i,n) FORD(i,n-1,0)
#define sqr(x) ((x)*(x))
#define ll long long
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector<pi>
#define vll vector<ll>
#define fi first
#define se second
#define all(a) a.begin(),a.end()
#define add push_back
#define len(arr) arr.size()
#define print(x) cout<<(x)<<'\n'
using namespace std;
 
ll a[3003];

int main() {
	SPEED;
	//freopen("in.txt", "r", stdin);
	int n; cin >> n;
	rep(i, n) cin >> a[i];
	ll res = 0;
	rep(i, n) res += a[i] - 1;
	print(res);
	return 0;
}  

Measured memory_bytes: 256
use proconio::input;

fn main() {
    input! {
        n: usize,
        xy: [(i64, i64); n],
    };
    let mut map = std::collections::BTreeMap::new();
    for (i, &(x_i, y_i)) in xy.iter().enumerate() {
        for (j, &(x_j, y_j)) in xy.iter().enumerate() {
            if i == j {
                continue;
            }
            *map.entry((x_j - x_i, y_j - y_i)).or_insert(0) += 1;
        }
    }
    let mut c = vec![];
    for (&k, &v) in map.iter() {
        c.push((v, k.0, k.1));
    }
    c.sort_by_key(|(c, _, _)| -c);
    let ans = n as i64 - c.first().unwrap_or(&(0, 0, 0)).0;
    println!("{:?}", ans);
}


Measured memory_bytes: 2192
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#pragma region Macros
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define all(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
int gcd(int a, int b) // assuming a,b >= 1
{
    if (a < b)
        swap(a, b);
    if (b == 0)
        return a;
    if (a % b == 0)
        return b;
    return gcd(b, a % b);
}
int lcm(int a, int b) // assuming a,b >= 1
{
    return  a * b / gcd(a, b);
}
using namespace std;
#pragma endregion
signed main() {
    int A,B,C;
    cin >> A >> B >> C;
    if (B / A > C)
        cout << C;
    else
        cout << B / A;
}

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

namespace ConsoleApplication54
{
    class Program
    {
        static void Main()
        {
            int[] a = new int[int.Parse(Console.ReadLine())];
            Console.ReadLine();int p = 0;
            int[] c = Console.ReadLine().Split().Select(int.Parse).ToArray();
            for(int d = 0; d < c.Length; d++)
            {
                int[] e = Console.ReadLine().Split().Select(int.Parse).ToArray();
                p = 0;
                for (int f = 0; f < e.Length; f++)
                {                  
                    if (c[d] == e[f]) { a[f]++;p++; }                   
                }
                a[c[d] - 1] += a.Length - p;
            }
            foreach(int i in a)
            {
                Console.WriteLine(i);
            }
        }
    }
}

Measured memory_bytes: 9656
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
 
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define C(i) cin>>i
#define C2(i,j) cin>>i>>j
#define C3(i,j,k) cin>>i>>j>>k
#define C4(i,j,k,m) cin>>i>>j>>k>>m
////////////////////////////////////////////////////////////

int main(){
	int n;
	cin >> n;
	vector<int> a;
	rep(i,0,n){
		int t;
		cin >> t;
		a.push_back(t);
	}

	rvsort(a);

	int s1=0,s2=0;
	rep(i,0,n){
		if(i%2 == 0)
			s1 += a[i];
		else
			s2 += a[i];
	}
	
	cout << abs(s1-s2) << endl;

	ret 0;
}

Measured memory_bytes: 256
l, r = list(map(int, input().split(' ')))
hoge = 2019
for i in range(l, r+1):
    for j in range(i+1, r+1):
        hoge = min(hoge, (i*j) % 2019)
        if not hoge:
            break
    if not hoge:
        break
print(hoge)

Measured memory_bytes: 38896
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  long long a, b, c;

  std::cin >> a >> b >> c;

  if (c - a - b <= 0) {
    std::cout << "No" << std::endl;
  }
  else {
    std::cout << (4 * a * b < (c - a - b) * (c - a - b) ? "Yes" : "No") << std::endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int record[11];
long long ans=0;
int len,s;
string str;
void check()
{
	long long num=str[0]-'0';
	for(int i=0;i<len-1;i++)
	{
		if(record[i]==1)
		{
			ans+=num;
			num=0;
		}
		num=num*10+str[i+1]-'0';
	}
	ans+=num;
}
void doing(int v)
{
	if(v==len)
	{
		check();
		return;
	}
	record[v]=0;
	doing(v+1);
	record[v]=1;
	doing(v+1);
}
int main()
{
	cin>>str;
	len=str.size();
	doing(0);
	cout<<ans/2;
}

Measured memory_bytes: 256
#include <stdio.h>

#define L 10

static int ans[ 11 ][ 331 ] = { { 0 } };

static void
solve (
  int   n,
  int   s,
  int * d
  )
{
  int i;

  if ( n > 10 ) return ;

  for ( i = 0; i < L; ++i )
  {
    const int tmp = d[ i ]
            , sum = s + n * tmp;

    if ( tmp < 0 ) continue ;

    ++ans[ n ][ sum ];
    d[ i ] = -1;
    solve ( n + 1, sum, d );
    d[ i ] = tmp;
  }

  return ;
}

/** Application main entry point. */
int
main (
  int     argc,
  char  * argv[ ]
  )
{
  int d[ ] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
  solve ( 1, 0, d );

  for ( ; ; )
  {
    int n, s;

    if ( scanf ( "%d%d", &n, &s ) != 2 ) break ;

    if ( n > 10 || s > 330 )
    {
      puts ( "0" );
    }
    else
    {
      printf ( "%d\n", ans[ n ][ s ] );
    }
  }

  return ( 0 );
}

Measured memory_bytes: 296
#pragma region template
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template <typename T>
using pqrev = priority_queue<T, vector<T>, greater<T>>;
#define rep(i, n) for (ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for (ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for (ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
//*
constexpr ll MOD = 1e9 + 7;
/*/
constexpr ll MOD = 998244353;
//*/
constexpr ll INF = 1e+18;
constexpr ld EPS = 1e-12L;
constexpr ld PI = 3.14159265358979323846L;
constexpr ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
constexpr ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
template <typename S, typename T>
inline bool chmax(S &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename S, typename T>
inline bool chmin(S &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif
template <typename T>
bool print_(const T &a) {
  cout << a;
  return true;
}
template <typename T>
bool print_(const vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back()) {
      cout << " ";
    }
  }
  return false;
}
template <typename T>
bool print_(const vector<vector<T>> &vv) {
  for (auto &v : vv) {
    for (auto &a : v) {
      cout << a;
      if (&a != &v.back()) {
        cout << " ";
      }
    }
    if (&v != &vv.back()) {
      cout << "\n";
    }
  }
  return false;
}
void print() { cout << "\n"; }
template <typename Head, typename... Tail>
void print(Head &&head, Tail &&... tail) {
  bool f = print_(head);
  if (sizeof...(tail) != 0) {
    cout << (f ? " " : "\n");
  }
  print(forward<Tail>(tail)...);
}
#pragma endregion

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  unordered_set<int> st;
  int k;
  cin >> k;
  int x = 7 % k;
  int ans = 1;
  while(1){
    if(x == 0){
      print(ans);
      return 0;
    }
    if(st.count(x)){
      print(-1);
      return 0;
    }
    st.emplace(x);
    x = x * 10 + 7;
    x %= k;
    ans++;
  }
}


Measured memory_bytes: 42636
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
    int n,d;
    cin >> n >> d;
    int X[n][d];
    for(int i=0;i<n;i++){
        for(int j=0;j<d;j++){
            cin >> X[i][j];
        }
    }

    int ans=0;
    for(int i=0;i<(n-1);i++){
        

        for(int j=i+1;j<n;j++){
            int memo[d];
            int me=0;
            float sme=0;
            for(int m=0;m<d;m++){
                int as = abs(X[i][m] - X[j][m]);
                memo[m] = as * as; 
            }
            for(int m=0;m<d;m++) me += memo[m];
            sme = sqrt(me);
        
            if(ceil(sme) == floor(sme)){
                ans++;
            }
        }
    }
    cout << ans;

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef pair<double, long long> pdl;

const long double pi = 3.141592653589793;

#define debug(x) cerr << #x << " = " << (x) << endl;
#define rep(i, n) for(int i = 0;i < n;i++)
#define pb push_back
#define mp make_pair
#define mod 1000000007

bool allwhite(vector<string> &vs) {
    int n = vs.size();
    rep(i, n) rep(j, n) if(vs[i][j] == '#') return false;
    return true;
}

int main() {

    //freopen("input07.txt","r",stdin);
    //freopen("output_file_name.txt","w",stdout);
    int n;cin>>n;
    vector<string> vs(n);
    rep(i, n) cin>>vs[i];

    if(allwhite(vs)) {cout<<"-1";return 0;}

    vector<int> winc(n, 0);
    rep(i, n) {
        int counter = 0; rep(j, n) if(vs[j][i] == '.') counter++;
        winc[i] = counter;
    }

    // black color row present
    rep(i, n) {
        bool present = true;
        rep(j, n) {
            if(vs[i][j] == '.') {
                present = false;
                break;
            }
        }

        if(present) {
            int ans = 0;
            rep(i, n) if(winc[i] != 0) ans++;
            cout<<ans<<endl;
            return 0;
        }
    }

    int answer = 100000;
    for(int i = 0;i < n;i++) {
        int ans = 0;
        rep(j, n) if(vs[i][j] == '#') {if(winc[j] != 0) ans++;}
                  else ans += 2;
        if(winc[i] == n)
            answer = min(ans+1, answer);
        else
            answer = min(ans, answer);
    }

    cout<<answer<<endl;

    return 0;
}


Measured memory_bytes: 512
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#include <string>
using namespace std;
set<string> ans;
int n;
void dfs (int cur, int g, string s) {
  if (cur == n) {
    ans.insert(s);
    return;
  }
  for (int i = 0; i <= g + (cur > 0); i++) {
    s.push_back('a' + i);
    dfs (cur + 1, i == g + 1 ? g + 1 : g, s);
    s.pop_back();
  }
}
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  //d
  cin >> n;
  dfs(0, 0, "");
  for (auto& s : ans) {
    cout << s << '\n';
  }
  return 0;
}

Measured memory_bytes: 13824
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
using namespace std;
#define rep(i, n) for(int i=0; i<n; ++i)
typedef long long ll;
//必要な宣言
#define MAX 100000

//問題をよく読もう！
//論理的に考えよう！
//サンプルを確認しよう!
//絶対に諦めるな！
//工夫をしろ！
int main() {
  int A, B;
  cin >> A >> B;
  int total = A*B;
  int answer;

  answer = total - (A + B -1 );

  cout << answer << endl;

  return 0;
}


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


def solve(A: int, B: int, C: int):
    print(min(C, int(B/A)))
    return


# Generated by 1.1.3 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    solve(A, B, C)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    int n; cin>>n;
    vector<int> order(n);
    iota(order.begin(), order.end(), 0);
    vector<int> x(n),y(n);
    rep(i,n) cin>>x[i]>>y[i];

    long double sum = 0.0;

    do {
        long double tmp = 0.0;
        rep(i,n-1) {
            long double X = 0.0; long double Y = 0.0;
            X += (x[order[i]]-x[order[i+1]]); X*=X;
            Y += (y[order[i]]-y[order[i+1]]); Y*=Y;
            tmp += sqrt(X+Y);
        }
        sum += tmp;
    } while (next_permutation(order.begin(), order.end()));

    ll times = 1;
    for (int i = 1; i <= n; ++i) times *= i;

    cout << fixed << setprecision(13);
    cout << sum/times << '\n';

    return 0;
}

Measured memory_bytes: 764
#include<stdio.h>
int main(void)
{
	int w,a,b,c,d,x,y,z,m;
	while (1){
		scanf("%d",&w);
		if(w==-1) break;
		if(w<10){
			printf("3130\n");
		}
		else if(w>=10 &&  w<20){
			w=w-10;
			a=w*125;
			m=a+1150;
			printf("%d\n",4280-m);
		}
		else if(w>=20 && w<30){
			x=w-20;
			a=x*140;
			m=a+1250+1150;
			printf("%d\n",4280-m);
		}
		else{
			x=w-30;
			a=x*160;
			m=a+1250+1400+1150;
			printf("%d\n",4280-m);
		}
	}
	return 0;
}


Measured memory_bytes: 2608
G1 = [1,3,5,7,8,10,12]
G2 = [4,6,9,11]
G3 = [2]

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

if x in G1 and y in G1:
    print('Yes')
elif  x in G2 and y in G2:
    print('Yes')
elif  x in G3 and y in G3:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include<bits/stdc++.h> 
using namespace std; 
typedef  pair<int, int> iPair; 
//#define mod 1000000007
#define pb push_back
typedef long long ll;
typedef long double ld;
#define FOR(i,n) for(i=0;i<n;i++)
#define FORE(i,n) for(i=0;i<=n;i++)
 
 
ll gcd(ll a , ll b)
{
   if(b==0) return a;
   a%=b;
   return gcd(b,a);
   
}
    
ll maxl(ll a,ll b){
    if(a>b)return a;
    return b;
}
 
ll minl(ll a,ll b){
    if(a>b)return b;
    return a;
}
 
ll mod = 998244353;
 
ll mulmod(ll a, ll b,ll c){ 
    ll res = 0; 
    a = a % c; 
    while (b > 0){ 
        if (b % 2 == 1){ 
            res = (res + a) % c;
        }
        a = (a * 2) % c; 
        b /= 2; 
    } 
    return res % c; 
}
 
int binarySearch(int arr[], int l, int r, int x) 
{ 
    if (r >= l) { 
        int mid = l + (r - l) / 2; 
        if (arr[mid] == x) 
            return mid; 
        if (arr[mid] > x) 
            return binarySearch(arr, l, mid - 1, x); 
        return binarySearch(arr, mid + 1, r, x); 
    } 
    return -1; 
} 
 
int a[100005];
int tree[200005];
 
void build(int st,int low,int high){
    if(low==high){
        tree[st] = a[high]%2;
        return;
    }
    int mid = low+(high-low)/2;
    build(2*st,low,mid);
    build(2*st+1,mid+1,high);
    tree[st] = tree[2*st]+tree[2*st+1];
}
 
void update(int st,int start,int end,int ind,int val){
    if(start==end){
        tree[st] = val%2;
        return;
    }
    int mid = start+(end-start)/2;
    if(ind<=mid){
        update(2*st,start,mid,ind,val);
    }
    else update(2*st+1,mid+1,end,ind,val);
    tree[st] = tree[2*st]+tree[2*st+1];
}
 
int query(int st,int start,int end,int low,int high){
    if(start>high || end<low)return 0;
    int mid = start + (end-start)/2;
    if(start==low && end==high){
        return tree[st];
    }
    if(low>mid)return query(2*st+1,mid+1,end,low,high);
    if(high<=mid)return query(2*st,start,mid,low,high);
    return query(2*st,start,mid,low,mid)+query(2*st+1,mid+1,end,mid+1,high);
}

int main()
{
        ios_base::sync_with_stdio(false);
        cin.tie(NULL),cout.tie(NULL);
        int a,b;
        cin >> a >> b;
        if(b==1){
            cout << "0" << endl;
          return 0;
        }
        int ans = 1;
        int sum = a;
        a--;
        while(sum<b){
            sum+=a;
            ans++;
        }
        cout << ans << endl;
        return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <map>

#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

int main() {
  int N, K; cin >> N >> K;
  int h[N]; rep(i, N) cin >> h[i];

  sort(h, h+N);
  int result = pow(2,30);
  for (int i=0; i+(K-1)<N; i++) {
    result = min(result, h[i+(K-1)]-h[i]);
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	int N;
	int W, H;
	while (cin >> N, N) {
		cin >> W >> H;
		vector<vector<int>> area(H + 1, vector<int>(W + 1, 0));
		for (int i = 0; i < N;i++) {
			int x, y; cin >> x >> y;
			area[y][x] = 1;
		}

		//for (int i = 1; i <= H;i++) {
		//	for (int j = 1; j <= W; j++) {
		//		cout << area[i][j];
		//	}
		//	cout << endl;
		//}


		int S, T;
		cin >> S >> T;
		int ans = -1;
		for (int h = 1; h <= H - T + 1;h++) {
			for (int w = 1; w <= W - S + 1;w++) {
				int cnt = 0;
				for (int i = 0; i < T;i++) {
					for (int j = 0; j < S;j++) {
						if (area[h + i][w + j] == 1)cnt++;
					}
				}
				ans = max(cnt, ans);
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 3172
/* Trico */
#include <iostream>
#include <bits/stdc++.h>
#define inf 1e18
#define ll long long
#define x first
#define y second
#define pll pair<ll, ll>
#define pii pair<int, int>
#define mll map<ll, ll>
#define mii map<int, int>
#define vll vector<ll>
#define vi vector<int>
#define pb push_back
#define p push
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n, a[100101], pre[100101], suff[100101], ans = 0;
    pre[0] = 0;
    suff[n+1] = 0;
    cin>>n;
    for(int i = 1;i<=n;i++) { cin>>a[i]; pre[i] = __gcd(pre[i-1], a[i]);}
    for(int i = n;i>=1;i--) suff[i] = __gcd(suff[i+1], a[i]);
    for(int i  = 1;i<=n;i++){
        ans = max(__gcd(pre[i-1], suff[i+1]), ans);
    }
    cout<<ans;
} 

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

void cas(int i) {
    cout<<"Case "<<i<<":";
}

typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pii;
typedef vector< pii > vii;

#define ll          long long
#define ff          first
#define ss          second
#define pb          push_back
#define mkp         make_pair
#define sz          size()
#define dsc         greater<int>()

#define fef(i,a,b)    for(int i=a;i<b;i++)
#define feb(i,a,b)    for(int i=a;i>=b;i--)
#define all(a)      a.begin(),a.end()
#define mem(a,b)    memset(a,b,sizeof(a))
#define pi          2*acos(0.0)
#define End         return 0;

#define scan1(a)    scanf("%d",&a)
#define scan2(a,b)  scanf("%d %d",&a,&b)
#define scan3(a,b,c)  scanf("%d %d %d",&a,&b,&c)
#define scanl(a)    scanf("%lld",&a)
#define scanll(a,b) scanf("%lld %lld",&a,&b)
#define scanlll(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)

#define print1(a)    printf("%d",a)
#define print2(a,b)  printf("%d %d",a,b)
#define print3(a,b,c)  printf("%d %d %d",a,b,c)
#define printl(a)    printf("%lld",a)
#define printll(a,b) printf("%lld %lld",a,b)
#define printlll(a,b,c) printf("%lld %lld %lld",a,b,c)

#define MAXN        1000000007
#define INF 0x3f3f3f3f
bool sbs(const pii &a, const pii &b) {
    return (a.second < b.second);
}
//int dx[]={+1,-1,+0,+0};///Four Directions
//int dy[]={+0,+0,+1,-1};///Four directions
//int dx [] = {+1,-1,+0,+0,-1,-1,+1,+1};///Eight Directions
//int dy [] = {+0,+0,+1,-1,+1,-1,-1,+1};///Eight Directions

//int mark[10007];vi prime;void seive(){for(int i=2;i<10000;i++){if(mark[i]==0){prime.pb(i);for(int j=i+i;j<=10000;j+=i)mark[j]=1;}}}

//freopen("input.txt", "r", stdin);

int main()
{
   ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n,k; cin>>n>>k;
    vll v(n);
    for(int i=0;i<n;i++) cin>>v[i];
    ll sum=0;
    sort(all(v));
    for(int i=0;i<k;i++) sum+=v[i];
    cout<<sum<<endl;
    End;
}


Measured memory_bytes: 3660
def main():
    s = [ord(ss) - ord('a') for ss in input()]
    t = [ord(tt) - ord('a') for tt in input()]

    sets = set(s)
    if len([tt for tt in t if tt not in sets]) > 0:
        print(-1)
        return

    ns = len(s)
    table = [[-1] * 26 for _ in range(ns+1)]
    for i in range(ns)[::-1]:
        table[i] = table[i+1][:]
        table[i][s[i]] = i

    cur = -1
    cnt = 1
    for tt in t:
        next_cur = table[cur+1][tt]
        if next_cur == -1:
            next_cur = table[0][tt]
            cnt += 1
        cur = next_cur

    print(ns * (cnt - 1) + cur + 1)


main()


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

int main(){
  long long a,b,k;
  cin>>a>>b>>k;
  if(a>=k){
    cout<<a-k<<" "<<b<<endl;
    return 0;
  }
  if(a+b>=k){
    cout<<0<<" "<<a+b-k<<endl;
    return 0;
  }
  cout<<0<<" "<<0<<endl;
  return 0;
}


Measured memory_bytes: 3632
#include<stdio.h>
#include<iostream>
#include<stdlib.h>
#include<math.h> 
using namespace std;


int main(){
	int x1=0,y1=0,c1=0,x2=0,y2=0,c2=0;
	scanf("%d%d%d",&x1,&y1,&c1);
	scanf("%d%d%d",&x2,&y2,&c2);
	int dist=0;
	dist=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
if(c1<c2){
	int temp=c1;
	c1=c2;
	c2=temp;
}
	if(dist<c1-c2){
		printf("0\n");
	}
	else if(dist>(c1-c2)&&dist<(c1+c2)){
		printf("2\n");
	}
	else if(dist>(c1+c2)){
		printf("4\n");
	}
	else if(dist==c1+c2){
		printf("3\n");
	}
	else if(dist==(c1-c2)){
		printf("1\n");
	}
}



Measured memory_bytes: 3156
n=gets.chomp.to_i
a,b=gets.chomp.split(" ").map { |e| e.to_i }
p=gets.chomp.split(" ").map { |e| e.to_i }

ap = 0
bp = 0
cp = 0

for item in p do
  if item <= a
    ap += 1
  elsif a+1 <= item && item <= b
    bp += 1
  else
    cp += 1
  end
end

puts [ap, bp, cp].min


Measured memory_bytes: 1788
n = int(input())
li = list()
for i in range(n):
    a, b = [int(x) for x in input().split()]
    li.append([a,b])

count = 0
for i in li:
    if count < 3:
        if i[0] == i[1]:
            count += 1
        else:
            count = 0
    else:
        break

if count >= 3: print('Yes')
else: print('No')

Measured memory_bytes: 9200