akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;

#define N 4
#define N2 16
#define LIMIT 100

const int dx[4]={0,-1,0,1};
const int dy[4]={1,0,-1,0};
const char dir[4]={'r','u','l','d'};

int MDT[N2][N2];

struct puzzle{
    int f[N2],space,MD;
};

puzzle state;
int limit;
int path[LIMIT];

int getALLMD(puzzle pz)
{
    int sum=0;
    for(int i=0;i<N2;i++){
        if(pz.f[i]==N2){
            continue;
        }
        sum+=MDT[i][pz.f[i]-1];
    }
    return sum;
}

bool dfs(int depth,int prev)
{
    if(state.MD==0){
        return true;
    }
    if(depth+state.MD>limit){
        return false;
    }
    int sx=state.space/N;
    int sy=state.space%N;
    puzzle tmp;
    for(int r=0;r<4;r++){
        int tx=sx+dx[r];
        int ty=sy+dy[r];
        if(tx<0||ty<0||tx>=N||ty>=N){
            continue;
        }
        if(max(prev,r)-min(prev,r)==2){
            continue;
        }
        tmp=state;
        //计算曼哈顿距离的差值，同时交换拼图块
        state.MD-=MDT[tx*N+ty][state.f[tx*N+ty]-1];
        state.MD+=MDT[sx*N+sy][state.f[tx*N+ty]-1];
        swap(state.f[tx*N+ty],state.f[sx*N+sy]);
        state.space=tx*N+ty;
        if(dfs(depth+1,r)){
            path[depth]=r;
            return true;
        }
        state=tmp;
    }
    return false;
}

string iterative_deepening(puzzle in)
{
    in.MD=getALLMD(in);//初始状态的曼哈顿距离
    for(limit=in.MD;limit<=LIMIT;limit++){
        state=in;
        if(dfs(0,-100)){
            string ans="";
            for(int i=0;i<limit;i++){
                ans+=dir[path[i]];
            }
            return ans;
        }
    }
    return "unsolvable";
}

int main()
{
    for(int i=0;i<N2;i++){
        for(int j=0;j<N2;j++){
            //曼哈顿距离，此法太妙
            MDT[i][j]=abs(i/N-j/N)+abs(i%N-j%N);
        }
    }
    puzzle in;
    for(int i=0;i<N2;i++){
        cin>>in.f[i];
        if(in.f[i]==0){
            in.f[i]=N2;
            in.space=i;
        }
    }
    string ans=iterative_deepening(in);
//    for(int i=0;i<limit;i++){
//        cout<<path[i]<<" ";
//    }
    cout<<ans.size()<<endl;
    return 0;
}


Measured memory_bytes: 3224
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1LL << 30;

int main(){
  ll N;
  cin >> N;
  vll A(N), B(N), C(N);
  priority_queue<Pll> que;
  for(int i = 0; i < N; i++){
    cin >> A.at(i) >> B.at(i);
    que.push(Pll(B.at(i), A.at(i)));
  }
  ll border = INF;

  while(!que.empty()){
    ll B = que.top().first;
    ll A = que.top().second;
    que.pop();
    if(border >= B){
      border = B-A;
    }
    else{
      border -= A;
    }
  }
  cout <<(border >= 0? "Yes": "No") << endl;
}

Measured memory_bytes: 10864
#include <iostream>
#include <bits/stdc++.h>
#include <time.h>
#include <sys/timeb.h>
#include <cstdio>
#include <sys/time.h>

using namespace std;
#define ll long long
#define uint unsigned int
#define ulong unsigned long long int

template<typename T> bool InRange(T t, T l, T r){ return l <= t && t < r; }

int main(){
	
	string S;
	cin >> S;
	int N = S.length();
	int one = 0;
	for(int i=0;i<N;i++) one += (S[i] - '0');
	int zero = N - one;
	cout << min(one, zero) * 2 << endl;
	
    return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

NodePointer listSearch(int key){
  NodePointer i;
  for(i=nil->next;i!=nil;i=i->next){
      if(i->key==key) return i;
  }
  return i;
}

void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void deleteNode(NodePointer t){
  if(t==nil) return;
  t->prev->next=t->next;
  t->next->prev=t->prev;
  free(t);
}

void deleteFirst(){
  NodePointer t = nil->next;
  if ( t == nil ) return;
  deleteNode(t);
}

void deleteLast(){
  deleteNode(nil->prev);
}

void delete(int key){
  deleteNode(listSearch(key));
}


void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;

  x->next=nil->next;
  nil->next->prev=x;
  nil->next=x;
  x->prev=nil;

}

int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) {insert(key); np++; size++;}
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
	if ( com[6] == 'F' ) deleteFirst();
	else if ( com[6] == 'L' ) deleteLast();
      } else {
	delete(key); nd++; 
      }
      size--;
    }
  }

  printList();
  return 0;
}


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

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

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 60;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N; cin >> N;
    ll ulim = sqrt(N)+1;
    set<ll> yakusuu;
    for(ll i = 1; i <= ulim; i++){
        if(N%i == 0){
            yakusuu.insert(i);
            yakusuu.insert(N/i);
        }
    }
    ll ans = LLINF;
    for(auto m: yakusuu){
        ll n = N/m;
        ans = min(ans, m-1 + n-1);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
N = gets.to_i
A = gets.split.map(&:to_i)

sum_a = Array.new(N+2, 0)
(N).downto(0) do |i|
  sum_a[i] = sum_a[i+1] + A[i]
end

ans = 0
b = 1

0.upto(N) do |i|
  if b < A[i]
    puts -1
    exit
  end

  ans += b
  b -= A[i]
  b = [2 * b, sum_a[i+1]].min
end

puts ans


Measured memory_bytes: 21416
#include <stdio.h>
int main(){
	int m,n,k[30],a[30][30],i,j,f;
	scanf("%d %d",&n,&m);
	for(i=0;i<n;i++)
	{scanf("%d",&k[i]);
		for(j=0;j<k[i];j++)
		{
			scanf("%d",&a[i][j]);
		}
	}
	int count[30];
	for(i=0;i<n;i++)
	{
		for(j=0;j<k[i];j++)
		{
			count[a[i][j]]=count[a[i][j]]+1;
		}
	}
	for(i=0;i<=30;i++)
	{
		if(count[i]==n)f=f+1;
	}
	printf("%d",f);
	}


Measured memory_bytes: 128
import java.util.Scanner;

//20180511
//02

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

		String str = scanner.next();
		char[] list = str.toCharArray();
		int count = scanner.nextInt();

		for(int i = 0;i < count;i++) {
			String order = scanner.next();
			int a = scanner.nextInt();
			int b = scanner.nextInt();

			if("print".equals(order)) {
				for (int j = a; j <= b; j++) {
					System.out.print(list[j]);
				}
				System.out.println();
			}

			if("reverse".equals(order)) {
				for (int j = a, k = b; j < k; j++, k--) {
					char tmp = list[j];
					list[j] = list[k];
					list[k] = tmp;
				}
			}

			if("replace".equals(order)) {
				String replace = scanner.next();
				char[] replist = replace.toCharArray();
				for (int j = a; j <= b; j++) {
					list[j] = replist[j-a];
				}
			}
		}
		scanner.close();
    }
}


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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef vector<long long> vl;
typedef pair<long long, long long> pl;
typedef vector<vector<long long>> matrix;

