akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main(void){
	int isPrime[123456*2+1];
	int i,j;
	isPrime[0]=0;
	isPrime[1]=0;
	for(i=2;i<=123456*2;i++){
		isPrime[i]=1;
	}
	for(i=2;i<=123456*2;i++){
		if(isPrime[i]){
			for(j=2;i*j<=123456*2;j++){
				isPrime[i*j]=0;
			}
		}
	}

	int n;
	while(scanf("%d",&n),n){
		i=0;
		for(j=n+1;j<=2*n;j++){
			i+=isPrime[j];
		}
		printf("%d\n",i);
	}

	return 0;
}

Measured memory_bytes: 1564
N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
ans = 0
pre = -100
for i in range(N):
    ans += b[a[i] - 1]
    if pre + 1 == a[i]:
        ans += c[pre - 1]
    pre = a[i]

print(ans)

Measured memory_bytes: 38384
import scala.io.StdIn
import scala.collection.mutable

object Main extends App {
  val n = StdIn.readLine().toInt
  var p : Array[Array[Int]] = Array.empty

  (0 to n - 1).foreach {i =>
    p = p :+ StdIn.readLine.split(" ").map(_.toInt)
  }

  

  val tmp = p.permutations
  var sum: Double = 0
  var cnt = 0

  tmp.foreach { j =>
    cnt = cnt + 1
    var prev :Array[Int] = Array.empty
    sum = sum + j.foldLeft[Double](0) {(acc, v) =>
      if (prev.isEmpty) {
        prev = v; 0
      } else {
        acc + Math.sqrt(Math.pow(prev(0) - v(0), 2) + Math.pow(prev(1) - v(1), 2))
      }
    }
  }
  print(sum / cnt)
}


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

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int N;
  string S;
  cin >> N >> S;
  int n = 'Z' - 'A' + 1;
  for (auto& c : S)c = ((c + N - 'A') % n + 'A') & 0xff;
  cout << S << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<functional>

using namespace std;


int main() {
	int N, a, b, p, xa, xb, xp;
	char s[10];
	scanf("%d", &N);

	a = 0;
	b = N;
	p = (a + b) / 2;

	printf("0\n");
	fflush(stdout);
	scanf("%s", s);

	if (s[0] == 'M') { xa = 0; xb = 0; }
	if (s[0] == 'F') { xa = 1; xb = 1; }
	
	for (int i = 0; i < 25;i++) {
		printf("%d\n", p);
		fflush(stdout);
		scanf("%s", s);
		if (s[0] == 'M') { xp = 0; }
		if (s[0] == 'F') { xp = 1; }
		/*a-pとxa-xpの偶奇が同じなら、a = pとする*/
		if ((a + p + xa + xp) % 2 == 0) { a = p; xa = xp; }
		else { b = p; xb = xp; }
		p = (a + b) / 2;
	}

}

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<ll> VI; typedef pair<int,int> pii;
const int mod = (int)1e9 + 7;
void dbg(){ cerr << "\n"; }  template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main()
{
	//cin.tie(0); ios_base::sync_with_stdio(false);
	
	string sa, sb;
	cin >>sa >>sb;
	vector<vector<int16_t>> dp(sz(sa)+3, vector<int16_t>(sz(sb)+3));
	vector<vector<int16_t>> bf(sz(sa)+3, vector<int16_t>(sz(sb)+3, -1));
	rep(i,sz(sa)) rep(j,sz(sb)){
		if(sa[i]==sb[j]){ dp[i+1][j+1] = dp[i][j]+1; bf[i+1][j+1]= 0;}
		else{
			if(dp[i+1][j]< dp[i][j+1]){
				//dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1]);
				dp[i+1][j+1] = dp[i][j+1];
				bf[i+1][j+1] = 2;
			}else{
				dp[i+1][j+1] = dp[i+1][j];
				bf[i+1][j+1] = 3;
			}
		}
	}
	//cout << dp[sz(sa)][sz(sb)] <<"\n";
	
	//for(auto xl: dp){for(auto x :xl) printf("%2d ",x); puts("");}
	//puts("");
	//for(auto xl: bf){for(auto x :xl) printf("%2d ",x); puts("");}

	if(dp[sz(sa)][sz(sb)] ==0){cout <<" \n"; return 0;}
	int y=sz(sa), x=sz(sb);
	string ans;
	while(1){
		if(bf[y][x] ==0){
			ans += sa[y-1];
			y--; x--;
		}else if(bf[y][x] ==3){
			x--;
		}else if(bf[y][x] ==2) y--;
		else break;
	}
	reverse(all(ans));
	cout << ans <<"\n";
	return 0;
}


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

int fn(int arr[], int n)
{
    multiset<int> last;

    // last element in each  increasing subsequence
    // found so far
    for (int i = 0; i < n; i++) {

        // here our current element is arr[i]
        multiset<int>::iterator it = last.lower_bound(arr[i]);

        // iterator to the first element larger
        // than or equal to arr[i]
        if (it == last.begin())

            // if all the elements in last larger
            // than or to arr[i] then insert it into last
            last.insert(arr[i]);

        else {
            it--;

            // the largest element smaller than arr[i] is the number
            // before *it which is it--
            last.erase(it); // erase the largest element smaller than arr[i]
            last.insert(arr[i]); // and replace it with arr[i]
        }
    }
    return last.size(); // our answer is the size of last
}



int main()
{
    int n,i,j,k; cin>>n; int a[n];
    for(i=0;i<n;i++) cin>>a[i];

    cout<<fn(a,n);

    return 0;
}


Measured memory_bytes: 5376
#include <vector>
#include <list>
#include <map>
#include <string>
#include <iostream>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <utility>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;

