akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE cout << -1 << endl;return 0
#define MM <<" "<<
#define Endl endl

signed main(void){
    int N,K;
    int a[100];
    int dp[114514]={};
    cin >> N >> K;
    REP(i,N){
        cin >> a[i];
    }
    for(int i=1;i<=K;i++){
        REP(j,N){
            if(i-a[j]<0)continue;
            if(dp[i-a[j]]==0){
                dp[i]=1;
            }
        }
    }
    cout << (dp[K]==1?"First":"Second") << endl;
    return 0;
}



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

int main(void){
  char c1, c2;
  int ans = 0;
  
  cin >> c1;
  for (int i=0; i<3; i++){
    cin >> c2;
    if (c1==c2) ans |= 1;
    c1 = c2;
  }
  cout << (ans?"Bad":"Good") << endl;
  return 0;
}

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

using namespace std;

using ll = long long;
using vi = vector<int>;

const ll linf = 1LL << 62;
const int inf = 999999;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const ll atcoder = int(1e9 + 7);

#define Endl endl
#define pr(x) cout << x << endl
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
#define all(x) x.begin(),x.end()
#define atcoder(int)1e9+7
#define rep(i,n) for(int i = 0;i<n;i++)
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)


ll gcd(ll a, ll b) {//最大公約数
	if (a%b == 0)return b;
	else gcd(b, a%b);
}

ll lcm(ll a, ll b) {//最小公倍数
	return (a / gcd(a, b))*b;
}

ll t[100010];

int  main() {
	
	int n, c, k;
	cin >> n >> c >> k;
	rep(i, n)cin >> t[i];
	sort(t, t + n);
	int ans = 0;

	rep(i, n) {
		int a = t[i];
		i++;
		ans++;
		if (i > n)break;
		for(int j = 0;j<c-1;j++){
			if (i >= n)break;
			if (t[i] <= a + k)i++;
			else break;
		}
		i--;
	}

	pr(ans);
	return 0;

}

Measured memory_bytes: 1024
count=0
s=input()
len_s=len(s)
center=int((len_s-1)/2+1)
s_former=s[0:center-1]
s_leter=s[center:]
for a in range(int((len(s)-1)/2-1)):
    if(s[a]==s[-1-a]):
        pass
    else:
        count+=1
for a in range(int((len(s_former)+1)/2)):
    if(s_former[a]==s_former[-1-a]):
        pass
    else:
        count+=1
for a in range(int((len(s_leter)+1)/2)):
    if(s_leter[a]==s_leter[-1-a]):
        pass
    else:
        count+=1
if(count==0):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int n, m, k;
  cin >> n >> m >> k;
  vector<int> a(n), b(m);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  for (int i = 0; i < m; ++i) {
    cin >> b[i];
  }
  vector<ll> asum(n + 1), bsum(m + 1);
  for (int i = 0; i < n; ++i) {
    asum[i + 1] = asum[i] + a[i];
  }
  for (int i = 0; i < m; ++i) {
    bsum[i + 1] = bsum[i] + b[i];
  }
  int ans = 0;
  for (int i = 0; i <= n; ++i) {
    if (k < asum[i]) continue;
    int ok = 0, ng = m + 1;
    while (1 < abs(ok - ng)) {
      int mid = (ok + ng) / 2;
      if (bsum[mid] <= k - asum[i]) {
        ok = mid;
      } else {
        ng = mid;
      }
    }
    ans = max(ans, i + ok);
  }
  cout << ans << endl;
  return 0;
}

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

const int MAXN = 2e5+10;

inline int read() {
	int x = 0;
	char ch = getchar();
	for(; !isdigit(ch); ch = getchar()) ;
	for(; isdigit(ch); ch = getchar()) x = (x*10)+(ch^48);
	return x;
}

int n, p[MAXN];

int main() {

	n = read();
	for(int i = 1; i <= n; i++) p[read()] = i;
	int cl = 1, res = 1;
	for(int i = 2; i <= n; i++) {
		if(p[i] < p[i-1]) cl = 1;
		else cl++, res = std::max(res, cl);
	}
	printf("%d\n", n-res);
	return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

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

        while(true) {
        	String str = sc.next();
        	int sum = 0;

        	if(str.equals("0")) {
        		break;
        	}

        	for(int i = 0; i < str.length(); i++) {
        		sum += Integer.parseInt(str.substring(i, i+1));
        	}

        	System.out.println(sum);
        }
    }
}


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

using namespace std;
using ll=long long;