#define F 						first
#define S 						second
#define PB 						push_back
#define MP 						make_pair
#define all(c) 					c.begin(), c.end()
#define f(i,a,b) 				for(ll i=a; i<b; i++)
#define rep(i,n) 				f(i,0,n)
#define tr(c,i) 				for(typeof(c).begin() i = c.begin(); i != c.end(); i++)
#define present(c,x) 			(c.find(x) != c.end())	//for set and map
#define cpresent(c,x) 			(find(all(c),x) != c.end())	//for vectors
#define w(t)					ll t; cin>>t; while(t--)
#define epsilon 				1e-9
#define MOD						(ll)(1e9+7)

void doublade() {
	ios::sync_with_stdio(false); cin.tie(0); cout.precision(10);
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
}

int main() {
	doublade();
	// w(t) {
		ll n;
		cin >> n;
		vl a(n);
		rep(i, n) {
			cin>>a[i];
		}
		vl cum(n, 0);
		cum[0] = a[0];
		f(i, 1, n) cum[i] = cum[i-1] + a[i];
		ll ans = 0;
		rep(i, n-1) {
			ll tmp = a[i] % MOD;
			tmp *= (cum.back() - cum[i]) % MOD;
			tmp %= MOD;
			ans += tmp;
			ans %= MOD;
		}
		cout<<ans<<"\n";
	// }
	return 0;
}

Measured memory_bytes: 6348
#include<stdio.h>
#include<string.h>
#include <stdbool.h>
int main(){
 
   char T[11];

  char S[11];
   scanf("%s",S);

   scanf("%s",T);
   


 bool ok = true;
 for (int i = 0; i < strlen(S); i++)
{
   if (S[i] != T[i]) {
      ok = false;
   }
}
if (ok)
{
    printf("Yes");
}else{
  printf("No");
}
   
    return 0;
}

Measured memory_bytes: 1724
l = list(map(int, input().split()))
a, b = [i for i in l]

ans_count = 0
for mon in range(1, a + 1):
    max_day = 31
    if mon == a:
        max_day = b

    for day in range(1, max_day + 1):
        if day == mon:
            ans_count += 1

print(ans_count)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define loop(i,a,b) for(ll i=a; i<b; i++)
#define revloop(i,a,b) for(ll i=a; i>=b; i--)
#define pb push_back
#define vl vector<ll>
#define vvl vector<vl>
#define pl pair<ll,ll>
#define vpl vector<pl>
#define all(c) (c).begin(), (c).end()
#define sz(a) ((a).size())
#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i!=(c).end(); i++))
#define mp make_pair
#define ss second
#define ff first
const ll INF = 1e13;
const ll N = 200001;
const ll mod=998244353;
bool prime(ll x)
{
	if(x<2) return false;
	for(ll i=2; i*i<=x; i++) if(x%i==0) return false;
	return true;
}
vl fac(N);
void fact()
{
	fac[0]=1;
	loop(i,1,N) fac[i]=(fac[i-1]*i)%mod;
}
void solve()
{
  ll n;
  cin>>n;
  vl h(n+1), a(n+1,0);
  loop(i,1,n+1) cin>>h[i];
  a[2] = abs(h[2]-h[1]);
  loop(i,3,n+1)
  {
  	ll x = a[i-2] + abs(h[i]-h[i-2]);
  	ll y = a[i-1] + abs(h[i]-h[i-1]);
  	a[i] = min(x,y);
  }
  cout<<a[n]<<endl;
}

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t=1;
    //cin>>t;
    while(t--) solve();
 return 0;
}

