akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ll long long
#define endl '\n'
using namespace std;
const int N = 2e4 + 5;

int n, p[N];
int a[N], b[N];

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

    cin >> n;
    for(int i = 1; i <= n; i++)
    {
        cin >> p[n - i + 1];

        a[i] = i;
        b[i] = n - i + 1;
    }

    b[0] = 2e9;
    a[n + 1] = 2e9;
    int cur_add = n - 1;
    for(int i = 1; i <= n; i++, cur_add--)
    {
        b[p[i]] += cur_add;
        if(b[p[i]] >= b[p[i] - 1])
        {
            int diff = b[p[i]] - b[p[i] - 1] + 1;
            for(int j = 1; j < p[i]; j++)
            {
                b[j] += diff;
                a[j] -= diff;
            }
        }
    }

    int mn_a = *min_element(a + 1, a + n + 1);
    for(int i = 1; i <= n; i++)
        cout << a[i] - mn_a + 1 << ' ';
    cout << endl;
    for(int i = 1; i <= n; i++)
        cout << b[i] << ' ';
    cout << endl;


    return 0;
}


Measured memory_bytes: 896
# -*- coding: utf-8 -*-
"""
Created on Sat Aug 15 21:02:30 2020

@author: naoki
"""

S = input()
sq = [S[0],S[1],S[2]]

if sq[0]=="R" and sq[1]=="R" and sq[2]=="R":
    print(3)
elif (sq[0]=="R" and sq[1] == "R") or (sq[1]=="R" and sq[2] == "R"):
    print(2)
elif sq[0]=="S" and sq[1]=="S" and sq[2]=="S": 
    print(0)
else:
    print(1)
        
 

Measured memory_bytes: 9064
/*|In The Name Of Allah|*/
//This Month Will Be Expert ISA
#include <bits/stdc++.h>

using namespace std;

const int N = 1e5+5;

const int mod = 1e9+7;

long long n;

int main(){
    cin >> n;
    long long best = 1e12;
    for(long long i = 1; i*i <= n; i++){
        long long j = n / i;
        if(i*j == n){
            best = min(best , i+j-2);
        }
    }
    cout << best << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define EVEL 1
 
#ifndef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {X;}
#define TF(f) {f;}
#define END {}
#endif
const int MOD = 1000000007;
const int INF = 1000000;
#define NMAX 5000
#define MAX 10
 
    ll sum[NMAX+1],temp,buff=0;
    int N,K,ans=0;
    int A[100010];
    int count=0;
    bool dp[NMAX+10][NMAX+10],dp1[NMAX+10][NMAX+10];
    bool vis[NMAX+10][NMAX+10],vis1[NMAX+10][NMAX+10];
        int low=0,high,mid,fir;
 
bool dfs(ll x,ll y){
    //    DEB(x)DEB(y)END
    if(y<0)return false;
    if(y==0){return true;}
    if(vis[x][y]){
        return dp[x][y];
    }else vis[x][y]=true;
    if(x==N){dp[x][y]=false;/*DEB(dp[x][y])DEB(x)DEB(y)END*/ return dp[x][y];}
 
        if(dfs(x+1,y)||dfs(x+1,y-A[x])){
            dp[x][y]=true;
        }else dp[x][y]=false;
        //DEB(dp[x][y])DEB(x)DEB(y)END
    return dp[x][y];
}
bool front(ll x,ll y){
    if(y<0)return false;
    if(x<0){
        //DEB(dp1[x][y])DEB(x)DEB(y)END
        if(x==-1&&y==0)return true;
        else return false;
     }
    if(vis1[x][y]){
        return dp1[x][y];
    }else vis1[x][y]=true;
    if(y==0){
        dp1[x][y]=true; //DEB(dp1[x][y])DEB(x)DEB(y)END
        return dp1[x][y];
    }
 
 
        if(front(x-1,y)||front(x-1,y-A[x])){
            dp1[x][y]=true;
        }else dp1[x][y]=false;
        //DEB(dp1[x][y])DEB(x)DEB(y)END
    return dp1[x][y];
}
 
 
int main(){
    ios_base::sync_with_stdio(false);
    cin>>N>>K;
    ans=N;
    REP(i,N){cin>>A[i];}
    sort(A,A+N);
    high=N;
    while(true){
        ll i=(high+low)/2;
        DEB(high)DEB(i)DEB(low)END
        bool m=false;
        FOR(j,0,K+1){
            if(j<0)j=0;
            //if(front(i,j)) m=true;
            FOR(k,K-A[i]-j,K+1){
                 if(k<0)k=0;
                 if(j+k>=K)break;
                DEB(i)DEB(j)DEB(k)
                TF(front(i,j))
                TF(dfs(i,k))
                TF(dfs(i,k)&&front(i,j))
                DEB(low)DEB(i)DEB(high)
                END
                if(dfs(i+1,k)&&front(i-1,j)){
                    ans=i;
                    m=true;
                    break;
                }
            }
            if(m)break;
        }
        if(high==i||low==i){fir++;}
        if((high==i&&low==i)||fir>1){break;}
        if(m){high=i;}
        else{low=i;}
    }
    cout<<ans<<endl;
}

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

#define st first
#define nd second
#define pb push_back
#define mp make_pair
#define klar(v) memset(v, 0, sizeof(v))
#define bust ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define gcd(a, b) __gcd(a, b);
#define debug(x) cout << #x << " " << x << endl;
#define endl "\n"

typedef vector<int> vi;
typedef vector<pair<int, int> > vpii;
typedef vector<long long> vll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef long long ll;
const int maxn = 1e5+100;

int btree[2*maxn];
int arr[maxn];
int shoot[maxn];
int pref[maxn];
ll n;

void add(int v){
    v += maxn;
    while(v < 2*maxn){
        btree[v]++;
        v += v&(-v);
    }
}

ll query(int x){
    ll ret = 0;
    x += maxn;
    while(x > 0){
        ret += btree[x];
        x -= x&(-x);
    }
    return ret;
}

bool check(int med){
    klar(pref);
    klar(btree);
    ll count = 0;
    add(0);
    for(int i = 1; i <= n; i++){
        if(arr[i] > med)pref[i] = -1;
        else pref[i] = 1;
        pref[i] += pref[i-1];
//        cout << i << " " << pref[i] << " " << query(pref[i]) << endl;
        count += query(pref[i]-1);
        add(pref[i]);
    }
//    cout << "check " << med << " " << count << " return " << count  << "<" <<  n*(n+1)/4+1 << endl;
    if(count < (n*(n+1)/4)+1)return true;
    return false;
}

int main(){
    bust
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> arr[i];
        shoot[i] = arr[i];
    }
    sort(shoot+1, shoot+n+1);
    
    int l = 1, r = n;
    while(l != r){
        int mid = (l+r)/2;
//        cout << l << " "<< r << endl;
        if(check(shoot[mid]))l = mid+1;
        else r = mid;
//        cout << l << " "<< r << endl;
    }
    cout << shoot[r];
}