int main()
{
   int n;cin >> n;
   ll a[n],b[n];
   for(int i=0;i<n;i++){
    cin >> a[i]>> b[i];
   }
   ll ans=0;
   ll k=0;
   for(int i=n-1;i>=0;i--){
    a[i]+=k;
    a[i]%=b[i];
   if(a[i]==0)continue;
    k+=(b[i]-a[i]);
    ans+=(b[i]-a[i]);
   }
   cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
def main():
    N, M = [int(x) for x in input().split()]
    A = [int(x) for x in input().split()]
    import heapq
    bests = heapq.nlargest(M, A)
    # print(bests)
    if bests[-1] >= sum(A)/(4*M):
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <iomanip>
#include <limits>
#include <utility>
#include <bitset>
#include <sstream>
#define ll long long
#define lint long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
#define INF 1e9

int main()
{
    int N;
    cin >> N;
    vector<int> W(N);
    vector<int> s(N);

    rep(i,N)cin>>W[i];
    s[0] = W[0];
    for(int i = 1; i < N; i++) {
        s[i] = s[i-1] + W[i];
    }
    //rep(i,N) cout<<s[i]<<endl;

  
    int ans = INF;
    int tmp;
    for (int k = 0; k < N; k++) {
        tmp = abs((s[N-1] - s[k]) - s[k]);
        ans = min(tmp,ans);
    }

    cout<<ans<<endl;




    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define e1 first
#define e2 second
#define pb push_back
#define mp make_pair
#define boost {ios_base::sync_with_stdio(false);}
#define eb emplace_back
#define OUT(x) {cout << x; exit(0); }
#define FOR(i, a, b) for(int i=(a); i<=(b); ++i)
#define scanf(...) scanf(__VA_ARGS__)?:0
typedef long long ll;
typedef unsigned long long ull;
typedef pair <int, int> PII;
typedef pair <ll, ll> PLL;
typedef pair <PII, PII> PP;
typedef pair <PII, int> PPI;
typedef pair <int, PII> PIP;
typedef pair <ll, int> PLI;
typedef unsigned int ui;
typedef vector <int> vi;
const int mod = 1e9+7;
const int inf = 1e9+10;
const ll MOD = 1e9+696969;
const ll INF = 1e18;
#define maxn 1010
ll c = 0, px = 0, py = 0, p, k, n, m, F;
string s[maxn];

inline ll potmod(ll a, ll b) {
	ll res = 1;
	while (b > 0) {
		if (b & 1) res = (res * a)%mod;
		a = (a * a)%mod;
		b /= 2;
	}
	return res;
}
int main()
{
	cin >> n >> m >> k;
	if (k == 0) OUT(1);
	FOR(i, 0, n-1) cin >> s[i];
	FOR(i, 0, n-1)
	{
		if (s[i][0] == '#' && s[i][m-1] == '#') ++px;
	}
	FOR(j, 0, m-1)
	{
		if (s[0][j] == '#' && s[n-1][j] == '#') ++py;
	}
	FOR(i, 0, n-1)
		FOR(j, 0, m-1)
			if (s[i][j] == '#') ++c;
					
	if (px > 0 && py > 0) OUT(1);
	k--;
	if (k == 0) OUT(1);
	ll ile = 0;
	if (py > 0)
	{
		FOR(i, 1, n-1)
			FOR(j, 0, m-1) ile += (s[i][j] == '#' && s[i-1][j] == '#');
	}
	else
	{
		FOR(i, 0, n-1)
			FOR(j, 1, m-1) ile += (s[i][j] == '#' && s[i][j-1] == '#');
	}
	p = px + py;
	ll wyn = potmod(c, k);
	if (!p) OUT(wyn);
	F = (potmod(c, k) - potmod(p, k) + mod)%mod;
	F = F * potmod((c - p), mod - 2) % mod;
	F = F * ile % mod;
	cout << (wyn - F + mod)%mod;
}


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

 

int main()
{
    int i, j ,k, n;
    int b, f, r, v;
    int room[4][3][10]; 
   
    for(i=0; i<4; i++)
        for(j=0; j<3; j++)
            for(k=0; k<10; k++)
                room[i][j][k] = 0;

    cin >> n;
    for(i=0; i<n; i++)
    {
        cin >> b >> f >> r >> v;
        room[b-1][f-1][r-1] += v;
    }
   
    for(i=0; i<4; i++)
    {
        for(j=0; j<3; j++)
        {
            for(k=0; k<10; k++)
            {
                cout << " " << room[i][j][k];
            }
            cout << endl;
        }
        if(i<3)
            cout << "####################" << endl;
    }
}


Measured memory_bytes: 3068
#include <iostream>
using namespace std;
 
int main() {
  int n,a,i=0;
  cin >> n;
  for(; i < n; i += 1){
    cin >> a;
    if(a %2 == 0 && (!(a %3 == 0 || a %5 == 0))){
      break;
    }
  }
  if(i == n){
    cout << "APPROVED" << endl;
  }else{
    cout << "DENIED" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <set>
#include <string>
#include <iostream>
#include <cassert>
#include <cmath>
using namespace std;

int main() {
        int n;
        scanf("%d", &n);
        string s;
        cin >> s;
        vector<int> cnt(n), cnt2(n);
        cnt[0] = s[0] == 'E';
        for (int i = 1; i < n; i ++) {
                cnt[i] = cnt[i - 1] + (s[i] == 'E');
        }
        cnt2[n - 1] = s[n - 1] == 'W';
        for (int i = n - 2; i >= 0; i --) {
                cnt2[i] = cnt2[i + 1] + (s[i] == 'W');
        }
        int ans = 0;
        for (int i = 0; i < n; i ++) {
                int res = 0;
                if (i > 0) res += cnt[i - 1];
                if (i < n - 1) res += cnt2[i + 1];
                ans = max(ans, res);
        }
        printf("%d\n", n - ans - 1);
        return 0;
}



Measured memory_bytes: 2948
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstdio>
#include <climits>
#include <set>
using namespace std;

typedef long long ll;

int main()
{
    int a, b;
    cin >> a >> b;
    string s(b, a + '0');
    string t(a, b + '0');

    cout << min(s, t) << endl;


    
    
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
#include <map>
#include <queue>
#include <set>
#include<deque>
#include <regex>
#define rep(i,n) for(ll i=0;i<(n); ++i)
#define per(i,n) for(ll i=n-1;i>=0; --i)
#define all(x) (x).begin(),(x).end()
#define _GLIBCXX_DEBUG
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; }
const long long INF = 1LL << 60;
typedef long long ll;
const ll MOD = 1000000007;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s, t,ans = "~";//ASCIIコード的に一番後。
	cin >> s >> t;
	ll S = s.length();
	ll T = t.length();
	for (ll i = 0; i < S-T+1;i++) {
		bool ok = true;
		string s2 = s;
		for (ll k = 0; k < T; k++) {
			if (s[i + k] != '?' && s[i + k] != t[k]){
				ok = false;
				break;
			}
			else {
				s2[i + k] = t[k];
			}
		}
		if (ok) {
			replace(all(s2),'?','a');
			ans = min(ans,s2);
		}
	}
	if (ans == "~")cout << "UNRESTORABLE" << endl;
	else cout << ans << endl;
}




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

int main()
{
    int N;
    cin >> N;
    vector<long long> A(N);
    vector<long long> B(N);
    vector<long long> C(N);
    for (int i=0; i<N; i++) cin >> A[i];
    for (int i=0; i<N; i++) cin >> B[i];
    for (int i=0; i<N; i++) cin >> C[i];
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    sort(C.begin(), C.end());

    long long ans = 0;
    for (int i=0 ; i<N; i++)
    {
        long long target_B = B[i];
        long long A_upper = lower_bound(A.begin(), A.end(), target_B) - A.begin();
        long long C_lower = lower_bound(C.begin(), C.end(), target_B +1) - C.begin();
        ans += A_upper * (N - C_lower);
    }

    cout << ans << endl;
}

Measured memory_bytes: 5636
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

n, a, b = map(int, input().split())
vs = list(map(int, input().split()))
vs.sort(reverse=True)
rsw = [0]*(n+1)
for i in range(1,n+1):
    rsw[i] = sum(vs[:i])/i
#print(vs)
#print(rsw)
res = -float('inf')
for i in range(a,b+1):
    res = max(res,rsw[i])
print(res)
mut = []
res_lists = []
for i in range(1,b+1):
    if i < a:
        mut.append(vs[i-1])
    elif i == a:
        res_lists.append(mut.copy()+[vs[i-1]])
    else:
        if rsw[i] < res:
            break
        res_lists.append(res_lists[-1].copy() + [vs[i - 1]])
#print(res_lists)
res = 0
for lis in res_lists:
    x = lis[-1]
    r = lis.count(x)
    N = 0
    for i in range(n):
        if vs[i] == x:
            N += 1
    res += combinations_count(N,r)
print(res)

Measured memory_bytes: 65464
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;

int main() {
  while(1){
    int n;
    cin>>n;
    if(!n)break;
    vector<vector<int>> t(n);
    REP(i,n){
      int m;
      cin>>m;
      REP(j,m){
        int p;
        cin>>p;
        t[i].push_back(p);
      }
      sort(begin(t[i]),end(t[i]));
    }
    int k;
    cin>>k;
    vector<int> l(k);
    REP(i,k)cin>>l[i];
    vector<int> valid;
    REP(i,n){
      bool f=true;
      REP(j,k){
        if(!binary_search(begin(t[i]),end(t[i]),l[j]))
          f=false;
      }
      if(f)
        valid.push_back(i);
    }
    if(valid.size() == 1)
      cout << valid.front()+1 << endl;
    else
      cout << -1 <<endl;
  }
  return 0;
}

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

int calc(int ymd[]) {
    const int MONTH = 10, BIG_DAY = 20, SMALL_DAY = 19;
    int nomalYear = (MONTH / 2 * BIG_DAY) + (MONTH / 2 * SMALL_DAY);
    int uruYear   = MONTH * BIG_DAY;
    int ret       = 0;

    ret += ((ymd[0] - 1) / 3) * uruYear;
    ret += ((ymd[0] - 1) / 3) * 2 * nomalYear;
    ret += ((ymd[0] - 1) % 3) * nomalYear;
    if (ymd[0] % 3) {
        ret += (ymd[1] - 1) / 2 * BIG_DAY + (ymd[1] - 1) / 2 * SMALL_DAY;
        ret += (ymd[1] - 1) % 2 * BIG_DAY;
        ret += ymd[2];
    } else {
        ret += (ymd[1] - 1) * BIG_DAY;
        ret += ymd[2];
    }
    return ret;
}

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

    int n;
    int ymd[3];
    int millennium = 196471;
    cin >> n;
    for (int idxone = 0; idxone < n; ++idxone) {
        cin >> ymd[0] >> ymd[1] >> ymd[2];
        cout << millennium - calc(ymd) << endl;
    }
}


Measured memory_bytes: 3132
using System;

class Program
{
    static void Main(string[] args)
    {
        var s = Console.ReadLine().Split();
        if (s[0] == s[1] && s[1] == s[2]) Console.WriteLine(1);
        else if (s[0] == s[1] || s[1] == s[2] || s[2] == s[0]) Console.WriteLine(2);
        else Console.WriteLine(3);
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <cmath>
#include <algorithm>
#include <functional>

using namespace std;

typedef long long ll;

ll INF = 1<<29;
ll N,M,R;
ll r[8];
ll m[200][200];

int main(){
    cin >> N >> M >> R;
    for(int i=0;i<R;i++){
        cin >> r[i];
        r[i]--;
    }
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            if(i!=j) m[i][j] = INF;
            else m[i][j] = 0; 
        }
    }
    ll a,b,c;
    for(int i=0;i<M;i++){
        cin >> a >> b >> c;
        a--;
        b--;
        m[a][b] = m[b][a] = c;
    }
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            for(int k=0;k<N;k++){
                m[j][k] = min(m[j][k], m[j][i] + m[i][k]);
            }
        }
    }
    ll ans = INF;
    int p[8] = {0,1,2,3,4,5,6,7};
    do{
        ll l = 0;
        for(int i=0;i<R-1;i++) l += m[r[p[i]]][r[p[i+1]]];
        ans = min(l,ans);
    }while(next_permutation(p,p+R));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
#define FOR(i,a,b) for(int i =(a) ; i <= (b); i++)
#define REP(i,n)  FOR( i, 0, (n) - 1 )

int main(){
  int n; cin >> n;
  cout << ( (n+110)/111 ) * 111 << endl;
    return 0;
}

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

using namespace std;
int a[20], b[20], c[20];
int asum = 0;
int bsum = 0;
int n;
int result;

int main(void) {
	scanf("%d", &n);

	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	for (int i = 0; i < n; i++) {
		scanf("%d", &b[i]);
	}
	for (int i = 0; i < n; i++)
	{
		if (a[i] > b[i])c[i] = 1;
		else c[i] = 0;
	}
	for (int i = 0; i < n; i++)
	{
		if (c[i] == 1) {
			asum += a[i];
			bsum += b[i];
		}
	}
	result = asum - bsum;

	printf("%d", result);

	return 0;
}

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

using namespace std;

#define int long long

int H, W;
int A[33][33];

const int dy[] = {0, 1, 0, -1};
const int dx[] = {1, 0, -1, 0};

using Tapris = tuple<int, int, int, int>;

int mincost[1001][33][33];

signed main() {
  scanf("%lld %lld", &H, &W);
  for(int i = 0; i < H; ++i) {
    for(int j = 0; j < W; ++j) {
      scanf("%lld", &A[i][j]);
    }
  }

  auto in = [&](int i, int j) {
    return 0<=i&&i<H&&0<=j&&j<W;
  };

  priority_queue<Tapris, vector<Tapris>, greater<Tapris> > que;
  fill((int*)mincost[0], (int*)mincost[1001], 1LL<<55);
  que.emplace(0, 0, 0, 0);
  mincost[0][0][0] = 0;
  while(!que.empty()) {
    int cost, dist, y, x;
    tie(cost, dist, y, x) = que.top(); que.pop();
    if(y == H-1 && x == W-1) {
      printf("%lld\n", cost);
      return 0;
    }
    if(mincost[dist][y][x] < cost) continue;
    for(int i = 0; i < 4; ++i) {
      int ny = y+dy[i], nx = x+dx[i];
      if(!in(ny, nx)) continue;
      int nd = dist+1;
      int nc = cost+(2*dist+1)*A[ny][nx];
      if(nd <= 1000 && nc < mincost[nd][ny][nx]) {
	que.emplace(nc, nd, ny, nx);
	mincost[nd][ny][nx] = nc;
      }
    }
  }
  assert(false);

  return 0;
}



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

int main() {
  int N;
  cin >> N;
  vector<int> L(N);
  for(int i = 0; i < N; i++) {
    cin >> L.at(i);
  }
  sort(L.begin(), L.end());
  if(L.at(N-1) < accumulate(L.begin(), L.begin() + (N - 1), 0)){
    cout << "Yes";
  }else{
    cout << "No";
  }
}

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

class Bmondai
{
    static void Main()
    {
        var n = Console.ReadLine().Split(' ').Select(x => Int64.Parse(x)).ToArray();
        var N = n[0];
        var K = n[1];
        var line = Console.ReadLine().Split(' ').Select(x => Int64.Parse(x)).ToArray();
        var list = new List<long>();
        for (long i = 0; i < N; ++i)
        {
            var sum = 0L;
            for (long j = i; j < N; ++j)
            {
                sum += line[j];
                if (sum != 0L) list.Add(sum);
            }
        }
        var max =(int)(Math.Log(list.Max(),2));
        var ans = 0L;
        for (var i=max;i>-1;--i)
        {
            var bit = (long)Math.Pow(2,i);
            var ansList =list.Where(x => (x & bit)!=0).ToList();
            if (K <= ansList.Count())
            {
                list = ansList;
                ans |= bit;
            }
        }
        Console.WriteLine(ans);
    }
}

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

int main(void){
    
    int N, K, ans=0;

    cin >> N >> K;

    std::shared_ptr<int> p(new int[N], std::default_delete<int[]>());

    for(int i=0; i<N; i++){
        cin >> p.get()[i];
    }

    for(int j=0; j<K; j++){
        int pmin = 1001;
        int num = 0;
        for(int i=0;i<N; i++){
            if(p.get()[i]<pmin && p.get()[i]!=0){
                pmin = p.get()[i];
                num = i;
            }
        }
        ans += pmin;
        p.get()[num] = 0;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3612
import sys
raw=[4,1,2,1,2,1,4,1]
for line in sys.stdin.readlines():
    p=map(int,line.strip().split())
    ma,ans=1<<30,str(1<<30)
    for i in xrange(8):
        t=raw[i:]+raw[:i]
        temp=sum(map(lambda a,b:a-b if a>b else 0,p,t))
        if (temp<ma) or (temp==ma and int(ans)>int("".join(map(str,t)))):
            ma=temp
            ans="".join(map(str,t))
    print " ".join(ans)

Measured memory_bytes: 4244
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <cmath>
#define ll long long
#define INF 1e+18
#define MOD 998244353
using namespace std;


int main(){
    int a,c;
    cin >> a >> c;
    if((a*c)%2==1){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}


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

int N, M, x[100009], y[100009], col[100009], dist[100009]; vector<int>G[100009], L;

void dfs(int pos) {
	col[pos] = 1;
	for (int i = 0; i < G[pos].size(); i++) {
		if (col[G[pos][i]] == 1) continue;
		dfs(G[pos][i]);
	}
	L.push_back(pos);
}

int main() {
	cin >> N >> M;
	for (int i = 1; i <= M; i++) {
		cin >> x[i] >> y[i];
		G[x[i]].push_back(y[i]);
	}
	for (int i = 1; i <= N; i++) {
		if (col[i] == 1) continue;
		dfs(i);
	}
	reverse(L.begin(), L.end());

	for (int i = 0; i < L.size(); i++) {
		for (int j = 0; j < G[L[i]].size(); j++) dist[G[L[i]][j]] = max(dist[G[L[i]][j]], dist[L[i]] + 1);
	}
	int maxn = 0;
	for (int i = 1; i <= N; i++) maxn = max(maxn, dist[i]);
	cout << maxn << endl;
	return 0;
}

Measured memory_bytes: 9208
#include <bits/stdc++.h>
using namespace std;
#define uint unsigned int
#define llong long long int
#define ullong unsigned long long int
#define rep(i, n) for (int i = 0; i < n; ++i)
const static long long int MOD = 1000000000 + 7;
const static int dy[] = {0, 1, 0, -1};
const static int dx[] = {1, 0, -1, 0};

template<typename T> T combination(T n, T r)
{
    if (r == 0 || r == n)
        return (1);
    else if (r == 1)
        return (n);
    return (combination(n - 1, r - 1) + combination(n - 1, r));
}

int main(int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, p, a, even = 0, odd = 0;
    cin >> n >> p;
    rep(i, n) {
        cin >> a;
        if (a % 2) ++odd;
        else ++even;
    }

    llong ans = 0;
    if (p == 1) {
        rep(i, odd + 1) {
            if (i % 2) ans += combination(odd, i);
        }
        ans *= pow(2, even);
    } else {
        rep(i, odd + 1) {
            if (!(i % 2)) ans += combination(odd, i);
        }
        ans *= pow(2, even);
    }

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

Measured memory_bytes: 384
import java.io.PrintWriter;
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		char[] s = sc.next().toCharArray();
		int N = s.length;
		
		int[] parent = makeTree(s, N);
		if(parent==null) {
			pw.println(-1);
		} else {
			for(int i=0; i<N; i++) {
				if(parent[i]<0)
					continue;
				pw.println((i+1) + " " + (parent[i]+1));
			}
		}
		sc.close();
		pw.close();
	}
	
	static int[] makeTree(char[] s, int N) {
		if(s[N-1]=='1' || s[0]=='0' || s[N-2]=='0')
			return null;
		for(int i=1; i<N/2; i++)
			if(s[i]!=s[N-i-2])
				return null;
		
		int[] ans = new int[N];
		int p = 0;
		ans[1] = 0;
		for(int i=2; i<N/2+1; i++) {
			if(s[i-1]=='1') {
				ans[p] = i;
				p = i;
			} else {
				ans[i] = p;
			}
		}
		for(int i=N/2; i<N; i++)
			ans[i] = p;
		ans[p] = -1;
		return ans;
	}
}


Measured memory_bytes: 44996
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using boost::multiprecision::cpp_int;
using namespace std;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

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; }

typedef long long ll;
typedef pair<ll, ll> p;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int x;
  cin >> x;
  if(x >= 30) cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

int main() {
  string s;
  cin >> s;
  int n = s.size();
  
  int64_t sum = 0;
  for (int bit = 0; bit < (1 << n - 1); bit++) {
    int64_t t = s.at(0) - '0';
    for (int i = 0; i < n - 1; i++) {
      if (bit & (1 << i)) {
        sum += t;
        t = s.at(i + 1) - '0';
      }
      else {
        t *= 10;
        t += s.at(i + 1) - '0';
      }
    }
    sum += t;
  }
  cout << sum << endl;
}

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

int n;
long long sum=0;

int main()
{
	scanf("%d",&n);

	for(int i=1;i<=n;i++)
	{
		if(i%3!=0&&i%5!=0)sum=sum+i;
			
	}
	
	printf("%lld",sum);

	return 0;
}

Measured memory_bytes: 3824
#include <cstdio>
#include <utility>
#include <queue>
using namespace std;
int i,n,L,t,s;
int main(){
	typedef pair<int,int>pii;
	priority_queue<pii> qu;
	pii p;
	int tr[100002];
	
	for(scanf("%d%d",&n,&L);i++<n;)scanf("%d",tr+i);
	*tr=tr[n+1]=0;
	for(;--i;)
		tr[i]>tr[i-1]&tr[i]>tr[i+1]?
			qu.push(pii(tr[i]-L,i)),
			tr[i]=L:0;

	for(;!qu.empty();
			n&&n!=L&n>tr[s+2]?
			qu.push(pii(t-L+n,s+1)),
			tr[s+1]=L
		:0)
		p=qu.top(),
		qu.pop(),
		
		t=p.first,
		tr[s=p.second]=0,
		
		n=tr[s-1],
		n&&n!=L&n>tr[s-2]?
			qu.push(pii(t-L+n,s-1)),
			tr[s-1]=L
		:0,
		n=tr[s+1];

	
	printf("%d\n",-t);
}

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

int main(void){
    int n;
    cin >> n;
    map<string,int> mp;
    for(int i=0;i<n;i++){
        string s;
        cin >> s;
        mp[s]++;
    }
    cout << "AC x " << mp["AC"] << endl;
    cout << "WA x " << mp["WA"] << endl;
    cout << "TLE x " << mp["TLE"] << endl;
    cout << "RE x " << mp["RE"] << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <cstdio>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <queue>
#include <cmath>
#include <cstring>
using namespace std;

#ifdef ENABLE_LL
#define int long long
#endif

#ifdef ENABLE_LL
#define I "%lld"
#define II "%lld%lld"
#define III "%lld%lld%lld"
#define IIII "%lld%lld%lld%lld"
#define IN "%lld\n"
#define IIN "%lld%lld\n"
#define IIIN "%lld%lld%lld\n"
#define IIIIN "%lld%lld%lld%lld\n"
#else
#define I "%d"
#define II "%d%d"
#define III "%d%d%d"
#define IIII "%d%d%d%d"
#define IN "%d\n"
#define IIN "%d%d\n"
#define IIIN "%d%d%d\n"
#define IIIIN "%d%d%d%d\n"
#endif

#ifdef __LOCALE__
#define see(a) std::cout << #a << "=" << a << std::endl
#define ses(a) std::cout << #a << "=" << a << " " 
#else
#define see(a) //std::cout << #a << "=" << a << std::endl
#define ses(a)
#endif
#define repe(a,b) for (int a=0;a<(int)b.size();a++)
#define rep(i,n) for (int i=0;i<n;i++)
#define repa(i,n) for (int i=1;i<=n;i++)
#define repi(i,a,b) for (int i=a;i<=b;i++) 
#define repb(i,a,b) for (int i=a;i>=b;i--)
typedef pair < int , int > pr;
typedef pair < pr  , int > prr;
#define L first
#define R second
template <class T> inline bool checkMin(T& a , T b) { return (a > b ? a=b,1 : 0); }
template <class T> inline bool checkMax(T& a , T b) { return (a < b ? a=b,1 : 0); }
class Scanner{ private: istream& ist;public: Scanner(istream& in):ist(in){} string next(){ string r; ist >> r; return r; } string nextLine(){ string r; getline(ist,r); return r; } int nextInt(){ int r; ist >> r; return r; } double nextDouble(){ double r; ist >> r; return r; }};
Scanner sc(cin);


void init() {
     
}

void solve() {
    char a ; cin >> a; cout << (char)(a + 1) << endl;
}


#ifdef ENABLE_LL
#undef int
#endif
int main(){
    init();
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (ll i=0; i<(ll)(n); i++)
#define repd(i,n) for (ll i=n-1; i>=0; i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back
int main()
{
    int N;
    cin >> N;
    int a=N/100;
    int b=(N%100)/10;
    int c=(N%100)%10;
    if(a==7 || b==7 || c==7){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3596
#![allow(non_snake_case, unused_imports)]

// Input
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} };}
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,HashMap,BTreeMap,VecDeque};

// Functions

// Main
fn main(){
    input!{
        N: usize,
        A: [u64; N],
    }
    let mut A = A;
    let mut ans = 0;
    let mut color = vec![0;9];
    for i in 0..N{
        if A[i]>3200{
            A[i]=3200;
        }
        color[(A[i]/400) as usize] += 1;
    }
    for i in 0..8{
        if color[i]>0{
            ans += 1;
        }
    }
    println!("{} {}", max(1,ans), ans+color[8]);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    ll h, w, k;
    cin >> h >> w >> k;
    char gri[h][w];
    for (ll i = 0; i < h;i++){
        for (ll j = 0; j < w;j++){
            cin >> gri[i][j];
        }
    }
    ll ans = 0;
    for (ll hbit = 0; hbit < (1 << h); hbit++) {
        for (ll wbit = 0; wbit < (1 << w);wbit++){
            char grid[h][w];
                for (ll i = 0; i < h;i++){
                    for (ll j = 0; j < w;j++){
                     grid[i][j]=gri[i][j];
                    }
                }
                for (ll i = 0; i < h;i++){
                    if(hbit&(1<<i)){
                        for (ll j = 0; j < w;j++){
                            grid[i][j] = 'r';
                        }
                    }
                }
                for (ll i = 0; i < w;i++){
                    if(wbit&(1<<i)){
                        for (ll j = 0; j < h;j++){
                            grid[j][i] = 'r';
                        }
                    }
                }

                    ll cnt = 0;
                for (ll i = 0; i < h; i++) {
                    for (ll j = 0; j < w; j++) {
                        if (grid[i][j] == '#') cnt++;
                    }
                }
                if (cnt == k) ans++;
    }
}
cout << ans << endl;
}

Measured memory_bytes: 3632
#!/usr/bin/env python3
import sys, math, fractions, itertools, collections, copy, heapq


def solve(N: int, s: str, t: str):
    if t == s:
        print(N)
        return
    for i in range(1, N+1):
        S = s + t[-i:]
        if S[-N:] == t:
            print(len(S))
            break
    return


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

if __name__ == '__main__':
    main()


Measured memory_bytes: 5052
main = do
  n <- readLn
  putStrLn $ show $ luca n

luca :: Int -> Int
luca 0 = 2
luca 1 = 1
luca n = (lucalist !! (n - 1)) + (lucalist !! (n - 2))

lucalist :: [Int]
lucalist = [ luca i | i <- [0,1..] ]

Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
#define modulo 998244353
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000000000

vector<long long> dijkstra(int start,auto &E){
	vector<long long> ret(E.size(),Inf);
	priority_queue<pair<long long,int>,vector<pair<long long,int>>,greater<pair<long long,int>>> Q;
	Q.emplace(0,start);
	ret[start]=0;
	
	while(Q.size()!=0){
		long long D1 = Q.top().first;
		int from = Q.top().second;
		Q.pop();
		if(ret[from]>D1)continue;
		for(int i=0;i<E[from].size();i++){
			int to = E[from][i].first;
			long long D2 = E[from][i].second;
			if(D1+D2<ret[to]){
				ret[to] = D1+D2;
				Q.emplace(ret[to],to);
			}
		}
	}
	
	return ret;
}

int main(){
	
	int n,m,s,t;
	cin>>n>>m>>s>>t;
	s--;t--;
	
	vector<vector<pair<int,long long>>> EY(n,vector<pair<int,long long>>());
	auto ES = EY;
	
	for(int i=0;i<m;i++){
		int u,v;
		cin>>u>>v;
		
		long long a,b;
		cin>>a>>b;
		
		u--;v--;
		
		EY[u].emplace_back(v,a);
		EY[v].emplace_back(u,a);
		ES[u].emplace_back(v,b);
		ES[v].emplace_back(u,b);
	}
	
	vector<long long> disY = dijkstra(s,EY),disS = dijkstra(t,ES);
	
	vector<long long> ans(n,Inf);
	for(int i=0;i<n;i++){
	//	cout<<disY[i]<<','<<disS[i]<<endl;
		ans[i] -= disY[i]+disS[i];
	}
	
	for(int i=n-2;i>=0;i--){
		ans[i] = max(ans[i],ans[i+1]);
	}
	
	for(int i=0;i<n;i++)cout<<ans[i]<<endl;
	
	return 0;
}

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

// #define int long long
#define ll long long
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define pii pair<int,int>
#define e "\n"

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

    
void solve()
{
	
	int s,w;
	cin>>s>>w;
	if(w>=s)cout<<"unsafe"<<e;
	else cout<<"safe"<<e;
}
int main()
{
	// c_p_c();
	// int t;cin>>t;
	// while(t--)
		solve();
	
}

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

#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define OUT(a) cout << (a) << "\n"
#define ll long long
#define uint unsigned int
#define ushort unsigned short
#define ulong unsigned long

ll MOD = 10e9 + 7;

int main() {
    int n;
    cin >> n;
    vector<int> a(n+1);
    vector<int> res;
    for(int i=1; i<n+1; i++) cin >> a[i];
    for(int i=n; i>=1; i--) {
        int su = 0;
        for(int j=i; j<n+1; j+=i) su ^= a[j];
        a[i] = su;
        if (su == 1) res.push_back(i);
    }
    n = res.size();
    printf("%d\n", n);
    for(int i=0; i<n; i++) printf("%d ", res[i]);
    printf("\n");
    return 0;
}



Measured memory_bytes: 2424
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <map>
#include <set>
#include <list>
#include <unordered_set>
#include <unordered_map>
#include <stdlib.h>

using namespace std;
 
typedef long long i64;
typedef pair<i64, i64> P;

template<class T>
const T INF = numeric_limits<T>::max();
template<class T>
const T SINF = numeric_limits<T>::max() / 10;
static const i64 MOD = 1000000007;

//int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
//int dx[5] = {-1,0,0,0,1}, dy[5] = {0,-1,0,1,0};
//int dx[8] = {-1,0,1,1,1,0,-1,-1}, dy[8] = {1,1,1,0,-1,-1,-1,0};
//int dx[9] = {-1,0,1,1,1,0,-1,-1,0}, dy[9] = {1,1,1,0,-1,-1,-1,0,0};

struct edge {
	i64 from, to, cost;
	edge(i64 to, i64 cost) : from(-1), to(to), cost(cost) {}
	edge(i64 src, i64 to, i64 cost) : from(src), to(to), cost(cost) {}
};

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
	for(auto &e:t) fill_v(e,v);
}

//-----end of template-----//

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	vector<int> a(4);
	for(int i = 0; i < 4; ++i) cin >> a[i];
	sort(a.begin(), a.end());
	if(a[0] == 1 && a[1] == 4 && a[2] == 7 && a[3] == 9) cout << "YES" << endl;
	else cout << "NO" << endl;
}

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

