akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
long long n,k,a[1000010],an=0x3f3f3f3f;
int main()
{
	scanf("%lld%lld",&n,&k);
	for (int i=1;i<=n;i++) scanf("%lld",&a[i]);
	for (int i=1;i+k-1<=n;i++) an=min(an,a[i+k-1]-a[i]+min(abs(a[i]),abs(a[i+k-1])));
	printf("%lld",an);
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;

int main() {
    int d;
    cin >> d;
    vector<int> c(26);
    rep(i, 26) cin >> c[i];
    vector<vector<int>> s(d, vector<int>(26));
    rep(i, d) rep(j, 26) cin >> s[i][j];
    int t;
    vector<int> last(26, -1);
    int satisfy = 0;
    rep(i, d) {
        cin >> t;
        t--;
        satisfy += s[i][t];
        last[t] = i;
        int decrease = 0;
        rep(j, 26) decrease += c[j] * (i - last[j]);
        satisfy -= decrease;
        cout << satisfy << endl;
    }
}

Measured memory_bytes: 3628
s=input()
t=input()
lens=len(s)
lent=len(t)
dp=[[0 for _ in range(lent+1)] for _ in range(lens+1)] 
for i in range(len(s)):
  for j in range(len(t)):
    if s[i]==t[j]:
      dp[i+1][j+1]=max(dp[i+1][j+1],dp[i][j]+1)
      #print(max(dp[i+1][j+1],dp[i][j]+1))
    dp[i+1][j+1]=max(dp[i+1][j+1],dp[i][j+1],dp[i+1][j])
    #print(dp)
#print(dp)
#len=dp[lens][lent]
#print(len)
i=lens
j=lent
#ans=["" for _ in range(len)]
ans=""
while i>0 and j>0:
  #print(i,j,ans)
  if dp[i][j]==dp[i-1][j]:
    i-=1
  elif dp[i][j]==dp[i][j-1]:
    j-=1
  else:
    #print(i,j,ans)
    ans+=s[i-1]
    i-=1
    j-=1
    #len-=1
    #print(ans)
print(ans[::-1])
  
  

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

// g++ -std=c++17 -Wshadow -Wall -g -fsanitize=address -fsanitize=undefined -D_GLIBCXX_DEBUG -o 

int main(){
 int n;
 cin>>n;
 if(n>=30)
  puts("Yes");
 else
  puts("No");
 return 0;
}


Measured memory_bytes: 3524
#include <bits/stdc++.h>
/*
#include<algorithm>
#include<array>
#include<cassert>
#include<cmath>
#include<cstdlib>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<typeinfo>
#include<utility>
#include<vector>
*/
#define int long long int
#define double long double
using namespace std;
#define MOD 1000000007
#define INF 1000000000000000007
const int MAX_N = 1 << 17;
#define rep(i, n) for (int(i) = 0, i##_len = (n); (i) < i##_len; (i)++)
#define reps(i, x) for (int(i) = 1; (i) <= (int)(x); (i)++)
#define rrep(i, x) for (int(i) = ((int)(x)-1); (i) >= 0; (i)--)
#define rreps(i, x) for (int(i) = ((int)(x)); (i) > 0; (i)--)
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define pb push_back
#define mp make_pair
#define bit(n) ((int)(1) << (n))
#define all(x) (x).begin(), (x).end()
#define debug(x) std::cout << #x << ": " << (x) << std::endl
#define nint int
using namespace std;

int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
typedef pair<int, int> pii;
typedef pair<double, double> dop;
template <class T>
bool chmax(T& a, const T& b)
{
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b)
{
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
struct aaa {
    aaa()
    {
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout << fixed << setprecision(20);
    };
} aaaaaaa;


signed main()
{
    int n, k;
    cin >> n >> k;
    std::vector<int> x(n);
    for (int i = 0; i < n; i++) {
        cin >> x[i];
    }
    int mint = INF;
    for (int i = 0; i + k <= n; i++) {
        int range = x[i + k - 1] - x[i];
        chmin(mint, range + min(abs(x[i]), abs(x[i + k - 1])));
    }
    cout << mint << endl;
    return 0;
}

Measured memory_bytes: 1024
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;
 

//result = Math.pow(num1, num3)
//StringBuffer str = new StringBuffer(hoge1);
//String hoge2 = str.reverse().toString();
//map.containsKey(A)

//Map<String, Integer> map = new HashMap<String, Integer>(n);
/*for ( キーのデータ型 key : マップの名前.keySet() ) {
	データのデータ型 data = マップの名前.get( key );
	
	// keyやdataを使った処理;
}*/
//int i = Integer.parseInt(s);

//ArrayList<String> cc = new ArrayList<>(n);
//Collections.sort(list);
//Array.sort(list);
//Arrays.asList(c).contains("a")
//list.set(1,"walk");
public class Main {
	private static Scanner sc = new Scanner(System.in);
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	static String s;
	static String g;
	static int a[]=new int[4];
	public static void main(String[] args) {
		//String N=sc.next();
		int a=sc.nextInt();
		if(a<1200) {
			p("ABC");
		}else if(a<2800) {
			p("ARC");
		}else {
			p("AGC");
		}
	}
	static boolean dfs(int b,int sum,String v) {
		g=v;
		if(b==4)return sum==7;
		if(dfs(b+1,sum+a[b],v+"+"))return true;
		if(dfs(b+1,sum-a[b],v+"-"))return true;
		return false;
	}
	

	
	
	
}


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

int main() {
  vector<int> c(3);
  for (int i = 0; i < 3; i++) {
    cin >> c[i];
  }
  sort(c.begin(), c.end());
  cout << c[0] + c[1] << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>

using namespace std;

int main()
{
	int X, Y, Z;
	cin >> X >> Y >> Z;

	swap(X, Y);
	swap(X, Z);

	cout << X<<" "<<Y<<" "<<Z << endl;

}


Measured memory_bytes: 3600
//Jay Shree Krishna
#include"bits/stdc++.h"
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define ll long long int
#define inf 1e18
#define sr string
#define mod 1000000007
#define start int t;cin>>t;while(t--)
#define db(x) cout<<#x<<"="<<x<<"\n"
#define db2(a,b)cout<<#a<<": "<<a<<" , "<<#b<<": "<<b<< endl;
#define db3(a,b,c)cout<<#a<<": "<<a<<" , "<<#b<<": "<<b<<" , "<<#c<<": "<<c<<endl;
#define forr(i,n) for (int i = 0; i < n; i++)
#define fr(i,n) for (int i = 1; i <= n; i++)
#define rep(i,j,k) for(int i = j; i < k; i++)
#define rp(i,j,k) for(int i = j; i <=k; i++)
#define nn "\n"
#define en "\n"
#define vvi vector<vector<int>>
#define vi vector<int>
#define si set<int>
#define mlsi multiset<int>
#define vc vector<char>
#define vs vector<string>
#define vli vector<long long int>
#define vpii vector<pair<int,int>>
#define pii pair<int,int>
#define mii map<int,int>
#define msi map<string,int>
#define mci map<char,int>
#define mpiii map<pair<int,int>,int>
#define um unordered_map
#define umii unordered_map<int,int>
#define umsi unordered_map<string,int>
#define umci unordered_map<char,int>
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define sortv(x) sort(x.begin(),x.end())
#define sorta(x,n) sort(x,x+n)
#define sorted(x) is_sorted(x.begin(),x.end())
#define print_all(x) for(auto t:x) cout<<t<<" ";cout<<en;
#define mxe(x) *max_element(all(x))
#define mne(x) *min_element(all(x))
#define go(x) for(auto &[u,v]:x)
#define in(x) cin>>x
#define inn(x,y) cin>>x>>y
#define innn(x,y,z) cin>>x>>y>>z
#define innnn(x,y,z,v) cin>>x>>y>>z>>v
#define oo(x) cout<<x<<endl
#define oo2(x,y) cout<<x<<" "<<y<<endl
#define o3(x,y,z) cout<<x<<" "<<y<<" "<<z<<endl
#define ood(n,x) cout<<fixed<<setprecision(n)<<x<<"\n"
#define sz(x) x.size()
#define ff first
#define ss second
#define ooy cout<<"YES\n"
#define oon cout<<"NO\n" 
#define rr return
#define cc continue

using namespace std;

template<class T> bool ckmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<class T> bool ckmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
 
void read(vli &a,int n){
    a.resize(n);
    forr(i,n) cin>>a[i];
}


bool fine=0;
vli a;
ll n,m;
void solve(){
    in(n);
    if(n==1){
        oo(0);
        rr;
    }
    oo(1);
    /*ll a,b,c,d;
    innn(a,b,c);
    in(d);
    ll ans=b*d;
    ckmax(ans,b*c);
    ckmax(ans,a*c);
    ckmax(ans,a*d);
    oo(ans);*/
}

int main(){
    #ifndef ONLINE_JUDGE 
    freopen("input1.txt", "r", stdin); 
    freopen("error.txt", "w", stderr); 
    freopen("output1.txt", "w", stdout); 
    #endif
    fast; 
   if(fine){
        start{
            solve();
        }
   }
   else solve();
    return 0;
}


Measured memory_bytes: 3620
using System;
using System.Collections.Generic;
using System.Linq;
using Console = System.Console;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var r = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            if (r[0] % 3 == 0 ||
                r[1] % 3 == 0 ||
                (r[0] + r[1]) % 3 == 0)
            {
                Console.WriteLine("Possible");
            }
            else
            {
                Console.WriteLine("Impossible");
            }
        }
    }
}