ll solve(void);

int main(void)
{
	while (solve())
	{
	}
	return 0;
}

ll solve(void)
{
	ll N;
	cin >> N;

	vector<pair<ld, ld>> v(N);

	for (auto& p : v)
	{
		cin >> p.first >> p.second;
	}

	ld sum = 0.0;
	ll cnt = 0;
	for (ll i = 0; i < N; i++)
	{
		for (ll j = i + 1; j < N; j++)
		{
			sum += sqrtl(
				powl(v[i].first - v[j].first, 2.0)
				+ powl(v[i].second - v[j].second, 2.0)
			);
		}
	}

	ld ans = sum * 2.0 / ld(N);
	printf("%.10Lf\n", ans);

	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 n = Integer.parseInt(sc.next());

    int[] a = new int[n];

    for (int i = 0; i < n; i++) {
      a[i] = Integer.parseInt(sc.next()) / 400;
    }

    int color = 0;
    int free = 0;
    boolean[] flag = new boolean[8];
    for (int i = 0; i < n; i++) {
      switch (a[i]) {
        case 0:
          if (!flag[0]) {
            color++;
            flag[0] = true;
          }
          break;
        case 1:
          if (!flag[1]) {
            color++;
            flag[1] = true;
          }
          break;
        case 2:
          if (!flag[2]) {
            color++;
            flag[2] = true;
          }
          break;
        case 3:
          if (!flag[3]) {
            color++;
            flag[3] = true;
          }
          break;
        case 4:
          if (!flag[4]) {
            color++;
            flag[4] = true;
          }
          break;
        case 5:
          if (!flag[5]) {
            color++;
            flag[5] = true;
          }
          break;
        case 6:
          if (!flag[6]) {
            color++;
            flag[6] = true;
          }
          break;
        case 7:
          if (!flag[7]) {
            color++;
            flag[7] = true;
          }
          break;
        case 8:
        default:
          free++;
          break;
      }

    }
    System.out.print(Math.max(color, 1) + " ");
    System.out.println(color + free);
    sc.close();
  }
}

Measured memory_bytes: 21972
import java.util.*;
import java.util.stream.LongStream;
public class Main {
	static Scanner s = new Scanner(System.in);
	public static void main(String __[]){
		int x=s.nextInt(),y=s.nextInt();
		System.out.println(LongStream.of(
				calc( x,  y),
				calc(-x,  y)+1,
				calc( x, -y)+1,
				calc(-x, -y)+2).min().getAsLong());
	}
	static long calc(int x,int y) {
		return y-x<0?1145141919810L:y-x;
	}
}


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

int main()
{
	int n,r,p,c;
	int x[64],t[64];
	while(cin >> n >> r, n||r)
	{
		for(int i=0; i<n; i++)
		{
			x[i]=n-i;
		}

		while(r--)
		{
			cin >> p >> c;
			for(int i=0; i<p-1; i++)
			{
				t[i] = x[i];
			}
			for(int i=0; i<c; i++)
			{
				x[i] = x[p-1+i];
			}
			for(int i=0; i<p-1; i++)
			{
				x[c+i] = t[i];
			}
		}
		cout << x[0] << endl;

	}
}

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

using namespace std;

#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pow(x) x*x
#define ll long long
static const ll MAX = 1000000;
static const ll INFTY = 1e12;
static const ll MOD = 1000000007;

template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };

struct edge {
    ll to, cost;
};

using Graph = vector<vector<int>>;
using _Graph = vector<vector<edge>>;


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

// 深さ優先探索
vector<bool> seen;
vector<int> colors;

int H, W, N;
int sx, sy, gx, gy; 
vector<vector<char>> field;
vector<vector<int>> dist;
//vector<pair<int, int>> gx, gy;
deque<pair<int, int>> que;

typedef vector<vector<int> > Matrix;

const int INF = 100000000;


int main() {

    string S;
    cin >> S;
    string S_1 = S;
    string S_2 = S;
    REP(i, S.length()){
        S_1[i] = '0' + i % 2;
        S_2[i] = '0' + (i+1) % 2;
    }

    int count1 = 0;
    int count2 = 0;
    REP(i, S.length()){
        if(S[i]!=S_1[i])count1++;
        if(S[i]!=S_2[i])count2++;
    }

    cout << min(count1, count2) << endl;

}


/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/


Measured memory_bytes: 512
import math

K = int(input())

gcds = []

for a in range(1, K + 1):
    for b in range(1, K + 1):
        gcds.append(math.gcd(a, b))

# print(gcds)

ans = 0
for c in range(1, K + 1):
    for g in gcds:
        if c == 1 or g ==1:
            ans += 1
        else:
            ans += math.gcd(c, g)

print(ans)


Measured memory_bytes: 9356
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        int[] bits = new int[12]; //26進数を記録
        int top = 0; //26進表記何桁か
        
        //26進数に変換
        while(n > 0) {
            bits[top] = (int)(n % 26);
            n /= 26;
            //0を埋めてたら繰り下がり
            if(bits[top] == 0) {
                bits[top] = 26;
                n--;
            }
            top++;
        }

        //上の桁から出力
        for(int i = top - 1; i >= 0; i--) {
            System.out.print((char)('a' + bits[i] - 1));
        }
        System.out.println();
    }
}


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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    int n,k;
    cin>>n>>k;
    vector<int> a(n+1);
    for(int i=1;i<=k;i++)
    {
        int d;
        cin>>d;
        for(int i=0;i<d;i++)
        {
            int x;
            cin>>x;
            a[x]++;
        }
    }
    int ans=0;
    for(int i=1;i<=n;i++) if(a[i]==0) ans++;
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <queue>
#include <utility>
#include <vector>

