akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Text;
using System.Collections.Generic;

namespace F
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] NM = Console.ReadLine().Split(' ');
            int N = int.Parse(NM[0]);
            int M = int.Parse(NM[1]);
            string S = Console.ReadLine();
            StringBuilder SB = new StringBuilder(S);
            Stack<int> s = new Stack<int>();
            int j = N;
            int i = 0;
            while(true)
            {
                for(i=M;i>0;i--)
                {
                    if (j - i >= 0)
                    {
                        if (SB[j - i] != '1')
                        {
                            s.Push(i);
                            break;
                        }
                    }
                }
                if (i == 0) 
                {
                    Console.WriteLine("-1");
                    return;
                }
                j -= i;
                if (j > 0)
                {
                    continue;
                }
                else
                {
                    break;
                }
            }
            while(s.Count > 0)
            {
                Console.Write(s.Pop() + " ");
            }
            Console.WriteLine(" ");
        }
    }
}


Measured memory_bytes: 31972
#include <bits/stdc++.h>
using namespace std;
const int N = 110;
typedef long long ll;
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    int a,b,t,cnt = 1;
    cin >> a >> b;
    if(b == 1){
        cout << 0 ;
        return 0;
    }
    t = a;
    while(t < b){
        cnt ++;
        t += a;
        t--;
    }
    cout << cnt ;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
