akhauriyash/Code-Regression huggingface dataset:
import sys
readline = sys.stdin.readline


def treedoubling(P):
    #根の親は-1
    P = P[:]
    N = len(P)
    D = [P[:]]
    dep = N.bit_length()
    for _ in range(dep):
        ret = [-1]*N
        for i in range(N):
            k = D[-1][i]
            if k != -1:
                ret[i] = D[-1][k]
        D.append(ret)
    return D

def lca(u, v, D, par, dist):
    if dist[u] > dist[v]:
        u, v = v, u
    
    ddif = dist[v] - dist[u]
    for i in range(ddif.bit_length()):
        if (1<<i)&ddif:
            v = D[i][v]
    
    if u != v:
        for cnt in range(dist[u].bit_length()-1, -1, -1):
            if D[cnt][u] != D[cnt][v]:
                u = D[cnt][u]
                v = D[cnt][v]
        u = par[u]
    return u

def parorder(Edge, p):
    N = len(Edge)
    par = [0]*N
    par[p] = -1
    stack = [p]
    order = []
    visited = set([p])
    ast = stack.append
    apo = order.append
    while stack:
        vn = stack.pop()
        apo(vn)
        for vf in Edge[vn]:
            if vf in visited:
                continue
            visited.add(vf)
            par[vf] = vn
            ast(vf)
    return par, order

def rerootingdp(P, L, intv = None):
    def merge(x, y):
        if x == intv:
            return y
        if y == intv:
            return x
        sa, da = x
        sb, db = y
        return (sa + sb, da*db%MOD)

    def g(m, vn):
        if m == intv:
            return (1, 1)
        sc, dc = m
        return (sc+1, dc*frac[sc]*fraci[sc+1]%MOD)
    
    N = len(L)
    dp = [None]*N
    LR = [intv]*N
    D = [intv]*N
    cld = [[] for _ in range(N)]
    for l in L[::-1]:        
        resl = intv
        for ci in cld[l]:
            LR[ci] = merge(LR[ci], resl)
            resl = merge(resl, dp[ci])
        resr = intv
        for ci in cld[l][::-1]:
            LR[ci] = merge(LR[ci], resr)
            resr = merge(resr, dp[ci])
        D[l] = resr
        dp[l] = g(resr, l)
        
        if P[l] != -1:
            cld[P[l]].append(l)
        
    U = [None]*N
    ans = [None]*N
    U[L[0]] = intv
    ans[L[0]] = dp[L[0]]
    for l in L[1:]:
        p = P[l]
        U[l] = g(merge(U[p], LR[l]), p)
        ans[l] = g(merge(D[l], U[l]), l)    
    return ans 

def getcld(p):
    res = [[] for _ in range(len(p))]
    for i, v in enumerate(p):
        if v == -1:
            continue
        res[v].append(i)
    return res


MOD = 10**9+7
def frac(limit):
    frac = [1]*limit
    for i in range(2,limit):
        frac[i] = i * frac[i-1]%MOD
    fraci = [None]*limit
    fraci[-1] = pow(frac[-1], MOD -2, MOD)
    for i in range(-2, -limit-1, -1):
        fraci[i] = fraci[i+1] * (limit + i + 1) % MOD
    return frac, fraci
frac, fraci = frac(1341398)

N = int(readline())
Edge = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = map(int, readline().split())
    a -= 1
    b -= 1
    Edge[a].append(b)
    Edge[b].append(a)



P, L = parorder(Edge, 0)

Ans = [frac[a]*d%MOD for a, d in rerootingdp(P, L)]
print('\n'.join(map(str, Ans)))


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

int main() {
	int H, W; cin >> H >> W;
	vector<string> fig(H);
	
	for( string &k: fig )cin >> k;
	
	for( int i = 0; i < H; i++ ){
	for( int j = 0; j < W; j++ ){
		int num = 0;
		
		if(fig[i][j] == '#'){ cout << "#"; continue; }
		
		if( i != 0 && j != 0 )if(fig[i-1][j-1] == '#') num++;
		if( i != 0 )if(fig[i-1][j] == '#') num++;
		if( i != 0 && j != W-1)if(fig[i-1][j+1] == '#') num++;
		if( j != 0 )if(fig[i][j-1] == '#') num++;
		if( j != W-1 )if(fig[i][j+1] == '#') num++;
		if( i != H-1 && j != 0 )if(fig[i+1][j-1] == '#') num++;
		if( i != H-1 )if(fig[i+1][j] == '#') num++;
		if( i != H-1 && j != W-1 )if(fig[i+1][j+1] == '#') num++;
		
		cout << num;
	}
	cout << endl;
	}
}

Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define D()
#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define INITA(a,i,j,v) for(ll k=i;k<=j;k++){a[k]=v;}
int main() {
    ll n; cin >> n;
    ll tot = 0;
    set<ll> st;
    FOR(i, 1, 10000000) {
        tot += i;
        st.insert(i);
        if (tot >= n) {
            ll diff = tot - n;
            FOR(j, 1, i) {
                if (j != diff) {
                    cout << j << endl;
                }
            }
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3844
#include <iostream>
#include<algorithm>
using namespace std;
int h[100005][3] = { 0 };


int main()
{
	int n = 0;
	for (int i = 1; i <= 100004;i++) {
		if (i % 2 == 0) {
			h[i][1] = 1;
			h[i][2] = 0;
		}
		else {
			h[i][1] = 0;
			h[i][2] = 1;
		}
	}
	char a;

	while (cin >> a) {	
		n++;
		if (a == '0' && h[n][1] == 1)h[0][1]++;
		else if (a == '0')h[0][2]++;
		if (a == '1' && h[n][2] == 0)h[0][2]++;
		else if(a == '1')h[0][1]++;
			
	}
	cout << min(h[0][1], h[0][2]) << endl;

}

Measured memory_bytes: 1408
n,m,l = map(int,input().split())
a = [list(map(int,input().split())) for i in range(n)]
b = [list(map(int,input().split())) for i in range(m)]
c = [[0]*l for i in range(n)]
for i in range(n):
         for j in range(l):
                  for k in range(m):
                           c[i][j] += (a[i][k]*b[k][j])
for i in range(n):
         print(*c[i])



Measured memory_bytes: 7044
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const double eps = 1e-8;
const int NINF = 0xc0c0c0c0;
const int INF  = 0x3f3f3f3f;
const ll  mod  = 1e9 + 7;
const ll  maxn = 1e6 + 5;
const int N = 2e5 + 5;

int n,a[N];
map<ll,ll>M;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;cin>>n;
	ll res=0;
	for(int i=1;i<=n;i++){
		int x;cin>>x;
		if(M.count(x-i)) res+=M[x-i];
		M[-x-i]++;
	}
	cout<<res<<'\n';
	return 0;
}

Measured memory_bytes: 16088
#include<bits/stdc++.h>
#define mp make_pair
#define fi first
#define se second
#define VAL 100000
#define ll  long long int
#define INF 10000000000000000LL
#define pll pair<long long , long long>
const int MAX=1e6+9;
const ll MOD=998244353;
const int TOT_PRIMES=19;
const int MAX_A=70;
using namespace std;
int arr[MAX];
int cnt[MAX];
int main() 
{
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);  
    cout.tie(0);
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
      cin>>arr[i];
      cnt[arr[i]]+=1;
    }
    int res=0;
    for(int i=1;i<MAX;i++){
      if(cnt[i]){
        if(cnt[i]==1)
          res++;
      //  cout<<i<<endl;
        for(int j=2*i;j<MAX;j+=i)
          cnt[j]=0;
      }
    }
    cout<<res;
}

