akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

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


int main() {
	ll N;
	std::cin >> N;
	
	vll B(N,0);
	rep(i, 0, N) {
		ll F;
		ll d = 1;
		rep(j, 0, 5) {
			rep(k, 0, 2) {
				std::cin >> F;
				B[i] += d * F;
				d *= 2;
			}
		}
	}

	vector<vll> P(N, vll(11));
	rep(i, 0, N) {
		rep(j, 0, 11) {
			std::cin >> P[i][j];
		}
	}


	ll ans = -1e9;
	rep(i, 1, (1LL << 10)) {
		ll tmp = 0;
		rep(j, 0, N) {
			ll cnt = 0;
			ll ol = i & B[j];
			while (ol > 0) {
				if (ol % 2==1) {
					cnt++;
				}
				ol = ol >> 1LL;
			}
			tmp += P[j][cnt];
		}
		ans = max(ans, tmp);
	}

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


Measured memory_bytes: 256
s = int(input())
m9 = 10**9

if s <= m9:
  print(0, 0, 0, 1, s, 0)
else:
  if s%m9==0:
    print(0, 0, 0, m9, int(s/m9), 0)
  else:
    res = m9 - (s%m9)
    s += res
    print(0, 0, m9, res, 1, int(s/m9))

Measured memory_bytes: 3064
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <stdlib.h>
#include <set>
typedef long long ll;
using namespace std;

int main() {

	string s1,s2,s3,w;
	int i1,i2,i3;
	vector<int>v(3);
	cin>>s1>>s2>>s3;
	i1=stoi(s1);
	i2=stoi(s2);
	i3=stoi(s3);
	v.at(0)=i1;
	v.at(1)=i2;
	v.at(2)=i3;
	sort(v.begin(),v.end(),greater<int>());
	i1=v.at(0);
	i2=v.at(1);
	i3=v.at(2);
	s1=to_string(i1);
	s2=to_string(i2);
	s3=to_string(i3);
	w=s1+s2;
	i1=stoi(w);
	i3=stoi(s3);
	cout<<i1+i3<<endl;
	return 0;
}



Measured memory_bytes: 256
/* To Kaise Hain Aaplog*/

#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define all(x) (x).begin(), (x).end()

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

int32_t main()
{
   // shuru_krte_hai_bina_kisi_bakchodi_ke();
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int s = 0;
    for(int i=1;i<n;i++){
        if(a[i]<a[i-1]){
            int x = (a[i-1]-a[i]);
            s+=x;
            a[i]+=x;
        }
    }
    cout<<s<<"\n";
    return 0;
}

Measured memory_bytes: 5104
import math

A,B = map(int, input().split())

def computeGCD(x, y): 
    if x > y: 
        small = y 
    else: 
        small = x 
    for i in range(1, small+1): 
        if((x % i == 0) and (y % i == 0)): 
            gcd = i 
              
    return gcd

def lcm(x, y):
    return (x * y) // computeGCD(x, y)

print(lcm(A, B))

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

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector<int> arr(n);
    for(int i = 0; i < n; ++i) {
        cin >> arr[i];
    }
    vector<int> memo(n);
    memo[0] = 0;
    for(int i = 1; i < n; ++i) {
        memo[i] = abs(arr[i]-arr[i-1]) + memo[i-1];
        if(i-2 >= 0) {
            memo[i] = min(memo[i], abs(arr[i]-arr[i-2]) + memo[i-2]);
        }
    }
    cout << memo[n-1] << '\n';
    return 0;
}


























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

int main(){
	int N, K;
	cin >> N >> K;
	int x[N], ans[N-K];
	ll Min = 10000000000;
	for(int i=0; i<N; i++) cin >> x[i];
	for(int i=0; i+K-1<N; i++){
		int a = min(abs(x[i]), abs(x[i+K-1]));
		ans[i] = a + x[i+K-1] - x[i];
		if(Min > ans[i]) Min = ans[i];
	}
	cout << Min << endl;
	return 0;
}

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

#define rep(i, N) for(int (i) = 0; (i) < (N); i++)
#define all(v) v.begin(), v.end()
using i64 = int_fast64_t;

int main(){
    i64 X;
    cin >> X;
    vector<i64> prime;

    vector<bool> is_prime(1e6, true);
    is_prime[0] = is_prime[1] = false;
    for(int i = 2; i*i < 1e6; i++){
        if(is_prime[i] == false) continue;
        for(int k = i+i; k < 1e6; k += i) is_prime[k] = false;
    }

    rep(i, 1e6) if(is_prime[i]) prime.emplace_back(i);

    cout << *lower_bound(all(prime), X) << endl;
}

Measured memory_bytes: 1528
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
#define mp make_pair
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll C = (ll)1e9;

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

	ll S;
	scanf("%lld", &S);
	ll x1 = (S % C);
	if (x1 != 0) x1 = C - x1;
	ll y2 = 1;
	ll y1 = C;
	ll x2 = (S + x1) / C;
	printf("0 0 %lld %lld %lld %lld\n", x1, y1, x2, y2);

	return 0;
}


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