int main()
{
    int n, d;
    cin >> n >> d;
    int x[n][d];
    int ans = 0;
    rep(i,n){
        rep(j,d){
            cin >> x[i][j];
        }
    }
    rep(i,n-1){
        rep(j,n-i-1){
            int tmp=0;
            int s;
            rep(k,d){
                s = x[i][k] - x[j + i + 1][k];
                s *= s;
                tmp += s;
            }
            s = sqrt(tmp);
            s *= s;
            if(s==tmp)
                ans++;
        }

    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int N,K; cin>>N>>K;
  int ans=0,sum=1;
  while(sum<=N){
    sum*=K;
    ans++;
  }
  cout<<ans<<endl;
  }



Measured memory_bytes: 256
/*  3_4
    Y_Aizaki    */

#include <stdio.h>

int main(void){
    int n;
    scanf("%d", &n);
    // Nが1~9の二つの整数の積かどうかを判定する

    int i = 1;
    while(i < 10){
        if(n % i == 0 && n / i < 10){
            printf("Yes\n");
            break;
        }
        i += 1;
    }

    if(i == 10){
        printf("No\n");
    }

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#define REP(i, a, n) for(int i = ((int) a); i < ((int) n); i++)
using namespace std;

int N, K[100];
string S;
char st[52];

int main(void) {
  REP(i, 0, 26) st[i] = 'a' + i;
  REP(i, 0, 26) st[i + 26] = 'A' + i;

  while(cin >> N, N) {
    REP(i, 0, N) cin >> K[i];
    cin >> S;

    string ans = "";
    REP(i, 0, S.length()) {
      int code;
      if('a' <= S[i] && S[i] <= 'z') code = S[i] - 'a';
      else code = S[i] - 'A' + 26;
      ans += st[(code - K[i % N] + 52) % 52];
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 3156
#include <stdio.h>
 
int main() {
	int N;
	scanf("%d", &N);
	
	char arr[N];
	scanf("%s", &arr);
	
	int X = 0;
	int max = 0;
	for(int i = 0; i < N; i++) {
		if(arr[i] == 'I') {
			X++;
			if(max < X) {
				max = X;
			}
		}
		else if(arr[i] == 'D') {
			X--;
		}
	}
	
	printf("%d\n", max);
	return 0;
}

Measured memory_bytes: 1672
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=998244353;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};


struct edge {int to;LL cost;};

const int M_N=1<<17;

vector<edge> G[M_N+1];
LL d[M_N+1];

struct Dijkstra{

    void dijkstra(int s){
        priority_queue<P,vector<P>,greater<P>> que;
        que.push(P(0,s));
        d[s] = 0;
        while(!que.empty()){
            P p=que.top();
            que.pop();
            int v=p.second;
            if(d[v]<p.first) continue;
            for(int i=0;i<G[v].size();i++){
                edge e=G[v][i];
                if(d[e.to]>d[v]+e.cost){
                    d[e.to]=d[v]+e.cost;
                    que.push(P(d[e.to],e.to));
                }
            }
        }
    }

};


int main(){
    int n,m;cin >> n >> m;
    vector<int> im(n+1,0);
    for (int i = 0; i < m; i++) {
        LL l,r,c;cin >> l >> r >> c;
        l--,r--;
        im[l]++;
        im[r+1]--;
        G[l].pb({(int)r,c});
    }
    int s=0;
    for (int i = 0; i <= n; i++) {
        s+=im[i];
        im[i]=s;
    }
    for (int i = 1; i < n; i++) {
        if(im[i]){
            G[i].pb({i-1,0});
        }
    }
    Dijkstra ds;
    fill(d,d+n,LINF);
    ds.dijkstra(0);
    if(d[n-1]==LINF) cout << -1 << endl;
    else cout << d[n-1] << endl;
    return 0;
}


Measured memory_bytes: 10492
import math
a, b, c = map(int, input().split())
c = c * math.pi / 180
h = b * math.sin(c)
d = math.sqrt(b ** 2 + a ** 2 - 2 * b * a * math.cos(c))
S = a * h / 2
print(S)
print(a + b + d)
print(h)


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

#define ll long long
#define ar array

const int mxN=3e3, M=998244353;
int n, s, a[mxN];
ll dp[mxN+1][mxN+1], ans;

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

	cin >> n >> s;
	for(int i=0; i<n; ++i) {
		cin >> a[i];
		memcpy(dp[i+1], dp[i], sizeof(dp[0]));
		//start a new sequence
		dp[i+1][a[i]]=(dp[i+1][a[i]]+i+1)%M;
		for(int j=0; j+a[i]<=s; ++j)
			dp[i+1][j+a[i]]=(dp[i+1][j+a[i]]+dp[i][j])%M;
		ans=(dp[i+1][s]+ans)%M;
	}
	cout << ans;
}

Measured memory_bytes: 70656
// AOJ 1313: Intersection of Two Prisms
// 2017.12.19 bal4u@uu

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int x1[101], y1[101];
int x2[101], z2[101];
int x[201];

int cmp(int *a, int *b) { return (*a) - (*b); }

double w(int *a, int *b, int n, int x)
{
	int i, x1, y1, x2, y2;
	double l, r, u, v, y;

	l = 1e10, r = -1e10;
	for (i = 0; i < n; i++) {
		x1 = a[i],   y1 = b[i];
		x2 = a[i+1], y2 = b[i+1];
		if ((x1-x)*(x2-x) <= 0 && x1 != x2) {
			u = (double)(y1-y2)/(x1-x2);
			v = (double)(y1*x2 - y2*x1)/(x2-x1);
			y = u*x + v;
			if (y < l) l = y;
			if (y > r) r = y;
		}
	}
	r -= l;
	if (r < 0) r = 0;
	return r;
}

int main()
{
	int m, n, i, sz, min1, max1, min2, max2, a, b, c;
	double ans, fa, fb, fc;

	while (scanf("%d%d", &m, &n) && m > 0) {
		scanf("%d%d", x1, y1);
		x1[0] <<= 1, y1[0] <<= 1;
		min1 = max1 = x1[0];
		for (i = 1; i < m; i++) {
			scanf("%d%d", x1+i, y1+i);
			x1[i] <<= 1, y1[i] <<= 1;
			if      (x1[i] < min1) min1 = x1[i];
			else if (x1[i] > max1) max1 = x1[i];
		}
		x1[m] = x1[0], y1[m] = y1[0];

		scanf("%d%d", x2, z2);
		x2[0] <<= 1, z2[0] <<= 1;
		min2 = max2 = x2[0];
		for (i = 1; i < n; i++) {
			scanf("%d%d", x2+i, z2+i);
			x2[i] <<= 1, z2[i] <<= 1;
			if      (x2[i] < min2) min2 = x2[i];
			else if (x2[i] > max2) max2 = x2[i];
		}
		x2[n] = x2[0], z2[n] = z2[0];
		
		memcpy(x,   x1, sizeof(int)*m);
		memcpy(x+m, x2, sizeof(int)*n);
		qsort(x, m+n, sizeof(int), cmp);

		ans = 0, sz = m+n-1;
		for (i = 0; i < sz; i++) {
			a = x[i], b = x[i+1], c = (a+b) >> 1;
			if (min1 <= c && c <= max1 && min2 <= c && c <= max2) {
				fa = w(x1, y1, m, a) * w(x2, z2, n, a);
				fb = w(x1, y1, m, b) * w(x2, z2, n, b);
				fc = w(x1, y1, m, c) * w(x2, z2, n, c);
				ans += (b-a)/6.0 * (fa + 4*fc + fb);
			}
		}
		printf("%.13lf\n", ans/8);
	}
 	return 0;
}

Measured memory_bytes: 1844
#define _CRT_SECURE_NO_DEPRECATE
#pragma comment(linker, "/STACK:102400000,102400000")
#include<iostream>  
#include<cstdio>  
#include<fstream>  
#include<iomanip>
#include<algorithm>  
#include<cmath>  
#include<deque>  
#include<vector>
#include<bitset>
#include<queue>  
#include<string>  
#include<cstring>  
#include<map>  
#include<stack>  
#include<set>
#include<functional>
#define pii pair<int, int>
#define mod 1000000007
#define mp make_pair
#define pi acos(-1)
#define eps 0.00000001
#define mst(a,i) memset(a,i,sizeof(a))
#define all(n) n.begin(),n.end()
#define lson(x) ((x<<1))  
#define rson(x) ((x<<1)|1) 
#define inf 0x3f3f3f3f
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
ll a[55];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int i, j, k, m;
	ll n;
//	n = 50LL*(ll)pow(10, 16) - 5LL;
	cin >> n;
	cout << "50" << endl;
	ll tempn = 50;
	ll tst = n;
	for (int i = 1; i <= 49; ++i)
	{
		a[i] = tst / (51LL - i);
		tst -= tst / (51LL - i);
	}
	a[50] = tst;
	for (int i = 1; i <= 49; ++i)
		cout << 51LL * a[i] - n + 49LL << " ";
	cout << 51LL * a[50] - n + 49;
	return 0;
}

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

int main(void)
{
	double hex, bin;
	char bin_show[14];
	
	int i;
	
	while (1){
		scanf("%lf", &hex);
		if (hex < 0) break;
		
		memset(bin_show, '\0', sizeof(bin_show));
		bin_show[8] = '.';
		
		
		i = 0;
		bin = 128;
		while (bin > pow(2.0, -5.0)){
			if (hex >= bin){
				bin_show[i] = '1';
				hex -= bin;
			}
			else {
				bin_show[i] = '0';
			}
			bin /= 2;
			i++;
			if (i == 8) i++;
		}
		
		if (hex == 0) printf("%s\n", bin_show);
		else {
			NA:;
			printf("NA\n");
		}
	}
	
	return (0);
}

Measured memory_bytes: 0
s=input()+"T"
x,y=map(int,input().split())
n=len(s)
prev=-1
cnt=0
x_,y_=[],[]
for i in range(n):
    if s[i]=="T":
        if cnt%2:
            y_.append(i-prev-1)
        else:
            x_.append(i-prev-1)
        cnt+=1
        prev=i
prevx=[0]*(2*n+1)
prevy=[0]*(2*n+1)
prevx[n+x_[0]]=1
prevy[n]=1
x_=x_[1:]
for num in x_:
    curx=[0]*(2*n+1)
    for i in range(2*n+1):
        if prevx[i]:
            if i-num>=0:
                curx[i-num]=1
            if i+num<=2*n:
                curx[i+num]=1
    prevx=curx
for num in y_:
    cury=[0]*(2*n+1)
    for i in range(2*n+1):
        if prevy[i]:
            if i-num>=0:
                cury[i-num]=1
            if i+num<=2*n:
                cury[i+num]=1
    prevy=cury
if prevy[y+n] and prevx[x+n]:
    print("Yes")
else:
    print("No")
#print(x_)
#print(y_)

Measured memory_bytes: 87568
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<vector>

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define per(i, a, n)  for(int i=n-1; i>=a; i--)
#define all(x)  (x).begin(), (x).end()
#define MAX 100000
using namespace std;

int main(){
  int a, b; cin >> a >> b;
  cout << ((a-1)*(b-1)) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using uint = unsigned int;
using P = pair<int,int>;
using node = pair<string,ll>;
const ll inf = numeric_limits<ll>::max()/3;
const ll mod = 1e9+7;

vector< ll > s;
vector< ll > t;

ll get_upper(vector<ll> &v, ll x) {
  return *(upper_bound(v.begin(),v.end(), x) - 1);
}

ll get_lower(vector<ll> &v, ll x) {
  return *(lower_bound(v.begin(), v.end(), x));
}

void solve(ll x) {
  ll ws = x - get_upper(s, x);
  ll wt = x - get_upper(t, x);
  ll es = get_lower(s, x) - x;
  ll et = get_lower(t, x) - x;
  /*
  cout << x  << ": " 
       << ws << " "
       << wt << " "
       << es << " "
       << et << endl;
  */
  ll res = inf;
  res = min(res, max(ws,wt));
  res = min(res, max(es,et));
  res = min(res, ws + et + min(ws,et));
  res = min(res, wt + es + min(wt,es));
  cout << res << endl;
}

int main(void) {
  int a,b,q;
  cin >> a >> b >> q;
  s = vector<ll>(a + 2);
  t = vector<ll>(b + 2);
  s[0] = -inf; s[a+1] = inf;
  t[0] = -inf; t[b+1] = inf;
  for(int i = 1;i <= a;++i) {
    cin >> s[i];
  }
  for(int i = 1;i <= b;++i) {
    cin >> t[i];
  }
  for(int i = 0;i < q;++i) {
    ll x;
    cin >> x;
    solve(x);
  }
  return 0;
}


Measured memory_bytes: 2944
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            while (true) {
                int n = sc.nextInt();
                if (n==0) break;
                int s[] = new int[n];
                int max = 0;
                int min = 1001;
                int sum = 0;
                for (int i = 0; i < n; i++) {
                    s[i] = sc.nextInt();
                    if (s[i] >= max) max = s[i];
                    if (s[i] <= min) min = s[i];
                    sum += s[i];
                }
                sum = sum - max - min;
                int ave = sum/(n-2);
                System.out.println(ave);
            }
        }
    }
}