#define MAX_NODE 10000
#define INF 1000000000

using namespace std;

struct Edge {
	int to, w;
	Edge(int to, int w) {
		this->to = to;
		this->w = w;
	}
};
typedef pair<int, int> pii;

vector<Edge> adj[MAX_NODE];
int d[MAX_NODE];

void dijkstra(int n, int start) {
	priority_queue<pii, vector<pii>, greater<pii>> que;
	fill(d, d + n, INF);

	d[start] = 0;
	que.emplace(0, start);
	while (!que.empty()) {
		pii p = que.top();
		que.pop();
		int from = p.second;

		if (d[from] < p.first)
			continue;

		for (auto& e : adj[from])
			if (d[from] + e.w < d[e.to]) {
				d[e.to] = d[from] + e.w;
				que.emplace(d[e.to], e.to);
			}
	}
}

int main() {
	int n;

	cin >> n;

	for (int i = 0; i < n; i++) {
		int u, k;
		cin >> u >> k;
		while (k--) {
			int v, c;
			cin >> v >> c;
			adj[u].emplace_back(v, c);
		}
	}

	dijkstra(n, 0);

	for (int i = 0; i < n; i++)
		cout << i << " " << d[i] << endl;

	return 0;
}

Measured memory_bytes: 6292
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define debugArray(x, n)                           \
  cerr << __LINE__ << ": " << #x << " = {";        \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];        \
  cerr << "}" << endl
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  long long A[N];
  for (int i = 0; i < N; i++) cin >> A[i];
  long long dp[N + 1][2][2];
  const long long INF = INT_MAX;
  dp[0][0][0] = 0;
  dp[0][0][1] = -INF;
  dp[0][1][0] = -INF;
  dp[0][1][1] = -INF;
  for (int i = 1; i <= N; i++) {
    if (i & 1) {
      dp[i][0][0] = max(dp[i - 1][0][0], dp[i - 1][1][0]);
      dp[i][0][1] = max(dp[i - 1][0][1], dp[i - 1][1][1]);
      dp[i][1][0] = dp[i - 1][0][1] + A[i - 1];
      dp[i][1][1] = dp[i - 1][0][0] + A[i - 1];
    } else {
      dp[i][0][0] = dp[i - 1][1][1];
      dp[i][0][1] = max(dp[i - 1][0][0], dp[i - 1][1][0]);
      dp[i][1][0] = dp[i - 1][0][0] + A[i - 1];
      dp[i][1][1] = dp[i - 1][0][1] + A[i - 1];
    }
  }
  long long ans = max(dp[N][0][0], dp[N][1][0]);
  cout << ans << endl;
  return 0;
}


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

#include <iostream>
#include <algorithm>

#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <queue>
#include <deque>
#include <string>
#include <utility>
#include <array>
#include <complex>
#include <valarray>

#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <chrono>
#include <random>
#include <numeric>


using namespace std;
//#define int long long

typedef long long ll;
typedef unsigned long long ull;
//typedef unsigned __int128 HASH;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll,int> plli;
typedef pair<double, int> pdbi;
typedef pair<int,pii> pipii;
typedef pair<ll,pll> plpll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;
typedef vector<vector<int>> mat;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()

const ll hmod1 = 999999937;
const ll hmod2 = 1000000000 + 9;
const int INF = 1<<30;
const ll mod = 1000000000 + 7;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;

#define addm(X, Y) (X) = ((X) + ((Y) % mod) + mod) % mod
#define inside(y, x, h, w) (0 <= (y) && (y) < (h) && 0 <= (x) && (x) < (w)) ? true : false

int n, m, z, w;
int a[2005];

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> z >> w;
    rep(i, n) cin >> a[i];
    if (n == 1) {
        int ans = abs(a[0] - w);
        cout << ans << endl;
        return 0;
    }
    int ans = max(abs(a[n - 1] - w), abs(a[n - 1] - a[n - 2]));
    cout << ans << endl;


}

Measured memory_bytes: 256
// Author: Shusuke Ueda
// AtCoder Beginner Contest 135 - Problem B

#include <iostream>
#include <vector>
#include <algorithm>

int main() {
    int n;
    std::cin >> n;
    std::vector<int> a(n);
    for (auto& e: a) {
        std::cin >> e;
    }

    if (is_sorted(a.begin(), a.end())) {
        std::cout << "YES" << std::endl;
        return 0;
    }

    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            auto b = a;
            std::swap(b[i], b[j]);
            if (std::is_sorted(b.begin(), b.end())) {
                std::cout << "YES" << std::endl;
                return 0;
            }
        }
    }

    std::cout << "NO" << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<map>
#define  ll long long 
using namespace std;
int main()
{
	int a[10000]={0};
	int n;
	ll sum=0;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
	}
	for(int i=0;i<n-1;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			sum+=(a[i]*a[j]);
		}
	}
	printf("%lld\n",sum);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
long long int power(int a,int b)
{
    if(b==0)
        return 1;
    long long int k=power(a,b/2);
    if(b%2==0)
        return ((k%M)*(k%M))%M;
    else
        return ((k%M)*(k%M)*(a%M))%M;
}
long long int fact(long long int n)
{
    if(n==1 || n==0)
        return 1;
    else
        return ((n%M)*(fact(n-1)%M))%M;

}
int div(int n)
{  int c=0;
    for(int i=1;i<=sqrt(n);i++)
    {
        if(n%i==0)
        {
          if(n/i==i)
            c++;
          else
            c+=2;
        }

    }

    
    return  c;
}
int func(int n)
{
    return (n*(n+1))/2;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
     #ifndef ONLINE_JUDGE
 
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
 
   #endif
   
    int a,b;
    cin>>a>>b;
    int k;
    cin>>k;
    set<int>s; 
    for(int i=0;i<k;i++)
    {
        if(i+a<=b)
        {
            s.insert(i+a);
        }
    }
    for(int i=0;i<k;i++)
    {
        if(b-i>=a)
        {
            s.insert(b-i);
        }
    }
    for(auto x:s)
        cout<<x<<endl;


 return 0;
}








Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin() , v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)

