akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define Max(a, b) (a > b ? a : b)
#define Min(a, b) (a < b ? a : b)
#define ii pair<int, int>
#define fi first
#define se second
const int MAX = 200000; //2 * 10^5
const int MOD = 1000000007; //10^9 + 7
const int OO = 0x3f3f3f3f; // 0x3f3f3f3f;

int pf[5000][3];
vector<int> buc[3];
int n;
string s;

inline int getID(char c)
{
	if(c == 'R') return 0;
	if(c == 'G') return 1;
	return 2;
}

inline int count(char a, char b, char c)
{
	int ans = 0;
	for(int &i : buc[ getID(a) ])
	{
		for(int &j : buc[ getID(b) ])
		{
			if(j <= i) continue;
			
			ans += (pf[n][ getID(c) ] - pf[j][ getID(c) ]); 
			
			int d = j - i;
			
			int k = j + d;
			
			if(k <= n) ans -= (s[k - 1] == c);
		}	
	}
	return ans;
}

int32_t main()
{
	cin >> n >> s;

	for(int i = 1; i <= n; i++)
	{
		int c = getID(s[i - 1]);
		for(int j = 0; j < 3; j++)
			pf[i][j] = pf[i - 1][j] + (c == j);
		buc[c].push_back(i);
	}	

	int ans = 0;
	
	ans += count('R', 'G', 'B');
	ans += count('G', 'R', 'B');
	ans += count('R', 'B', 'G');
	ans += count('B', 'R', 'G');
	ans += count('G', 'B', 'R');
	ans += count('B', 'G', 'R');

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

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

using namespace std;

typedef long long int li;
typedef vector<li> vi;
typedef pair<li,li> pi;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define B begin()
#define E end()
#define f(i,l,r) for(li i=l;i<=r;++i)
#define fr(i,l,r) for(li i=l;i>=r;--i)
#define u_map unordered_map
#define endl "\n"

li fastpow(li base,li exp,li M) 
{
    li res=1;
    while(exp>0) {
        if(exp&1)
            res=(res*base)%M;

        base=(base*base)%M;
        exp>>=1;
    }
    return res;
}

vi par,sz,vis;
vector<vi> graph;

void init(li n)
{
    par.resize(n);
    sz.resize(n);
    vis.resize(n);
    graph.resize(n);

    f(i,0,n-1)
    {
        par[i]=i;
        sz[i]=1;
    }
}

li root(li a)
{
    while(a!=par[a])
    {
        par[a]=par[par[a]];
        a=par[a];
    }

    return a;
}

void unio(li a,li b)
{
    li r_a=root(a);
    li r_b=root(b);

    if(par[r_a]!=r_b)
    { 
        if(sz[r_a]<sz[r_b])
        {
            par[r_a]=par[r_b];
            sz[r_b]+=sz[r_a];
            sz[r_a]=0;
        }
        else
        {
            par[r_b]=par[r_a];
            sz[r_a]+=sz[r_b];
            sz[r_b]=0;
        }
    }
}

int main()
{    
 

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

    li n,m;

    cin>>n>>m;

    if(n==m)
        cout<<"Yes";
    else
        cout<<"No";

    return 0;
}

Measured memory_bytes: 256
// 2_abc146_b
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define SZ(x) ((int)(x).size())
#define INF (1e16)
#define MOD (1000000007)
typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    string s;
    cin >> n;
    cin >> s;
    string alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

    rep(i, s.length()){
        int k = s[i] - 'A';
        if(k + n < 26){
            s[i] = alpha[k + n];
        }else{
            s[i] = alpha[k + n - 26];
        }
    }

    cout << s << endl;
    return 0;
}


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

int main(void)
{

	int n,r;
	int p,c;
	int i1,i2;

	while(1){

		cin >> n >> r;
		if (n==0 && r==0) break;

		vector<int> fuda(n),temp(n);

		/* syokika */
		for(i1=0;i1<n;i1++){
			fuda[i1] = n-i1;
	//		cout << fuda[i1] << " ";

		}


		for(i2=0;i2<r;i2++){
			
			cin >> p >> c;

			

			/* copy */
			for(i1=0;i1<p-1;i1++){
				temp[i1] = fuda[i1];
			}


			/* shuffle */
			for(i1=0;i1<c;i1++){
				fuda[i1] = fuda[p-1+i1];
			}
			for(i1=c;i1<p-1+c;i1++){
				fuda[i1] = temp[i1-c];
			}


	/*		for(i1=0;i1<n;i1++){
				cout << fuda[i1] << " ";
			}*/


		}
		cout << fuda[0] << endl;

	}

	return 0;
}

Measured memory_bytes: 1196
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define ll long long
#define cst first
#define dur second
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int N = 1e5 + 5, M = 2 * N + 5;

int n;
char s[N];
ll dp[N][15];
ll MOD(1e9 + 7);

ll solve(int i, int ba2e){
    if(i == n)return (ba2e == 5);
    ll &ret = dp[i][ba2e];
    if(~ret)return ret;
    ret = 0;
    for(int j = 0 ; j <= 9 && s[i] == '?'; ++j)
        ret = (ret + solve(i + 1, (ba2e * 10 + j) % 13)) % MOD;
    if(s[i] != '?')
        ret = (ret + solve(i + 1, (ba2e * 10 + (s[i] - '0')) % 13)) % MOD;
    return ret;
}
int main(){
    scanf("%s", s);
    n = strlen(s);
    memset(dp, -1, sizeof dp);
    printf("%lld\n", solve(0, 0));
}

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


class Point {
public:
  double x, y;
  Point(double x = 0, double y = 0):x(x), y(y){}
  Point operator +(Point p) { return Point(x+p.x, y+p.y);}
  Point operator -(Point p) { return Point(x-p.x, y-p.y);}
  Point operator *(double t) { return Point(x*t, y*t);}
};

struct Segment{
  Point p1, p2;
};

  Segment s;
  Point p,ans;