Measured memory_bytes: 3456
//#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 <assert.h>
#include <functional>
#include <unordered_map>

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	BitSetV(Val,Bit)		((Val) |= (Bit))			
#define	BitTstV(Val,Bit)		((Val) & (Bit))				
#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 pair<ll, ll>			P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
int main()
{
	double A, B;
	cin >> A >> B;

	cout << setprecision(6) << (A / B) << endl;
	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.util.*
import kotlin.math.abs
import kotlin.math.max
import kotlin.math.min

val MOD = 1_000_000_007L

class Solver(stream: InputStream, private val out: java.io.PrintWriter) {
  fun solve() {
    val L = ni()
    val R = ni()
    val D = ni()
    var ans = 0
    for (x in L .. R) {
      if ( x % D == 0) ans++
    }
    out.println(ans)
  }













































  private val isDebug = try {
    // なんか本番でエラーでる
    System.getenv("MY_DEBUG") != null
  } catch (t: Throwable) {
    false
  }

  private var tokenizer: StringTokenizer? = null
  private val reader = BufferedReader(InputStreamReader(stream), 32768)
  private fun next(): String {
    while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {
      tokenizer = StringTokenizer(reader.readLine())
    }
    return tokenizer!!.nextToken()
  }

  private fun ni() = next().toInt()
  private fun nl() = next().toLong()
  private fun ns() = next()
  private fun na(n: Int, offset: Int = 0): IntArray {
    return map(n) { ni() + offset }
  }
  private fun nal(n: Int, offset: Int = 0): LongArray {
    val res = LongArray(n)
    for (i in 0 until n) {
      res[i] = nl() + offset
    }
    return res
  }

  private fun na2(n: Int, offset: Int = 0): Array<IntArray> {
    val a  = Array(2){IntArray(n)}
    for (i in 0 until n) {
      for (e in a) {
        e[i] = ni() + offset
      }
    }
    return a
  }

  private inline fun map(n: Int, f: (Int) -> Int): IntArray {
    val res = IntArray(n)
    for (i in 0 until n) {
      res[i] = f(i)
    }
    return res
  }

  private inline fun debug(msg: () -> String) {
    if (isDebug) System.err.println(msg())
  }

  private fun debug(a: LongArray) {
    debug { a.joinToString(" ") }
  }

  private fun debug(a: IntArray) {
    debug { a.joinToString(" ") }
  }

  private fun debug(a: BooleanArray) {
    debug { a.map { if (it) 1 else 0 }.joinToString("") }
  }

  private fun debugDim(A: Array<LongArray>) {
    if (isDebug) {
      for (a in A) {
        debug(a)
      }
    }
  }
  private fun debugDim(A: Array<IntArray>) {
    if (isDebug) {
      for (a in A) {
        debug(a)
      }
    }
  }

  /**
   * 勝手にimport消されるのを防ぎたい
   */
  private fun hoge() {
    min(1, 2)
    max(1, 2)
    abs(-10)
  }
}

fun main() {
  val out = java.io.PrintWriter(System.out)
  Solver(System.`in`, out).solve()
  out.flush()
}

Measured memory_bytes: 34648
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class BMixJuice {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n, k; cin >> n >> k;
      vector<int> p(n);
      rep(i, n) {
        cin >> p[i];
      }
      int ans = 0;
      sort(all(p));
      rep(i, k) {
        ans += p[i];
      }
      cout << ans << endl;
    }
};

