akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <iostream>
#include <math.h>    //pow(x,y)=x^y 99999とかの場合+1するif文
#include <algorithm> //sort(a.begin(), a.end());reverse(a.begin(), a.end());
#define ll long long
#define rep(init, i, n) for (ll i = init; i < (n); i++)
#define rev(s) reverse(s.begin(), s.end())
#define sor(v) sort(v.begin(), v.end())
#define PI 3.14159265358979323846264338327950L
//コード自動整形 Shift + Option + F @vscode
using namespace std;


/////main/////
int main()
{
    ll N, sum;
    cin >> N;
    sum = 0;
    ll temp = 0;
    rep(0, i, N / 2)
    {
        if (N % (1 + i) == 0)
        {
            temp = N / (i + 1) - 1;
            sum += temp;
        }
        else
        {
            temp = N / (i + 1);
            sum += temp;
        }
        //cout << temp << endl;
    }
    sum += N - N / 2-1;
    cout << sum << endl;
}
/////main/////

/////function/////


Measured memory_bytes: 3632
import numpy as np
n=int(input())
abc=[list(map(int,input().split())) for i in range(n)]

dp=[[0]*3]*n
dp=np.array(dp)
abc=np.array(abc)
dp[0,0]=abc[0,0]
dp[0,1]=abc[0,1]
dp[0,2]=abc[0,2]
for i in range(1,n):
  dp[i,0]=max(dp[i-1,1],dp[i-1,2])+abc[i,0]
  dp[i,1]=max(dp[i-1,2],dp[i-1,0])+abc[i,1]
  dp[i,2]=max(dp[i-1,0],dp[i-1,1])+abc[i,2]
print(max(dp[-1,:]))

Measured memory_bytes: 44160
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define makei(N) int N; cin >> N;
#define makel(N) ll N; cin >> N;
#define makes(s) string s; cin >> s;
#define maked(d) double d; cin >> d;
#define makev(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 1000000007
#define distance(x1,y1,x2,y2) sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2));

using namespace std;
using ll = long long int;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using msi = map<string, int>;

template<typename T>
void say(T s) {
	cout << s << "\n";
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << "\n";
}

void yn(bool b) {
	if (b)say("yes");
	else say("no");
}

void Yn(bool b) {
	if (b)say("Yes");
	else say("No");
}

void YN(bool b) {
	if (b)say("YES");
	else say("NO");
}

template<typename T>
void maxi(T & a, T b) {
	a = max(a, b);
}

template<typename T>
void mini(T & a, T b) {
	a = min(a, b);
}

void exact_say(double x) {
	cout << setprecision(numeric_limits<double>::max_digits10) << x << endl;
}

template<class T> void getVector(vector<T> & v) {
	for (int i = 0; i < v.size(); ++i)
		cin >> v[i];
}

int main() {
	ll a, b, x;
	cin >> a >> b >> x;
	if (x < a) {
		cout << x%mod << endl;
		return 0;
	}
	ll n = (x - a) / (a - b) + 1;
	n %= mod;
	b %= mod;
	cout << (x + (n * b % mod)) % mod << endl;
}


Measured memory_bytes: 3080
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1000000010
#define EPS 1e-9
#define F first
#define S second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

typedef pair<int,int> PII;
typedef pair<int,string> PIS;
typedef pair<string,int> PSI;

struct UnionFind{
  vector<int> data;

  UnionFind(int N){
    data.assign(N,-1);
  }

 bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }
};


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n,m,k;
  cin>>n>>m>>k;
  UnionFind UF=UnionFind(n);
  vector<int> vv[n];
  rep(i,m){
    int a,b;
    cin>>a>>b;
    a--;
    b--;
    UF.unite(a,b);
     vv[b].push_back(a);
    vv[a].push_back(b);
  }
  vector<int> v[n];
  rep(i,k){
    int c,d;
    cin>>c>>d;
    c--;
    d--;
    v[c].push_back(d);
    v[d].push_back(c);
  }
  rep(i,n){
    int ans=UF.size(i);
    rep(j,v[i].size() ){
      if(UF.find(v[i][j])==UF.find(i)) ans--;
    }
    rep(j,vv[i].size() ){
      if(UF.find(vv[i][j])==UF.find(i)) ans--;
    }
    if(i) cout<<" ";
    cout<<ans-1;
  }
  cout<<endl; 
  return 0;
}


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

using namespace std;

#define mp make_pair
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define forlr(i, l, r) for (int i = int(l); i < int(r); i++)
#define repeat(n) for (int hjfjke = 0; hjfjke < int(n); hjfjke++)
#define all(c) c.begin(), c.end()
#define ll long long

vector<int> gr[100500];
int dp[100500];

int dfs(int v) {
    if (dp[v])
        return dp[v];

    int mx = 0;
    for (int x : gr[v])
        mx = max(mx, dfs(x));

    return dp[v] = mx + 1;
}

int32_t main() {
    std::iostream::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n, m;
    cin >> n >> m;

    repeat(m) {
        int x, y;
        cin >> x >> y;
        x--; y--;
        gr[x].push_back(y);
    }

    int ans = 0;

    for (int i = 0; i < n; i++)
        ans = max(ans, dfs(i));

    cout << ans - 1;

    return 0;
}

Measured memory_bytes: 8192
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;

int main()
{
	int a;
	string s;

	cin >> a >> s;

	if (a >= 3200)
	{
		cout << s << endl;
	}
	else
	{
		cout << "red" << endl;
	}

}

Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main{
 public static void main(String[] args){
  Scanner scanner=new Scanner(System.in);
  int n=scanner.nextInt();
  int k=scanner.nextInt();
  int total=0;
  for(int i=0;i<n;i++){
   int x=scanner.nextInt();
   total+=2*Math.min(x,k-x);
  }
  scanner.close();
  System.out.println(total);
 }
}


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