using P = pair<ll,ll>;
#define v first
#define w second

// v/w 高い順
bool comp1(P a, P b){
    return a.v*b.w > b.v*a.w;
}

// v高い順（vが同じならw軽い方優先）
bool comp(P a, P b){
    return a.v == b.v ? a.w < b.w : a.v > b.v;
}

int main(void){
    ll N,W;
    cin>>N>>W;
    vector<P> a(N);
    rep(i,N){
        ll v,w;
        cin>>v>>w;
        a[i] = {v,w};
    }
    // sort(all(a),comp1);
    vector<P> dp = {{0,0}};

    rep(i,N){
        vector<P> tmp;
        for(auto& s : dp){
            tmp.push_back(s);
            tmp.push_back({s.v + a[i].v, s.w + a[i].w});
        }

        sort(all(tmp),comp);
        dp.clear();
        ll w_border = W+1;
        for(auto& s : tmp){
            if( w_border > s.w){
                w_border = s.w;
                dp.push_back(s);
            }
        }
        assert(dp.size() <= N*N*2);
    }
    cout<<dp[0].v<<endl;
    return 0;
}



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

ll absl(ll a) {
    return a > 0 ? a : -a;
}

int main() {
    ll n, k;
    cin >> n >> k;

    ll a = n % k;
    cout << min(a, absl(a - k)) << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define rep(i,l,n) for(i=l;i<n;i++)

int main(void){
	char s[101];
	char p[101];
	int i,j,ls,lp,a,m;
	
	scanf("%s",s);
	scanf("%s",p);
	
	ls=strlen(s);
	lp=strlen(p);
	
	a=0;
	
	rep(i,0,ls){
		if(a) break;
		rep(j,0,lp){
			m=i+j;
			if(m>=ls) m-=ls;
			if(s[m]!=p[j]) break;
			if(j==lp-1) a++;
			
		}
	}
	
	if(a) printf("Yes\n");
	else printf("No\n");
	
	return 0;
}



Measured memory_bytes: 2104
#include<iostream>
using namespace std;
int main(){
while(true){
int h,w;
cin>>h>>w;
if(h==0&&w==0)
return 0;
for(int i=0;i<h;i++){
for(int j=0;j<w;j++){

cout<<'#';
}
cout<<'\n';
}
cout<<'\n';


}





}

Measured memory_bytes: 3092
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int s = sc.nextInt();
		int w = sc.nextInt();
		
		if(s<= w) {
			System.out.println("unsafe");
		}else {
			System.out.println("safe");
		}
	}
	
}