int main() {
    int N, Y;
    cin >> N >> Y;
    rep(a, N+1) {
        rep(b,N+1-a) {
            int c = N -a -b;
            int sum = a * 10000 + b * 5000 + c * 1000;
            if (sum == Y) {
                cout << a << " " << b << " " << c << endl;
                exit(0);
            }
        }
    }
    cout << -1 << " " << -1 << " " << -1 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int

using namespace std;

const ll mod=1000000007;
const ll inf=1e18;

struct UnionFind{
  vector<ll> par;
  vector<ll> sizes;

  UnionFind(ll n) : par(n), sizes(n, 1) {
    for(ll i=0;i<n;i++) par[i] = i;
  }

  ll find(ll x) {
    if (x == par[x]) return x;
    return par[x] = find(par[x]);  // 根を張り替えながら再帰的に根ノードを探す
  }

  void unite(ll x, ll y) {
    x = find(x);
    y = find(y);
    if (x == y) return;
    if (sizes[x] < sizes[y]) swap(x, y);
    par[y] = x;
    sizes[x] += sizes[y];
  }

  bool same(ll x, ll y) {
    return find(x) == find(y);
  }

  ll size(ll x) {
    return sizes[find(x)];
  }
};

int main(){

  ll n,m,k;
  cin >> n >> m >> k;

  UnionFind tree(n);
  vector<vector<ll>> G1(n);
  for(ll i=0;i<m;i++){
    ll a,b;
    cin >> a >> b;
    G1[a-1].push_back(b-1);
    G1[b-1].push_back(a-1);
    tree.unite(a-1,b-1);
  }

  vector<vector<ll>> G2(n);
  for(ll i=0;i<k;i++){
    ll c,d;
    cin >> c >> d;
    G2[c-1].push_back(d-1);
    G2[d-1].push_back(c-1);
  }

  for(ll i=0;i<n;i++){
    ll a=tree.size(i)-1-G1[i].size();
    for(ll j=0;j<G2[i].size();j++){
      if(tree.same(i,G2[i][j]))a--;
    }
    cout << a << endl;
  }






}

Measured memory_bytes: 16736
#include <bits/stdc++.h>
#define lsb(x) (x & (-x))
#define ll long long
#define ull unsigned long long
#define Test(tt) cout << "Case #" << tt << ": "

using namespace std;



int main() {
#ifdef HOME
    ifstream cin("B.in");
    ofstream cout("B.out");
#endif
   	int	t, i;
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

	cin >> t;
	while(t--) {
		int n;
		cin >> n;

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

		string str;
		cin >> str;

		vector<int> id(60, -1);
		bool ans = 1;

		for(i = n - 1; i >= 0; i--) {
			bool found = 1;

			for(int bit = 59; bit >= 0; bit--) {
				if(values[i] & (1LL << bit)) {
					if(id[bit] != -1) {
						values[i] ^= values[id[bit]];
					}
					else {
						id[bit] = i;
						found = 0;
						break;
					}
				}
			}

			if(str[i] == '1' && found == 0) {
				ans = 0;
				break;
			}
		}

		cout << (ans ^ 1) << "\n";
	}

    return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
//#pragma GCC optimize("O3")
//#pragma GCC target ("sse4")
using namespace std;
#define PB push_back
#define all(x) (x).begin(),(x).end()
#define MEM(x,a) memset((x),a,sizeof((x)))
#define F first
#define S second
#define imx INT_MAX
#define inI(x) scanf("%d",&x)
#define inI2(x,y) scanf("%d %d",&x,&y)
#define inI3(x,y,z) scanf("%d %d %d",&x,&y,&z)
const long long MOD = (long long)(1e9+7);
const long long MMX = (long long)(1e18);
typedef long long LL;
int n,num[100005],k,cc=MOD,k2,g;
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&num[i]);
        if(k<num[i])k=num[i],g=i;
    }
    for(int i=1;i<=n;i++)
    {
        if(i==g)continue;
        if(k%2==0)
        {
            if(abs((k/2)-num[i])<cc)
            {
                cc=abs((k/2)-num[i]);
                k2=num[i];
            }
        }
        else
        {
            if(abs((k/2)-num[i])<cc)
            {
                cc=abs((k/2)-num[i]);
                k2=num[i];
            }
            if(abs(((k+1)/2)-num[i])<cc)
            {
                cc=abs(((k+1)/2)-num[i]);
                k2=num[i];
            }
        }
    }
    printf("%d %d",k,k2);
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin >> n;
    string b;
    for(int i=0;i<n;i++){
        string a;
        cin >> a;
        sort(a.begin(),a.end());
       // cout << a ;
        if(i==0){
            b=a;
        }
      //  cout << " "<<b << endl;
        int j=0;
        for(int i=0;i<a.size();i++){
            if(b.size()<=j)break;
            if(a[i]==b[j]){
                j++;
                if(b.size()<=j)break;
            }
            else{
                if (a[i]>b[j]){
                    b.erase(b.begin()+j);
                    if(b.size()<=j)break;
                    i--;
                }
                
                
            }
        }
        while(j<b.size()){
            b.erase(b.begin()+j);
          //  cout << -1<<j<<endl;
        }
    }
    cout << b << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<Float> x = new ArrayList<>();
        List<String> u = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            x.add(sc.nextFloat());
            u.add(sc.next());
        }
        float ans = 0;
        for (int i = 0; i < n; i++) {
            if (u.get(i).equals("JPY")) {
                ans += x.get(i);
            } else if (u.get(i).equals("BTC")) {
                ans += (float) 380000.0 * x.get(i).floatValue();
            }
        }
        System.out.printf("%.5f%n", ans);
    }
}


Measured memory_bytes: 24404
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
template<class T1, class T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return true;} return false; }
template<class T1, class T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return true;} return false; }
inline int popcount(int x) {return __builtin_popcount(x);}
inline int popcount(long long x) {return __builtin_popcountll(x);}
void print() { cout << "\n"; }
template<class T, class... Args>
void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////

const int B = 320;
const ll MAX = (1LL<<31)-1;
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N,Q; cin >> N >> Q;
    vector<ll> A(N,MAX);
    int sz = (N-1)/B+1;
    vector<ll> bucket(sz,MAX);
    
    while(Q--) {
        int t; cin >> t;
        if (t) {
            int l,r; cin >> l >> r;
            ll ans = MAX;
            if (l/B==r/B) {
                for (int i = l; i <= r; i++) chmin(ans,A[i]); 
            } else {
                for (int i = l; i/B == l/B; i++) chmin(ans,A[i]);
                for (int i = l/B+1; i < r/B; i++) chmin(ans,bucket[i]);
                for (int i = r/B*B; i <= r; i++) chmin(ans,A[i]);
            }
            cout << ans << ln;
        } else {
            int p,x; cin >> p >> x;
            A[p] = x;
            bucket[p/B] = MAX;
            for (int i = p/B*B; i/B == p/B and i < N; i++) chmin(bucket[p/B],A[i]);
        }
    }
}


