akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef pair<pii,pii> P;
typedef tuple<ll,ll,ll> tl;
typedef pair<double,double> pdd;
typedef vector<vector<ll>> mat;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll mod5=1000000009;
ll inf=1LL<<62;
double pi=3.141592653589793238462643383279L;
double eps=1e-14;
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
#define mrep(itr,mp) for(auto& itr:mp)
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#define umh unordered_map<ll,ll,custom_hash>
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll c=gcd(a,b);
    return a*b/c;
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
    now%=md;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
ll popcount(ll n){
    ll ret=0;
    ll u=n;
    while(u>0){
        ret+=u%2;
        u/=2;
        
    }
    return ret;
}

int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    set<string> st;
    int n;cin>>n;
    rep(i,0,n){
        string s;cin>>s;
        st.insert(s);
    }
    cout<<st.size()<<endl;
}


Measured memory_bytes: 19208
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <unordered_map>
#include <set>
#include <algorithm>
#include <utility>
#include <cmath>
using namespace std;

typedef long long llong;
typedef unsigned long long ullong;
// -2.1e-9 <= int <= 2.1e9
// -9.2e-18 <= long long <= 9.2e18
// 0 <= unsigned int <= 4.2e9
// 0 <= unsigned long long <= 18.4e18
// cout << fixed << setprecision(10);

int main() {
    uint N, Q;
    cin >> N >> Q;

    string S;
    cin >> S;

    vector<int> Sum(N+1, 0);
    bool afterA = false;
    int match = 0;

    for (uint i=0; i<N; i++) {

        if (S[i] == 'A') {
            afterA = true;
        }
        else if ((S[i] == 'C') && (afterA)) {
            ++match;
            afterA = false;
        }
        else {
            afterA = false;
        }
        Sum[i+1] = match;
    }

    for (uint q=0; q<Q; q++) {

        uint l, r;
        cin >> l >> r;

        --l;
        --r;
        if ((l >= 1) && (S[l-1] == 'A') && (S[l] == 'C'))
            ++l;
        int ans = Sum[r+1] - Sum[l];
//        if ((l >= 1)
//            && (S[l-1] == 'A') && (S[l] == 'C')) {
//            ans -= 1;
//        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 1408
import sys
import os

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]


def fc(n):
    for p in range(2, n):
        if n % p == 0:
            return False
    else:
        return True


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    while True:
        if fc(N):
            print(N)
            exit()
        N += 1


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

lli up(lli a,lli b){
	if(a%b==0)return a/b;
	else return a/b+1;
}

signed main(){

	string s,t;
	cin>>s>>t;
	map<char,vector<lli>> data;

	lli size = s.size();

	REP(i,0,size){
		data[s.at(i)].push_back(i);
	}

	lli sum=0;

	REP(i,0,t.size()){
		char now = t.at(i);

		auto pos = lower_bound(data[now].begin(),data[now].end(),sum%size);
		if(pos == data[now].end()){
			sum = up(sum,size)*size;

			auto pos2 = lower_bound(data[now].begin(),data[now].end(),sum%size);
			if(pos2 == data[now].end()){
				cout<<-1<<endl;
				return 0;
			}
			sum += *pos2 -sum%size;
		}
		else{
			sum += *pos - sum%size;
		}
		sum++;
	}
	cout<<sum<<endl;

	return 0;
}

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

#define LL long long
#define Dl double
#define Pb push_back
#define Po pop_back
#define Mp make_pair
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)

using namespace std;

typedef vector<LL> Vl;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef vector<Pll> Vpl;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
#define X first
#define Y second

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

    LL L = s.size();

    if(L == 2 && s[0] == s[1])
        return cout << "1 2\n", 0;

    for(LL i = 0; i <= L - 3; i++){
        if(s[i] == s[i + 1] || s[i + 1] == s[i + 2] || s[i] == s[i + 2])
            return cout << i + 1 << ' ' << i + 3 << '\n', 0;
    }

    cout << "-1 -1\n";
    return 0;
}



Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<bool>> vvbool;

const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const double PI = 3.14159265358979323846264338327950288;
//========================================================================


int main() {

	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	//==================================


	ll N;
	cin >> N;
	vll A(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}

	int n_odd = 0;
	for (int i = 0; i < N; i++) {
		n_odd += (A[i] % 2 == 1);
	}

	
	if (n_odd %2 == 1) {
		cout << "NO";
	}
	else {
		cout << "YES";
	}

}


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

int main() {
  int n;
  cin >> n;
  int ans = 0;
  for (int i = 1;; i++) {
    ans = i * i;
    if (ans > n) {
      ans = (i - 1) * (i - 1);
      cout << ans << endl;
      break;
    }
  }
}

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

int main() {
	long long int A;
	string str;
	int B;
	cin >> A >> str;
	B = (str[0] - '0') * 100 + (str[2] - '0') * 10 + (str[3] - '0');

	long long int output = A * B;
	output /= 100;
	cout << output << endl;

	return 0;
}

Measured memory_bytes: 3612
#include <stdio.h>