using namespace std;

typedef long long ll;

ll md = 1000000007;


int main(int, char**)
{
	ll w, h, x, y;
	cin >> w >> h >> x >> y;

	double wd = w;
	double hd = h;

	cout << setprecision(10) << (wd * hd)/ 2.0 << " ";

	if (2*x == w && 2*y==h)
		cout << 1 << endl;
	else
		cout << 0 << endl;


	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;

    if (n == 1) {
        cout << "Hello World" << endl;
    } else {
        int a, b;
        cin >> a >> b;
        cout << a + b << endl;
    }

    return 0;
}

Measured memory_bytes: 256
while(True):
    H, W = map(int, raw_input().split())

    # Exceptation
    if H == 0 and W == 0:
        break

    # Output Loop
    for i in range(H):
        s = ""

        # Odd Line
        if i%2 == 1:
            for j in range(W):
                if j%2 == 1:
                    s = s + "#"
                else:
                    s = s + "."
        # Even Line
        if i%2 == 0:
            for j in range(W):
                if j%2 == 1:
                    s = s + "."
                else:
                    s = s + "#"
        # Output
        print s
    print

Measured memory_bytes: 6452
#!/usr/bin/env python
# coding: utf-8

def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

def main():
    n = ri()
    for x in range(1, n+1):
        if int(x*1.08) == n:
            print(x)
            return
    print(":(")


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define ll long long
using namespace std;
void qmax(int &x,int y) {if (x<y) x=y;}
void qmin(int &x,int y) {if (x>y) x=y;}
inline ll read()
{
	char s;
	ll k=0,base=1;
	while((s=getchar())!='-'&&s!=EOF&&!(isdigit(s)));
	if(s==EOF)exit(0);
	if(s=='-')base=-1,s=getchar();
	while(isdigit(s)){k=k*10+(s^'0');s=getchar();}
	return k*base;
}
ll n,a[2],ans,sum,flag;
int main()
{
	flag=0;
	n=read();sum=1e16;
	for (int i=1;i<=n;i++)
	{
		a[0]=read();a[1]=read();
		if (a[0]!=a[1]) flag=1;
		ans+=a[0];
		if (a[0]>a[1]) sum=min(sum,a[1]); 
	}
	if (!flag) 
	{
		cout<<"0";
		return 0;
	} 
	ans=ans-sum;
	cout<<ans<<" \n";
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
//typedef pair<int,int> pii;
#define int long long

int a[200010];

int n,k;
int cal(int x){
    if(!x)return 1e9+1;
    int ans=0;
    for(int i=1;i<=n;++i){
        ans=ans+((a[i]-1)/x);
    }

    return ans;
}

signed main(){
    scanf("%lld%lld",&n,&k);
    for(int i=1;i<=n;++i){
        scanf("%lld",&a[i]);
    }
    int l=1,r=1e9+10,mid;
    while(l<=r){
        mid=(l+r)/2;
        int f=cal(mid);
        if(f>k)l=mid+1;
        else r=mid-1;
    }
    printf("%lld\n",l);


}


Measured memory_bytes: 5284
import sys;sys.setrecursionlimit(9**9);n=int(input());s=list(map(int,list(input())));e=[[]for _ in[0]*n]
for _ in[0]*(n-1):a,b=map(int,input().split());e[a-1].append(b-1);e[b-1].append(a-1)
def f(a):
  l,r,c=a[0]
  for u,v,d in a[1:]:l,r=max(max(l,u)-min(r,v),(l^u)&1),r+v;c+=d
  return[l,r,c]
def g(o,u):
  if(o!=u)&(len(e[u])==1):return[s[u]]*3
  l,r,c=f([g(u,v)for v in e[u]if o-v]);c+=s[u];return[l+c,r+c,c]
a=[r-c for l,r,c in[g(i,i)for i in range(n)]if l==c];print(min(a)//2if a else-1)

Measured memory_bytes: 227596
from math import sqrt
def sieve(n):
    if n <= 4:
        return list(range(2, n))
    def _sieve_of_eratosthenes(n):
        limit = int(sqrt(n))+1
        table = [1] * n
        table[0] = table[1] = 0
        for i in range(2, limit):
            if table[i]:
                for j in range(i**2, n, i):
                    table[j] = 0
        return [i for i in range(2, n) if table[i]]
    return _sieve_of_eratosthenes(n)
print(*[x for x in sieve(5555) if x % 5 == 1][:int(input())])

Measured memory_bytes: 9036
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cassert>
#define SIZE 200005
#define INF 1000000000000000LL

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

ll A[SIZE];
ll dp[SIZE][5];

ll score(ll a,int t)
{
  if(t==0||t==4) return a;
  if(t==1||t==3)
  {
    if(a==0) return 2;
    else return a%2;
  }
  return (a+1)%2;
}

int main()
{
  int n;
  scanf("%d",&n);
  for(ll i=0;i<n;i++) scanf("%lld",&A[i]);
  for(ll i=0;i<=n;i++) for(int j=0;j<5;j++) dp[i][j]=INF;
  for(int j=0;j<5;j++) dp[0][j]=0;
  for(ll i=0;i<n;i++)
  {
    for(int j=0;j<5;j++)
    {
      if(j>0) dp[i][j]=min(dp[i][j],dp[i][j-1]);
      dp[i+1][j]=min(dp[i+1][j],dp[i][j]+score(A[i],j));
    }
  }
  ll ret=INF;
  for(int j=0;j<5;j++) ret=min(ret,dp[n][j]);
  printf("%lld",ret);
  return 0;
}

Measured memory_bytes: 9472
using namespace std;
#include <bits/stdc++.h>
#define rep(i, s) for (int i = 0; i < s; ++i)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define all(v) (v.begin(), v.end())
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define EPS (1e-7)
#define INF (1e10)
#define PI (acos(-1))
const ll mod = 1000000007;
bool f(string s){
  bool ans=true;
  rep(i,s.size()/2){
    if(s[i]!=s[s.size()/2+i]){
      ans=false;
      break;
    }
  }
  return ans;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  char A;
  cin>>A;
  cout<<char(A+1)<<endl;
}


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

int main() {
    int h, a, b, ans = 0;
    cin >> h >> a >> b;
    for(int i=a;i<=b;i++){
        if(h%i==0) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3084
#include <stdio.h>
int main(void){
   char t[60][60]={};
   int h,w;
   
   scanf("%d %d\n",&h,&w);
   for(int i=0;i<h;i++){
       for(int j=0;j<w;j++){
           scanf("%c",&t[i+1][j+1]);
       }
       scanf("\n");
   }
   
   for(int i=0;i<h;i++){
       for(int j=0;j<w;j++){
           
           if(t[i+1][j+1]=='#')continue;
           int count=0;
           for(int k=-1;k<=1;k++){
               for(int l=-1;l<=1;l++){
                   if(k==0 && l==0)continue;
                   if(t[i+k+1][j+l+1]=='#')count++;
               }
           }
           t[i+1][j+1]=count+48;
           
       }
   }
   
   for(int i=0;i<h;i++){
       for(int j=0;j<w;j++){
           printf("%c",t[i+1][j+1]);
       }
       printf("\n");
   }
   
    
}

Measured memory_bytes: 1644
H,W=map(int,input().split())
a=[input() for i in  range(H)]
b=[['#']*(W+2) for i in range(H+2)]
for i in range(H):
    for j in range(W):
        b[i+1][j+1]=a[i][j]
for i in range(H+2):
    for j in range(W+2):
        print(b[i][j],end='')
    print()


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

#define int long long
#pragma GCC optimize ("O3")
#define ll long long
#define vi vector <int>
#define vii vector <pair<int,int> >
#define rep(i,a,b) for (int i=a;i<b;i++)
#define repD(i,a,b) for (int i=a;i>b;i--)
#define pb push_back
#define pii pair <int,int>
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define MOD 1000000007
#define PI 3.14159265359


/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>

using namespace __gnu_pbds;
typedef tree<pii,null_type,less <pii>,rb_tree_tag,tree_order_statistics_node_update>ind_set;
*/
///*X.find_by_order("index")
///X.order_of_key("key")



#define deb(x) cerr<<#x<< " : " <<x<<"\n";
#ifndef local
	#define deb(x) ;
#endif
///----------------------------------------------------------------------------------

int n;vi adj[10004];
int deg[10004],arr[10004],ans[10004];

int dfs(int so,int P=-1)
{
	int ret=0;
	for (auto x:adj[so])if (x!=P)ret+=min(ans[so],ans[x])+dfs(x,so);
	return ret;
}
vi TS;
void dfs2(int so,int P=-1)
{
	for (auto x:adj[so])if (x!=P)dfs2(x,so);
	TS.pb(so);
}
void solve()
{
	cin>>n;int u,v;rep(i,0,n-1)cin>>u>>v,adj[u-1].pb(v-1),adj[v-1].pb(u-1);
	rep(i,0,n)cin>>arr[i],deg[i]=adj[i].size();

	sort(arr,arr+n);

	/*queue<int> Q;
	rep(i,0,n)if (deg[i]==1)Q.push(i);
	int c=0;
	while(!Q.empty())
	{
		int X=Q.front();Q.pop();

		ans[X]=arr[c++];
		deg[adj[X][0]]--;
		if (deg[adj[X][0]]==1)Q.push(adj[X][0]);
	}*/
	dfs2(0);
	
	rep(i,0,n)ans[TS[i]]=arr[i];
	int temp=0;
	rep(i,0,n-1)temp+=arr[i];

	///if (temp!=dfs(0))exit(1);

	cout<<dfs(0)<<"\n";
	rep(i,0,n)cout<<ans[i]<<" ";

}

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

    #ifdef local
    freopen("input.txt","r",stdin);
    ///freopen("output.txt","w",stdout);
    #endif

    clock_t qwertyuiop = clock();
    int t=1;
    ///cin>>t;
    rep(a,0,t)
    {
        ///cout<<"Case #"<<a+1<<": ";
        solve();
    }
    #ifdef local
	{qwertyuiop = clock() - qwertyuiop;double time_taken = ((double)qwertyuiop)/CLOCKS_PER_SEC;cerr<<fixed<<setprecision(5)<<"\n\nTime Taken : "<<time_taken<<" seconds\n";}
	#endif
}


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

int main() {
    int K,num,ans;
    cin >> K;
    num = K / 2;
    
    if(K%2!=0){
        ans = num * (num + 1);
    }else{
        ans = num * num;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long int lli;
#define optimize ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define vi vector<int>
#define pii pair<int,int>
#define mii map<int,int>
#define F first
#define S second
#define forn(i,n) for(int i = 0; i<n; i++)
#define forab(i,a,b) for(int i = a; i<b; i++)
#define forll(i,a,b) for(lli i = a; i<b; i++)
#define mp make_pair
#define pb push_back
#define sortv(v) sort(v.begin(), v.end())
#define debug(x) cout<<#x<<" : "<<x<<endl
#define all(x) x.begin(),x.end()
#define printv(v) for(auto it : v) cout<<it<<" ";cout<<endl;
#define prec(n) fixed<<setprecision(n)
const int mod1 = 1000000007;
const int mod2 = 998244353;
const int N = 1e5;

int main()
{
	optimize

	#ifndef ONLINE_JUDGE
	freopen("inputf.in", "r", stdin);
	freopen("outputf.in", "w", stdout);
	#endif

	int x;
	cin>>x;
	if(x == 0)
		cout<<1<<endl;
	if(x==1)
		cout<<0<<endl;

	return 0;
}

Measured memory_bytes: 3648
use v5.18; # strict say state
use warnings;
use List::Util qw(reduce first max min sum0);

chomp (my $n = <STDIN>);
chomp (my @a = split / /, <STDIN>);
my %h;
$h{$_}++ for @a;
my @s = sort {$b <=> $a} grep {$h{$_} >= 4} keys %h;
my @t = sort {$b <=> $a} grep {$h{$_} >= 2} keys %h;
my $ans = 0;
$ans = $s[0] * $s[0] if @s > 0;
$ans = max($ans, $t[0] * $t[1]) if @t > 1;
say $ans;

Measured memory_bytes: 28196
N=int(input())
i=0
l=[]
for i in range(0,N):
    a,b=input().split()
    l.append(a)
    l.append(b)
    i+=1
i=0
c=0
for i in range(0,2*N):
    if i==2*N-4:
        break
    if l[i]==l[i+1]:
        if l[i+2]==l[i+3]:
            if l[i+4]==l[i+5]:
                c+=1
                break
            else:
                if i+6<2*N-5:
                    i+=6
        else:
            if i+4<2*N-3:
                i+=4
    else:
        i+=2
if c==0:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 9220
// Author : heyuhhh
// Created Time : 2020/09/13 21:02:47
#include<bits/stdc++.h>
#define MP make_pair
#define fi first
#define se second
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define INF 0x3f3f3f3f
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
//head
const int N = 1e5 + 5;
void run() {
    int n;
    cin >> n;
    vector<int> x(n), y(n);
    vector<int> a(4, -2000000000);
    vector<int> b(4, 2000000000);
    for (int i = 0; i < n; i++) {
        cin >> x[i] >> y[i];
        a[0] = max(a[0], x[i] + y[i]);
        b[0] = min(b[0], x[i] + y[i]);

        a[1] = max(a[1], x[i] - y[i]);
        b[1] = min(b[1], x[i] - y[i]);

        a[2] = max(a[2], -x[i] + y[i]);
        b[2] = min(b[2], -x[i] + y[i]);

        a[3] = max(a[3], -x[i] - y[i]);
        b[3] = min(b[3], -x[i] - y[i]);
    }
    int ans = -2000000000;
    for (int i = 0; i < 4; i++) {
        ans = max(ans, a[i] - b[i]);
    }
    cout << ans << '\n';
}
int main() {
#ifdef Local
    freopen("input.in", "r", stdin);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cout << fixed << setprecision(20);
    run();
    return 0;
}

Measured memory_bytes: 4776
#define _CRT_SECURE_NO_WARNINGS // #pragma warning(disable:4996)
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <functional>
#include <sstream>
#include <cmath>
#include <set>
#include <map>
using namespace std; 

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define all(a) a.begin(),a.end()
#define len(x) ((int)(x).size())
#define tmax(a,b,c) max((a),max((b),(c)))
#define tmin(a,b,c) min((a),min((b),(c)))
#define debug(x) cerr << #x << " is " << x << endl;

typedef pair<int, int> Pii;
typedef vector<int> Vi;
typedef vector<vector<int> > VVi;
typedef long long ll;
const int inf = 2e9;
const ll ll_inf = 1e17;
const int mod = 1e9 + 7;
const long double eps = 1e-10;

int a[101];

int main()
{
	while(1) {
		int n, m, p;
		cin >> n >> m >> p;
		if (!n && !m && !p) break;
		int sum = 0, cnt = 0;
		rep(i,0,n) {
			cin >> a[i];
			sum += (100 - p) * a[i];
			cnt += a[i];
		}
		m--;
		if (!a[m]) {
			cout << 0 << endl;
			continue;
		}

		cout << floor((double)sum / a[m]) << endl;
	}

	return 0;
}

Measured memory_bytes: 1236
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <string>

using namespace std;

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

	sort(s.begin(), s.end());
	cout << (s == "abc" ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
#include<atcoder/segtree.hpp>
using namespace atcoder;
using namespace std;
#define REP(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define rep(i,n) REP((i),0,(n))
using ll = long long;
using pll = pair<ll, ll>;
using tp3 = tuple<ll, ll, ll>;
constexpr int INF = 1 << 28;
constexpr ll INFL = 1ll << 60;
constexpr int dh[4] = { 0,1,0,-1 };
constexpr int dw[4] = { -1,0,1,0 };
bool isin(const int H, const int W, const int h, const int w) {
    return 0 <= h && h < H && 0 <= w && w < W;
}
// ============ template finished ============

int op(int a, int b) {
    return max(a, b);
}
int e() {
    return 0;
}

const int SIZE = 3e5 + 10;
int main()
{
    int N, K;
    cin >> N >> K;
    segtree<int, op, e> segMax(SIZE);

    rep(_, N) {
        int A;
        cin >> A;
        int l = max(A - K, 0);
        int r = min(A + K, SIZE - 1);
        int best = segMax.prod(l, r + 1);
        best++;
        segMax.set(A, best);
    }
    cout << segMax.all_prod() << endl;
    return 0;
}


Measured memory_bytes: 8540
N = int(input())
X = list(map(int, input().split()))
max_raw = max(X)

ans_raw = []
count = 0

for i in range(1, max_raw + 1):
    count = 0
    for j in range(0, len(X)):
        count += (X[j] - i) ** 2
    ans_raw.append(count)

print(min(ans_raw))


Measured memory_bytes: 3060
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
from collections import deque
from fractions import gcd
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#############
# Main Code #
#############

S = inputS()

if S == "ARC":
  print("ABC")
else:
  print("ARC")

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

int main() {
	int week;
	cin >> week;
	int debt = 100;
	for (int i = 0; i < week; i++)
	{
		debt = ((debt * 105) / 100) + ((debt % 20) > 0 ? 1 : 0);
	}
	cout << debt << "000" << endl;

	return 0;
}

Measured memory_bytes: 2972
import numpy as np

n = int(input())

a = np.array(list(map(int, input().split())))
d = [0] * (n+1)
s = {}

for i in a:
  d[i] += 1
  
sum = 0
for k in d:
  if k>1:
    sum += (k*(k-1))//2

for i in range(n):
  nd = d[a[i]]
  ans = sum-(nd*(nd-1))//2
  nd -= 1
  if nd>1:
    ans += (nd*(nd-1))//2
  print(ans)


Measured memory_bytes: 36204
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	var strs []string
	var a, b, c, d, e, f float64
	var x, y float64
	for scanner.Scan() {
		strs = strings.Split(scanner.Text(), " ")
		_a, _ := strconv.Atoi(strs[0])
		_b, _ := strconv.Atoi(strs[1])
		_c, _ := strconv.Atoi(strs[2])
		_d, _ := strconv.Atoi(strs[3])
		_e, _ := strconv.Atoi(strs[4])
		_f, _ := strconv.Atoi(strs[5])
		a = float64(_a)
		b = float64(_b)
		c = float64(_c)
		d = float64(_d)
		e = float64(_e)
		f = float64(_f)
		y = (c*d - f*a) / (d*b - a*e)
		x = (c - b*y) / a

		fmt.Printf("%.3f %.3f\n", x, y)
	}
}



Measured memory_bytes: 1148
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<string>
#include<cstring>
#include<time.h>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<bitset>
#include <queue>
#include <map>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;


//BDD,ZDD,kdtree, bdtree,bicalc, bolonoy, doloney,chinesemod,segmenttree,daikusutora, saidairyuu, 2bugurahu, heirokenshutu, topologicalsort, kyourenketuseibun


#define PRI(s) cout << s << endl
#define PRIY PRI("Yes")
#define PRIN PRI("No")

int main() {
	int n;
	cin >> n;
	int x = (n + 1) / 2;
	PRI((double)x/(double)(n));
	return 0;
}

Measured memory_bytes: 3756
/*
Miles Morales : When will I know I'm ready?
Peter B. Parker : You won't. It's a leap of faith. That's all it is, Miles. A leap of faith.
*/
//KEEP IT SIMPLE STUPID

#include <bits/stdc++.h>

#pragma GCC optimize("O3")
#pragma GCC target("avx")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define ll long long
#define MP make_pair
#define ERR cout << "================================================\n"
#define fi first
#define se second
#define PB push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n)-1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define print(v)          \
    for (auto x : v)      \
    {                     \
        cout << x << " "; \
    }
#define MAX(v) *max_element(all(v))
#define MIN(v) *min_element(all(v))
#define SP << " " <<
#define W(t)  \
    ll t;     \
    cin >> t; \
    while (t--)
#define FIO                           \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout);
#define FAST                 \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const ll INF = 1e18;
const ll NEG_INF = -1 * (1e18);
using namespace std;

void usaco(string prob)
{
    freopen((prob + ".in").c_str(), "r", stdin);
    freopen((prob + ".out").c_str(), "w", stdout);
}

/* Function to check primality in O(sqrt(n)) */
bool prime(int n)
{
    if (n < 2)
        return false;
    for (int x = 2; x * x <= n; x++)
    {
        if (n % x == 0)
            return false;
    }
    return true;
}

/* Function to get prime factorization of n */
vector<int> getFactors(int n)
{
    vector<int> f;
    for (int x = 2; x * x <= n; x++)
    {
        while (n % x == 0)
        {
            f.push_back(x);
            n /= x;
        }
    }
    if (n > 1)
        f.push_back(n);
    return f;
}

void solve()
{
    /* Write Solution Here */
    string s;
    cin >> s;
    if (s == "RSS" || s == "SRS" || s == "SSR" || s == "RSR")
    {
        cout << 1 << "\n";
    }
    else if (s == "SSS")
    {
        cout << 0 << "\n";
    }
    else if (s == "RRS" || s == "SRR")
    {
        cout << "2\n";
    }
    else
    {
        cout << "3\n";
    }
}

int main()
{
    //FIO
    FAST

        //usaco("cowlands");

        ll TC = 1;
    /*
	Uncomment when multiple test cases
	*/

    // cin>>TC;
    for1(tt, TC)
    {
        solve();
    }
    return 0;
}

/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
*/


Measured memory_bytes: 3624
#include<stdio.h>

int main( void ){
    int a, b, c;
	
	scanf("%d %d %d", &a, &b, &c);
	
	if( a < b && b < c ){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}


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

    int a[k],m=0,x,l,b,c,min;
    for(i=0;i<k;i++){a[i]=0;}
    for(i=n-2;i>=0;i--)
    {

        if(m<k){m++;}
        for(l=0;l<m;l++)
        {
            x=abs(arr[i]-arr[i+1+l])+a[l];
            if(l==0){min=x; b=a[l];}
            else{if(min>x){min=x;} c=a[l];a[l]=b;b=c;}
        }
        a[0]=min;

    }
    cout<<a[0];
}

Measured memory_bytes: 640
n=int(input())
A=[int(i) for i in input().split()]
B=[int(i) for i in input().split()]
C=[int(i) for i in input().split()]
import bisect
A.sort()
B.sort()
C.sort()
ans=0
for b in B:
  ans+=bisect.bisect_left(A,b)*(n-bisect.bisect_right(C,b))
print(ans)
    




Measured memory_bytes: 23200
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define pai 3.14159265358979323846
const int INF = 1001001001;
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
int a[3][3],n;
using Graph = vector<vector<int>>;
vector<vector<int>> field;
vector<bool> seen;

int main() {
  int a,b;
  cin >> a >> b;
  int ans = 1,cnt = 0;

  while(ans < b){
    cnt++;
    ans += a-1;
    //cout << 1 << endl;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e15;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
typedef pair<ll,ll> P;
typedef pair<double,double> point;
const ll MAX = 2000005;
constexpr ll nx[8] = {1,0,-1,0,1,-1,1,-1};
constexpr ll ny[8] = {0,1,0,-1,1,1,-1,-1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m;
    cin >> n >> m;
    vector<vector<ll>> ball(n,vector<ll>(2,0));
    rep(i,1,n) ball[i][0] = 1;
    ball[0][1] = 1;
    ll x,y;
    rep(i,m){
        cin >> x >> y;
        x--;
        y--;
        if (ball[x][0] && ball[x][1]){
            ball[y][1]++;
            ball[x][0]--;
        }
        else if (ball[x][0]){
            ball[y][0]++;
            ball[x][0]--;
        }
        else{
            ball[y][1]++;
            ball[x][1]--;
        }
    }
    ll ans = 0;
    rep(i,n){
        if (ball[i][1]) ans++;
    }
    PRINT(ans);
}


Measured memory_bytes: 8632
def dist(x,y):
    return abs(x[0]-y[0])+abs(x[1]-y[1])
N,M = map(int,input().split())
X = [list(map(int,input().split())) for _ in range(N)]
Y = [list(map(int,input().split())) for _ in range(M)]
for i in range(N):
    x,y = X[i]
    ind = M+1
    dmin = 10**9
    for j in range(M):
        c,d = Y[j]
        d = dist((x,y),(c,d))
        if d<dmin:
            ind = j+1
            dmin = d
    print(ind)

Measured memory_bytes: 67712
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pi pair<int,int>
#define ff first
#define ss second
#define boost ios::sync_with_stdio(false);cin.tie(nullptr)
#define endl "\n"
#include "string"

const int inf = 1e16;
const int N = 3003;
int a[N][N], dp[N][N][4];
int r, c, n;
	
int solve(int x, int y, int cur) {
	if(x  > r or y > c)
		return 0;

	int &tmp = dp[x][y][cur];
	if(tmp != -1)
		return tmp;
	tmp = max(solve(x + 1, y, 0), solve(x, y + 1 , cur));
	tmp = max(tmp , solve(x, y + 1, cur));
	if(cur + 1 < 4) {
		tmp = max(tmp , solve(x + 1, y , 0) + a[x][y]);
		tmp = max(tmp , solve(x, y + 1, cur + 1) + a[x][y]);
	}
	return tmp;
}

int32_t main() {
	boost;
	cin >> r >> c >> n;
	memset(dp, -1, sizeof dp);
	for(int i = 0; i < n; i++) {
		int x, y, val;
		cin >> x >> y >> val;
		a[x][y] = val;
	} 
	int ans = solve(1,1,0);
	cout << ans << endl;
}

Measured memory_bytes: 356224
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  ll n,c;
  cin >> n >> c;
  vec v(n);
  for(ll i=0;i<n;i++) {
    cin >> v[i];
  }
  ll ans=0;
  for(ll i=1;i<=min(c,n);i++) {
    for(ll j=0;j<=i;j++) {
      ll tans=0;
      priority_queue<ll,vec,greater<ll>> q;
      for(ll k=0;k<j;k++) {
        tans+=v[k];
        q.push(v[k]);
      }
      for(ll k=0;k<i-j;k++) {
        tans+=v[n-1-k];
        q.push(v[n-1-k]);
      }
      ll cnt=c-i;
      while(cnt&&q.size()&&q.top()<0) {
        tans-=q.top();
        q.pop();
        cnt--;
      }
      ans=max(ans,tans);
    }
  }
  cout << ans << endl;
}

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

#define rep(i,n) for(ll i=0;i<ll(n);i++)
#define YESNO(T) if(T){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yesno(T) if(T){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}
#define YesNo(T) if(T){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
const double pi = 3.14159265358979;

ll comb(ll n,ll k){
    vector<vector<ll>> v(n+1, vector<ll> (n+1,0));
    for (ll i = 0; i < v.size(); i++){
        v[i][0] = 1;
        v[i][i] = 1;
    }

    for (ll i = 2; i < v.size(); i++){
        for (ll j = 1; j < i; j++){
            v[i][j] = v[i-1][j-1] + v[i-1][j];
        }
    }

    return v[n][k];
    
    // nCkを返す
}

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

    ll n,p;
    cin >> n >> p;
    vector<ll> a(n);
    for (ll i = 0;i < n;i++){
        cin >> a[i];
    }

    ll k;
    for (ll i = 0; i < n; i++){
        if (a[i]%2 == 1){
            k++;
        }
    }

    ll s = 0;
    for (ll i = 0; i <= k; i += 2){
        s += comb(k,i);
    }

    ll ans = s;
    rep(i,n-k){
        ans *= 2;
    }

    if (p == 0){
        cout << ans << endl;
    }
    else{
        ll y = pow(2,n);
        cout << y-ans << endl;
    }

}

Measured memory_bytes: 3992
#include<string>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include <iomanip>
#include<cmath>
#include<stack>
#include <algorithm>
#include<cstdio>
#include <cstring>
#include <iostream>
#define inf 0n7fffffff
using namespace std;
int main ()
{
    int n;
    int i;
    int sum=0;
    scanf("%d",&n);
    for(i=0;i<=n;i++)
        sum+=i;
    printf("%d",sum);
    return 0;
}

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

int N, M, ans;
int main(){
	scanf("%d %d", &N, &M);
	int temp = M/N;
	int stop;
	for (int i = 1; ; i++) {
		if (i*i > M) {
			stop = i - 1;
			break;
		}
	}
	for (int i = 1; i <= min(stop, temp); i++) {
		if (M % i == 0) {
			if (M / i <= temp) {
				ans = max(ans, M/i);
			}
			ans = max(ans, i);
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
#define rep(i,n) for(int i=0;i<n;++i)
#define rep2(i,x,n) for(int i=x;i<n;++i)

int main()
{    
    int n,k;
    cin >> n >> k;
    vector<int> h(n);
    rep(i,n) cin >> h[i];

    sort(h.begin(),h.end());
    i64 sum = 0;
    rep(i,n-k) sum += h[i];
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 1024
n = int(input())
a = []

for i in range(n):
    x = int(input())
    a.append(x)

ma = max(a)
max_i = a.index(ma)
b = []

for j in range(n):
    if j != max_i:
        b.append(a[j])

mb = max(b)

for i in range(n):
    if i != max_i:
        print(ma)
    else:
        print(mb)


Measured memory_bytes: 14068
#include<bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const ll MOD=1000000007;
const ll INF=1000000010;
const ll LINF=4000000000000000010;
int dx[5]={0,1,0,-1,0};
int dy[5]={1,0,-1,0,0};
int main(){
    int a,b;cin>>a>>b;
    if(a+b==15){
        cout<<"+"<<endl;
    }else if(a*b==15){
        cout<<"*"<<endl;
    }else{
        cout<<"x"<<endl;
    }
}


Measured memory_bytes: 768
N, K = map(int, input().split())
A = [int(a) for a in input().split()]
X = [0] * (K + 1) # 後手必勝のところが1

X[K] = 1
for i in range(K)[::-1]:
    for a in A:
        if i + a <= K:
            if X[i+a] == 1:
                break
    else:
        X[i] = 1
        
print(["First", "Second"][X[0]])


Measured memory_bytes: 41708
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
#define LINF (1LL << 60)
#define INF (1 << 30)
#define MAX_N 2160
typedef long long  Int;
struct E{
	int to, rev;
	Int lim;
	E(int x, Int y, int z){
		to = x;
		lim = y;
		rev = z;
	}
};

vector<E> edge[MAX_N];
int lev[MAX_N];
int iter[MAX_N];

void make_edge(int a, int b, Int l){
	edge[a].push_back(E(b, l, edge[b].size()));
	edge[b].push_back(E(a, 0, edge[a].size() - 1));
}

Int dfs(int s, int g, Int f){
	if(s == g)return f;
	for(int &i = iter[s];i < edge[s].size();i++){
		E &e = edge[s][i];
		if(lev[e.to] <= lev[s] || e.lim <= 0)continue;
		Int tmp = dfs(e.to, g, min(f, e.lim));
		if(!tmp)continue;
		e.lim -= tmp;
		edge[e.to][e.rev].lim += tmp;
		return tmp;
	}
	return 0;
}

void bfs(int x){
	queue<int> q;
	q.push(x);
	int p = 0;
	while(!q.empty()){
		for(int i = q.size();i--;){
			int tmp = q.front();q.pop();
			if(lev[tmp] != INF)continue;
			lev[tmp] = p;
			for(int j = 0;j < edge[tmp].size();j++){
				if(edge[tmp][j].lim > 0 && lev[edge[tmp][j].to] == INF)q.push(edge[tmp][j].to);
			}
		}
		p++;
	}
}

Int max_flow(int s, int g){
	Int res = 0;
	bool fin = false;
	while(!fin){
		fill(lev, lev + MAX_N, INF);
		fill(iter, iter + MAX_N, 0);
		bfs(s);
		fin = true;
		while(true){
			int p = dfs(s, g, INF);
			if(p == 0)break;
			fin = false;
			res += p;
		}
	}	
	return res;
}

int dist[108][108];
int p[1080], t[1080];
int main(){
	int n, m, l, u, v, d;
	while(cin >> n >> m >> l, n|m|l){
		for(int i = 0;i < 2160;i++)edge[i].clear();
		for(int i = 0;i < n;i++){
			for(int j = 0;j < n;j++){
				if(i == j)dist[i][j] = 0;
				else dist[i][j] = INF - 1;
			}
		}
		for(int i = 0;i < m;i++){
			cin >> u >> v >> d;
			dist[u][v] = d;
			dist[v][u] = d;
		}
		for(int i = 0;i < n;i++)
			for(int j = 0;j < n;j++)
				for(int k = 0;k < n;k++)
					dist[j][k] = min(dist[j][i] + dist[i][k], dist[j][k]);
		for(int i = 0;i < l ;i++){
			cin >> p[i] >> t[i];
		}
		for(int i = 0;i < l;i++){
			make_edge(l * 2, i, 1);
			make_edge(i + l, l * 2+1, 1);			
			for(int j = 0;j < l;j++){
				if(i == j)continue;
				if(t[i] + dist[p[i]][p[j]] <= t[j]){
					make_edge(i, j + l, 1);
				}
			}
		}
		cout << l - max_flow(l * 2, l * 2 + 1) << endl;
	}
	return 0;
}

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

int main(){
	int a, b, c;
	cin >> a >> b >> c;
	
	if(a==b+c || b==c+a || c==a+b) printf("Yes\n");
	else printf("No\n");
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[1000000];
int v[100000];
int b[2];
int x, y,sum;
int n;
void dfs(int k,int t)
{
	if (t == 2)
	{
		sum += b[0]*b[1];
		return;
	}
	for (int i = k; i < n; i++)
	{
		if (!v[i])
		{
			b[t] = a[i];
			v[i] = 1;
			t++;
			dfs(i, t );
			t--;
			v[i] = 0;
		}
	}
}
int main()
{
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	dfs(0,0);
	cout << sum;

}

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

typedef long long ll;
const int maxn=2e5+54;
char buff[maxn];
int cnt[maxn];
int main() {
    cnt[0]=1;int n,p;
    cin>>n>>p;
    scanf("%s",buff+1);
    int now=0,pow10=1;ll ans=0;
    if(p==2)
    for(int i=n;i>=1;i--){
        if((buff[i]-'0')%2==0) ans+=i;
    }
    else if(p==5){
        for(int i=n;i>=1;i--){
            if((buff[i]-'0')%5==0) ans+=i;
        }
    }
    else{
        for(int i=n;i>=1;i--){
        now=(now+pow10*(buff[i]-'0'))%p;
        pow10=pow10*10%p;
        ans+=cnt[now];cnt[now]++;
    }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <string.h>
int main(){
  int n;
  char s[100+2]={0};
  scanf("%d", &n);
  scanf("%s", s);
  
  if(n%2){ printf("No"); return 0; }
  
  for(int i=0; i<n/2; i++){
    if( s[i] != s[i+(n/2)] ){ printf("No"); return 0; }
  }
  printf("Yes");
  return 0;
}


Measured memory_bytes: 1704
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 4611686018427387903;
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main(){
	ll a, b, v, w; 
	cin >> a >> v >> b >> w;
	ll t;
	cin >> t;
	if(a<b){
		if(a+t*v>=b+t*w)
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}
	else{
		if(a-t*v<=b-t*w)
			cout << "YES" << endl;
		else
			cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>
using namespace std;
#define ll long long int

struct UnionFind {
  vector < int > parent;
  
  //最初はすべての根が親であるとして初期化
  UnionFind( int N ) : parent ( N ) {
    for ( int i = 0; i < N; ++i ) parent[i] = i;
  }
  

  int root( int x ) {
    if ( parent[x] == x ) return x;
    return parent[x] = root( parent[x] );
  }

  void unite( int x, int y ) {
    int rx = root(x);
    int ry = root(y);
    if ( rx == ry ) return;
    parent[rx] = ry;  
  }

  bool same( int x, int y ) {
    int rx = root(x);
    int ry = root(y);
    return rx == ry;  
  }
};


int main() {
  int n, m, ans = 0;
  cin >> n >> m;
  vector < int > p(n);
  for ( int i = 0; i < n; ++i ) {
    cin >> p[i];
  }
  UnionFind tree(n);

  for ( int i = 0; i < m; ++i ) {
    int x, y;
    cin >> x >> y;
    tree.unite( x - 1, y - 1 );
  }
  for ( int i = 0; i < n; ++i ) {
    if ( tree.same( i, p[i] - 1 ) ) {
      ans++;   
    }  
  }
  cout << ans << endl;
  return 0;
}




Measured memory_bytes: 1024
N, *AS = $stdin.read.split.map &:to_i

p [1, -1].map{|o|
  ans = 0
  acc = 0
  N.times.each do |i|
    target = (i.odd? ? 1 : -1) * o
    case
    when target ==  1 && (acc + AS[i]) >= 1 ||
         target == -1 && (acc + AS[i]) <= -1
      diff = 0
      actual = AS[i]
    else
      diff = target - (acc + AS[i])
      actual = AS[i] + diff
    end
    #p a: AS[i], acc_: acc+AS[i], target: target, actual: actual, diff: diff
    acc += actual
    ans += diff.abs
    #p acc: acc, ans: ans
  end
  #p "\n"
  ans
}.min


Measured memory_bytes: 9340
#include <iostream>

using namespace std;


int main() {
	unsigned int s;
	cin >> s;
	if(s == 1053){
		cout << "1053" << endl;
	}else{
		if ((s / 100 <= 12) && (s / 100 > 0)) {
			if ((s % 100 <= 12) && (s % 100 > 0)) {
				cout << "AMBIGUOUS" << endl;
			}else {
				cout << "MMYY" << endl;
			}
		}else {
			if ((s % 100 <= 12) && (s % 100 > 0)) {
				cout << "YYMM" << endl;
			}else {
				cout << "NA" << endl;
			}
		}
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P; 
const int inf = 1<<21;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int n;
ll d[2003][2003];
int x, y;

void floyd(){
    rep(i, n){
        if(d[i][x-1] == INF) continue;
        rep(j, n){
            if(d[x-1][j] == INF) continue;
            chmin(d[i][j], d[i][x-1] + d[x-1][j]);
        }
    }

    rep(i, n){
        if(d[i][y-1] == INF) continue;
        rep(j, n){
            if(d[y-1][j] == INF) continue;
            chmin(d[i][j], d[i][y-1] + d[y-1][j]);
        }
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> x >> y;
    rep(i, n)rep(j, n) {
        d[i][j] = abs(i-j);
    }
    d[x-1][y-1] = 1;
    floyd();
    map<int, int> mp;
    rep(i, n)for(int j=i+1; j<n; j++){
        mp[d[i][j]]++;
    }
    rep(i, n-1){
        cout << mp[i+1] << endl;
    }

    return 0;
}

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

vector<ll> dividers(ll num) {
    ll a = 1;
    vector<ll> r;
    while (a * a <= num) {
        if (num % a == 0) {
            r.push_back(a);
            r.push_back(num / a);
        }
        a++;
    }
    sort(r.begin(), r.end());
    return r;
}

int main() {
    ll a, b;
    cin >> a >> b;
    //
    auto as = dividers(a);
    auto bs = dividers(b);
    //共通のものを探す
    int ac = as.size();
    int bc = bs.size();
    int ai = 0;
    int bi = 0;
    vector<ll> common;
    while (ai < ac && bi < bc) {
        if (as[ai] == bs[bi]) {
            //1は絶対あるので除去
            if (as[ai] != 1) {
                common.push_back(as[ai]);
            }
            ai++;
            bi++;
        } else if (as[ai] < bs[bi]) {
            ai++;
        } else {
            bi++;
        }
    }
    //共通部分が素なもののみ抽出。
    vector<ll> ans;
    rep(i, common.size()) {
        ll v = common[i];
        bool add = true;
        rep(j, ans.size()) {
            if (v % ans[j] == 0) {
                add = false;
                break;
            }
        }
        if (add) {
            ans.push_back(v);
        }
    }
    cout << (ans.size() + 1) << "\n";
}

Measured memory_bytes: 512