typedef Point Vector;

double norm(double x, double y){
  return x*x + y*y;
}

double gaiseki(Vector a, Vector b) {
  return a.x*b.y - a.y*b.x;
}

double naiseki(Vector a, Vector b) {
  return a.x*b.x + a.y*b.y;
}

Point project(Segment s, Point p){
  Vector base = s.p2 - s.p1;
  double t = naiseki(p - s.p1, base)/norm(base.x, base.y);
  return s.p1 + base*t;
}

Point reflect (Segment s, Point p){
  return p + (project(s, p) - p)*2.0;
}

int main(){
 
  int i;
  double x1,x2,y1,y2,xq,yq;

  while(scanf("%lf,%lf,%lf,%lf,%lf,%lf",&x1, &y1 ,&x2, &y2, &xq,&yq)!=EOF){

    s.p1 = Point(x1,y1);
    s.p2 = Point(x2,y2);
    p = Point(xq,yq);

    ans  = reflect(s,p);

    printf("%.6f %.6f\n", ans.x, ans.y);
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
ll MOD = 1e9+7;
int main()
{
  int a, b, c;
  cin >> a >> b >> c;
  if(a + b + c >= 22) cout << "bust" << endl;
  else cout << "win" << endl;
}

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

int main(){
    string s, t;
    cin >> s >> t;

    int x = 0;

    for(int i = 0; i < s.length(); i++){
        if(s[i] != t[i]){
            x++;
        }
    }
    cout << x;
}


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


int main(){
    vector<int> mountain(10);
    for (int i = 0; i < 10; i++) cin >> mountain[i];

    sort(mountain.begin(), mountain.end(), greater<int>());

    for (int i = 0; i < 3; i++) cout << mountain[i] << endl;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define ll long long int
#define ss second
#define ff first
#define Mem(x,val) memset(x,val,sizeof x)
#define pb push_back
#define all(v) v.begin(),v.end()
#define unik(v)  v.erase(unique(v.begin(),v.end()),v.end())
#define cerr(x) cerr << __LINE__ << " th Line : " << #x << " = " << x << "\n"
using namespace std;
typedef pair<int, int> pi32;
typedef pair<ll, ll> pi64;
typedef vector<int> vi32;
typedef vector<ll> vi64;
const ll mod = 998244353;
const ll sz = 1e3 + 10, inf = 2 * 1e18 + 10;
const double pi = acos(-1.0);
int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	int n; cin >> n;
	vi32 a(n);
	vi32 fr(n, 0);
	for (int i = 0; i < n - 1; i++) {
		cin >> a[i];
		fr[a[i]]++;
	}
	vi32 ans;

	for (int i = 1; i < fr.size(); i++)cout << fr[i] << '\n';
	cout << "0\n";
	return 0;
}

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

int main() {
  int n;
  cin>>n;
  long long int x[n],y[n];
  for(int i=0;i<n;i++){
    cin>>x[i];
    y[i]=x[i];
  }
  sort(x,x+n);
  
  for(int i=0;i<n;i++){
    long long int left=x[n/2-1],right=x[n/2];
    if(y[i]<=left)
      cout<<right;
    else cout<<left;
    cout<<endl;
  }

}

Measured memory_bytes: 5376
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
using namespace std;

int main(){
    int d,n;cin>>d>>n;
    if(n==100)n=101;
    cout<<n;
    if(d==0)cout<<endl;
    else if(d==1)cout<<"00"<<endl;
    else if(d==2)cout<<"0000"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MOD = 1e9+7;
int modinv(int a, int b=MOD-2) {
    int ret = 1, mult = a % MOD;
    while(b) {
        if(b&1) ret = (ret*mult)%MOD;
        mult = (mult*mult)%MOD;
        b /= 2;
    }
    return ret;
}
int frac(int a, int b) {
    return (a*modinv(b))%MOD;
}
int C(int n, int r) {
	int ret = 1, div = 1;
	for(int i=n-r+1; i<=n; i++)
		ret = (ret*i) % MOD;
	for(int i=1; i<=r; i++)
		div = (div*i) % MOD;
	return frac(ret, div);
}
int32_t main() {
	ios::sync_with_stdio(0);cin.tie(0);
	int n, a, b;
	cin >> n >> a >> b;
	int ans = modinv(2, n) - C(n, a) - C(n, b);
	cout << (ans + 3*MOD - 1) % MOD;
}

Measured memory_bytes: 256
def main():
    N, K = map(int, input().split())
    MOD = 10**9 + 7
    cnt = [0 for _ in range(K)] # k番目の要素はgcd(A)==k+1(x)となるような数列Aの個数
    ans = 0

    for k in range(K)[::-1]:
        x = k+1

        ### gcd(A)がxの倍数となるような数列Aの個数
        cnt[k] = pow((K//x), N, MOD) # (K//x)**Nでは計算量がかかる
        cnt[k] %= MOD
        ### gcd(A)が2x, 3x...となる数列Aの個数を引く。
        for j in range(2*x, K+1, x):
            cnt[k] -= cnt[j-1]
            cnt[k] %= MOD

        ans += cnt[k]*x
        ans %= MOD
    print(ans)
main()

Measured memory_bytes: 11216
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define M 1101
#define MOD 1000000007
#define fi first
#define se second
#define vi vector<int>
#define vl vector<ll>
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define repl(i,l,r) for(long long i=l;i<=r;++i)
#define rep(i,l,r) for(int i=l;i<=r;++i)
#define ins insert
#define inf INT_MAX
#define vp vector< pair<int,int> >
int n;
const int maxn=100005;
vp g[maxn];
int col[maxn];
bool visited[maxn];
void ass(int i)
{
    for(auto j:g[i])
    {
        if(visited[j.first])
        {
            continue;
        }
        visited[j.first]=true;
        col[j.first]=(j.second+col[i])%2;
        ass(j.first);
    }
    return;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n;
    rep(i,1,n-1)
    {
        int x,y,w;
        cin>>x>>y>>w;
        g[x].pb(mp(y,w));
        g[y].pb(mp(x,w));
    }
    memset(visited,false,sizeof visited);
    col[1]=0;
    ass(1);
    rep(i,1,n)
    {
        cout<<col[i]<<"\n";
    }


    return 0;
}



Measured memory_bytes: 7680
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long hxtype;
typedef pair<int,int> pii;
typedef pair<int,ll > pil;
typedef pair<ll ,int> pli;
typedef pair<ll ,ll > pll;
#define pque priority_queue
#define rep(i,l,r) for(i=(l);i<=(r);++i)
#define per(i,l,r) for(i=(l);i>=(r);--i)
#define REP(i,l,r) for(i=(l);i< (r);++i)
#define PER(i,l,r) for(i=(l);i> (r);--i)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
template<class IT>inline void cmax(IT &a,IT b){if(a<b)a=b;}
template<class IT>inline void cmin(IT &a,IT b){if(b<a)a=b;}
const int N=200005;

int main(){
	int h,n,a;
	scanf("%d%d",&h,&n);
	while(n--){scanf("%d",&a);h-=a;}
	if(h<=0)puts("Yes");else puts("No");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(int argc, char* argv[])
{
	int W,H,N;
	cin>>W>>H>>N;
	int i;
	int x,y,a;
	int minX=0,minY=0;
	int maxX=W,maxY=H;
	for (i=0;i<N;i++){
		cin>>x>>y>>a;
		switch(a){
			case 1:
				if (x>minX){
					minX=x;
				}
				break;
			case 2:
				if (x<maxX){
					maxX=x;
				}
				break;
			case 3:
				if (y>minY){
					minY=y;
				}
				break;
			case 4:
				if (y<maxY){
					maxY=y;
				}
				break;
		}
	}
	if (maxX<minX || maxY<minY){
		cout<<0<<endl;
		return 0;
	}
	cout<<(maxX-minX)*(maxY-minY)<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
class Main{
    static Scanner sc=new Scanner(System.in);
    public static void main(String[] args){
        int N = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();
        boolean ans =false;
        for(int i=A;i<=B;i++){
            if(i%N==0){
                ans=true;
                break;
            }
        }
        if(ans)
        System.out.println("OK");
        else
        System.out.println("NG");
    }
}

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

int n, m, dp[1005][1005], mod = 1e9+7;
vector<string> vs;

int main(){
    
    cin >> n >> m;
    for(int i = 0; i < n; i++){
        string s; cin >> s;
        vs.push_back(s);
    }

    dp[0][0] = 1;
    for(int i = 0; i < n; i++)
        for(int j = 0; j < m; j++){
            if(vs[i][j] == '#') continue;
            if(j-1 >= 0) dp[i][j] += dp[i][j-1];
            if(i-1 >= 0) dp[i][j] += dp[i-1][j];
            dp[i][j] %= mod;
        }
    cout << dp[n-1][m-1] << endl;    
	return 0;
}


Measured memory_bytes: 5248
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define rep(i, n) FOR(i, 0, n)
#define REP(i, n) FOR(i, 1, ll(n) + 1)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;

template <typename T> inline bool chmax(T &a, const T b) {
    if(a >= b) return false;
    a = b;
    return true;
}
template <typename T> inline bool chmin(T &a, const T b) {
    if(a <= b) return false;
    a = b;
    return true;
}

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

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

    int n, m;
    cin >> n >> m;

    vector<int> imos(m + 1), cnt(m + 1);

    ll num = 0, x = 1;
    int a, b;
    cin >> a;
    rep(i, n - 1) {
        cin >> b;
        num += min(b < a ? b + m - a : b - a, b);
        a = (a == m ? 1 : a + 1);
        cnt[b] += b - a;
        imos[a]++;
        imos[b]--;
        if(b < a) {
            imos[0]++;
            cnt[b] += m;
        }
        a = b;
    }
    rep(i, m) imos[i + 1] += imos[i];

    ll ans = num;
    while(x < m) {
        num += cnt[x] - imos[x++];
        chmin(ans, num);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
import sys


def input():
    return sys.stdin.readline().rstrip()


def main():
    N = list(map(int,input()))
    count = 0

    S = len(N)
    flag = 0
    for i in range(S):
        temp = flag + N[-1 - i]
        if temp > 5:
            count += 10 - temp
            flag = 1
        elif temp ==5  and i !=S-1 and N[-1-i-1]>=5:
            count+=temp
            flag=1

        else:
            count += temp
            flag = 0

    print(count + flag)


if __name__ == "__main__":
    main()


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

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

    vector<long long> A(N + 1);
    for (long long &a : A)
    {
        cin >> a;
    }

    vector<long long> B(N);
    for (long long &b : B)
    {
        cin >> b;
    }

    long long ans = 0;
    long long kill;
    for (long long i = 0; i < N; i++)
    {
        kill = min(A[i], B[i]);
        A[i] -= kill;
        B[i] -= kill;
        ans += kill;

        kill = min(A[i + 1], B[i]);
        A[i + 1] -= kill;
        B[i] -= kill;
        ans += kill;
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define ll long long
#define INF (1 << 30)
#define INFLL (1LL << 60)

#define FOR(i,a,b) for(ll i = (a);i<(b);i++)
#define REP(i,a) FOR(i,0,(a))
#define MP make_pair

bool ans[1010] = {};
vector<pair<int, pair<int, int> > > edge[1010];
int n, m;

void dijkstra(int start){
	priority_queue<pair<int, pair<int, int> > > que;
	que.push(MP(0, MP(start, -1)));
	int minUsed[101];
	REP(i, 101){
		minUsed[i] = -1;
	}

	while(que.size()){
		int nowC = -que.top().first;
		int now = que.top().second.first;
		int nowEdgeNum = que.top().second.second;
		que.pop();

		if(minUsed[now] != -1){
			if(minUsed[now] != nowC) continue;
		}
		minUsed[now] = nowC;

		if(nowEdgeNum != -1) ans[nowEdgeNum] = true;

		for(int i = 0;i < edge[now].size();i++){
			int to = edge[now][i].first;
			int toC = nowC + edge[now][i].second.first;
			int toEdgeNum = edge[now][i].second.second;

			que.push(MP(-toC, MP(to, toEdgeNum)));
		}
	}
}

int main() {
	cin >> n >> m;
	int a,b,c;
	REP(i, m){
		cin >> a >> b >> c;
		a--;b--;
		edge[a].push_back(MP(b, MP(c, i)));
		edge[b].push_back(MP(a, MP(c, i)));
	}

	REP(i, n){
		dijkstra(i);
	}

	int how = 0;
	REP(i, m){
		if(ans[i] == false) how++;
	}

	cout << how << endl;
	return 0;
}

Measured memory_bytes: 512
from sys import stdin


def main():
    a = next_int()
    b = next_int()
    x = next_int()

    ans = b // x
    ans -= (a - 1) // x

    print(ans)

def next_int() -> int:
    return int(next_str())


def next_str() -> str:
    result = ""
    while True:
        tmp = stdin.read(1)
        if tmp.strip() != "":
            result += tmp
        elif tmp != '\r':
            break
    return result


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
//increase stack size
#pragma comment(linker, "/STACK:16777216")

ll mxm() {return LLONG_MIN;}
template<typename... Args>
ll mxm(ll a, Args... args) { return max(a,mxm(args...)); }

ll mnm() {return LLONG_MAX;}
template<typename... Args>
ll mnm(ll a, Args... args) { return min(a,mnm(args...)); }

template<class T> ostream& operator<<(ostream& os,vector<T> V){
	os<<"[ ";for(auto v:V)os<<v<<" ";return os<<"]";
}
template<class L,class R> ostream& operator<<(ostream& os,pair<L,R> P){
	return os<<"("<<P.first<<","<<P.second<<")";
}

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__,__VA_ARGS__)
template<typename Arg1>
void __f(const char* name,Arg1&& arg1){
	cout<<name<<" : "<<arg1<<endl;
}
template <typename Arg1,typename... Args>
void __f(const char* names,Arg1&& arg1,Args&&... args){
	const char* comma=strchr(names+1,',');cout.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1,args...);
}
#else
#define trace(...) 1
#endif

#define ld long double
#define pll pair<ll,ll>
#define ii pair<int,int>
#define vll vector<ll>
#define vii vector<ii>
#define vi vector<int>
#define vpll vector<pll>
#define vld vector<ld>
#define vvld vector<vld>
#define vvi vector<vi>
#define vvll vector<vll>
#define vvpll vector<vpll>
#define vvii vector<vii>
#define I insert
#define F first
#define S second
#define pb push_back
#define endl "\n"
#define all(x)	x.begin(),x.end()

const int mod=1e9+7;
// 128 bit: __int128
inline int add(int a,int b){a+=b;if(a>=mod)a-=mod;return a;}
inline int sub(int a,int b){a-=b;if(a<0)a+=mod;return a;}
inline int mul(int a,int b){return (a*1ll*b)%mod;}
inline int power(int a,int b){int rt=1;while(b>0){if(b&1)rt=mul(rt,a);a=mul(a,a);b>>=1;}return rt;}
inline int inv(int a){return power(a,mod-2);}

struct compare{
	bool operator() (const int &a,const int &b) const{
		return a>b;
	}
};

int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cout<<setprecision(25);
	int n;
	cin >> n;
	set<string> st;
	for(int i = 0; i < n; i++){
		string s;
		cin >> s;
		st.I(s);
	}
	cout << st.size() << endl;
}

Measured memory_bytes: 19276
#include <iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
int main(){
	int N,A,res=1;
	cin>>N;
	int used[N]={};
	rep(i,N){
		cin>>A;
		used[A]++;
		if(used[A]>2 || A>=N || used[0]>1)res=0;
	}
	rep(i,N/2)res=(res*2)%1000000007;
	cout<<res<<endl;
}


Measured memory_bytes: 640
while True:
    [n,x]=map(int,input().split())
    if n==0 and x==0:
        break
    n+=1
    count=0
    for i in range(1,n):
        for j in range(i+1,n):
                for k in range(j+1,n):
                    if i+j+k==x:
                        count+=1
    print(count)


Measured memory_bytes: 5596
#include <iostream>

using namespace std;
bool flag;
int p,q,j;
int r[10000];
int x[10000];
int main(){
	while(cin >> p){
		cin >> q;
		int i=1;
		flag=false;
		x[0]=0;
		r[0]=p;
		while(1){
			p*=10;
			x[i]=p/q;
			r[i]=p%q;
			p=r[i];
			for(j=0;j<i;j++){
				if(r[i]==r[j]||r[i]==0){
					if(r[i]==0)flag=true;
					goto FIN;
				}
			}
			i++;
		}
		FIN:
		for(int k=1;k<i+1;k++){
			cout << x[k];
		}
		cout << endl;
		while(!flag){
			for(int k=1;k<i+1;k++){
				if(k>j)cout << "^";
				if(k<=j)cout << " ";
			}
			cout << endl;
			flag=true;
		}
	}
	return 0;
}

Measured memory_bytes: 3056
#include <bits/stdc++.h>
using namespace std;
int main()
{
    
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    long t;
    cin >> t;
    string s;
    unordered_set<string> s1;
    while (t--)
    {
        cin >> s;
        s1.insert(s);
    }
    cout << s1.size();
    return 0;
}


Measured memory_bytes: 17692
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <array>
#include <vector>
#include <utility>
#include <bitset>
#include <queue>
#include <unordered_map>
#include <unordered_set>

using namespace std;

using ll = long long;
using p = pair<ll, ll>;

int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;

    cout << N / 3 << endl;
}



Measured memory_bytes: 256
x = int(input())
ans_i = 0
ans_j = 0
for i in range(-120, 120):
    j = -120
    while x > j ** 5:
        if i ** 5 - j ** 5 == x:
            ans_i = i
            ans_j = j
            j = x + 1
            break
        else:
            j += 1
print(ans_i, ans_j)

Measured memory_bytes: 65776
n, m = map(int, input().split())
cs = [[float('inf')] * n for _ in range(n)]
ns = [[0] * n for _ in range(n)]
for i in range(n):
    cs[i][i] = 0
for _ in range(m):
    a, b, c = map(int, input().split())
    cs[a - 1][b - 1] = cs[b - 1][a - 1] = c
    ns[a - 1][b - 1] = b - 1
    ns[b - 1][a - 1] = a - 1
for k in range(n):
    for i in range(n):
        for j in range(n):
            s = cs[i][k] + cs[k][j]
            if s < cs[i][j]:
                cs[i][j] = s
                ns[i][j] = ns[i][k]
used = set()
for i in range(n):
    for j in range(i + 1, n):
        path = [i]
        while path[-1] != j:
            s = path[-1]
            t = ns[s][j]
            path.append(t)
            used.add(tuple(sorted([s, t])))
print(m - len(used))

Measured memory_bytes: 3444
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
//typedef tuple<ll, ll, ll> T;

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 dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c;
    cin>>a>>b>>c;
    string ans="No";
    if(a<=c&&c<=b) ans="Yes";
    if(b<=c&&c<=a) ans="Yes";
    cout<<ans<<endl;
}

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s, t;
	cin >> s >> t;
	int ans = 0;
	for (int i = 0; i < 3; i++) if (s[i] == t[i]) ans++;
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
int main() {
	long long num1, num2; std::cin >> num1 >> num2;
	long long a = num1, b = num2;
	std::map<long long, long long>mp;

	for (long long x = 2; x * x < num1; x++) {
		while (a % x == 0) {
			a /= x; mp[x] = 1;
		}
	}if (a != 1)mp[a] = 1;
	long long cnt = 0;
	for (long long x = 2; x * x < num2; x++) {
		while (b % x == 0) {
			b /= x; if (mp[x] == 1) { mp[x] = 2; cnt++; }
		}
	}if (b != 1)if (mp[b] == 1)cnt++;
	std::cout << cnt + 1;
}

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

using namespace std;
using ll =long long;

#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }
void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}

const ll INF = 1LL << 60;

pair<int,int> jouge(int n){
	int a = n % 10 ;
	int b = n % 10 ;
	while (n > 0 ){
		b = n % 10 ;
		n /= 10;
	}
	return make_pair(b,a); 
}
//Write From this Line

const int mod = 1e9+7;
int main(){
	int n ; 
	cin >> n ; 
	map<pair<int,int>, int > p;
	for(int i = 1 ; i <= n ; i ++ ){ 
		pair<int,int> P = jouge(i);
		//cout << "joui: " << P.first <<" kai: " << P.second << endl;
		p[P] ++ ; 
	}
	ll ans = 0 ;
	for(int i =1 ; i <= n ; i ++){
		if( i % 10 == 0 ) continue;
		pair<int,int> P = jouge(i);
		int a = P.second ;
		int b = P.first ; 
		P.second = b;
		P.first = a ;
		ans += p[P] ; 
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
int A[2000];
int main() {
	ll N, K;
	cin >> N >> K;
	for (int i = 0; i < N; i++) cin >> A[i];
	ll ans = 0;
	for (int i = 0; i < N; i++) {
		ll inv = 0, tot = 0;
		for (int j = i + 1; j < N; j++) {
			if (A[i] > A[j]) inv++;
		}
		for (int j = 0; j < N; j++) {
			if (A[i] > A[j]) tot++;
		}
		ll add = (inv*K) % MOD;
		ll tmp = (K*(K - 1) / 2) % MOD;
		(add += tot * tmp) %= MOD;
		(ans += add) %= MOD;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
       int n = sc.nextInt();
       int k = sc.nextInt();
       ArrayList<Integer> arrayList = new ArrayList<Integer>();
       for(int i=0;i<n;i++){
           arrayList.add(sc.nextInt());
       }
       int sum = 0;
       for(int i=0;i<k;i++){
           int idx = 0;
           int min = 999999;
           for(int j=0;j<arrayList.size();j++){
               if(arrayList.get(j)<min){
                   idx = j;
                   min = arrayList.get(j);
               }
           }
           sum += arrayList.get(idx);
           arrayList.remove(idx);
       }

        System.out.println(sum);
    }

}


Measured memory_bytes: 38920
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
string S;
 
int main(void){
	
	cin >> S;
	
	if(S[0] != 'A'){ cout << "WA" << endl; return 0; }
	
	int count = 0;
	for(int i = 0; i < S.size(); ++i) if(isupper(S[i])) ++count;
	if(count != 2){ cout << "WA" << endl; return 0; }
	
	for(int i = 2; i <= S.size() - 2; ++i) if(S[i] == 'C'){ cout << "AC" << endl; return 0; }
	cout << "WA" << endl;
    
	return 0;
}

Measured memory_bytes: 256
S = input()
N = len(S)
a_sum = [0] * N
count=0
left_start=0
for i in range(N - 1):
    if S[i]=="R":
        count+=1
        if S[i+1]=="L":
            a_sum[i] = count
            count=0
            left_start = i+1
    else:
        count+=1
        if S[i+1]=="R":
            a_sum[left_start] = count
            count=0
a_sum[left_start] = count+1

end=False
for i in range(N - 1):
    if a_sum[i] == 0 or end:
        end = False
        continue
    
    left = a_sum[i] - a_sum[i]//2 + a_sum[i+1]//2
    right = a_sum[i]//2 + a_sum[i+1] - a_sum[i+1]//2
    a_sum[i] = left
    a_sum[i+1] = right
    end = True

for a in a_sum:
    print(a ,end=" ")
print()

Measured memory_bytes: 51544
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <bitset>

#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define INF 2000000000
#define rep(i,n) for(int i=0;i<(n);i++)
typedef pair<int, int> P;
const ll MOD=1000000007;
using Graph = vector<vector<int>>;

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 h[100005];
vector<int> dp(100005,INF);
int main() {
    int n, k;
    cin >> n >> k;
    rep(i, n) cin >> h[i];

    dp[0] = 0;
    for (int i = 1; i < n; i++) {
        for (int j = 1; j <= k; j++) {
            if (j > i) break;
            chmin(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
        }
    }
   
    cout << dp[n - 1] << endl;
    return 0;
}

Measured memory_bytes: 1024
import numpy as np

N, M = [int(i) for i in input().split()]

LR = np.ones([M,2])

for i in range(M):
    LR[i][0],LR[i][1] = [int(i) for i in input().split()]
    
max_L = max(LR[:,0])
min_R = min(LR[:,1])
if max_L <= min_R:
    ans = int(min_R - max_L+1)
else:
    ans =0
    
print(ans)


Measured memory_bytes: 14032
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
    int n,a,b;cin >> n >> a >> b;
    if(a%2 == b%2){
        cout << abs(a-b)/2 << endl;
    }
    else{
        int ret;
        //1
        {
            int dist = b-a;
            dist--;
            int tmp = dist/2 + a;
            ret = tmp;

        }
        //n
        {
            int dist = b-a;
            dist--;
            int tmp = dist/2 + n-b+1;
            ret = min(ret,tmp);
         
        }
        cout << ret << endl;

    }
    return 0;
}

Measured memory_bytes: 3604
s=input()
t=input()
a=str()
b=0
c=0
for i in range(len(s)):
    b+=1
    for j in range(len(s)):
        a+=s[j-b]
    if a==t:
        c+=1
    a=str()
if c==0:
    print("No")
else:
    print("Yes")

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

const int MAXN = 18;
const int MAXM = 1 << MAXN;
int N;
int M;

int A[MAXM];

int ans[MAXM];

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> N;
	M = 1 << N;
	for (int i = 0; i < M; i++) {
		cin >> A[i];
	}

	for (int m = 0; m < M; m++) {
		int v[2] = {};
		for (int s = m; true; s = (s-1) & m) {
			int a = A[s];
			for (int i = 0; i < 2; i++) {
				if (a > v[i]) {
					swap(a, v[i]);
				}
			}
			if (s == 0) break;
		}
		ans[m] = v[0] + v[1];
	}

	for (int m = 1; m < M; m++) {
		ans[m] = max(ans[m], ans[m-1]);
	}

	for (int m = 1; m < M; m++) {
		cout << ans[m] << '\n';
	}

	return 0;
}


Measured memory_bytes: 5120
#include <stdio.h>

int main() {
    int A, B, K;
    int i, c;
    scanf("%d%d%d", &A, &B, &K);
    for (i=(A < B ? A : B) ; i > 0 ;i--) {
        if (A % i == 0 && B % i == 0) {
            c++;
        }
        if (c == K) {
            printf("%d\n", i);
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);
        
        long a = sc.nextLong();
        long b = sc.nextLong();
        long x = sc.nextLong();
        long ans;
        
        if(a != 0){
            ans = b / x - (a-1) / x;
        }else{
            ans = b / x + 1;
        }
        
        System.out.println(ans);
    }
}


Measured memory_bytes: 23252
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define INIT    \
    cin.tie(0); \
    ios::sync_with_stdio(false);

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

ll const INF = 1LL << 60;
ll const MOD = 1000000007;

int main() {
    INIT;

    ll N;
    cin >> N;
    vector<ll> A(N + 2, 0);
    reps(i, 1, N + 1) cin >> A[i];

    vector<ll> diff(N + 2, 0);

    rep(i, N + 1) { diff[i] = abs(A[i + 1] - A[i]); }

    // repv(A) cout << *it << " ";
    // cout << endl;

    // repv(diff) cout << *it << " ";
    // cout << endl;

    ll sum = 0;
    repv(diff) sum += *it;

    // cout << sum << endl;

    reps(i, 1, N + 1) {
        if ((A[i - 1] <= A[i] && A[i] <= A[i + 1]) ||
            (A[i - 1] > A[i] && A[i] > A[i + 1])) {
            cout << sum << endl;
        } else if (A[i - 1] <= A[i] && A[i] > A[i + 1]) {
            cout << sum - 2 * min(diff[i - 1], diff[i]) << endl;
        } else if (A[i - 1] > A[i] && A[i] <= A[i + 1]) {
            cout << sum - 2 * min(diff[i - 1], diff[i]) << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 4736
#include<stdio.h>
int main()
{
int n,k,i;

scanf("%d %d",&n,&k);
 long long int score[n];
for(i=0;i<n;++i)
{
scanf("%lld",&score[i]);
}
  for(i=0;i<n-k;++i)
  {  
if(score[i]<score[i+k]) printf("Yes\n"); 
else printf("No\n");}
  
return 0;}

Measured memory_bytes: 3220
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <map>

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

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

using namespace std;

const ll BIG = 1000000007LL;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

template<typename T>
void inputArray(T* p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

template<typename T>
void inputVector(vector<T> * p, int a){
    rep(i, a){
        T input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision = 0) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

const int Max = 110000;
const int MAX_EQ = 110000;
int N;
double D[Max], L[Max], R[Max], X[Max], A[Max];;

void solve_tridiagonal(int n, double d[], double l[], double r[], double b[], double x[]){
	static double d2[MAX_EQ], l2[MAX_EQ], r2[MAX_EQ], b2[MAX_EQ], a[MAX_EQ];
	//右上と左下が0の場合
	if(l[0] == 0.0 && r[n-1] == 0.0){
		for(int i=1; i<n; ++i){
			d[i] -= r[i-1] * (l[i] / d[i-1]);
			b[i] -= b[i-1] * (l[i] / d[i-1]);
		}
		for(int i=n-2; i>=0; --i){
			b[i] -= b[i+1] * (r[i] / d[i+1]);
		}
		for(int i=0; i<n; ++i){
			x[i] = b[i] / d[i];
		}
		return ;
	}

	for(int i=0; i<n-1; ++i){
		d2[i] = d[i];
		l2[i] = (i ? r[i-1] : 0.0);
		r2[i] = (i < n-2 ? l[i+1] : 0.0);
	}

	fill(b2, b2+n-1, 0.0);
	b2[0] = r[n-1];
	b2[n-2] = l[n-1];
	solve_tridiagonal(n-1, d2, l2, r2, b2, a);

	for(int i=0; i<n-1; ++i){
		b[n-1] -= a[i] * b[i];
	}
	d[n-1] -= a[n-2] * r[n-2] + a[0] * l[0];
	b[0] -= b[n-1] * l[0] / d[n-1];
	b[n-2] -= b[n-1] * r[n-2] / d[n-1];
	l[0] = r[n-2] = 0.0;
	solve_tridiagonal(n-1, d, l, r, b, x);
	x[n-1] = b[n-1] / d[n-1];
}

int main(int argc, const char * argv[]) {
    cin >> N;
    inputArray(A, N);
    rep(i, N) {
        D[i] = 1;
        L[i] = 0;
        R[i] = 1;
    }
    solve_tridiagonal(N, D, L, R, A, X);

    rep(i, N) {
        output((int)round(X[i]*2));
    }

    return 0;
}

Measured memory_bytes: 9728
#include<bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define mod 1000000007
#define inf 1000000000000000007
#define eps 0.00000001
#define pi 3.141592653589793
#define pii pair<int,int>
#define pdd pair<ld,ld>
#define pll pair<ll,ll>
#define ff first
#define ss second
#define vii vector<int>
#define vpl vector<pll>
#define vll vector<ll>
#define sti stack <int>
#define stll stack <ll>
#define mseti multiset <ll>
#define msetd multiset <ll, greater <ll> >
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound 
#define stp setprecision(20)//use fixed before stp
#define endl '\n'
int main()
{  
    FAST
    ll n,m;
    cin>>n>>m;
    ll s[n],t[m];
    ll dp[n]={0};
    for(ll i=0;i<n;i++)
    {
        cin>>s[i];
    }
    for(ll i=0;i<m;i++)
    {
        cin>>t[i];
    }
    ll ans=1,x,y;
    for(ll i=0;i<m;i++)
    {
        x=1,y=1;
        for(ll j=0;j<n;j++)
        {
            y+=dp[j];
            y%=mod;
            if(s[j]==t[i])
            {
                dp[j]+=x;
                dp[j]%=mod;
            }
            x=y;
        }
    }
    for(ll i=0;i<n;i++)
    {
        ans+=dp[i];
        ans%=mod;
    }
    cout<<ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <iomanip>


#define PI 3.14159265


double standard_deviation(double *s, double m, double n) {
  double sum_ = 0;
  for (int i = 0; i < n; i ++) {
    sum_ += pow((s[i] - m), 2);
  }
  return sum_ / n;
}

int main() {
  double n;
  double s[1000] = {0};
  double m = 0;

  while (true) {
    m = 0;
    std::cin >> n;
    if (n == 0) break;
    for (int i = 0; i < n; i ++) {
      std::cin >> s[i];
      m += s[i];
    }
    m /= n;

    std::cout << std::fixed << std::setprecision(8)
      << sqrt(standard_deviation(s, m, n)) << std::endl;
  }

  return 0;
}



Measured memory_bytes: 3236
import numpy as np
H, W = map(int, input().split())
grid = []
for _ in range(H):
    a = [i for i in input()]
    if "#" in a:
        grid.append(a)
grid = np.array(grid)
grid_T = grid.T
ans = []
for i in range(W):
    if "#" in grid_T[i]:
        ans.append(grid_T[i])
ans = np.array(ans).T
for i in range(ans.shape[0]):
    print("".join(ans[i]))

Measured memory_bytes: 12516
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define uniq(x) (x).erase(unique(ALL(x)),(x).end())
#define SORT(x) sort(ALL(x))
#define REV(x) reverse(ALL(x))
#define foreach(it,x) for(__typeof((x).begin()) it=(x).begin();it!=(x).end();it++)
#define debug(x) cerr<<#x<<"="<<(x)<<endl
#define gett() cerr<<"Time:"<<clock()<<"ms."<<endl
#define ri(x) scanf("%d",&x)
#define rl(x) scanf("%lld",&x)
#define rlcfpoj(x) scanf("%I64d",&x)
#define pi(x) printf("%d",x)
#define pl(x) printf("%lld",x)
#define plcfpoj(x) printf("%I64d",x)
#define lfd() printf("\n")
#define sp() printf(" ")
#define inrep(x) int x;scanf("%d",&x);while(x--)
int n;
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
	int res=0;
	for(int i=1;i<=n;i++){
		int cnt=0;
		int t=i;
		while(t){
			t/=10;
			cnt++;
		}
		res+=cnt%2;
	}
	cout<<res<<endl;
	return 0;
}


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

int main() {
  uint32_t A = 0, B = 0, C = 0;
  std::cin >> A >> B >> C;

  uint32_t flag = A % 2 + B % 2 + C % 2;
  uint32_t op = 0;
  if (flag == 1) {
    if (A % 2 == 0) A++;
    if (B % 2 == 0) B++;
    if (C % 2 == 0) C++;
    op++;
  } else if (flag == 2) {
    if (A % 2 == 1) A++;
    if (B % 2 == 1) B++;
    if (C % 2 == 1) C++;
    op++;
  }

  uint32_t max = std::max({A, B, C});
  op += (max - A) / 2 + (max - B) / 2 + (max - C) / 2;
  std::cout << op << std::endl;

  return 0;
}

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

const int K = 18, N = 1<<K, M = 1e9+7;
int prod[N][K];
int a[N];

vector<pair<int, int>> vp[N];

void add(int x, int z, int mul) {
    assert(vp[x].empty() || vp[x].back().first <= z);
    if (vp[x].empty() || vp[x].back().first < z)      vp[x].push_back({z, mul});
    else {
        vp[x].back().second += mul;
        if (vp[x].back().second >= M) vp[x].back().second -= M;
    }
}

int rgt[N];

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

    int k;
    cin>>k;

    int L = 1<<(k-1);

    for (int i=L; i<2*L; i++) {
        prod[i][0] = i;
        for (int j=1; j<k; j++) {
            prod[i][j] = (1LL*prod[i][j-1]*(i>>j))%M;
        }
    }

    for (int i=0; i<N; i++)   vp[i].reserve(K);

    for (int i=L; i<2*L; i++) {
        int x;
        cin>>x;
        a[i] = x+L-1;
    }

     for (int k1=k-1; k1>=0; k1--) {
        for (int k2=k-1; k2>=0; k2--) {
            for (int i=L; i<2*L; i++) {
                int x = a[i];
                int pr = (1LL*prod[i][k1]*prod[x][k2])%M;

                int a1 = (i>>k1), a2 = (x>>k2);
                add(a2, a1, pr);
            }
        }
    }

    long long ans = 0;
    for (int i=1; i<=L; i++) {
        int ll = 2*i, rr = 2*i+1;

        for (auto pr: vp[rr])       rgt[pr.first] = pr.second;

        for (auto pr: vp[ll]) {
            int x = pr.first;
            if (x == 1) continue;
            unsigned long long con = (1LL*pr.second*rgt[x^1])%M;
            con = (con*i*(x>>1))%M;
            ans += con;
        }

        for (auto pr: vp[rr])       rgt[pr.first] = 0;
    }
    cout<<ans%M<<endl;
}


Measured memory_bytes: 253200
import java.util.*;

class Main{

    public static void main(String[] args){

	Scanner sc = new Scanner(System.in);

	int a = sc.nextInt();

	String s = sc.next();

	if(a>=3200){

	System.out.println(s);

  }	

	else{

	System.out.println("red");

  }

 }
}

Measured memory_bytes: 21972
#include<cstdio>
#include<algorithm>
using namespace std;

int main(){
    int A,B,C,Ans=0;
    scanf("%d%d%d",&A,&B,&C);
    int Max1=max(A,max(B,C));
    int Max2;
    if(A==Max1) Max2=max(B,C);
    else if(B==Max1) Max2=max(A,C);
    else if(C==Max1) Max2=max(A,B);
    int Max3=A+B+C-Max1-Max2;
    int tmp1=Max1-Max2;
    Ans+=tmp1,Max3+=tmp1,Max2+=tmp1;

    if((Max1-Max3)%2) Ans+=(Max1-Max3)/2+2;
    else Ans+=(Max1-Max3)/2;
    printf("%d",Ans);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  string t;
  int n;cin>>n;
	map<string, int>s;
  s["AC"]=0;s["WA"]=0;s["TLE"]=0;s["RE"]=0;
  for(int i=0;i<n;i++){cin>>t;s[t]+=1;}
  cout<<"AC x "<<s["AC"]<<'\n';
  cout<<"WA x "<<s["WA"]<<'\n';
  cout<<"TLE x "<<s["TLE"]<<'\n';
  cout<<"RE x "<<s["RE"]<<'\n';
                        
}

Measured memory_bytes: 3632
/*

                              Jai Shree Krishna !!
                                 Radhe Radhe !!
                                 
             उद्यमेन हि सिद्ध्यन्ति कार्याणि न मनोरथैः। नहि सुप्तस्य सिंहस्य मुखे प्रविशन्ति मृगाः।।
             
*/
   
   
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
typedef long long ll;
#define loop(i,n)  for(int i=0;i<n;i++)
#define read(a) int a; cin >>a;
#define readarr(a,n) int a[n] ; for(int i=0;i<n;i++) cin >> a[i];
#define readmat(a,n,m) int a[n][m]; for(int i=0;i<n;i++) for(int j=0;j<m;j++) cin >> a[i][j];
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define pi pair<int,int>
#define vvi vector<vector<int>>
#define sti set<int>
#define vpi vector<pair<int,int>>
#define print(a,n) for(int i=0;i<n;i++) cout<<a[i]<<" "; cout<<endl;
#define printmat(a,n,m) for(int i=0;i<n;i++) {for(int j=0;j<m;j++) cout<<a[i][j]<<" "; cout<<endl;}
#define fast ios_base::sync_with_stdio(false);  cin.tie(NULL);
#define endl "\n"
#define mp make_pair
#define ins insert
#define rep(i,s,e)  for(int i=s;i<=e;i++)
#define repd(i,s,e)  for(int i=e;i>=s;i--)
#define vb vector<bool>
#define read2(n,m) int n,m; cin >> n >> m;
#define range(v) v.begin(),v.end()
#define sortd(v) sort(v.begin(),v.end(),greater<int>())
#define sorti(v) sort(v.begin(),v.end())

const ll inf = 1e18;
const ll mod = 1e9 + 7;
 
signed main()
{
 
    fast;
    read(n);
    string s = to_string(n);
    char ch = s[s.length()-1];
    if(ch=='2'||ch=='4'||ch=='5'|ch=='7'||ch=='9') cout<<"hon"<<endl;
    else
    if(ch=='0'||ch=='1'||ch=='6'||ch=='8') cout<<"pon"<<endl;
    else
    cout<<"bon"<<endl;
    return 0;
}

/* Pooja Yadav */

Measured memory_bytes: 3700