Measured memory_bytes: 28900
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout<< (x) << " "
int main(){
    int a,b,c,d;cin>>a>>b>>c>>d;
    while(1){
        c-=b;
        if(c<=0){co("Yes");return 0;}
        a-=d;
        if(a<=0){co("No");return 0;}
    }
}

Measured memory_bytes: 3672
from copy import copy
h, w = map(int, input().split())
data = [list(map(int, input().split())) for _ in range(10)]

c = [list(map(int, input().split())) for _ in range(h)]

d = copy(data)
def cnt_set(d):
    for k in range(10):
        for i in range(10):
            for j in range(10):
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])
cnt_set(d)
ans = 0

for i in range(h):
    for j in range(w):
        if c[i][j] == -1:
            continue
        ans += d[c[i][j]][1]

print(ans)

Measured memory_bytes: 9724
#include<stdio.h>
int main()
{
	int c[6]={500,100,50,10,5,1},i,m,r;
	for(;scanf("%d",&m),m;)
	{
		for(m=1000-m,i=r=0;m;r+=m/c[i],m%=c[i++]);
		printf("%d\n",r);
	}
	return 0;
}

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

int main(void){
  int a[1000];
  int n,b,e,k,q;
  
  cin >> n;
  for (int i=0; i<n; i++) cin >> a[i];
  cin >> q;
  for (int i=0; i<q; i++){
    int cnt = 0;
    cin >> b >> e >> k;
    for (int j=b; j<e; j++){
      if (a[j] == k) cnt++;
    }
    cout << cnt << endl;
  }
  return 0;
}
  
  



Measured memory_bytes: 3108
using System;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
      	var n = Console.ReadLine();
        var input = Console.ReadLine().Split(' ');
        var count = 0;

        var As = new List<int>();
        foreach (var elem in input)
        {
            As.Add(int.Parse(elem));
        }

        while (true)
        {
            foreach (var a in As)
            {
                if (a % 2 != 0)
                {
                    Console.WriteLine(count);
                    return;
                }
            }

            var temp = new List<int>();

            foreach (var a in As)
            {
                temp.Add(a / 2);
            }

            As = temp;
            count++;
        }
    }
}


Measured memory_bytes: 27976
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;


