akhauriyash/Code-Regression huggingface dataset:
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <cassert>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#define ALL(v) begin(v),end(v)
#else
#define ALL(v) (v).begin(),(v).end()
#endif

using namespace std;


namespace{
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8

int as[50], bs[50], cs[50];
int tbl1[410][410], tbl2[410][410];

const int INF = 1010101010;

void calc(int from, int to, int tbl[][410]){
	for(int i = 0; i < 410; ++i)
	for(int j = 0; j < 410; ++j){
		tbl[i][j] = INF;
	}
	
	tbl[0][0] = 0;
	for(int i = from; i < to; ++i){
		for(int j = 400; j >= as[i]; --j)
		for(int k = 400; k >= bs[i]; --k){
			tbl[j][k] = min(tbl[j][k], tbl[j - as[i]][k - bs[i]] + cs[i]);
		}
	}
}

void mainmain(){
	int n, ma, mb;
	cin >> n >> ma >> mb;
	for(int i = 0; i < n; ++i){
		cin >> as[i] >> bs[i] >> cs[i];
	}
	
	calc(0, n / 2, tbl1);
	calc(n / 2, n, tbl2);
	
	int ans = INF;
	for(int w = 0; w <= 400; ++w)
	for(int x = 0; x <= 400; ++x)
	for(int y = 0; y <= 400; ++y){
		int t = (w + y) * mb;
		if(t % ma == 0){
			int z = t / ma - x;
			if(0 <= z && z <= 400){
				if(!w && !x && !y && !z){ continue; }
				ans = min(ans, tbl1[w][x] + tbl2[y][z]);
			}
		}
	}
	
	if(ans == INF){ ans = -1; }
	cout << ans << endl;
}



}
int main() try{
//	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	cerr << fixed << setprecision(4);
	mainmain();
}
catch(...){}


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

#define mod 1000000007
#define ll long long int
#define mk make_pair
#define pb push_back
#define xx first
#define yy second
#define ar array
#define del 1e-8

template<typename T, typename U> static inline void amin(T &x, U y){ if(y<x) x=y; }
template<typename T, typename U> static inline void amax(T &x, U y){ if(x<y) x=y; }

double pi=3.141592653589793238;
const int M = 1e9+7;
const int Nmax=5005;
const int MM = 998244353;
const int N=100005;

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0);
	int T=1;
	//cin>>T;
	while(T--){
    int n;
    cin>>n;
    ar<ll,2> arr[n+1];
    int f[n];
    for(int i=0;i<n;i++){
        cin>>arr[i][0]>>arr[i][1];
        if(arr[i][0]==arr[i][1])f[i]=1;
        else f[i]=0;    }
    for(int i=0;i+2<n;i++){
        if(f[i]+f[i+1]+f[i+2]==3){
            cout<<"Yes\n";
            return 0;
        }
    }
    cout<<"No\n";
    }
	return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
//using namespace __gnu_pbds;

#define ll  long long
#define PR  pair<int, int>

const int N = 3e5 + 10;
const int MOD = 1e9 + 7;
const long long INF = 5e18;
const double PI = 2 * acos(0.0);
//template<typename T> using ordered_set = tree<T, nulong long_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    vector<int> p2(31, 1);
    for (int i = 1; i < 31; i++) {
        p2[i] = p2[i - 1] * 2;
    }
    int n;
    cin >> n;
    multiset<int> ms;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        ms.insert(x);
    }
    int ans = 0;
    while (!ms.empty()) {
        int a = *ms.rbegin();
        ms.erase(ms.lower_bound(a));
        for (int i = 30; i >= 0; i--) {
            int need = p2[i] - a;
            if (ms.find(need) != ms.end()) {
                ms.erase(ms.lower_bound(need));
                ans++;
                break;
            }
        }
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 12976
//#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>

using namespace std;

#define rep(i , n) for(int i=0 ; i<n ; i++)
#define rep1(i , n) for(int i=1 ; i<=n ; i++)

typedef long long int ll;


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

	int arr[3],k;
	cin >> arr[0] >> arr[1] >> arr[2] >> k;

	sort(arr , arr+3);
	cout << arr[1]+arr[0]+(arr[2] * (1<<k));
	return 0;
}

Measured memory_bytes: 256
/*
 * 16-8-21_AGC003_B.cpp
 *
 *  Created on: 2016/08/21
 *      Author: ryoma
 */

#include<iostream>

using namespace std;

int main() {
	int N;
	cin >> N;
	long long ans = 0;
	long long now = 0, former = 0;
	for (int i = 0; i < N; i++) {
		cin >> now;
		if (now > 0 && former == 1) {
			now--;
			ans++;
		}
		ans += now / 2;
		former = now % 2;
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n,m,k,i,a[10009][10009],ans[10000009],x,ans2=100000000009,l;
bool ok1,ok2;
void funq(long long ind)
{
	if(ind==n)
	{
		ok1=true;
		for(k=1;k<=m;k++)
		{
			if(ans[k]<x)
			{
				ok1=false;
			}
		}
		if(ok1==true) 
		{
			ans2=min(ans2,l);
			ok2=true;
		}
	}
	else
	{
		for(k=1;k<=m;k++)
		{
			ans[k]+=a[ind+1][k];
		}
		l+=a[ind+1][0];
		funq(ind+1);
		for(k=1;k<=m;k++)
		{
			ans[k]-=a[ind+1][k];
		}
		l-=a[ind+1][0];
		funq(ind+1);
	}
}
int main()
{
	cin>>n>>m>>x;
	for(k=1;k<=n;k++)
	{
		for(i=0;i<=m;i++)
		{
			cin>>a[k][i];
		}
	}
	funq(0);
	if(ok2==false)
	{
		cout<<"-1";
	}
	else cout<<ans2;
}

Measured memory_bytes: 3656
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int s = sc.nextInt();
        int[] arr = new int[1000000];

        int index = 0;
        int res = 0;
        while (true) {
            if (index == 0) {
                arr[index] = s;
                index++;
                continue;
            } else if(arr[index-1] % 2 == 0) {
                arr[index] = arr[index-1]/2;
            } else {
                arr[index] = 3 * arr[index-1] +1;
            }

            if (hasNum(arr, arr[index], index-1) && arr[index] != 0) {
                res = index;
                break;
            }

            index++;
        }

        System.out.println(res+1);
    }

    private static boolean hasNum(int[] arr, int key, int index) {
        boolean res = false;

        for (int i = 0; i <= index; i++) {
            if (arr[i] == key) {
                res = true;
                break;
            }
        }

        return res;
    }
}


