akhauriyash/Code-Regression huggingface dataset:
import sys
h, w, k = map(int, sys.stdin.readline().split())
graph = [list(sys.stdin.readline().rstrip()) for _ in range(h)]
ans = 10**9+1

for div in range(2**(h-1)):
    # 1. 縦で切った時のグループ数を計算する
    id = [0] * h # 各行がどのグループに属しているか記録する
    group = 0 # グループの番号
    for j in range(h):
        id[j] = group
        if (div >> j) & 1:
            group += 1
    group += 1

    # 2. グループの各行にある白チョコ数を出す
    c = [[0] * w for _ in range(group)]
    for j in range(w):
        for i in range(h):
            if graph[i][j] == '1':
                c[id[i]][j] += 1

    temp = group-1 # このdivにおける分割回数
    now = [0] * group # 探索中に各グループが持つ白チョコ数を格納

    def add(now, j):
        # 各グループへ白チョコの数を反映
        for i in range(group):
            now[i] += c[i][j]

    def judge(now):
        # 現在のグループ分けで白チョコがk個以下か判定する
        for i in range(group):
            if now[i] > k: return False
        return True

    # 3. 横方向に探索し、グループがk個を超えたら分割する
    for j in range(w):
        add(now, j)
        if not judge(now):
            # k個を超えた→分割したとしてnowを初期化
            temp += 1
            now = [0] * group

            # k個以下を満たせない場合を検出する
            add(now, j)
            if not judge(now):
                temp = 10**9 + 1
                break

    ans = min(ans, temp)

print(ans)


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

const int MAX = 1e7;
ll fac[MAX], finv[MAX], inv[MAX];

//前処理
void COMinit (){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAX; i++){
        fac[i] = fac[i-1]*i%mod;
        inv[i] = mod-inv[mod%i]*(mod/i)%mod;
        finv[i] = finv[i-1]*inv[i]%mod;
    }
}
//二項係数
ll COM(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n]*(finv[k]*finv[n-k]%mod)%mod;
}

int main(){
    int n,k;
    cin >> n >> k;
    int r = n-k;
    int b = k;
    COMinit();
    ll ans = 0;
    for(int i = 1; i <= k; i++){
        ll can = 1;
        can *= COM(n-k+1,i);
        can *= COM(k-1,i-1);
        cout << can%mod << endl;
    }   
}

Measured memory_bytes: 234624
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e9;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
int main(){
	int z;
	cin>>z;
	while(z--){
		vi in(10);
		rep(i,10){
			char c;
			cin>>c;
			if(isdigit(c))c-='0';
			else if(c=='A')c=11;
			else c=10;
			in[i]=c;
		}
		int sum=in[0]+in[1];
		int co=0;
		if(in[0]==11)co++;
		if(in[1]==11)co++;
		if(co&&sum==21){
			cout<<"blackjack"<<endl;
			continue;
		}
		if(co==2){
			co--;
			sum-=10;
		}
		loop(i,2,10){
			if(sum<17||sum==17&&co){
				sum+=in[i];
				if(in[i]==11){
					co++;
				}
				if(co&&sum>21){
					co--;
					sum-=10;
				}
			}else break;		
		}
		if(sum<22)cout<<sum<<endl;
		else cout<<"bust"<<endl;
	}
}

Measured memory_bytes: 1192
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <istream>
#include <map>
#include <set>
#define rep0(i,n) for (int i = 0; i <= (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)
#define REP(a,b) for (int i = a; i <= (b); ++i) 
using namespace std;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
//
	string s;
	int a;
	cin >> a >> s;
	if (a >= 3200)
		cout << s << endl;
	else
		cout << "red" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <set>