Measured memory_bytes: 3528
#include <stdio.h>

int N;

void solve(){
	int p[N][N];
	int l[N];
	int suspect[N];
	int i,j,M,n,K;
	for(i=0;i<N;i++){
		for(j=0;j<N;j++){
			p[i][j]=0;
		}
	}
	for(i=0;i<N;i++){
		scanf("%d",&M);
		for(j=0;j<M;j++){
			scanf("%d",&n);
			p[i][n-1]=1;
		}
	}
	scanf("%d",&K);
	for(i=0;i<N;i++){
		l[i]=0;
		suspect[i]=1;
	}
	for(i=0;i<K;i++){
		scanf("%d",&n);
		l[n-1]=1;
	}
	for(i=0;i<N;i++){
		for(j=0;j<N;j++){
			if(p[i][j]==0&&l[j]==1){
				suspect[i]=0;
			}
		}
	}
	int count=0;
	for(i=0;i<N;i++){
		if(suspect[i]){
			count++;
		}
	}
	if(count==1){
		for(i=0;i<N;i++){
			if(suspect[i]){
				printf("%d\n",i+1);
			}
		}
	}else{
		printf("-1\n");
	}
	return;
}

int main(void){
	while(scanf("%d",&N),N){
		solve();
	}
	return 0;
}

Measured memory_bytes: 652
import Control.Applicative
import Data.List
import qualified Data.Set as Set
import qualified Data.IntMap as IMap

main = do
    [n,k] <- map read . words <$> getLine  :: IO [Int]
    list <- sequence (replicate n ((\[x,y]->(x,y)) . map read . words <$> getLine)) :: IO [(Int,Int)]
    print $ solve k list

solve :: Int -> [(Int,Int)] -> Int
solve k list = fd k dic
    where dic = make list


fd k dic = if b >= k then a else (fd (k-b) dic_)
    where ((a,b),dic_) = IMap.deleteFindMin dic

make :: [(Int,Int)] -> IMap.IntMap Int
make list = foldl (\acc (a,b)->append acc a (a,b)) IMap.empty list

append :: IMap.IntMap Int -> Int -> (Int,Int) -> IMap.IntMap Int
append dic key (a,b) = case mb of Nothing -> IMap.insert key b dic
                                  Just x  -> IMap.update (\y -> Just (b+y)) key dic
    where mb = IMap.lookup key dic


test = IMap.fromList [(1,3),(2,4),(3,1)]


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

typedef long long lint;
typedef pair<int, int> P;
#define REP(i, x, n) for(lint i = x ; i < n ; i++)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(lint i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())

const int IINF = 1e9 + 10;
const lint LLINF = (lint)1e18 + 10;
const lint MOD = (lint)1e9 + 7;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

lint n;

bool check(lint x){
    if(x * (x + 1) / 2 >= n){
        return true;
    }else{
        return false;
    }
}

pair<lint, lint> meguruSearch(lint ok, lint ng){
    lint mid;
    pair<lint, lint> res = make_pair(ok, 0);
    while(abs(ok - ng) > 1){
        mid = (ok + ng) / 2;
        if(check(mid)){
            ok = mid;
            res.first = mid;
            res.second = (mid * (mid + 1) / 2) - n;
        }else{
            ng = mid;
        }
    }
    return res;
}

int main(){
    cin >> n;
    pair<lint, lint> ans = meguruSearch(n+1, 0);
    REP(i, 1, ans.first + 1){
        if(i == ans.second){
            continue;
        }
        cout << i << endl;
    }
    return 0;
}

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

int main() {
  int N,L,R,X,Y;
  cin>>N;
  L=(N%1000);
  R=N%10;
  
  X=L%111;
  Y=(N-R)%111;
  
  if(X==0||Y==0){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
  
  
  
}

Measured memory_bytes: 3600
/**
 * @author Finn Lidbetter
 */
import java.util.*;
import java.io.*;
import java.awt.geom.*;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringBuilder sb = new StringBuilder();
    
    int n = Integer.parseInt(br.readLine());
    long[] arr = new long[n];
    String[] s= br.readLine().split(" ");
    for (int i=0; i<n; i++) {
      arr[i] = Long.parseLong(s[i]);
    }

    long[] b = new long[n];
    long lo = 0;
    long hi = Long.MAX_VALUE/2L;
    long mid = lo + (hi-lo)/2;
    long best = -1;
    // Get close then try smaller values
    while (lo<=hi) {
      long sum = 0;
      for (int i=0; i<n; i++) {
        long num = arr[i]-(n-1)+mid;
        long denom = n+1;
        b[i] = num/denom;
        if (num%denom!=0 && num>=0)
          b[i]++;
        if (b[i]<0)
          b[i] = 0;
        sum += b[i];
      }
      if (sum<=mid) {
        best = mid;
        hi = mid-1;
      } else {
        lo = mid+1;
      }
      mid = lo + (hi-lo)/2;
    }
    for (int j=1000; j>=0; j--) {
      if (best-j>=0) {
        mid = best-j;
        long sum = 0;
        for (int i=0; i<n; i++) {
          long num = arr[i]-(n-1)+mid;
          long denom = n+1;
          b[i] = num/denom;
          if (num%denom!=0 && num>=0)
            b[i]++;
          if (b[i]<0)
            b[i] = 0;
          sum += b[i];
        } 
        if (sum==mid) {
          System.out.println(mid);
          System.exit(0);
        }
      }
    }
    System.out.println(best);
  }
}


Measured memory_bytes: 21204
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<int,int>;