Measured memory_bytes: 13396
#include <iostream>
using namespace std;
int main()
{
    int a, b;
    cin >> a >> b;
    for(int p = 1; p <= 10000; p++) {
        if(p * 8 / 100 == a && p * 10 / 100 == b) {
            cout << p << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

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

int main(){
    int N;
    cin >> N;
    long long int sum=0;
    for(int i=0; i<N;i++){
        int num = i+1;
        if(num %3 != 0 && num %5 != 0){
            sum += num;
        }
    }

    cout << sum << endl;
}

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

using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
template <typename T> constexpr T inf = numeric_limits<T>::has_infinity ? numeric_limits<T>::infinity() : numeric_limits<T>::max() / 4;

#define REP(i, stop) FOR(i, 0, stop)
#define FOR(i, start, stop) for (int i = start, i##_len = stop; i < i##_len; ++i)
#define RREP(i, n) for (int i = n; i-- > 0;)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define COMP(key) [](const auto& a, const auto& b) { return a.key < b.key; }

template<typename T, typename U> istream& operator>>(istream& is, pair<T, U>& a) { return is >> a.first >> a.second; }
template<typename T> istream& operator>>(istream& is, vector<T>& a) { for (T& x : a) is >> x; return is; }

void LOG(const int& x) { cerr << x << "\n"; }
template<typename T> void LOG(const vector<T>& a) { for (const T& x : a) cerr << x << " "; cerr << "\n"; }
template<typename T, std::size_t S> void LOG(const T (&a)[S]) { REP(i, S) cerr << a[i] << " "; cerr << "\n"; }
template<typename T, std::size_t S, std::size_t R> void LOG(const T (&a)[S][R]) { REP(i, S) { REP(j, R) cerr << a[i][j] << " "; cerr << "\n"; } }

i64 ceil(i64 a, i64 b) { return (a - 1) / b + 1; }
i64 gcd(i64 a, i64 b) { while (b != 0) { i64 t = b; b = a % b; a = t; } return a; }
i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
i64 gcd(const vector<i64>& v) { return accumulate(ALL(v), 1LL, static_cast<i64(*)(i64, i64)>(gcd)); }
i64 lcm(const vector<i64>& v) { return v.empty() ? 0LL : accumulate(v.begin() + 1, v.end(), v[0], static_cast<i64(*)(i64, i64)>(lcm)); }
i64 pow(i64 x, i64 y, i64 z) { i64 a = 1; while (y > 0) { if (y & 1) a = a * x % z; x = x * x % z; y /= 2; } return a; }
i64 inv(i64 x, i64 m) { return pow(x, m - 2, m); }

struct InitCpp { InitCpp() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10); } } initCpp;

const i64 INF = inf<i64>;
using P = pair<i64, i64>;
signed main() {
  i64 T1, T2, A1, A2, B1, B2;
  cin >> T1 >> T2 >> A1 >> A2 >> B1 >> B2;
  i64 X1 = T1 * A1;
  i64 X2 = T2 * A2;
  i64 Y1 = T1 * B1;
  i64 Y2 = T2 * B2;
  if (!(X1 < Y1)) {
    swap(X1, Y1);
    swap(X2, Y2);
  }
  // assert(X1 < Y1);
  if (X1 + X2 == Y1 + Y2) {
    cout << "infinity" << endl;
  } else if (X1 + X2 < Y1 + Y2) {
    cout << 0 << endl;
  } else {
    i64 D2 = (X1 + X2) - (Y1 + Y2);
    i64 D1 = Y1 - X1;
    cout << ((D1 / D2) * 2 + (D1 % D2 ? 1 : 0)) << endl;
  }
}


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

int cnt[200];
int main() {
	int a, b;
	while (~scanf("%d%d", &a, &b)) {
		a--; b--;
		memset(cnt, 0, sizeof(cnt));
		cnt[a]++; cnt[b]++;
		while (scanf("%d%d", &a, &b), a) {
			a--; b--;
			cnt[a]++; cnt[b]++;
		}
		int k = 0;
		rep(i, 200) {
			if (cnt[i]) {
				if (cnt[i] & 1)k++;
			}
		}
		if (k == 2 && cnt[0] & 1 && cnt[1] & 1)puts("OK");
		else puts("NG");
	}
}

Measured memory_bytes: 3064
n=int(input())
l=[]
for i in range(n):
    a,b=map(int,input().split())
    l.append((a-b,i,0))
    l.append((a+b-0.1,i,1))
l.sort()
buf=0
b=0
count=0
for i in range(2*n):
    if l[i][2]==0:
        buf=buf | 1<<l[i][1]
        b+=1
    elif l[i][2]==1 and (buf & (1<< l[i][1]))>>l[i][1]==1:
        count+=1
        buf=0
        b=0
    #print(l[i],buf,count)
print(count)

Measured memory_bytes: 78460
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<unordered_map>
#include<functional>
#include<set>
#include<numeric>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define SUM(a) accumulate(all(a),0LL)
#define pb push_back
#define endl '\n'
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 2222222222222222222LL;
const ll mod = 1000000007LL;

ll n = 0, m = 0, ans = 0, cnt = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok = true, flag = false;
ll dx[9] = { 0,1,-1,0,0,1,1,-1,-1 }, dy[9] = { 0,0,0,1,-1,1,-1,1,-1 };
#pragma endregion
#define MAX 222222




int main(void) {

  cin >> n;
  cout << "Christmas";
  rep(i, 25 -n) cout << " Eve";
  cout << endl;



  return 0;
}

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

const int MAXN = 1123456;

vector <int> v;
int memo[MAXN][2];
int solve (int pos, int carry) {
	if (pos == -1) return carry;
	int & p = memo[pos][carry];
	if (p + 1) return p;

	if (carry) {
		
		p = min (
			(10 - v[pos] - 1) + solve (pos - 1, 1),
			v[pos] + 1 + solve (pos - 1, 0)
		);

		p = min (p, 10 - v[pos] + solve (pos - 1, 0));

	} else {
		
		p = min (
			v[pos] + solve (pos - 1, 0),
			v[pos] + 1 + solve (pos - 1, 1)
		);

	}

	return p;
}

int digiCount (int x) {
	int ans = 0;
	while (x) {
		ans += x % 10;
		x /= 10;
	}

	return ans;
}

int build (vector <int> v) {
	int num = 0;
	for (int i = 0; i < v.size(); ++i) {
		num *= 10;
		num += v[i];
	}

	return num;
}

int brute (int x, int y) {
	return digiCount (x) + digiCount (x - y);
}

void buildVector (int x) {
	v.clear ();
	while (x) {
		v.push_back (x % 10);
		x /= 10;
	}

	v.push_back (0);

	for (int i = 0; i < v.size(); ++i)
		cout << v[i] << " ";
	cout << endl;
}

int main () {

	ios :: sync_with_stdio (false); cin.tie (0);

	string s;
	cin >> s;

	v.push_back (0);
	for (int i = 0; i < s.size(); ++i) {
		v.push_back (s[i] - '0');
	}

	reverse (v.begin(), v.end());
	// for (int i = 0; i < v.size(); ++i)
	// 	cout << v[i] << " ";
	// cout << endl;

	memset (memo, -1, sizeof memo);

	cout << solve (v.size() - 1, 0) << endl;

	// for (int num = 606; num <= 610; ++num) {
	// 	buildVector (num);
	// 	memset (memo, -1, sizeof memo);
	// 	int dpAns = solve (v.size() - 1, 0);
	// 	int bruteAns = num;
	// 	for (int i = num; i <= 10000; ++i)
	// 		if (brute (bruteAns, num) > brute (i, num))
	// 			bruteAns = i;

	// 	if (dpAns != brute (bruteAns, num))
	// 		cout << "DIFF! " << num << " " << dpAns << " " << brute (bruteAns, num) << " usando: " << bruteAns << "  troco: " << bruteAns - num << endl;
	// 	else
	// 		cout << "OK " << dpAns << endl;
	// 	cout << endl;
	// }

	return 0;
}

Measured memory_bytes: 61972
x = int(input())
if 400 <= x <= 599:
    print(8)
elif 600 <= x <= 799:
    print(7)
elif 800 <= x <= 999:
    print(6)
elif 1000 <= x <= 1199:
    print(5)
elif 1200 <= x <= 1399:
    print(4)
elif 1400 <= x <= 1599:
    print(3)
elif 1600 <= x <= 1799:
    print(2)
else:
    print(1)


Measured memory_bytes: 9176
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
const LL INF=1e18;
string u="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main(){
    int H,W;
    cin >> H >> W;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            string s;
            cin >> s;
            if(s=="snuke"){
                cout << u[j] << i+1 << endl;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int k,s,x,y,z,count=0;
    scanf("%d%d",&k,&s);
    for(x=0; x<=k; x++)
    {
        for(y=0; y<=k; y++)
        {
            z=s-(x+y);
            if(z>=0&&z<=k) 
            {
                count++;
            }
        }
    }
    printf("%d\n",count);
    return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>

#define For(i, j, k) for(int i = j; i <= k; i++)
#define Forr(i, j, k) for(int i = j; i >= k; i--)

using namespace std;

const int N = 310;

int n;
int G[N][N];
bool vis[N][N];

int main(){
	scanf("%d", &n);
	long long ans = 0;
	For(i, 1, n) For(j, 1, n) scanf("%d", &G[i][j]), ans += G[i][j];
	For(k, 1, n)
		For(i, 1, n) if(i != k) For(j, 1, n) if(j != k){
			if(G[i][j] > G[i][k] + G[k][j]){
				puts("-1");
				return 0;
			}
			if(G[i][j] == G[i][k] + G[k][j]) vis[i][j] = true;
		}
	For(i, 1, n) For(j, 1, n) if(vis[i][j]) ans -= G[i][j];
	cout << ans / 2 << endl;
	return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<string, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

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

    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];
    set<int> st;
    for (int i = 1; i < (1 << n); i++)
    {
        int sum = 0;
        for (int j = 0; j < n; j++)
        {
            if (i & (1 << j))
                sum += a[j];
        }
        st.insert(sum);
    }
    int q;
    cin >> q;
    for (int i = 0; i < q; i++)
    {
        int m;
        cin >> m;
        if (st.find(m) != st.end())
            cout << "yes" << endl;
        else
            cout << "no" << endl;
    }
}



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

namespace ARC082D {
    class Program {
        static void Main(string[] args) {
            int N = int.Parse(Console.ReadLine());
            int[] input = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            int count = 0;
            for (int i = 0; i < N; i++) {
                if (input[i] == i + 1) {
                    count++;
                    i++;
                }
            }
            Console.WriteLine(count);
        }
    }
}


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

using namespace std;

int main(void) {
	string s; cin >> s;
	for (int i = 0; i < s.size(); i++) {
		if (i > 0 && s[i] == s[i - 1]) {
			cout << "Bad" << endl;
			return 0;
		}
	}
	cout << "Good" << endl;
	return 0;
}

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

int main() {
	int a , b, c , d;
	cin >> a >> b >> c >> d;
  	if((a + b) > (c + d)){
    	cout << "Left" << endl;
    }else if((a + b) == (c + d)){
    	cout << "Balanced" << endl;
    }else{
    	cout << "Right" << endl;
    }
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)

	for i := 1; i <= len(s); i++ {
		str := s[i-1 : i]

		if i%2 == 1 && (str != "R" && str != "U" && str != "D") || i%2 == 0 && (str != "L" && str != "U" && str != "D") {
			fmt.Println("No")
			return
		}
	}
	fmt.Println("Yes")
}