int main(void){
	ll n,a,b,x[100010],ans=0;
	cin>>n>>a>>b;
	rep(i,n){
		cin>>x[i];
		if(i==0)continue;
		if(a*(x[i]-x[i-1])<b){
			ans+=a*(x[i]-x[i-1]);
		}else{
			ans+=b;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using std::vector;
const int MAXN=200005;
int n,i,cnt,a[MAXN],f[MAXN],ans[MAXN];
vector<int> G[MAXN];
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
    	if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
inline void print(int x)
{
    if (x<0)
        putchar('-'),x=-x;
    if (x>9)
        print(x/10);
    putchar(x%10+'0');
}
inline void dfs(int u,int fa)
{
	int l=1,r=ans[fa],mid,last;
	if (!fa)
		f[1]=a[u],ans[1]=1;
	else
	{
		while (l<=r)
		{
			mid=(l+r)>>1;
			if (a[u]<=f[mid])
				r=mid-1;
			else
				l=mid+1;
		}
		last=f[l];
		f[l]=a[u];
		ans[u]=ans[fa];
		if (l>ans[fa])
			ans[u]++;
	}
	for (int i=0;i<G[u].size();i++)
	{
		int v=G[u][i];
		if (v!=fa)
			dfs(v,u);
	}
	f[l]=last;
}
signed main(void)
{
	read(n);
	for (i=1;i<=n;i++)
		read(a[i]);
	for (i=1;i<n;i++)
	{
		int u,v;
		read(u),read(v);
		G[u].push_back(v);
		G[v].push_back(u);
	}
	dfs(1,0);
	for (i=1;i<=n;i++)
		print(ans[i]),putchar('\n');
	return 0;
} 

Measured memory_bytes: 30452
fun stringSizeEval(n: Int): Boolean {
    return n % 2 == 0
}

fun stringJudgment(s_1: String, s_2: String): String {
    return if(s_1 == s_2){
        "Yes"
    }else{
        "No"
    }
}

fun stringHalf(s: String): Pair<String, String> {
    val s_1: String = s.substring(0, s.length/2)
    val s_2: String = s.substring(s.length/2)
    return Pair(s_1, s_2)
}

fun main(args: Array<String>){
    if (stringSizeEval(readLine()!!.toInt())){
        val s: String = readLine()!!
        val spair = stringHalf(s)
        val ans = stringJudgment(spair.first, spair.second)
        println(ans)
    }else{
        println("No")
    }
}

Measured memory_bytes: 33656
int main(void){
  int i;
  int x[200],tmp[200];
  int n,m,k;

  scanf("%d",&n);
  for(i=0;i<2*n;i++){
    x[i] = i+1;
  }

  scanf("%d",&m);
  while(m--){
    scanf("%d",&k);

    if(k){
      for(i=0;i<k;i++){
        tmp[i+(2*n-k)] = x[i];
      }
      for(i=k;i<2*n;i++){
        tmp[i-k] = x[i];
      }
    }
    else{
      for(i=0;i<n;i++){
        tmp[2*i]   = x[i];
        tmp[2*i+1] = x[i+n];
      }
    }

    for(i=0;i<2*n;i++){
      x[i] = tmp[i];
    }
  }

  for(i=0;i<2*n;i++){
    printf("%d\n",x[i]);
  }

  return 0;
}

Measured memory_bytes: 0
'use strict'

const inArray = (needle, haystack) => haystack.some(item => item === needle)

const main = (input) => {
    input = input.split('\n')
    const H = parseInt(input[0].split(' ')[0])
    const W = parseInt(input[0].split(' ')[1])
    const grid = input.slice(1, H + 1).map(w =>  w.split(''))
    const g1 = grid.filter(g => g.some(h => h === '#'))
    let buffer = []
    g1.forEach(g => {
        g.forEach((h, i) => {
            if(h === '#'){
                buffer.push(i)
            }
        })
    })
    buffer = [...new Set(buffer)]
    g1.forEach(g => {
        let str = ''
        g.forEach((h, i) => {
            if(inArray(i, buffer)){
                str += h
            }
            if(i === g.length -1){
                console.log(str)
            }
        })
    })
}

main(require('fs').readFileSync('/dev/stdin', 'utf-8'))

Measured memory_bytes: 11468
L,R = map(int,input().split())

v = 2019

mins = []
for i in range(L,min(R,L + v)):
    tmp_min = 10e10
    for h in range(i + 1,min(R,L + v) + 1):
        res = (i * h) % v
        if res < tmp_min:
            tmp_min = res
    mins.append(tmp_min)


print(min(mins))


Measured memory_bytes: 3060
n, m = map(int, input().split())
if n==1 and m>1:
    ans=m-2
elif m==1 and n>1:
    ans=n-2
elif n==1 and m==1:
    ans=1
else:
    ans=n*m-2*(n+m)+4
if ans>0:
    print(ans)
else:
    print(0)

Measured memory_bytes: 3060
X = int(input())

A = []
for i in range(1000):
    A.append(i ** 5)

x, y = 0, 0

flag = False
for i, a in enumerate(A):
    for j, b in enumerate(A[i+1:]):
        if b - a == X:
            flag = True
            x = j + i + 1
            y = i
            break
        if a + b == X:
            flag = True
            x = i
            y = -(j + i + 1)
            break
    if flag:
        break
print(x, y)

Measured memory_bytes: 79564
#include <stdio.h>

int main(void)
{
    int a, b;
    scanf("%d %d", &a, &b);
    if(a < b)
    	printf("a < b\n");
    else if(a > b)
    	printf("a > b\n");
    else if(a == b)
    	printf("a == b\n");
    return 0;
}

Measured memory_bytes: 2596
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
using namespace std;

int main(){

	ll N,sum,limit,tmp,calc,count;

	while(true){
		scanf("%lld",&N);
		if(N == 0)break;

		if(N <= 5){
			printf("deficient number\n");
			continue;
		}

		sum = 1;
		limit = sqrt(N);
		tmp = N;

		calc = 1;
		count = 1;
		while(tmp%2 == 0){
			tmp /= 2;
			calc += pow(2,count);
			count++;
		}

		sum *= calc;

		for(int i = 3; i <= limit; i+=2){
			calc = 1;
			count = 1;
			while(tmp%i == 0){
				tmp /= i;
				calc += pow(i,count);
				count++;
			}
			sum *= calc;
		}
		if(tmp < N && tmp != 1){
			sum *= (1+tmp);
		}

		sum -= N;

		if(sum == N){
			printf("perfect number\n");
		}else if(sum > N){
			printf("abundant number\n");
		}else{
			printf("deficient number\n");
		}
	}
	return 0;
}

Measured memory_bytes: 2708
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>

using namespace std;


int main() {
	map<int, int> mp;
	long long int n, m=0,tmp=1,ax=0,k=0,t[500000],x,y,res[5000],a,b,c,GCD,two=1,kisuu=0,p,q,r,type=0;
	string str, str2[5000];
	cin>>n;
	

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

		if (t[i] > t[i - 1]) {
			if (type == 0) { type = 1; }

			else if (type == 1) { continue; }
			else if (type == -1) {
				tmp++;
				type = 0;
			}
		}

		if (t[i] < t[i - 1]) {
			if (type == 0) { type = -1; }

			else if (type == -1) { continue; }
			else if (type == 1) {
				tmp++;
				type = 0;
			}
		}

	}
	cout << tmp;
}

Measured memory_bytes: 2944
# -*- coding: utf-8 -*-
"""
Created on Sun Sep 13 14:18:02 2020

@author: liang
"""

import math
from math import gcd
A, B = map(int,input().split())
g = gcd(A,B)
n = int(math.sqrt(g))
d_list = list()# 1

#約数チェック O(√n)
for i in range(1,n+1):
    if g % i == 0:
        j = g//i
        d_list.append(i)
        if j != 1:
            d_list.append(j)
d_list.sort()
#print(d_list)
ans_list = [1]
d_list.pop(0)
while d_list:
    t = d_list.pop(0)
    ans_list.append(t)
    d_list = [i for i in d_list if i%t != 0]
#print(d_list)
#print(ans_list)
print(len(ans_list))

Measured memory_bytes: 9180
#include <algorithm>
#include <iostream>
#include <queue>
#include <cmath>
#include <set>
#include <iomanip>
#include <vector>
using namespace std;
typedef long long ll;
typedef long double ld;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
#define INF 100000000
#define MAX_V 100001
#define MOD 1000000007
typedef vector<vector<int> > Graph;

int main(){
   int n;cin>>n;
   int ans=0;
   vector<int> a(n);
   for(int i=0;i<n;i++){
       cin>>a[i];
       a[i]--;
   }
   for(int i=0;i<n;i++){
       if(a[a[i]]==i){
           ans++;
           a[a[i]]=-1;
        }
    }
   cout<<ans<<endl;
}
 



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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define int ll

const ll MOD = 1000000007;
const ll INF_LL = (ll)1000000007 * 1000000007;
const int INF_INT = (int)1000000007;
const double PI = 3.14159265358979323846;

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define irep(itr, st) for (auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for (auto itr = (st).rbegin(); itr != (st).rend(); ++itr)

#define m0(x) memset((x), 0, sizeof((x)))
#define m1(x) memset((x), -1, sizeof((x)))

// xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end()  // sortなどの引数を省略したい
#define RALL(x) (x).rbegin(), (x).rend()  // sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())     // sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))  //最大値を求める
#define MIN(x) *min_element(ALL(x))  //最小値を求める
#define all(x) (x).begin(), (x).end()

//略記
#define pb emplace_back  // vectorヘの挿入
#define mp make_pair     // pairのコンストラクタ
#define F first          // pairの一つ目の要素
#define S second         // pairの二つ目の要素

#define BITCOUNT __builtin_popcount
#define BITCOUNT_LL(x) __builtin_popcountll(x)

#define perm(c)             \
  sort(all(c));             \
  for (bool c##p = 1; c##p; \
       c##p = next_permutation(all(c)))  //順列 123 132 213 231 312 321

#define BIT(n) (1LL << (n))

#ifdef DEBUG
#define PRINT(A) std::cout << (#A) << ": " << (A) << std::endl;
#else
#define PRINT(A)
#endif

//入力高速化
struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

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;
}

signed main() {
  int N;
  cin >> N;
  int count = 0;
  if (N % 2 == 0) {
    for (int i = 1; i <= N; i++) {
      for (int j = i + 1; j <= N; j++) {
        if (i == j || j == (N + 1 - i)) {
          continue;
        }
        count++;
      }
    }
  } else {
    for (int i = 1; i <= N; i++) {
      for (int j = i + 1; j <= N; j++) {
        if (i == j || j == (N - i)) {
          continue;
        }
        count++;
      }
    }
  }

  cout << count << endl;

  if (N % 2 == 0) {
    for (int i = 1; i <= N; i++) {
      for (int j = i + 1; j <= N; j++) {
        if (i == j || j == (N + 1 - i)) {
          continue;
        }
        cout << i << " " << j << endl;
      }
    }
  } else {
    for (int i = 1; i <= N; i++) {
      for (int j = i + 1; j <= N; j++) {
        if (i == j || j == (N - i)) {
          continue;
        }
        cout << i << " " << j << endl;
      }
    }
  }
}

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

int main(){
    int64_t N;
    cin >> N;
    cout << (N / 1 * 1 * (N / 1 + 1) - N / 3 * 3 * (N / 3 + 1) - N / 5 * 5 * (N / 5 + 1) + N / 15 * 15 * (N / 15 + 1)) / 2 << endl;
}

Measured memory_bytes: 3552
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>

//#include <tuple>

//#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long
#define pb push_back

long euclid(long c, long d){ // 最大公約数を求めるプログラム
    long mx = max(c,d);
    long mi = min(c,d);
    long tmp=0;
    while(mi > 0){
        tmp = mx % mi;
        if(tmp==0){
            return mi;
        } else{
            mx = mi;
            mi = tmp;
        }
    }
    return 1;
} 

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  rep(i, N){
    cin >> a[i];
  }

  // それぞれについての最大公約数を求める
  long tmp = a[0];
  rep(i, N){
    tmp = euclid(tmp, a[i]);
  }
  cout << tmp << endl;

}


Measured memory_bytes: 640
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    resolve(System.in, System.out);
  }

  static void resolve(InputStream is, PrintStream pw) {
    Scanner sc = new Scanner(is);
    int[][] card = new int[3][3];
    boolean[][] marked = new boolean[3][3];
    for (int i = 0; i < 3; i++) {
      for (int j = 0; j < 3; j++) {
        card[i][j] = Integer.parseInt(sc.next());
        marked[i][j] = false;
      }
    }
    int n = Integer.parseInt(sc.next());
    for (int k = 0; k < n; k++) {
      int b = Integer.parseInt(sc.next());
      for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
          if (card[i][j] == b) {
            marked[i][j] = true;
          }
        }
      }
    }
    for (int i = 0; i < 3; i++) {
      boolean bingo = true;
      for (int j = 0; j < 3; j++) {
        bingo = bingo && marked[i][j];
      }
      if (bingo) {
        pw.println("Yes");
        return;
      }
    }
    for (int j = 0; j < 3; j++) {
      boolean bingo = true;
      for (int i = 0; i < 3; i++) {
        bingo = bingo && marked[i][j];
      }
      if (bingo) {
        pw.println("Yes");
        return;
      }
    }
    if (marked[0][0] && marked[1][1] && marked[2][2]) {
      pw.println("Yes");
      return;
    }
    if (marked[0][2] && marked[1][1] && marked[2][0]) {
      pw.println("Yes");
      return;
    }
    pw.println("No");
  }
}


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