int main()
{
  string s;
  cin >> s;
  int K;
  cin >> K;
  int N = s.size();
  REP(i,N){
    if(K>='z'-s.at(i)+1&&i!=N-1&&s.at(i)!='a'){
      K-='z'-s.at(i)+1;
      s.at(i)='a';
    }else if(i==N-1&&K>0){
      K=K%26;
      if(s.at(i)+K>'z'){
        s.at(i)='a'+K-('z'-s.at(i))-1;
      }else{
        s.at(i)=s.at(i)+K;
      }
    }
  }

  cout << s << endl;
}

Measured memory_bytes: 512
// #include <iostream>
#include <stdio.h>
#include <vector>
#include <queue>
// #include <algorithm>
#define pb push_back
#define boost ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define f first
#define s second
// #define cerr if(0)cerr
using namespace std;
typedef long long LL;
typedef pair<int,LL> PILL;

const int N=1e2+10;
const int K=1e5+10;
int n,k;
int T[N];
bool DP[K];


LL maxi(LL x, LL y){if(y>x)return y;return x;}

int main()
{
  // boost;
  scanf("%d%d",&n,&k);
  for(int i=1; i<=n; i++)
    scanf("%d",&T[i]);

  for(int i=1; i<=k; i++)
  {
    bool b=1;
    for(int j=1; j<=n; j++)
      if(i-T[j]>=0)
        b=b&DP[i-T[j]];

    DP[i]|=!b;
  }
  printf(DP[k] ? "First" : "Second");

  return 0;
}


Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"

using namespace std;

const long long int MOD = 1000000007;
//const int MOD = 1000000007;
//const int MOD = 998244353;
//const long long int MOD = 998244353;

long long int N, M, K, H, W, L, R;
//int N, M, K, H, W, L, R;

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

	cin >> N >> K;
	vector<int>box(N + 1);
	for (int i = 1; i <= N; i++)box[i] = i;
	vector<vector<int>>edge(N + 1);
	for (int i = 0; i < K; i++) {
		cin >> L >> R >> M;
		edge[L].push_back(R);
		edge[R].push_back(L);
	}
	for (int i = 1; i <= N; i++) {
		if (box[i] != i)continue;
		queue<int>Q;
		Q.push(i);
		while (!Q.empty()) {
			int cn = Q.front();
			Q.pop();
			for (auto j : edge[cn]) {
				if (box[j] != i) {
					box[j] = i;
					Q.push(j);
				}
			}
		}
	}
	int ans = 0;
	for (int i = 1; i <= N; i++)ans += i == box[i];
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 6904
import java.util.Scanner;

class Main
{
	public static void main(String[] args){
	
	Scanner scan = new Scanner(System.in);
	
	int[] men = new int[7];
	int[] kari = new int[7];
	
	for(int i=1; i<=6; i++){
		men[i] = scan.nextInt();}
	
	String Ord = scan.next();
	
	char[] ord = Ord.toCharArray();
	
	for(int i=0; i<ord.length; i++){
		if(ord[i]==('N')){
			kari[1] = men[1];		kari[2] = men[2];
			kari[5] = men[5];		kari[6] = men[6];
			
			men[1] = kari[2];		men[2] = kari[6];
			men[6] = kari[5];		men[5] = kari[1];
		}
		else if(ord[i]==('S')){
			kari[1] = men[1];		kari[2] = men[2];
			kari[5] = men[5];		kari[6] = men[6];
			
			men[1] = kari[5];		men[2] = kari[1];
			men[6] = kari[2];		men[5] = kari[6];
		}
		else if(ord[i]==('E')){
			kari[1] = men[1];		kari[3] = men[3];
			kari[4] = men[4];		kari[6] = men[6];
			
			men[1] = kari[4];		men[3] = kari[1];
			men[4] = kari[6];		men[6] = kari[3];
		}
		else{
			kari[1] = men[1];		kari[3] = men[3];
			kari[4] = men[4];		kari[6] = men[6];
			
			men[1] = kari[3];		men[3] = kari[6];
			men[4] = kari[1];		men[6] = kari[4];
		}}
		System.out.println(men[1]);
	}
}


Measured memory_bytes: 26304
import java.util.*

fun main(args : Array<String>) {
    val n = readLine()!!.toInt()
    val t = HashMap<String, Int>()
    var u = 1
    (1..n).forEach {
        val s = readLine()!!
        if (t.containsKey(s)) {
            val v = t[s]!! + 1
            t[s] = v
            u = Math.max(u, v)
        } else {
            t[s] = 1
        }
    }
    val w = TreeSet<String>()
    for ((k, v) in t) {
        if (v == u) w += k
    }
    w.forEach(::println)
}