Measured memory_bytes: 512
/*   ꧁༒☬महाकाल☬༒꧂ ꧁༒ঔमहाकालঔ༒꧂
                   
                   ঔৣ۝महाकालᴳᵒᵈ۝ঔৣ            
 
 */ 
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template <typename T, typename cmp=less<T>> using oset =tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define ll long long 
#define mod 1000000007
#define inf 100000000000000000
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define _it iterator
#define all(_x) _x.begin(),_x.end()
#define f first
#define s second
#define pb push_back
void mahakal(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
}
int main(){
	//mahakal(),fast;
	ll n ;
	cin>>  n ;
	ll arr[n];
	for(ll i=0;i<n-1 ;i++)cin>>arr[i];
	ll ans[n];
	for(ll i=0;i< n-2 ;i++){
		ans[i]=min(arr[i],arr[i+1]);
		// cerr<<ans[i]<<" ";
	}
	ll sum=0;
	for(ll i=0;i<n-2 ;i++)sum+=ans[i];
	sum+=arr[0];
	sum+=arr[n-2];
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
import scala.io.Source.stdin

object Main extends App {
  stdin.getLines.filter(_!="").map(_.toDouble).foreach { x =>
    println {
      x match  {
        case i if i <= 48D => "light fly"
        case i if i <= 51D => "fly"
        case i if i <= 54D => "bantam"
        case i if i <= 57D => "feather"
        case i if i <= 60D => "light"
        case i if i <= 64D => "light welter"
        case i if i <= 69D => "welter"
        case i if i <= 75D => "light middle"
        case i if i <= 81D => "middle"
        case i if i <= 91D => "light heavy"
        case _ => "heavy"
      }
    }
  }
}

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

int dp[100];

//最大公約数
int gcd(int x, int y){
  if(x % y == 0) return 1;
  return gcd(y, x % y);
}
//最小公倍数
int lcm(int x, int y){
  return x * y / gcd(x, y);
}
//フィボナッチ数列
//配列dpを-1で初期化する
int fib(int n){
  if(n == 0 || n == 1) return dp[n] = 1;
  if(dp[n] != -1) return dp[n];
  return dp[n] = fib(n - 1) + fib(n - 2);
}
//階乗計算(factorial)
int fact(int n){
  if(n = 1) return 1;
  return n * fact(n - 1);
}
//累乗計算(Exponentiation)
//x**y
ll expo(int x, int y){
  ll ans = 1;
  rep(i, y){
    ans *= x;
  }
  return ans;
}
//桁数
int keta(ll x){
  if(x == 0) return 1;
  int res = 0;
  while(x){
    x /= 10;
    res++;
  }
  return res;
}


int main(){
  int n;
  cin >> n;
  vector<int> d(n);
  rep(i, n) cin >> d[i];

  sort(d.begin(), d.end());
  int a = d[n/2-1];
  int b = d[n/2];
  if(n % 2 == 1) cout << 0 << endl;
  else{
    if(a == b) cout << 0 << endl;
    else cout << b - a << endl;
  }
}


/*





















*/


Measured memory_bytes: 640
#include<stdio.h>

#define _USE_<ATH_DEFINES


#include<math.h>


int main(void)


{


  double x,y,r;


  scanf("%lf",&r);


  x=r*r*M_PI;


  y=2*r*M_PI;


  printf("%lf %lf\n",x,y);


  return 0;


}

Measured memory_bytes: 648
#include <string>
#include <iostream>
#include <set>
#include <utility>
using namespace std;
typedef long long ll;

int main(void) {
  ll i, j, k, sm = 1, num, n, las;
  string s, ans;
  cin >> s >> k;
  n = s.size();
  while(sm < n) sm *= 2;
  ll seg[sm * 2];
  set< pair<char, ll> > se;
  for(i = 0; i < sm * 2; ++i) seg[i] = 0;
  num = k + 1 < n ? k + 1 : n;
  las = num;
  for(i = 0; i < num; ++i) se.insert(make_pair(s[i], i));
  ll cnt = 0;
  while(k && ans.size() != n) {
    ++cnt;
    num = k + 1 < n - ans.size() ? k + 1 : n - ans.size();
    while(num > se.size() && las != n) {
      if(seg[sm + las] != -1) se.insert(make_pair(s[las], las));
      las++;
    }
    while(num < se.size()) {
      --las;
      if(seg[sm + las] != -1) se.erase(se.find(make_pair(s[las], las)));
    }
    ans = ans + (*se.begin()).first;
    ll nn = sm + (*se.begin()).second, nnum = (*se.begin()).second;
    while(nn) nnum -= seg[nn], nn /= 2;
    k -= nnum;
    ll now = sm + (*se.begin()).second;
    while( 1 ) {
      while(!(now % 2)) now /= 2;
      if(seg[now] != -1) seg[now]++;
      ll mm = 1;
      while(mm < now) mm *= 2;
      if(mm - now == 1 || now == 1) break;
      now++;
    }
    seg[(*se.begin()).second + sm] = -1;
    set< pair<char, ll> >::iterator it = se.begin();
    it++;
    se.erase(se.begin(), it);
  }
  for(i = 0; i < n; ++i) if(seg[sm + i] != -1) ans = ans + s[i];
  cout << ans << endl;
  return 0;
}


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

int main(){
  int N;
  string S;
  cin >> N >> S;
  vector<int> B(N+10),W(N+10);
  B[0]=0;
  for(int i=0;i<N;i++){
    B[i+1]=B[i]; if(S[i]=='#'){B[i+1]++;}
  }
  for(int i=0;i<=N;i++){W[i]=i-B[i];}
  int m=200000000;
  for(int i=0;i<N;i++){
    int a=B[i]+(W[N]-W[i+1]);
    m=min(a,m);
  }
  cout << m << endl;
}

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

int main() {
	int N; cin >> N;
	int h[25];
	int ans = 0;
	int c = 0;
	for (int i = 0; i < N; i++) {
		cin >> h[i];
		if (ans <= h[i]) {
			ans = h[i];
			c++;
		}
	}
	cout << c;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
 
int main()
{
    string str;
    getline(cin,str);
 
    for(int i=0;i<str.size();++i){
        if(str[i] >= 'a' && str[i] <= 'z'){
            str[i] -= ('a'-'A');
        }else if(str[i] >= 'A' && str[i] <= 'Z'){
            str[i] += ('a'-'A');
        }
    }
 
    cout << str << endl;
 
    return 0;
}


Measured memory_bytes: 3168
#include <iostream>
#include <queue>
#include <algorithm>
#include <string>

using namespace std;

int main()
{
    int n, nn = 0;
    int a, b;
    int aa, bb;
    string s;

    cin >> n >> a >> b;
    cin >> s;

    aa = 0; bb = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] == 'a') {
            if (aa + bb < a + b) {
                aa++;
                cout << "Yes" << endl;
            } else {
                cout << "No" << endl;
            }
        } else if (s[i] == 'b') {
            if (aa + bb < a + b && bb < b) {
                bb++;
                cout << "Yes" << endl;
            } else {
                cout << "No" << endl;
            }
        } else {
            cout << "No" << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <deque>
using namespace std;
int H, W, CH, CW, DH, DW;
char S[1001][1001]; 
int dp[1001][1001]; // i,jへの最小コスト
const int INF = 10000000;
const int dy[4] = {-1, 0, 1, 0};
const int dx[4] = {0, -1, 0, 1};

struct point { int h, w; };

void bfs(int sh, int sw) {
  // キュー
  deque<point> que;
  dp[sh][sw] = 0;
  que.emplace_back((point){sh, sw});
  while (!que.empty()) {
    point p = que.front();
    que.pop_front();
    int d = dp[p.h][p.w];
    // 四方向に歩く
    for (int i = 0; i < 4; i++) {
      int nh = p.h + dy[i];
      int nw = p.w + dx[i];
      // 画面外か壁なら歩けない
      if (0 <= nh && nh < H && 0 <= nw && nw < W && S[nh][nw] == '.') {
        // コストを更新できるならプッシュ
        if (d < dp[nh][nw]) {
          dp[nh][nw] = d;
          que.emplace_front((point){nh, nw});
        }
      }
    }
    
    // ワープする
    for (int i = -2; i <= 2; i++) {
      for (int j = -2; j <= 2; j++) {
        int nh = p.h + i;
        int nw = p.w + j;
        // 画面外か壁なら歩けない
        if (0 <= nh && nh < H && 0 <= nw && nw < W && S[nh][nw] == '.') {
          // コストを更新できるならプッシュ
          if (d + 1 < dp[nh][nw]) {
            dp[nh][nw] = d + 1;
            que.emplace_back((point){nh, nw});
          }
        }
      }
    }
  } 
}

int main() {
  cin >> H >> W >> CH >> CW >> DH >> DW;
  CH--;CW--;DH--;DW--; //0オリジンとする
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> S[i][j];
      dp[i][j] = INF;
    }
  }
  
  bfs(CH, CW);
  if (dp[DH][DW] == INF) cout << -1;
  else cout << dp[DH][DW];
}

