akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<queue>
using namespace std;
#define MAX 10000000
#define MAX_ST 101 //MAX_STATION
#define LP(i,n) for(int i=0;i<n;i++)
class Node{
public:
	int at;
	int cost;
	Node(int a,int c){
		at=a;cost=c;
	}
	bool operator < (const Node &o) const{
		return cost>o.cost;
	}
};
int feeMap[MAX_ST][MAX_ST];
int timeMap[MAX_ST][MAX_ST];
int minMap[MAX_ST];
bool visited[MAX_ST];
typedef priority_queue<Node> PQ;

int dijkstra(int st,int ed,int n,int judge){
	PQ pq;
	pq.push(Node(st,0));
	while(!pq.empty()){
		Node cur=pq.top();pq.pop();
		if(cur.at==ed)return cur.cost;
//		cout<<"now:"<<cur.at<<endl;
		for(int i=1;i<=n;i++){
			if((judge&&timeMap[cur.at][i]==MAX)||(!judge&&feeMap[cur.at][i]==MAX)||cur.at==i)continue;
			int cost=judge?timeMap[cur.at][i]:feeMap[cur.at][i];
			if(minMap[i]<cur.cost+cost)continue;
			//cout<<"    next:"<<i<<endl;
			minMap[i]=cur.cost+cost;
			pq.push(Node(i,cur.cost+cost));
		}
	}
	cout<<"not found"<<endl;
	return MAX;
}