int main()
{
	int a, b, ans;
	char c;

	while (1)
	{
		scanf("%d %c %d", &a, &c, &b);

		if (c == '+')
		{
			ans = a + b;
		}
		else if (c == '-')
		{
			ans = a - b;
		}
		else if (c == '*')
		{
			ans = a * b;
		}
		else if (c == '/')
		{
			ans = a / b;
		}
		else if (c == '?')
		{
			return 0;
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 600
#include <cstdio>
#include <vector>
#include <algorithm>
#include <queue>
#include <utility>

using namespace std;

template <class T>
using lp_queue=priority_queue<T, deque<T>, greater<T>>;

using Weight=long long;
static const Weight INF=1LL<<57;

struct Edge {
    size_t src, dst;
    Weight weight;
    Edge() {}
    Edge(size_t src, size_t dst, Weight weight=1):
        src(src), dst(dst), weight(weight)
    {}
};

bool operator<(const Edge &e, const Edge &f) {
    if (e.weight != f.weight) {
        return e.weight > f.weight;
    } else {
        return e.src!=f.src? e.src<f.src : e.dst<f.dst;
    }
}

using Edges=vector<Edge>;
using Vertex=vector<Edge>;
using Graph=vector<Vertex>;

void join(Graph &g, size_t s, size_t d, Weight w=1) {
    // non-directed
    g[s].push_back(Edge(s, d, w));
    g[d].push_back(Edge(d, s, w));
}

void connect(Graph &g, size_t s, size_t d, Weight w=1) {
    // directed
    g[s].push_back(Edge(s, d, w));
}

vector<vector<Weight>> shortest_distance(Graph &g) {
    /* Johnson */
    size_t V=g.size();
    vector<Weight> h(V);
    for (size_t k=0; k<V; ++k)
        for (size_t i=0; i<V; ++i)
            for (const Edge &e: g[i])
                if (h[e.dst] > h[e.src] + e.weight) {
                    h[e.dst] = h[e.src] + e.weight;
                    if (k == V-1)
                        return vector<vector<Weight>>();
                }

    for (size_t i=0; i<V; ++i)
        for (Edge &e: g[i])
            e.weight += h[e.src] - h[e.dst];

    vector<vector<Weight>> d(V, vector<Weight>(V, INF));
    for (size_t s=0; s<V; ++s) {
        d[s][s] = 0;
        lp_queue<pair<Weight, size_t>> q; q.push(make_pair(0, s));
        while (!q.empty()) {
            pair<Weight, size_t> p=q.top(); q.pop();
            size_t v=p.second;
            if (d[s][v] < p.first) continue;

            for (const Edge &e: g[v])
                if (d[s][e.dst] > d[s][v] + e.weight) {
                    d[s][e.dst] = d[s][v] + e.weight;
                    q.push(make_pair(d[s][e.dst], e.dst));
                }
        }

        for (size_t u=0; u<V; ++u)
            if (d[s][u] < INF)
                d[s][u] += h[u] - h[s];
    }

    for (size_t v=0; v<V; ++v)
        for (Edge &e: g[v])
            e.weight += h[e.dst] - h[e.src];

    return d;
}

int main() {
    size_t V, E;
    scanf("%zu %zu", &V, &E);

    Graph g(V);
    for (size_t i=0; i<E; ++i) {
        size_t s, t;
        Weight d;
        scanf("%zu %zu %lld", &s, &t, &d);

        connect(g, s, t, d);
    }

    vector<vector<Weight>> d=shortest_distance(g);
    if (d.empty())
        return !printf("NEGATIVE CYCLE\n");

    for (vector<Weight> &w: d)
        for (size_t i=0; i<V; ++i)
            if (w[i] < INF) {
                printf("%lld%c", w[i], i<V-1? ' ':'\n');
            } else {
                printf("INF%c", i<V-1? ' ':'\n');
            }

    return 0;
}

Measured memory_bytes: 2912
//
#include <vector>
#include <set>
#include <array>
#include <iostream>
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <numeric>
#include <bitset>
//
using ll = long long;
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);++i)
inline void yes(bool cond) { cond ? puts("Yes") : puts("No"); }
template<typename Type> inline void chmin(Type& a, Type b) { if (a > b) a = b; }
template<typename Type> inline void chmax(Type& a, Type b) { if (a < b) a = b; }
#define BIGP   1000000007
#define INF_I  std::numeric_limits<ll>::max()
#define INF_F  std::numeric_limits<float>::infinity()
//
int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    ll X;
    cin >> X;
    yes(30 <= X);
}

Measured memory_bytes: 3128
n = int(input())
s_list = [input() for i in range(n)]
m = int(input())
t_list = [input() for j in range(m)]


def list_diff(list1, list2):
    result = list1.copy()
    for val in list2:
        if val in result:
            result.remove(val)
    return result


def count_max(diff_list):
    cnt_list = [diff_list.count(ele) for ele in set(diff_list)]
    if len(cnt_list) != 0:
        return max(cnt_list)
    else:
        return 0


lst = list_diff(s_list, t_list)
print(count_max(lst))