int a, b; string s;

int main(){
    cin >> a >> b >> s;
    int cnt = 0;
    for(auto x : s) if(x == '-') ++cnt;
    if(s[a] == '-' && cnt==1) puts("Yes");
    else puts("No");
}

Measured memory_bytes: 256
from math import sqrt,ceil
N=int(input())
if N<105:
    print("0")
    exit()
ans=0
for n in range(105,N+1):
    cnt=0
    if n%2==0:
        continue
    for i in range(1,n+1):
        if n%i==0:
            cnt+=1
    if cnt==8:
        ans+=1
print(ans)

Measured memory_bytes: 38512
N = int(input())
XY = [list(map(int, input().split())) for _ in range(N)]
U = [x+y for x, y in XY]
V = [x-y for x, y in XY]
min_u = min(U)
max_u = max(U)
min_v = min(V)
max_v = max(V)
print(max(
    max_u - min_u,
    max_v - min_v
))


Measured memory_bytes: 61444
S = input()
T = input()
match = 0
ans = 0

for n in range(len(S)-len(T)+1):
  match2 = 0
  U = S[n:n+len(T)]
  for m in range(len(T)):
    if U[m]==T[m]:
      match2+=1
  match = max(match,match2)
      
print(len(T)-match)

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

using namespace std;

int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

    int n, k;

    cin >> n >> k;

    vector<int> v(n);

    for(int &x : v) cin >> x;

    vector<int> dp(k+1);// dp[i] = true se iesimo vence se existir alguma dp[i-k] | k eh pedra e o vencedor for false

    for(int stone=1; stone<=k; stone++){
        for(int x : v) if(stone >= x and !dp[stone-x]) dp[stone] = 1;
    }

    puts(dp[k] ? "First\n" : "Second\n");

    return 0;
}


Measured memory_bytes: 640
// King's Inspection

#include <iostream>
#include <cstring>
#include <vector>
#include <cstdio>

using namespace std;

int main() {
    int n;
    int now=0;
    int k[102];
    string station;
    string ans;
    string alpha = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
    
    while(1) {
      // Input
        cin>>n;
        if(n == 0) {
            break;
        }
        for(int i=0; i<n; i++) {
            cin>>k[i];
        }
        cin.ignore();

	// Output
	now = 0;
	getline(cin, station);

	for(int i=0; i<station.length(); i++) {
	    int tmp;
	    tmp = alpha.find(station[i]);
	    ans[i] = alpha[(tmp-k[now]+52)%52];
	    now++;
            if(now == n) {
                now = 0;
            }
	}
        for(int i=0; i<station.length(); i++) {
            cout<<ans[i];
        }
        cout<<endl;
    }
}

Measured memory_bytes: 1208
#include <stdio.h>

int main(void)
{
  int debt;
  int num, i;

  debt = 100000;

  scanf("%d", &num);

  for(i = 1; i <= num ; i++){
    debt *= 1.05;
    debt += 999;
    debt /= 1000;
    debt *= 1000;
  }

  printf("%d\n", debt);

  return 0;
}