void init(){
	LP(i,MAX_ST){LP(j,MAX_ST)feeMap[i][j]=timeMap[i][j]=MAX;}
}
void init2(){
	LP(i,MAX_ST){visited[i]=false;minMap[i]=MAX;}
}
void printMap(int n){
	LP(i,n){LP(j,n)printf("%8d",feeMap[i][j]!=MAX?feeMap[i][j]:-1);cout<<endl;}
	cout<<"---------------------------------------------------------"<<endl;
	LP(i,n){LP(j,n)printf("%8d",timeMap[i][j]!=MAX?timeMap[i][j]:-1);cout<<endl;}
}
int main(){
	int n,m;
	while(cin>>n>>m&&(n||m)){
		init();
		//ツ静シツ路ツ湘ョツ陛ア
		for(int a,b,cost,time;n--&&cin>>a>>b>>cost>>time;){
			if(feeMap[a][b]>cost)feeMap[a][b]=feeMap[b][a]=cost;
			if(timeMap[a][b]>time)timeMap[a][b]=timeMap[b][a]=time;
		}
//		printMap(m);
		int d;
		cin>>d;
		//ツ姪「ツつ「ツ債づュツつケ
		for(int p,q,r;d--&&cin>>p>>q>>r;){
			init2();
//			cout<<"@========== "<<p<<" to "<<q<<" ======="<<endl;
			cout<<dijkstra(p,q,m,r)<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 996
#include<bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define scn(n) scanf("%d",&n)
using namespace std;

int main() {
	
	int n,m;
	ll k;
	cin>>n>>m>>k;
	
	ll arr1[n+2]={0};
	ll arr2[m+2]={0};
	
	for(int i=1;i<=n;i++)
	{
	    cin>>arr1[i];
	    arr1[i]+=arr1[i-1];
	}
	
	for(int i=1;i<=m;i++)
	{
	    cin>>arr2[i];
	    arr2[i]+=arr2[i-1];
	}
	
	int j=m,ans=0;
	
	for(int i=0;i<=n;i++)
	{
	    if(arr1[i]>k)
	    break;
	    while(arr2[j]>(k-arr1[i]))
	    j--;
	    
	    ans=max(ans,(i+j));
	}
	cout<<ans;
	return 0;
}

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

using namespace std;

//
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 N, K, A[101];

int dp[101010];  // dp[k] := k個の石からなる山で先手が勝ち状態か(=1なら勝ち状態)

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

  for (int k = 0; k < K + 1; k++) {
    int lose = 0, cnt = 0;
    for (int i = 0; i < N; i++) {
      if (0 <= k - A[i]) {
        cnt++;
        if (!dp[k - A[i]]) lose++;
      }
    }

    if (cnt == 0)
      dp[k] = 0;
    else if (0 < lose)
      dp[k] = 1;
    else
      dp[k] = 0;
  }

  if (dp[K])
    cout << "First\n";
  else
    cout << "Second\n";

  return 0;
}

Measured memory_bytes: 640
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {//213
	int n;
	cin>>n;
	vector<int> arr(n);
	for(int &i:arr)cin>>i;
	sort(arr.begin(),arr.end());
	int pos = lower_bound(arr.begin(),arr.end(),arr[n-1]/2)-arr.begin();
	int element = pos!=n-1 ?arr[pos] : arr[pos-1];
	if(pos!=0&&abs(arr[n-1]-2*element) > abs(arr[n-1]-2*arr[pos-1]))element = arr[pos-1];
	cout<<arr[n-1]<<" "<<element;
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3636
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		for(int i = 0; i < M; i++)
			N -= sc.nextInt();
		System.out.println(Math.max(N, -1));
	}

}


Measured memory_bytes: 46452
class _in{struct my_iterator{int it;const bool rev;explicit constexpr my_iterator(int it_, bool rev=false):it(it_),rev(rev){}constexpr int operator*(){return it;}constexpr bool operator!=(my_iterator& r){return it!=r.it;}void operator++(){rev?--it:++it;}};const my_iterator i,n;public:explicit constexpr _in(int n):i(0),n(n){}explicit constexpr _in(int i,int n):i(i,n<i),n(n){}constexpr const my_iterator& begin(){return i;}constexpr const my_iterator& end(){return n;}};

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

using i64 = long long;
const int INF = 1e9;
int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    int N, K; cin >> N >> K;

    vector<int> box(26, 0);
    for(int i : _in(N)) {
        string s;
        cin >> s;
        int k = (int)(s[0] - 'A');
        box[k]++;
    }
    priority_queue<int> que;
    for(int i : _in(26)) {
        if(box[i] > 0) {
            que.emplace(box[i]);
        }
    }
    int sum = 0;
    vector<int> tmp;
    while((int)que.size() >= K) {
        tmp.clear();
        for(int i : _in(K)) {
            tmp.emplace_back(que.top());
            que.pop();
        }
        for(int i : _in(K)) {
            int x = tmp[i] - 1;
            if(x > 0) que.emplace(x);
        }
        ++sum;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include <string>
#include <iostream>
#include <algorithm>
#pragma warning(disable : 4996)
using namespace std;
string a, b, c;
int main() {
	cin >> a >> b >> c;
	cout << (char)(a[0] - 'a' + 'A') << (char)(b[0] - 'a' + 'A') << (char)(c[0] - 'a' + 'A') << endl;
	return 0;
}

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

#define ran 22

int n;
int a[ran];

int main() {
	scanf("%d", &n);
	for(int i=1;i<=n;i++) scanf("%d", &a[i]);
	
	int ans = 0;
	for(int i=2;i<n;i++)
		if(a[i]>a[i-1] && a[i]<a[i+1] ||
		   a[i]<a[i-1] && a[i]>a[i+1]) ans++;
	printf("%d\n", ans);
	
	return 0;
}

Measured memory_bytes: 256
n = int(input())
p1, p2 = (0, 0), (100, 0)
ans_ls = [p1, p2]

def koch(d, p1, p2):
    '''
    d...現在の深さ 0スタートにする
    p1,p2...端の座標。ここから途中の座標を計算しlistにappendする
    '''
    # 終了条件
    if d == n:
        return
    # 内分点の計算
    s = (2/3 * p1[0] + 1/3 * p2[0], 2/3 * p1[1] + 1/3 * p2[1])
    t = (1/3 * p1[0] + 2/3 * p2[0], 1/3 * p1[1] + 2/3 * p2[1])

    # 正三角形の頂点uの計算
    # (u-s)=R(1/3 pi) (t-s)が成り立つのでsを移行してuが計算できる。R()は回転行列で、加法定理から導出可能。
    R = [[1/2, -0.86602540378], [0.86602540378, 1/2]]
    u = (R[0][0] * (t[0] - s[0]) + R[0][1] * (t[1] - s[1]) + s[0],
         R[1][0] * (t[0] - s[0]) + R[1][1] * (t[1] - s[1]) + s[1])
    ans_ls.extend([s, u, t])  # 確定した点を追加

    # 再帰的に探索
    koch(d+1, p1, s)
    print(*s)
    koch(d+1, s, u)
    print(*u)
    koch(d+1, u, t)
    print(*t)
    koch(d+1, t, p2)

print(*p1)
koch(0, p1, p2)
print(*p2)


Measured memory_bytes: 6196
#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;
int main(){
	int n;
	priority_queue<int, vector<int>, greater<int> > d;
	int m;
	priority_queue<int, vector<int>, greater<int> > t;
	int x;
	cin >> n;
	for(int i=0;i < n;i++){
		cin >> x;
		d.push(x);
	}
	cin >> m;
	for(int i=0;i < m;i++){
		cin >> x;
		t.push(x);
	}
	int dt = d.top(), tt = t.top();
	while(!d.empty()){
		if(tt < dt){
			cout << "NO" << endl;
			return 0;
		}
		if(tt != dt)
		{
			d.pop();
			dt = d.top();
		}
		else
		{
			d.pop();
			t.pop();
			dt = d.top();
			tt = t.top();
		}
		if(t.empty())
		{
			cout << "YES" << endl;
			return 0;
		}
	}
	cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 2548
n=int(input())
a=(list(map(int,input().split(" "))))
b=(list(map(int,input().split(" "))))

x=a[0]
y=0
for i in range(n):
    for j in range(i):
        x=x+a[j+1]
    for k in range(n-i):
        x=x+b[k+i]
    if y < x:
        y = x
    x=a[0]
print(str(y))


Measured memory_bytes: 3064
import sys
sys.setrecursionlimit(10**6)
s = input()
t = input()
start, end = 0, len(t)
def f(s, t, start, end):
    min_changes = len(t)
    count = 0
    for i in range(len(t)):
        if s[start:end][i] != t[i]: count += 1
    if start + len(t) == len(s): return min(count, min_changes)
    else: return min(count, f(s, t, start+1, end+1))

print(f(s, t, start, end))


Measured memory_bytes: 9612
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main
{

	public static void main(String[] args) throws IOException
	{
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		int A = Integer.parseInt(str.substring(0, str.indexOf(" ")));
		int B = Integer.parseInt(str.substring(str.indexOf(" ") + 1));
		int C = A + B;
		if(C >= 24) C -= 24;
		System.out.println(C);
	}

}

Measured memory_bytes: 21076
A, B, X = map(int, input().split())
if A > 2 * B:
    A = 2 * B
if A < B:
    B = A
ans = X // 1000 * A
X %= 1000
# print(ans + (B if X <= 500 else A))
a, b, x = A, B, X
wa = ans + (0 if X == 0 else (B if X <= 500 else A))
print(wa)


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





int main() {
    long long N, M;
    cin >> N >> M;
    long long teisyutu_kaisuu = 1LL<<M;
    long long each_time = 1900LL * M + 100LL * (N - M);
    cout <<  each_time * teisyutu_kaisuu << endl;
}

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

typedef long long ll;
typedef pair<int,int> P;

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

template<typename T1,typename T2>ostream& operator<<(ostream& os,const pair<T1,T2>& a) {os << "(" << a.first << ", " << a.second << ")";return os;}

const char newl = '\n';

int main() {
    ll n,ans = 0;
    cin >> n;
    for (ll i = 1;i < n+1;++i) {
        ans += (n/i)*(n/i+1)/2*i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
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(int argc, char const *argv[]) {
  int k,x;
  cin >> k >> x;
  if(500*k>=x) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool f[100001];
int c[100001];
int n,l,r;
int main()
{
	ios::sync_with_stdio(false);
	for(int i=2;i<=100000;i++)
	{
		if(!f[i])
		{
			for(int j=i*2;j<=100000;j+=i) f[j]=true;
		}
	}
	for(int i=3;i<=100000;i+=2)
	{
		if(!f[i] && !f[(i+1)/2]) c[i]++;
	}
	for(int i=3;i<=100000;i++) c[i]+=c[i-1];
	cin>>n;
	while(n--)
	{
		cin>>l>>r;
		cout<<c[r]-c[l-1]<<endl;
	}
	return 0;
}

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

Measured memory_bytes: 256
/*
ID: Bipin Singh [bipinsingh061]
LANG: C++
TASK: gift1
*/
#include<bits/stdc++.h> 
using namespace std; 
#define deb(x) cout <<"\n"<< (#x) << " = " << (x) << "\n"
#define int long long int

void inputoutput()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); 
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    
}



bool dfs(int src,int c , bool *vis , vector<int> (&v)[2001] , int col[])
{
	vis[src]=true;
	col[src]=c ;
	// cout<<src<<" ";

	for(auto it : v[src])
	{
		if(!vis[it])
		{
			if(dfs(it,c*-1,vis,v,col)==false)
				return false;
		}
		else
		{
			if(col[src]==col[it])
				return false;
		}
	}
	return true ;
}

int mod=1e9+7 ;


void update(vector<int>& D, int l, int r, int x) 
{ 
    D[l] += x; 
    D[r + 1] -= x; 
}

int32_t main()
{
	inputoutput();
// d t s
	
//    s=d/t 
//    t=d/s

   double d,t,s;
   cin>>d>>t>>s;

   double takes=d/s ;

   if(takes<=t)
   	cout<<"Yes";
   else
   	cout<<"No";

    



	return 0;
}




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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}


signed main() {
  int w, a, b;
  cin >> w >> a >> b;
  if(abs(a - b) - w <= 0) {
    cout << 0 << endl;
  }else {
    cout << abs(a - b) - w << endl;
  }
}


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

using namespace std;

int main() {
  int r, degree=0;
  cin >> r;
  double x=1.0, y=0.0;
  
  int count = 1;
  while ( abs(x) > 1e-9 || abs(y) > 1e-9){
    degree +=r;
    if (degree > 360){
      degree -= 360;
    }
    double rad = degree * M_PI / 180.0;
    x += cos(rad);
    y += sin(rad);
    count++;
  }
  
  cout << count << endl;
  return 0;
  
}

Measured memory_bytes: 3992
from sys import stdin
data = [stdin.readline().rstrip().split() for _ in range(2)]
count = 0
i = 0
while i + count+ 1 < int(data[0][0]):
    if (data[1][i + count+ 1] == data[1][i + count]):
        count = count + 1
    i = i + 1
print(count)

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

int main() {
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #endif

    int n,m,X,Y;
    cin>>n>>m>>X>>Y;
    int x[n], y[m];
    for(int i = 0;i < n;i++) cin>>x[i];
    for(int i = 0;i < m;i++) cin>>y[i];
    sort(x,x+n); sort(y,y+m);
    for(int Z = X+1; Z <= Y;Z++) {
        if(x[n-1] < Z && y[0] >= Z) {
            cout<<"No War";
            return 0;
        }
    }
    cout<<"War";
}

Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect

def LI(): return [int(x) for x in sys.stdin.readline().split()]


def I(): return int(sys.stdin.readline())


def LS(): return [list(x) for x in sys.stdin.readline().split()]


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


def LIR(n):
    return [LI() for i in range(n)]


def SR(n):
    return [S() for i in range(n)]


def LSR(n):
    return [LS() for i in range(n)]


sys.setrecursionlimit(1000000)
mod = 1000000007


def solve():
    n = I()
    a = LI()
    ca = Counter(a)
    for i in range(1,n):
        print(ca[i])
    print(0)
    return


if __name__ == "__main__":
    solve()

Measured memory_bytes: 116780
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_ll.hpp>
#include <boost/rational.hpp>
namespace mp = boost::multiprecision;
using Bll = mp::cpp_ll; //任意長整数 
using Real32 = mp::number<mp::cpp_dec_float<32>>;
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
using Rat = boost::rational<Bll>;//有理数*/
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define size(v) (ll)(v).size()
ll mod = 1000000007;
ll INF = 1000000099;
//cin.tie(0);
//ios::sync_with_stdio(false);

map<ll,ll> ma;
vector<ll> v;

signed main(){
    ll n,m,x=0,ans=0;
    cin>>n>>m;
    ma.emplace(0,1);
    v.pb(x);
    for(ll i=0;i < n;i++)
    {
        ll in;
        cin>>in;
        x+=in;
        x%=m;
        if(!ma.count(x)){
            ma.emplace(x,1);
            v.pb(x);
        }else{
            ma.at(x)++;
        }
    }

    sort(v.begin(),v.end());
    unique(all(v));

    for(ll i=0;i<size(v);i++){
        ll y=ma.at(v.at(i));
        ans+=y*(y-1)/2;
    }

    cout << ans << endl;
}
/* */

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

int main(){
  int i=0,n,ans=0;
  string s;
  cin >> s;
  n=sz(s)-1;
  while(i<n-i){
  	if(s.at(i)!=s.at(n-i)) ans++;
        i++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

n = ni()
s = ns().strip()
h = 0
minh = 0
for c in s:
    if c == "(":
        h += 1
    else:
        h -= 1
    minh = min(minh, h)
print("("*(-minh) + s + ")"*(h-minh))
#括弧列では、任意の接頭辞で、"("の方が多いこと、かつ全体で(と)の数が等しいことが必要なので、そうなる条件を考える。
#一番バランスが悪いところに合わせて(を先頭からならべ、後方に)を並べて整合性を取ればよく、その方法が辞書順最小であることが示される(解説参照)
#括弧列に関してあまり考えずに逆算してしまった。


Measured memory_bytes: 3060
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <stack>

int trans(std::string x)
{
    int ret = 0;
    for (int i = 0; i < x.length(); ++i)
        ret = ret * 10 + (x[i] ^ 48);
    return ret;
}

std::string st;

int main()
{
    std::ios::sync_with_stdio(0), std::cin.tie(0), std::cout.tie(0);
    std::cin >> st;
    int p = 0, q = 0, a = trans(st.substr(0, 2)), b = trans(st.substr(2, 2));
    if (b > 0 && b < 13)
        q = 1;
    if (a > 0 && a < 13)
        p = 1;
    if (p && q)
        std::cout << "AMBIGUOUS\n";
    else if (!p && !q)
        std::cout << "NA\n";
    else if (p)
        std::cout << "MMYY\n";
    else
        std::cout << "YYMM\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
long long n,k,ans,p;
long long map[12][6]={
    {4,2,0,9,7},
    {1,10,8,6,4},
    {9,7,5,3,1},
    {6,4,2,0,9},
    {3,1,10,8,6},
    {0,9,7,5,3},
    {8,6,4,2,0},
    {5,3,1,10,8},
    {2,0,9,7,5},
    {10,8,6,4,2},
    {7,5,3,1,10}};
int main()
{
    cin>>n>>k;
    n-=2;
    p=n%11;n/=11;
    ans=n*5;
    for(int i=0;i<p;i++)
        for(int j=0;j<5;j++)
        if(map[i][j]==k)ans++;
    cout<<ans<<endl;
    return 0;
}

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

int main() {
  int N, sum = 0;
  cin >> N;
  int n = N;
  while (n > 0) {
    sum += n % 10;
    n /= 10;
  }
  if (N % sum == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    System.out.print(s.substring(0,5));
    System.out.print(" ");
    System.out.print(s.substring(6,13));
    System.out.print(" ");
    System.out.println(s.substring(14,19));
  }
}


Measured memory_bytes: 20692
def pad(n):
  n = str(n)
  n = '0'*(6-len(n))+n
  return n

N,M=map(int,input().split())
py = [tuple(map(int,input().split())) for _ in range(M)]

py = sorted(enumerate(py),key=lambda x: x[1])

pref=0
count=0
new_py = []
for i in range(M):
  j,(p,y)=py[i]
  if p==pref:
    count += 1
  else:
    count = 1
  new_py.append((j,pad(p)+pad(count)))
  pref = p
  
new_py = sorted(new_py)
for i in range(M):
  print(new_py[i][1])

Measured memory_bytes: 46932
a = input()
k, s = a.split(' ')
K = int(k)
S = int(s)
ans = 0
for x in range(K + 1):
    for y in range(K + 1):
        z = S - x - y
        if (z >= 0) and (z <= K):
            ans += 1

print(ans)

Measured memory_bytes: 67796
n = int(input())
a = list(map(int, input().split()))

max_a = max(a)
lst = [0 for i in range(max_a+1)]

ans = 1
for i in a:
    if i == 0:
        if lst[i] == 0:
            ans = (ans * 3) % 1000000007
            lst[i] += 1
        elif lst[i] == 1:
            ans = (ans * 2) % 1000000007
            lst[i] += 1
        else:
            lst[i] += 1
        if lst[i] > 3:
            print(0)
            exit()
    else:
        if lst[i-1]-lst[i] < 1:
            print(0)
            exit()
        ans = (ans * (lst[i-1]-lst[i])) % 1000000007
        lst[i] += 1
        if lst[i] > 3:
            print(0)
            exit()

print(ans)

Measured memory_bytes: 56172
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define gre greater //sortを降順にする
#define pri_queue priority_queue //優先度付きキュー
const int mod = 1000000007;
ll n;
std::vector<string> s,ans;
std::map<string, ll> m; std::map<string, bool> done;
int main(){
  cin >> n;
  s.resize(n);
  ll tar = 0;
  for (size_t i = 0; i < n; i++) {
    cin >> s[i];
    m[s[i]]++;
    tar = max(tar,m[s[i]]);
  }
  for (size_t i = 0; i < n; i++) {
    if(tar == m[s[i]] && !(done[s[i]])){
      ans.pb(s[i]);
      done[s[i]] = true;
    }
  }
  sort(all(ans));
  for (size_t i = 0; i < ans.size(); i++) {
    cout << ans[i] << endl;
  }
}


Measured memory_bytes: 41200
n = int(input())
A = []

for i in range(n):
    s, t = [int(x) for x in input().split()]
    A.append((s, t))

A.sort(key=lambda x: x[1])

ans = 0
t = -1

for a in A:
    if a[0] > t:
        ans += 1
        t = a[1]

print(ans)



Measured memory_bytes: 20424
/**
 *    Author:  "Robin Singh" !!!!    
**/
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define ff first
#define ss second
#define mp make_pair
#define str string 
#define szz(v) ((int)(v).size())  
#define fr(i, j, k) for(int i = j; i < k; i++)     // 0 -> n-1 (i,0,n)
#define bk(i, j, k) for(int i = j-1; i >= k; i--)  // n-1 -> 0 (i,n,0)
#define frit(it, a) for(__typeof((a).begin()) it = a.begin(); it != a.end(); ++it)
#define mem(ptr)  memset(ptr, 0, sizeof ptr)  // use fill() for value other than 0 //
#define rtn return 
#define itt(a)   __typeof((a).begin())
#define RT  (cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << " ms\n")  // Run Time
#define nl "\n"  // New Line
#define dbg(x) (cerr << #x << " = " << x << "  ")
#define enl (cerr << "\n")
#define dbgg(x,y) (cerr << #x << " = " << x << " -> " << #y << " = " << y << "\n")
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector< pair<int,int> > vpii;
typedef vector< pair<ll, ll> > vpll;
const long long mod = 1e9+7;
const ld eps = 1e-9;
const int inf = (1<<30);
const ll INF = (1LL<<61);

ll gcd(ll a,ll b) { return b==0 ? a : gcd(b, a%b); }
ll expo(ll x, ll y){ ll res = 1; x = x % mod;  while (y > 0) { if (y & 1)res = (res*x) % mod; y = y>>1;x = (x*x) % mod;}return res;}
void matmul(ll a[][2], ll b[][2]) { ll tmp[2][2]; for(int i=0; i<2; i++) { for(int j=0; j<2; j++) { tmp[i][j] = 0; for(int k=0; k<2; k++) tmp[i][j] = (tmp[i][j] + a[i][k]*b[k][j]) % mod; }} for(int i=0; i<2; i++) for(int j=0; j<2; j++) a[i][j] = tmp[i][j]; }
ll fibo(int n)    // returns nth fibonacci number, also S(n) = f(n+2)-1
{ if(n == 0) return 0; else if(n == 1) return 1; ll T[2][2] = { {0, 1} , {1, 1} }; ll res[2][2] = { {1, 0}, {0,1} }; n--; while(n) { if(n & 1) matmul(res, T); n >>= 1; matmul(T, T); } return res[1][1]; }

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    int a, b;
    cin >> a >> b;
    if(a+b ==15) cout << "+";
    else if(a*b == 15) cout << "*";
    else cout << "x";
    return 0;
}

Measured memory_bytes: 256
N,K = map(int,input().split())
H = list(map(int,input().split()))
DP = [0]
for i in range(1,N):
    a = DP[i-1] + abs(H[i]-H[i-1])
    for j in range(2,min(K,i)+1):
        b = DP[i-j] + abs(H[i]-H[i-j])
        a = min(a,b)
    DP.append(a)
print(DP[N-1])

Measured memory_bytes: 58336
s = input()
n = len(s)
ans = (n+1)//2
if n%2:
    x = s[n//2]
    for i in range(1,n//2+1):
        if s[n//2-i] == s[n//2+i] == x:
            ans += 1
        else:
            break
if n%2==0:
    if s[n//2] == s[n//2-1]:
        ans += 1
        x = s[n//2]
        for i in range(1,n//2):
            if s[n//2-1-i] == s[n//2+i] == x:
                ans += 1
            else:
                break
print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define UM unordered_map
#define ALL(a) (a).begin(), (a).end()
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
typedef pair<ll, ll> pii;
const ll INF = 1LL << 58;
const ll MOD = 1000000007;
typedef vector<pii> vpii;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

signed main()
{
    string S;
    cin >> S;
    REP(i, 3)
    {
        if (S[i] == S[i + 1])
        {
            cout << "Bad" << endl;
            return 0;
        }
    }
    cout << "Good" << endl;
    return 0;

    // system("pause");
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

num = [0]*(10**6+1)

for x in a:
    num[x] += 1

pairwise = True
for i in range(2, 10**6+1):
    cnt = sum(num[i::i])
    if cnt == n:
        print('not coprime')
        exit()
    if cnt > 1:
        pairwise = False

if pairwise:
    print('pairwise coprime')
else:
    print('setwise coprime')
    

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

int main()
{
   int n;
   int prime[60000] = {1,1};
   vector<int> r1,r2;
   int count=0;
   for (int i=2; i<=244; i++)
   {
       if (prime[i] == 0)
       {
	   for (int j=i*2; j<60000; j+=i)
	   {
	       prime[j] = 1;
	   }
       }
   }
   while (scanf("%d",&n) != EOF)
   {
       int previous,forward;
       for (int i=n-1; i>0; i--)
       {
	   if (prime[i]==0)
	   {
	       previous = i;
	       break;
	   }
       }
       for (int i=n+1; i<60000; i++)
       {
	   if (prime[i]==0)
	   {
	       forward = i;
	       break;
	   }
       }
       r1.push_back(previous);
       r2.push_back(forward);
   }
   for (int i=0; i<r1.size(); i++)
   {
       cout << r1[i] << " " << r2[i] << endl;
   }
   return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>

using namespace std;
using ll = long long;

int main()
{
    int n; 
    string s;
    cin >> n >> s;
    int ans = 1;
    for(int i = 0; i < n-1; i++){
        if(s[i] == s[i+1]){
            continue;
        }else{
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int stringcount(string s, char c) {
  return count(s.cbegin(), s.cend(), c);
}

int main() {
  string s;
  cin >> s;
  cout << stringcount(s, '1') << endl;
  return 0;
}

Measured memory_bytes: 256
program test
implicit none

integer(8) :: n,m,a(200000),b(200000),brj=0,ans=0,i,j

read(*,*) n,m
do i=1,m
	read(*,*) a(i),b(i)
enddo

call heapsort_up(m,b(1:m),a(1:m))

do i=1,m
	if(brj < a(i))then
		ans = ans + 1
		brj = b(i) - 1
	endif
enddo

write(*,*) ans

contains
subroutine heapsort_down(n,y1,y2)
 
	implicit none
	integer(8),intent(in) :: n
	integer(8),intent(inout) :: y1(1:n)
	integer(8),intent(inout) :: y2(1:n)
	integer(8) :: i,k,j,l
	integer(8) :: t1,t2
	
	l = n/2+1
	k = n
 
	do while (k /= 1)
		 if(l > 1) then
				l = l-1
				t1 = y1(l)
				t2 = y2(l)
				
		 else
				t1 = y1(k)
				t2 = y2(k)
				y1(k) = y1(1)
				y2(k) = y2(1)
				k = k-1
				if(k == 1) then
					 y1(1) = t1
					 y2(1) = t2
					 exit
				endif
		 endif
 
		 i = l
		 j = l+l
 
		 do while(j <= k)
				if(j < k) then
					 if(y1(j) > y1(j+1)) j = j+1
				endif
				
				if (t1 > y1(j)) then
					 y1(i) = y1(j)
					 y2(i) = y2(j)
					 i = j
					 j = j+j
				else
					 j = k+1
				endif
		 
		 enddo
		 
		 y1(i) = t1
		 y2(i) = t2
	
	enddo
	return
 
end subroutine heapsort_down
 
subroutine heapsort_up(n,y1,y2)
 
	implicit none
	integer(8),intent(in) :: n
	integer(8),intent(inout) :: y1(1:n)
	integer(8),intent(inout) :: y2(1:n)
	integer(8) :: i,k,j,l
	integer(8) :: t1,t2
	
	l = n/2+1
	k = n
 
	do while (k /= 1)
		 if(l > 1) then
				l = l-1
				t1 = y1(l)
				t2 = y2(l)
				
		 else
				t1 = y1(k)
				t2 = y2(k)
				y1(k) = y1(1)
				y2(k) = y2(1)
				k = k-1
				if(k == 1) then
					 y1(1) = t1
					 y2(1) = t2
					 exit
				endif
		 endif
 
		 i = l
		 j = l+l
 
		 do while(j <= k)
				if(j < k) then
					 if(y1(j) < y1(j+1)) j = j+1
				endif
				
				if (t1 < y1(j)) then
					 y1(i) = y1(j)
					 y2(i) = y2(j)
					 i = j
					 j = j+j
				else
					 j = k+1
				endif
		 
		 enddo
		 
		 y1(i) = t1
		 y2(i) = t2
	
	enddo
	return
 
end subroutine heapsort_up

end program

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define int long long
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
using namespace std ;
static const int INF = 1e9;
static const int MAX_N = 1e+6 +10;
typedef pair<int,int> pii;

struct edge{
    int to,cost;
    edge(){}
    edge(int p1,int p2){
        to=p1;
        cost=p2;
    }
};

int N,K;
vector<int> V[5010];
pii G[6010];
vector<int> D[5010];
int d[6010];
int A[6010];

void bfs(int s){
    for(int i=0;i<6000;++i)d[i]=INF;
    queue<pii> que;
    que.push(pii(s,0));
    while(!que.empty()){
        pii p=que.front();
        que.pop();
        int v = p.FI;
        if(d[v]==1)continue;
        d[v]=1;
        if(p.SE<=G[s].SE&&p.FI!=s){
             D[s].PB(v);
        }
        for(int i=0;i<V[v].size();++i){
             que.push(pii(V[v][i],p.SE+1));
        }
     }
}

void dijkstra(int s){
    priority_queue<pii,vector<pii>,greater<pii> > que;
    for(int i=0;i<6000;++i)A[i]=INF;
    A[s]=0;
    que.push(pii(0,s));
    while(!que.empty()){
        pii p = que.top();
        que.pop();
        int v=p.SE;
        if(A[v]<p.FI)continue;
        for(int i=0;i<V[v].size();i++){
            int e = V[v][i];
            if(A[e]>A[v]+G[v].FI){
                A[e] = A[v]+G[v].FI;
                que.push(pii(A[e],e));
            }
        }
    }
}

signed main(){
    cin>>N>>K;
    for(int i=0;i<N;++i){
        cin>>G[i].FI>>G[i].SE;
    }
    for(int i=0;i<K;++i){
        int a,b;
        cin>>a>>b;
        a--;b--;
        V[a].PB(b);
        V[b].PB(a);
    }
    for(int i=0;i<N-1;++i)bfs(i);
    for(int i=0;i<N-1;++i){
        V[i].clear();
    }
    for(int i=0;i<N-1;++i){
        for(int j=0;j<D[i].size();++j){
            int a=i;
            int b=D[i][j];
            V[a].PB(b);
        }
    }
    dijkstra(0);
    cout<<A[N-1]<<endl;
}

Measured memory_bytes: 252108
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

using namespace std;

int now,al;
string s;

bool formula(void){
	
	if(isupper(s[now])){
		now++;
		return s[now-1]=='T';
	}
	
	if(islower(s[now])){
		now++;
		return (al>>(s[now-1]-'a'))&1;
	}
	
	if(s[now]=='('){
		now++;
		bool res1=formula();
		
		if(s[now]=='*'){
			now++;
			bool res2=formula();
			if(s[now]==')')now++;
			return res1&res2;
		}
		if(s[now]=='+'){
			now++;
			bool res2=formula();
			if(s[now]==')')now++;
			return res1|res2;
		}
		if(s[now]=='-' && s[now+1]=='>'){
			now+=2;
			bool res2=formula();
			if(s[now]==')')now++;
			if(res1==true && res2==false)return false;
			return true;
		}
	}
	
	if(s[now]=='-'){
		now++;
		bool res=formula();
		return !res;
	}
}

bool equation(void){
	bool res1=formula();
	now++;
	bool res2=formula();
	return (res1==res2);
}

int main(void){
	
	while(cin >> s,s!="#"){
		bool fg=true;
		for(al=0;al<(1<<11);al++)now=0,fg&=equation();
		if(fg)cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 1244
#include<iostream>

using namespace std;

int main()
{
    int a,b;
    cin>>a>>b;
    if((a==1 && b==2) || (a==2&&b==1)){
        cout<<3<<endl;
    }
    else if((a==3 && b==2) || (a==2&&b==3)){
        cout<<1<<endl;
    }
    else if((a==3 && b==1) || (a==1&&b==3)){
        cout<<2<<endl;
    }
	return 0;
}


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


int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
//    return *(long long*)a - *(long long*)b;
}
//  qsort(A, b, sizeof(int), compare_int);

int compare_string(const void *a, const void *b) {
  return strcmp(*(const char **)a, *(const char **)b);
}
//  qsort(names, 3, sizeof *names, compare_string);

//long long  factorial(long long n) {
//    if (n > 0) {
//        return n * factorial(n - 1);
//    } else {
//        return 1;
//    }
//}
long long  factorial(long long n, long long depth) {
    if (n > 1) {
        depth++;
        return factorial(n / 2, depth);
    } else {
        return depth;
    }
}

int min(int a, int b) {
    if (a > b)
        return b;
    else
        return a;
}

int distance(int a, int b) {
  return abs(a-b)*abs(a-b);
}



//int ()
/*
int triangle(int a, int b, int c){
  if(a<b+c){
    if(b<c+a){
      if(c<a+b){
        printf("1\n");
        return 1;
      }
    }
  }
  printf("1\n");
  return 0;
}
*/

int main()
{
  //unsigned long long a, b, c, d, e, X, Y;
  //  double  c;
// long long  A[200003]={};
//  printf("%llu\n",);
//  char s[101][101]={};
//  char s[10000001][11]={};
//  char t[100001]={};
//  long long  C[101]={};
  int i,j,k;
//  int sosuu[46] ={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199};
//  int min =100000001;
  
//  char alp[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};

  int X=0;
  int N=0;
  int p[101]={};
  int flg[101]={};

  int ans1=101;
  int ans2=101;

  scanf("%d%d", &X, &N);
  for(i=0;i<N;i++){
    scanf("%d", &p[i]);
    flg[p[i]]++; 
  }
  qsort(p, N, sizeof(int), compare_int);
  for(i=0;i<100;i++){
    if(flg[i]==0){
      if(X>i) ans1=i;
//      printf("%d\n",ans1);
    }
  }
  for(i=100;i>0;i--){
    if(flg[i]==0){
      if(X<=i) ans2=i;
//      printf("%d\n",ans2);
    }
  }
  if(X-ans1<=ans2-X) printf("%d\n",ans1);
  else printf("%d\n",ans2);

return 0;
}


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

int gcd(int x, int y)
{
	if(x == 0 || y == 0)
	{
		return x > y ? x : y;
	}
	if(x >= y)
	{
		gcd(y, x % y);
	}
	else
	{
		gcd(x, y % x);
	}
}
int main()
{
	int a, b;
	cin >> a >> b;
	int c = gcd(a, b);
	cout << c << endl;
	return 0;
}


Measured memory_bytes: 3060
H,W=map(int,input().split())

M=["."]*H
C=[[0]*50 for i in range(50)]
L=[[0,0,0] for i in range(10**5)]

s=0
for i in range(H):
    t=list(input())
    s+=t.count("#")
    M[i]=t

c=0
i=0
p=0
while(True):
    x=L[i][0]
    y=L[i][1]
    p=L[i][2]
    if(i>c):
        print(-1)
        break
    
    if((H-1)==y and (W-1)==x):
        print(H*W-s-p-1)
        exit()

    if(y>0):
        if(M[y-1][x]=="." and C[y-1][x]==0):    
            c+=1
            L[c][0]=x
            L[c][1]=y-1
            L[c][2]=p+1
            C[y-1][x]=1
    if(x<(W-1)):
        if(M[y][x+1]=="." and C[y][x+1]==0):
            c+=1
            L[c][0]=x+1
            L[c][1]=y
            L[c][2]=p+1
            C[y][x+1]=1
    if(y<(H-1)):
        if(M[y+1][x]=="." and C[y+1][x]==0):
            c+=1
            L[c][0]=x
            L[c][1]=y+1
            L[c][2]=p+1
            C[y+1][x]=1
    if(x>0):
       if(M[y][x-1]=="." and C[y][x-1]==0):
            c+=1
            L[c][0]=x-1
            L[c][1]=y
            L[c][2]=p+1
            C[y][x-1]=1
    i+=1


Measured memory_bytes: 13300
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define is(a, b) a == b
#define len(v) ll(v.size())

class UnionFind {
public:
	vector<int> par;//親の番号
    vector<int> rank;//木の深さ
 
	UnionFind(int n){//全ての要素に対して自身が根となるように初期化, 木の深さは0になる
		rep(i,n){
            par.push_back(i);
            rank.push_back(0);
        }
	}
 
	int find(int x) {//木の根を求める
		if(par[x]==x){
            return x;
        }else{
            return par[x]=find(par[x]);
        }
	}
 
	void unite(int x,int y){//xとyの属する集合を併合
        x=find(x);
        y=find(y);
        if(x==y) return;
        if(rank[x]<rank[y]){//木の深さが小さい方を大きい方へ繋げる
            par[x]=y;
        }else{
            par[y]=x;
            if(rank[x]==rank[y]) rank[x]++;
        }
    }

    bool same(int x,int y){//xとyが同じ集合に属するか否か
        return find(x)==find(y);
    }
};
//x以下の要素への最小index, ソートしてから使ってね
template <class T> 
int former(const vector<T> &v, T x){
  return upper_bound(v.begin(), v.end(), x) - v.begin() - 1;
}
//x以上の要素への最小index
template <class T> 
int latter(const vector<T> &v, T x){
  return lower_bound(v.begin(), v.end(), x) - v.begin();
}
//vector書き出し
template <class T>
void cout_vec(const vector<T> &vec1){
  rep(i,len(vec1)){
    cout<<vec1[i]<<' ';
  }
  cout<<'\n';
}
//nCk
template <class T>
T comb(T n,T k){
    T ans=1;
    FOR(i,n-k+1,n+1){
        ans*=i;
    }
    FOR(i,1,k+1){
        ans/=i;
    }
    return ans;
}
//a,bの最大公約数
template <class T>
T gcd(T a,T b) {
	if (b == 0) return a;
	else return gcd(b, a % b);
}
//素因数分解
template <class T>
map<T,T> prime_factor(T x){
    map<T,T> ans;
    for(T i=2;i*i<=x;i++){
        while(x%i==0){
            x/=i;
            ans[i]++;
        }
    }
    if (x!=1){
        ans[x]=1;
    }
    return ans;
}
//約数列挙
template <class T>
vector<T> divisor(T x){
    vector<T> res;
    for(T i=1;i*i<=x;i++){
        if(x%i==0){
            res.push_back(i);
            if(i!=x/i){
                res.push_back(x/i);
            }
        }
    }
    return res;
}
//素数判定
template <class T>
bool is_prime(T x){
    for(T i=2;i*i<=x;i++){
        if(x%i==0){
            return false;
        }
    }
    return x!=1;
}

const ll inf=1e9+7;

ll mult(ll n,ll m){//n^m%infを求める
    if(m==1){
        return n%inf;
    }else if(m%2==0){//オーバーフロー防止のためにn^(m/2)*n^(m/2)を考える
        ll t=mult(n,m/2);
        return (t*t)%inf;
    }else{//奇数の時はn^(m-1)*nを考える
        ll t=mult(n,m-1);
        return (t*n)%inf;
    }
}

typedef pair<ll,ll> P;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x,y;
    cin>>x>>y;
    if(x==2 && y==2){
        cout<<"Yes"<<endl;
    }else if((x==4||x==6||x==9||x==11)&&(y==4||y==6||y==9||y==11)){
        cout<<"Yes"<<endl;
    }else if((x==1||x==3||x==5||x==7||x==8||x==10||x==12)&&(y==1||y==3||y==5||y==7||y==8||y==10||y==12)){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace Aizu {
    public class OnlineJudge {
        static void Main() {
            Console.WriteLine(
                Enumerable
                    .Range(0, int.Parse(Console.ReadLine()))
                    .Select(_ => int.Parse(Console.ReadLine()))
                    .Where(q => q == 2 || (q & 1) == 1)
                    .Count(q => Enumerable.Range(0, 10000)
                            .Select(i => 3 + (2 * i))
                            .TakeWhile(i => i <= Math.Sqrt(q))
                            .All(i => q % i != 0)
                    )
            );
        }
    }
}



Measured memory_bytes: 9492
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define ull unsigned long long 
#define FF first
#define SS second
#define MOD 1000000007

using namespace std;

int gcd(int a, int b) {
  while (a > 0 && b > 0)
    if (a > b) a %= b;
    else b %= a;
  return a + b;
}

ll modpower(ll x, ll y, ll p) //x^y mod p
{
    ll res = 1;      // Initialize result
 
    x = x % p;  // Update x if it is more than or 
                // equal to p
 
    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y %2!= 0)
            res = (res*x) % p;
 
        // y must be even now
        y = y/2;
        x = (x*x) % p;  
    }
    return res;
}

int main()
{
	ios_base::sync_with_stdio(false);
	int a,b;
	cin>>a>>b;
	if(a>8 || b>8)
	{
		cout<<":(\n";
	}
	else
	{
		cout<<"Yay!\n";
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
using namespace std;
typedef tree<pair<int,int> ,null_type,less<pair<int,int> >,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
long long MOD = 1e9+7;
pair<int,int> dx[4] = {{1,0},{-1,0},{0,1},{0,-1}};
long long fastpow(long long x,long long k)
{
    if(!k)
        return 1;
    if(k & 1)
        return ((x * fastpow(x,k-1) % MOD) % MOD) % MOD;
    long long ans = fastpow(x,k/2);
    ans %= MOD;
    ans *= ans;
    ans %= MOD;
    return ans;
}
long long sumF(long long x)
{
    int s = 0;
    while(x)
        s += x%10,x /= 10;
    return s;
}
int arr[105];
long long dp[105][100005];
long long prefixSum[105][100005];
int solve(int idx,int left)
{
    if(idx == 0)
        return left == 0;
    int C = 0;
    for(int i = 0;i <= arr[idx] && i <= left;i++)
        C += solve(idx - 1,left - i);
    return C;
}
int main()
{
    int n,k;
    cin >> n >> k;
    for(int i = 1;i <= n;i++)
        cin >> arr[i];
    dp[0][0] =  prefixSum[0][0] = 1;
    for(int i = 1;i <= k;i++)
        prefixSum[0][i] += prefixSum[0][i-1];
    for(int i = 1;i <= n;i++)
    {
        for(int j = 0;j <= k;j++)
        {
            int f1 = j;
            int f2 = j - min(arr[i],j);
            dp[i][j] += (((prefixSum[i-1][f1] - (f2 ? prefixSum[i-1][f2-1] : 0))%MOD) + MOD ) % MOD;
            dp[i][j] %= MOD;
            prefixSum[i][j] = dp[i][j];
            if(j)
                prefixSum[i][j] += prefixSum[i][j-1];
            prefixSum[i][j] %= MOD;
            dp[i][j] %= MOD;
        }
    }
    cout << dp[n][k] % MOD;
    return 0;
}


Measured memory_bytes: 160000
import java.util.*;
import java.io.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;

public class Main implements Runnable
{
//    static int dx[]={-1,0,1,0};
//    static int dy[]={0,-1,0,1};
    static long mod=1000000007;
    
    public static void main(String[] args) {        
        new Thread(null, new Main(), "", 200 * 1024 * 1024).start();        
    }

    public void run() {
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);
        
//        int n=sc.nextInt();
        long a=sc.nextLong();
        long b=sc.nextLong();
        long n=sc.nextLong();
        if(n<=b-1)ret(a*n/b);
        out.println(a*(b-1)/b);
     	out.flush();
    }
    

    static void ret(String ans) {
    	System.out.println(ans);
    	System.exit(0);
    }

    static void ret(long ans) {
    	System.out.println(ans);
    	System.exit(0);
    }
    
    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }

    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }
}

//class P {
//	int x,c;long s;
//	P(int  x, int c, long s) {
//	  this.x=x;
//	  this.c=c;
//	  this.s=s;
//	}
//}


class P implements Comparable<P>{
	int x,c;long s;
	P(int  x, int c, long s) {
	  this.x=x;
	  this.c=c;
	  this.s=s;
	}

    public int compareTo(P p){
        return Long.signum(s-p.s);
    }
}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString()
    {
        while( st==null || !st.hasMoreTokens() )
			try {
				st = new StringTokenizer(x.readLine());
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
        return st.nextToken();
    }
    public int nextInt()
    {
        return Integer.parseInt(nextString());
    }
    public int[] nextIntArray(int size) {
        int r[] = new int[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextInt(); 
        }
        return r;
    }
    public long[] nextLongArray(int size) {
        long r[] = new long[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextLong(); 
        }
        return r;
    }
    public char[] getCharSet() {
        return this.nextString().toCharArray();
    }    
    public long nextLong()
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


Measured memory_bytes: 33048
from bisect import bisect_right, bisect_left
n, *l = map(int, open(0).read().split())
l.sort()

ans = 0
for i in range(n):
    for j in range(i + 1, n):
        a = l[i]
        b = l[j]
        # a - b < c
        # b - a < c
        # c < a + b
        # max(a - b, b - a) < c < a + b
        right = bisect_left(l, a + b)
        left = bisect_right(l, max(a - b, b - a))
        tmp = max(0, right - left)
        if left <= i < right:
            tmp -= 1
        if left <= j < right:
            tmp -= 1
        ans += tmp
print(ans // 3)


Measured memory_bytes: 74712
#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<ull,ull>
//#define PP pair<int,pair<int,int> >
//#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 n, v[N];

inline int gcd(int x,int y) { 
	int t;
	while( y ) t = x, x = y, y = t % y;
	return x;
}

inline bool check(bool x) { 
	int n1 = 0, n2 = 0, d = 0; bool f1 = 0;
	rep(i,1,n) { 
		if( v[i] & 1 ) n1++; else n2++;
		if( v[i] == 1 ) f1 = 1;
	}
	if( n2 & 1 ) return x;
	if( n1 > 1 || f1 ) return x ^ 1;
	rep(i,1,n) if( v[i] & 1 ) v[i]--;
	rep(i,1,n) d = gcd(v[i],d);
	rep(i,1,n) v[i] /= d;
	return check(x^1);
}

int main() {
	n = read();
	rep(i,1,n) v[i] = read();
	if( !check(0) ) puts("First");
	else puts("Second");
	return 0; 
}

Measured memory_bytes: 640