Measured memory_bytes: 3064
///বিসমিল্লাহির_রহমানির_রহীম
#include<bits/stdc++.h>
#define     pie                          acos(-1)
#define     N                            2000005
#define     ESP                          1e-9
#define     pii                          pair<int,int>
#define     pb                           push_back
#define     pp                           pop_back
#define     ff                           first
#define     ss                           second
#define     nl                           "\n"
#define     MOD                          1000000007
#define     sp                           " "
#define     CLR(a)                       memset(a,0,sizeof(a))
#define     SET(a)                       memset(a,-1,sizeof(a))
#define     mk                           make_pair
#define     ALL(x)                       x.begin(),x.end()
#define     SZ(x)                        (int)(x).size()
using namespace std;
int dx[]={0,0,1,-1,-1,-1,1,1};
int dy[]={1,-1,0,0,-1,1,1,-1};
typedef long long ll;
typedef long double ld;
int main(){
    ios_base::sync_with_stdio(false); cout.setf(ios::fixed); cout.precision(10);
    cin.tie(nullptr);  cout.tie(nullptr);
    // freopen ("output.txt","w",stdout);
    // freopen ("input.txt","r",stdin);
    int a,b,c;
    cin>>a>>b>>c;
    if((c>a&&c<b)||(c<a&&b<c)) cout<<"Yes"<<nl;
    else cout<<"No"<<nl;

    return 0;
}


Measured memory_bytes: 256
// Problem : A. String Similarity
// Contest : Codeforces - Educational Codeforces Round 94 (Rated for Div. 2)
// URL : https://codeforces.com/contest/1400/problem/0
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long 	
int mod=1e9+7;
int po(int x,int y,int m)  { if (y==0) return 1; int t=po(x,y/2,m)%m; t=(t*t)%m; if (y&1) return (t*x)%m;	return t%m; }

signed main() {

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

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   	int d,t,s;
  cin>>d>>t>>s;
  if (t*s<d)
	cout<<"No"<<endl;
  else
    cout<<"Yes"<<endl;
   
   	return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int x, n;
  cin >> x >> n;
  int sum = 0;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    sum += x;
  }
  if (sum >= x) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
  return 0;
}

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


int H, W;
char m[102][102];
int d[4][2]={{1,0},{-1,0},{0,1},{0,-1}};

int dfs(int x, int y, char c){
	if(m[x][y]!=c || !m[x][y]) return 0;
	m[x][y] = 0;
	for(int i=0;i<4;i++) dfs(x+d[i][0], y+d[i][1], c);
	return 1;
}


main(){
	int i,j;
	while(cin >> H >> W, H){
		memset(m, 0, sizeof(m));
		int ans=0;
		for(i=1;i<=H;i++) if(!(cin>>&m[i][1]))return 0;
		for(i=1;i<=H;i++){
			for(j=1;j<=W;j++){
				ans += dfs(i,j,m[i][j]);
			}
		}
		
		cout << ans << endl;
	}
}

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

#define ll long long
#define f(i, a, b) for(ll i=a;i<b;i++)
#define fi(i, a, b) for(ll i=b-1;i>=a;i--)
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
#define ml map<ll,ll>
#define pll pair<ll,ll>
int main(){
  int x,n;
  cin>>x>>n;
  if(n==0){
    cout<<x;
  }else{
  vector<int>vec(101,0);
   map<int,int>mp;
   for(int i=-110;i<=110;i++){
     mp[i]=0;
   }
  for(int i=0;i<n;i++){
    int a;
    cin>>a;
    mp[a]=1;;
  }
  int mini=INT_MAX;
int num;

  for(int i=-110;i<=110;i++){
    if( mp[i]==0 && abs(x-i) < mini ){
      mini=abs(x-i);
      num=i;
     }

    }
  cout<<num;
    }
}


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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")

int main()
{

	string S;
	cin >> S;
	int ans = INT_MAX;
	bool flag = true;
	fx(S.size()-1) {
		if (S[x]!=S[x+1]) {
			ans = min(ans,max(x+1,(int)S.size()-x-1));
			flag = false;
		}
	}
	if (flag) {
		ce(S.size())
		
	}
	else {
		ce(ans)
	}
    return 0;
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin >> n;
	vector<int> cat(n);
	int res = 0;
	for (int q = 0; q < n; q++)
	{
		cin >> cat[q];
		res ^=cat[q];
	}
	for (int q = 0; q < n; q++)
	{
		cout << (cat[q] ^ res) << " ";
	}
	cout << "\n";
	return 0;
}


Measured memory_bytes: 3912
import java.io.*;
import java.util.*;
public class Main{
    public static void main(String[] args) throws IOException{
        MyReader r = new MyReader();    
        int N;
        long K;
        {long[] a = r.ll(); N = (int)a[0]; K = a[1];}
        long[] num = new long[100001];
        for(int i = 0; i < N; i++){
            int[] c = r.ii();
            num[c[0]] += c[1];
        }
        long k = 0;
        for(int i = 1; i < 100001; i++){
            k += num[i];
            if(k >= K){
                println(i);
                return;
            }   
        }
    }

    static void print(Object o){
        System.out.print(o.toString());
    }

    static void println(Object o){
        System.out.println(o.toString());
    }

    static int Int(String s){
        return Integer.parseInt(s);
    }

    static long Long(String s){
        return Long.parseLong(s);
    }

    static class MyReader extends BufferedReader{
        void read(Integer a) throws IOException{
            a = i();
        }
        MyReader(){
            super(new InputStreamReader(System.in));
        }

        String s() throws IOException{
            return readLine();
        }