Measured memory_bytes: 2176
n,k = map(int,input().split())
d = list(map(int,input().split()))
a = n
f = False
while f == False:
    li = []
    for i in str(a):
        li.append(int(i))
    if set(li) & set(d) == set():
        print(a)
        f = True
    else:
        a += 1

Measured memory_bytes: 3060
var n,i,ans :integer;
begin
  ans:=0;
  read(n);
  for i:=1 to n do
    if (i<10)or((i div 100>0)and(i div 100<10))or((i div 10000>0)and(i div 10000<10))
    then inc(ans);
  write(ans);
end.

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

int main(){


int score[20]={};


for(int i=0;i<10;i++){
  cin >> score[i];
 }
 sort(score, score+10);


 int score2[20]={};

for(int i=0;i<10;i++){
  cin >> score2[i];
 }
 sort(score2,score2+10);

int  sum1=score[9]+score[8]+score[7];
int  sum2=score2[9]+score2[8]+score2[7];

 cout << sum1 << ' '<< sum2 << endl;

}

Measured memory_bytes: 1176
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
 
signed main()
{
 
    
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    int n, k; cin >> n >> k;
    int a[n]; 
    for (int i=0; i<n; i++)
        cin >>a[i];
    sort(a, a+n);
    int s = 0;
    for (int i=0; i<k; i++)
        s += a[i];
    cout << s;

    return 0;
}

Measured memory_bytes: 3660
import java.io.*;
import java.util.*;

class Main {

	public static void main(String[] args) throws Exception {
		final Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		double[] p = new double[n];
		for (int i = 0; i < n; i++) {
			p[i] = sc.nextDouble();
		}

		double[][] dp = new double[n + 1][n + 1];
		dp[0][0] = 1;
		for (int i = 1; i <= n; i++) {
			for (int j = 0; j <= i; j++) {
				dp[i][j] += dp[i - 1][j] * (1.0 - p[i - 1]);
				if (j > 0) dp[i][j] += dp[i - 1][j - 1] * p[i - 1];
			}
		}

		double a = 0.0;
		for (int i = n / 2 + 1; i <= n; i++) {
			a += dp[n][i];
		}
	
		System.out.println(a);
	}
}


Measured memory_bytes: 123996
using System;

namespace Volume0_0007
{
	class Program
	{
		static void Main(string[] args)
		{
			int n = int.Parse(Console.ReadLine());
			long m = 100000;

			for(int i = 0; i < n; i++) {
				double d = m * 1.05;

				m = (long)Math.Ceiling(d / 1000.0) * 1000;
			}

			Console.WriteLine(m);
		}
	}
}



Measured memory_bytes: 13948
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF=1e18;
const ll Maxn=5e5+10;
const ll Mod=1e9+7;
ll fact[Maxn+10],in_fact[Maxn+10];
ll qp(ll a,ll b){
    ll sum=1;
    while(b){
        if(b&1) sum=(sum*a)%Mod;
        a=(a*a)%Mod;
        b>>=1;
    }
    return sum;
}
ll C(ll nn,ll mm){
    return fact[nn]*in_fact[mm]%Mod*in_fact[nn-mm]%Mod;
}
ll A(ll nn,ll mm){
    return fact[nn]*in_fact[nn-mm]%Mod;
}
int main() {
    fact[0]=in_fact[0]=1;
    for(int i=1;i<=Maxn;i++){
        fact[i]=fact[i-1]*i%Mod;
        in_fact[i]=in_fact[i-1]*qp(i,Mod-2)%Mod;
    }
    ll N,M;
    cin>>N>>M;
    ll ans=0;
    for(ll i=0;i<=N;i++){
        ans=(ans+C(N,i)*((i&1)?-1:1)*A(M-i,N-i)%Mod)%Mod;
    }
    cout<<(ans*A(M,N)%Mod+Mod)%Mod;
    return 0;
}


Measured memory_bytes: 11356
#include<bits/stdc++.h>
using namespace std;
 int main(){
 	char c,min;
 	int n;
 	cin>>n;
 	int count=n;
 	  cin>>min;
 	for(int i=1;i<n;i++){
 		cin>>c;
 		if(min==c)
 		count--;
 		  min=c;
	 }
	cout<<count;
 }

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