Measured memory_bytes: 27084
#include<stdio.h>
int MIN(int a,int b){return a<b?a:b;}
int main(){
  int n,i,j,k,d[110][110],a[110],b[110];
  scanf("%d",&n);
  for(i=0;i<n*n;i++)d[i/n][i%n]=1e9;
  for(i=0;i<n;i++)scanf("%d %d",&a[i],&b[i]);
  for(i=0;i<n;i++)d[i][i]=0;
  for(i=1;i<n;i++){
    for(j=0;j+i<n;j++){
      for(k=j;k<i+j;k++){
	d[j][i+j]=MIN(d[j][i+j],d[j][k]+d[k+1][i+j]+a[j]*b[k]*a[k+1]*b[i+j]);
      }
    }
  }
  printf("%d\n",d[0][n-1]);
  return 0;
}
   


Measured memory_bytes: 2044
#include <iostream>
#include <map>
using namespace std;
int main(void){
    
    int N;
    cin >> N;
    
    map< string, int > ps;
    
    int output = 0;
    
    for( int i = 1; i <= N; ++i ){
        int a;
        string left, right, key;
        cin >> a;
        if( i < a ){
            left = to_string(i);
            right = to_string(a);
        }else{
            left = to_string(a);
            right = to_string(i);
        }
        ++ps[left + "," + right];
        if(ps[left + "," + right] == 2){
            ++output;
        }
    }
    
    cout << output << endl;
    
    return 0;
    
}


Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
#define pb push_back
#define ub upper_bound
#define lb upper_bound
#define mp make_pair
#define F first
#define S second
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define ve vector
#define vi vector<int>
#define vp vector<pair<int,int>>
#define vvi vector<vector<int>>
 