Measured memory_bytes: 89008
#include<iostream>
using namespace std;
long long gcd(long long m,long long n)
{
    long long t;
    while(n!=0)
    {
        t=m%n;
        m=n;
        n=t;
    }
    return m;
}
int main()
{
    long long i,j,k,l,total=0,n,m=1,p;
    cin>>l;
    for(i=1;i<=l;i++)
    {
        for(j=1;j<=l;j++)
        {
            p=gcd(i,j);
            for(k=1;k<=l;k++)
            {
                total+=gcd(k,p);             
            }
        }
    }
    cout<<total<<endl;
    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>

bool comp(pair<int,int> a,pair<int,int> b){
    return a.first>b.first;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    int a[n][3];
    for(int i=0;i<n;i++){
        for(int j=0;j<3;j++){
            cin>>a[i][j];
        }
    }
    for(int i=n-2;i>=0;i--){
        for(int j=0;j<3;j++){
            int x=INT_MIN;
            for(int k=0;k<3;k++){
                if(k!=j && a[i+1][k]){
                    x=max(x,a[i+1][k]);
                }
            }
            a[i][j]+=x;
        }
    }
    cout<<max(a[0][0],max(a[0][1],a[0][2]))<<endl;
}


Measured memory_bytes: 1408
/*
     ▄▀▀▀▄
▄███▀░◐░░░▌
    ▌░░░░░▐

    ▌░░░░░▐▄▄
    ▌░░░░▄▀▒▒▀▀▀▀▄
   ▐░░░░▐▒▒▒▒▒▒▒▒▀▀▄
   ▐░░░░▐▄▒▒▒▒▒▒▒▒▒▒▀▄
    ▀▄░░░░▀▄▒▒▒▒▒▒▒▒▒▒▀▄
      ▀▄▄▄▄▄█▄▄▄▄▄▄▄▄▄▄▄▀▄
           ▌▌░▌▌
           ▌▌░▌▌
         ▄▄▌▌▄▌▌ */
#include <iostream>
#include <set>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <queue>
#include <stack>
#include <cstring>
#include <ctime>

#define pb push_back
#define re return
#define fi first
#define se second
#define ll long long

using namespace std;

map <int, int> mx, m[10010];
set <int> sx, s[10010];
int a[10010], b[1000000];
vector <int> v;



int main()
{
    int a, b;
    cin >> a >> b;
    cout << a/b+min(1, a%b);

}


Measured memory_bytes: 3072
#include <stdio.h>  /*入出力*/
#include <stdlib.h> /*標準ライブラリ*/
#include <string.h> /*文字列*/
#include <math.h>   /*計算*/
#include <assert.h> /*確認*/
#include <ctype.h>  /*文字操作*/
#include <stdbool.h>/*bool型*/
#include <limits.h>/*限界*/

#define rep(i, n) for(int  i = 0; i < (n); i++)
#define max(a,b) ((a>b)?a:b)
#define ABS(a) (((a)>(0))?a:-(a))
#define LL long long
#define MOD 1000000007//10^9+7(素数)

int main(void)
{
  long long a;
  long long b;
  long long c;
  double A;
  double B;
  double C;
  double f = 0;
  double s = 0;
  double r = 0;
  scanf("%lld %lld %lld",&a, &b, &c );
/*
  A = sqrt(a);
  B = sqrt(b);
  C = sqrt(c);
  if (A+B<C) {
    printf("Yes\n");
  }else printf("No\n");
  */
  /*
  s = f + (A + r);
  r = (A+r) - (s-f);
  f = s;
  s = f + (B + r);
  r = (B + r) - (s - f);
  f = s;
  */

  //A = sqrt(a*b);
  c = c-a-b;
  if (c <= 0) {
    printf("No\n" );
    return 0;
  }
  //printf("%lf %lf\n",A , (double)c/2.0);
  if (a*b*4 < (c*c)){
    printf("Yes\n");
 }else printf("No\n");
  return 0;
}


Measured memory_bytes: 128
import java.util.HashMap;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	static class Vertex implements Comparable <Vertex> {
		int id, ticket;
		double d0;
		Vertex(int vertex, int ticket, double d0){
			this.id = vertex;
			this.ticket=ticket;
			this.d0 = d0;
		}
		public int compareTo(Vertex v) {
			if(this.d0 < v.d0)
				return -1;
			else
				return 1;
		}
	}
	
	static int inf = 100000000;
	public static void main(String args[]){
		try(Scanner sc=new Scanner(System.in)){
			while(sc.hasNext()) {
				int n=sc.nextInt();//馬車券枚数
				int m=sc.nextInt();//町数
				int p=sc.nextInt();//路線数
				int s=sc.nextInt();//出発地
				int e=sc.nextInt();//目的地
				if(n==0) break;
				double[] horse=new double[n+1];//馬車券に指定された頭数
				double[][] f=new double[m+1][m+1];//距離
				double[][] t=new double[m+1][1<<n];//頂点と使った割引券
				
				for(int i=0; i<n; i++) {
					horse[i]=sc.nextDouble();
				}
				for(int i=0; i<p; i++) {
					int a=sc.nextInt();
					int b=sc.nextInt();
					f[a][b]=f[b][a]=sc.nextDouble();
				}
				
				for(int i=1; i<=m; i++) {
					for(int j=0; j<(1<<n); j++) {
						t[i][j]=inf;
					}
				}
				t[s][0]=0;
				PriorityQueue<Vertex> pq=new PriorityQueue<Vertex>();
				pq.add(new Vertex(s, 0, 0));//頂点、チケット、所要時間
				
				Map<Integer, Double> prev=new HashMap<>();
				prev.put(s, 0.0);//頂点、所要時間
				
				while(!pq.isEmpty()) {
					Vertex u=pq.remove();
					if(prev.containsKey(u.id)) {
						double keymin=Math.min(prev.get(u.id), u.d0);
						prev.remove(u.id);
						prev.put(u.id, keymin);
					}
					else {
						prev.put(u.id, u.d0);
					}
					
					for(int i=1; i<=m; i++) {
						if(f[u.id][i]>0) {
							for(int k=0; k<n; k++) {
								if((1&u.ticket>>k)==1) {
									continue;
								}
								int nexti=u.ticket|(1<<k);
								
//								for(int j=0; j<n; j++) {
//									if((1&u.ticket>>j)==1)
//										System.out.print(1);
//									else
//										System.out.print(0);
//								}
//								System.out.print(" ");
//								for(int j=0; j<n; j++) {
//									if((1&nexti>>j)==1)
//										System.out.print(1);
//									else
//										System.out.print(0);
//								}
//								System.out.print(" ");
//								
								double alt=u.d0+f[u.id][i]/horse[k];
//								System.out.println("u.d0="+u.d0+"new="+(alt-u.d0));
//								System.out.println("now="+u.id+" i="+i+" "+alt);
								if(t[i][nexti]>alt) {
									t[i][nexti]=alt;
									pq.add(new Vertex(i, nexti, alt));
								}
							}
						}
					}
				}

				System.out.println((prev.get(e)==null)? "Impossible" : prev.get(e));
				
			}
		}
	}
} 


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