using ll = long long;
using pii = pair<int, int>;

#define vt          vector
#define sz(x)       (int)(x).size()
#define all(x)      (x).begin(), (x).end()
#define rall(x)     (x).rbegin(), (x).rend()
#define fi          first
#define se          second

signed main() {
    ios::sync_with_stdio(0), cin.tie(0);

    int n, k;
    cin >> n >> k;
    vt<int> a(n);
    for (int &i : a) cin >> i;

    ll ans = 0;
    vt<int> b(n + 1);
    map<int, int> m;
    for (int i = 0; i < n; i++) {
        m[b[i]]++;
        if (i >= k - 1) m[b[i - k + 1]]--;
        b[i + 1] = ((b[i] - a[i] + 1) % k + k) % k;
        if (m.count(b[i + 1])) ans += m[b[i + 1]];
    }

    cout << ans;
}


Measured memory_bytes: 14212
package main

import (
	"fmt"
	"math"
)

var mod = pow(10, 9) + 7
var A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z int
var ans int = 0

func main() {
	fmt.Scan(&N)
	p := make([]int, N)

	for i := 0; i < N; i++ {
		fmt.Scan(&p[i])
	}
	var cnt int
	for i := 1; i < N-1; i++ {
		if p[i-1] < p[i] && p[i] < p[i+1] {
			cnt++
		} else if p[i-1] > p[i] && p[i] > p[i+1] {
			cnt++
		}
	}
	fmt.Println(cnt)
}