        String[] ss() throws IOException{
            return s().split(" ");
        }

        int i() throws IOException{
            return Int(s());
        }

        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++) ii[j] = Integer.parseInt(ss[j]);
            return ii;
        }

        long l() throws IOException{
            return Long(s());
        }

        long[] ll() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            long[] ll = new long[size];
            for(int j = 0; j < size; j++) ll[j] = Long.parseLong(ss[j]);            
            return ll;
        }

        void ii(int[] ii) throws IOException{
            for(int i = 0; i < ii.length; i++) ii[i] = i();
        }
    }
}

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

int main()
{
	int n, k;
	cin >> n >> k;
	int a[n];
	int dp[k+1];
	memset(dp, 0, sizeof(dp));

	for(int i=0; i<n; i++)
	{
		cin >> a[i];
		dp[a[i]] = 1;
	}

	for(int i = a[0]; i <= k; i++)
	{
		for(int j = 0; j < n and !(dp[i]); j++)
		{
			if(i >= a[j]  && !dp[i - a[j]])
			{
				dp[i] = 1;
				break;
			}
		}
	}

	if(dp[k])
		cout << "First";
	else
		cout << "Second";
	return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define PP pair<P,P>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;
template<class T> inline void chmax(T& a, T b) { a = max(a, b); }
template<class T> inline void chmin(T& a, T b) { a = min(a, b); }

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
int get_rand(int MIN, int MAX) {
	random_device rnd;
	mt19937_64 mt64(rnd());
	uniform_int_distribution<int>engine(MIN, MAX);
	return engine(mt64);
}
/*--------Library Zone!--------*/

string s, t;
int ans;
set<int>st[30];
signed main() {
	cin >> s >> t;
	rep(i, s.size()) {
		st[s[i] - 'a'].insert(i);
	}
	int now = -1;
	rep(i, t.size()) {
		if (st[t[i] - 'a'].upper_bound(now) != st[t[i] - 'a'].end()) {
			now = *st[t[i] - 'a'].upper_bound(now);
		}
		else if (st[t[i] - 'a'].size()) {
			ans++; now = *st[t[i] - 'a'].begin();
		}
		else {
			cout << -1 << endl; return 0;
		}
	}
	cout << ans * s.size() + now + 1 << endl;
}


Measured memory_bytes: 5120
// In the name of God

#include <bits/stdc++.h>

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	vector<int> v(5);
	
	for(int i = 0; i < 5; i++) cin >> v[i];

	auto solve = [](vector<int> v) {
		int t = 0;
		for(int i = 0; i < v.size(); i++) {
			if(t % 10 != 0) {
				t += 10 - t % 10;
			}
			t += v[i];
		}
		return t;
	};

	int ans = 1e9;

	do {
		ans = min(ans, solve(v));
	} while(next_permutation(v.begin(), v.end()));
	
	cout << ans;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<queue>
#include<vector>
#include <cstdlib>
#include<algorithm>
#include <cstdio>
#include <cctype>
using namespace std;
const long long INF=1000000000LL;
typedef long long ll;
typedef pair<int,int> Q;
typedef pair<int,Q> Pa;
ll N,A[100005],D[2][8005]={},B[200005]={};
bool b;
ll L=0,ans=0;
int a=0,k;
string str;
char s;
string n[100002];
int main(){
	cin>>str;
	s=str[0];
	for(int i=0;i<str.size();++i){
		if(str[i]!=s){
			A[a]=L;
			a++;
			L=0;
			s=str[i];
		}
		L++;
	}
	A[a]=L;
	N=str.size();
	k=0;
	while(1){
		ans+=A[k];
		if(ans>=N-ans){
			ans=min(ans,N-ans+A[k]);
			break;
		}
		k++;
	}
	k=a;
	ll v=0;
	while(1){
		v+=A[k];
		if(v>=N-v){
			v=min(v,N-v+A[k]);
			break;
		}
		k--;
	}
	ans=max(ans,v);
//	if(a==1)ans=min(A[0],A[1]);
	cout<<ans<<endl;
	return 0;
}


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

using namespace std;
  
bool checkingAlgo(int koyta, int seq[]) 
{  
    int duplicate[koyta]; 
    for (int i = 0; i < koyta; i++) 
        duplicate[i] = seq[i]; 
    sort(duplicate, duplicate + koyta); 
  
 
    int swap = 0; 
    for (int i = 0; i < koyta; i++) 
        if (seq[i] != duplicate[i]) 
            swap++; 
    if (swap == 0 || swap == 2) 
        return true; 
    else
        return false; 
} 
  

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

    int seq[koyta]; 
    for (int i = 0; i < koyta; i++) 
        cin >> seq[i]; 
     

    if (checkingAlgo(koyta, seq)) 
        cout << "YES"; 
    else
        cout << "NO"; 
    return 0; 
} 


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    if (!(a == 1 || b == 1)) {
      System.out.println(1);
    }
    if (!(a == 2 || b == 2)) {
      System.out.println(2);
    }
    if (!(a == 3 || b == 3)) {
      System.out.println(3);
    }
  }
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define in freopen("in.txt","r",stdin)
//#define out freopen("out.txt","w",stdout) 
ll n,m,j,k,t,l,r;
ll b,c,d;
char A,B,C,X,Y,Z;
ll ans,MAX,MIN=40,sum;
ll ax[200050],bx[200050];
//ll dp1[1000][1000],dp2[1000][1000];
char str[200050];