def main():
    s = input()
    n = len(s)
    k = int(input())
    candidates = set()

    for j in range(min(n, k)):
        for i in range(n - j):
            candidates.add(s[i:i + j + 1])

    print(sorted(candidates)[k - 1])


if __name__ == '__main__':
    main()


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

int r[12] = {31,28,31,30,31,30,31,31,30,31,30,31};

int main(){
  int m1, d1;
  int m2, d2;
  cin>>m1>>d1;
  cin>>m2>>d2;
  int x = r[m1-1];
  if(x == d1){
    cout<<1<<endl;
    return 0;
  }
  else cout<<0<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(int (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num,init) vector<ll> name((num),(init));
#define op(i) cout<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define mat(name,fnum,snum,init); vector<vector<ll>> name((fnum),vector<ll>((snum),(init)));
#define debugP int debug_point; cin>>debug_point;
template <typename T>
void putv(vector<T>& V){
	// cout << "The elements in the vector are: " << endl;
	for(auto x: V)
		cout << x << " ";
	cout << endl;
}
template <class T>
vector<T> getv(ll n){
	vector<T> Vector_temp;
	rep(i,n){
		T input;
		cin >> input;
		Vector_temp.emplace_back(input);
	}
	return Vector_temp;
}
/* <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3*/
ll gcd(ll c,ll b){

    while(1){
        if(c%b!=0){
        ll tmp=b;
        b=c%b;
        c=tmp;
        }else{
            return b;
        }
    }
}

int main(){
    ll n;
    ll ans=1;
    cin>>n;
    vec(a,n,0);
    a=getv<ll>(n);
    sort(all(a));
    for(int i=0;i<n-1;i++){
        a[i+1]=(a[i]/gcd(a[i],a[i+1]))*a[i+1];
    }
    cout<<a[n-1]<<endl;
    return 0;
}

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

int main(void){
    int n;
    ll d;
    cin >> n >> d;
    int cnt = 0;
    for(int i=0;i<n;i++){
        ll x,y;
        cin >> x >> y;
        if(x*x+y*y<=d*d) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3560
import math
text = input()
reply = "Yes"

if text != text[::-1]:
    reply = "No"

tmp = text[0:math.floor((len(text)-1)/2)]
if tmp != tmp[::-1]:
    reply = "No"

text = text[::-1]
tmp = text[0:math.floor((len(text) -1)/2)]
if tmp !=tmp[::-1]:
    reply = "No"

print(reply)

Measured memory_bytes: 38384
// abc161_a
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int a,b,c;
    cin >> a >> b >> c;

    print(c, a, b);


    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>
#include<bitset>
#include<utility>

#define PB push_back
#define ALL(a)  (a).begin(),(a).end()
#define all(v) begin(v), end(v)
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)

using namespace std;

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

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int inf = (int)1e9;
const ll INF = (ll)1e18;
const ll MOD{ (ll)1e9 + 7 };
const long double EPS = 1e-10;

int main() {
	string s;
	cin >> s;
	string ans = "AC";
	if (s[0] != 'A') {
		ans = "WA";
	}
	int cnt = 0;
	for (int i = 1; i < (int)s.size(); i++) {
		if (isupper(s[i])) {
			if (i == 1 || i == (int)s.size() - 1 || s[i] != 'C') {
				ans = "WA";
			}
			cnt++;
		}
	}
	if (cnt != 1) {
		ans = "WA";
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;
using ll = long long int;
const int MOD = 998244353;

int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	int h, w; cin >> h >> w;
	vector<string> g(h);
	vector<array<int, 2>> dir = {{0, 1}, {1, 0}};
	for (int i = 0; i < h; ++i)
	{
		cin >> g[i];
	}
	int cost[h][w]; memset(cost, 0, sizeof cost);
	queue<array<int, 2>> q;
	int mx = g[0][0] == '.' ? 1 : 2;
	cost[0][0] = mx;
	vector<array<int, 2>> nxt = {{0, 0}};
	while (cost[h-1][w-1] == 0)
	{
		for (auto it : nxt)
			q.push(it);
		nxt.clear();
		while (!q.empty())
		{
			auto it = q.front(); q.pop();
			int x = it[0], y = it[1];
			for (auto it2 : dir)
			{
				int X = x + it2[0], Y = y + it2[1];
				if (X >= h or Y >= w) continue;
				if (cost[X][Y]) continue;
				if (g[x][y] == g[X][Y]) {cost[X][Y] = mx; q.push({X, Y}); continue;}
				else {cost[X][Y] = mx+1; nxt.pb({X, Y});}
			}
		}
		++mx;
	}
	cout << cost[h-1][w-1]/2 << '\n';
}

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

int n;
vector<int> taro, hanako;

#define TARO 0
#define HANAKO 1

int taro_pt, hanako_pt;

void solve() {
    int field = 0;
    int turn = TARO;
    while (true) {
loop_start:
        if (taro.empty()) {
            taro_pt = hanako.size();
            break;
        }
        if (hanako.empty()) {
            hanako_pt = taro.size();
            break;
        }
        if (turn == TARO) {
            for (vector<int>::iterator i = taro.begin(); i != taro.end(); i++) {
                if (*i > field) {
                    field = *i;
                    taro.erase(i);
                    turn = HANAKO;
                    goto loop_start;
                }
            }
            turn = HANAKO;
            field = 0;
        } else {
            for (vector<int>::iterator i = hanako.begin(); i != hanako.end(); i++) {
                if (*i > field) {
                    field = *i;
                    hanako.erase(i);
                    turn = TARO;
                    goto loop_start;
                }
            }
            turn = TARO;
            field = 0;
        }
    }
}

int main() {
    while (cin >> n) {
        if (n == 0) break;
        taro.clear(); hanako.clear();
        taro_pt = hanako_pt = 0;
        for (int i = 0; i < n; i++) {
            int taro_c; cin >> taro_c;
            taro.push_back(taro_c);
        }
        sort(taro.begin(), taro.end());
        for (int i = 1; i <= 2 * n; i++) {
            if (find(taro.begin(), taro.end(), i) == taro.end())
                hanako.push_back(i);
        }
        solve();
        cout << taro_pt << endl;
        cout << hanako_pt << endl;
    }
    return 0;
}

Measured memory_bytes: 0
N,x = map(int,(input().split()))
a = list(map(int,(input().split())))

ans = 0
for i in range(N-1):
    s = a[i] + a[i+1]
    if s > x:
        if a[i+1] < s-x:
            a[i+1] = 0
            a[i] -= s-x-a[i+1]
        else:
            a[i+1] -= s-x
        ans += s-x

print(ans)

Measured memory_bytes: 63984
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader input =new BufferedReader (new InputStreamReader (System.in));
		String str = input.readLine( );
		int n = Integer.parseInt(str);

		str = input.readLine( );
		String[] strlist = str.split(" ");
		int[] list = new int[n*2];
		for(int i=0; i<n*2; i++){
			list[i] = Integer.parseInt(strlist[i]);
		}

		Arrays.sort(list);

		int answer = 0;

		for(int i=0; i<n; i++){
			answer = answer + list[i*2];
		}

		System.out.println(answer);
	}
}


Measured memory_bytes: 20692
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef std::int_fast64_t i64;
typedef std::uint_fast64_t u64;
typedef std::int_fast32_t i32;
typedef std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(std::vector<T>& vector, const typename std::vector<T>::size_type size) {
    vector.reserve(size);
    std::copy_n(std::istream_iterator<T>(std::cin), size, std::back_inserter(vector));
  }

  template <typename T, std::size_t N>
  void read(std::array<T, N>& array) {
    std::copy_n(std::istream_iterator<T>(std::cin), N, array.begin());
  }
}

#endif

// main.cpp

int main() {
  i64 A, B;
  std::cin >> A >> B;
  std::cout << (B % A == 0 ? A + B : B - A) << std::endl;
  return 0;
}

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


int main(void) {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n){
        cin >> a.at(i);
    }
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    int alice = 0,bob = 0;
    rep(i,n){
        if((i + 1) % 2 > 0)alice += a.at(i);
        else bob += a.at(i);
    }
    cout << alice - bob << endl;

}