Measured memory_bytes: 592
#include<cstdio>
int main()
{
	int n,k,x,y;
	scanf("%d %d %d %d",&n,&k,&x,&y);
	if(n>k){printf("%d",(n-k)*y+k*x);}
	else {printf("%d",n*x);}
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

vector< pair<ll,ll> >edge;
vector<ll> adj[100005];
vector<ll> adj_st[100005];
set< pair<ll,ll> >edges_in_st;
vector<ll> outdegree(100005,0);
vector< pair<ll,ll> >ans;

void func(ll src,vector<bool> &visited ,ll parent)
{
    visited[src]=true;
    for(auto ele:adj_st[src])
    {
        if(!visited[ele])
            func(ele,visited,src);
    }

    if(outdegree[src]&1)
    {
        if(parent==-1)
        {
            cout<<"-1";
            exit(0);
        }

        outdegree[src]++;
        ans.push_back( make_pair(src , parent) );
    }
    else
    {
        if(parent!=-1)
        {
            outdegree[parent]++;
            ans.push_back( make_pair(parent , src) );
        }
    }
}

void dfs(ll src, vector< bool> &visited)
{
    visited[src]=true;
    for(int i=0;i<adj[src].size();i++)
    {
        ll ele = adj[src][i];
        if(!visited[ele])
        {
            adj_st[src].push_back(ele);
            adj_st[ele].push_back(src);
            edges_in_st.insert( make_pair( min(src,ele) , max(src,ele) ) );
            dfs(ele,visited);
        }
    }
}

int main()
{
    fast();
    ll n,m;
    cin>>n>>m;
    for(ll i=0;i<m;i++)
    {
        ll u,v;
        cin>>u>>v;
        u--;v--;
        adj[u].push_back(v);
        adj[v].push_back(u);
        edge.push_back( make_pair( min(u,v) , max(u,v) ) );
    }

    vector<bool> visited(n, false);
    dfs(0,visited);


    for(ll i=0;i<m;i++)
    {
        if(edges_in_st.find( edge[i] )!=edges_in_st.end())
            continue;
        outdegree[edge[i].first]++;
        ans.push_back( edge[i] );
    }
    vector<bool> visited_st(n,false);
    func(0,visited_st,-1);

    for(ll i=0;i<ans.size();i++)
        cout<<ans[i].first+1<<" "<<ans[i].second+1<<endl;

}



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


int main(){
string S;
int n=0;
cin >> S;
for(int i=0;i<4;i++){
if(S[i+2]==S[i+3]){
  n++;
}
}
if(n>1){
  cout << "Yes" <<endl;
}else{
  cout << "No" <<endl;
}
return 0;
}


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


#define base 1000000007LL
#define ll long long
#define ld long double
#define X first
#define Y second
#define pb push_back
#define EPS 1e-15
#define all(a) (a).begin(), (a).end()
#define sz(a) int((a).size())

#define ms(s, n) memset(s, n, sizeof(s))

#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define sqr(a) (a)*(a)

#define foru(i,a,b) for (ll i = (a); i <= (b); i++)
#define ford(i,a,b) for (ll i = (a); i >= (b); i--)
#define cbit(a) __builtin_popcount(a)
#define uni(a) (a).resize(unique(all(a)) - (a).begin())
#define cprint(n) printf("%.6lf + %.6lfi\n", (n).real(), (n).imag())

#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it !=(a).end(); it++)


using namespace std;
typedef pair<ll, ll> II;
typedef pair<int, int> ii;


struct Edge{
    ll u,v,w;
    Edge(ll u=0, ll v=0, ll w=0): u(u),v(v),w(w) {}
    bool operator < (Edge a){return w<a.w;}
};

const int M=1e5+7;
const int MM=4*M;
const ll MOD=base;
const int MAX=1e9;


inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline ll power(ll n, ll k, ll p = MOD) {ll r = 1; for (; k; k >>= 1LL) {if (k & 1LL) r = r * n % p; n = n * n % p;} return r;}
inline ll inverse(ll n, ll p=MOD){return power(n,p-2);}
ll search(ll a[], ll N, ll x){ ll l = 0, r = N - 1; while (l <= r){ ll mid = (l + r) / 2; if (x == a[mid]){ return 1; } else if (x < a[mid]){ r = mid - 1; } else if (x > a[mid]){ l = mid + 1; } } return -1; }

ll n, k;

int main(){
	cin >> n >> k;
	if (n % k == 0){
		cout << 0; return 0;
	}
	cout << 1;
    return 0;
}


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

ll n,x,y;
ll dist[2005][2005];
ll cnt[2005];

int main(){
    cin>>n>>x>>y;
    for(int i=1; i<=n; ++i){
        for(int j=i+1; j<=n; ++j){
            dist[i][j]=j-i;
            if(i<=x && x<=j && j<=y){
                dist[i][j]=min(dist[i][j],x-i+1+y-j);
            }
            if(x<=i && i<=j && j<=y){
                dist[i][j]=min(dist[i][j],i-x+1+y-j);
            }
            if(x<=i && i<=y && y<=j){
                dist[i][j]=min(dist[i][j],i-x+1+j-y);
            }
            if(i<=x && y<=j){
                dist[i][j]=min(dist[i][j],x-i+1+j-y);
            }
            cnt[dist[i][j]]++;
        }
    }
    for(int i=1; i<=n-1; ++i){
        cout<<cnt[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 31104
#include <iostream>
#include <vector>
#include <unordered_map>
#include <map>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <deque>
#include <cmath>
#include <stack>
#include <queue>
#include <string>
#include <iomanip>
#include <cstring>
#include <climits>
#include <cstdio> 

#define nl '\n'

using namespace std;

long long n, x;

int main(){

    cin >> n;

    for(long long i = 1; i < n+1; i++) {
        if(i%3!=0 && i%5!=0) {
            x += i;
        }
    }
    cout << x;
}
 
//g++ -std=c++14 comp.cpp -o c && c.exe
//g++ -std=c++14 comp.cpp -o c; ./c.exe
//g++ -std=c++14 comp.cpp && ./a.out

//Surely this is going to AC

Measured memory_bytes: 3636
fn run() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let a: i32 = it.next().unwrap().parse().unwrap();
    let b: i32 = it.next().unwrap().parse().unwrap();
    let ans = std::cmp::max(0, a - 2 * b);
    println!("{}", ans);
}

fn main() {
    run();
}

Measured memory_bytes: 4352
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int> > Matrix;


int main(){
  int n, Q;
  string s;
  cin >> n >> Q >> s;
  vector<P> q(Q);
  vector<bool> t(n, false);
  for (int i = 0; i < n - 1; i++){
    if (s[i] == 'A' && s[i+1] == 'C') t[i] = true; 
  }
  rep(i, Q) cin >> q[i].first >> q[i].second;

  vector<int> u(n);
  u[0] = 0;
  for (int i = 1; i < n; i++){
    u[i] = u[i-1] + t[i-1];
  }
  rep(i, Q){
    int l = q[i].first-1, r = q[i].second-1;
    int ans = u[r] - u[l];
    cout << ans << "\n";
  }
  /*
  rep(i, n) cout << u[i] << " ";
  cout << endl;*/
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define all(v) (v).begin(), (v).end()
#define eb emplace_back

int main(){
    i64 N, X;
    cin >> N >> X;
    i64 D = 0;
    i64 ans = 1;
    rep(i, N){
        i64 L; cin >> L;
        D += L;
        if(D <= X) ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;
const ll LINF=1e18;

int main(){
    int x,y;
    cin>>x>>y;
    int ans=0;
    if(x==1&&y==1){
        cout<<1000000<<endl;
        return 0;
    }
    if(x==1){
        ans+=3;
    }
    else if(x==2){
        ans+=2;
    }
    else if(x==3){
        ans+=1;
    }
    if(y==1){
        ans+=3;
    }
    else if(y==2){
        ans+=2;
    }
    else if(y==3){
        ans+=1;
    }
    cout<<ans*100000<<endl;
}

Measured memory_bytes: 256
use proconio::input;

fn main() {
  input! {
    _N: usize,
    S: String
  }
  
  let mut rs: usize = 0;
  let mut gs: usize = 0;
  let mut bs: usize = 0;
  
  for (i, c) in S.chars().enumerate() {
    match c {
      'R' => rs += 1,
      'G' => gs += 1,
      'B' => bs += 1,
      _ => unreachable!()
    }
  }
  let mut result = rs * gs * bs;
  
  let chars: Vec<char> = S.chars().collect();
  let chars_len = chars.len();
  for i in 0..chars_len {
    let c = chars[i];
    for j in (i+1)..chars_len {
    let cc = chars[j];
      if c == cc { continue };
      let k = 2 * j - i;
      if chars_len <= k { continue }
      let ccc = chars[k];
      if c != ccc && cc != ccc {
        result -= 1;
      }
    }
  }
  
  println!("{}", result);
}


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

string s, t;
int dp[4096][4096];

int calc(int m, int n) {
    if(!m or !n) return 0;
    int &y = dp[m][n];
    if(y != -1) return y;
    y = max(calc(m, n-1), calc(m-1, n));
    if(s[m] == t[n]) y = max(y, 1+calc(m-1, n-1));
    return y;
}

string build(int m, int n) {
    if(!m or !n) return "";
    int temp = calc(m, n);
    if(temp == calc(m, n-1)) {
        return build(m, n-1);
    }
    else if(temp == calc(m-1, n)) {
        return build(m-1, n);
    }
    else {
        return build(m-1, n-1) + s[m];
    }
}

int main() {
    memset(dp, -1, sizeof(dp));
	cin >> s >> t;
	s = '$' + s;
	t = '#' + t;
	cout << build(s.size()-1, t.size()-1) << endl;
	return 0;
}


Measured memory_bytes: 69592
using System;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var XYZ = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            Console.WriteLine((XYZ[0]- XYZ[2]) /(XYZ[1]+XYZ[2]));
        }
    }
}


Measured memory_bytes: 13396
using System;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var s = Console.ReadLine().ToCharArray();
        var t = Console.ReadLine().ToCharArray();
        int ans = 0;
        for (int i = 0; i <= s.Length - t.Length; i++)
        {
            int count = 0;
            for (int j = 0; j < t.Length; j++)
            {
                if (s[i + j] == t[j])
                    count++;
            }
            ans = Math.Max(ans, count);
        }

        Console.WriteLine(t.Length - ans);
    }
    static int ReadInt()
    {
        return int.Parse(Console.ReadLine());
    }
    static string[] ReadStringArray()
    {
        return Console.ReadLine().Split(' ');
    }
    static int[] ReadIntArray()
    {
        return ReadStringArray().Select(i => int.Parse(i)).ToArray();
    }
}

Measured memory_bytes: 25948
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
using namespace std;

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

    long long cur = 0;
    long long ans = 0;

    for(long long i=0; i<M; i++){
        if(cur == N) break;
        long long B = CB[i].second;
        long long C = CB[i].first;
        for(int cnt=0; cnt<B && cur<N; cnt++){
            if(C <= A[cur]) break;
            ans += C;
            cur++;
        }
    }
    for(int i=cur; i<N; i++)
        ans += A[i];

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2688
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#define Rep(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define ll long long int
#define INF 1e9
#define LINF 1e18
#define MOD 1000000007
#define PI 3.14159265359
#define EPS 1e-10
#define All(a) (a).begin(), (a).end()

using namespace std;
using P = pair<ll, ll>;
 
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

/**
 * Usage:
 * 
 * G[from].push_back(Edge(to, weight));
 * using Graph = vector<vector<Edge>>;
 * 
 */ 
struct Edge {
  int to;     
  ll weight; 
  Edge(int t, ll w) : to(t), weight(w) { }
};

/**
 * Usage:
 * 
 * chmin(old, new);
 * chmax(old, new);
 * 
 */ 
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

template<typename T>
void printv(vector<T>& v) {
  if (v.size() == 0) {
    cout << "\n";
    return;
  }

  Rep(i, v.size()) {
    cout << v[i] << ((i + 1 < v.size()) ? ' ' : '\n');
  }
}



int N;
ll T;
ll a[110000];
ll b[110000];
ll d[110000];

int main () {
  cin >> N >> T;
  rep(i, N) cin >> a[i];

  ll tmp = 0LL;

  for (int k=N;k>=1;--k) {
    chmax(tmp, a[k]);
    b[k] = tmp;
  }

  rep(i, N) {
    d[i] = b[i] - a[i];
    //cout << d[i] << "\n";
  }

  ll tmp_max = 0LL;
  rep(i, N) {
    chmax(tmp_max, d[i]);
  }

  int ct = 0;
  rep(i, N) {
    if (tmp_max == d[i]) ct++;
  }

  cout << ct << "\n";
}

Measured memory_bytes: 2560
from math import factorial
from sys import exit

bign = 10**9 + 7


n,k = map(int,input().split())
nk = n-k+1

if n == k:
    print(1)
    for i in range(k-1):
        print(0)
    exit()

ans = nk
print(ans)
if k-1<=nk:
    for i in range(1,k):
        i1 = i+1
        ans = (ans * (nk-i) // i1)
        ans = (ans * (k-i) // i)
        print(ans%bign)
else:
    for i in range(1,nk+1):
        i1 = i+1
        ans = (ans * (nk-i) // i1)
        ans = (ans * (k-i) // i)
        print(ans%bign)
    for i in range(k-1-nk):
        print(0)


Measured memory_bytes: 3316
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

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



















int main(){
    string s, t;
    cin >> s >> t;
    ll c = 0;
    REP(i, 3){
        if(s[i] == t[i]) c++;
    }
    cout << c << endl;
}

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

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}



signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int N, K;
	int ans = 0;
	string n;
	
	cin>>n>>K;
	
	if(K == 1) {
		int con = ((int)n.size() - 1) * 9 + n[0] - '0';
		
		cout<<con<<endl;
	} else if(K == 2) {
		int con =  9 * 9 * (n.size()-0) * (n.size()-1) / 2 - (9 - (n[0] - '0')) * (n.size()-1) * 9;
		for(int i = 1, cc = 0, hoge = 0; i < n.size() && cc < 1; i++, hoge += 9){
			if(n[i] != '0' || n.size() == i + 1) {
				cc++;
				con -=  (9 - (n[i] - '0')) + hoge;
			}
		}
		
		cout<<con<<endl;
	} else if(K == 3) {
		int con =  9 * 9 * 9 *  (n.size()-1) * (n.size()-2) * (n.size() - 3)/ 6;
		
		for(int i = 0, cc = 0; i < n.size() && cc < 3; i++){
			if(n[i] != '0') {
				if(cc == 0) con += ((int)n.size() - i - 1) * ((int)n.size() - i - 2) / 2 * (n[i] - '1') * 9 * 9;
				else if(cc == 1) con += ((int)n.size() - i - 1)  / 1 * (n[i] - '1') * 9 + ((int)n.size() - i - 1) * ((int)n.size() - i - 2) / 2 * 9 * 9;
				else if(cc == 2) con += (n[i] - '0') + ((int)n.size() - i - 1) * 9;
				cc++;
			}
		}
		
		cout<<con<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main() {
	string s;
	cin >> s;
	if (s.at(0) == 'S') {
		cout << "Cloudy" << endl;
	}
	else if (s.at(0) == 'C') {
		cout << "Rainy" << endl;
	}
	else {
		cout << "Sunny" << endl;
	}
}

Measured memory_bytes: 256
#include<stdio.h>

#include<stdlib.h>

#include<string.h>

int main(void){

char num_str[1002];

int num;

long sum = 0;

int i;

char tmp;

while (1){

fgets(num_str,sizeof(num_str),stdin);

if (num_str[0] =='0') break;

for (i = 0; i < strlen(num_str)-1; i++){

tmp = num_str[i];

num = atoi(&tmp);

sum = sum + num;

}

printf("%ld\n",sum);

sum = 0;

memset(num_str,1002, 0);

}

return 0;

}

Measured memory_bytes: 532
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define repr4(i,s,n) for(ll i = (n);i>=(s);i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
using Graphw = vector<vector<pair<ll,ll>>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/


int main(){
string S;
int Q,revnum=0;
cin>>S>>Q;
deque<char> S_;
rep(i,S.size()){
    S_.push_back(S[i]);
}
rep(i,Q){
    int T;
    cin>>T;
    if(T==1){
        revnum++;
    }
    else{
        int F;
        char C;
        cin>>F>>C;
        if((revnum+F)%2==0){
            S_.push_back(C);
        }
        else{
            S_.push_front(C);
        }
    }
}
string ans="";
if(revnum%2==1){
    while(!S_.empty()){
    char C=S_.back();
    S_.pop_back();
    ans+=C;
    }

}
else{
    while(!S_.empty()){
    char C=S_.front();
    S_.pop_front();
    ans+=C;
    }

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

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
const int mod = 1e9 + 7;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
const double phi = (1 + sqrt(5)) / 2;
const double phi_ = (1 - sqrt(5)) / 2;
ll fib(ll n){
    double res = pow(phi, n+1) - pow(phi_, n+1);
    return res / sqrt(5);
}
ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}
ll lcm(ll x,ll y)
{
    x /= gcd(x,y);
    y /= gcd(x,y);
    return (x*y);
}
string to_bin_string(int n){
    stringstream ss;
    ss << bitset<3>(n); //任意の桁数<m>
    string s = ss.str();
    return s;
}
int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    cout << c << " " << a << " " << b << endl;
    return 0;
} 

Measured memory_bytes: 256
#include <iostream>

using std::cin;
using std::cout;
using std::endl;

int count_scale(int n) {
	int w = n/3;
	if ( n < 4 ) {
		return 1;
	}
	if ( n%3 != 0 ) {
		w++;
	}

	return count_scale(w)+1;
}

int main(void) {
	int N;
	cin >> N;
	int ret = count_scale(N);
	cout << ret << endl;

	return 0;
}

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

//aのb乗
int beki(int a,int b,int M = modulo){
	int x = 1;
	while(b!=0){
		if(b&1){
			x=((long long)x*a)%M;
		}
		a=((long long)a*a)%M;
		b>>=1;
	}
	return x;
}


//aの逆元
int gyakugen(int a){
	return beki(a,modulo-2);
}

struct combi{
	deque<int> kaijou;
	deque<int> kaijou_;
	
	combi(int n){
		kaijou.push_back(1);
		for(int i=1;i<=n;i++){
			kaijou.push_back(mod(kaijou[i-1]*i));
		}
		
		int b=gyakugen(kaijou[n]);
		
		kaijou_.push_front(b);
		for(int i=1;i<=n;i++){
			int k=n+1-i;
			kaijou_.push_front(mod(kaijou_[0]*k));
		}
	}
	
	int combination(int n,int r){
		if(r>n)return 0;
		int a = mod(kaijou[n]*kaijou_[r]);
		a=mod(a*kaijou_[n-r]);
		return a;
	}
	
	int junretsu(int a,int b){
		int x = mod(kaijou_[a]*kaijou_[b]);
		x=mod(x*kaijou[a+b]);
		return x;
	}
	
};

int main(){
	
	int N;
	cin>>N;
	
	vector<int> A(N),B(N);
	for(int i=0;i<N;i++){
		scanf("%d %d",&A[i],&B[i]);
	}
	
	vector<vector<int>> dp(4001,vector<int>(4001,0));
	
	for(int i=0;i<N;i++){
		dp[2000-A[i]][2000-B[i]]++;
	}
	
	for(int i=0;i<=4000;i++){
		for(int j=0;j<=4000;j++){
			if(i!=4000){
				dp[i+1][j] = mod(dp[i][j]+dp[i+1][j]);
			}
			if(j!=4000){
				dp[i][j+1] = mod(dp[i][j]+dp[i][j+1]);
			}
		}
	}
	
	int ans = 0;
	
	for(int i=0;i<N;i++){
		ans = mod(ans + dp[2000+A[i]][2000+B[i]]);
	}
	
	combi C(10000);
	
	for(int i=0;i<N;i++){
		ans = mod(ans - C.junretsu(A[i]*2,B[i]*2));
	}
	
	ans = mod(ans * gyakugen(2));
	
	cout<<ans<<endl;
	
    return 0;
}


Measured memory_bytes: 64640
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 1e5 + 7;
const int MOD = 1e9 + 7;
int a[N];
int main() {
	int n,Max=0,pp;
	scanf("%d",&n);
	for(int i=0;i<n;i++) {
		scanf("%d",&a[i]);
		if(a[i]>Max) {
			Max=a[i];
			pp=i;
		}
	}
	int q;
	double t=Max/2.0+0.5,p=Max*1.0;
	for(int i=0;i<n;i++) {
		if(i==pp) continue;
		if(abs((double)a[i]-t)<=p) {
			q=a[i];
			p=abs((double)a[i]-t);
		}
	}
	printf("%d %d\n",Max,q);
	return 0;
}

Measured memory_bytes: 640
//#include "stdafx.h"
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <tuple>
#include <numeric>
#include <unordered_map>
#include <cstdint>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define REP(i, n)				for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)			for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF						2e9
#define MOD						(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)				(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)				(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)			((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)				(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)				(!IsOdd((x)))						
#define ArrayLength(x)			(sizeof( x ) / sizeof( x[ 0 ]))
#define	MAX_QWORD				((QWORD)0xFFFFFFFFFFFFFFFF)
#define M_PI					3.14159265358979323846
typedef long long				ll;
typedef unsigned long long int	QWORD;
typedef unsigned long long		SQWORD;

/*-----------------------------------------------------------------------------
　メイン
 -------------------------------------------------------------------------------*/
int N;
string S;
void getMapList(map<pair<string, string>, ll> &list, int ofs)
{
	for (int i = 0; i < (1 << N); i++) {
		string red;
		string blue;
		for (int j = 0; j < N; j++) {
			if (i & (1 << j)) {
				red += S[j + ofs];
			}
		}
		for (int j = N - 1; j >= 0; j--) {
			if (!(i & (1 << j))) {
				blue += S[j + ofs];
			}
		}
		if (ofs == 0) {
			list[pair<string, string>(red, blue)]++;
		} else {
			list[pair<string, string>(blue, red)]++;
		}
	}
}


int main()
{
	cin >> N >> S;
	map<pair<string, string>, ll> list1;
	map<pair<string, string>, ll> list2;
	getMapList(list1, 0);
	getMapList(list2, N);
	ll ans = 0;
	for (auto rp1 = list1.begin(); rp1 != list1.end(); rp1++) {
		ans += (list2[rp1->first] * rp1->second);
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 108288
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <random>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef deque<ll> dll;
#define mod 1e18 + 7;

int main()
{
	ios_base::sync_with_stdio(false); 
	cin.tie(nullptr); 
	cout.tie(nullptr); 
	cout.setf(ios::fixed); 
	cout.precision(20);

	ll n;
	cin >> n;
	vi v(n+1);
	rep(i, n) {
		ll m;
		cin >> m;
		v[m-1] = i;
	}
	ll ans = 1,t = 1;
	REP(i,1,n){
		if (v[i] > v[i - 1]) t++;
		else t = 1;
		ans = max(ans, t);
	}
	cout << n - ans << endl;
	return 0;
}

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

int h, w;
char grid[10][10];
bool visited[10][10], can = true;

bool isvalid(int x, int y)
{
    if(x>=1&&x<=h&&y>=1&&y<=w&&grid[x][y]=='#'&&!visited[x][y]) return true;
    return false;
}

void DFS(int x, int y)
{
    visited[x][y] = true;
    if(isvalid(x+1, y) && isvalid(x, y+1)) {
        can = false;
        return;
    }
    if(isvalid(x+1,y)) DFS(x+1, y);
    if(isvalid(x, y+1)) DFS(x, y+1);
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> h >> w;
    for(int i=1; i<=h; i++)
        for(int j=1; j<=w; j++)
            cin >> grid[i][j];
    DFS(1,1);
    if(!can) {
        cout << "Impossible" << '\n';
        return 0;
    }
    for(int i=1; i<=h; i++)
        for(int j=1; j<=w; j++) {
            if(!visited[i][j]&&grid[i][j]=='#') {
                cout << "Impossible" << '\n';
                return 0;
            }
        }
    cout << "Possible" << '\n';

    return 0;
}


Measured memory_bytes: 256