int main()
{
    ll i,s,x;
    t=1;
    //scanf("%lld",&t);
    while(t--)
    {
    	cin>>k;
    	scanf("%s",str);
    	n=strlen(str);
    	if(n<=k) printf("%s",str);
    	else
    	{
    		for(i=0;i<k;i++)
    		printf("%c",str[i]);
    		printf("...");
		}
	}
	return 0;
}

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

int main(){
 int S, W;
 string ans;
 cin >> S >> W;
 if( S <= W ){
   ans = "unsafe";
 }
 else{
   ans = "safe";
 }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
 
int main() {
    int k, x;
    int n= 2000001;
    cin >> k >> x;

    int renge = k - 1;

    for(int i=0; i < (renge*2 + 1); i++){
        int ans = (x -renge) + i;
        if((ans >=-100000) ||(ans <= 100000)){
        cout << ans <<" ";
        }
    }
    cout << endl;


    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

const long long int MAX_N = 1000;

int main(int argc, char const *argv[]) {
  long long int n, l[MAX_N], r[MAX_N];
  cin >> n;
  for (size_t i = 0; i < n; i++) cin >> l[i] >> r[i];

  long long int ans = 0;

  for (size_t i = 0; i < n; i++) ans += r[i] - l[i] +1;

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


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

signed main(){
    int n,m;
    cin>>n>>m;
    vector<int> a(n);
    rep(i,n)cin>>a[i];
    
    double dp[501][502];
    rep(i,501)rep(j,502)dp[i][j] = -INF;
    dp[0][0] = 0;
    
    vector<int> rs(n+1,0);
    rep(i,n)rs[i+1] = a[i];
    for(int i=1;i<=n;i++){
        rs[i] += rs[i-1];
    }
    
    auto ave = [&](int l,int r){
        int sum = rs[r] - rs[l];
        return (double)sum/(r-l);
    };
    
    for(int i=1;i<=n;i++){
        for(int j=0;j<=n;j++){
            for(int k=1;k<=n;k++){
                if(i-k<0 or j-(k-1)<0)break;
                dp[i][j] = max(dp[i][j],dp[i-k][j-(k-1)]+ave(i-k,i));
            }
        }
    }
    
    double ans = -INF;
    for(int j=n-m;j<=n;j++){
        ans = max(ans,dp[n][j]);
    }
    printf("%.20lf\n",ans);
}



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

#define ll long long

int main() {
  int N;
  cin >> N;
  
  vector<ll> A(N);
  
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  
  sort(A.begin(), A.end());
  
  ll ans = 0;
  
  priority_queue<ll> que;
  
  que.push(A[N-1]);
  
  for (int i = N-2; i>=0; i--){
    
    ans += que.top();
    
    que.pop();
    que.push(A[i]);
    que.push(A[i]);
    
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 6928
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

ll mod(ll a){
  return a % 1000000007;
}

ll lcm(ll a,ll b){
  return (a*b)/gcd(a,b);
}


int main(){
  char a,b; cin >> a >> b;
  if(a > b) cout << '>' << endl;
  else if(a < b) cout << '<' << endl;
  else cout << '=' << endl;
}

Measured memory_bytes: 256
import java.util.Scanner

fun main(args: Array<String>){
    val cin = Scanner(System.`in`)
    val x = cin.nextInt()
    val h = x/3600
    val m = (x-h*3600)/60
    val s = x-h*3600-m*60

    println("$h:$m:$s")
}



Measured memory_bytes: 27284
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
  int N;
  cin >> N;
  if (N==1) {
    cout <<"Hello World" << endl;
  }
  else {
    int A;
    int B;
    cin >>A>>B;
    int c=A+B;
    cout << c<< endl;
  }
}


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

using namespace std;

#define int long long

signed main(){
	string s;
	cin >> s;
	int n=s.length();
	int i=0,j=n/2-1;
	while(i<=j){
		if(s[i]!=s[j]){
			cout << "No";
			exit(0);
		}
		i++;
		j--;
	}
	i=n/2+1,j=n-1;
	while(i<=j){
		if(s[i]!=s[j]){
			cout << "No";
			exit(0);
		}
		i++;
		j--;
	}
	i=0,j=n-1;
	while(i<=j){
		if(s[i]!=s[j]){
			cout << "No";
			exit(0);
		}
		i++;
		j--;
	}
	cout << "Yes";
}

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

namespace My
{
template <typename ArrayT>
static void DumpArray(const ArrayT &arr)
{
#if defined(HOME)
	for (auto it = std::begin(arr); it != std::end(arr); ++it) {
		cerr << *it << " ";
	}
	cerr << endl;
#endif
}
template <typename T>
static void DumpGrid(const vector<vector<T>> &grid)
{
#if defined(HOME)
	REP (i, grid.size()) {
		REP (j, grid[i].size()) {
			cerr << grid[i][j] << " ";
		}
		cerr << endl;
	}
#endif
}
template <class ArrayT, typename T>
static void InitArray(ArrayT &arr, T initValue)
{
	for (auto &v : arr) {
		v = initValue;
	}
}
template <typename T>
static bool ReplaceIfSmaller(T &target, T value)
{
	if (value < target) {
		target = value;
		return true;
	} else {
		return false;
	}
}
template <typename T>
static bool ReplaceIfBigger(T &target, T value)
{
	if (target < value) {
		target = value;
		return true;
	} else {
		return false;
	}
}

struct Station {
	Station(int c, int s, int f) {
		C = c;
		S = s;
		F = f;
	}
	int C;
	int S;
	int F;
};

class Solver
{
  public:
	Solver() {}
	void Solve(istream &cin, ostream &cout)
	{
		int N;
		cin >> N;

		vector<Station> vec;
		REP (i, N-1) {
			int C, S, F;

			cin >> C >> S >> F;
			vec.emplace_back(C, S, F);
		}

		REP(i, N-1){
			// i番目から出発
			int t = 0;	// 現在時刻
			for (size_t j = i; j < N - 1; j++) {
				const auto& s = vec[j];
				if (t <= s.S){
					// Sに出発するので次の駅に着くのは S+C 秒後
					t = s.S + s.C;
				}else {
					// Sより後に出発する
					auto cycle = (t - s.S + s.F - 1) / s.F;
					t = s.S + s.F * cycle + s.C;
				}
			}
			cout << t << endl;
		}
		cout << 0 << endl;
	}
};
} // namespace My

#if !defined(BOOST_TEST_MODULE)
#if !defined(GTEST_INCLUDE_GTEST_GTEST_H_)
int main()
{
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);

	My::Solver solver;
	solver.Solve(std::cin, std::cout);

	return 0;
}
#endif
#endif


Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

    static PrintWriter out;
    static Scanner sc;

    static void solve() {
        int a = nextInt();
        int b = nextInt();
        int c = nextInt();
        int d = nextInt();

        int ans = Math.min(a, b) + Math.min(c, d);
        out.println(ans);
    }

    static int nextInt() {
        return Integer.parseInt(sc.next());
    }

    static long nextLong() {
        return Long.parseLong(sc.next());
    }

    static String nextString() {
        return sc.next();
    }

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

    static List<Integer> nextIntList(int n) {
        List<Integer> list = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            list.add(nextInt());
        }
        return list;
    }

    static List<Long> nextLongList(int n) {
        List<Long> list = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            list.add(nextLong());
        }
        return list;
    }

    static <T extends Comparable<? super T>> void sort(List<T> list) {
        Collections.sort(list);
    }

    // greatest common divisor
    static long gcd(long a, long b) {
        if (b == 0) {
            return a;
        }
        return gcd(b, a % b);
    }

    // baseのn乗を計算を返す
    static int pow(int base, int n) {
        int ret = 1;
        for (int i = 0; i < n; i++) {
            ret *= base;
        }
        return ret;
    }

    // intをlength桁のbit文字列に変換
    static String toBinaryString(int input, int length) {
        return toBinaryString(input).substring(29 - length);
    }

    // intを29桁のbit文字列に変換
    static String toBinaryString(int input) {
        String ret = "";
        int max = 0x10000000;
        for (int i = 0; i < 29; i++) {
            int tmp = input / max;
            ret += tmp;
            input %= max;
            max /= 2;
        }
        return ret;
    }

    public static void main(String[] args) {
        out = new PrintWriter(System.out);
        sc = new Scanner(System.in);

        solve();

        out.flush();
        sc.close();
    }

}


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