typedef long long ll;
using namespace std;
int main() {
    ll n; cin >> n;
    vector<ll> a;
    vector<ll> b;
    ll asum = 0;
    ll bsum = 0;
    bool straight = true;
    for (int i = 0; i < n; i++) {
        ll _a; cin >> _a;
        a.push_back(_a);
        asum += _a;
    }
    for (int i = 0; i < n; i++) {
        ll _b; cin >> _b;
        b.push_back(_b);
        bsum += _b;
        if (b[i] > a[i]) straight = false;
    }
    if (straight) {
        cout << 0 << endl;
        return 0;
    }
    if (bsum > asum) {
        cout << -1 << endl;
        return 0;
    }
    
    ll diff = 0;
    ll ans = 0;
    vector<ll> over;
    for (int i = 0; i < n; i++) {
        ll d = b[i] - a[i];
        if (d > 0) {
            diff += d;
            ans++;
        }
        if (d < 0) {
            over.push_back(-d);
        }
    }
    sort(over.begin(), over.end(), greater<ll>());
    ll i = 0;
    while (diff > 0) {
        diff -= over[i];
        ans++;
        i++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2804
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
int main (){
    string s,t;int cnt=0;
    cin>>s>>t;
    for(int i=0;i<s.size();i++){
        if (s[i]!=t[i])cnt++;
    }
    cout<<cnt;






    return 0;
}


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


int main() {
	
	int a, b, c=0;
	cin >> a >> b;
	int d = b - a;
	
	for(int i=0; i<d; i++) c += i; 
	cout << c - a << endl;
	
	return 0;
}

Measured memory_bytes: 256
mod=10**9+7
n=int(input())
l=list(map(int,input().split()))
ans=1
rgb=[0,0,0]
for i in range(n):
    c=0
    for j in range(3):
        if l[i]==rgb[j]:
            c+=1
    if c==0:
        print(0)
        exit()
    p=rgb.index(l[i])
    if not 0<=p<=2:
        print(0)
        exit()
    rgb[p]+=1
    ans*=c
    ans%=mod
print(ans)


Measured memory_bytes: 20572
#include <stdio.h>

//Istiyak Hossain

int main()
{
    int n, i, v;
    char ch ,S[13], H[13], C[13], D[13];

    for(v = 0; v < 13; v++)
    {
        S[v] = '0';
        H[v] = '0';
        C[v] = '0';
        D[v] = '0';
    }

    scanf("%d", &n);

    for(i = 1; i <= n; i++)
    {
        scanf(" %c %d", &ch, &v);
        v--;
        switch(ch)
        {
            case 'S':
                S[v] = '1';
                break;
            case 'H':
                H[v] = '1';
                break;
            case 'C':
                C[v] = '1';
                break;
            case 'D':
                D[v] = '1';
                break;
        }
    }
    for(i = 0; i < 52; i++)
    {
        if(i < 13 && S[i] == '0'){
            printf("S %d\n", i+1);
        }
        else if(i < 26 && i >= 13&& H[i-13] == '0'){
            printf("H %d\n", i-12);
        }
        else if(i < 39 && i >= 26&& C[i - 26] == '0'){
            printf("C %d\n", i - 25);
        }
        else if(i >= 39 && D[i - 39] == '0'){
            printf("D %d\n", i - 38);
        }
    }

    return 0;
}



Measured memory_bytes: 2044
import math
n,h = map(int,raw_input().split())

arra = []
arrb = []


for i in range(n):
	a , b = map(int,raw_input().split())
	arra.append(a)
	arrb.append(b)

arrb.sort()

l = len(arrb) - 1 
m = max(arra)
count = 0
while arrb[l] > m and -1 < l and h > 0:
	h = max(0,h-arrb[l])
	l -= 1
	count += 1

print count + -(h*-1 // m)



Measured memory_bytes: 12164
#include <bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
using namespace std;

int main() {
	int n;
	cin >> n;
	vector <ll> A(n);
	map <ll, ll> m;
	for (int i = 0; i < n; i++) {
		cin >> A[i];
		m[A[i]]++;
	}
	ll ans = 0;
	for (auto g : m) {
		ans += g.ss * (g.ss - 1) / 2;
	}
	for (int i = 0; i < n; i++) {
		cout << ans - m[A[i]] * (m[A[i]] - 1) / 2 + (m[A[i]] - 1) * (m[A[i]] - 2) / 2 << "\n";
	} 
}


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


bool compare_by_first(pair<int, int> a, pair<int, int> b) {
    if(a.first!=b.first) return a.first < b.first;
    else return a.second < b.second;
}

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

    vector<pair<int, int>> p(n);

    for(int i=0; i<n; i++) {
        cin >> a;
        p[i] = make_pair(a, i+1);
    }
    sort(p.begin(), p.end(), compare_by_first);

    for(int i=0; i<n; i++) {
        cout << p[i].second << ' ';
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll ZERO = 0;
const int Inf = 1e9;
const ll INF= 1e18;
const ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

int main() {
    int N;
    cin >> N;
    vector<int> vec(N);
    for(int i = 0;i < N;i++) {
        cin >> vec.at(i);
    }
    bool ret2 = true;
    vector<int> ret;
    for(int i = 0;i < N;i++) {
        bool cnt = false;
        for(int j = vec.size() - 1;j >= 0;j--) {
            if(vec.at(j) == j + 1) {
                vec.erase(vec.begin() + j);
                cnt = true;
                ret.push_back(j + 1);
                break;
            }
        }
        if(cnt == false) {
            ret2 = false;
            break;
        }
    }
    if(ret2 == false) {
        cout << -1 << endl;
    }
    else {
        reverse(ret.begin(),ret.end());
        for(int i = 0;i < N;i++) {
            cout << ret.at(i) << endl;
        }
    }
}

Measured memory_bytes: 256
import math
K = int(input())
l = []
for a in range(1, K+1):
    for b in range(1, K+1):
        l.append(math.gcd(a, b))
t = []
for x in l:
    for c in range(1, K+1):
        t.append(math.gcd(x, c))
print(sum(t))

Measured memory_bytes: 71784
from collections import Counter

n = int(input())
a = list(map(int,input().split()))
b = []
c = []
ans = 0
for i in range(n):
    b.append(i+1-a[i])
    c.append(i+1+a[i])
B = Counter(b)
for i in c:
    ans += B.get(i,0)
    
print(ans)

Measured memory_bytes: 134404
#include <stdio.h>

#define LIM 1000000000

int main (void) {
    int a, b;
    int c;
    int k;

    scanf("%d %d", &a, &b);

    if (a < b) {//aが大きい
        c = a;
        a = b;
        b = c;
    } 

    for (k = a/2; k < LIM; k++) {
        if (a-k == k-b) {
            printf("%d\n", k);
            return 0;
        }

    }
    puts("IMPOSSIBLE");

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

template <class T = int>T in(){
    T x;
    cin >> x;
    return (x);
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int N = in();
    vector<int> d(N);
    REP(i,N)d[i] = in();
    sort(ALL(d));
    cout << d[N/2] - d[N/2 -1 ] << "\n";
}

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

#define int long long

#define rep(i, n) for (int i = 0; i < (n); i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end()
#define fi first
#define se second

using vint = vector<int>;
using pint = pair<int, int>;
using vpint = vector<pint>;

template <typename A, typename B>
inline void chmin(A& a, B b) {
    if (a > b) a = b;
}
template <typename A, typename B>
inline void chmax(A& a, B b) {
    if (a < b) a = b;
}

template <class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>& p) {
    ost << "{" << p.first << "," << p.second << "}";
    return ost;
}

template <class T>
ostream& operator<<(ostream& ost, const vector<T>& v) {
    ost << "{";
    for (int i = 0; i < v.size(); i++) {
        if (i) ost << ",";
        ost << v[i];
    }
    ost << "}";
    return ost;
}

inline int topbit(unsigned long long x) {
    return x ? 63 - __builtin_clzll(x) : -1;
}

inline int popcount(unsigned long long x) {
    return __builtin_popcountll(x);
}

inline int parity(unsigned long long x) {
    return __builtin_parity(x);
}

const int INF = 1001001001;

signed main() {
    string S, T;
    cin >> S >> T;

    int ans = INF;
    for (int i = 0; i + T.size() <= S.size(); i++) {
        int cost = 0;
        rep(j, T.size()) if (S[i + j] != T[j]) cost++;
        chmin(ans, cost);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>


using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD (ll)1000000007
#define P pair<ll, ll>

ll n;
double x[110000], y[110000];
char d[110000];
const double EPS = 1e-10;

double f(double a) {
	double xmx = 1e8 * 3 * -1, xmi = 1e8 * 3, ymx = 1e8 * 3 * -1, ymi = 1e8 * 3;
	REP(i, n) {
		double nowx = x[i], nowy = y[i];
		if (d[i] == 'R') nowx += a;
		if (d[i] == 'L') nowx -= a;
		if (d[i] == 'U') nowy += a;
		if (d[i] == 'D') nowy -= a;
		xmx = max(xmx, nowx);
		xmi = min(xmi, nowx);
		ymx = max(ymx, nowy);
		ymi = min(ymi, nowy);
		//cout << nowx << " " << nowy << endl;
	}
	//cout << xmx << " " << xmi << " " << ymx << " " << ymi << endl;
	return (xmx - xmi) * (ymx - ymi);
}

int main() {
	cin >> n;
	REP(i, n) {
		cin >> x[i] >> y[i] >> d[i];
	}
	double low = 0.0, high = 1e8 * 3;
	REP(i,300) {
		double width = high - low, ml = low + width / 3.0, mr = low + 2.0 * width / 3.0;
		if (f(ml) <= f(mr)) {
			high = mr;
		}
		else {
			low = ml;
		}
	}
	//cout << (high + low) * 0.5 << endl;
	cout << setprecision(10) << fixed << f((high + low) * 0.5) << endl;
}


Measured memory_bytes: 1920
#include<stdio.h>

int main()
{
   int n, q, i, j, c=0;
   int s[10000], t[500];

   scanf("%d", &n);
   for(i=0; i<n; i++) scanf("%d", &s[i]);

   scanf("%d", &q);
   for(i=0; i<n; i++) scanf("%d", &t[i]);

   for(i=0; i<q; i++) {
      for(j=0; j<n; j++) {
         if(s[j] == t[i]) {
            c++;
            break;
         }
      }
   }
   printf("%d\n", c);

   return 0;
}

   

Measured memory_bytes: 640
#include <iostream>
#include<string>
#include<cmath>
#include<ciso646>
#include<cstring>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<utility>
#include<map>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
using ll = long long;
int Max = 10 + 1e8;
int N = 5 + 1e5;
int main()
{
	int n;
	cin >> n;
	vector<int> zbn(n);
	rep(i, n) zbn[i] = i;
	vector<int> x(n);
	vector<int> y(n);
	rep(i, n) 	cin >> x[i] >> y[i];
	long double sum = 0;
	int cnt = 0;
	do {
		rep(i, n-1) {
			double xx = (x[zbn[i+1]] - x[zbn[i]]) * (x[zbn[i+1]] - x[zbn[i]]);
			double yy = (y[zbn[i + 1]] - y[zbn[i]]) * (y[zbn[i + 1]] - y[zbn[i]]);
			sum += sqrt(xx + yy);
		}
		cnt++;
	} while (next_permutation(zbn.begin(), zbn.end()));

	cout << fixed << setprecision(8) << sum / cnt;
}

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

void solve(long long K, long long A, long long B){
    for(int i=A;i<=B;i++){
        if(i%K==0){
            cout << "OK" << endl;
            return;
        }
    }
    cout <<"NG"<<endl;

}

int main(){
    long long K;
    scanf("%lld",&K);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(K, A, B);
    return 0;
}


Measured memory_bytes: 3764
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  n=I()
  l=LI()

  al=sum(l)

  sm=0
  sa=inf
  for x in l[:-1]:
    sm+=x
    sa=min(sa,abs(sm-(al-sm)))

  return sa

print(main())


Measured memory_bytes: 27672
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define f(k,n) for(auto i =k; i<n; i++)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie();
#define test ll t; cin>>t;


int main(){
    IOS
    ll n ; 
    cin>>n; ll sum = 0;
    ll a[n];
    f(0,n){
        cin>>a[i]; sum += a[i];
    }
    ll ave = sum/n;
    ll k = 0 , g =0;
    f(0,n){
        k += (a[i] - ave)*(a[i] - ave);
    }
    f(0,n){
        g += (a[i] - (ave+1))*(a[i] - (ave+1));
    } 
    cout<<((k<g)?k:g)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;

int h, w;
char s[55][55];
int dis[55][55] = {0};
int d[4] = {0, 1, 0, -1};

int solve();

int main() {
  cin >> h >> w;
  for(int i = 0; i < h; ++i)
    for(int j = 0; j < w; ++j) cin >> s[i][j];
  cout << solve() << endl;
  return 0;
}

int solve() {
  queue<pair<int, int>> qu;
  int cnt = 0;
  for(int i = 0; i < h; ++i)
    for(int j = 0; j < w; ++j) {
      dis[i][j] = -1;
      if(s[i][j] == '.') ++cnt;
    }
  dis[0][0] = 1;
  qu.push(make_pair(0, 0));
  while(qu.size() > 0) {
    pair<int, int> now, nextp;
    now = qu.front();
    qu.pop();
    for(int i = 0; i < 4; ++i) {
      nextp = make_pair(now.fi + d[i], now.se + d[1 ^ i]);
      if(nextp.fi < 0 || nextp.fi >= h || nextp.se < 0 ||
         nextp.se >= w || s[nextp.fi][nextp.se] == '#' ||
         dis[nextp.fi][nextp.se] >= 0)
        continue;
      dis[nextp.fi][nextp.se] = dis[now.fi][now.se] + 1;
      qu.push(nextp);
    }
  }
  if(dis[h - 1][w - 1] < 0) return -1;
  return cnt - dis[h - 1][w - 1];
}

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

#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define setbits(x) __builtin_popcount(x)
#define zerobits(x) __builtin_ctz(x)
#define setbitsll(x) __builtin_popcountll(x)
#define zerobitsll(x) __builtin_ctzll(x)
#define inf 1e18
#define ps(x,y) fixed<<setprecision(y)<<x

typedef vector<int> vi;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef unsigned long long ull;
typedef map<int,int> mii;

const int MOD = 1e9+7;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n,k;
	cin >> n >> k;
	int arr[n];
	for (int i = 0;i < n;++i) {
		cin >> arr[i];
	}
	sort(arr,arr+n);
	int ans = 0;
	for (int i = 0;i < k;++i) {
		ans += arr[i];
	}
	cout << ans << '\n';
	return 0;
}



Measured memory_bytes: 3652
//#include<iostream>
//#include<algorithm>
//#include<string>
//#include <cmath>
//#include <vector>
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define REP(x,n) for(int x=0;x<n;x++)

//vector//
#define vei vector<int> 
#define velli vector<long long int> 
#define pb(x) push_back(x) // 末尾にxを加える
#define pb2 pop_back() // 末尾削除
#define all(x) (x).begin(),(x).end() //イテレーター
#define be(x) (x).begin()
//auto  auto begin = v.begin()とか

typedef pair<int,int> P;  //q(p.first,p.second)

int main (){
    int s,w;
    cin >> s >> w;

    if(w>=s){
        cout << "unsafe";
    }else{
        cout << "safe";
    }
}

Measured memory_bytes: 3644
X,n = map(int,input().split(" "))
def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)
a=Base_10_to_n(X, n)
print(len(str(a)))

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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)

signed main(){

	lli n,l;
	cin>>n>>l;

	multiset<string> s;
	REP(i,0,n){
		string v;
		cin>>v;
		s.insert(v);
	}

	for(auto &e:s){
		cout<<e;
	}
	cout<<endl;

	return 0;
}

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

#define INF 200000000
#define FER 0.0000000001

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;

ll dp[10001];
int v[100];
int w[100];

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

	int N, W;
	cin >> N >> W;

	for (int i = 0; i < N; i++)
	{
		cin >> v[i] >> w[i];
	}

	fill(dp, dp + 10001, LLONG_MAX);
	dp[0] = 0;

	for (int i = 0; i < N; i++)for (int j = 10000; j != -1; j--)
	{
		if (dp[j] < LLONG_MAX)
		{
			dp[j + v[i]] = min(dp[j + v[i]], dp[j] + w[i]);
		}
	}

	int ans;
	for (int i = 0; i <= 10000; i++)
	{
		if (dp[i] <= W)
		{
			ans = i;
		}
	}

	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 3312
using System;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        int N = int.Parse(Console.ReadLine());
        int A = int.Parse(Console.ReadLine());

        if(N % 500 <= A){
            Console.WriteLine("Yes");
        }else{
            Console.WriteLine("No");
        }
    }
}

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

using namespace std;

typedef long long int64;
const int64 INF = 1LL << 58;

int64 MinimumCost(vector< int > &A, vector< int > &B)
{
  vector< int > near(B.size());
  int tail = 0;
  for(int i = 0; i < B.size(); i++) {
    while(tail < A.size() && A[tail] < B[i]) ++tail;
    near[i] = tail;
  }
  int sz = (int) B.size() * 2 + 1;
  vector< int64 > dp(sz, 0);
  for(int i = 0; i < B.size(); i++) {
    const int diff = near[i] - (i == 0 ? 0 : near[i - 1]);
    for(int j = 0; j < sz; j++) dp[j] = dp[min(j + diff, sz - 1)];
    vector< int64 > nxt(sz, INF);
    for(int j = 0; j < sz - 1; j++) {
      const int k = near[i] - (int) B.size() + j;
      nxt[j + 1] = min(nxt[j + 1], nxt[j]);
      if(k < 0 || k >= A.size()) continue;
      nxt[j + 1] = min(nxt[j + 1], dp[j] + abs(B[i] - A[k]));
    }
    dp.swap(nxt);
  }
  if(dp.back() == INF) return (-1);
  return (dp.back());
}

int main()
{
  int N, P[4000], D[4000];

  while(scanf("%d", &N), N) {
    if(N == 2) {
      int a, b, c, d;
      cin >> a >> b >> c >> d;
      cout << abs(a - c) << endl;
      continue;
    }
    vector< int > latte, malta;
    for(int i = 0; i < N; i++) {
      scanf("%d %d", &P[i], &D[i]);
      if(D[i] == 1) latte.push_back(i);
      else malta.push_back(i);
    }

    sort(begin(latte), end(latte), [&](int a, int b) -> bool
    {
      return (P[a] < P[b]);
    });
    sort(begin(malta), end(malta), [&](int a, int b) -> bool
    {
      return (P[a] < P[b]);
    });

    for(int i = 1; i < malta.size(); i++) --D[malta[i]];
    for(int i = 0; i + 1 < malta.size(); i++) --D[malta[i]];

    vector< int > beet, vs;
    for(int i : malta) while(D[i]--) beet.push_back(P[i]);
    for(int i : latte) vs.push_back(P[i]);
    auto get = MinimumCost(beet, vs);
    if(get == -1) puts("-1");
    else printf("%lld\n", get + P[malta.back()] - P[malta.front()]);
  }
}

Measured memory_bytes: 68652
#include <iostream>
#include <string>
#include <cstring>
using namespace std;

int main() {
	int form[26], s2t[26];
	memset(form, 0xff, sizeof(form));
	memset(s2t, 0xff, sizeof(s2t));
	string s, t;
	cin>>s>>t;
	for (int i=0; i<s.size(); i++) {
		if (form[t[i]-'a'] == -1)
			form[t[i]-'a'] = s[i];
		if (s2t[s[i]-'a'] == -1)
			s2t[s[i]-'a'] = t[i];
		if (form[t[i]-'a'] != s[i] || s2t[s[i]-'a'] != t[i]) {
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}


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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int xh,xm,yh,ym,k;
	cin>>xh>>xm>>yh>>ym>>k;
	int mmm=60*(yh-xh)+(ym-xm)-k;
	if(mmm<0)mmm=0;
	cout<<mmm<<endl;
	return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    ll H, W;
    cin >> H >> W;
    ll ans = 1LL << 60;
    rep(i, 1, H){
        ll one = i * W;
        ll h = H - i;
        ll w = W;
        ll two, three;
        if(h % 2 == 0 || w % 2 == 0){
            two = three = h * w / 2;
        }
        else{
            if(h > w) swap(h, w);
            two = h * (w / 2);
            three = h * (w / 2 + 1);
        }
        ll ma = max({one, two, three});
        ll mi = min({one, two, three});
        ans = min(ans, ma - mi);
    }
    swap(H, W);
    rep(i, 1, H){
        ll one = i * W;
        ll h = H - i;
        ll w = W;
        ll two, three;
        if(h % 2 == 0 || w % 2 == 0){
            two = three = h * w / 2;
        }
        else{
            if(h > w) swap(h, w);
            two = h * (w / 2);
            three = h * (w / 2 + 1);
        }
        ll ma = max({one, two, three});
        ll mi = min({one, two, three});
        ans = min(ans, ma - mi);
    }
    output(ans);
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
 
int main(){
 
    int n, v;
    cin >> n;
 
    vector<int> even(1e5+1, 0), odd(1e5+1, 0);
    for(int i = 0; i < n / 2; i++){
        cin >> v;
        even[v]++;
        cin >> v;
        odd[v]++;
    }
 
    vector<pair<int, int> > even_pair, odd_pair; // pair(count, index)
    for(int i = 1; i <= 1e5; i++){
        even_pair.push_back(make_pair(even[i], i));
        odd_pair.push_back(make_pair(odd[i], i));
    }
 
    sort(even_pair.rbegin(), even_pair.rend());
    sort(odd_pair.rbegin(), odd_pair.rend());
 
    if(even_pair[0].second != odd_pair[0].second) cout << n - (even_pair[0].first + odd_pair[0].first) << endl;
    else cout << n - max(even_pair[0].first + odd_pair[1].first, even_pair[1].first + odd_pair[0].first) << endl;
 
    return 0;
}

Measured memory_bytes: 2804
n = int(input())
a = list(map(int,input().split()))
ans = 1
for i in range(n):
    if a[i]%2 == 0:
        if a[i]%3 == 0 or a[i]%5 == 0:
            pass
        else:
            ans = 0
            break
if ans == 1:
    print("APPROVED")
else:
    print("DENIED")

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

namespace AtCoderTest
{
    class ABC163D
    {
        public static int readLineAsInt()
        {
            var line = Console.ReadLine();
            return int.Parse(line);
        }

        public static List<int> readLineAsListOfInt()
        {
            var line = Console.ReadLine();
            return line.Split(' ').Select(x => int.Parse(x)).ToList();
        }

        public static List<List<int>> readLinesAsTableOfInt(int N)
        {
            var ret = new List<List<int>>();
            for (int i = 0; i < N; ++i)
                ret.Add(readLineAsListOfInt());

            return ret;
        }

        public static List<int> readLinesAsListOfIntFromColumn(int N)
        {
            var ret = new List<int>();
            for (int i = 0; i < N; ++i)
                ret.Add(readLineAsListOfInt()[0]);

            return ret;
        }

        static void Main(string[] args)
        {
            var N_K = readLineAsListOfInt();
            var res = core(N_K[0], N_K[1]);

            Console.Write(res.ToString());
        }

        static long core(int N, int K)
        {
            long sum = 0;

            long modN = 1000000000 + 7;

            for (long i =K; i<=N+1; ++i)
            {
                long thisValue = ((N - i + 1) * i + 1) % modN;
                sum += thisValue;
                sum %= modN;
            }

            return sum;
        }
    }
}


Measured memory_bytes: 18860
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define cyes cout<<"YES"<<endl
#define cno cout<<"NO"<<endl
#define sp <<" "<<
#define cst(x) cout<<fixed<<setprecision(x)
#define pi 3.14159265359
#define mod 1000000007
struct edge {
    int to; 
    int weight;
    edge(int t, int w) : to(t),weight(w) {}
};
using namespace std;
using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;
using que_a = priority_queue<int, vector<int>, greater<int> >;
using que_d = priority_queue<int>;
using pint = pair<int,int>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(){

    int n; cin >> n;
    ll sum = 0;
    int min = 1e9+1;
    int minus = 0;
    rep(i,n){
        int a; cin >> a;
        if(a < 0) minus++;
        int a_new = abs(a);
        chmin(min,a_new);
        sum += a_new;
    }
    if(minus%2) cout << sum - 2*min << endl;
    else cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  long N,A[100000],i,x,a=1;
  
  scanf("%ld",&N);
  x=1;
  for(i=0;i<N;i++){
    scanf("%ld",&A[i]);
    if(A[i]==0){
      puts("0");
      return 0;
    }
    if((long)1e18/x/A[i]<1){
      a=0;
    }
    else x=x*A[i];
  }
  if(a==0)puts("-1");
  else printf("%ld\n",x);
  return 0;
}


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

int main(){
    int n,m;
    cin >> n >> m;
    vector<vector<int>> sec(n+1);

    for(int i=0; i<m; i++){
        int a,b;
        cin >> a >> b;
        sec[a].push_back(b);
    }
    int count = 1;
    int end = n;
    for(int i=1; i<=n; i++){
        if(sec[i].empty()){
            continue;
        }
        if(end <= i){
            count++;
            end = n;
        }
        sort(sec[i].begin(), sec[i].end());
        end = min(end, sec[i][0]);
    }
    cout << count << endl;
}

Measured memory_bytes: 5760
#include <iostream>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

int main(){
	stack<long> S1, ans;
	stack<pair<long, long> > S2;
	char ch;
	long sum = 0;
	for (long i = 0; cin >> ch; i++){
		if (ch == '\\') S1.push(i);
		else if (ch == '/' && S1.size() > 0){
			long j = S1.top(); S1.pop();
			sum += i - j;
			long a = i - j;
			while (S2.size() > 0 && S2.top().first > j){
				a += S2.top().second; S2.pop();
			}
			S2.push(make_pair(j, a));
		}
	}
	cout << sum << endl << S2.size();
	while (S2.size() > 0){ans.push(S2.top().second); S2.pop();}
	while (ans.size() > 0){cout << " " << ans.top(); ans.pop();}
	cout << endl;
	return 0;
}

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

ll f(ll n) {
  if (n < 2) return 0;
  return n * (n-1) / 2;
}

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

  ll a;
  vector<ll> v(N, 0);
  map<ll, ll> m1, m2;
  rep(i,0,N-1) {
    cin >> a;
    v[i] = a;
    m1[a]++;
  }

  ll sum = 0;
  for (pair<ll, ll> p : m1) {
    ll c1 = f(p.second);
    ll c2 = f(p.second - 1);
    m2[p.first] = c1 - c2;
    sum += c1;
  }

  rep(i,0,N-1) {
    cout << sum - m2[v[i]] << endl;
  }

  return 0;
}


Measured memory_bytes: 20608
#include <stdio.h>
#include <iostream>
#include <algorithm>

template <class _T> static _T tp_abs(const _T& a) {
	return ((a < 0) ? (a * -1) : a);
}
template<class _T> static void get1int(_T& a) {
	const char* fmt = " %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld";
	}

	if (scanf(fmt, &a) < 0) {
		printf("g1int Error\n");
	}
}
template<class _T> static void get3int(_T& a, _T& b, _T& c) {
	const char* fmt = " %d %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld %lld";
	}

	if (scanf(fmt, &a, &b, &c) < 0) {
		printf("g3int Error\n");
	}
}

static void ABC086C_Traveling();

#if 1
int main()
{
	ABC086C_Traveling();
	fflush(stdout);
	return 0;
}
#endif

class ABC086C_Point {
public:
	int ti = 0;
	int xi = 0;
	int yi = 0;
	static bool asc_ti(const ABC086C_Point& a, const ABC086C_Point& b) {
		return a.ti < b.ti;
	}
};
static void ABC086C_Traveling()
{
	int N;
	get1int(N);

	auto pts = new ABC086C_Point[N + 2];
	for (int i = 1; i <= N; i++) {
		get3int(pts[i].ti, pts[i].xi, pts[i].yi);
	}
	std::sort(pts, pts + N + 1, ABC086C_Point::asc_ti);

	bool arrival = true;
	for (int i = 0; i < N; i++) {
		int distTime = pts[i + 1].ti - pts[i].ti;
		int dist = tp_abs(pts[i + 1].xi - pts[i].xi) + tp_abs(pts[i + 1].yi - pts[i].yi);
		
		int diff = dist - distTime;
		if ((diff > 0) || (diff % 2)) {
			arrival = false;
			break;
		}
	}
	
	printf("%s\n", arrival ? "Yes" : "No");
	delete[] pts;
}


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

const ll INF = 1LL<<60;

ll d[105][105];

int main(){
	ll V,E;
	cin >> V >> E;
	
	rep(i,V){
		rep(j,V){
			if(i == j){
				d[i][j] = 0;
			}else{
				d[i][j] = INF;
			}
		}
	}
	
	rep(i,E){
		ll s,t,w;
		cin >> s >> t >> w;
		d[s][t] = w;
	}
	
	rep(k,V){
		rep(i,V){
			rep(j,V){
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}
	
	bool negative_cycle = false;
	
	rep(i,V){
		if(d[i][i] < 0) negative_cycle = true;
	}
	
	if(negative_cycle){
		cout <<  "NEGATIVE CYCLE" << endl;
	}else{
		rep(i,V){
			rep(j,V){
				if(j == V-1){
					if(d[i][j] >= INF/2){
						cout << "INF" << endl;
					}else{
						cout << d[i][j] << endl;
					}
				}else{
					if(d[i][j] >= INF/2){
						cout << "INF" << " ";
					}else{
						cout << d[i][j] << " ";
					}
				}
			}
		}
	}
    return 0;
}




Measured memory_bytes: 3196
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0590

#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;

const int C = (int) 1e6;

bool isprime[C];
vector<int> prime;

void init() {
  fill(isprime, isprime+C, true);
  isprime[0] = isprime[1] = false;
  for (auto i=2; i<C; i++) {
    if (isprime[i]) {
      prime.push_back(i);
      for (auto j=2; ; j++) {
	int t = i*j;
	if (t >= C) break;
	isprime[t] = false;
      }
    }
  }
}

int main() {
  init();
  int N;
  cin >> N;
  int count = 0;
  for (auto i=0; i<N; i++) {
    long long n;
    cin >> n;
    long long S = 2*n+1;
    long long sq = (long long)sqrt(S);
    for (auto j=0; prime[j]<=sq; j++) {
      if (S%prime[j] == 0) {
	count++;
	break;
      }
    }
  }
  cout << N-count << endl;
}

Measured memory_bytes: 2564
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_(i, n, m) for (int i = n; i < (int)(m); i++)
#define all(v) v.begin(), v.end()
#define int long long
#define stoi stoll
//#define _GLIBCXX_DEBUG

int vminn(vector<int> v) {
  sort(v.begin(), v.end());
  return v[0];
}

signed main() {
  string A = "abcdefghijklmnopqrstuvwxyz";
  
  int n; cin >> n;
  vector<vector<int>> a(26, vector<int>(n, 0));
  rep(i, n) {
    string s; cin >> s;
    for(char c : s) {
      a[(c-'a')][i]++;
    }
  }
  
  rep(i, 26) {
    rep(j, vminn(a[i])) cout << A[i];
  }
  cout << endl;

}


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

#define lli long long int
#define mpr make_pair
#define pr pair<lli,lli>
#define pb push_back
#define vl vector<lli>
#define mp map<lli,lli>
#define all(x) x.begin(),x.end()
#define FOR(i,n) for(lli i=0;i<(lli)n;i++)
#define FOR1(i,j,n) for(lli i=j;i<(lli)n;i++)
#define mod 1000000007

lli power(lli x,lli n,lli m)
{
	lli res=1;
	while(n>0)
	{
		if(n&1) res=(res*x)%m;
		x=(x*x)%m;
		n=n>>1;
	}
	return res;
}

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    lli n,q,s=0;
    cin>>n;
    vl v(n);
    mp m;
    for(lli i=0;i<n;i++)
    {
		cin>>v[i];
		m[v[i]]++;
		s+=v[i];
	}
	cin>>q;
	while(q--)
	{
		lli b,c;
		cin>>b>>c;
		lli cnt=m[b];
		m.erase(b);
		m[c]+=cnt;
		s=s-cnt*b+cnt*c;
		cout<<s<<endl;
	}
	
	
	
	
return 0;
}


Measured memory_bytes: 7828
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = ReadInt();
            var k = ReadInt();
            var x = ReadInts();
            var ans = 0;
            for (int i = 0; i < n; i++)
            {
                ans += Min(2 * x[i], 2 * (k - x[i]));
            }
            WriteLine(ans);
        }

        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}

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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)