Measured memory_bytes: 256
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
N,K = parseMap(split(readline()))

snuke_list = zeros(N)
for i in 1:K
    d = parseInt(readline())
    A = parseMap(split(readline()))
    for a in A
        snuke_list[a] = 1
    end
end
ans = 0
for s in snuke_list
    if s == 0
        ans += 1
    end
end
println(ans)
end

main()

Measured memory_bytes: 166520
#include<iostream>
#include<vector>
#include<string.h>

using namespace std;

int main(void){

    char weather[3][10] = {"Sunny", "Cloudy", "Rainy"};

    char n[10];

    cin >> n;

    for(int i = 0;i < 3;i++){
        if(strcmp(n, weather[i]) == 0){
            if(i == 2){
                cout << weather[0] << endl;
            }else{
                cout << weather[i+1] << endl;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int func(int n) {
	long long memo[100] = { 0 };
	memo[1] = 1;
	memo[2] = 2;
	memo[3] = 4;
	for (int i = 4; i <= n; i++) {
		memo[i] += memo[i - 1] + memo[i - 2] + memo[i - 3];
	}
	return memo[n] / (10 * 365) + 1;
}

int main() {
	int N;
	while (cin >> N) {
		if (N == 0) {
			break;
		}
		cout << func(N) << endl;
	}
}

Measured memory_bytes: 1160
import java.util.*;

public class Main{
	public static List<List<Integer>> to = new ArrayList<>();
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int Q = sc.nextInt();
		
		for(int i=0;i<N+10;i++) to.add(new ArrayList<Integer>());
		
		//辺を全て貼る
		for(int i=0;i<N-1;i++) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			//双方向に辺を貼る
			to.get(a).add(b);
			to.get(b).add(a);
		}
		//頂点に値を加える。
		int cnt[] = new int[N];
		for(int i=0;i<Q;i++) {
			int p = sc.nextInt();
			int x = sc.nextInt();
			cnt[p-1] += x;	
		}
		dfs(1,-1,cnt);
		StringBuilder sb = new StringBuilder();
		for(int tmp:cnt) {
			sb.append(tmp);
			sb.append(" ");
		}
		System.out.println(sb.toString());
	}
	static void dfs(int v, int f, int[] cnt) {
		for(int tmp:to.get(v)) {
			if (tmp==f)continue;//親については何もしない
			cnt[tmp-1]+=cnt[v-1];
			dfs(tmp, v, cnt);
		}
	}
}


Measured memory_bytes: 212856
#include <iostream>
using namespace std;
int main(){
int N;
  cin>>N;
  if((N%10==2)||(N%10==4)||(N%10==5)||(N%10==7)||(N%10==9)){
cout<<"hon"<<endl;
  }else if(N%10==3){
    cout<<"bon"<<endl;
  }else{
cout<<"pon"<<endl;
  }
}


Measured memory_bytes: 3588
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int ai = 0;
int bi = 0;
int N, M, K;
vector<ll> a;
vector<ll> b;
bool isOK(int index, int key) {
    if (b[index] <= key) return true;
    else return false;
}
int binary_search(int key) {
    int ng = b.size(); //「index = 0」が条件を満たすこともあるので、初期値は -1
    int ok = -1; // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

    /* ok と ng のどちらが大きいかわからないことを考慮 */
    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;

        if (isOK(mid, key)) ok = mid;
        else ng = mid;
    }
    return ok;
}
int main(){
    int ans = 0;

    cin >> N >> M >> K;
  	a.assign(N+1,0);
  	b.assign(M+1,0);
    int ai = N+1;
    for (int i = 1; i < N+1; i++)
    {
        cin >> a[i];
    }
    for (int i = 1; i < N+1; i++)
    {
        a[i] += a[i-1];
    }
    
    for (int i = 1; i < M+1; i++)
    {
        cin >> b[i];
    }
     for (int i = 1; i < M+1; i++)
    {
        b[i] += b[i-1];
    }
    for (int i = 0; i < N+1; i++)
    {
      	if(a[i]>K)break;
        int tmp = K-a[i];
        ans = max(ans, i+binary_search(tmp));
    }
    
    
    cout << ans << endl;
}

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

using namespace std;

typedef long long ll;

using V = vector<int>;
using Q = queue<int>;
using Graph = vector<vector<int>>;

#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x
#define inn(x, y) int x,y;cin>>x>>y
#define innn(x, y, z) int x,y,z;cin>>x>>y>>z
#define bit(n) (1<<(n))

#define out(x) cout<<(x)<<endl
#define outt(x,y) cout<<(x)<<" "<<(y)<<endl
#define err(x) cerr<<(x)<<endl
#define errr(x,y) cerr<<(x)<<" "<<(y)<<endl
#define errrr(x,y,z) cerr<<(x)<<" "<<(y)<<" "<<(z)<<endl

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

#define lim5 200010
#define lim9 1000000010

#define deg(_rad) (((_rad)/2/M_PI)*360)
#define rad(_deg) (((_deg)/360)*2*M_PI)
#define mid(min, max) ((min + max) / 2)

int main() {
	inn(n, k);
    V a(n);
	rep(i, n) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	ll ans = 0;
	rep(i, k) {
		ans += a[i];
	}
	out(ans);
    return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX;
typedef long long ll;
using namespace std;

int main(){
  int n,m; cin >> n >> m;
  map<int,int> ac;
  map<int,int> wa;
  vector<bool> flag(n);
  rep(i,m){
    int x; cin >> x;
    string result; cin >> result;
    if(result=="AC"){
      ac[x]++;
      flag.at(x-1) = true;
    }
    if(result=="WA"){
      if(!flag.at(x-1)) wa[x]++;
    }
  }

  int correct = ac.size();
  int wrong =0;
  for(auto x:wa){
    if(flag.at(x.first-1)) wrong+=x.second;
  }
  cout << correct << " " << wrong <<endl;
}

Measured memory_bytes: 4992
#include"bits/stdc++.h"
using namespace std;

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

	char old_char = 0;
	int old_length;
	int now_length;
	int cnt = 0;
	for (int i = 0;i < s.size();i++) {
		if (s[i] == old_char) {
			i++;
			if (i == s.size()) {
				break;
			}
			old_char = 0;
			cnt++;
			continue;

		}
		else {
			cnt++;
			old_char = s[i];
		}

	}
	cout << cnt << endl;
	return 0;
}


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

int main(){
  int N;
  cin >> N;
  if((N-3)%10==0){
    cout << "bon" << endl;
  }else if(N%10==0||(N-1)%10==0||(N-6)%10==0||(N-8)%10==0){
    cout << "pon" << endl;
  }else{
    cout << "hon" << endl;
  }
}
    

Measured memory_bytes: 3636
#include <iostream>
#include <vector>

std::vector<int> g;
int total_count = 0;

template<typename T>
void insertion_sort(std::vector<T>& a, std::size_t n, int g) {
    for (int i = g; i < n; ++i) {
        auto v = a[i];
        auto j = i - g;
        while (j >= 0 && a[j] > v) {
            a[j + g] = a[j];
            j = j - g;
            total_count++;
        }
        a[j + g] = v;
    }
}

template<typename T>
int shell_sort(std::vector<T> &a, std::size_t n) {
    // generate sequence: g[n + 1] = 3g[n] + 1
    auto h = 1;
    while (true) {
        if (h > n) {
            break;
        }
        g.push_back(h);
        h = 3 * h + 1;
    }

    for (int i = static_cast<int>(g.size()) - 1; i >= 0; i--) {
        insertion_sort(a, n, g[i]);
    }
}


int main() {
    std::size_t n;
    std::cin >> n;
    std::vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        std::cin >> a[i];
    }

    shell_sort(a, n);

    std::cout << g.size() << std::endl;
    for (int j = static_cast<int>(g.size()) - 1; j >= 0; j--) {
        std::cout << g[j];
        if (j != 0) {
            std::cout << " ";
        }
    }
    std::cout << std::endl;
    std::cout << total_count << std::endl;
    for (std::size_t k = 0; k < n; ++k) {
        std::cout << a[k] << std::endl;
    }

    return 0;
}


Measured memory_bytes: 6780
#include <iostream>
#include <string>
#include <vector>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main() {
  string a, b;
  cin >> a >> b;
  a += b;
  int c = std::stoi(a);

  rep(i, c) {
    if (i * i == c) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
try:
    from typing import List
except ImportError:
    pass


def solve(N: int, K: int, S: str):
    d = []  # type: List[int]
    i = 0
    while True:
        r = 0
        while i < N and S[i] == "1":
            r += 1
            i += 1
        d.append(r)
        if i >= N:
            break
        s = 0
        while i < N and S[i] == "0":
            s += 1
            i += 1
        d.append(s)
    c = 2 * K + 1
    if c > len(d):
        print(sum(d))
        return
    dl = 0
    acc = sum(d[:c])
    ans = acc
    while dl + c + 2 <= len(d):
        acc += d[dl + c] + d[dl + c + 1] - d[dl] - d[dl + 1]
        ans = max(ans, acc)
        dl += 2
    print(ans)


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
    K = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, K, S)


if __name__ == '__main__':
    main()


Measured memory_bytes: 4596