int main(){
  string S;
  cin >> S;
  if(S=="RRR"){
    cout << 3 << endl;
  }
  else if(S=="SSS"){
    cout << 0 << endl;
  }
  else if(S=="RRS" || S=="SRR"){
    cout << 2 << endl;
  }
  else{
    cout << 1 << endl;
  }
}

Measured memory_bytes: 3604
n=int(input())
s=[0]*n
t=['0']*n
c=0
for i in range(n):
    s[i],t[i]=input().split()
    t[i]=int(t[i])
x=input()
a=s.index(x)
for i in range(a+1,n):
    c+=t[i]
print(c)

Measured memory_bytes: 3060
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

    void run() {
        Scanner sc = new Scanner(System.in);
        int[] ar = new int[3];
        for (int i = 0; i < 3; i++) ar[i] = sc.nextInt();
        Arrays.sort(ar);
        System.out.println(ar[0] + ar[1]);
    }


    void debug(Object...os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long N, A, B, C, D;
	cin >> N >> A >> B >> C >> D;
	N--;
	for(int i=0;i<=N;i++){
		long long l = A + C*i - (N-i)*D;
		long long r = A + D*i - (N-i)*C;
		if(l <= B && B <= r){
			printf("YES\n");
			return 0;
		}
	}
	printf("NO\n");
}

Measured memory_bytes: 256
N, Y = map(int, input().split())
for x in range(N + 1):
    for y in range(N - x + 1):
        z = N - x -y
        if 0 <= z <= 2000 and 10000 * x + 5000 * y + 1000 * z == Y:
            print(x, y, z)
            exit()
print(-1, -1, -1)


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