signed main() {
  BMixJuice solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 3616
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()

int main() {
  ll n, a, b;
  cin >> n >> a >> b;
  ll c = n/(a+b);
  ll x = n - c*(a+b);
  if (x > a) x = a;
  cout << c*a + x << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#include <stdlib.h>
#include <vector>
#define pi acos(-1)
#define MOD 1000000007
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
///s1.substr(1,3);///STARTING FROM INDEX 1, 3 LNEGTH SUBSTRING.
///s1.find("adn")///RETURNS STARTING INDEX OF THE SUBSTRING
///"adn" IF IT EXISTS IN THE STRING S1.///
///s1.find("adn",int pos);///RETURNS STARTING INDEX OF THE
///SUBSTRING "adn" SEARCHING FROM INDEX POS OF STRING s1.///
///string::npos returns a garbage value if not found...
///reverse(s1.begin(),s1.end())-> to reverse a string.
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define gcd(a,b) __gcd(a,b)
using namespace std;

vector<int>adj[100005];
int vis[100005];
int vis2[100005];
//vector<ll>a1;
ll f[100005],x7=1000000005,x8,s=0;
ll f2[100005];
ll size1[200005];
ll size2[100005];
set<int>x2;
set<int>::iterator it;

int root(int a)
{
    while(f2[a]!=a){
        f2[a]=f2[f2[a]];
        a=f2[a];
    }
    return a;
}

void union1(int a,int b)
{
    int root_a=root(a);
    int root_b=root(b);
    if(root_a==root_b)return;
    else if(size1[root_a]>size1[root_b]){
        f2[root_b]=root_a;
        size1[root_a]+=size1[root_b];
    }
    else{
        f2[root_a]=root_b;
        size1[root_b]+=size1[root_a];
    }
}

map<string,ll>m2;

string removeSpaces(string str)
{
    str.erase(remove(str.begin(), str.end(), ' '), str.end());
    return str;
}

int binaryToDecimal(int n)
{
    int num = n;
    int dec_value = 0;

    // Initializing base value to 1, i.e 2^0
    int base = 1;

    int temp = num;
    while (temp) {
        int last_digit = temp % 10;
        temp = temp / 10;

        dec_value += last_digit * base;

        base = base * 2;
    }

    return dec_value;
}
//x8=x7;
ll g[5];
void dfs(ll a)
{
    if(vis[a])return;
    vis[a]=1;x7=min(x7,f[a]);//s-=f[a];
    for(int j=0;j<adj[a].size();j++){
        dfs(adj[a][j]);
    }
}

int main()
{
    long long int t,i,q,h,w,n,a,k1,k2,d,e,m,b,c,x1=1000000005,x3=0,x4=0,x5=0,x6=0;
    string s2,s3,s4,s5,s6,s7;
    cin>>n;cin>>s2;
    for(int i=0;i<=n-3;i++){
        if(s2.substr(i,3)=="ABC")s++;
    }
    cout<<s<<endl;

    return 0;
}


Measured memory_bytes: 5248
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
using namespace std;

class Str
{
public:
	string s;
	int c;
	Str(string s, int c)
	:s(s),c(c)
	{}
	
	bool operator<(const Str& sr) const
	{
		if(s!=sr.s) return s<sr.s;
		return c<sr.c;
	}
};

int K,lim;
string sor, dis;
set<Str> st;

string rot(int p, int n, string d)
{
	string ret=d;
	
	int t=(ret[p]-'0')+n;
	if(t<0) t+=10;
	ret[p]=(t%10)+'0';
	
	return ret;
}

bool dfs(string rt, int p, int c)
{
	if(p==K) return true;
	
	int m;
	while(1)
	{
		m=(dis[p]-rt[p]);
		if(m!=0) break;
		p++;
		if(p==K) return true;
	}
	
	if(c>=lim) return false;
	
	string t=rt;
	for(int j=p; j<K; j++)
	{
		t=rot(j,m,t);
		if(!st.insert(Str(t,c)).second) continue;
		
		if(dfs(t,p+1,c+1)) return true; 
	}
	
	
	return false;
}
int main()
{
	while(cin >> K, K)
	{
		cin >> sor >> dis;
		
		for(lim=0; ;lim++)
		{
			st.clear();
			if(dfs(sor,0,0)) break;
		}
		
		cout << lim << endl;
	}
}

Measured memory_bytes: 1380
#include <stdio.h>
int main(void){
	char a[4];
	scanf("%s",a);
	if(a[0]=='S'){
		if(a[1]=='A'){
			printf("1\n");
		}else{
			printf("7\n");
		}
	}else if(a[0]=='T'){
		if(a[1]=='U'){
			printf("5\n");
		}else{
			printf("3\n");
		}
	}else if(a[0]=='M'){
		printf("6\n");
	}else if(a[0]=='W'){
		printf("4\n");
	}else{
		printf("2\n");
	}	
	return 0;
}

Measured memory_bytes: 128
#![allow(unused_imports)]

use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::{i32, i64, i128, u32, u64, u128, f64};
use std::io::{stdout, Write, BufWriter};
use std::mem::{swap};
use proconio::marker::{Isize1, Usize1, Bytes, Chars};

#[proconio::fastout]
fn main() {
    proconio::input!{
        n: usize,
        arr: [i64; n],
        q: usize,
        bcs: [(i64, i64); q],
    }
    let mut counter = HashMap::new();
    for a in arr { *counter.entry(a).or_insert(0) += 1; }
    let mut state = counter.iter().map(|(k, v)| k * v).sum::<i64>();
    for (b, c) in bcs {
        if let Some(k) = counter.get_mut(&b) {
            state += (c - b) * *k;
            let b = *k;
            *k = 0;
            *counter.entry(c).or_insert(0) += b;
        }
        println!("{}", state);
    }
}


Measured memory_bytes: 9616
#include<stdio.h>
int main(){
 int n,i,j,k,temp,kou=0;
 int A[101];

/*????´??????°?????\???*/
 scanf("%d",&n);

/*??????????????\???*/
 for(i=0;i<n;i++){
  
 if(i==n-1){
    scanf("%d",&A[n-1]);
   }else{
    scanf("%d ",&A[i]);
   }

 }




/*?????????*/
 for(i=0;i<n-1;i++){

  for(j=n-2;j>=i;j--){
   temp=A[j+1];
   if(temp<A[j]){
    A[j+1]=A[j];
    A[j]=temp;
    kou+=1;
   }
}
 }

 for(k=0;k<n-1;k++){
  printf("%d ",A[k]);
 }
  printf("%d\n",A[n-1]);
  printf("%d\n",kou);


return 0;
}

Measured memory_bytes: 1852
#include<bits/stdc++.h>
#define N 100005
using namespace std;
int read(){
	int x=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while('0'<=c&&c<='9'){x=(x<<3)+(x<<1)+c-'0';c=getchar();}
	return x*f;
}
int n,cnt,h[N],col[N];
struct Edge{
	int to,next,w;
}a[N*2];
void Add(int x,int y){
	int z=read();
	cnt++;a[cnt].to=y;a[cnt].next=h[x];a[cnt].w=z;h[x]=cnt;
	cnt++;a[cnt].to=x;a[cnt].next=h[y];a[cnt].w=z;h[y]=cnt;
}
void dfs(int x,int fa){
	for(int i=h[x];i;i=a[i].next){
		int y=a[i].to;
		if(y==fa)continue;
		if(a[i].w&1)col[y]=col[x]^1;
		else col[y]=col[x];
		dfs(y,x);
	}
}
int main(){
	n=read();
	for(int i=1;i<n;i++)Add(read(),read());
	col[1]=2;
	dfs(1,0);
	for(int i=1;i<=n;i++)printf("%d\n",col[i]-2);
}

Measured memory_bytes: 9612
#include <iostream>
#define eol '\n';
using namespace std;

int k;
int n = 8;
int* row;
int* col;
int* dif;
int* sum;

bool search(int cnt) {
  if (cnt == n+1) {
    // end
    return true;
  }

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (!row[i] && !col[j] && !dif[i-j+n-1] && !sum[i+j]) {
        row[i] = cnt;
        col[j] = cnt;
        dif[i-j+7] = cnt;
        sum[i+j] = cnt;

        if (search(cnt+1)) {
          return true;
        }

        row[i] = 0;
        col[j] = 0;
        dif[i-j+n-1] = 0;
        sum[i+j] = 0;
      }
    }
  }
  return false;
}

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

  row = new int[n];
  col = new int[n];
  dif = new int[n*2-1];
  sum = new int[n*2-1];

  cin >> k;
  int cnt = 1;
  for (int i = 0; i < k; i++) {
    int r,c;
    cin >> r >> c;
    row[r] = cnt;
    col[c] = cnt;
    dif[r-c+n-1] = cnt;
    sum[r+c] = cnt;
    cnt++;
  }

  search(cnt);

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (col[j] == row[i]) {
        cout << 'Q';
      } else {
        cout << '.';
      }
    }
    cout << eol;
  }

  return 0;
}

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

typedef uint32_t u32;
typedef uint64_t u64;
typedef std::pair<int, int> pii;

class Data {
public:
  Data() {}
  Data(int t, int n, int m, int s)
    : t(t), n(n), m(m), s(s)
  {}
  int t, n, m, s;
};

bool operator < (const Data& left, const Data& right) {
  return left.t < right.t;
}

Data data[10000];

int main() {

  for(;;) {
    int N, M;
    std::cin >> N >> M;
    if( N == 0 and M == 0 ) break;
    int r;
    std::cin >> r;
    for(int i = 0; i < r; ++i) {
      int t, n, m, s;
      std::cin >> t >> n >> m >> s;
      data[i] = Data(t, n, m, s);
    }
    std::sort(data, data + r);
    int q;
    std::cin >> q;
    for(int i = 0; i < q; ++i) {
      int t1, t2, m;
      std::cin >> t1 >> t2 >> m;
      int res = 0;
      int use[2000] = {};
      for(int j = 0; j < r; ++j) {
        if( m != data[j].m ) continue;
        if( data[j].s == 1 ) {
          use[data[j].t] += 1;
        }
        else {
          use[data[j].t] -= 1;
        }
      }
      int t = 0;
      for(int j = 0; j < 2000; ++j) {
        t += use[j];
        use[j] = t;
      }
      for(int j = t1; j < t2; ++j) {
        if( use[j] != 0 ) {
          res += 1;
        }
      }
      std::cout << res << std::endl;        
    }
  }
    
  
  return 0;
}