/*  ----------------------------------------  */

func lcm(x, y int) int {
	return (x / gcd(x, y)) * y
}

func gcd(x, y int) int {
	if x%y == 0 {
		return y
	} else {
		r := x % y
		return gcd(y, r)
	}
}

func combination(x, y int) int {
	return permutation(x, y) / permutation(y, y)
}

func permutation(x, y int) int {
	var ans, cnt int = 1, 0
	for cnt < y {
		ans *= (x - cnt)
		cnt++
	}
	return ans
}

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}
func pow(x, y int) int { return int(math.Pow(float64(x), float64(y))) }
func abs(x int) int    { return int(math.Abs(float64(x))) }
func floor(x int) int  { return int(math.Floor(float64(x))) }
func ceil(x int) int   { return int(math.Ceil(float64(x))) }

type SortBy []int

func (a SortBy) Len() int           { return len(a) }
func (a SortBy) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool { return a[i] > a[j] }


Measured memory_bytes: 512
#include <cstdio>
#include <cstdint>

int calc(int x) {
  int n=0;
  while (x % 100 == 0) {
    ++n;
    x /= 100;
  }
  return n;
}

int main() {
  int D, N;
  scanf("%d %d", &D, &N);

  int m=0;
  for (int i=1; i<=1e7; ++i) {
    if (calc(i) == D)
      ++m;

    if (m == N)
      return !printf("%d\n", i);
  }
}


Measured memory_bytes: 128
N=int(input())
S=1/2*N*(N+1)
FB=N//15
F=N//3
B=N//5

sum_FB=15*1/2*FB*(FB+1)
sum_F=3/2*F*(F+1)
sum_B=5/2*B*(B+1)
print(int(S-sum_B-sum_F+sum_FB))

Measured memory_bytes: 9180
#include<cstdio>
main(){for(char t[11];scanf("%s",t)!=EOF;){int i,s,p[10]={1,9,6,4,6,6,4,6,9,1};for(i=s=0;i<10;i++)s+=(t[i]-48)*p[i];printf("%d\n",s%10);}}

Measured memory_bytes: 0
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

import bisect
A.sort()
B.sort()
C.sort()





bc_val = [0] * N
for i in range(N):
    b = B[i]
    c_idx = bisect.bisect_right(C,b)
    bc_val[i] = (N-c_idx)
    
bc_ruiseki = [0] * N
tmp = bc_val[N-1]
bc_ruiseki[N-1] = tmp
for i in reversed(range(N-1)):
    tmp += bc_val[i]
    bc_ruiseki[i] = tmp
 

ans = 0
ib = 0
b = B[0]
flag = True
for ia in range(N):
    a = A[ia]
    while b <= a:
        if ib == N-1:
            flag = False
            break
        ib += 1
        b = B[ib]
    if flag:
        ans += bc_ruiseki[ib]
    else:
        break
    
print(ans)

Measured memory_bytes: 24652
/*------------------------- Bism Allah Alruhmin Alrahim -------------------------------*/
#include <bits/stdc++.h>
#define forn(i, n) for (int i = 0; i < n; i++)
#define ford(i, n) for (int i = n - 1; i > -1; i--)
#define forl(i, l, r) for (int i = l; i <= r; i++)
#define vc vector
#define f first
#define s second
#define pb(i) push_back(i)
#define mx(ar, n) (*max_element(ar, ar + n))
#define mn(ar, n) (*min_element(ar, ar + n))

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
const long double pi = acos(-1);