Measured memory_bytes: 8568
s = list(set(list(input())))
a = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
li = []
for i in range(len(a)):
  if a[i] not in s:
    li.append(a[i])
if len(li) == 0:
    print("None")
else:
    print(min(li))

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

void solve(std::istream &in, std::ostream &out);

int main() {
#ifdef LOCAL
  freopen("../IO/d.in", "r", stdin);
//  freopen("../IO/d.out", "w", stdout);
#else
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::cout.tie(nullptr);
#endif
  solve(std::cin, std::cout);
  return 0;
}

void solve(std::istream &in, std::ostream &out) {
  int k;
  in >> k;
  queue<int64_t> Q;
  for (int i = 1; i <= 9; ++i) {
    Q.push(i);
  }
  for (int i = 1; i < k; ++i) {
    int64_t top = Q.front();
    Q.pop();
    if (top % 10)
      Q.push(top * 10 + top % 10 - 1);
    Q.push(top * 10 + top % 10);
    if (top % 10 < 9)
      Q.push(top * 10 + top % 10 + 1);
  }
  out << Q.front() << '\n';
}



Measured memory_bytes: 1792
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    a, b = map(int, readline().split())

    if a + b == 15:
        print("+")
    elif a * b == 15:
        print("*")
    else:
        print("x")