Measured memory_bytes: 3048
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

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

		List<Integer> iList = new ArrayList<Integer>();
		for (int i=0; i<N; i++) {
			iList.add(sc.nextInt());
		}

		int aliceSum = 0;
		int bobSum = 0;

		Collections.sort(iList, Collections.reverseOrder());

		for (int i=0; i<N; i++) {
			int num = iList.get(i);

			if (i%2 == 0) {
				// TURN:alice
				aliceSum += num;
			}
			else {
				// TURN:Bob
				bobSum += num;
			}

		}

		System.out.println(aliceSum - bobSum);

	}

}


Measured memory_bytes: 22736
/*割り当て*/
#include <stdio.h>
#define N 100000

int t[N];//荷物の値を格納
int n, k;

int check(int); //Pを入力として、積むことのできる荷物の数を返す関数
int solve(void); //最大積載量Pを返す関数

//最大積載量Pのk台のトラックで何個の荷物をかえす
int check(int p){
  int i, j;
  int x=0;

  i=0;
  for (j=0; j<k; j++){
    while (x+t[i] <= p){
      x += t[i];
      i++;
      if (i==n) return i;
    }
    x=0;
  }
  return i;
}

int solve(){
  int p, left, mid, right;

  left = 0;
  right = 1000000000;

  while(right-left > 1){
    mid = (left+right) / 2;
    if (check(mid) >= n) right = mid;
    else left = mid;
  }
  return right;
}



int main(){
  int i;

  scanf("%d%d", &n, &k);
  for (i=0; i<n; i++)
    scanf("%d", &t[i]);

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

  return 0;
}



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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1LL << 60;

int main(){
  string a, b, c;
  cin >> a >> b >> c;

  cout << (a[a.size()-1] == b[0] && b[b.size()-1] == c[0] ? "YES" : "NO") << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  int N; cin >> N;
  cout << (N+1)/2 << endl;
}

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

using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n, m, x;
    cin >> n >> m >> x;
    vector<int> c(n);
    vector<vector<int>> a(n, vector<int>(m));
    for (int i = 0; i < n; i++) {
        cin >> c[i];
        for (int j = 0; j < m; j++) {
            cin >> a[i][j];
        }
    }
    bool found = false;
    int ans = 1e9;
    for (int mask = 0; mask < (1<<n); mask++) {
        vector<int> cur(m);
        int tot = 0;
        for (int i = 0; i < n; i++) {
            if ((mask & (1<<i)) > 0) {
                for (int j = 0; j < m; j++) {
                    cur[j] += a[i][j];
                }
                tot += c[i];
            }
        }
        bool ok = true;
        for (int j = 0; j < m; j++) {
            if (cur[j] < x) {
                ok = false;
            }
        }
        if (ok) {
            found = true;
            ans = min(ans, tot);
        }
    }
    cout << (found ? ans : -1) << endl;
}


Measured memory_bytes: 3628
import java.util.*

fun main(args: Array<String>) {
	val (n, a, b) = readLine()!!.split(" ").map { it.toInt() }
	val values = readLine()!!.split(" ").map { it.toLong() }.toLongArray()
	values.sort()
	values.reverse()
	val sum = (0..(a - 1)).fold(0L) { acc, i -> acc + values[i] }
	val ans = sum.toDouble() / a.toDouble()
	println("%.6f".format(ans))
	val v = values[a - 1]
	var r = (0..(a - 1)).fold(0) { acc, i -> if (values[i] == v) { acc + 1 } else { acc } }
	val num = (0..(n - 1)).fold(0) { acc, i -> if (values[i] == v) { acc + 1 } else { acc } }
	var prv = 1L
	for (i in 1..r) {
		prv = (prv * (num - i + 1)) / i
	}
	var total = prv
	if (r != a) {
		println(total)
		return
	}
	for (i in (r + 1)..(r + b - a)) {
		val pattern = (prv * (num - i + 1)) / i
		prv = pattern
		total += pattern
	}
	println(total)
}


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

vector<int> G[150000];
double sum1[150000];
double sum2[150000];
double dp1[150000];
double ans[150000];

double dfs1(int v, int p){
	int M = G[v].size();
	if(p != -1) M--;
	if(M == 0) return 0;

	for(auto c : G[v]){
		if(c == p) continue;
		sum1[v] += dfs1(c, v) + 1;
	}
	return dp1[v] = sum1[v] / M;
}

void dfs2(int v, int p){
	for(auto c : G[v]){
		if(c == p) continue;
		sum2[v] += dp1[c] + 1.0;
	}
	if(p != -1){
		if(G[p].size() != 1){
			sum2[v] += (sum2[p] - (dp1[v] + 1.0)) / (G[p].size() - 1) + 1.0;
		}
		else{
			sum2[v] += 1.0;
		}
	}
	ans[v] = sum2[v] / G[v].size();

	for(auto c : G[v]){
		if(c != p) dfs2(c, v);
	}
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
#ifdef LOCAL
	std::ifstream in("in");
	std::cin.rdbuf(in.rdbuf());
#endif

	int N;
	cin >> N;
	for(int i = 0; i < N - 1; i++){
		int a, b;
		cin >> a >> b;
		a--, b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}

	dfs1(0, -1);
	dfs2(0, -1);
	for(int i = 0; i < N; i++){
		cout << fixed << setprecision(15) << ans[i] << endl;
	}
}


Measured memory_bytes: 20480
import random
 
def calc1(D, s, t):
  last = [0 for _ in range(26)]
  val1 = [0 for _ in range(D)]
 
  value = 0
  for i in range(D):
    day = i + 1
    value += s[i][t[i]-1]
    val1[i] += s[i][t[i]-1]
    last[t[i]-1] = day
    for j in range(26):
      value -= c[j] * (day - last[j])
      val1[i] -= c[j] * (day - last[j])
  return value, val1
 
D = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(D)]

last = [0 for _ in range(26)]
calc = [0 for _ in range(26)]

t = [0 for _ in range(D)]
 
for i in range(D):
  for j in range(26):
    day = i + 1
    calc[j] = c[j] * (day - last[j])
  min_idx = calc.index(max(calc))
  last[min_idx] = day
  t[i] = min_idx + 1