typedef long long ll;
const ll INF = LLONG_MAX - 100;
const ll mod = 1e9 + 7;
const int MAX_N = 2e5 + 5;
int dx[] = {-1,0,1,0}, dy[] = {0,1,0,-1};
vector<ll> prime;
 
int fac[MAX_N], inv[MAX_N];
 
template <class T = ll> T in() {T x; cin >> x; return (x);}
void DEBUG(vector<int> a) {for(int i=0;i<a.size();i++)cout<<a[i]<<" ";cout<<endl;}
ll GCD(ll a, ll b) {ll c; while (b != 0) {c = a % b; a = b; b = c;}return a;}
ll LCM(ll a, ll b) {return a * b / GCD(a, b);}
ll POW(ll a, ll b, bool usemod = true) {ll c = 1LL; while (b > 0) {if (b & 1LL) {if(!usemod)c*=a;else c = a * c%mod;}if (!usemod) a*=a;else a = a * a%mod; b >>= 1LL;}return c;}
void _nCr() {fac[0] = 1LL; for (int i = 1LL; i < MAX_N; i++) {fac[i] = fac[i - 1LL] * i%mod;}for (int i = 0; i < MAX_N; i++) {inv[i] = POW(fac[i], mod - 2);}}
ll nCr(ll n, ll r) {return (fac[n] * inv[r] % mod)*inv[n - r] % mod;}
void PRI(ll n) {bool a[n + 1LL]; for (int i = 0; i < n + 1LL; i++) {a[i] = 1LL;}for (int i = 2; i < n + 1LL; i++) {if (a[i]) {prime.pb(i); ll b = i; while (b <= n) {a[b] = 0; b += i;}}}}
template <typename T> T chmin(T& a, T b) {if(a>b)a=b;return a;}
template <typename T> T chmax(T& a, T b) {if(a<b)a=b;return b;}