if __name__ == '__main__':
    main()


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

int main(int argc, const char * argv[]) {
    char str1[10000],str2[10000],str3[10000];
    char a;
    gets(str1);
    gets(str2);
    strcpy(str3,str1);
    strcat(str1,str3);
    
    a = strstr(str1,str2);
    if(a == 0){
        printf("No\n");
    }else{
        printf("Yes\n");
    }

    return 0;
}

Measured memory_bytes: 528
#include <stdio.h>
#include <math.h>
#include<bits/stdc++.h>
using namespace std;
#define int long long int
 #define hi ios_base :: sync_with_stdio(false); cin.tie(0);cout.tie(0);
int i,j,k,mo;
main()

{
    int n;cin>>n;
    int a[n+1],b[n+1];
    for(i=0;i<n+1;i++) cin>>a[i];
    for(i=0;i<n;i++) cin>>b[i];
    b[n]=0;
    int s=0,cm=0;
    for(i=0;i<n+1;i++)
    {
        if(i==0&&b[i]>=a[i])
        {
            s=a[i];
            cm+=a[i];
            a[i]=a[i]-s;
            b[i]=b[i]-s;
        }
        else if(i==0&&a[i]>b[i])
        {
            cm+=b[i];
            s=b[i];
            a[i]=a[i]-s;
            b[i]=b[i]-s;
        }
        else
        {
            int k=b[i-1];
            if(a[i]>=k)
            {
                a[i]=a[i]-k;
                cm=cm+k;
                if(a[i])
                {
                    if(a[i]>=b[i])
                    {
                        s=b[i];
                        a[i]=a[i]-s;
                        b[i]=b[i]-s;
                        cm+=s;
                    }
                    else
                    {
                        s=a[i];
                        a[i]=a[i]-s;
                        b[i]=b[i]-s;
                        cm+=s;
                    }
                }
            }
            else
            {
                cm+=a[i];

                a[i]=a[i]-k;

            }
        }
    }
  cout<<cm<<endl;

}