val, val1 = calc1(D, s, t)
for _ in range(35000):
  d_rand = val1.index(min(val1)) + 1
  q_rand = random.randint(1,26)
  old = t[d_rand-1]
  t[d_rand-1] = q_rand
  new_val, new_val1 = calc1(D, s, t)
  if val > new_val:
    t[d_rand-1] = old
  else:
    val = new_val
    val1 = new_val1
for i in range(D):
  print(t[i])

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

int main() {
  int n, k;
  cin >> n >> k;
  int z = n - k;
  if (k == 1) {
    cout << 0 << endl;
    return 0;
  }
  if (z <= 0) {
    cout << 0 << endl;
  } else {
    cout << z << endl;
  }
}

Measured memory_bytes: 256
n, k = map(int, input().split())
A = [*map(int, input().split())]
P, M = [], [] # plus, minus
for a in A:
    if a < 0: M.append(a)
    else: P.append(a)

def mix():
    len_p = len(P); len_m = len(M)
    P.sort(reverse=True); M.sort()
    P.append(-1); M.append(1) # add endpoint
    pa, ma = [], []
    while len(pa) + len(ma) < k:
        if P[len(pa)] < -M[len(ma)]: ma.append(M[len(ma)])
        else: pa.append(P[len(pa)])
    if len(ma)%2 == 0: return pa + ma
    exist_pa = len(pa) > 0; exist_ma = len(ma) > 0
    remain_p = len_p > len(pa); remain_m = len_m > len(ma)
    if exist_pa & exist_ma & remain_p & remain_m:
        if abs(pa[-1] * P[len(pa)]) < abs(ma[-1] * M[len(ma)]):
            pa.pop(); ma.append(M[len(ma)])
        else: ma.pop(); pa.append(P[len(pa)])
    elif exist_ma & remain_p: ma.pop(); pa.append(P[len(pa)])
    elif exist_pa & remain_m: pa.pop(); ma.append(M[len(ma)])
    return pa + ma

ans_list = []
if k==n: ans_list = A
elif len(P) == n: ans_list = sorted(P, reverse=True)[:k]
elif len(M) == n: ans_list = sorted(M, reverse=k%2)[:k]
else: ans_list = mix()
MOD = 10**9 + 7
ans = 1
for a in ans_list: ans *= a; ans %= MOD
ans += MOD; ans %= MOD
print(ans)


Measured memory_bytes: 31812
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<cmath>
#include<unordered_set>
#include<map>
#include<deque> 
#include<cstring>
#include<utility>
#include<queue>
#include<string>
#include<iomanip>
#include<unordered_map>
#include<list>
using namespace std;
#define int /*unsigned*/long long
#define pb push_back
#define fr(i,n) for(int i=0;i<n;i++)
#define F first
#define S second
#define LM LONG_MAX
#define LS LONG_MIN
#define ccM 1000000007
#define fastio ios_base::sync_with_stdio(false);cin.tie(0)
int max(int b,int a){if(b>a)return b;else return a;}
int min(int b,int a){if(b<a)return b;else return a;}
int Abs(int b){return max(b,-b);}
void print(vector<pair<int,int> >&v){fr(i,v.size())cout<<v[i].F<<" "<<v[i].S<<endl;cout<<endl;}
void print(int arr[],int n){for(int i=0;i<n;i++)cout<<arr[i]<<" ";cout<<endl;}
bool sortbysec(const pair<pair<int,int>,int> &a,const pair<pair<int,int>,int> &b){return (a.first.second < b.first.second);}
set<int>s;
void primeFactors(int n)  
{  
    // Print the number of 2s that divide n  
    while (n % 2 == 0)  
    {  
        s.insert(2);
        n = n/2;  
    }  
  
    // n must be odd at this point. So we can skip  
    // one element (Note i = i +2)  
    for (int i = 3; i <= sqrt(n); i = i + 2)  
    {  
        // While i divides n, print i and divide n  
        while (n % i == 0)  
        {  
            s.insert(i);
            n = n/i;  
        }  
    }  
  
    // This condition is to handle the case when n  
    // is a prime number greater than 2  
    if (n > 2)  
       s.insert(n);
}  
int32_t main()
{
	int a,b;
	cin>>a>>b;
	int d=__gcd(a,b);
	primeFactors(d);
	cout<<s.size()+1<<endl;

}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n,m; cin>>n>>m;
	vector<int>s,g;
	for(int i=0;i<m;++i){
		int a,b; cin>>a>>b;
		if(a==1)s.emplace_back(b);
		else if(b==n)g.emplace_back(a);
	}
	sort(s.begin(),s.end());
	if(s.size())for(auto&&i:g){
		if(*lower_bound(s.begin(),s.end(),i)==i){
			cout<<"POSSIBLE\n"s;
			return 0;
		}
	}
	cout<<"IMPOSSIBLE\n"s;
}


Measured memory_bytes: 4360
// 2017/04/21 Tazoe

#include <iostream>
#include <algorithm>
using namespace std;

struct Card{
	char a;
	int  b;
};

bool compare_as_ints(Card i, Card j)		// stable_sort()?????????
{
	return (i.b<j.b);
}

int partition(Card A[], int p, int r)
{
	Card x = A[r];
	int i = p-1;

	for(int j=p; j<=r-1; j++){
		if(A[j].b<=x.b){
			i++;
			swap(A[i], A[j]);
		}
	}

	swap(A[i+1], A[r]);

	return i+1;
}

void quickSort(Card A[], int p, int r)
{
	if(p<r){
		int q = partition(A, p, r);
		quickSort(A, p, q-1);
		quickSort(A, q+1, r);
	}
}

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

	Card A[100000], B[100000];
	for(int i=0; i<n; i++){
		cin >> A[i].a >> A[i].b;
		B[i] = A[i];
	}

	quickSort(A, 0, n-1);
	stable_sort(B, B+n, compare_as_ints);	// ??????????????????

	bool flg = true;
	for(int i=0; i<n; i++){
		if(!(A[i].a==B[i].a && A[i].b==B[i].b)){
			flg = false;
			break;
		}
	}
	if(flg){
		cout << "Stable" << endl;
	}
	else{
		cout << "Not stable" << endl;
	}

	for(int i=0; i<n; i++){
		cout << A[i].a << ' ' << A[i].b << endl;
	}

	return 0;
}

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