int main()
{
	int n, m = 0;
	string s;

	cin >> n >> s;

	for (int i = 0; i < n; i++) {
		string t;

		cin >> t;

		int d = 0;

		while (d < t.size() - s.size() + 1) {
			bool f;
			while (d < t.size() - s.size() && s[0] != t[d])
				d++;

			int j = 1;

			while (j <= t.size() / (s.size() - 1)) {
				f = 1;

				for (int k = 0; k < s.size(); k++) {
					if (d + k * j >= t.size() || s[k] != t[d + k * j]) {
						f = 0;
						break;
					}
				}

				if (f)
					break;
				j++;
			}
			if (f) {
				m++;
				break;
			}
			d++;
		}
	}

	cout << m << endl;

	return 0;
}



Measured memory_bytes: 3228
/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt(), k=sc.nextInt(), c=sc.nextInt()+1;
		char[] car=sc.next().toCharArray();
		int[] dp=new int[n], dprev=new int[n];
		for(int i=0;i<n;i++){
			if(car[i]!='x')dp[i]=1+(((i-c)>=0)?dp[i-c]:0);
			else dp[i]=((i-1)>=0)?dp[i-1]:0;
		}
		for(int i=n-1;i>=0;i--){
			if(car[i]!='x')dprev[i]=1+(((i+c)<n)?dprev[i+c]:0);
			else dprev[i]=((i+1)<n)?dprev[i+1]:0;
		}
		StringBuilder ans=new StringBuilder();
		// System.out.println(Arrays.toString(dp)+" "+Arrays.toString(dprev));
		for(int i=0;i<n;i++){
			if(car[i]!='x'){
				int l = (((i-1)>=0)?dp[i-1]:0),r=(((i+1)<n)?dprev[i+1]:0);
				if(l+r<k){
					ans.append((i+1)+"\n");
				}
			}
		}
		System.out.print(ans);
	}
}

Measured memory_bytes: 47100
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

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

    ll N, A, B;
    while(cin >> N >> A >> B) {
        vi X(N);
        rep(i, N)cin >> X[i];

        ll ans = 0;
        rep(i, N - 1) {
            ans += min((X[i + 1] - X[i])*A, B);
        }
        cout << ans << endl;
    }
}


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

int main(){
	int characters[26]={},taken=0,pseudostringsize=0;
	char inp;
	while(cin>>inp){
		characters[inp-'a']++;
	}
	sort(characters,characters+3);
	characters[2]-=characters[0];
	characters[1]-=characters[0];
	
	if((characters[1]+characters[2])>2||(characters[2]==2)) cout<<"NO";
	else cout<<"YES";
	cout<<"\n";
	
	return 0;
}

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

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,P; cin >> N >> P;
    map<ll,ll> m=prime_factor(P);
    ll ans=1;
    for (auto p:m) ans*=(ll)pow(p.first,p.second/N);
    cout << ans << '\n';
}

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

int main(){
    int n,x,t;
    cin>>n>>x>>t;

    int ans = 0,cnt=0;
    while(1){
        ans = ans+x;
        cnt++;
        if(ans>=n) break;
    }

    cout<<cnt*t<<endl;

    return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;
int main()
{
    ll H, W, N;
    cin >> H >> W >> N;
    const ll width = 2 * W;
    auto get = [&](const ll d, const ll n) {
        const ll ans = (n + ((n + d) % 2 == 1 ? 1 : width - 1) * d % width) % width;
        return (ans < W) ? ans : width - ans - 1;
    };
    vector<ll> vec(W);
    for (ll i = 0; i < W; i++) {
        vec[i] = i;
    }
    using P = pair<ll, ll>;
    vector<P> edge(N);
    for (ll i = 0; i < N; i++) {
        ll a, b;
        cin >> a >> b;
        a--, b--;
        edge[i] = {a, b};
    }
    sort(edge.begin(), edge.end());
    for (ll i = 0; i < N; i++) {
        const ll a = edge[i].first;
        const ll b = edge[i].second;
        const ll u = get(a, b);
        const ll v = get(a, b + 1);
        swap(vec[u], vec[v]);
    }
    vector<ll> rev(W);
    for (ll i = 0; i < W; i++) {
        rev[vec[get(H, i)]] = i + 1;
    }
    for (ll i = 0; i < W; i++) {
        cout << rev[i] << endl;
    }
    return 0;
}



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

int main(int argc, char const* argv[])
{
	string str;
	cin >> str;
	while(str != "-"){
			int m;
			cin >> m;
			for(int i = 0; i < m; i++){
					int h;
					cin >> h;
					string sf = str.substr(h);
					str = sf + str.substr(0, h);
			}
			cout << str << endl;
			cin >> str;
	}
	return 0;
}



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

using namespace std;

typedef pair<string, string> P;
typedef pair<string, int> S;

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

	int n;
	while (cin >> n, n) {
		vector<P> v(n);
		for (int i = 0; i < n; i++) {
			string a, b; cin >> a >> b;
			v[i] = P(a, b);
		}
		string c, d; cin >> c >> d;
		queue<S> q;
		q.push(S(c,0));
		bool flag = false;
		while (!q.empty()) {
			S next = q.front(); q.pop();
			string st = next.first;
			int cnt = next.second;
			if (st == d) {
				cout << cnt << endl;
				flag = true;
				break;
			}
			if (st.length() > d.length()) continue;
			for (int i = 0; i < n; i++) {
				string from = v[i].first, to = v[i].second;
				string str = st;
				string::size_type pos = str.find(from);
				while (pos != string::npos) {
					str.replace(pos, from.size(), to);
					pos = str.find(from, pos + to.size());
				}
				if (str == st) continue;
				q.push(S(str, cnt + 1));
			}
		}
		if (!flag) cout << -1 << endl;
	}
}