#define mod 1e9+7;
#define inf 1e18+7;

typedef long long ll;

int main() {
    int n,k;cin>>n>>k;
    vector<int>h(n),d(n);

    rep(i,n){
        cin>>h[i];
    }
    rep(i,n){
        d[i+1]=d[i]+(h[i+1]-h[i]);
    }

    sort(d.begin(),d.end());

    int ans=inf;

    rep(i,n-k+1){
        ans=min(ans,d[i+k-1]-d[i]);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i,a,...) for(int i = (a)*(strlen(#__VA_ARGS__)!=0);i<(int)(strlen(#__VA_ARGS__)?__VA_ARGS__:(a));++i)
#define per(i,a,...) for(int i = (strlen(#__VA_ARGS__)?__VA_ARGS__:(a))-1;i>=(int)(strlen(#__VA_ARGS__)?(a):0);--i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
using ll = long long;
//const ll MOD = (ll)1e9+7;
const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}
#ifdef DEBUG
#define debug(x) cout<<"LINE "<<__LINE__<<": "<<#x<<" = "<<x<<endl;
#else
#define debug(x) (void)0
#endif

ll modpow(ll x, ll b){
  ll res = 1;
  while(b){
    if(b&1)res = res * x % MOD;
    x = x * x % MOD;
    b>>=1;
  }
  return res;
}

ll modinv(ll x){
  return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t a){
  if(was_output)cout << " ";
  cout << a;
  was_output = true;
}
void outendl(){
  was_output = false;
  cout << endl;
}
ll in(){
  ll res;
  scanf("%lld", &res);
  return res;
}

template<class t>
istream& operator>>(istream&is, vector<t>&x){
  for(auto &i:x)is >> i;
  return is;
}

template<class t, class u>
istream& operator>>(istream&is, pair<t, u>&x){
  is >> x.first >> x.second;
  return is;
}

template<class t>
void in(t&x){
  cin >> x;
}

template<class t>
void out(t x){
  cout << x;
}

template<class t>
vector<t> sorted(vector<t> line,function<bool(t,t)> comp=[](t a,t b){return a<b;}){
  sort(line.begin(),line.end(),comp);
  return line;
}

template<class t>
vector<t> reversed(vector<t> line){
  reverse(line.begin(),line.end());
  return line;
}

int main(){
  int a = in();
  int b = in();
  int c = in();
  swap(a,b);
  swap(a,c);
  cout << a << " " << b << " " << c << endl;
            
  return 0;
}


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


int main()
{
	int c[9];
	int i, j, k, sum,flag;
	sum = 0;
	flag = 0;
	for (i = 0; i < 9; i++) {
		cin >> c[i];
	}
	sum = c[0] + c[4] + c[8];
	for (i = 0; i <= 2; i++) {
		for (j = 3; j <= 5; j++) {
			for (k = 6; k <= 8; k++) {
				if (i % 3 != j % 3 && j % 3 != k % 3 && k % 3 != i % 3) {
					if (sum != c[i] + c[j] + c[k]) {
						flag = 1;
						break;
					}
				}
			}
		}
	}
	if (flag == 1) {
		cout << "No" << endl;
	}
	else
		cout << "Yes" << endl;
	return 0;
}



Measured memory_bytes: 256
/*  /$$                                     /$$
      | $$                                    | $$
  /$$$$$$$  /$$$$$$   /$$$$$$$  /$$$$$$   /$$$$$$$  /$$$$$$   /$$$$$$
 /$$__  $$ /$$__  $$ /$$_____/ /$$__  $$ /$$__  $$ /$$__  $$ /$$__  $$
| $$  | $$| $$$$$$$$| $$      | $$  \ $$| $$  | $$| $$$$$$$$| $$  \__/
| $$  | $$| $$_____/| $$      | $$  | $$| $$  | $$| $$_____/| $$
|  $$$$$$$|  $$$$$$$|  $$$$$$$|  $$$$$$/|  $$$$$$$|  $$$$$$$| $$
 \_______/ \_______/ \_______/ \______/  \_______/ \_______/|__//$$$$$$ /$$$$$$
                                                               |______/|______/

*/
#include <bits/stdc++.h>
#define fastio        ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ln            cout << endl;
#define vi            vector<int>
#define vll           vector<long long>
#define sortl(vec)    sort(vec.begin(), vec.end());
#define sortr(vec)    sort(vec.rbegin(), vec.rend());
#define forn(i, x, n) for(long long i = x; i < n; i++)
#define revn(i, n, x) for(long long i = n; i >= x; i--)
#define in(vec)       for(auto &it : vec) cin >> it;
#define loop(vec)     for(auto &it : vec)
#define	out(vec)      for(auto &it : vec) cout << it << " "; ln
#define ll            long long
#define mod           1000000007
#define debug(x)      cout << x << endl;
#define pb            emplace_back
#define mp            make_pair
#define um            unordered_map
#define pii           pair<int, int>
#define pll           pair<ll, ll>
#define f             first
#define s             second
#define pi            3.14159265359
#define CLOCK         cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl;
using namespace std;

ll bS(ll l, ll r, ll x, vll arr) {
	while (l <= r) {
		ll m = l + (r - l) / 2;

		if (arr[m] == x)
			return m;

		if (arr[m] < x)
			l = m + 1;

		else
			r = m - 1;
	}

	return -1;
}

void primeFactors(ll n) {
	while (n % 2 == 0) {
		//cout << 2 << " ";
		n = n / 2;
	}

	for (ll i = 3; i <= sqrt(n); i += 2) {
		while (n % i == 0) {
			//cout << i << " ";
			n = n / i;
		}
	}

	if (n > 2)
		cout << n << " ";
}

ll power(ll x, ll y, ll p) {
	ll res = 1;
	x = x % p;

	while (y > 0) {
		if (y & 1)
			res = (res * x) % p;

		y = y >> 1;
		x = (x * x) % p;
	}
	return res;
}

ll modulo(ll a, ll b) {
	ll c = a % b;
	return (c < 0) ? c + b : c;
}

int main() {
// in(vec) works for size-defined type vectors

#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input1.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output1.txt", "w", stdout);
#endif

	fastio
	ll t = 1;
	while (t--) {
		ll n;
		cin >> n;
		vll vec(n + 1);
		for (ll i = 1; i <= n; i++)
			cin >> vec[i];
		vll sum(200005, 0);
		vll diff(200005, 0);


		forn(i, 1, n + 1) {
			if (i + vec[i] < 200005)
				sum[i + vec[i]]++;
			if (i - vec[i] >= 0)
				diff[i - vec[i]]++;
		}
		ll count = 0;

		forn(i, 1, 200005) {
			if (sum[i] && diff[i])
				count += sum[i] * diff[i];
		}
		cout << count << endl;

	}
	CLOCK
	return 0;
}



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

int n;
long long m = 0, j = 1;
string s, t[100000];

int main()
{
	cin >> n;

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

		sort(s.begin(), s.end());

		t[i] = s;
	}

	sort(t, t + n);

	for (int i = 1; i < n; i++) {
		if (t[i] == t[i - 1])
			j++;
		else {
			m += j * (j - 1) / 2;
			j = 1;
		}
	}

	m += j * (j - 1) / 2;
	cout << m << endl;

	return 0;
}

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

using namespace std;
const int maxn =  1e6 + 10;
#define ll long long
#define ios std::ios::sync_with_stdio(false)
const ll INF(0x3f3f3f3f3f3f3f3fll);
const int inf(0x3f3f3f3f);
/*


ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
ll pow_mod(ll x,ll n,ll mod){ll res=1;while(n){if(n&1)res=res*x%mod;x=x*x%mod;n>>=1;}return res;}//xµÄn´Î·½mod


ll mult(ll a,ll b,ll p){a%=p;b%=p;ll r=0,v=a;while(b){if(b&1){r+=v;if(r>p)r-=p;}v<<=1;if(v>p)v-=p;b>>=1;}return r;}
ll quick_pow(ll a,ll b,ll p){ll r=1,v=a%p;while(b){if(b&1)r=mult(r,v,p);v=mult(v,v,p);b>>=1;}return r;}
bool CH(ll a,ll n,ll x,ll t)
{ll r=quick_pow(a,x,n);ll z=r;for(ll i=1;i<=t;i++){r=mult(r,r,n);if(r==1&&z!=1&&z!=n-1)return true;z=r;}return r!=1;}
bool Miller_Rabin(ll n)
{if(n<2)return false;if(n==2)return true;if(!(n&1))return false;ll x=n-1,t=0;while(!(x&1)){x>>=1;t++;}srand(time(NULL));
ll o=8;for(ll i=0;i<o;i++){ll a=rand()%(n-1)+1;if(CH(a,n,x,t))return false;}return true;}


*/

#define int long long
#define sc(t) scanf("%lld",&t)
#define pr(ans) printf("%lld\n",ans)
ll pow_mod(ll x,ll n,ll mod){ll res=1;while(n){if(n&1)res=res*x%mod;x=x*x%mod;n>>=1;}return res;}//xµÄn´Î·½mod
template<typename T>void read(T &res){bool flag=false;char ch;while(!isdigit(ch=getchar()))(ch=='-')&&(flag=true);
for(res=ch-48;isdigit(ch=getchar());res=(res<<1)+(res<<3)+ch - 48);flag&&(res=-res);}
typedef unsigned long long ULL;
const double pi = 3.1415926535897932384626;
int gcd(int a,int b){return !b?a:gcd(b,a%b);}
int lcm(int a,int b){return a/gcd(a,b)*b;}
#define debug(x) cout << #x << " : " << x << '\n';
#define sb cout << "sb\n";
#define fi first
#define se second
#define pb(a) push_back(a)
#define cn cout << '\n'
#define mp(a , b) make_pair(a , b)
const double ep = 1e-6;

int a[maxn];
signed main()
{
    ios;///60 10 50
    cin.tie(0);
    for(int i = 1 ; i <= 101 ; i ++){
        for(int j = 1 ; j <= 101 ; j ++){
            if(i * i + j * j + i * j > 1e4)break;
            for(int k = 1 ; k <= 101 ; k ++){
                if(i * i + j * j + k * k + i * j + i * k + j * k > 1e4)break;
                else{
                    a[i * i + j * j + k * k + i * j + i * k + j * k] ++;
                }
            }
        }
    }
    int n;
    cin >> n;
    for(int i = 1 ; i <= n ; i ++) cout << a[i] << '\n';
	return 0;
}
/*
18
2 3 3
*/


Measured memory_bytes: 3708
#include<stdio.h>
int main(void){
  char *s="python3 -c\""
"n,*s=open(0)\n"
"a=b=c=d=0\n"
"for t in s:\n"
"    if t[-2]=='A'and t[0]=='B':\n"
"        d+=1\n"
"    elif t[-2]=='A':\n"
"        a+=1\n"
"    elif t[0]=='B':\n"
"        b+=1\n"
"    c+=t.count('AB')\n"
"if all(i==0for i in(a,b)):\n"
"    print(c+max(0,d-1))\n"
"    exit()\n"
"elif a==b:\n"
"    print(a+c+d)\n"
"    exit()\n"
"ans=min(a,b)+c\n"
"dif=abs(a-b)\n"
"ans+=min(dif,d)\n"
"d-=min(dif,d)\n"
"print(ans+d)\n"
"\"";
  system(s);
  return 0;
}            

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

#define NMAX 3

int main(){
    int n, m;
    int num[NMAX + 1];
    int memo[NMAX + 1];
    cin >> n >> m;

    for(int i=0; i<=n; i++){
        num[i] = 0;
        memo[i] = -1;
    }

    for(int i=0; i<m; i++){
        int s, c;
        cin >> s >> c;
        num[s] = c;
        if(memo[s] == -1) memo[s] = num[s];
        else if(memo[s] != num[s]){
            cout << -1 << endl;
            return 0;
        }

    }

    int ans=0;
    if(n != 1 && memo[1] == 0){
        cout << -1 << endl;
        return 0;
    }else if (n == 1 && memo[1] != -1){
        cout << num[1] << endl;
        return 0;       
    }else if(n == 1 && memo[1] == -1){
        cout << 0 << endl;
        return 0;       
    }

    if(memo[1] == -1) ans += pow(10, n-1);
    else ans += num[1] * pow(10, n-1);

    for(int i=2; i<=n; i++){
        ans += num[i] * pow(10, n-i);
    }

    cout << ans << endl;
   
}

Measured memory_bytes: 256