int main() {
	int H , W;
  	cin >> H >> W;
  	vector<vector<char>> hyo(H, vector<char>(W));
  	for(int i = 0; i < H; i++){
    	for(int j = 0; j < W; j++){
        	cin >> hyo.at(i).at(j);
        }
    }
    int count = 0;
    for(int i = 0; i < W; i++){
      	bool tate_check = true;
        for(int j = 0; j < H; j++){
           	if(hyo.at(j).at(i - count) != '.'){
               	tate_check = false;
               	break;
            }
        }
        if(tate_check == true){
            for(int k = 0; k < H; k++){
               	for(int l = i - count; l < W - 1; l++){
                    hyo.at(k).at(l) = hyo.at(k).at(l + 1);
                }
            }
            count++;
        }
    }
  	for(int i = 0; i < H; i++){
        bool yoko_check = false;
    	for(int j = 0; j < W ; j++){
        	if(hyo.at(i).at(j) != '.'){
              	yoko_check = true;
            	break;
            }
        }
      	if(yoko_check == true){
        	for(int j = 0 ; j < W - count; j++){
            	cout << hyo.at(i).at(j);
            }
          	cout << endl;
        }
    }
}


Measured memory_bytes: 256
N = gets.to_i
S = gets.strip.split(//)

counts = {}

S.each{|c|
  counts[c] ? counts[c] += 1 : counts[c] = 1
}

total = 1
counts.each{|c, count|
  total *= (count + 1)
}

puts (total - 1) % (10 ** 9 + 7)

Measured memory_bytes: 6908
#include<bits/stdc++.h>
using namespace std;
 
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define mp make_pair
 
typedef long long ll;
typedef unsigned long long int ull;
typedef long double ld;
 
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef pair<string, string> ss;
typedef pair<int, ss> iss;
 
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<ld> vld;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<pll> vpll;
typedef vector<pii> vpii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<pair<int, pii>> vpiii;
 
typedef map<string, string> mss;
typedef map<string, int> msi;
typedef map<int, int> mii;
typedef map<int, bool> mib;
typedef map<int, ll> mill;
typedef map<int, vpii> mivpii;

const int MAXN = 1e5;

vi g[MAXN + 1];
int dp[MAXN + 1];
bool vis[MAXN + 1];

void fast_io() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
}

void dfs(int u) {
	vis[u] = true;
	for(int v : g[u]) {
		if(!vis[v]) dfs(v);
		dp[u] = max(dp[u], 1 + dp[v]);
	}
}

int main() {
	fast_io();
//	freopen("input/dp_g.txt", "r", stdin);
	
	int n, m, u, v;
	cin >> n >> m;
	for(int i = 1; i <= m; i++) {
		cin >> u >> v;
		g[v].pb(u);
	}
	
	for(int i = 1; i <= n; i++) {
		if(!vis[i]) dfs(i);
	}
	
	int ans = 0;
	for(int i = 1; i <= n; i++) {
		ans = max(ans, dp[i]);
	}
	cout << ans << '\n';
	
	return 0;
}

Measured memory_bytes: 10752
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#include <queue>
#define mod 1000000007
#define ten5 100005
#define PI 3.1415926
using namespace std;

int num[26];

int main()
{
    //int m,n,o=0,i,j,k;
    long long int sum=0,sum2=0,n1=0,n2=0,n3;
    double ans=0.0,half;
    long long int m,n,o,i,j,k=1,now=1;
    long long int a,a1,a2,a3,a4;
    //float f,g,h;
    //char now,pre;
    string s,s1;
    cin>>n;
    a=2;a1=1;a2=1;
    for(i=0;i<n-1;i++)
    {
        a2=a+a1;
        a=a1;
        a1=a2;
    }
    cout<<a2;
    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int a,b;
  scanf("%d %d",&a,&b);
  if(a<b){
    printf("a < b\n");
  }
  if(a>b){
    printf("a > b\n");
  }
  if(a==b){
    printf("a == b\n");
  }
  return 0;
}

Measured memory_bytes: 580
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define pii pair<long long,long long>
#define pll pair<long long, long long>
#define rep(i,l,r) for(long long i = l;i<r;i++)

#define SSTR( x ) static_cast< std::ostringstream & >( \
        ( std::ostringstream() << std::dec << x ) ).str()

#define fastout  ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
using namespace __gnu_pbds;

typedef tree<pll,null_type,less<pll>,rb_tree_tag,tree_order_statistics_node_update> order_set;

const long long INF = (long long)1e9 + 7;
const long long LLINF = (long long)1e18 + 7;

mt19937 mt('O' + '4' + 'K' + 'O');

void kekek()
{
    
    mt();
    #ifdef EB_UG
        freopen("in.txt", "r", stdin), freopen("out.txt", "w", stdout);
    #endif
    #ifndef EB_UG
        ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    #endif
}

double dp[3000][3000];

int main() {
    kekek();
    cout.precision(10);
    int n;
    cin >> n;
    vector<double> prob;
    for (int i = 0; i < n; i++) {
        double t;
        cin >> t;
        prob.push_back(t);
    }
    dp[0][0] = 1;
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j <= i; j++) { //how many heads
            if (j != 0)
                dp[j][i - j] += dp[j - 1][i - j] * prob[i - 1];
            if (i - j != 0) {
                dp[j][i - j] += dp[j][i - j - 1] * (1 - prob[i - 1]);
            }
        }
    }
    // for (int i = 0; i <= n; i++) {
    //     for (int j = 0; j < n; j++) {

    //     }
    // }
    double ans = 0;
    for (int h = 1; h <= n; h++) {
        if (n - h < h) {
            ans += dp[h][n - h];
        }
    }
    cout << ans;
}

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

void solveA(){
  int n;
  cin >> n;
  vector<int> b(n);
  int flg = 0;

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

  vector<int> ans;
  while(b.size()>0){
    int c = -1;

    for(int i=0;i<b.size();i++){
      if(i+1==b[i]) c=b[i];
    }
    if (c==-1) {
      flg = 1;
      break;
    }
    ans.push_back(c);
    b.erase(b.begin()+c-1);
  }

  reverse(ans.begin(),ans.end());
  if(flg){
    cout << -1 << endl;
  }
  else{
    for(auto x:ans){
      cout << x << endl;
    }
  }
}