Measured memory_bytes: 4140
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <random>
#include <ctime>
#include <string>
#include <iomanip>
#include <set>
#include <map>
#include <queue>
#include <stack>

using namespace std;

typedef long long li;
typedef unsigned long long uli;
typedef pair<int, int> pii;
typedef long double ld;

#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define fr first
#define sc second
#define pb push_back
#define forn(i, n) for(int i = 0; i < int(n); ++i)
#define fore(i, l, r) for(int i = int(l); i < int(r); ++i)
#define forb(i, n) for(int i = int(n) - 1; i >= 0; --i)
//#define x first
//#define y second

const int INF = 1e9;
const li INF64 = 4e18;
const int M = 26;
const int N = 100 + 100;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
const double PI = 3.14159265359;

li gcd(li a, li b) {
    return a == 0 ? b : gcd(b % a, a);
}

int main() {
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int n;
    cin >> n;

    vector<vector<int>> a(n, vector<int>(3));

    forn(i, n) {
        forn(j, 3) {
            cin >> a[i][j];
        }
    }

    vector<vector<int>> dp(n + 1, vector<int>(3));
    
    fore(i, 1, n + 1) {
        forn(j, 3) {
            forn(k, 3) {
                if (j != k) {
                    dp[i][j] = max(dp[i][j], dp[i - 1][k] + a[i - 1][j]);
                }
            }
        }
    }

    cout << max(dp[n][0], max(dp[n][1], dp[n][2])) << '\n';


}

Measured memory_bytes: 11136
import math 
import numpy as np
k = input().split(" ")
hour_length = float(k[0])
min_length = float(k[1])

hour_move = float(k[2])
min_move = float(k[3])

def pol2cart(rad, degree):
    #x = rho * np.cos(phi)
    #y = rho * np.sin(phi)
    #return(x, y)
    radius = rad
    theta = math.degrees(degree)
    theta = theta * math.pi/180.0;

    x = radius * math.cos(theta)
    y = radius * math.sin(theta)
    return x,y
hour_moved_by_min = (min_move/60)
hour_degrees = (((hour_move+hour_moved_by_min)/12)*math.pi*2)
min_degrees = ((min_move/60)*math.pi*2)

xh,yh = pol2cart(hour_length,hour_degrees)
xm,ym = pol2cart(min_length,min_degrees)

dx = abs(xh-xm)
dy = abs(yh-ym)

hypo = math.sqrt(dx**2 + dy**2)
#print(xh,yh)
#print(xm,ym)
print(hypo)

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

int main(){
  string s;
  cin >> s;
  bool ok=true;
  for(int i=0;i<s.size();i++){
    if(i%2==0&&s.at(i)=='L')
      ok=false;
    if(i%2==1&&s.at(i)=='R')
      ok=false;
  }
  cout << (ok?"Yes":"No") << endl;
  return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main(){
int N,H;
  cin>>N>>H;
  vector<int>A(N);
  vector<int>B(N);
  for(int i=0;i<N;i++){
  int a,b;
    cin>>a>>b;
    A.at(i)=a;
    B.at(i)=b;
  }sort(A.begin(),A.end());
  int Max=A.at(N-1);
  sort(B.begin(),B.end());
  auto itr=lower_bound(B.begin(),B.end(),A.at(N-1));
  int k=distance(B.begin(),itr);
  int ans=0;
  int sum=0;
  for(int i=0; ;i++){
  if(i<=N-k-1){
  sum+=B.at(N-1-i);if(H<=sum){ans=i+1; break;}
  }else{
  sum+=A.at(N-1);if(H<=sum){ans=i+1; break;}
  }
  }cout<<ans<<endl;
   return 0;
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication33
{
    class Program
    {
        static void Main()
        {
            string[] a = Console.ReadLine().Split();
            for(int b = 2; b < a.Length; b++)
            {    if (a[1] == null) break;
                if (!char.IsDigit(a[b][0])&&a[b].Length==1)
                {
                    switch (a[b][0]) {
                        case '+':a[b - 2] =( int.Parse(a[b - 2]) + int.Parse(a[b - 1])).ToString(); break;
                        case '*': a[b - 2] =( int.Parse(a[b - 2]) * int.Parse(a[b - 1])).ToString(); break;
                        case '-': a[b - 2] = (int.Parse(a[b - 2]) - int.Parse(a[b - 1])).ToString(); break;
                        default: a[b - 2] = (int.Parse(a[b - 2]) / int.Parse(a[b - 1])).ToString(); break;
                    }
                    for(int i = b - 1; i < a.Length; i++)
                    {
                        try { a[i] = a[i + 2]; }
                        catch { a[i] = null; }
                    }b = 1;
                }
                if (a[1] == null) break;
            }
            Console.WriteLine(a[0]);
        }
    }
}

Measured memory_bytes: 9164