Measured memory_bytes: 8292
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<bitset>
#include<cmath>
#include<cstdio>
using namespace std;
double dis(double xa,double ya,double xb,double yb){
    return sqrt((xa-xb)*(xa-xb)+(ya-yb)*(ya-yb));
}
double S(double a,double b,double c){
    double s=(a+b+c)/2;
    return sqrt(s*(s-a)*(s-b)*(s-c));
}
bool in(double xa,double ya,double xb,
        double yb,double xc,double yc,double xp,double yp){
    double AB,BC,CA,AP,BP,CP;
    AB=dis(xa,ya,xb,yb);
    BC=dis(xb,yb,xc,yc);
    CA=dis(xc,yc,xa,ya);
    AP=dis(xa,ya,xp,yp);
    BP=dis(xb,yb,xp,yp);
    CP=dis(xc,yc,xp,yp);
    double ABC,ABP,BCP,CAP;
    ABC=S(AB,BC,CA);ABP=S(AB,AP,BP);
    BCP=S(BC,BP,CP);CAP=S(CA,CP,AP);

    double dif=ABC-ABP-BCP-CAP;
    if(dif<=0.0001&&dif>=-0.0001)return true;
    else return false;
}
int main(){
    double x[4],y[4];
    while(scanf("%lf,%lf",&x[0],&y[0])!=EOF){
        for(int i=1;i<4;i++)scanf(",%lf,%lf",&x[i],&y[i]);
        bool F=false;
        for(int i=0;i<4;i++){
            int a=(i+1)%4,b=(i+2)%4,c=(i+3)%4;
            F|=in(x[i],y[i],x[a],y[a],x[b],y[b],x[c],y[c]);
        }

        if(!F)cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
}

Measured memory_bytes: 1224
# include <stdio.h>

int main(){

  int n,i,ans=0,r=0,l=0;
  char s[3];

  for(;;){
  scanf("%d",&n);
  if(n==0){
    break;
  }

  for(i=1;i<=n;i++){

    scanf("%s",s);

    if(s[0]=='l'&&s[1]=='u'){
      l=1;
    }

    if(s[0]=='l'&&s[1]=='d'){
      l=0;
    }

    if(s[0]=='r'&&s[1]=='u'){
      r=1;
    }

    if(s[0]=='r'&&s[1]=='d'){
      r=0;
    }

    if(ans%2==0&&r==1&&l==1){
      ans++;
    }

    if(ans%2!=0&&r==0&&l==0){
      ans++;
    }
  }

  printf("%d\n",ans);
  ans=0;
  r=0;
  l=0;

  }
  return 0;
}

Measured memory_bytes: 1032
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

ll ppow(ll a,ll b){
	ll res=1;
	while(b){
		if(b&1)res=(res*a)%MOD;
		a=(a*a)%MOD;
		b>>=1;
	}
	return res;
}
ll a[200000],c[200000];
ll d[200000],e[200000];

signed main(){
	string s;cin>>s;
	rep(i,s.size()){
		if(i)a[i]+=a[i-1];
		if(s[i]=='A')a[i]++;
	}
	for(int i=s.size()-1;i>=0;i--){
		if(i<s.size()-1)c[i]+=c[i+1];
		if(s[i]=='C')c[i]++;
	}
	rep(i,s.size()){
		if(i)d[i]+=d[i-1];
		if(s[i]=='?')d[i]++;
	}
	for(int i=s.size()-1;i>=0;i--){
		if(i<s.size()-1)e[i]+=e[i+1];
		if(s[i]=='?')e[i]++;
	}
	ll sum=0;
	for(int i=1;i<s.size()-1;i++){
		if(!(s[i]=='B'||s[i]=='?'))continue;
		//A*C
		sum+=a[i-1]*c[i+1]%MOD*ppow(3,d[i-1]+e[i+1])%MOD;
		//A*?
		if(e[i+1])sum+=a[i-1]*e[i+1]%MOD*ppow(3,d[i-1]+e[i+1]-1)%MOD;
		//C*?
		if(d[i-1])sum+=d[i-1]*c[i+1]%MOD*ppow(3,d[i-1]+e[i+1]-1)%MOD;
		//?*?
		if(d[i-1]&&e[i+1])sum+=d[i-1]*e[i+1]%MOD*ppow(3,d[i-1]+e[i+1]-2)%MOD;
		sum%=MOD;
	}
	cout<<sum<<endl;
}

Measured memory_bytes: 5888
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define F first
#define S second
#define vi vector
#define FOR(i,n) for(int i=0;i<n;i++)
#define FORE(i,a,b) for(int i=a;i<=b;i++)
#define FORR(i,a,b) for(int i=a;i>=b;i--)
#define mod 998244353
#define pb push_back
#define ll long long int
#define db double
#define all(v) v.begin(),v.end()

using namespace std;

/*

ll expo(ll n){
    ll t;
    if(n==0)return 1;
    else if(n==1) return 2;
    t=expo(n/2);
    if(n%2){
        return t*t*2;
    }
    else return t*t;
}

//ffrom geek for geek
ll exponentMod(ll A, ll B, ll C)  
{  
    if (A == 0)  
        return 0;  
    if (B == 0)  
        return 1;  
    ll y;  
    if (B % 2 == 0) {  
        y = exponentMod(A, B / 2, C);  
        y = (y * y) % C;  
    }  
    else {  
        y = A % C;  
        y = (y * exponentMod(A, B - 1, C) % C) % C;  
    }  
  
    return (ll)((y + C) % C);  
}

*/
/*
class dsu{
public:    
vi<ll> v;


void init(ll n){
    v.assign(n+1,-1);
}

 
ll dsufind(ll x){
    if(v[x]<0){
        return x;
    }
    v[x]=dsufind(v[x]);
    return v[x];
}
 
void dsujoin(ll x,ll y){
    x=dsufind(x);
    y=dsufind(y);
    
    if(x==y)
    return;
    if(v[x]>v[y])swap(x,y);
    v[y]+=v[x];
    v[x]=y;
}

};
*/

ll a[3005];
ll dp[3001][3001];

ll go(ll l,ll r){
    if(l>r)
    return 0;
    if(r==l)
    return a[l];
    if(dp[l][r]!=-1)
    return dp[l][r];
    ll ans=a[l]-go(l+1,r);
    ans=max(ans,a[r]-go(l,r-1));
    dp[l][r]=ans;

    return ans;
}


int main(){
    IOS;
    ll t;
    t=1;
    ///cin>>t;
    while(t--){
        ll n;
        cin>>n;
        memset(dp,-1,sizeof(dp));
        FOR(i,n)cin>>a[i];
        cout<<go(0,n-1);
        
    }
    return 0;
} 


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

int main() {
	int s;
	cin >> s;
	vector<int> a(1, s);
	do {
		if (a.back() & 1)
			a.push_back(3 * a.back() + 1);
		else
			a.push_back(a.back() / 2);
	} while (count(a.begin(), a.end(), a.back()) < 2);
	cout << a.size() << endl;
}


Measured memory_bytes: 256
#include <iostream>
using std::cin;
using std::cout;
using std::endl;

int main() {
	int h, w;
	cin >> h >> w;
	
	char px[w][h];
	
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> px[j][i];
		}
	}
	
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cout << px[j][i];
		}
		cout << endl;
		for (int j = 0; j < w; j++) {
			cout << px[j][i];
		}
		cout << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