Measured memory_bytes: 2144
/**********************************************************************/
/********                                                      ********/
/********                     Writer:孙~~                      ********/
/********                       Lang:C++                       ********/
/********                     Status:Unknow                    ********/
/********                                                      ********/
/**********************************************************************/
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <queue>
#include <list>
#include <cstdlib>
#include <algorithm>
#include <set>
#include <map>
#include <deque>
#include <cstring>
#include <cmath>
//#include<bits/stdc++.h>
using namespace std;

const int INF=0x3f3f3f3f;
const int SIZE=100005;
const double EPS=1e-6;

int dp[SIZE],h[SIZE];

int main(){
	/*main function start*/
	int n,k;
	scanf("%d%d",&n,&k);
	for(int i=0;i<n;i++){
		scanf("%d",h+i);
	}
	dp[0]=0;
	for(int i=1;i<n;i++){
		dp[i]=INF;
		for(int j=1;j<=k && i-j>=0;j++){
			dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
		}
	}
	printf("%d\n",dp[n-1]);
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using PII = pair<int, int>;
const int INF = numeric_limits<int>::max();

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

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

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

int main()
{
    int a; cin >> a;
    cout << a + a * a + a * a * a << endl;
    return 0;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
int ans=0;
int main()

{
	int n,a;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a;
		while(a%2==0)
		{
			a/=2;
			ans++;
		}
		
	}
		
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int acs(const void *a, const void *b) { 
  return *(int*)a - *(int*)b;
} /* 1,2,3,4.. */
int des(const void *a, const void *b) {
  return *(int*)b - *(int*)a;
} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { 
  return *(char*)a - *(char*)b;
} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) {
  return strcmp(*(const char **)a, *(const char **)b);
} /* aaa,aab.. */
#define min(a,b) (a < b ? a : b)
#define max(a,b) (a > b ? a : b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 200001
#define MOD 1000000007
#define INF 1000000009
typedef long long int lli;

int main(void) {
  int k, n;
  scanf("%d %d", &k, &n);
  int a[MAX];
  rep(i, 0, n) scanf("%d", &a[i]);

  int max = a[0] + (k - a[n-1]);
  rep(i, 0, n-1) max = max(max, a[i+1] - a[i]);
  printf("%d\n", k - max);
  return 0;
}


Measured memory_bytes: 896
#include <stdio.h>
#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2
 
int n,m[N][N];
int color[N],d[N],f[N],tt;
 
void dfs_visit(int u){
 
  int v;
  color[u] = GRAY;
  d[u]=++tt;
  for(v=0;v<n;v++){
    if(m[u][v]==0) continue;
    if(color[v]==WHITE) {
      dfs_visit(v);
    }
  }
  color[u] = BLACK;
  f[u] = ++tt;
}
 
void dfs(){
  int u;
 
  for(u=0;u<n;u++){
    color[u]=WHITE;
    tt = 0;
  }
   
  for(u=0;u<n;u++){
    if(color[u]==WHITE) dfs_visit(u);
  }
  for(u=0;u<n;u++){
    printf("%d %d %d\n",u+1,d[u],f[u]);
  }
}
 
int main(){
  int u,v,k;
  int i,j;
 
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++) m[i][j]=0;
  }
  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    u--;
    for(j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      m[u][v]=1;
    }
  }
 
  dfs();
 
  return 0;
}

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

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	long long int n,k;
	cin >> n >> k;
	vector<long long int>v;
	for(int i=0;i<n;i++){
		int l;cin>>l;
		v.push_back(l);
	}
	if(k>=n)cout << 0 << endl;
	else{
		sort(v.begin(),v.end());
		long long int m = 0;
		for(int i=0;i<n-k;i++){
			m+=v[i];
		}
		cout << m << endl;
	}
	
	return 0;
}


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

int main(){
	// sengen
	LL a,b,c,d;
	// nyuryoku
	cin >> a >> b >> c >> d;
	LL multi = lcm(c,d);
	// keisan
	LL fc,fd,lc,ld,fm,lm;
	if(a%c == 0){
		fc = a/c;
	}else{
		fc = a/c + 1;
	}
	if(a%d == 0){
		fd = a/d;
	}else{
		fd = a/d + 1;
	}
	if(a%multi == 0){
		fm = a/multi;
	}else{
		fm = a/multi + 1;
	}
	lc = b/c; ld = b/d; lm = b/multi;
	LL ans = b - a + 1;
	if(lc >= fc){
		ans = ans - (lc - fc + 1);
	}
	if(ld >= fd){
		ans = ans - (ld - fd + 1);
	}
	if(lm >= fm){
		ans = ans + (lm - fm + 1);
	}
	cout << ans << endl;
	// syutsuryoku
}

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

int main () {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  string s;
  bool y = true;
  cin >> n >> s;
  if (n%2 != 0) {
    y = false;
  } else {
    for (int i = 0; i < n / 2; ++i) {
      if (s[i] != s[i + n / 2]) {
        y = false;
        break;
      }
    }
  }
  cout << (y?"Yes":"No") << endl;
}

Measured memory_bytes: 256
# N = int(input())
N, K = [int(i) for i in input().split()]
S = input()
count_list = []
pre_s = S[0]
count = 1
for i in range(1, N):
    if S[i] == pre_s:
        count += 1
    else:
        count_list.append([pre_s, count])
        pre_s = S[i]
        count = 1
count_list.append([pre_s, count])

first = S[0]
count = 1
for i in range(1, len(count_list)):
    if count > K:
        break
    if count_list[i][0] != first:
        count_list[i][0] = first
        count += 1

count = count_list[0][1]
next_i = None
for i in range(1, len(count_list)):
    if count_list[i-1][0] == count_list[i][0]:
        count += count_list[i][1]
    else:
        next_i = i
        break

if next_i is not None:
    next_sum = sum([c[1]-1 for c in count_list[next_i:]])
    print(count-1 + next_sum)