Measured memory_bytes: 5100
INF = 10 ** 18
N, K = gets.split.map(&:to_i)
$eat_costs = gets.split.map(&:to_i).sort
$food_costs = gets.split.map(&:to_i).sort { |a, b| b <=> a }

def possible?(limit)
  neccesary_training = 0
  N.times do |i|
    tmp_cost = $eat_costs[i] - limit / $food_costs[i]
    neccesary_training += tmp_cost if tmp_cost > 0
  end
  neccesary_training <= K
end

puts (0..INF).bsearch { |limit| possible?(limit) }


Measured memory_bytes: 32724
n=int(input())
s=[input() for _ in range(n)]
isFinishA=[s[i][-1]=='A' for i in range(n)]
isStartB=[s[i][0]=='B' for i in range(n)]
ans=0
for si in s:
    wasA=False
    for sij in si:
        if sij=='B':
            if wasA:
                ans+=1
        wasA=(sij=='A')

fromBtoA=0
fromB=0
toA=0
for i in range(n):
    if isFinishA[i]:
        if isStartB[i]:
            fromBtoA+=1
        else:
            toA+=1
    else:
        if isStartB[i]:
            fromB+=1

if fromBtoA==0:
    ans+=min(fromB,toA)
else:
    if fromB+toA>0:
        ans+=fromBtoA+min(fromB,toA)
    if fromB+toA==0:
        ans+=fromBtoA-1
# print(fromB,toA,fromBtoA)
print(ans)


Measured memory_bytes: 3828
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0; i<n; i++)
#define REP(i,x,n) for (int i=x; i<n; i++)
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;

int main(){
  int n;
  cin >> n;
  vi a(n+2);
  a.at(0) = 0;
  a.at(n+1) = 0;
  int sum = 0;
  REP(i,1,n+1){
    cin >> a.at(i);
  }
  rep(i,n+1){
    sum += abs(a.at(i+1) - a.at(i));
  }
  REP(i,1,n+1){
    if ((a.at(i) > a.at(i-1) && a.at(i) < a.at(i+1)) ||
     (a.at(i) < a.at(i-1) && a.at(i) > a.at(i+1))){
      cout << sum << endl;
    }
    else {
      cout << sum - abs(a.at(i) - a.at(i-1)) - abs(a.at(i+1) - a.at(i)) + abs(a.at(i+1) - a.at(i-1)) << endl;;
    }
  }
  return 0;
}


Measured memory_bytes: 3744
#include<stdio.h>
int main(){
    int x,y,i;
    while(1){
        scanf("%d%d",&x,&y);
        if(x==0&&y==0)break;
        if(x>y){
                i=x;
                x=y;
                y=i;
        }
        printf("%d %d\n",x,y);
    }
    return 0;
}

Measured memory_bytes: 2616
while True:
	s = input()
	if s=='-':
		exit(0)
	m = int(input())
	for i in range(0,m):
		h = int(input())
		s = s[h:]+s[:h]
	print(s)

#s = 'abcdefgh'
#h = 3
#print(s[3:]+s[:3])


Measured memory_bytes: 5592
#!/usr/bin/env python3
import sys


def solve(S: str):
    ret = 'AC'
    if S[0] != 'A':
        ret = 'WA'
    else:
        count = 0
        for i, c in enumerate(S[1:]):
            if not c.islower():
                if count < 1 and c == 'C' and i >= 1 and i <= len(S) - 3:
                    count += 1
                else:
                    ret = 'WA'
                    break
        if count < 1:
            ret = 'WA'
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <iostream>
#include <math.h>
#include<algorithm>
#include <vector>

using namespace std;