using namespace std;
typedef long long int ll;
#define rep(i,n) for(int i = 0; i < n; i++)
#define invrep(i,n) for(int i = n; i > 0; i--)

double dist (int i, int j, vector<int> x, vector<int> y) {
    return pow(pow((x[i] - x[j]), 2) + pow((y[i] - y[j]), 2), 0.5);
}

bool g[10][10];
int main() {
    int n1, n2;
    cin >> n1 >> n2;

    vector<int> idx;
    rep(i, n1) idx.emplace_back(i);

    int a, b;
    
    rep(i, n2) {
        cin >> a >> b;
        a--; b--;
        g[a][b] = g[b][a] = true;
    }

    int cnt = 0;
    do {
        if (idx[0] != 0) break;

        bool ok = true;
        rep(i, n1-1) {
            int from = idx[i];
            int to = idx[i+1];
            // cout << from << to << endl;
            if (!g[from][to]) ok = false;
        }

        if (ok) cnt++;
    } while(next_permutation(idx.begin(), idx.end()));
    
    // cout << cnt << endl;
    cout << cnt << endl;
}

Measured memory_bytes: 3612
void main() {
	auto K = ri;
	auto ip = readAs!(int[]), A = ip[0], B = ip[1];
	foreach(i; A..B+1) {
		if(i % K == 0) {
			writeln("OK");
			return;
		}
	}
	writeln("NG");
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Measured memory_bytes: 2720
#include <bits/stdc++.h>
#include <fstream>
#include <cstdio>
using namespace std;
// vector<pair<int,int> > v;
// cin.ignore();//twice getline(cin,s);
// g++ iterator.cpp -std=c++17
// cout<<(A + B == C ? "YES" : "NO")<<endl;
// __gcd(a,b)
// string s=to_string(n);
// string p=s.substr(0,len);
// string q=s.insert(0,str);
// sort(arr, arr+n, greater<int>());
// cout<<fixed<<setprecision(9)<<pi<<endl
// const  double pi = acos(-1.0);
#define ff first
#define ss second
#define pb push_back
#define mk make_pair
#define vll vector<ll>
#define mll map<ll,ll >
#define mlli map<ll,ll>::iterator
#define size size()
#define endl "\n"
#define ll long long int
#define ld long double
void fast(){ios_base::sync_with_stdio(false);
cin.tie(NULL);cout.tie(NULL);}


int main(void)
{
	fast();
	int n;
	cin>>n;
	int m=n+1;
	int a[m];
	int cnt=0;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		if(a[i]%2==1 && i%2==1)
		{
			cnt++;
		}
	}	
	cout<<cnt<<endl;
}

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