bool solve() {
	int n,l;cin>>n>>l;
	int sum = (2*l+n-1)*n/2;
	if (l >= 0) {
		sum-=l;
	} else if (l+n-1 <= 0) {
		sum-=l+n-1;
	}
	cout << sum << endl;
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<string.h>
using namespace std;
int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if(a+b>c+d)cout<<"Left"<<endl;
	else if(a+b<c+d)cout<<"Right"<<endl;
	else cout<<"Balanced"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include<math.h>
#include<string.h>
using namespace std;
#define MAX 200005
#define MOD 998244353
#define INF 1000000000000000000
#define EPS 0.0000000001
#define CHAINS 18
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL)
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
long long segment_tree[MAX*4];
void build(int index,int l,int r)
{
    if(l==r)
    {
        segment_tree[index]=(l==0);
        return;
    }
    int m=(l+r)/2;
    build(index*2,l,m);
    build(index*2+1,m+1,r);
    segment_tree[index]=(segment_tree[index*2]+segment_tree[index*2+1])%MOD;
}
void update(int index,int l,int r,int ind,long long v)
{
    if(l>ind||r<ind) return;
    if(l==r)
    {
        segment_tree[index]=v%MOD;
        return;
    }
    int m=(l+r)/2;
    update(index*2,l,m,ind,v);
    update(index*2+1,m+1,r,ind,v);
    segment_tree[index]=(segment_tree[index*2]+segment_tree[index*2+1])%MOD;
}
long long query(int index,int l,int r,int L,int R)
{
    if(L>r||R<l) return 0;
    if(L<=l&&r<=R)
    {
        return segment_tree[index];
    }
    int m=(l+r)/2;
    long long F=query(index*2,l,m,L,R);
    long long S=query(index*2+1,m+1,r,L,R);
    return (F+S)%MOD;
}
vector<pair<int,int> > P;
int main()
{
    int n,i,m,j;
    scanf("%d %d",&n,&m);
    pair<int,int> p;
    build(1,0,n-1);
    for(i=0;i<m;i++)
    {
        scanf("%d %d",&p.first,&p.second);
        P.push_back(p);
    }
    sort(P.begin(),P.end());
    for(i=1;i<n;i++)
    {
        long long cur=0;
        for(j=0;j<P.size();j++)
        {
            if(P[j].first>i) break;
            cur=(cur+query(1,0,n-1,max(0,i-P[j].second),i-P[j].first))%MOD;
        }
        update(1,0,n-1,i,cur);
    }
    long long ans=query(1,0,n-1,n-1,n-1);
    printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 7856
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef unsigned long long ll;
typedef pair<int,int> pint;

int main(){
    ll n,m;
    cin>>n>>m;
    if(n==1&&m==1) cout<<1<<endl;
    else if(n==1) cout<<m-2<<endl;
    else if(m==1) cout<<n-2<<endl;
    else cout<<(n-2)*(m-2)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,x,m[110];
  cin>>n>>x;
  int g=x;
  for(int i=0;i<n;i++){
     cin>>m[i];
     g-=m[i];
  }
  sort(m,m+n);
  if(g<m[0]){ cout<<n; return 0; }
  cout<<g/m[0]+n;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
ll dp[100][2][2][2];
int main()
{
	ll num;
	scanf("%lld", &num);
	dp[0][0][0][0] = 1;
	for (int i = 0; i < 62; i++)
	{
		int s = ((num&(1LL << i)) != 0);
		if (s == 0)
		{
			dp[i + 1][0][0][0] += dp[i][0][0][0];
			dp[i + 1][0][1][1] += dp[i][0][0][0];
			dp[i + 1][1][0][0] += dp[i][0][0][0];
			dp[i + 1][0][0][1] += dp[i][1][0][0];
			dp[i + 1][1][1][0] += dp[i][1][0][0];
			dp[i + 1][1][0][1] += dp[i][1][0][0];

			dp[i + 1][0][1][0] += dp[i][0][1][0];
			dp[i + 1][0][1][1] += dp[i][0][1][0];
			dp[i + 1][1][1][0] += dp[i][0][1][0];
			dp[i + 1][0][1][1] += dp[i][1][1][0];
			dp[i + 1][1][1][0] += dp[i][1][1][0];
			dp[i + 1][1][1][1] += dp[i][1][1][0];

			dp[i + 1][0][0][1] += dp[i][0][0][1];
			dp[i + 1][0][1][1] += dp[i][0][0][1];
			dp[i + 1][1][0][1] += dp[i][0][0][1];
			dp[i + 1][0][0][1] += dp[i][1][0][1];
			dp[i + 1][1][1][1] += dp[i][1][0][1];
			dp[i + 1][1][0][1] += dp[i][1][0][1];

			dp[i + 1][0][1][1] += dp[i][0][1][1];
			dp[i + 1][0][1][1] += dp[i][0][1][1];
			dp[i + 1][1][1][1] += dp[i][0][1][1];
			dp[i + 1][0][1][1] += dp[i][1][1][1];
			dp[i + 1][1][1][1] += dp[i][1][1][1];
			dp[i + 1][1][1][1] += dp[i][1][1][1];
		}
		else
		{
			dp[i + 1][0][0][0] += dp[i][0][0][0];
			dp[i + 1][0][0][0] += dp[i][0][0][0];
			dp[i + 1][1][0][0] += dp[i][0][0][0];
			dp[i + 1][0][0][0] += dp[i][1][0][0];
			dp[i + 1][1][0][0] += dp[i][1][0][0];
			dp[i + 1][1][0][0] += dp[i][1][0][0];

			dp[i + 1][0][0][0] += dp[i][0][0][1];
			dp[i + 1][0][0][1] += dp[i][0][0][1];
			dp[i + 1][1][0][0] += dp[i][0][0][1];
			dp[i + 1][0][0][1] += dp[i][1][0][1];
			dp[i + 1][1][0][0] += dp[i][1][0][1];
			dp[i + 1][1][0][1] += dp[i][1][0][1];

			dp[i + 1][0][0][0] += dp[i][0][1][0];
			dp[i + 1][0][1][0] += dp[i][0][1][0];
			dp[i + 1][1][0][0] += dp[i][0][1][0];
			dp[i + 1][0][0][0] += dp[i][1][1][0];
			dp[i + 1][1][1][0] += dp[i][1][1][0];
			dp[i + 1][1][0][0] += dp[i][1][1][0];

			dp[i + 1][0][0][0] += dp[i][0][1][1];
			dp[i + 1][0][1][1] += dp[i][0][1][1];
			dp[i + 1][1][0][0] += dp[i][0][1][1];
			dp[i + 1][0][0][1] += dp[i][1][1][1];
			dp[i + 1][1][1][0] += dp[i][1][1][1];
			dp[i + 1][1][0][1] += dp[i][1][1][1];
		}
		for (int p = 0; p < 8; p++)dp[i + 1][(p & 4) >> 2][(p & 2) >> 1][p & 1] %= mod;
	}
	printf("%lld\n", dp[62][0][0][0]);
}

Measured memory_bytes: 128