else:
    print(count-1)




Measured memory_bytes: 63468
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int a,b,d,r;
    double f;
    scanf("%d %d",&a,&b);
    d = a/b;
    r = a%b;
    f = 1.0*a/b;
    printf("%d %d %f\n",d,r,f);
    return 0;
}



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

int main() {
  int n;
  cin>>n;
  cout<<n*n*n<<endl;
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define REP(i, n) for(int i = 0; i < int(n); i++)
#define FOR(i,n,m) for(int i = int(n); i < int(m); i++)
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 6;
const ll LLINF = 1e18 + 1;

int main() {
    int x; cin >> x;
    vector<bool> ok(x + 1, false);
    ok[0] = true;
    for (int i = 100; i <= 105; i++) {
        for (int j = 0; j <= x; j++) {
            if (j-i >= 0 && ok[j-i]) ok[j] = true;
        }
    }
    if (ok[x]) cout << 1 << endl;
    else cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 256
K,N = map(int,input().split())
A = list(map(int,input().split()))

a = [0 for i in range(N)]
amax = 0
for i in range(N):
    a[i] = A[i] - A[i-1]
    if a[i] < 0:
        a[i] += K
    if a[i] > amax:
        amax = a[i]

print(K-amax)

Measured memory_bytes: 26444
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_1_C&lang=jp
"""
import sys


def warshallFloyd(V, dp):
    for k in range(V):
        for i in range(V):
            for j in range(V):
                dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j])


def main(args):
    V, E = [int(x) for x in input().split(' ')]
    dp = [[float('inf')]*V for _ in range(V)]
    for i in range(V):
        dp[i][i] = 0
    for _ in range(E):
        f, t, d = [int(x) for x in input().split(' ')]
        dp[f][t] = d
    # print(dp)
    warshallFloyd(V, dp)

    is_nagative = False
    for i in range(V):
        if dp[i][i] < 0:
            is_nagative = True
    if is_nagative:
        print('NEGATIVE CYCLE')
    else:
        for d in dp:
            print(' '.join(map(str, d)).replace('inf', 'INF'))


if __name__ == '__main__':
    main(sys.argv[1:])
    

Measured memory_bytes: 8312
#include <stdio.h>

int main(){
	int a, b, c, i = 0;
	scanf("%d %d %d", &a, &b, &c);
	while(a <= b){
		if(c % a == 0) i++;
		a++;
	}
	
	printf("%d\n", i);	
	return 0;
}

Measured memory_bytes: 596
#include <iostream>

using namespace std;

int main(void)
{
    int n, p[21], i, count=0;

    cin >> n;

    for(i=1; i<=n; i++){
        cin >> p[i];
    }

    for(i=2; i<=n-1; i++){
        if((p[i]>p[i-1]&&p[i]<p[i+1]) || (p[i]<p[i-1]&&p[i]>p[i+1])){
            count++;
        }
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
    int a,b;
    while (cin>>a>>b && (a&&b))
    {
        for(int i=0;i<a;i++){
            for(int j=0;j<b;j++){
                if(i==0 || i==a-1 || j==0 || j==b-1)
                    cout<<'#';
                else cout<<'.';
            }
            cout<<'\n';
        }
        cout<<'\n';
    }
    return 0;
}


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

int main(){
	string s;
	cin >> s;
	reverse(s.begin(), s.end());
	for(size_t i=0; i<s.length(); ++i){
		if( s.substr(i,5) == "maerd" ){
			i += 4;
			continue;
		}
		if( s.substr(i,7) == "remaerd" ){
			i += 6;
			continue;
		}
		if( s.substr(i,5) == "esare" ){
			i += 4;
			continue;
		}
		if( s.substr(i,6) == "resare" ){
			i += 5;
			continue;
		}
		cout << "NO" << endl;
		return 0;
	}
	cout << "YES" << endl;
	return 0;
}

Measured memory_bytes: 512
main(a,b,c,n,r){
  for(;scanf("%d%d%d%d",&a,&b,&c,&n),a;){
    if(a>c)r=a,a=c,c=r;
    if(b>c)r=b,b=c,c=r;
    for(;n--;puts(r*2>hypot(a,b)?"OK":"NA"))
      scanf("%d",&r);
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF (1 << 30)
#define LLINF (1LL << 60)
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

signed main() {
    cin >> S >> T;
    cout << T + S << endl;
}

Measured memory_bytes: 256
n = '1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51'
nn = n.split(', ')
nn = list(map(int, nn))

K = int(input())

print(nn[K-1])

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
using ll= long long;
#define rep(i,x,n) for(int i=x; i<n; i++)
#define all(x) x.begin(), x.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;}

int cntbit(int a){
  int ans=0;
  rep(i,0,20){
    if((a>>i)&1){
      ans++;
    }
  }
  return ans;
}

int main(){
  int n,a[20],x[20][20],y[20][20],ans=0;
  bool ok;
  cin >> n;
  rep(i,0,n){
    cin >> a[i];
    rep(j,0,a[i]){
      cin >> x[i][j] >> y[i][j];
    }
  }
  rep(bit,0,1<<n){
    ok=true;
    rep(i,0,n){
      if(!(bit & 1<<i))continue;
      
      rep(j,0,a[i]){
        if((bit>>(x[i][j]-1))&1 ^ y[i][j]){
          ok=false;
          break;
        }
      }
    }
    if(ok){
      ans= max(ans, cntbit(bit));
    }
  }
  cout << ans;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

const int nmax = 1e9 + 7;
const long long INF = 1e18;
const double PI = 2 * asin(1);
typedef long long ll;


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

  vector <ll> x(N), y(M);

  for (int i = 0; i < N; i++) cin >> x[i];
  for (int i = 0; i < M; i++) cin >> y[i];

  sort(x.begin(), x.end(), greater<ll>());
  sort(y.begin(), y.end(), greater<ll>());

  vector <ll> X(N - 1), Y(M - 1);
  for (int i = 0; i < N - 1; i++) X[i] = x[i] - x[i + 1];
  for (int i = 0; i < M - 1; i++) Y[i] = y[i] - y[i + 1];
  
  ll sumx = 0, nowx = N - 1, degx = N - 3;
  for (int i = 0; i < N - 1; i++){
    ll now = (X[i] * nowx) % nmax;
    sumx += now; sumx %= nmax;
    nowx += degx; degx -= 2;
  }

  ll sumy = 0, nowy = M - 1, degy = M - 3;
  for (int i = 0; i < M - 1; i++){
    ll now = (Y[i] * nowy) % nmax;
    sumy += now; sumy %= nmax;
    nowy += degy; degy -= 2;
  }

  cout << (sumx * sumy) % nmax << endl;

  return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=1e9+7;
const int size=1e5;
const int inf=1e9;
template<typename T>
struct matrix{
	vector<vector<T>> m;
	int n;
	matrix(int n):m(n,vector<T>(n)){
		(*this).n = n;
	}
    matrix<T> operator = (matrix<T> b){
		rep(i,0,n)rep(j,0,n) (*this).m[i][j] = b.m[i][j];
		return *this;
	}
    matrix<T> operator % (long p){
        rep(i,0,n)rep(j,0,n) (*this).m[i][j] %= p;
        return *this;
    }
    matrix<T> operator %= (long p){
        (*this) = (*this) % p;
        return *this;
    }
	matrix<T> operator + (matrix<T> b){
		matrix<T> vec(n);
		rep(i,0,n)rep(j,0,n) vec.m[i][j] = (*this).m[i][j] + b.m[i][j];
		return vec;
	}
    matrix<T> operator += (matrix<T> b){
        *this = *this + b;
        return *this;
    }
	matrix<T> operator * (matrix<T> b){
		matrix<T> vec(n);
		rep(i,0,n)rep(j,0,n){
			rep(k,0,n) (vec.m[i][j] += (*this).m[i][k] * b.m[k][j] % mod) %= mod;
		}return vec;
	}
    matrix<T> operator *= (matrix<T> b){
        *this = *this * b;
        return *this;
    }
};
matrix<long> modpow(matrix<long> a, long n, long p){
	int i = 0;
	matrix<long> res(a.n);
    rep(i,0,a.n)rep(j,0,a.n) res.m[i][j] = i == j;
	while(n >= (1LL<<i)){
		if(n & (1LL<<i)) (res *= a) %= p;
		i++;
		a = (a * a) % p;
	}return res;
}
int main(){
	int N; long K; cin>>N>>K;
	matrix<long> a(N),b(N);
	rep(i,0,N)rep(j,0,N) cin>>a.m[i][j];
	b = modpow(a, K, mod);
	long ans = 0;
	rep(i,0,N)rep(j,0,N) (ans += b.m[i][j]) %= mod;
	cout<<ans<<endl;
}

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define per(i,n) for(int i = n; i >= 0; i--)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
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; }


const int MAX_H = 2*1e4;
vi dp(MAX_H, inf); // dp[i] = iダメージ与えたときの使用魔力の最小値;

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

  int h, n;
  cin >> h >> n;
  vector<P> m(n);
  rep(i,n) cin >> m[i].fi >> m[i].se;
  dp[0] = 0;
  rep(i,MAX_H) {
    rep(j,n) { // j番目の魔法を使ったとき
      if(i-m[j].fi >= 0) chmin(dp[i], dp[i-m[j].fi] + m[j].se);
    }
  }
  int ans = inf;
  for(int i = h; i < sz(dp); i++) {
    chmin(ans, dp[i]);
  }
  cout << ans << endl;
}

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

using namespace std;

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

    int x[11][11];

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

    double ans;
    int c = 0;
    for (int i = 0; i < n; ++i) {
        
        for (int j = i + 1; j < n; ++j) {
            int sum = 0;
            for(int k = 0; k < d; ++k) {
                // cout << "x[i][k] " << x[i][k] << endl;
                // cout << "x[j][k] " << x[j][k] << endl;

                sum += pow(x[i][k] - x[j][k], 2);
            }
            ans = sqrt(sum);
            // cout << ans << endl;
            if(ceil(ans) == ans) c++;
        }
    }
    
    cout << c << endl;
}


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

typedef long long ll;
typedef long double ld;
#define umap unordered_map
#define size(a) int((a).size())
#define present(c, x) (c.find(x) != c.end()) 
#define printVerdict(verdict) cout << (verdict ? "Yes": "No") << '\n'
#define printDecimal(d) printf("%.9f\n", d)
#define inrange(val, start, end) (val >= start && val <= end)
#define var(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

const ll inf = 0x3f3f3f3f;

template <class T1, class T2, class T3> 
void printTuple(tuple<T1, T2, T3> t) { cout << get<0>(t) << " " << get<1>(t) << " " << get<2>(t) << '\n'; }
template <class T1, class T2>
void printPair(pair<T1, T2> p) { cout << p.first << " " << p.second << '\n'; }
template <class T>
void printArray(vector<T> arr) { for (int i = 0; i<size(arr); i++) {cout << arr[i] << " ";} cout << '\n'; }

struct segTree {
	int sz;
	ll baseValue = 0; 
	vector<ll> tree;
	void init(ll n) {
		sz = 1;
		while (sz < n) sz *= 2;
		tree.assign(2*sz, baseValue);
	}
	
	ll query(ll a, ll b) {
		return max(a, b);
	}
	
	void set(int idx, ll val) {set(idx, val, 0, 0, sz);}
	void set(int idx, ll val, int curr, int left, int right) {
		if (right - left == 1) tree[curr] = val;
		else {
			int mid = left + (right - left)/2;
			if (idx < mid) set(idx, val, curr*2+1, left, mid);
			else set(idx, val, curr*2 + 2, mid, right);
			tree[curr] = query(tree[curr*2 + 1], tree[curr*2 + 2]);
		}
	}
	
	ll evaluate(int left, int right) {return evaluate(left, right, 0, 0, sz);}
	ll evaluate(int left, int right, int curr, int curr_left, int curr_right) {
		if (curr_left >= right || left >= curr_right) return baseValue;
		if (curr_left >= left && curr_right <= right) return tree[curr];
		int mid = curr_left + (curr_right - curr_left)/2;
		ll s1 = evaluate(left, right, curr*2+1, curr_left, mid), s2 = evaluate(left, right, curr*2+2, mid, curr_right);
		return query(s1, s2);
	}
};

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n,k;
	ll maxVal = -1; cin >> n >> k;
	vector<ll> a(n);
	for (int i = 0; i<n; i++) {
		cin >> a[i];
		maxVal = max(maxVal, a[i]);
	}
	segTree tree;
	tree.init(maxVal);
	tree.set(a[0], 1);
	ll ret = 1;
	for (int i = 1; i<n; i++) {
		ll best = tree.evaluate(max(a[i]-k, 0ll), min(a[i]+k+1, maxVal + 1));
		tree.set(a[i], best + 1);
		ret = max(ret, best + 1);
	}
	cout << ret << '\n';
}



Measured memory_bytes: 13772
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main(void){
  int x, y;
  cin >> x >> y;

  cout << x + y / 2 << endl;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define int         long long
#define mod         1000000007
#define FAST        ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define f(i,n)      for(int i=0;i<n;i++)
#define fp(i,k,n)   for(int i=k;i<=n;i++)
#define fr(i,k,n)   for(int i=k;i>=n;i--)
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define dbg(x)      cout << (#x) << " is " << (x) << '\n' 
#define F           first
#define S           second
#define sz(x)       (int)(x).size()
#define lb          lower_bound
#define ub          upper_bound
#define mems(x)     memset(x,0,sizeof(x))
#define all(a)      a.begin(),a.end()
 
/*---------------------------------------------------------------------------------------------------*/
 
void solve()
{
    double a, b, c;
    cin >> a >> b >> c;

    double ans = a / (double)c;
    cout << (ans <= b ? "Yes" : "No");
} 
 
signed main()
{
  FAST
  int T=1;
//   cin >> T;
  while(T--) solve();
  return 0;
}

Measured memory_bytes: 3704
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    // Rust version 1.15.1, which is used by AtCoder,
    // does not support std::str::FromStr for char
    ($iter:expr, char) => {
        $iter.next().unwrap().chars().next().expect("Parse error")
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
fn main() {
    use std::cmp::max;
    use std::cmp::min;
    use std::collections::HashMap;

    input!{
        a: char,
        b: char,
    }

    let ans = if a < b {
        '<'
    } else if a == b {
        '='
    } else {
        '>'
    };
    println!("{}", ans);
}


Measured memory_bytes: 4352
package main

import (
  "fmt"
)

func main() {
  var h, w int 
  fmt.Scan(&h, &w)
  ss := make([]string, h)
  for i := 0; i < h; i++ {
    fmt.Scan(&ss[i])
  }
  for _, s := range ss {
    for i := 0; i < 2; i++ {
      fmt.Println(s)
    }
  }
}

Measured memory_bytes: 512
n = int(input())
a = list(map(int, input().split()))
result = 1
delta = 0
for i in range(1, n):
    if a[i - 1] < a[i]:
        ndelta = +1
    elif a[i - 1] > a[i]:
        ndelta = -1
    else:
        ndelta = 0
    if delta and ndelta and delta != ndelta:
        result += 1
        delta = 0
    elif not delta:
        delta = ndelta
print(result)

Measured memory_bytes: 14224
d = [0,1,2,3,4,5,6,7,8,9]
arr = [0, 9, 17, 24, 30, 35, 39, 42, 44, 45]
while input = gets
  n, s = input.split.map(&:to_i)
  break if n == 0 && s == 0
  if s > arr[n] then
    puts 0
  else
    count = 0
    d.combination(n).collect{|arr| arr.inject(:+)}.each{|i|
      count += 1 if i == s
    }
    puts count
  end
end

Measured memory_bytes: 8628
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <math.h>
#include <cstring>
using namespace std;

int main(void){
    int n;
    cin >> n;
    string s;
    cin >> s;
    char c = s[0];
    int ans = 1;
    for(int i = 0;i < n;i++){
        if(s[i] != c){
            ans++;
            c = s[i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
def solve(n, d, x):
    ans = 0
    while n:
        ans += d + (2 * n - 1) * x / 2
        d = ((n + 1) * d + 5 * x / 2) / n
        x *= (n + 2) / n
        n -= 1
    return ans


print('{:.10f}'.format(solve(*map(float, input().split()))))


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
using namespace std;

int main () {
	int a, b;
	cin >> a >> b;
	if(a > 9 || b > 9) {
		cout << "-1";
	}else {
		cout << (a * b);
	}
	return 0;
}  

Measured memory_bytes: 256
S = list(input())

i = 0
while i < len(S):
    if i % 2 == 0 and S[i] in ["R", "U", "D"]:
        i += 1
        continue
    elif i % 2 == 1 and S[i] in ["L", "U", "D"]:
        i += 1
        continue
    else:
        print("No")
        exit()
print("Yes")


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

// template {{{
#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); (i) += 1)
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); (i) -= 1)

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

// constexpr i32 mod   = 998244353;
constexpr i32 mod   = 1e9 + 7;
constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

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

struct IoSetup { IoSetup(int x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

template <typename T> vector<T> make_vector(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_vector(ts...))>(a, make_vector(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// }}}

void solver() {
    double A, B, H, M;
    cin >> A >> B >> H >> M;

    double t1 = (2 * acos(-1)) / (12 * 60) * (60 * H + M);
    double t2 = (2 * acos(-1)) / 60 * M;
    cout << sqrt(A * A + B * B - 2 * A * B * cos(max(t1 - t2 + 2 * acos(-1), t2 - t1))) << endl;
}

signed main(int argc, char *argv[]) {
    solver();
}


Measured memory_bytes: 4248
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<map>
using namespace std;
int main() {
  long long n,a[100000]={},ans=0,cnt=0;
  cin >> n;
  for(int i=0; i<n; i++) {
    cin >> a[i];
  }
  for(int i=0; i<n-1; i++) {
    if(a[i+1]<=a[i]) {
      cnt++;
      ans=max(ans,cnt);
    }
    else {
      cnt=0;
    }
  }
  cout << ans << endl;
}


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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> a(N);
  while (cin >> M) a.at(M - 1)++;
  for (M = N; M--; cout << a.at(N - M - 1) << endl);
}

Measured memory_bytes: 3632
#include <stdio.h>

int main(void)
{
	char s[4];

	scanf("%s", s);

	if (s[0] == 'S' && s[1] == 'U') {
		printf("%d", 7);
	}
	else if (s[0] == 'M') {
		printf("%d", 6);
	}
	else if (s[0] == 'T' && s[1] == 'U') {
		printf("%d", 5);
	}
	else if (s[0] == 'W') {
		printf("%d", 4);
	}
	else if (s[0] == 'T' && s[1] == 'H') {
		printf("%d", 3);
	}
	else if (s[0] == 'F') {
		printf("%d", 2);
	}
	else {
		printf("%d", 1);
	}

	return 0;
}

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

using namespace std;

int dp[44][444][444];
int a[44],b[44],c[44];
int n,ma,mb;
const int INF = 1e6;
int main() {
  cin >> n >> ma >> mb;
  
  for(int i = 0; i < n; i++) cin >> a[i] >> b[i] >> c[i];

  for(int i = 0; i <= n; i++) {
    for(int j = 0; j < 404; j++) {
      fill(dp[i][j],dp[i][j]+404,INF);
    }
  }
  dp[0][0][0] = 0;

  for(int i = 0; i < n; i++) {
    for(int j = 0; j < 404; j++) {
      for(int k = 0; k < 404; k++) {
	if(dp[i][j][k] == INF) continue;
	dp[i+1][j][k] = min(dp[i+1][j][k],dp[i][j][k]);
	dp[i+1][j+a[i]][k+b[i]] = min(dp[i+1][j+a[i]][k+b[i]],dp[i][j][k] + c[i]);
      }
    }
  }

  int ans = INF;
  for(int i = 1; i <= n * 10; i++) {
    for(int j = 1; j <= n * 10; j++) {
      if((i * mb) == (j * ma)) {
	ans = min(ans,dp[n][i][j]);
      }
    }
  }
  if(ans == INF) cout << "-1" << endl;
  else 
  cout << ans << endl;
}


Measured memory_bytes: 32896
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
const long long mod = 1e9+7;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
const int ddx[4] = {1,1,-1, -1};
const int ddy[4] = {1,-1,-1,1};
//////////////////////////////////

int main() {
    string s; cin >> s;
    int n = s.size();
    bool f = true;
    for(int i=0; i<n; i++) {
        if(i%2 == 0) {
            if(!(s[i] == 'R' || s[i] == 'U' || s[i] == 'D')) {
                f = false;
            }
        }else{
            if(!(s[i] == 'L' || s[i] == 'U' || s[i] == 'D')) {
                f = false;
            }
        }
    }

    cout << (f ? "Yes": "No") << endl;
    return 0;
}

// EOF


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

int main(){
    int a;
    scanf("%d",&a);
    if(a%1000!=0){
        printf("%d",1000-a%1000);
    }else{
        printf("0");
    }
    

    return 0;
}

Measured memory_bytes: 1732
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
using namespace std;
 
#include <math.h>
#include <iomanip>
#include <vector>
#include <queue>
#include <climits>
using Graph = vector<vector<int>>;
const double PI = 3.14159265358979323846;
 
 
 
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
 
 
//約数をベクトル形式で返す
vector<int> vect_yakusuu(int n) {
	vector<int> ret;
	for (int i = 1; i*i <= n; i++) {
		if (n%i == 0) {
			ret.push_back(i);
			if (i*i != n) ret.push_back(n / i);
		}
	}
	sort(begin(ret), end(ret));
	return ret;
}
 
 
 
int main() {

	int A,B,C,K;
	cin >>A >>B >>C >>K;
	string ans;

	int count = 0;

	while (1){
		if (A<B){
			break;
		}
		B=B*2;
		count++;
	}
		while (1){
		if (B<C){
			break;
		}
		C=C*2;
		count++;
	}

	ans = "Yes";

	if (count>K){
		ans = "No";
	}
	
	cout << ans;
 
	return 0;
 
 
}

Measured memory_bytes: 3628
# -*- coding: utf-8 -*-
"""
Created on Fri May 15 15:49:49 2020

@author: shinba
"""

n = int(input())
A = list(map(int,input().split()))

ans = 0

for i in range(n):
    if A[i] == i+1:
        ans += 1
        if i != n-1:
            A[i+1] = A[i]

print(ans)
        


Measured memory_bytes: 13880
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define repr(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;
const int dx[] = {0, 1, -1, 0};
const int dy[] = {1, 0, 0, -1};
const ll mod = 1e9 + 7;
const ll INF = 1e9;
const ll LINF = 1LL << 60;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //////////////////////////////////////
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  int count = min(50, k);
  for (int j = 0; j < count; j++) {
    vector<int> b(n, 0);
    rep(i, n) {
      int l = max(0, i - a[i]);
      int r = min(n - 1, i + a[i]);
      b[l]++;
      if (r + 1 < n) b[r + 1]--;
    }
    rep(i, n - 1) b[i + 1] += b[i];
    rep(i, n) a[i] = min(n, b[i]);
  }
  rep(i, n) cout << a[i] << " ";
  cout << endl;
  return 0;
}


Measured memory_bytes: 4908
N,M=map(int,input().split())
AB=[list(map(int, input().split())) for _ in range(N)]
AB.sort(key=lambda x:x[0])
cnt=0
s=0
for ab in AB:
    if M-cnt>ab[1]:
        cnt+=ab[1]
        s+=ab[0]*ab[1]
    else:
        s+=ab[0]*(M-cnt)
        break
print(s)

Measured memory_bytes: 29024
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using static System.Console;
using static System.Math;

namespace AtCodeeeer
{
    class AtCOOOOOOOOOOOder
    {
        static void Main(string[] args)
        {
            int[] s = ReadLine().Split(' ').Select(int.Parse).ToArray();
            int N = s[0];
            int A = s[1];
            int B = s[2];

            WriteLine(Min(A*N,B));
        }
    }
}


Measured memory_bytes: 11348
#include <iostream>
#include <map>
using namespace std;
int main()
{
  int a[1501];
  int n,m,i,j,c;
  for(;;){
    cin >> n >> m;
    if(n==0 && m==0) break;
    map<int,int> hm,wm;
    for(i=1;i<=n;i++){
      cin >> a[i];
      a[i] += a[i-1];
      for(j=0;j<i;j++){
	hm[a[i]-a[j]]++;
      }
    }
    for(i=1;i<=m;i++){
      cin >> a[i];
      a[i] += a[i-1];
      for(j=0;j<i;j++){
	wm[a[i]-a[j]]++;
      }
    }
    map<int,int>::iterator it = hm.begin();
    c = 0;
    while(it != hm.end()){
      c += wm[(*it).first] * (*it).second;
      it++;
    }
    cout << c << endl;
  }
  return 0;
}

Measured memory_bytes: 21000
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

LL N;
std::vector<LL>a, b, c;
std::vector<std::vector<LL>>memo;

LL dp(LL i, LL j)
{
	if (i == N) return 0;
	if (memo[i][j] != -1) return memo[i][j];
	LL res1 = 0, res2 = 0, res3 = 0;
	if (j != 1) res1 = dp(i + 1, 1) + a[i];
	if (j != 2) res2 = dp(i + 1, 2) + b[i];
	if (j != 3) res3 = dp(i + 1, 3) + c[i];
	return memo[i][j] = std::max({ res1, res2, res3 });
}

int main()
{
	in >> N;
	a.resize(N); b.resize(N); c.resize(N);
	rep(i, N) in >> a[i] >> b[i] >> c[i];

	memo.resize(N);
	rep(i, memo.size()) memo[i].resize(4, -1);
	out << dp(0, 0) << std::endl;
}


Measured memory_bytes: 17408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
#define INF 1000000000
#define mod 1000000007

char a[10][10];
void solve() {
    int n, m , k;
    cin >> n >> m >> k;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j)
            cin >> a[i][j];
    }
    int ans = 0;
    for (int x = 0; x < (1 << n); ++x) {
        for (int y = 1; y < (1 << m); ++y) {
            int cnt = 0;
            for (int i = 0; i < n; ++i) {
                if (!(x & 1 << i)) continue; 
                for (int j = 0; j < m; ++j) {
                    if (!(y & 1 << j)) continue;
                    if (a[i][j] == '#') cnt++;
                }
            }
            if (cnt == k) ++ans;
        }
    }
    cout << ans << "\n";
}
 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    int t = 1;
    // cin >> t;
    while (t--)
        solve();
    return 0;
}


Measured memory_bytes: 3616
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
using namespace std;
typedef long long ll;

int n;

map<int, int>m;

int main() {
    
    cin >> n;
    int temp;
    int count = 0;
    for (int i = 1; i <= n; i++) {
        cin >> temp;
        m.insert(pair<int, int>(i, temp));
        
        if (i > 1) {
            if (m.find(temp)->second == i)
                count++;
        }
    }
    cout << count << endl;
    return 0;
    
    
}


Measured memory_bytes: 4992
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<n; ++i)
#define all(x) begin(perm),end(perm)
#define showall(obj) for(auto x:obj)cout<<x<<endl;
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
typedef vector<int> vint;
typedef vector<ll> vll;
const int inf = 100100100;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
    string s; cin>>s;
    int q; cin>>q;
    int qo;
    int f;
    char c;
    int head = 1;
    rep(i,q){
        cin>>qo;
        if(qo == 1)head *= -1;
        if(qo == 2){
            cin>>f>>c;
            if(f == 1){
                if(head==1){s.insert(s.begin(),c);}
                else s.insert(s.end(),c);
            }else{
                if(head==1){s.insert(s.end(),c);}
                else s.insert(s.begin(),c);
            }
        }
    }
    if(head == -1)reverse(s.begin(),s.end());
    cout<<s<<endl;
}


Measured memory_bytes: 900