int main(){
  solveA();
}


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

using namespace std;

int main()
{
	string s;
	int i;
	cin >> s;
	bool can[26];
	
	for(i=0; i<26; i++)
		can[i] = false;	
	
	for(i=0; i<s.length(); i++){
		for(char c='a'; c<='z'; c++){
			if(s[i] == c){
				can[s[i] - 'a'] = true;
				break;
			}
		}
	}

	for(i=0; i<26; i++)
		if(!can[i]){
			cout << (char)(i + 'a') << endl;
			return 0;
		}
		cout << "None" << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define INF 1 << 30
#define EPS 1e-10

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int N, C;
int a[32], b[32][16], p[32];
int dp[1 << 16][32];

int rec(int S, int n){
  if(n == N) return 0;
  if(dp[S][n] >= 0) return dp[S][n];
  //  printf("%x %d\n", S,n);

  int tmp = S | a[n];
  int res = 0;
  rep(i, C){
    int cb = tmp & p[i];
    int c = __builtin_popcount(cb);
    res = max(res, rec(tmp - cb, n+1) + c);
  }
  return dp[S][n] = res;
  //  return res;
}

int main(){
  while(scanf("%d%d", &N, &C) && N + C){
    memset(dp, -1, sizeof(dp));
    memset(p, 0, sizeof(p));
    memset(a, 0, sizeof(a));
    int in;
    rep(i, N){
      rep(j, 16){
	scanf("%d", &in);
	a[i] |= (in << j);
      }
    }
    rep(i, C){
      rep(j, 16) scanf("%d", &b[i][j]);
      int tmp = 0;
      rep(j, 16) p[i] |= (b[i][j] << j);
      //      printf("%x\n", p[i]);
    }

    printf("%d\n", rec(0, 0));
  }
  return 0;
}

Measured memory_bytes: 9392
import java.util.*;
	import java.util.Map.Entry;
	 
	 
	 class Main {
		 static int mod =  (int) (Math.pow(10,9)+7);
		 static List<ArrayList<Integer>>  list = new ArrayList<ArrayList<Integer>>();
	    public static void main(String[] args) {
	    	
	        Scanner sc = new Scanner(System.in);
	        int N = sc.nextInt();
	        int M = sc.nextInt();
	        long X = sc.nextLong();
	        long[] c = new long[N];
	        long[][] a = new long[N][M];
	        for (int i=0 ; i<N; i++) {
	            c[i] = Long.parseLong(sc.next());
		        for (int j=0 ; j<M; j++) {
		            a[i][j] = Long.parseLong(sc.next());		        	
		        }
	        }
	        long ans=Long.MAX_VALUE;
	        
	        for(int i=0;i<(2<<N);i++) {
	        	long tmp=0;
	        	long[] m = new long[M];
	        	for(int j=0;j<N;j++) {
	        		if(((i>>j)&1)==1) {
	        			tmp=tmp+c[j];
	        			for(int k=0;k<M;k++) {
	        				m[k]=m[k]+a[j][k];
	        			}
	        		}
	        	}
	        	boolean flg=false;
	        	for(int j=0;j<M;j++) {
	        		if(m[j]<X)flg=true;
	        	}
	        	if(flg==false) {
	        		ans=Math.min(ans, tmp);
	        	}
	        	
	        }
	        
	        if(ans==Long.MAX_VALUE) {
	        	ans=-1;
	        }
	        System.out.println(ans);
	    }
	}

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

int main(){
	int n;
	cin >> n;
	vector<long long int>cnt_array(n, 1);
	vector<string>s(n);
	for(int i = 0; i < n; i++){
		string s_temp;
		cin >> s_temp;
		sort(s_temp.begin(), s_temp.end());
		s[i] = s_temp;
	}
	sort(s.begin(), s.end());
	
	/*
	long long int cnt = 1;
	for(int i = 0; i < n-1; i++){
		if(s[i] == s[i+1]){
			cnt += 1;
			if(i == n-2)cnt_array.push_back(cnt);
		}else{
			cnt_array.push_back(cnt);
			cnt = 1;
		}
	}
	*/

	//long long int cnt = 1;
	int j = 0;
	for(int i = 0; i < n - 1; i++){
		if(s[i] == s[i+1])cnt_array[j] += 1;
		else j += 1;
	}

	//for(int i = 0; i < n; i++)cout << s[i]<<endl;

	//for(int i = 0; i < cnt_array.size(); i++){
	//	cout << cnt_array[i]<<endl;
	//}


	long long int ans = 0;
	for(int i = 0; i < cnt_array.size(); i++){
		ans += (cnt_array[i]*(cnt_array[i]-1))/2;
	}
	cout << ans << endl;

	
}

Measured memory_bytes: 6528
# test
class fenwick_tree:
  def __init__(s, n):
    s._n = n
    s.data = [0] * n

  def add(s, p, x):
    p += 1
    while p <= s._n:
      s.data[p - 1] += x
      p += p & -p

  def sumlr(s, l, r):
    return s.sum(r) - s.sum(l)

  def sum(self, r):
    s = 0
    while r > 0:
      s += self.data[r - 1]
      r -= r & -r
    return s


N, Q = list(map(int, input().split()))
a = list(map(int, input().split()))
Query = [list(map(int, input().split())) for _ in range(Q)]
  
bit = fenwick_tree(N)
for i in range(N):
  bit.add(i, a[i])

for q in Query:
  if q[0] == 0:
    _, p, x = q
    bit.add(p, x)
  else:
    _, l, r = q
    print(bit.sumlr(l, r))


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

int main()
{
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    int ans = min(a, k);
    k -= a;
    k -= b;
    if (k > 0) ans -= min(k, c);
    cout << ans << "\n";
}


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

int main(){
  int n;cin>>n;
  int a[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  vector<int> v(1e5+1,0);
  for(int i=0;i<n;i++){
    v[a[i]]++;
  }
  int cnt=0;
  for(int i=0;i<1e5+1;i++)if(v[i]>1){
    cnt+=v[i]-1;
  }
  cout<<n-((cnt+1)/2)*2<<endl;
  return 0;
}

Measured memory_bytes: 1152