Measured memory_bytes: 25556
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n;
	ll d;
	cin >> n >> d;
	int ret = 0;
	while(n--){
		ll a, b;
		cin >> a >> b;
		double long dist = sqrt((a*a) + (b*b));
		if(dist <= d){
			ret++;
		}
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 3668
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdlib>

using namespace std;  //このネームスペースを使う

int main(){
  int N,T ;
  int i;
  int num,min;
  cin >> N >> T ;

  int c[N];
  int t[N];
 

  for(i=0;i<N;i++){
  	cin >> c[i] >> t[i];
  }

  num=-1;
  min=1001;
  for(i=0;i<N;i++){
//      cout << c[i] << " " << t[i] << endl;
    if(t[i] <= T && min > c[i]){
      num = i;
      min = c[i];
      //cout << min << endl;
    }
  }

  if(num == -1){
  	cout << "TLE" << endl;
  }
  else{
  	cout << min << endl ;
  }

  
  return 0;
}



Measured memory_bytes: 256
n=int(input())
l=list(map(int,input().split()))
ans=0
for x in range(n-2):
    for y in range(x+1,n-1):
        for z in range(y+1,n):
            if not (l[x]==l[y] or l[y]==l[z] or l[x]==l[z]):
                p=sorted([l[x],l[y],l[z]])
                if p[0]+p[1]>p[2]:
                    ans+=1
print(ans)


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

int main(){
    ll A, B, Q;
    cin >> A >> B >> Q;
    vector<ll> s(A+2), t(B+2);
    s[0] = -1e18; s[A+1] = 1e18;
    t[0] = -1e18; t[B+1] = 1e18;
    rep(i, 1, A+1) cin >> s[i];
    rep(i, 1, B+1) cin >> t[i];
    rep(q, 0, Q){
        ll x; cin >> x;
        auto jin = lower_bound(s.begin(), s.end(), x);
        auto ter = lower_bound(t.begin(), t.end(), x);
        ll ans = max(*jin, *ter) - x;
        ans = min(ans, x - min(*(jin-1), *(ter-1)));
        ans = min(ans, 2 * min(x - *(jin-1), *ter - x) + max(x - *(jin-1), *ter - x));
        ans = min(ans, 2 * min(x - *(ter-1), *jin - x) + max(x - *(ter-1), *jin - x));
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 2944
#include<cstdio>
#define ll long long
using namespace std;

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

int main() {
	ll k = 0; ll ans = 0;
	scanf("%lld", &k);
	for (ll x = 1; x <= k; x++) {
		for (ll y = 1; y <= k; y++) {
			for (ll z = 1; z <= k; z++) {
				ans = ans + gcd(x, gcd(y, z));
			}
		}
	}
	printf("%lld", ans); return 0;
}

Measured memory_bytes: 3232
// Problem : B - Homework
// Contest : AtCoder - AtCoder Beginner Contest 163
// URL : https://atcoder.jp/contests/abc163/tasks/abc163_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

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

#define ll long long
#define endl "\n"
#define lb "lower_bound"
#define ub "upper_bound"
#define bs "binary_search"

int dif(int a,int b){if(a > b)return a - b;else return b - a;}
int min(int a,int b){if(a > b)return b;else return a;}
int max(int a,int b){if(a > b)return a;else return b;}
int gcd(int a,int b){if(a == 0)return b;else return (a%b,b);}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL),cout.tie(NULL);
    int n,m;
    cin>>n>>m;
    int arr[m],sum = 0;
    for(int i = 0;i < m;i++)
    {
    	cin>>arr[i];
    	sum += arr[i];
    }
    if(n >= sum)
    cout<<n - sum;
    else cout<<-1;
	return 0;
}


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

using namespace std;

int main(int argc, const char *argv[]) {
  int h, w;
  cin >> h >> w;

  vector<string> va(h);
  vector<bool> vr(h, false), vc(w, false);
  for (int i = 0; i < h; ++i) {
    cin >> va[i];
  }

  for (int i = 0; i < h; ++i) {
    bool skip = true;
    for (int j = 0; j < w; ++j) {
      if (va[i][j] == '#') {
        skip = false;
        break;
      }
    }

    vr[i] = skip;
  }

  for (int i = 0; i < w; ++i) {
    bool skip = true;
    for (int j = 0; j < h; ++j) {
      if (va[j][i] == '#') {
        skip = false;
        break;
      }
    }

    vc[i] = skip;
  }

  for (int i = 0; i < h; ++i) {
    if (vr[i]) {
      continue;
    }

    for (int j = 0; j < w; ++j) {
      if (!vc[j]) {
        cout << va[i][j];
      }
    }

    cout << '\n';
  }
  return 0;
}

Measured memory_bytes: 3604
#include<iostream>
using namespace std;
int main(){
    while(1){
        int N,n,suma=0,sumb=0,x,y;
        cin >> N;
        if(N==0)    break;
        n=N;
        while(n--){
            cin >> x >> y;
            if(x>y) suma=suma+x+y;
            else if(x == y) {
                suma+=x;
                sumb+=y;
            }
            else    sumb=sumb+x+y;
        }
        cout << suma << " " << sumb << "\n";
    }
    return 0;
}

Measured memory_bytes: 3076
#include<iostream>
#include<string>

using namespace std;

int main(){
    int N;
    cin >> N;
    long a[N];
    for(int i =0; i < N; i++)scanf("%ld", &a[i]);

    int count[N];
    for(int i = 0; i < N; i++)count[i] = 0;


    int rid = N; 
    for(int i = 0; i < N; i++){
        if(a[i] > N)continue;
        if(++count[a[i] -1] >= a[i]){
            rid -= a[i];
            count[a[i] - 1] = -1*(N+1);
         }
    }

    cout << rid << endl;

}

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

int main() {
    int n;
    cin >> n;
    long long ans, x, y;
    vector<int> a(n);
    vector<long long> s(n+1);
    s[0]=0;
    for(int i=0; i<n; i++) {
        cin >> a[i];
        s[i+1]=s[i]+a[i];
    }
    for(int i=1; i<n; i++) {
        x=s[i];
        y=s[n]-s[i];
        if(i==1) ans=abs(x-y);
        else ans=min(ans, abs(x-y));
    }
    cout << ans;
}

Measured memory_bytes: 2560
max = 1_000_000
table = Array.new(max, true)
2.upto(max - 1){|i|
    count = 2
    until i * count >= max
        table[i * count] = false
        count += 1
    end
}
n_primes = Array.new(max, 0)
count = 0
2.upto(max - 1){|i|
    count += 1 if table[i]
    n_primes[i] = count
}

while n = gets
    n = n.to_i
    puts n_primes[n]
end

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

int main()
{
  int n, m;
  cin >> n;
  map<char, int> mp;
  char c;
  rep(i, n){
    cin >> c;
    mp[c]++;
  }
  cout << (mp.size() == 3 ? "Three" : "Four") << endl;
  return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <vector>
using namespace std;

int main() {
  int N, H, W;
  cin >> N >> H >> W;
  vector<int> D(N*W+1);
  for(int i = 0; i < N; ++i){
    int x;
    cin >> x;
    if(i%2){
      ++D[i*W-x];
      --D[i*W-x+W];
    }else{
      ++D[i*W+x];
      --D[i*W+x+W];
    }
  }
  // for(auto d : D)
  //   cerr << d << " ";
  // cerr << endl;
  long long ans = 0;
  for(int i = 0; i < N*W; ++i){
    D[i+1] += D[i];
    if(!D[i]) ++ans;
  }
  ans *= H;
  cout << ans << endl;
}



Measured memory_bytes: 3128
import java.util.*;
 
public class Main{
 
	public static void main(String[] args) {
		Scanner sc= new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		int c=sc.nextInt();
		if(c==a+b||a==b+c||b==a+c) System.out.println("Yes");
		else					   System.out.println("No");
		
	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <bitset>
#include <cstdio>
#include <set>
#include <stack>
#include <queue>
#include <cassert>
//#include <bits/stdc++.h>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define vi vector<int>
#define vii vector<vector<int>>
#define mii map<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
#define ALL(a)  (a).begin(),(a).end()

typedef long long ll;

//const int MOD = 1000000007;
//const int INF = 1<<30;
using namespace std;

string yn(bool x){
    return x ? "Yes" : "No";
}


int main(){
    ll n,k; cin >> n >> k;
    
    map<ll,ll> m;
    
    rep(i,n){
        int x,y; scanf("%d %d",&x,&y);//cin >> x >> y;
        m[x] += y;
    }
    
    
    ll ans = 0;
    int i = 1;
    while(1){
        ans += m[i];
        if(ans>=k){
            cout << i << endl;
            break;
        }
        i++;
    }
    
    /*
    for(ll ans = 1 ; ans<=100000 ; ans++){
        if(k <= m[ans]){
            cout << ans << endl;
            break;
        }
        
        k -= m[ans];
    }
     */
}














Measured memory_bytes: 6528
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>

using namespace std;

int main() {
long long int a, b, c;
scanf("%lld %lld %lld", &a, &b, &c);
if(a+b>=c)
    printf("No");
else if((4*a*b)>=(c-a-b)*(c-a-b))
    printf("No");
else
    printf("Yes");

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>
#include <numeric>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using ll = long long int;
using ul = unsigned long long int;
const ll LL_MAX (1LL<<60);
const ll MOD (1000000007);

#define rep(i,s,e) for(ll i=(s); i<(e); i++) 

using namespace std;

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

    ll n, q;
    cin >> n >> q;

    queue<pair<string, ll>> a;    
    rep(i,0,n)
    {
        string s;
        ll t;
        cin >> s >> t;
        a.emplace(s, t);
    }
  
    vector<pair<string, ll>> res; 
    ll tm(0);
    while (a.size()) 
    {
        pair<string, ll> p = a.front(); a.pop();
        if (p.second <= q)
        {
            tm += p.second;
            res.emplace_back(p.first, tm);
        }
        else
        {
            p.second -= q;
            tm += q;
            a.emplace(p);
        }
    }

    for (auto i: res)
        cout << i.first << ' ' << i.second << endl;

    return 0;
}



Measured memory_bytes: 7040
#include<stdio.h>

int main(void){
  double a,b,k,jug_k;
  int out_k;
  scanf("%lf",&a);
  scanf("%lf",&b);
  k = (a+b)/2;
  out_k = k;
  jug_k = k - out_k;
  if(jug_k == 0){
  	printf("%d",out_k);
  }else{
  	printf("IMPOSSIBLE");
  }
  return 0;
}

Measured memory_bytes: 128
#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;
}

#define IOS ios::sync_with_stdio(false), cin.tie(nullptr)
#define FOR(i, a, b) for (int i = (a); i < (int)(b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greater<int>()
#define MAX(a) *max_element(all(a))

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vc = vector<char>;
using vs = vector<string>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vvi;

const int INF = 1001001001;
const int MOD = 1000000007;
const long long INFL = (1LL << 60);
const double EPS = 1e-9;

int main() {
  IOS;
  constexpr char endl = '\n';

  int N;
  cin >> N;
  ll sum = 0;
  rep(i, N + 1) {
    if (i % 3 && i % 5) sum += i;
  }

  cout << sum << endl;
}

Measured memory_bytes: 3636
N, T = map(int, input().split())
A = list(map(int, input().split()))
B = A[::-1]
C = []

maxv = 0
for i in range(N):
    if maxv > B[i]:
        C.append(maxv)
    else:
        maxv = B[i]
        C.append(maxv)

C = C[::-1]

ans = 0
maxv = 0
for i in range(N-1):
    z = C[i] - A[i]
    if maxv > z:
        continue
    elif maxv < z:
        maxv = z
        ans = 1
    else:
        ans += 1

print(ans)



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

int main(){
    string s,t;
    cin>>s>>t;
    sort(s.begin(),s.end());
    sort(t.begin(),t.end());
    reverse(t.begin(),t.end());
    if(s<t) cout<<"Yes";
    else cout<<"No";
}

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

namespace Painting_problem
{
    class Program
    {
        static int height = 0;
        static int width = 0;
        static int[,] datas = new int[51, 51];
        static void Main(string[] args)
        {
            String input = Console.ReadLine();
            try
            {
                height = Int32.Parse(input.Split(' ')[0]);
                width = Int32.Parse(input.Split(' ')[1]);
            
                for (int i = 0; i < height; i++)
                {
                    input = Console.ReadLine();
                    for (int j = 0; j < width; j++)
                    {
                        if (input[j].Equals('#'))
                        {
                            datas[i, j] = 1;
                        }
                    }
                }
            }
            catch (Exception)
            {
                Console.WriteLine("形式エラー");
                Console.ReadLine();
                return;
            }
            bool result = true;
            //Paint
            for (int i = 0; i < height; i++)
            {
                for (int j = 0; j < width; j++)
                {
                    if (!PaintOut(i, j))
                    {
                        result = false;
                        break;
                    }
                }
            }
            Console.WriteLine(result ? "Yes" : "No");
            Console.ReadLine();
        }

        static Boolean PaintOut(int x, int y)
        {
            if (datas[x,y] == 1)
            {
                bool isSuccess = false;
                if (x > 0)
                {
                    isSuccess = isSuccess || datas[x - 1, y] != 0;
                }
                if (y > 0)
                {
                    isSuccess = isSuccess || datas[x, y - 1] != 0;
                }
                isSuccess = isSuccess || datas[x + 1, y] != 0;
                isSuccess = isSuccess || datas[x, y + 1] != 0;
                if (isSuccess)
                {
                    datas[x, y] = 2;
                }
                return isSuccess;
            }
            return true;
        }
    }
}


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

int Area(int V,int W){
    return V*W;
}
int Length(int V,int W){
    return 2*(V+W);
}
int main(){
    int V,W;
    cin>>V>>W;
    cout<<Area(V,W)<<' '<<Length(V,W)<<'\n';
    return 0;

}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
const long long INF = 1e15;

int main(){
    ll n;
    cin >> n;
    ll ans = mod;
    for(ll i = 1; i*i <= n; i++){
        if(n%i == 0){
            ll a = to_string(n/i).size();
            ll b = to_string(i).size();
            ans = min(ans,max(a,b));
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3772
i = 0
chara1 = input()
chara1_list = list(chara1)
chara2 = input()
chara2_list = list(chara2)
if chara1_list[0] == chara2_list[0]:
    i += 1
if chara1_list[1] == chara2_list[1]:
    i += 1
if chara1_list[2] == chara2_list[2]:
    i += 1
print(i)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define REP(i, m, n) for(int i = m; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define dup(x, y) (((x) + (y)-1) / (y)) //整数型のまま切り上げ演算する
#define PI 3.14159265359
typedef long long LL;
template <class T> inline void chmax(T &a, T b) {
    if(a < b) {
        a = b;
    }
}
template <class T> inline void chmin(T &a, T b) {
    if(a > b) {
        a = b;
    }
}
template <class T> inline T gcd(T x, T y) {
    if(y == 0) {
        return x;
    } else if(x == 0) {
        return y;
    }
    return gcd(y, x % y);
}
template <class T> inline T lcm(T x, T y) { return (x * y) / gcd(x, y); }
template <class T> inline void print_vector(vector<T> vec) {
    for(int i = 0; i < vec.size(); i++) {
        cout << vec[i] << " ";
    }
    cout << endl;
}
const LL MOD = 1e9 + 7;
const LL LLINF = 1LL << 60;
const int INF = 1 << 30;

#define N_MAX 100001

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

    vector<int> a(N);
    rep(i, N) cin >> a[i];

    if(N == 1) {
        cout << 1 << endl;
        return 0;
    } else if(N == 2) {
        int ans = abs(a[0] - a[1]) <= 2 ? 2 : 1;
        cout << ans << endl;
        return 0;
    }

    vector<int> count(N_MAX);
    rep(i, N) count[a[i]]++;

    // 012の和,123の和・・・
    vector<int> shakutori(N_MAX);
    shakutori[0] = count[0] + count[1] + count[2];
    for(int i = 1; i < N_MAX - 2; i++) {
        shakutori[i] = shakutori[i - 1] + count[i + 2] - count[i - 1];
    }

    cout << *max_element(ALL(shakutori)) << endl;
    return 0;
}


Measured memory_bytes: 1408
N, W = [int(x) for x in input().split()]
v = [0] * N;  w = [0] * N;
for i in range(N):
    v[i], w[i] = [int(x) for x in input().split()]

dp = [0] * (W + 1)
for i in range(0, N):
    for j in range(W, 0, -1):
        if w[i] <= j:
            dp[j] = max(dp[j], v[i] + dp[j - w[i]])
print(dp[W])


Measured memory_bytes: 5720
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner in = new Scanner(System.in);
		int a = in.nextInt();
		int b = in.nextInt();
		int c = in.nextInt();

		int max = Math.max(Math.max(a, b), c);

		if (max == a) {
			System.out.println(10 * a + b + c);
		} else if (max == b) {
			System.out.println(10 * b + a + c);

		} else {
			System.out.print(10 * c + a + b);
		}

	}

}

Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<char,char> pcc;
typedef pair<char,int> pci;
typedef vector<pair<int,int>> vpii;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
#define sci(a) scanf("%d",&a)
#define scii(a,b) scanf("%d %d",&a,&b)
#define sciii(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define sciiii(a,b,c,d) scanf("%d%d%d%d",&a,&b,&c,&d)
#define scl(a) scanf("%lld",&a)
#define scll(a,b) scanf("%lld %lld",&a,&b)
#define sclll(a,b,c) scanf("%lld %lld %lld",&a,&b,&c
#define scllll(a,b,c,d) scanf("%lld %lld %lld %lld",&a,&b,&c,&d)
#define print(a) printf("%d ",a)
#define println(a) printf("%d\n",a)
#define ln printf("\n")
#define pb(a) push_back(a)
#define m_p(a,b) make_pair(a,b)
#define all(a) a.begin(),a.end()
#define rep(i,s,n) for(int i=s;i<=n;i++)
#define rrep(i,e,s) for(int i=e;i>=s;i--)
#define repv(i,m) for(auto i = m.begin();i != m.end();i++)
#define FileIO freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
const long long INF = 4000000000000000000LL;
/************************************* Chocolate *************************************/
const int mod = 1000000007;
int main(){
    int h,w;
    scii(h,w);
    vs grid(h);
    rep(i,0,h-1){
        cin >> grid[i];
    }
    vvi dp(h,vi(w,0));
    dp[0][0] = 1;
    rep(i,0,h-1){
        rep(j,0,w-1){
            if(grid[i][j] == '#') continue;
            if(i < h-1) dp[i+1][j] = (dp[i+1][j] + dp[i][j])%mod;
            if(j < w-1) dp[i][j+1] = (dp[i][j+1] + dp[i][j])%mod;
        }
    }
    cout << dp[h-1][w-1] << endl;

}

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

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

  unordered_map<char, vector<int>> smap;

  for (int i = 0; i < s.length(); i++)
  {
    smap[s[i]].push_back(i + 1);
  }

  for (int i = 0; i < t.length(); i++)
  {
    if (smap.find(t[i]) == smap.end()) {
      cout << -1 << endl;
      return 0;
    }
  }

  int loop = 0;
  int now = 0;
  for (int i = 0; i < t.length(); i++)
  {
    auto it = upper_bound(smap[t[i]].begin(), smap[t[i]].end(), now);
    if (it == smap[t[i]].end()) {
      loop++;
      now = smap[t[i]][0];
    }
    else {
      now = *it;
    }
  }

  long long ans = (long long)loop * s.length() + now;

  cout << ans << endl;
}

Measured memory_bytes: 1216
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n = read::<usize>();
    let m = read::<usize>();
    let mut xs = vec![0; m];
    for i in 0..m {
        xs[i] = read::<i64>();
    }
    xs.sort();
    let mut ans = 0;
    let mut ds = vec![0; m - 1];
    for i in 0..(m - 1) {
        ds[i] = xs[i + 1] - xs[i];
        ans += ds[i];
    }
    ds.sort();
    ds.reverse();
    for i in 0..std::cmp::min(ds.len(), n - 1) {
        ans -= ds[i];
    }
    println!("{}", ans);
}


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

int cnt;

void insertionSort(int* a,int n,int g){
    int v,j;
    for(int i=g;i<n;i++){
        v=a[i];
        j=i-g;
        while(j>=0&&a[j]>v){
            a[j+g]=a[j];
            j=j-g;
            cnt++;
        }
        a[j+g]=v;
    }
}

void shellSort(int* a,int n){
    cnt=0;
    int m=0;
    int* g=(int*)malloc(sizeof(int)*n);
    
    for(int j=1;;){
    	if(j>n)break;
    	g[m]=j;
    	m++;
    	j=3*j+1;
    }
	
	printf("%d\n",m);
	for(int i=m-1;i>=0;i--){
		printf("%d",g[i]);
		if(i!=0)printf(" ");
	}
    printf("\n");
    
    for(int i=m-1;i>=0;i--){
        insertionSort(a,n,g[i]);
    }
    free(g);
}

int main(void){
    int n;
    cnt=0;
    
    scanf("%d",&n);
    
    int* a=(int*)malloc(sizeof(int)*n);
    
    for(int i=0;i<n;i++){
        scanf("%d",a+i);
    }
    
    shellSort(a,n);
    printf("%d\n",cnt);
    for(int i=0;i<n;i++)printf("%d\n",a[i]);
    
    free(a);
}




Measured memory_bytes: 5472
#include<bits/stdc++.h>
using namespace std;
int dp[1000];

int main()
{
	int a[100],b[100];
	int n,m,x,y;
	cin>>n>>m>>x>>y;
	for(int i=0;i<n;i++)
		cin>>a[i];
	for(int i=0;i<m;i++)
		cin>>b[i];
	sort(a,a+n);
	sort(b,b+m);
	
	if(a[n-1]<b[0]&&b[0]>x&&b[0]<=y)
		cout<<"No War"<<endl;
	else cout<<"War"<<endl;
	return 0;
}

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

#define nl '\n'

using namespace std;

typedef long long ll;

void solve() {
  int N, K;
  cin >> N >> K;
  vector<int> L(K), R(K);
  for (int i = 0; i < K; i++)
    cin >> L[i] >> R[i];
  const int MOD = 998244353;

  vector<int> dp(N + 1);
  dp[1] = 1, dp[2] = -1;
  for (int i = 1; i <= N; i++) {
    dp[i] = ((dp[i] + dp[i - 1]) % MOD + MOD) % MOD;
    for (int j = 0; j < K; j++) {
      if (i + L[j] <= N)
        dp[i + L[j]] = ((dp[i + L[j]] + dp[i]) % MOD + MOD) % MOD;
      if (i + R[j] + 1 <= N)
        dp[i + R[j] + 1] = ((dp[i + R[j] + 1] - dp[i]) % MOD + MOD) % MOD;
    }
  }

  cout << dp[N];
}

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

  // int t;
  // cin >> t;
  // while (t--) {
  solve();
  cout << nl;
  // }

  return 0;
}

Measured memory_bytes: 3972
#include <bits/stdc++.h>
typedef long long ll;
#define ALL(l)  (l).begin(),(l).end()
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
using namespace std;

//const ll mod =  1000000007;
//const ll maxn = 1000000000;

//---------------------------------------------------------------------------------------------------
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vll = vector<ll>; // intの1次元の型に vi という別名をつける
using vvll = vector<vll>; // intの2次元の型に vvi という別名をつける
using vs = vector<string>; // stringの1次元の型に vs という別名をつける
using pll = pair<ll, ll>; // これ以降 pii という型名はpair<ll, ll> と同じ意味で使える
//---------------------------------------------------------------------------------------------------


int main() {
   ll ans=0,n,nr=0;
   cin>>n;
   vi a(n);
   rep(i,n){
       char s;
       cin>>s;
       if(s=='W')a.at(i)=0;
       else{
            a.at(i)=1;
            nr++;
       }
   }
   rep(i,nr){
       if(a.at(i)==0)ans++;
   }
   cout<<ans<<endl;
}



Measured memory_bytes: 4052
N = int(input())
inputs = [int(input()) for i in range(N)]
 
points = [int(s) for s in inputs]
 
get_point = sum(points)
non_10 = [x for x in points if (x % 10 != 0)]
 
if get_point % 10 != 0:
    print(get_point)
elif non_10 == []:
    print(0)
else:
    print(get_point - min(non_10))

Measured memory_bytes: 3064
<?php
  $inp = explode(' ', fgets(STDIN));

  for ($i = 0; $i < 3; $i++) {
    $inp[$i] = intval($inp[$i]);
  }
  if ($inp[0] === 0) {
    return print("0\n");
  }

  $sum = $inp[1] + $inp[2];
  $quot = intval($inp[0] / $sum) * $inp[1];
  $sur = $inp[0] % $sum;

  if ($inp[1] < $sur) {
    $quot += $inp[1];
  } else {
    $quot += $sur;
  }

  printf("%s\n", $quot);

?>

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> s(m);

  for (int i = 0; i < m; ++i) {
    int k;
    cin >> k;
    for (int j = 0; j < k; ++j) {
      int l;
      cin >> l;
      l--;
      s[i].push_back(l);
    }
  }

  vector<int> p(m);
  for (int i = 0; i < m; ++i) cin >> p[i];

  int ans = 0;
  for (int i = 0; i < (1 << n); ++i) {
    bool flg = true;
    for (int j = 0; j < m; ++j) {
      int cnt = 0;
      for (auto x : s[j])
        if (i & (1 << x)) cnt++;
      if (cnt % 2 != p[j]) flg = false;
    }
    if (flg) ans++;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
sx,sy,tx,ty = list(map(int,input().split()))

ans = ""
for i in range(tx-sx):
    ans += "R"
for i in range(ty-sy):
    ans += "U"
for i in range(tx-sx):
    ans += "L"
for i in range(ty-sy):
    ans += "D"
ans += "D"
for i in range(tx-sx+1):
    ans += "R"
for i in range(ty-sy+1):
    ans += "U"
ans += "L"
ans += "U"
for i in range(tx-sx+1):
    ans += "L"
for i in range(ty-sy+1):
    ans += "D"
ans += "R"
print(ans)


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

int main() {
  ll n; cin >> n;
  map<ll, ll> mp;
  rep(i, n) {
    ll a; cin >> a;
    mp[a]++;
  }
  ll sum = 0;
  for (auto p : mp) {
    sum += p.first * p.second;
  }
  ll q; cin >> q;
  rep(i, q) {
    ll b, c; cin >> b >> c;
    sum -= b * mp[b];
    sum += c * mp[b];
    mp[c] += mp[b];
    mp[b] = 0;
    cout << sum << endl;
  }
  return 0;
}

Measured memory_bytes: 9548
import java.util.Scanner;
 
public class Main {
 
	public static void main(String[] args){
		try(Scanner scan = new Scanner(System.in)){
			String S = scan.nextLine();
			
			int max = (int) Math.pow(2,S.length()-1);
			long ans = 0;
			
			for(int bit = 0; bit<max; bit++){
				int left = 0;
				for(int i = 0; i < S.length()-1; i++){
					if( ((bit >> i) & 1) > 0){
						ans += Long.valueOf(S.substring(left, i+1));
						left = i+1;
					}
				}
				ans+=Long.valueOf(S.substring(left, S.length()));
			}
			
			System.out.println(ans);
		}
	}
}


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

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

Measured memory_bytes: 256
def len(x, y)
    Math.sqrt(x**2.0 + y**2.0)
end 

p0x, p0y, p1x, p1y = gets.chomp.split(' ').map &:to_f
vx0 = p1x - p0x
vy0 = p1y - p0y
lv0 = len(vx0, vy0)
nvx0 = vx0 / lv0
nvy0 = vy0 / lv0
n = gets.chomp.to_i
n.times do
    x, y = gets.chomp.split(' ').map &:to_f
    vx = x - p0x
    vy = y - p0y
    lv = len(vx, vy)
    
    c = (vx0 * vx + vy0 * vy) / (lv * lv0)
    l = lv * unless c.nan? then c else 1.0 end
    puts "%.10f %.10f" % [(p0x + nvx0 * l), (p0y + nvy0 * l)]
end

Measured memory_bytes: 6196
//by Himanshu Shukla
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ll long long
#define v32 vector<int>
#define v64 vector<ll>
#define s32 set<int>
#define s64 set<ll>
#define graph vector<s32>
#define p32 pair<int,int>
#define p64 pair<ll,ll>
#define fi first
#define se second
#define ln '\n'
#define debug(x) cout << (#x) << ": " << (x) << ln
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline ll add(ll a, ll b, ll m) { return (((a % m + b % m) % m + m) % m); }
inline ll mul(ll a, ll b, ll m) { return (((a % m * b % m) % m + m) % m); }
const double EPS = 1e-6;
const ll MOD = 1e9 + 7;
template <typename T, typename U>
ostream& operator<<(ostream& out, const pair<T,U>& p){
	out << '[' << p.fi << ", " << p.se << ']';
	return out;
}
template <template <typename, typename...> class ContainerType, typename ValueType, typename ...Args>
void print_container(const ContainerType<ValueType, Args...>& c){
	cout << "{ ";
	for(const auto& v : c)
		cout << v << ' ';
	cout << '}' << ln;
}

int main()
{
	FASTIO;
	int n,m;
	cin >> n >> m;
	vector<p64> arr(n);
	for(int i = 0;i < n;i++)
		cin >> arr[i].se >> arr[i].fi;
	sort(arr.begin(),arr.end(),greater<p64>());
	set<ll> day;
	for(ll i = 0;i < m + 1;i++) day.insert(i);
	ll ans = 0;
	for(int i = 0;i < n;i++){
		ll key = m - arr[i].se;
		auto itr = day.upper_bound(key);
		if(itr == day.begin()) continue;
		itr--;
		day.erase(*itr);
		ans += arr[i].fi;
	}
	cout << ans << ln;
	return 0;
}


Measured memory_bytes: 6528
N=int(input())
BLUE=[input() for i in range(N)]
M=int(input())
RED=[input() for i in range(M)]
List=list(set(list(set(BLUE))+list(set(RED))))
ans=0
for s in List:
  p=BLUE.count(s)
  m=RED.count(s)
  ans=max(ans,p-m)
print(ans)

Measured memory_bytes: 3064
h, w, k = gets.split.map(&:to_i)
c = Array.new(h){gets.chomp.split("").map{|i| i.chomp == ?. ? 1 : 0}}
ans = 0

(2 ** h).times{|i|
	bi = []
	h.times{|it| bi << it if i[it] == 1}
	(2 ** w).times{|j|
		bj = []
		w.times{|jt| bj << jt if j[jt] == 1}
		ans += 1 if c.map{|l|l.values_at(*bj)}.values_at(*bi).flatten.count(0) == k
	}
}
puts ans

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

#define rep(i,start,n) for(int i=start;i<(int)(n);i++)
#define rrep(i,end,n) for(int i=n-1;i>=end;i--)
#define each(it,v) for(auto it : v)
#define all(v) (v).begin(),(v).end()

using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using Pii = pair<int,int>;
using Pll = pair<ll,ll>;
using vpii = vector<Pii>;
using vpll = vector<Pll>;

const ll mod=1e9+7;
const int intINF=INT_MAX;
const ll  longINF=LONG_LONG_MAX;

main()
{
        int n; cin>>n;
        vi a,b(n);
        rep(i,0,n)
        {
                cin>>b[i];
                if(b[i]>i+1)
                {
                        cout<<-1<<endl;
                        return 0;
                }
        }

        vi ans;
        bool f;
        while(b.size()>0)
        {
                f=false;
                rrep(i,0,b.size())
                {
                        if(b[i]==i+1)
                        {
                                ans.push_back(b[i]);
                                b.erase(b.begin()+i);
                                f=true;
                                break;
                        }
                }
                if(!f)
                {
                        cout<<-1<<endl;
                        return 0;
                }
                //each(it,b)cout<<it<<" ";
                //cout<<endl;
        }

        reverse(all(ans));

        each(it,ans)cout<<it<<endl;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
mod = 10 ** 9 + 7
max_n = 2050
comb = [[0] * max_n for i in range(max_n)]
for i in range(max_n):
    comb[i][1] = i
    comb[i][i] = 1
    comb[i][0] = 1
for i in range(1, max_n):
    for j in range(1, i):
        comb[i][j] = (comb[i-1][j] + comb[i-1][j-1]) % mod
for i in range(1, k+1):
    ans = comb[k-1][i-1]
    ans = (ans * comb[n-k+1][i]) % mod
    print(ans)


Measured memory_bytes: 108692
#include<bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = 0; i < (n); i++)
 
int main() {
    string S;
    cin >> S;
    if(S.length()%2 == 1){
            cout << "No" << endl;
            return 0 ;
    }
    for(int i=0;i<S.length();i+=2){
        if(!(S[i] == 'h' && S[i+1] == 'i')){
            cout << "No" << endl;
            return 0 ;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
					
					#define F first
					#define S second
					#define N 222222
					#define M 1000000007
					#define pb push_back
					#define cend(s) return cout << s, 0
					using namespace std;
					typedef long long ll;
					typedef vector<int> vi;
					
					int main()
					{
						int n;
						cin >> n;
						if(n >= 30)
							cout << "Yes";
						else cout << "No";	
					}

Measured memory_bytes: 3628
A, B = map(int,input().split())
num = B / A
i = 0
if B == 1:
  print(int(0))
else:
  while True:
    if B == 1:
        print(0)
        break
    if A * i - (i - 1) >= B:
        print(i)
        break
    i += 1
    

Measured memory_bytes: 9044
#include <bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;

typedef long long ll;
const ll mod=1e9+7;
const int nax=1e5+10;

int par[nax];

inline int root(int v){return par[v] < 0 ? v : (par[v] = root(par[v]));}

inline int merge(int x,int y){
    if((x = root(x)) == (y = root(y))) return 0 ;
	if(par[y] < par[x])	swap(x, y);
	par[x] += par[y];
	par[y] = x;
	return 1;
}

int main(){
	FIO;
	ll n,m;
	cin>>n>>m;
	pair<int,int>a[m];
	for (int i = 0; i < nax; ++i) par[i]=-1;
	for (int i = 0; i < m; ++i) cin>>a[i].first>>a[i].second;
	ll ans[m],tot=(n*(n-1))/2;
	for(int i=m-1;i>=0;--i){
		ans[i]=tot;
		ll x=root(a[i].first),y=root(a[i].second);
		if(x==y) continue;
		x=-par[x],y=-par[y],tot-=x*y,merge(a[i].first,a[i].second);
	}
	for (int i = 0; i < m; ++i) cout<<ans[i]<<'\n';
	return 0;
}


Measured memory_bytes: 3328
N, M = map(int, input().split())
n = [-1 for i in range(N)]

judge = True
i = 0
while i < M:
	s, c = map(int, input().split())
	if n[s-1] == -1:
		n[s-1] = c
	else:
		if c != n[s-1]:
			judge = False

	i += 1

if N != 1 and n[0] == 0:
	judge = False

if N != 1 and n[0] == -1:
	n[0] = 1
elif n[0] == -1:
	n[0] = 0

if judge:
	num = 0
	for j in n:
		if j != -1:
			num += j
		num *= 10
	print(int(num/10))
else:
	print(-1)


Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main()
{
    int n,k;
    cin>>n>>k;
    int d[k],arr[n],i,m,j;
    for(i=1;i<=n;i++)
        arr[i]=i;
    for(i=0;i<k;i++)
    {
        cin>>m;
        while(m--)
        {
            cin>>j;
            arr[j]=0;
        }
    }
    int f=0;
    for(i=1;i<=n;i++)
    {
        if(arr[i]!=0)
            f++;
    }
    cout<<f<<endl;
    return 0;
}


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

using namespace std;

int frog(vector<int>& cost){
    vector<int> dp(cost.size());
    dp[cost.size()-1]=0;
    dp[cost.size()-2]=abs(cost[cost.size()-1]-cost[cost.size()-2]);
    for(int i=cost.size()-3;i>=0;i--){
        dp[i]=min(dp[i+1]+abs(cost[i]-cost[i+1]),dp[i+2]+abs(cost[i]-cost[i+2]));
    }
    return dp[0];
}

int main(){
  int n;
  cin>>n;
  vector<int> arr(n);
  for(int i=0;i<n;i++) cin>>arr[i];
  cout<<frog(arr);
}

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

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

    vector<int> data(n);
    for (int i = 0; i < n - 1; i++){
        int boss;
        cin >> boss;
        boss--;
        data.at(boss)++;
    }

    for (int i = 0; i < n; i++){
        cout << data.at(i) << endl;
    }
}


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

int main() {
  int N;
  cin >> N;
  vector<int> bot(N);
  for(int i=0; i<N; i++){
    cin >> bot.at(i);
  }
  
  int a=0, b=0;
  for(int i=0; i<N; i++){
    a = bot.at(a) - 1;
    b++;
    //cout << a << "!" << b <<endl;
    if (a==1) {
      cout << b << endl;
      break;
    }
    if (b==N){
      cout << "-1" << endl;
      break;
    }
  }
}


Measured memory_bytes: 640
import math

order = [int(input()) for _ in range(5)]

def minus(x):
    return 0 if x == 0 else 10 - x

aaa = list(map(lambda x: math.ceil(x/10)*10, order))
bbb = list(map(lambda x: x%10,order))

print(sum(aaa) - max(map(minus,bbb)))


Measured memory_bytes: 3060
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define DEBUG(x) cerr << (#x) << ": " << (x) << endl
#define DEBUG_VEC(v)            \
    cerr << #v << ": ";         \
    REP(__i, (v).size())        \
    cerr << ((v)[__i]) << ", "; \
    cerr << endl

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

int main()
{
    ios::sync_with_stdio(false);
    int N, A, B;
    cin >> N >> A >> B;

    cout << min(N * A, B) << endl;
    
    return 0;
}


Measured memory_bytes: 256
def solve():
    N = int(input())
    A = list(map(int, input().split()))
    ans = 'YES'
    c = 0
    for i, a in enumerate(A):
        if i+1 != a:
            c += 1
    
    return 'YES' if c == 0 or c == 2 else 'NO'

print(solve())

Measured memory_bytes: 3060
import java.io.InputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;
import java.math.BigInteger;

public class Main{

static PrintWriter out;
static InputReader ir;

static void solve(){
 for(;;){
  int n=ir.nextInt();
  if(n==0) return;
  int K=ir.nextInt();
  int s=ir.nextInt();
  int[][][] dp=new int[K+1][n+1][s+1];
  for(int i=0;i<=n;i++) dp[K][i][s]=1;
  for(int i=K-1;i>=0;i--){
   for(int j=0;j<=n;j++){
    for(int k=0;k<=s;k++){
     for(int l=j+1;l<=n&&l+k<=s;l++){
      dp[i][j][k]+=dp[i+1][l][k+l];
     }
    }
   }
  }
  out.println(dp[0][0][0]);
 }
}

public static void main(String[] args) throws Exception{
 ir=new InputReader(System.in);
 out=new PrintWriter(System.out);
 solve();
 out.flush();
}

static class InputReader {
 private InputStream in;
 private byte[] buffer=new byte[1024];
 private int curbuf;
 private int lenbuf;

 public InputReader(InputStream in) {this.in=in; this.curbuf=this.lenbuf=0;}
 
 public boolean hasNextByte() {
  if(curbuf>=lenbuf){
   curbuf= 0;
   try{
    lenbuf=in.read(buffer);
   }catch(IOException e) {
    throw new InputMismatchException();
   }
   if(lenbuf<=0) return false;
  }
  return true;
 }

 private int readByte(){if(hasNextByte()) return buffer[curbuf++]; else return -1;}
 
 private boolean isSpaceChar(int c){return !(c>=33&&c<=126);}
 
 private void skip(){while(hasNextByte()&&isSpaceChar(buffer[curbuf])) curbuf++;}
 
 public boolean hasNext(){skip(); return hasNextByte();}
 
 public String next(){
  if(!hasNext()) throw new NoSuchElementException();
  StringBuilder sb=new StringBuilder();
  int b=readByte();
  while(!isSpaceChar(b)){
   sb.appendCodePoint(b);
   b=readByte();
  }
  return sb.toString();
 }
 
 public int nextInt() {
  if(!hasNext()) throw new NoSuchElementException();
  int c=readByte();
  while (isSpaceChar(c)) c=readByte();
  boolean minus=false;
  if (c=='-') {
   minus=true;
   c=readByte();
  }
  int res=0;
  do{
   if(c<'0'||c>'9') throw new InputMismatchException();
   res=res*10+c-'0';
   c=readByte();
  }while(!isSpaceChar(c));
  return (minus)?-res:res;
 }
 
 public long nextLong() {
  if(!hasNext()) throw new NoSuchElementException();
  int c=readByte();
  while (isSpaceChar(c)) c=readByte();
  boolean minus=false;
  if (c=='-') {
   minus=true;
   c=readByte();
  }
  long res = 0;
  do{
   if(c<'0'||c>'9') throw new InputMismatchException();
   res=res*10+c-'0';
   c=readByte();
  }while(!isSpaceChar(c));
  return (minus)?-res:res;
 }

 public double nextDouble(){return Double.parseDouble(next());}

 public int[] nextIntArray(int n){
  int[] a=new int[n];
  for(int i=0;i<n;i++) a[i]=nextInt();
  return a;
 }

 public long[] nextLongArray(int n){
  long[] a=new long[n];
  for(int i=0;i<n;i++) a[i]=nextLong();
  return a;
 }

 public char[][] nextCharMap(int n,int m){
  char[][] map=new char[n][m];
  for(int i=0;i<n;i++) map[i]=next().toCharArray();
  return map;
 }
}
}

Measured memory_bytes: 27928
#include <bits/stdc++.h>
using namespace std;
char sir[110];
int i,l,j;
int main()
{
    cin>>sir;
    l=strlen(sir);
    for(i=0;i<l;i++)
        if((i%2==0 && sir[i]=='L') || (i%2==1 && sir[i]=='R'))
        {
            cout<<"No";
            return 0;
        }
    cout<<"Yes";
    return 0;
}


Measured memory_bytes: 256