int main(){
    int n;
    int count = 0;
    int a[50];
    int b[50];

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

    sort(b,b+n); //b is sorted

    for (int i = 0; i < n;i++){
        if(a[i]!=b[i]){
            count++;
        }
    }
    if(count<=2){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef vector<long long> vi;
typedef pair<long long, long long> ii;
typedef vector<pair<long long, long long>> vii;
typedef stringstream ss;
ll mil() {return numeric_limits<long long>::min();}
ll mal() {return numeric_limits<long long>::max();}

#define R3(i, a, b) for(long long i=(a); i<(b); ++i)
#define R2(i, b) for(long long i=0; i<(b); ++i)
#define R1(b) for(long long i=0; i<(b); ++i)
#define RR(i, a, b) for(long long i=a; i>b; --i)
#define PB(x) push_back(x)
#define MP(x, y) make_pair(x, y)

istringstream lcin;
void rl() { string s; getline(cin, s); lcin = istringstream(s);}
// build: ctrl + f9

// run: shift + f10
// debug: shift + f9
// sanitize: shift + f11

int main(int, char **) {
ios::sync_with_stdio(false);
cin.tie(nullptr);
    int N, M;
    

    cin >> N;
    cin >> M;    
    ll totAssignments = 0;
    
    R1(M) {
        int ai;
        cin >> ai;
        totAssignments += ai;
    }

    if(totAssignments <= N) 
        cout << N - totAssignments << endl;    
    else 
        cout << -1 << endl;    

}

Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
int main(){
	string a;
	cin>>a;
	int l=a.length();
	string t;
	for(int i=0;i<a.length();i++){
		t+=a[i];
		//cout<<"t: "<<i<<' '<<t<<" A: "<<a<<'\n';
		if(a=="dream"||a=="erase"||a=="dreamer"||a=="eraser"){
			cout<<"YES\n";
			return 0;
		}
		if(t=="dream"){
			if(i+4<a.length()){
				if(a[i+1]=='e'&&a[i+2]=='r'&&((a[i+3]=='e'&&a[i+4]=='r')||(a[i+3]=='d'&&a[i+4]=='r'))){
					a.erase(0,t.length()+2);
					t="";
					i=-1;
				}
				else{
					a.erase(0,t.length());
					t="";
					i=-1;
				}
			}
			else{
				a.erase(0,t.length());
				t="";
				i=-1;
			}
		}
		if(t=="erase"){
			if(a[i+1]=='r'){
				a.erase(0,t.length()+1);
				t="";
				i=-1;
			}
			else{
				a.erase(0,t.length());
				t="";
				i=-1;
			}
		}
	}
	if(a.length()==0){
		cout<<"YES\n";
	}
	else{
		cout<<"NO\n";
	}
}

Measured memory_bytes: 3740
n=int(input())
A=list(map(int,input().split()))

S=0
for a in A:
    S+=abs(a)




cnt=0
for a in A:
    if a<0:
        cnt+=1
if cnt%2==0:
    print(S)
else:
    m=abs(A[0])
    for i in range(n):
        if m>abs(A[i]):
            m=abs(A[i])
    print(S-2*m)
    

Measured memory_bytes: 14412
#include <iostream>
#include <utility>
#include <set>
#include <vector>

using namespace std;

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

  using Point = pair<int, int>;

  set<pair<Point, bool>> points;
  for(int i = 0; i < N; ++i) {
    int a, b;
    cin >> a >> b;
    points.insert(make_pair(make_pair(a, b), false));
  }
  for(int i = 0; i < N; ++i) {
    int c, d;
    cin >> c >> d;
    points.insert(make_pair(make_pair(c, d), true));
  }

  int ans = 0;
  vector<pair<Point, bool>> reds;
  for(auto it = cbegin(points); it != cend(points); ++it) {

    if(!it->second) {  // 赤い点
      reds.push_back(make_pair(it->first, false));
    }

    else {  // 青い点
      auto y_max_red = end(reds);
      for(auto red = begin(reds); red != cend(reds); ++red) {
        if(!red->second && (red->first.second < it->first.second)) {
          if(y_max_red == end(reds)) {
            y_max_red = red;
          }
          else {
            y_max_red = (red->first.second > y_max_red->first.second) ? red : y_max_red;
          }
        }
      }
      if(y_max_red != end(reds)) {
        y_max_red->second = true;
        ++ans;
      }
    }

  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define vi vector<int>
#define ll long long
#define ld long double
#define vvi vector<vi>
#define vll vector<ll>
#define vld vector<ld>
#define vvll vector<vll>
#define vvld vector<vld>
#define MOD 1000000007
#define endL << '\n'
#define ii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define se second
#define mp make_pair
#define endL << '\n'
#define vii vector<ii>
#define pb push_back

/*
ll powmod(ll x, ll y, ll mod){
	ll res = 1;
	while (y > 0){
		if (y%2) res = (res*x) % mod;
		x = (x*x) % mod;
		y /= 2;
	}
	return res;
}
*/

/*const int N = 1000000;
int lp[N+1];
vector<ll> pr;

void sieve(){
	for (int i=2; i<=N; ++i) {
	    if (lp[i] == 0) {
	        lp[i] = i;
	        pr.push_back (i);
	    }
	    for (int j=0; j<(int)pr.size() && pr[j]<=lp[i] && i*pr[j]<=N; ++j)
	        lp[i * pr[j]] = pr[j];
	}
}*/

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t=1; //cin >> t;
	while(t--){
		int n, k; cin >> n >> k;
		vi a(n); for (int i = 0; i < n; i++) cin >> a[i];
		vi dp(k+1, 0);
		for (int i = 1; i <= k; i++){
			for (int j = 0; j < n; j++){
				if (a[j] > i) continue;
				dp[i] = dp[i] || !dp[i-a[j]];
			}
		}
		if (dp[k]) cout << "First";
		else cout << "Second";
	}
}

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

int main(){
  int n,l, sum=0, t;
  cin >> n >> l;
  pair<int, int>a[n];
  for(int i=0;i<n;i++){
    if(l+i>0) t=1;
    else t=-1;
    a[i]=make_pair(l+i,t);
    sum+=l+i;
    if(l+i<0)a[i].first*=-1;
  }
  sort(a,a+n);
  cout <<sum-a[0].first*a[0].second<<endl;
    
}

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

int main()
{
    int n;
    cin >> n;
    vector<int> v(n);
    for(int i=0; i<n; i++) cin >> v[i];
    sort(v.begin(), v.end());
    int ans = 0;    
    for(int i=0; i<n; i++){
        for(int j=i; j<n; j++){
            if(i == j) continue;
            int a = v[i];
            int b = v[j];
            int right = a + b;
            auto r = lower_bound(v.begin(), v.end(), right);
            ans += ((r-v.begin()) -1 - j);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
A,B=map(int,input().split())
S=input()
#print(A,B,S)
#print(S[:A],S[A+1:])
if(len(S[:A])==A and S[A]=='-' and len(S[A+1:])==B and S.count('-')==1):
  print('Yes')
else:print('No')

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repe(i,n) for (int i = 0; i <= (n); ++i)
#define repe1(i,n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a * b / gcd(a, b);}

ll pow_kai(ll a, ll n) {
    ll x = 1;
    while(n > 0) {
        if(n&1) {
            x = x*a;
        }
        a = a*a;
        n >>= 1;
    }
    return x;
}

int main() {
    ll a,b,k;
    cin >> a >> b >> k;
    set<ll> v;
    vector<ll> vv;
    int cnt = 0;
    int cntd = b;
    int mmax = min(b,k+a);
    int nmax = max(a, b-k);
    for(ll i=a; i<=b; ++i) {
        if (i<=a+k-1 || i>=b-k+1) {
            v.insert(i);
        }
    }
    for(auto vvv: v) {
        vv.pb(vvv);
    }
    sort(all(vv));
    rep(i,vv.size()) {
        cout << vv[i] << "\n";
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

		char result;

		int m = sc.nextInt();
		int f = sc.nextInt();
		int r = sc.nextInt();

		for (; m != -1 || f != -1 || r != -1;) {
			if (m == -1 || f == -1) {
				result = 'F';
			} else if (m + f >= 80) {
				result = 'A';
			} else if (m + f >= 65) {
				result = 'B';
			} else if (m + f >= 50) {
				result = 'C';
			} else if (m + f >= 30) {
				if (r >= 50) {
					result = 'C';
				} else {
					result = 'D';
				}
			} else {
				result = 'F';
			}

			System.out.println(result);

			m = sc.nextInt();
			f = sc.nextInt();
			r = sc.nextInt();
		}
		
		sc.close();
	}
}

Measured memory_bytes: 19296
L,R = map(int,input().split())
if R - L > 2020:
    print(0)
    quit()
table = [i for i in range(L,R+1)]
from itertools import combinations
# combinations('ABCD', 2) --> AB AC AD BC BD CD
# combinations(range(4), 3) --> 012 013 023 123
combi_list = list(combinations(table,2))

cand = []

for x in combi_list:
    cand.append((x[0] * x[1]) % 2019)

print(min(cand))


Measured memory_bytes: 191548
import numpy as np
D,G=list(map(int,input().split()))
p=np.zeros(D)
c=np.zeros(D)
for i in range(D):
    a,b=list(map(int,input().split()))
    p[i]=a
    c[i]=b
    
def solve(x):  
    score=0
    cost=0
    no_use=0
    
    b=str(format(x,'010b'))
    for i in range(1,D+1):
        if b[-i]=="1": #全問解答する
            score+=100*i*p[i-1]+c[i-1]
            cost+=p[i-1]
        else:
            no_use=i-1

    if score<G: #足りていない場合
        no_solve=p[no_use]-1
        while(no_solve!=0):
            score+=100*(no_use+1)
            cost+=1
            if score>=G:
                return cost
            no_solve-=1
                
    if score<G:
        return 10**9+7
    return cost

min_cost=10**9+7
for x in range(2**D):
    cost=solve(x)
    if cost<min_cost:
        min_cost=cost
print(int(min_cost))

Measured memory_bytes: 12504
#include <iostream>
using namespace std;
int n,dmax;
int m[300];
bool visited[300], isVisit[300], isGoal;
void dfs(int p){
  if(visited[p])return ;
  visited[p] = true;
  isVisit[p] = true;
  if(p == n+1){
    isGoal = true;
    return;
  }
  for(int i = 1; i <= dmax && p+i <= n+1; i++){
    int np = p+i;
    np = np + m[np];
    if(np > n + 1)np = n + 1;
    if(np < 0) np = 0;  
    dfs(np);
  }
}
void solve(){
  fill(isVisit, isVisit+(n+2), false);
  isVisit[0] = true;
  for(int i = 0 ; i <= n; i++){
    if(!isVisit[i])continue;
    isGoal = false;
    fill(visited, visited+(n+2), false);
    dfs(i);
    if(!isGoal)break;    
  }
  cout << (isGoal?"OK":"NG") << endl;
}
int main(){
  while( cin >> dmax, dmax ){
    cin >> n;
    fill(m, m+(n+2), 0);
    for(int i = 0 ; i < n ;i++){
      cin >> m[i+1];
    }
    solve();
  }
  return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
/*
#include<algorithm>
#include<array>
#include<cassert>
#include<cmath>
#include<cstdlib>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<typeinfo>
#include<utility>
#include<vector>
*/
#define int long long int
#define double long double
using namespace std;
#define MOD 1000000007
#define INF 1000000000000000007
const int MAX_N = 1 << 17;
#define REP(i, n) for (int(i) = 0, i##_len = (n); (i) < i##_len; (i)++)
#define REPS(i, x) for (int(i) = 1; (i) <= (int)(x); (i)++)
#define RREP(i, x) for (int(i) = ((int)(x)-1); (i) >= 0; (i)--)
#define RREPS(i, x) for (int(i) = ((int)(x)); (i) > 0; (i)--)
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define pb push_back
#define mp make_pair
#define BIT(n) ((int)(1) << (n))
#define ALL(x) (x).begin(), (x).end()
#define debug(x) std::cout << #x << ": " << (x) << std::endl
#define nint int
using namespace std;

int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
typedef pair<int, int> pii;
typedef pair<double, double> dop;
template <class T>
bool chmax(T& a, const T& b)
{
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b)
{
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
struct aaa {
    aaa()
    {
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout << fixed << setprecision(20);
    };
} aaaaaaa;


signed main()
{
    int n, m;
    cin >> n >> m;
    int sum = 0;
    for (int i = 0; i < m; i++) {
        int temp;
        cin >> temp;
        sum += temp;
    }
    if (n < sum) {
        cout << -1 << endl;
    } else {
        cout << n - sum << endl;
    }
    return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int v[n];
  int l1=0;
  int l2=0;
  for(int i=0;i<n;i++)
  {
  	cin>>v[i];
  	if(v[i]>l1) 
	  {
  		l2=l1;
	  l1=v[i];
	}
	else 
	{
		if(v[i]>l2 && v[i]!=l1) 
		{
			l2=v[i];
		}
	}
  }

int count=0;
	for(int i=0;i<n;i++)
	{
		if(v[i]==l1)
		{		
			count+=1;
		if(count==2)  break;
	}
    }
	if(count==2) 
	{
	for(int i=0;i<n;i++)
	{
		cout<<l1<<endl;
		}
	}
	else
	{
		for(int i=0;i<n;i++)
		{
			if(v[i]==l1) cout<<l2<<endl;
			else cout<<l1<<endl;
		}
	}
		
	    


}
   
    
  

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

N = int(input())
A = 1
B = 1

for i in range(N):
    t, a = map(int, input().split())
    n = max((-1 * A // t) * -1, (-1 * B // a) * -1)
    A = n * t
    B = n * a
print(A + B)


Measured memory_bytes: 3060