int main(){
    int n;
    cin>>n;
    int a[n];

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

    for(int i=n-1;i>0;i--){
        cout<<a[i]<<" ";
    }
    cout<<a[0]<<endl;

    return 0;
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
  ll n,cnt=0;
  cin >> n;
  vl a(n);
  rep(i,n){
    cin >> a[i];
    while(a[i]%2==0){
      a[i]/=2;
      cnt++;
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int MAX_N = 1 << 18;
struct BIT{
  int bit[MAX_N+1],n;
  //1-indexed
  BIT(){init();}
  BIT(int n):n(n){init();}
  void init(){
    memset(bit,0,sizeof(bit));
  }
  int sum(int i){
    int s=0;
    while(i>0){
      s+=bit[i];
      i-=i&-i;
    }
    return s;
  }
  void add(int i,int x){
    while(i<=n){
      bit[i]+=x;
      i+=i&-i;
    }
  }
  int sum0(int i){
    return sum(i+1);
  }
  void add0(int i,int x){
    add(i+1,x);
  }
};
signed main(){
  int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++) cin>>a[i];
  int b[n];
  for(int i=0;i<n;i++) b[i]=a[i];
  sort(b,b+n);
  map<int,int> m;
  for(int i=0;i<n;i++) m[b[i]]=i+1;
  BIT bit(n);
  int ans=0;
  for(int i=0;i<n;i++){
    //cout<<i<<" "<<m[a[i]]<<endl;
    ans+=i-bit.sum(m[a[i]]);
    bit.add(m[a[i]],1);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 20796
#include <cmath>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <functional>
#include <queue>
#include <iostream>
#include <string.h>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <cstdint>
#include <climits>
#include <unordered_set>
#include <sstream>
#include <stack>

using namespace std;

typedef long long int ll;
typedef pair<ll,ll> pii;
typedef tuple<double,ll,ll> t3;

using namespace std;

int N;
string S[202];
ll dp[1<<20];
ll mod=1000000007;
ll fact[21];
ll ret[21];
int cost[20][20];

int main()
{
    vector<t3> p;
    ll si = 1;
    for(int i = 0;i < 4;i++)
    {
        ll a;
        cin >> a;
        p.push_back(make_tuple(a / (double)si, si, a));
        si *= 2;
    }
    sort(p.begin(), p.end());
    ll n;
    cin >> n;
    n*=4;
    ll cost = 0;
    while(n > 0)
    {
        for(auto& e : p)
        {
            double a;
            ll b,c;
            tie(a,b,c) = e;
            if(n >= b)
            {
                ll dd = n / b;
                cost += c * dd;
                n -= b * dd;
            }
        }
    }
    cout << cost << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))

n, m = na()
wa = [0] * n
ac = [0] * n
ans = 0
for _ in range(m):
    p, s = ns().split()
    p = int(p) - 1
    if s == "WA" and ac[p] == 0:
        wa[p] = wa[p] + 1
    if s == "AC" and ac[p] == 0:
        ans += wa[p]
        ac[p] = 1
print(sum(ac), ans)



Measured memory_bytes: 4596
#include<stdio.h>
#include<math.h>
int main(void){
	int n,i;
	double x1,y1,x2,y2,x3,y3;
	double px,py,r;
	double a,b,c,s;
	scanf("%d",&n);
		for(i=0;i<n;i++){
			scanf("%lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3);
			px=((y1-y3)*(y1*y1-y2*y2+x1*x1-x2*x2)-(y1-y2)*(y1*y1-y3*y3+x1*x1-x3*x3))/(2*(y1-y3)*(x1-x2)-2*(y1-y2)*(x1-x3));
			py=((x1-x3)*(x1*x1-x2*x2+y1*y1-y2*y2)-(x1-x2)*(x1*x1-x3*x3+y1*y1-y3*y3))/(2*(x1-x3)*(y1-y2)-2*(x1-x2)*(y1-y3));
			a=sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
			b=sqrt((x3-x2)*(x3-x2)+(y3-y2)*(y3-y2));
			c=sqrt((x1-x3)*(x1-x3)+(y1-y3)*(y1-y3));
			s=(a+b+c)/2;
			r=a*b*c/4/sqrt(s*(s-a)*(s-b)*(s-c));
			printf("%.3f %.3f %.3f\n",px,py,r);
		}
	return 0;
}

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

using namespace std;

typedef long long ll;

const int MOD = 1e9 + 7;
const int N = 1e6 + 34;

ll mincx[15][1 << 15];
ll mincy[15][1 << 15];

int main()
{
    int n;
    cin >> n;
    vector<ll> x(n), y(n), p(n);
    for (int i = 0; i < n; i++)
    {
        cin >> x[i] >> y[i] >> p[i];
    }
    vector<ll> ans(n + 1, 1ll * MOD * MOD);
    for (int mask = 0; mask < (1 << n); mask++)
    {
        for (int j = 0; j < n; j++)
        {
            ll res = 1e18;
            for (int z = 0; z < n; z++)
            {
                if (mask & (1 << z)) res = min(res, p[j] * abs(x[j] - x[z]));
            }
            res = min(res, p[j] * abs(x[j]));
            mincx[j][mask] = res;
        }
    }
    for (int mask = 0; mask < (1 << n); mask++)
    {
        for (int j = 0; j < n; j++)
        {
            ll res = 1e18;
            for (int z = 0; z < n; z++)
            {
                if (mask & (1 << z)) res = min(res, p[j] * abs(y[j] - y[z]));
            }
            res = min(res, p[j] * abs(y[j]));
            mincy[j][mask] = res;
        }
    }
    for (int mask = 0; mask < (1 << n); mask++)
    {
        int cnt = __builtin_popcount(mask);
        for (int submask = mask; ; submask = (submask - 1) & mask)
        {
            int oth = mask - submask;
            ll res = 0;
            for (int j = 0; j < n; j++)
            {
                res += min(mincx[j][submask], mincy[j][oth]);
            }
            ans[cnt] = min(ans[cnt], res);
            if (submask == 0) break;
        }
    }
    for (int i = 0; i < n + 1; i++)
    {
        cout << ans[i] << "\n";
    }
}


Measured memory_bytes: 11268
n=int(input())
ar=list(map(int,input().split()))
di={}
for i in ar:
    di[i]=di.get(i,0)+1
sm=sum(ar)
q=int(input())
for i in range(q):
    b,c=map(int,input().split())
    if(b not in di):
        print(sm)
    elif(b in di):
        x=di[b]
        del di[b]
        if(c in di):
            di[c]+=x
        else:
            di[c]=x
        s=0
        s=sm-(b*x)+(x*c)
        sm=s
        print(s)

    

Measured memory_bytes: 20592
#!/usr/bin/env python

def main():
    N = int(input())
    P = list(map(int, input().split()))
    min_val = 10 ** 6
    ans = 0
    for p in P:
        if p < min_val:
            ans += 1
        min_val = min(min_val, p)
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 75344
#include <iostream>
#include <vector>
#include <climits>

using namespace std;

template<typename T>
int32_t merge(vector<T> &A, int32_t left, int32_t mid, int32_t right) {
    int32_t n1 = mid - left;
    int32_t n2 = right - mid;

    vector<T> L(n1+1);
    vector<T> R(n2+1);
    for (int32_t i = 0; i < n1; i++) {
        L[i] = A[left+i];
    }
    for (int32_t i = 0; i < n2; i++) {
        R[i] = A[mid+i];
    }
    L[n1] = INT_MAX;
    R[n2] = INT_MAX;

    int32_t i = 0, j = 0, count = 0;
    for (int32_t k = left; k < right; k++) {
        if (L[i] <= R[j]) {
            A[k] = L[i];
            i++;
        } else {
            A[k] = R[j];
            j++;
        }
        count++;
    }

    return count;
}

template<typename T>
int32_t merge_sort(vector<T> &A, int32_t left, int32_t right) {
    if (left + 1 < right) {
        int32_t mid = left + (right - left) / 2;
        int32_t count1 = merge_sort(A, left, mid);
        int32_t count2 = merge_sort(A, mid, right);
        int32_t count3 = merge(A, left, mid, right);
        return count1 + count2 + count3;
    }

    return 0;
}

int main() {
    int32_t n;

    cin >> n;
    vector<int32_t> S(n);
    for (int32_t i = 0; i < n; i++) {
        cin >> S[i];
    }

    int32_t count = merge_sort(S, 0, n);
    for (int32_t i = 0; i < n; i++) {
        cout << S[i];
        if  (i == n-1) {
            cout << endl;
        } else {
            cout << " ";
        }
    }
    cout << count << endl;

    return 0;
}

Measured memory_bytes: 6748
<?php
$stdin = fopen("php://stdin", "r");
for ($i = 0; $i < 3; $i++) {
	fscanf($stdin, "%[^\n]", $arr_temp);
	$arr[] = array_map('intval', preg_split('/ /', $arr_temp, -1, PREG_SPLIT_NO_EMPTY));
}
$possible = 'YES';
$town = [];
for($i = 1; $i<=4; $i++) {
	$town[$i] = 0;
}

for($i = 0; $i<3; $i++) {
	for($j=0; $j<2; $j++) {
		$town[$arr[$i][$j]] += 1;
		if($town[$arr[$i][$j]] >= 3) {
			$possible = 'NO';
			break;
		}
	}
}
echo $possible;


Measured memory_bytes: 3700
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <unordered_set>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>

using namespace std;
using lli = long long int;
// #define DEBUG
#ifdef DEBUG
#define debug(var) cout << (#var) << ": " << (var) << endl;
template<class T> void dump_array_impl(const T& a) {
  bool first = true;
  for (auto&& x : a) {
    if (!first) { cout << ", "; first = false; }
    cout << x;
  }
}
#define debug_array(a) cout<<(#a)<<": ";dump_array_impl(a);cout<<endl
#else
#define debug(var) {}
#define debug_array(a) {}
#endif
template<class T> void read_n(vector<T>& v, size_t n) {
  v = vector<T>(n);
  for (lli i=0; i<n; ++i) cin >> v[i];
}


lli n;
vector<lli> l, r;
vector<pair<lli, lli>> nl, nr;

void f(decltype(l)& v, decltype(nl)& n) {
  sort(begin(v), end(v));
  lli p = -1, c = 0;
  for (auto x : v) {
    if (x==p) c++;
    else {
      n.push_back({p, c});
      c=1;
      p=x;
    }
  }
  n.push_back({p, c});
  using P = decltype(n[0]);
  sort(begin(n), end(n), [](P& p1, P& p2) {
    return p1.second > p2.second;    
  });
}

int main() {
  cin >> n;
  for (int i=0; i<n; ++i) {
    lli x; cin >> x;
    if ((i&1)==0) l.push_back(x); else r.push_back(x);
  }
  f(l, nl);
  f(r, nr);
  lli sub = nl[0].first == nr[0].first 
    ? max(nl[0].second + nr[1].second, nl[1].second + nr[0].second)
    : nl[0].second + nr[0].second;
  
  cout << n-sub << endl;
  return 0;
}


Measured memory_bytes: 3312
#!/usr/bin/env python3
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
A = [0]
B = [0]
for i in range(n):
    A.append(A[i] + a[i])
for i in range(m):
    B.append(B[i] + b[i])
ans = 0
j = m
for i in range(n + 1):
    if A[i] > k:
        break
    while j > 0 and k - A[i] < B[j]:
        j -= 1
    ans = max(ans, i + j)

print(ans)


Measured memory_bytes: 47396
#include<stdio.h>
 
void printRectangle(int H, int W){
    int i,j;
     
    for(i=0; i<H; i++){
        for(j=0; j<W; j++){
            if(i==0 || i == H-1 || j==0 || j==W-1)  printf("#");
            else printf(".");
        }
        printf("\n");
    }
    printf("\n");
}
 
int main(void){
     
    int h,w;
     
    while(1){
        scanf("%d %d", &h, &w);
        if(h==0 && w==0) break;
        printRectangle(h, w);
    }
    return 0;
}

Measured memory_bytes: 572
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	vector<int>dp(3);
	for(int day=0;day<n;day++){
		vector<int>new_dp(3,0);
		vector<int>c(3);
		for(int i=0;i<3;i++){
			scanf("%d",&c[i]);
		}
		for(int i=0;i<3;i++){
			for(int j=0;j<3;j++){
				if(i!=j){
					new_dp[j] = max(new_dp[j],dp[i]+c[j]);
				}
			}
		}
		dp = new_dp;
	}
	cout<<max({dp[0],dp[1],dp[2]});
return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string N;
  cin>>N;
if(N[0]==N[1]&&N[1]==N[2]){
cout<<"Yes"<<endl;
}
  else if(N[1]==N[2]&&N[2]==N[3]){
  cout<<"Yes"<<endl;}
  else{
  
  cout<<"No"<<endl;}

}


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

int main() {
 int N;
 string S;
  cin >> N;
  int n=0;
  for(;n<N;n++){
    cin >> S;
    if(S=="Y"){
      cout << "Four";
      n=n+N;
    }
  }
  if(n==N)
    cout << "Three";
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Infinite Express
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0289

"""
import sys


def solve(s, d):
    ans = 0
    while s != d:
        step = (s & -s) if s!=0 else 2**32
        while s + step > d:
            step //= 2
        s += step
        ans += 1
    return ans


def main(args):
    N = int(input())
    for _ in range(N):
        s, d = map(int, input().split())
        ans = solve(s, d)
        print(ans)


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


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

#define INF 1e9
using namespace std;

int main() {

    string S; cin >> S;

    for (int bit = 0; bit < (1 << 3); ++bit) {
        int sum = S[0] - '0';
        string word;
        word += S[0];

        for (int i = 0; i < 3; ++i) {
            if (bit & (1 << i)) {
                sum += S[i+1] - '0';
                word += '+';
                word += S[i+1];
            } else {
                sum -= S[i+1] - '0';
                word += '-';
                word += S[i+1];
            }
        }

        if (sum == 7) {
            cout << word + "=7" << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
//// Journey of Harry Singh from Diploma in Cse to Red Coder of India.///////////////////////////////////////////////////
#include <bits/stdc++.h>
#define ll long long
using namespace std;
 
int main(){
ll n,m,k;
cin>>n;
ll mi=10000009;
for(int i=1;i<=sqrt(n);i++)
{
	ll mx=100009;
	if(n%i==0)
	{
		string f=to_string(i);
		string s=to_string(n/i);
		mx=max(f.length(),s.length());
	}
	mi=min(mi,mx);
}
cout<<mi<<"\n";








}

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

typedef pair<ll, int> LIP;
vector<LIP> factorize(ll n) {
    vector<LIP> res;
    for(ll i=2; i*i<=n; i++) {
        if (n % i) continue;
        res.emplace_back(i, 0);
        while (n%i == 0) {
            n /= i;
            res.back().second++;
        }
    }
    if(n != 1) res.emplace_back(n, 1);
    return res;
}

ll modpow(ll n, ll p, ll m) {
    ll res = 1;
    while(p>0){
        if(p%2==1) res = (res * n) % m;
        n = (n * n) % m;
        p /= 2;
    }
    return res;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll mod = 1LL<<60;
    ll n,p;cin>>n>>p;
    vector<LIP> t = factorize(p);
    ll ans = 1;
    for(auto a : t){
        if(a.second/n){
            ans *= (modpow(a.first, a.second/n, mod));
        }
    }
    cout<<ans<<endl;

}

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

std::vector<long long> fact, inv;

constexpr auto pow(long long x, long long n, const long long mod) {
    long long ret = 1;
    while(n > 0) {
        if ((n & 1) == 1) ret = (ret * x) % mod;
        x = (x * x) % mod;
        n >>= 1;
    }
    return ret;
}

constexpr auto inverse(const long long x, const long long p) {
    return pow(x, p - 2, p);
}

void init_factorial(const int n, const long long mod) {
    fact.resize(n + 1);
    inv.resize(n + 1);
    fact[0] = 1;
    for (long long i = 1; i <= n; i++) fact[i] = fact[i - 1] * i % mod;
    inv[n] = inverse(fact[n], mod);
    for (long long i = n; i > 0; i--) inv[i - 1] = inv[i] * i % mod;
}

int main() {
    constexpr i64 mod = 1000000007;
    int n, k;
    std::cin >> n >> k;
    init_factorial(n, mod);
    std::map<i64, i64> cnt;
    for (int i = 0; i < n; i++) {
        i64 in;
        std::cin >> in;
        cnt[in]++;
    }

    i64 ret = 0, s = 0;
    for (auto it = cnt.rbegin(); it != cnt.rend(); it++) {
        i64 a = it->first, c = it->second, e = s + c;
        if (n - s - k < 0) break;
        i64 w = fact[n - s] * inv[k] % mod * inv[n - s - k] % mod;
        if (n - e - k >= 0) w = (w + mod - fact[n - e] * inv[k] % mod * inv[n - e - k] % mod) % mod;
        ret = (ret + a * w % mod) % mod;
        s = e;
    }

    s = 0;
    for (auto el : cnt) {
        i64 a = el.first, c = el.second, e = s + c;
        if (n - s - k < 0) break;
        i64 w = fact[n - s] * inv[k] % mod * inv[n - s - k] % mod;
        if (n - e - k >= 0) w = (w + mod - fact[n - e] * inv[k] % mod * inv[n - e - k] % mod) % mod;
        ret = (ret + mod - a * w % mod) % mod;
        s = e;
    }

    if (ret < 0) ret += mod;
    std::cout << ret << std::endl;

    return 0;
}


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

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

    if (n < s.length()) {
    for (int i=0; i < n ; i++) cout << s[i] ;
    cout << "..." ; }
    else {
        cout << s ;
    }
}

Measured memory_bytes: 3628
import java.awt.Point;
import java.util.Arrays;
import java.util.Scanner;

public class Main{
	
	static final Scanner s=new Scanner(System.in);
	
	public static void main(String args[]){
		int n=s.nextInt();
		Point in[]=new Point[n];
		for(int i=0; i<n; i++)
			in[i]=new Point(s.nextInt(),0);
		for(int i=0; i<n; i++)
			in[i].translate(0,s.nextInt());
		
		for(int i=1; i<=3; i++){
			final int b=i;
			System.out.println(
					Math.pow(
							Arrays.stream(in)
									.mapToDouble(p->Math.pow(Math.abs(p.x-p.y),b))
									.sum(),
							1.0/b));
		}
		System.out.println(
				Arrays.stream(in)
						.mapToInt(p->Math.abs(p.x-p.y))
						.max().getAsInt());
	}
}

Measured memory_bytes: 33172
#include<bits/stdc++.h>
#define LL long long
#define pb push_back
#define SZ(x) ((int)x.size()-1)
#define ms(a,b) memset(a,b,sizeof a)
#define F(i,a,b) for (int i=(a);i<=(b);++i)
#define DF(i,a,b) for (int i=(a);i>=(b);--i)
using namespace std;
inline LL read(){
	char ch=getchar(); LL w=1,c=0;
	for(;!isdigit(ch);ch=getchar()) if (ch=='-') w=-1;
	for(;isdigit(ch);ch=getchar()) c=(c<<1)+(c<<3)+(ch^48);
	return w*c;
}
const int M=2000;
LL d[66]; 
void ins(LL x){
	DF(i,60,0){
		if (x>>i&1){
			if (!d[i]) {
				d[i]=x; 
				break;
			}
			x^=d[i]; 
		}
	}
}
bool qry(LL x){
	DF(i,60,0){
		if (x>>i&1) x^=d[i]; 
	}
	return x;
}
char ch[M]; 
LL a[M]; 
int main(){
	int T=read(); 
	while (T--){
		int n=read(); ms(d,0);
		F(i,1,n) a[i]=read(); scanf("%s",ch+1);
		bool flag=0;
		DF(i,n,1){
			if (ch[i]=='0') {
				ins(a[i]); 
			}
			else {
				if (qry(a[i])){
					flag=1;
					break;
				}
			}
		}
		if (flag) puts("1");
		else puts("0");
	}
	return 0;
}




Measured memory_bytes: 3620
from collections import defaultdict
d = defaultdict(int)
for _ in range(int(input())):
    s = input()
    d[s]+=1
print("AC x "+str(d["AC"]))
print("WA x "+str(d["WA"]))
print("TLE x "+str(d["TLE"]))
print("RE x "+str(d["RE"]))


Measured memory_bytes: 9476
t = []
for i in range(5):
    t.append(int(input()))

saigo = 9
nonzero = 0
for i in range(5):
    if t[i] % 10 != 0:
        saigo = min(saigo,t[i]%10)
        nonzero += 1
if nonzero == 0:
    saigo = 10

jikan = 0
for i in range(5):
    if t[i] % 10 == 0:
        jikan += t[i]
    else:
        jikan += t[i] + 10 - t[i]%10

jikan -= 10 - saigo
print(jikan)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
typedef long long ll;
typedef pair<ll,ll> P;
int main(){
	ll n,m;
	cin >> n >> m;
	priority_queue<P> que;
	rep(i,n){
		ll a;
		cin >> a;
		que.push(make_pair(a,1));
	}
	rep(i,m){
		ll b,c;
		cin >> b >> c;
		que.push(make_pair(c,b));
	}
	ll ans = 0;
	ll count = 0;
	while(!que.empty()){
		auto p = que.top();
		que.pop();
		ll temp = count;
		rep(i,min(n-temp,p.second)){
			ans += p.first;
			count++;
			if(count == n) break;
		}
		if(count == n) break;
	}
	
	cout << ans << endl;
	
    return 0;
}



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

const int N = 2005;
const int mod = 998244353;

int n;
string s;
int sumB[N];
int dp[N * 2][N * 2];

void add(int &x, int y) {
	x += y; while(x >= mod) x -= mod;
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	
	cin >> s;
	n = s.size();
	s = ' ' + s;
	for (int i = 1; i <= n; ++i) sumB[i] = sumB[i - 1] + (s[i] - '0');
	
	dp[0][0] = 1;
	for (int i = 0; i < 2 * n; ++i) for (int b = 0; b <= i; ++b) {
		if (!dp[i][b]) continue;
		int j = min(i + 1, n);
		int r = i - b;
		
		int remB = sumB[j] - b;
		int remR = 2 * j - sumB[j] - r;
		//cerr << i << ' ' << b << ' ' << remB << ' ' << remR << endl;
		assert(remB >= 0 && remR >= 0);
		
		if (remB > 0) add(dp[i + 1][b + 1], dp[i][b]);
		if (remR > 0) add(dp[i + 1][b], dp[i][b]);
	}
	
	int res = 0;
	for (int b = 0; b <= 2 * n; ++b) add(res, dp[2 * n][b]);
	
	cout << res << endl;
}


Measured memory_bytes: 60544
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long
using namespace std;
int main()
{
    int n,m;
    cin >> n >> m;
    vector<int> a(n);
    rep(i,n){
        cin >> a[i];
        a[i] = a[i]/2;
    }
    int l = 0;
    int b=a[0];
    while(b%2==0){
        l++;
        b /= 2;
    }
    rep(i,n-1){
        int x=0;
        b = a[i + 1];
        while (b % 2 == 0)
        {
            x++;
            b /= 2;
        }
        if (x!= l)
        {
            cout << 0 << endl;
            return 0;
        }
    }
    ll g = a[0];
    rep(i,n-1){
        int r = __gcd(g, (ll)a[i + 1]);
        g = g * a[i + 1] / r;
    }
    int ans = 0;
    ans = (m / g + 1) / 2;
    cout << ans << endl;
}

Measured memory_bytes: 640
N, M = map(int, input().split())
gate_num = [0 for i in range(N)]
for i in range(M):
    L, R = map(int, input().split())
    gate_num[L - 1] += 1
    if R < N:
        gate_num[R] -= 1
for i in range(1, N):
    gate_num[i] = gate_num[i] + gate_num[i - 1]
    
ans = 0
for i in range(N):
    if(gate_num[i] == M):
        ans += 1
print(ans)

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

int main() {
  int N, X;
  int m[110];

  cin >> N >> X;
  for(int i = 0; i < N; i++) {
    cin >> m[i];
  }

  int r = X;
  int min = 1000;
  for(int i = 0; i < N; i++) {
    r -= m[i];
    if(m[i] < min) {
      min = m[i];
    }
  }
  cout << N + r / min << endl;

}

Measured memory_bytes: 256
import sys
from numba import njit, i8


@njit((i8, i8, i8, i8), cache=True)
def floor_sum(n, m, a, b):
    result = 0
    while True:
        result += (n - 1) * n * (a // m) // 2 + n * (b // m)
        a %= m
        b %= m
        y_max = (a * n + b) // m
        if y_max == 0:
            break
        x_max = y_max * m - b
        result += (n - (x_max + a - 1) // a) * y_max
        n, m, a, b = y_max, a, m, (a - x_max % a) % a
    return result


def main():
    t = int(sys.stdin.buffer.readline())
    ans = [0]*t
    for i, x in enumerate(sys.stdin.buffer.readlines()):
        n, m, a, b = map(int, x.split())
        ans[i] = floor_sum(n, m, a, b)
    print(*ans, sep="\n")


if __name__ == "__main__":
    main()


Measured memory_bytes: 114392
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    int K, X;
    cin >> K >> X;
    if(500*K >= X){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
n = int(input())
s = input()

num_w=num_b=0
for i in range(n):
    let = s[i]
    if let == ".":
        num_w+=1
    else:
        num_b+=1


ans=num_w

mini = ans

for i in range(n):
    if s[i] == ".":
        ans -=1
    else:
        ans +=1
    mini = min(mini,ans)

print(mini)

Measured memory_bytes: 3500
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
int main() {
	int n;
	while (cin >> n){
		if (n == 0)return 0;
		int maxnum;
		double maxbmi;
		int num;
		double x, y;
		cin >> num >> x >> y;
		x /= 100;
		x *= x;
		y /= x;
		maxnum = num;
		maxbmi = y;
		for (int i = 1; i < n; i++){
			cin >> num >> x >> y;
			x /= 100;
			x *= x;
			y /= x;
			if (abs(22 - maxbmi) > abs(22 - y)){
				maxnum = num;
				maxbmi = y;
			}
			else if (abs(22 - maxbmi) == abs(22 - y)){
				maxnum = min(maxnum, num);
			}
		}
		cout << maxnum << endl;
	}
}

Measured memory_bytes: 3072
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>  
#include <stdbool.h>   
#define inf (INT_MAX-1)
#define INF 9223372036854775807;
#define PI 3.14159265358979323846;
#define EPS 1e-10
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
/*
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r)
*/
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r)
#define TYPE long long
#define ll long long
#define MEMSET(a) memset(a,0,sizeof(a))
#define MEMSET_U(a) memset(a,-1,sizeof(a))
#define bool    _Bool
const int mod = (int)1e09 + 7;

//#define DEBUG1
//#define DEBUG2
//#define DEBUGF
#define DUMMY

int in(void) { int i; scanf("%d", &i); return i; }
long long llin(void) { long long i; scanf("%lld", &i); return i; }
double din(void) { double i; scanf("%lf", &i); return i; }
void chin(char s[]) { scanf("%s", s); }

void print(int a) { printf("%d\n", a); }
void llprint(long long a) { printf("%lld\n", a); }
void dprint(double a) { printf("%.10f\n", a); }
void print2(int a, int b) { printf("%d %d\n", a, b); }
int Max(int a, int b) { if (a > b) { return a; }return b; }
int Min(int a, int b) { if (a < b) { return a; }return b; }
long long llmax(long long a, long long b) { return a > b ? a : b; }
long long llmin(long long a, long long b) { return a < b ? a : b; }
double dmax(double a, double b) { return a > b ? a : b; }
double dmin(double a, double b) { return a < b ? a : b; }
//long long llmax(long long a, long long b) { return a > b ? a : b; }
//long long llmin(long long a, long long b) { return a < b ? a : b; }
//double dmax(double a, double b) { return a > b ? a : b; }
int cmp(const void *a, const void *b) { return *(TYPE *)a - *(TYPE *)b; }
int cmp_r(const void *a, const void *b) { return *(TYPE *)b - *(TYPE *)a; }
int char_cmp(const void *a, const void *b) { return strcmp((char *)a, (char *)b); }
int char_cmp_r(const void *a, const void *b) { return strcmp((char *)b, (char *)a); }
void swap(int *a, int *b) { int t = *a; *a = *b; *b = t; }


int main() {
	int H, W;
	char S[52][52];
	scanf("%d%d", &H, &W);
	for (int i = 0; i < H; i++) {
		scanf("%s", S[i]);
	}
	bool ans = true;
	int dx[4] = { -1,1,0,0 };
	int dy[4] = { 0,0,-1,1 };
	int i, j, k;
	for (i = 0; i < H; i++) {
		for (j = 0; j < W; j++) {
			if (S[i][j] == '#') {
				bool found = false;
				for (k = 0; k < 4; k++) {
					int i2 = i + dy[k];
					int j2 = j + dx[k];
					if (0 <= i2 && i2 < H && 0 <= j2 && j2 < W && S[i2][j2] == '#') {
						found = true;
					}
				}
				if (!found) {
					ans = false;
				}
			}
		}
	}
	if (ans == true) {
		puts("Yes");
	}
	else {
		puts("No");
}

#ifdef DEBUGF
	getch();
#endif
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main() {
	int A[3];
	for(int i = 0; i < 3; i++) cin >> A[i];
	sort(A, A + 3);
	int ans = A[2] - A[0];
	cout << ans << endl;
	return 0;
}


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    ll N, K;
    cin >> N >> K;

    vector<ll> C(N,0);
    REP(i, K){
        ll d;
        cin >> d;

        REP(j, d){
            ll a;
            cin >> a;
            C[a-1]++;
        }
    }
    ll ans = 0;
    REP(i, N){
        if(C[i] == 0) ans++;
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
    ll h,w,n;
    std::cin >> h>>w>>n;
    ll sr,sc;
    std::cin >> sr >> sc;
    sr--;
    sc--;
    string s,t;
    std::cin >> s;
    std::cin >> t;
    
    ll l,r;
    l = 0;
    r = w-1;
    for (int i = n-1; i >=0; i--) {
        if(t[i]=='R'){
            l--;
            l = max((ll)0,l);
        }else if(t[i]=='L'){
            r++;
            r = min(w-1,r);
        }
        
        if(s[i]=='R'){
            r--;
        }else if(s[i]=='L'){
            l++;
        }

        if(r<l){
            std::cout << "NO" << std::endl;
            return 0;
        }
    }

    if(sc<l || r<sc){
        std::cout << "NO" << std::endl;
        return 0;
    }
    
    l = 0;
    r = h-1;
    for (int i = n-1; i >=0; i--) {
        if(t[i]=='D'){
            l--;
            l = max((ll)0,l);
        }else if(t[i]=='U'){
            r++;
            r = min(h-1,r);
        }
        
        if(s[i]=='D'){
            r--;
        }else if(s[ i]=='U'){
            l++;
        }
        
        if(r<l){
            std::cout << "NO" << std::endl;
            return 0;
        }
    }                                                                                                                                           
    if(sr<l || r<sr){
        std::cout << "NO" << std::endl;
        return 0;
    }
    
    std::cout << "YES" << std::endl;
}


Measured memory_bytes: 776
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <cstring>
#include <climits>
#include <queue>
#include <map>
#include <sstream>
using namespace std;

#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define EPS 1e-9

int gcd(int x, int y){
	return y ? gcd(y,x%y) : x;
}
int main(){
	int a,b;
	while(~scanf("%d%d",&a,&b)){
		printf("%d\n",gcd(a,b));
	}
	return 0;
}

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

//#define int long long
#define fi first
#define se second
#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 rep11(i, n) for (int i = 1; i < (int)(n); ++i)
#define repo(i, o, n) for (int i = o; i < (int)(n); ++i)
#define repm(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1002000007
#define INF LONG_LONG_MAX

int main(){
    int r;
    cin >> r ;
    
    cout<< 3*r*r <<endl;
    
}

Measured memory_bytes: 256
N, S = gets.split.map(&:to_i).tap{|it| it[1] /= 1000}
ans = [-1,-1,-1]
(0 .. N).each do |y|
  x, d = (S - N - 4 * y).divmod(9)
  if d == 0 && x >= 0 && N - x - y >= 0
    ans = [x, y, N - x - y]
    break
  end
end
puts ans.join(" ")

Measured memory_bytes: 1788
#include <iostream>
#include <string>
using namespace std;
//線形探索
int main() {
	int a, b, c, x,ct=0;
	cin >> a >> b >> c >> x;
	for (int i= 0; i <= a; i++) {
		for (int j = 0; j <= b; j++) {
			for (int k = 0; k <= c; k++) {
			
				if ( 500 * i + 100 * j + 50 * k== x)
					ct++;
			}
		}
 
	}
	cout << ct;
 
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> //JuniorMonster a.k.a Sho10
#define ll long long
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define mod 1000000007
#define PI 3.14159265359
#define CODE_START  ios_base::sync_with_stdio();cin.tie();cout.tie();
using namespace std;
ll n;
string s;
int32_t main(){
CODE_START;
cin >> s;
n=s.size();
if(s[0]==s[n-1]){
    if(n%2==0){
        rc("First");
    }else {
    rc("Second");
    }
}
if(n%2==0){
    rc("Second");
}else rc("First");
return 0;}


Measured memory_bytes: 512