int main()
{
	long long x , d , r ; 
	int n ; 
	cin >> n ; 
	vector<pair<string , pair<int , int > > > v;
	for (int i = 0; i < n; ++i)
	{
		int a ; string s ;
		cin >> s >> a; ;
		v.push_back({s,{a,i}});
	}
	sort(v.begin(), v.end());
	for (int i = 0; i < v.size() - 1; ++i)
	{
		for (int j = 0; j < n-i-1; ++j)
		{
			if(v[j].second.first < v[j+1].second.first and v[j].first == v[j+1].first){
				swap(v[j] , v[j+1]);
			}
		}
	}
	for (int i = 0; i < v.size(); ++i)
	{
		cout << v[i].second.second+1 << endl ;
	}
	return 0 ;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
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;
const int inf = 1001001001;
 
template <typename T>
struct UnionFind {
   vector<T> par; 
 
   UnionFind(T N) : par(N) { 
        for(T i = 0; i < N; i++) par[i] = i;
   }
 
   int root(T x) { 
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
   }
 
   void unite(T x, T y) { 
       T rx = root(x); 
       T ry = root(y); 
       if (rx == ry) return; 
       par[rx] = ry; 
   }
 
   bool same(T x, T y) { 
       T rx = root(x);
       T ry = root(y);
       return rx == ry;
   }
};
 
int main(){

    int a,b,c,d;
    cin >> a >> b >> c >> d;
    cout << c-(d-b) << " " << d+(c-a) << " " << (c-d+b)-(c-a) << " " << (d+c-a)-(d-b) << endl;


 
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
//#define mp make_pair
#define fi first
#define se second
#define REP(i,j) for(int i=0;i<j;i++)
#define FORN(i,j,k) for(int i=j;i<k;i++)
#define vi vector<int>
#define vvi vector<vi >
#define pii pair<int,int>
#define vpii vector<pii >
using namespace std;
int n;
int a[200005];
bool used[200005];
map<int,ll>mp;
vi have;
ll cnt=0;
ll func(int k){
	ll ret=cnt-mp[k]*(mp[k]-1)/2+(mp[k]-1)*(mp[k]-2)/2;
	return ret;
}
int main(void){
	cin>>n;
	REP(i,n)cin>>a[i];
	REP(i,n){
		if(!used[a[i]]){
			used[a[i]]=1;
			have.pb(a[i]);
		}
		mp[a[i]]++;
	}
	sort(have.begin(),have.end());
	REP(i,have.size()){
		cnt+=mp[have[i]]*(mp[have[i]]-1)/2;
	}
	REP(i,n){
		cout<<(ll)func(a[i])<<endl;
	}
	return 0;
}

Measured memory_bytes: 11000
N = int(input())
sin = [input().strip() for i in range(N)]

def encode(dic):
    strs = 'abcdefghijklmnopqrstuvwxyz'
    key = ''
    for c in strs:
        num = str(dic[c]) if c in dic else '0'
        key += num + '_'
    return key

adic = {}
for s in sin:
    dic = {}
    for c in s:
        if c in dic:
            dic[c] += 1
        else:
            dic[c] = 1
    key = encode(dic)
    if key in adic:
        adic[key] += 1
    else:
        adic[key] = 1

ans = 0
for e in adic.values():
    ans += int(e * (e - 1) / 2)
print(ans)



Measured memory_bytes: 28692
a,b,c,d = map(int,input().split())

if a>=0:
    if c>=0:
        print(b*d)
    elif d>=0:
        print(b*d)
    else:
        print(a*d)
    

elif b>=0:
    if c>=0:
        print(b*d)
    elif d>=0:
        print(max(a*c,b*d))
    else:
        print(a*c)
 
else:
    if c>=0:
        print(b*c)
    elif d>=0:
        print(a*c)
    else:
        print(a*c)

Measured memory_bytes: 61836
n=int(input())
a=list(map(int,input().split()))
change=0

def hyouji(a,change):
    for i in range(len(a)):
        if i==0:
            print(a[i],end="")
        else:
            print(" "+str(a[i]),end="")
    print()
    print(change)


for i in range(n):
    mini=i
    for j in range(i,n):
        if a[j]<a[mini]:
            mini=j
    v=a[i]
    a[i]=a[mini]
    a[mini]=v
    if i!=mini:
        change+=1

hyouji(a,change)



Measured memory_bytes: 5616
#include<bits/stdc++.h>
using namespace std;
int a,b,c,s[8];
int main()
{
 //freopen(".in","r",stdin);
 //freopen(".out","w",stdout);
 scanf("%d%d%d",&a,&b,&c);
 s[1]=a+b;
 s[2]=a+c;
 s[3]=b+c;
 sort(s+1,s+4);
 cout<<s[1];
 return 0;
}

Measured memory_bytes: 256
/*
    Author - Param Kothari
    Ah shit, here we go again
*/
 
/* Ordered Set Implementaton:

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace __gnu_pbds;

typedef tree<
    int,
    null_type,
    less<int>,
    rb_tree_tag,
    tree_order_statistics_node_update>
ordered_set;
*/

#include <bits/stdc++.h>
 
using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define mk make_pair 
 
typedef long long ll;
typedef long double ld;

void solve(){
    int n = 0, m = 0;
    cin >> n >> m;
    int check[n + 1] = {0};
    map<int, int> mp;
    for(int i = 0; i < m; i++){
        int x;
        cin >> x;
        string t;
        cin >> t;
        if(check[x] == 1){
            continue;
        }
        else{
            if(t == "WA"){
                mp[x]++;
            }
            else{
                check[x] = 1;
            }
        }
    }
    int res = 0, wa = 0;
    for(int i = 0; i < n + 1; i++){
        if(check[i] == 1){
            res++;
            if(mp.find(i) != mp.end()) wa += mp[i];
        }
    }
    cout << res << " " << wa << "\n";
    return;
}
 
int main(){
    IOS;
    int t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 3584
import sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**10
def I(): return int(input())
def F(): return float(input())
def S(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()

def resolve():
    while True:
        H = I()
        if H==0:
            break
        else:
            s = [LI() for _ in range(H)]

            score = 0
            while True:
                # 消滅判定
                score_tmp = 0
                for i in range(H):
                    prev = 0
                    cnt = 1
                    for j in range(5):
                        if s[i][j]==prev:
                            cnt += 1
                        else:
                            if cnt>=3:
                                score_tmp += prev*cnt
                                for k in range(cnt):
                                    s[i][j-cnt+k] = 0
                            prev = s[i][j]
                            cnt = 1
                    if cnt>=3:
                        score_tmp += prev*cnt
                        for k in range(cnt):
                            s[i][j+1-cnt+k] = 0
                # print('s')
                # for i in s:
                #     print(i)
                if score_tmp==0:
                    break
                score += score_tmp

                # 落下処理
                # その石がどれだけ落下するかの算出
                drop = [[0]*5 for _ in range(H)]
                for i in range(5):
                    for j in range(H-1):
                        drop[H-j-2][i] = drop[H-j-1][i] + (1 if s[H-j-1][i]==0 else 0)
                # print('drop')
                # for i in drop:
                #     print(i)
                
                # 落下先にコピー
                for i in range(5):
                    for j in range(H):
                        if drop[H-j-1][i]!=0:
                            s[H-j-1+drop[H-j-1][i]][i] = s[H-j-1][i]
                            s[H-j-1][i] = 0
                # print('dropped s')
                # for i in s:
                #     print(i)

            print(score)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 5736
K=int(input())
inf=(10**(K-1)-1)
temp=7
if K%2==0 or K%5==0:
    print(-1)
    exit()
else:
    for i in range(K):
        temp=temp%K
        if temp==0:
            print(i+1)
            exit()
        temp=10*temp+7



Measured memory_bytes: 10512
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    double p[n];
    for(int i=0; i<n; i++)
        cin>>p[i];
    double arr[n+1][n+1] = {0};
    arr[0][0] = 1;
    for(int i=0; i<=n; i++)
    {
        for(int j=i; j<=n; j++)
        {
            if(i==0 && j==0)
                continue;
            double head_prob = p[j-1];
            double tail_prob = 1 - head_prob;
            if(i==0)
            {
                arr[i][j] = tail_prob*(arr[i][j-1]);
                continue;
            }
            else
            {
                arr[i][j] = head_prob*(arr[i-1][j-1]) + tail_prob*(arr[i][j-1]);
            }
        }
    }
    double sum = 0;
    for(int i=((n/2)+1); i<=n; i++)
    {
    //    cout<<"i : "<<i<<",     arr[i][n-1] : "<<arr[i][n-1]<<endl;
        sum += arr[i][n];
    }
    cout<<setprecision(10)<<sum;

    return 0;
}


Measured memory_bytes: 70528
#https://atcoder.jp/contests/ddcc2020-qual/tasks/ddcc2020_qual_a
XY=input().split()
X=int(XY[0])
Y=int(XY[1])
award=0
if X==1 and Y==1:
    award+=400000
for num in [X,Y]:
    if num==3:
        award+=100000
    if num==2:
        award+=200000
    if num==1:
        award+=300000
print(award)

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
ll dp[2500];
void init(){
    for(int i=3; i<=2000; i++){
        dp[i]=1;
        if(i-3>=3){///dp[i]=1;
            for(int j=3; j<=i-3; j++)dp[i]=(dp[i]+dp[j])%mod;
        }
    }
}
int main()
{
    init();
    int n;cin>>n;
    ///if(n<=2)return cout<<0<<endl,0;
    cout<<dp[n]<<endl;
    return 0;
}


Measured memory_bytes: 3116
//#include "pch.h"
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>

#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <bitset>

#define ll long long
#define fri(n) for(i=0;i<(n);i++)
#define frj(n) for(j=0;j<(n);i++)
#define min(p,q) ((p)<(q)?(p):(q))
#define max(p,q) ((p)>(q)?(p):(q))
#define INF 1000000000000000000//10^18
#define INFINT 2000000001//2*10^9+1
#define MOD 1000000007
#define MODANOTHER 998244353
#define PI acos(-1)

using namespace std;

struct bangumi_t{
	int s;
	int t;
	int c;
};

int compare_channel(const void *a, const void *b) {//降順と昇順あってる？？
	struct bangumi_t *A = (struct bangumi_t *)a;
	struct bangumi_t *B = (struct bangumi_t *)b;
	if(A->c - B->c >0){
		return 1;
	}else if(A->c - B->c <0){
		return -1;
	}else{
		return 0;
	}
}


int main(void)
{
	//変数の宣言
	int n,m;
	char s[100010];

	//よく使う変数
	int i,j,k,l;
	int flag=0;
	int ans=0;
	int count=0;
	int temp=0;
	int temp1=0;
	int temp2=0;
	int temp3=0;
	int max=0;
	int min=INFINT;
	int len=0;
	int sum=0;
	int ok=0;
	int ng=0;
	char dummy;
	char stemp[11];
	
	//データの読み込み


	scanf("%d %d",&n,&m);
//	scanf_s("%d %d",&n,&m);

	scanf("%s",&s);
//	scanf_s("%s",&s,100010);


/*	for(i=0;i<n;i++){
//		scanf("%d",&b[i]);
		scanf_s("%d",&b[i]);
	}*/


/*	for(i=0;i<n;i++){
//		scanf("%c",&c[i]);
		scanf_s("%c",&c[i]);
		d[i]=0;
	}*/


	//	printf("nは%dです\n", n);
	//	printf("データの読み込み終了\n");
	//実際の処理

//	clock_t start=clock();

	for(i=0;i<n-1;i++){
		if(s[i]==s[i+1]) sum++;
	}

//	clock_t end=clock();

	//	printf("計算部分終了\n");

	//出力
	printf("%d",min(sum+2*m,n-1));

//	printf("time=%lf",(double)(end-start)/CLOCKS_PER_SEC);
	//	printf("結果の出力終了\n");

	return 0;
}



Measured memory_bytes: 384
N = int(input())
A = list(map(int, input().split()))
L = [0 for i in range(max(A)+2)]
ans = 1
L[0] = 3
p = 10 ** 9 + 7
for i in range(N):
  ai = A[i]
  ans *= (L[ai] - L[ai + 1])
  ans = ans % p
  L[ai + 1] += 1
print(ans)


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

int main() {
  int N;
  cin >> N;
  string s[N];
  // read
  for (int i=0; i < N; ++i) cin >> s[i];

  int M;
  cin >> M;
  string t[M];
  // read
  for (int i=0; i < M; ++i) cin >> t[i];

  int res = 0, cnt = 0;
  
  // caliculate
  for (int i=0; i < N; ++i) {
    cnt = 1;
    for (int j=i+1; j < N; ++j) {
      if (s[i] == s[j]) ++cnt;
//      cout << " i:" << i << " j:" << j << " s[i]:" << s[i] << " cnt:" << cnt << endl;
    }  
    for (int k=0; k < M; ++k) {
      if (s[i] == t[k]) --cnt;
//      cout << " i:" << i << " k:" << k << " s[i]:" << s[i] << " cnt:" << cnt << endl;
    }  
    cnt = max(cnt,0);
    res = max(cnt,res);
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
import math
n = int(input())
while (n != 0):
    nlist = list(map(float, input().split()))
    sum = 0
    for i in range(n):
        sum += nlist[i]
    aver = sum/n
    var = 0
    for i in range(n):
        var += (nlist[i] - aver)**2 / n
    dev = math.sqrt(var)
    print(dev)
    n = int(input())


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

int a[3],k;

int main()
{
	scanf("%d%d%d",&a[0],&a[1],&k);
	int f = 0;
	while (k--){
		if (a[f]&1) a[f]--;
		a[1-f] += a[f]/2, a[f] /= 2;
		f = 1-f;
	}
	printf("%d %d\n",a[0],a[1]);
	return 0;
}

Measured memory_bytes: 256
k = %[Man Oku Cho Kei Gai Jo Jou Ko Kan Sei Sai Gok Ggs Asg Nyt Fks Mts].split.to_a
k.unshift("")
while gets
  m, n = $_.split.map(&:to_i)
  break if m == 0 && n == 0
  v = m ** n
  x = []
  a = v.to_s.size / 4
  (0..a).each{ |i| x[i] = v / 10**(4*i) % 10000 }
  a.downto(0){ |i| print x[i], k[i] if x[i] > 0 }
  puts
end

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MOD 1000000009

using namespace std;

using ll = long long int;

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec)
{
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
  }
  return os;
}

// template <typename T>
// void print_table(ostream& os, const T , int m, int n)
// {
//   for(int i = 0; i < m; ++i)
//   {
//     for(int j = 0; j < n; ++j)
//     {
//       cout << dp[i][j] << " ";
//     }
//     cout << endl;
//   }
// }

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n, x, d = 0;
  ll tmp, cnt = 0;
  cin >> n >> x;
  vector<int> a(n);
  rep(i, n)
  {
    if (i == 0)
    {
      cin >> a[i];
    }
    else
    {
      int tmp;
      cin >> tmp;
      a[i] = tmp + a[i-1];
    }
  }
  rep(i, n)
  {
    if (a[i] <= x) ++cnt;
  }
  cout << cnt + 1 << endl;
}

Measured memory_bytes: 256
h,w=[int(i) for i in input().split()]
s=[[j for j in input().split()] for i in range(h)]
abc="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
result=""
for i in range(h):
    for j in range(w):
        if s[i][j]=="snuke":
            result=abc[j]+str(i+1)
            break
    if len(result)==2:
        break
print(result)

Measured memory_bytes: 3060