akhauriyash/Code-Regression huggingface dataset:
#require 'prime'
#require 'openssl'
MOD=10**9+7;  cnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)
def gs() gets.chomp end
def gi() gets.chomp.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def ar2(s1,s2,de=nil) Array.new(s1){Array.new(s2,de)} end
def ar3(s1,s2,s3,de=nil) Array.new(s1){Array.new(s2){Array.new(s3,de)}} end

def desc(ar) ar.sort!{|x,y| y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+).to_i end
def ceil(a,b) (a.to_f/b).ceil end

def C(a,b) b==0||a==b ? 1 : (b=a-b if a/2<b;(a-b+1..a).inject(:*)/(1..b).inject(:*)) end
def rui(ar) s=[0]; ar.size.times{|i| s<<s[-1]+ar[i]}; s end
def rev_rui(ar) s=[0]; ar.size.times.reverse_each{|i| s<<s[-1]+ar[i]}; s end

def puts_yesno(b) puts(b ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def pu(h) begin; require './../nemi_lib/debug.rb'; puts_val(h); rescue LoadError; end; end
########### ( ˘ω˘ )ｽﾔｧ… ###########
n=gi
a=gsmi
a.each do |i|
  h[i]+=1
end
ans=[]
q=gi

prev=0
h.each do |k,v|
  prev+=k*v
end

q.times do |i|
  b,c=gsmi
  prev= prev - b*h[b] + c*h[b]
  h[c]+=h[b]
  h[b]=0

  ans<<prev
end

puts ans

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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
ll MOD = 1e9+7;
//ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x, ll y, ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}   


int main(){
  ll i,j,o;
  ll result=0,buf=0,buf1=0,buf2=0,buf3=0,buf4=0;
  bool judge = true;
  ll n,a;cin>>n>>a;
  cout<<n*n-a<<endl;
  


  return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''
n = int(input())
p = list(map(int, input().split()))
count = 0

for i in range(1, n - 1):
	if (p[i - 1] < p[i] and p[i] < p[i + 1]) or (p[i - 1] > p[i] and p[i] > p[i + 1]):
		count += 1
		
print(count)


Measured memory_bytes: 38552
#include<bits/stdc++.h>
#define sd(a) scanf("%d",&a)
using namespace std;
int n,k;
const int maxn=2*(5e3+10);
char s[maxn];
char ans[maxn];
char tmp[maxn];
void check(){
    for(int i=1;i<=n;++i){
        if(ans[i]<tmp[i])return;
        if(tmp[i]<ans[i]){
            for(int j=1;j<=n;++j)
                ans[j]=tmp[j];
        }
    }
}
int main(){
    sd(n);
    sd(k);
    scanf("%s",s+1);
    char c='z';
    for(int i=1;s[i];++i){
        c=min(c,s[i]);
    }
    for(int i=1;s[i];++i){
        s[2*n-i+1]=ans[i]=s[i];
    }
    ans[n+1]=0;
    if(s[n]==c){
        int len=0,y=k;
        for(int i=n;s[i]==c;--i)len++;
        int pos=n-len;
        while(len<n&&y--)len<<=1;
        if(len<n){
            for(int i=1;i<=len;++i)
                tmp[i]=c;
            for(int i=len+1;i<=n;++i)
                tmp[i]=s[pos--];
        }
        else{
            for(int i=1;i<=n;++i)
                tmp[i]=c;
        }
        check();
    }
    for(int i=n+1;i<=2*n;++i){
        int len=0;
        if(i+1<=2*n)
            while(s[i]==s[i+1])i++;
        int pos;
        if(s[i]==c){
            int j;
            for(j=i;s[j]==c;--j){
                len++;
            }
            pos=j;
            int y=k-1;
            while(len<n&&y--)len<<=1;
            if(len<n){
                for(int i=1;i<=len;++i)
                    tmp[i]=c;
                for(int i=len+1;i<=n;++i)
                    tmp[i]=s[pos--];
            }
            else{
                for(int i=1;i<=n;++i)
                    tmp[i]=c;
            }
            check();
        }
    }
    printf("%s\n",ans+1);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define lim 100005
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define eps 1e-8
#define INF 1e10
#define F first
#define S second
#define sd(n) scanf("%lld",&n)
#define pd(n) printf("%.9lf\n",n)
ll a[lim+1];
ll t[lim+1];
ll ans[lim+1];
int main()
{ 
    ll n;
    cin>>n;
    for(ll i=0;i<n;i++)
        cin>>t[i],ans[i]=-1;
    for(ll i=0;i<n;i++)
        cin>>a[i];
    bool pop=1;
    ans[0]=t[0];
    for(ll i=1;i<n;i++)
    {
        if(t[i]!=t[i-1])
        {
            ans[i]=t[i];
        }
    }
    if(ans[n-1]!=a[n-1]&&ans[n-1]!=-1)
        pop=0;
    if(!pop)
    {
        cout<<0<<endl;
        return 0;
    }
    ans[n-1]=a[n-1];
    for(ll i=n-2;i>=0;i--)
    {    if(ans[i]!=-1)
        {
            if(ans[i]>a[i])
            {
                cout<<0<<endl;
                return 0;
            }
        }
        if(a[i]!=a[i+1])
        {
            if(ans[i]!=a[i]&&ans[i]!=-1)
            {
                cout<<0<<endl;
                return 0;
            }
            ans[i]=a[i];
        }
    }
    ll fans=1;
    for(ll i=0;i<n;i++)
    {  ll p;
        if(ans[i]==-1)
        {
            p=min(a[i],t[i]);
            fans*=p;
            fans%=mod;

        }
    }
    cout<<fans%mod<<endl;
}


Measured memory_bytes: 2560
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
//#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memse(a,b) memset(a,b,sizeof(a))
#define iter(v,ite) for(auto ite=(v).begin();ite!=(v).end();ite++)
#define mimunum(v,x) distance((v).begin(),lower_bound((v).begin(),(v).end(),x))


int h,w;
char s[65][15];

int dat[65][15];

int rs[605];
int ls[605];
int ws[605];
int xs[605];
vector<int> us[605];
int gone[605];

int dy[4] = {0,1,0,-1};
int dx[4] = {1,0,-1,0};
void ren(int y,int x,char c,int to){
	if(y<0 || y>=h || x<0 || x>=w)return;
	if(s[y][x]!=c)return;
	s[y][x] = '.'; 
	dat[y][x]=to;
	rep(i,4){
		ren(y+dy[i],x+dx[i],c,to);
	}
}


bool dfs(int no){
	gone[no]=1;
	//printf("%d :: %d %d %d\n",no,ws[no],xs[no],ls[no],rs[no]);
	rep(i,us[no].size()){
		int to=us[no][i];
		if(gone[to])continue;
		if(!dfs(to))return false;
		ws[no] += ws[to];
		xs[no] += xs[to];
	}
	int w=ws[no],x=xs[no];
	//printf("%d :: %d %d %d\n",no,w,x,ls[no],rs[no]);
	int r = rs[no] * w + (w+1)/2,
		l = ls[no] * w - (w+1)/2;
	return (l<x && x<r);
	
}

int main(void){
	for(;;){
		scanf("%d%d",&w,&h);
		if(w==0)break;
		memse(dat,0);
		rep(y,h){
			scanf("%s",s[y]);
		}
		int nas = 1;
		rep(y,h)rep(x,w){
			if(s[y][x]!='.'){
				ren(y,x,s[y][x],nas);
				nas++;
			}
		}
		
		memse(gone,0);
		memse(xs,0);
		memse(ws,0);
		memse(rs,-1);
		memse(ls,-1);
		rep(i,605)us[i].clear();
		rep(y,h)rep(x,w){
			int d=dat[y][x];
			//printf("%d%c",d,x+1==w?'\n':' ');
			if(d==0)continue;
			ws[d]++; xs[d] += x;
			if(y==h-1 || dat[y+1][x]!=0){
				if(dat[y+1][x]==d)continue;
				if(y==h-1)us[0].push_back(d);
				else{
					int td=dat[y+1][x];
					if(td==0)continue;
					us[td].push_back(d);
				}
				if(rs[d]<0 || rs[d]<x)rs[d]=x;
				if(ls[d]<0 || ls[d]>x)ls[d]=x;
			}
		}
		
		int base = us[0][0];
		printf("%s\n",dfs(base)?"STABLE":"UNSTABLE");
	}
	return 0;
}

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

int main() {
    long long n, x, result = LLONG_MAX;
    cin >> n >> x;
    long long a[n], dp[n][n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        dp[i][0] = a[i];
    }
    for (int i = 1; i < n; i++) {
        for (int j = 0; j < n; j++) {
            dp[j][i] = min(dp[j][i - 1], a[(j - i + n) % n]);
        }
    }
    for (int i = 1; i < n; i++) {
        for (int j = 0; j < n; j++) {
            dp[i][j] += dp[i - 1][j];
        }
    }
    for (int i = 0; i < n; i++) {
        result = min(result, i * x + dp[n - 1][i]);
    }
    cout << result;
    return 0;
}

Measured memory_bytes: 31616
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
namespace mp = boost::multiprecision;
using Mint = mp::cpp_int;

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

	string res = "";
	for(char c : s) {
		switch(c) {
			case '0': res += c; break;
			case '1': res += c; break;
			case 'B':
				if(res != "") res.pop_back();
				break;
			default: break;
		}
	}

	cout << res << endl;
}

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

using namespace std;

int main(){
    unsigned long long N, M, H[100010], A, B;

    unsigned long long i, j, k,n = 0;
    int yoi[100010] = {0}, solo[100010];

    scanf("%llu %llu", &N, &M);

    for (i = 1; i <= N; i++){
        scanf("%llu", &H[i]);
    }

    for (i = 0; i <= N; i++ ){
        solo[i] = 1;
    }

    for (i = 1; i <= M; i++)
    {
        scanf("%llu %llu", &A, &B);
        if (H[A] > H[B])
        {
            if(yoi[A] != -1){
                yoi[A] = 1;
            }            
            yoi[B] = -1;
        }else if (H[A] < H[B])
        {
            yoi[A] = -1;
            if(yoi[B] != -1){
                yoi[B] = 1;
            }
        }else
        {
            yoi[A] = -1;
            yoi[B] = -1;
        }
        solo[A] = 0;
        solo[B] = 0;
    }

    for (i = 1; i <= N; i++)
    {
        if (yoi[i] == 1 || solo[i] == 1)
        {
            n++;
        }
    }

    printf("%llu", n);
    return 0;
}


Measured memory_bytes: 5400
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ff first
#define ss second
int main(){
	ll n, x, y, ans = 2147483647;
	cin >> n;
	char c;
	map<ll, vector<ll> > m[12];
	for (ll i = 0; i < n; i++){
		cin >> x >> y >> c;
		if (c == 'U'){
			m[0][x].emplace_back(y);
			m[4][x - y].emplace_back(y);
			m[8][x + y].emplace_back(y);
		}else if (c == 'D'){
			m[1][x].emplace_back(y);
			m[7][x - y].emplace_back(y);
			m[11][x + y].emplace_back(y);
		}else if (c == 'L'){
			m[3][y].emplace_back(x);
			m[5][x - y].emplace_back(y);
			m[10][x + y].emplace_back(y);
		}else{
			m[2][y].emplace_back(x);
			m[6][x - y].emplace_back(y);
			m[9][x + y].emplace_back(y);
		}
	}
	for (ll i = 0; i < 12; i += 2){
		for (auto it = m[i].begin(); it != m[i].end(); it++){
			if (m[i + 1].find(it -> ff) == m[i + 1].end()) continue;
			vector<ll> v = it -> ss, w = m[i + 1][it -> ff];
			sort(v.begin(), v.end()), sort(w.begin(), w.end());
			ll p1 = 0, p2 = 0;
			while (p1 < v.size() && p2 < w.size()){
				if (w[p2] < v[p1]) p2++;
				else{
					if (i > 2) ans = min(ans, (w[p2] - v[p1]) * 10);
					else ans = min(ans, (w[p2] - v[p1]) * 5);
					p1++;
				}
			}
		}
	}
	if (ans == 2147483647) printf("SAFE\n");
	else printf("%lld\n", ans);
}

Measured memory_bytes: 69340
#include<iostream>
#include<string>
#include<queue>
using namespace std;

struct TProcess
{
	string Name;
	int    Time;
};

struct TFinished
{
	string Name;
	int    Time;
};

queue<TFinished> RoundRobin(queue<TProcess> Input, int q)
{
	queue<TFinished> Output;
	int TotalTime = 0;
	while(!Input.empty()){
		if(Input.front().Time <= q){
			TotalTime += Input.front().Time;
			TFinished Finished;
			Finished.Name = Input.front().Name;
			Finished.Time = TotalTime;
			Output.push(Finished);
		}else{
			TotalTime += q;
			Input.front().Time -= q;
			Input.push(Input.front());
		}
		Input.pop();
	}
	return Output;
}

int main()
{
	int n, q;
	cin >> n;
	cin >> q;
	queue<TProcess> Input;
	for(int i = 0; i < n; i++){
		TProcess Process;
		cin >> Process.Name >> Process.Time;
		Input.push(Process);
	}
	queue<TFinished> Output = RoundRobin(Input, q);
	while(!Output.empty()){
		cout << Output.front().Name << " " << Output.front().Time << endl;
		Output.pop();
	}
	return 0;
}

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

using namespace std;
using ll =long long;
using db = double;
using vll = vector<long long>;

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; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
#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 leftunique(a) {SORT(a);(a).erase(unique((a).begin(),(a).end()),(a).end());}
//leftuniqueは配列から同じ要素のものを取り除く 例 4 6 2 1 3 4 1 2 なら 1 2 3 4 6 になる
#define debug(x)  cout << #x << " = " << (x) << endl;
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
bool coY() {cout <<"Yes"<<endl;}
bool coN(){cout <<"No"<<endl;}
const int mod = 1e9 + 7;
const ll INF = 1LL << 60;
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//グラフ用
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};	
//ここから書き始める

struct point {ll x ;ll y;} ;
int main()
{
	cout <<setprecision(10);
	ll n; cin >> n;
	vector<point> XY(n);
	rep(i,n) cin >> XY[i].x>>XY[i].y ;
	db nanikore = (n - 1) * 2;
	int nokori = n - 2;
	while(nokori > 0){
		nanikore *= nokori;
		nokori -- ;
	}
	
	db distsum = 0 ;
	int k = n ;
	db waru = 1;
	while(k > 0){
		waru *= k;
		k--;
	}//全部で何通りあるか
	rep(i,n){
		For(j,i+1,n){
			db distx =  pow(abs(XY[i].x-XY[j].x),2);
			db disty = pow(abs(XY[i].y-XY[j].y),2);
			db Di = sqrt(distx+disty) * nanikore ;
			distsum += Di;
		}
	}
	db ans = distsum/ waru ;
	cout << ans<< endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define MOD 10000
int N, K, hoge[101],dp[101][4][4];
int rec(int today,int kino,int oto){ //日付 昨日 一昨日
  if(today == N) return 1;
  if(dp[today][kino][oto]) return dp[today][kino][oto];
  int ret = 0;
  if(hoge[today]){ //決まってるじゃん
    if(hoge[today] == kino && kino == oto) ret = 0;
    else ret = rec(today + 1,hoge[today],kino);
  }else{ //決まってないじゃん
    for(int i = 1 ; i < 4 ; i++ ){
      if(i != kino || kino != oto) ret += rec( today + 1, i, kino);
    }
  }
  return dp[today][kino][oto] = ret % MOD;
}
int main(){
  cin >> N >> K;
  for(int i = 0 ; i < K ; i++ ){
    int day;
    cin >> day;
    cin >> hoge[--day];
  }
  cout << rec(0,0,0) << endl;
}

Measured memory_bytes: 1168
using System;
using System.ComponentModel;
using System.Linq;

namespace ColoringColorfully {
	class Program {
		static void Main(string[] args) {
			var input = Console.ReadLine();
			
			var initial = input[0];
			char oddChar, evenChar;
			if (initial == '0') {
				oddChar = '1';
				evenChar = '0';
			} else {
				oddChar = '0';
				evenChar = '1';
			}
			var result = 0;
			for (int index = 0; index < input.Length; index++) {
				if (index % 2 == 0) {
					if (input[index] != evenChar) {
						result++;
					}
				} else {
					if (input[index] != oddChar) {
						result++;
					}
				}
			}
			Console.WriteLine(result);
		}
	}

	public static class Helper<T> {
		public static T[] Read(int count) {
			var result = new T[count];
			for (int index = 0; index < count; index++) {
				result[index] = (T)TypeDescriptor.GetConverter(typeof(T)).ConvertFromString(Console.ReadLine());
			}
			return result;
		}

		public static T[] ReadLine() {
			var input = Console.ReadLine();
			var inputs = input.Split(' ');
			var result = new T[inputs.Count()];
			for (int index = 0; index < inputs.Count(); index++) {
				result[index] = (T)TypeDescriptor.GetConverter(typeof(T)).ConvertFromString(inputs[index]);
			}
			return result;
		}
	}
}


Measured memory_bytes: 13144
/*input
2
10 10
*/
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define pb push_back
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define mpr make_pair
#define MX 1000000007
#define ui unsigned int
#define ll long long
#define ld long double
#define fi first
#define se second
#define testcases int testcases;cin>>testcases;while(testcases--)
#define printvector(v) for(int i=0;i<v.size();i++) cout<<v[i]<<" ";  cout<<endl
#define printarray(v,n)  for(int i=0;i<n;i++) cout<<v[i]<<" ";  cout<<endl
#define inputarray(v,n)  for(int i=0;i<n;i++)cin>>v[i]
#define debug(i) cout<<"debug: "<<i<<endl
#define pr(i) cout<<i<<endl
#define timetaken cerr<<clock()/double(CLOCKS_PER_SEC)<<endl
#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define toDigit(a) (a-'0')
ll powmod(ll base,ll exp,ll MOD){ll res=1;while(exp>0){if(exp%2==1) res=(res*base)%MOD;base=(base*base)%MOD;exp/=2;}return (res%MOD);}
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }



int cal(vector<int>&a, int n){
    vector<int>dp(n+1,0);
    dp[2] = abs(a[0]-a[1]);

    for(int i=3;i<=n;++i){
        dp[i] = min(dp[i-1] + abs(a[i-1]-a[i-2]),dp[i-2] + abs(a[i-1]-a[i-3]));
    }
    return dp[n];
}

int main() {
    fast_io;
    int n;
    cin>>n;
    vector<int>a(n); inputarray(a,n);
    pr(cal(a,n));
    return 0;
}

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

int main() 
{ 
   string s;
   cin>>s;
   sort(s.begin(),s.end());
   if(s[0]==s[2])
   {
       cout<<"No"<<endl;
   }
   else {
       cout<<"Yes"<<endl;
   }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
	
signed main(){
	ll n, i, j;
	cin >> n;
	ll cost[n+1];
	for( i = 1 ; i <= n ; i++ )
		cin >> cost[i];
	ll dp[n+1];
	dp[0] = 0;
	dp[1] = 0;
	dp[2] = abs(cost[2] - cost[1]);
	for( i = 3 ; i <= n ; i++ ){
		dp[i] = min( dp[i-2] + abs(cost[i] - cost[i-2]) , dp[i-1] + abs(cost[i] - cost[i-1]) );
	}
	cout << dp[n] << endl;
	return 0;
}

Measured memory_bytes: 1792
#include<stdio.h>
int main(){
  int a=-1,b,c;
  while(a<0 || 100<c){
    scanf("%d%d%d",&a,&b,&c);
  }
  if(a<b && b<c) printf("Yes\n");
  else printf("No\n");
  return 0;
}

Measured memory_bytes: 580
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
#include<map>
#include<stack>
#include<set>
#include<utility>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
typedef pair<ll,ii> P;
typedef unsigned long long int ull;
const int MOD=1e9+7;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
const int MAXN=100000;
const int MAXE=100000;
const int MAXV=10000;
const ll INF=2e9;

int main(){
    int h,w,k;cin>>h>>w>>k;
    char c[h][w];
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>c[i][j];
        }
    }
    int ans=0;
    for(int bh=0;bh<(1<<h);bh++){
        for(int bw=0;bw<(1<<w);bw++){
            int cnt=0;
            for(int i=0;i<h;i++){
                for(int j=0;j<w;j++){
                    if(c[i][j]=='#'&&((bh>>i)&1)&&((bw>>j)&1)){
                        cnt++;
                    }
                }
            }
            if(cnt==k) ans++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3620
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        
        String input = Integer.toString(a) + Integer.toString(b);
        int value = Integer.parseInt(input);
        double sqrt = Math.floor(Math.sqrt(value));
        
        if(value == Math.pow(sqrt, 2)){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 21716
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

string rev(string x) {
  reverse(all(x));
  return x;
}

void solve() {
  int n;
  cin >> n;
  while (n--) {
    string w;
    cin >> w;
    set<string> p;
    rep(i, w.size() - 1) {
      string s = w.stlice(0, i), t = w.stlice(i + 1, w.size() - 1);
      p.insert(s + t);
      p.insert(rev(s) + t);
      p.insert(s + rev(t));
      p.insert(rev(s) + rev(t));
      p.insert(t + s);
      p.insert(rev(t) + s);
      p.insert(t + rev(s));
      p.insert(rev(t) + rev(s));
    }
    cout << p.size() << endl;
  }
}

Measured memory_bytes: 3232
n, d = map(int,input().split())
x = [list(map(int,input().split())) for i in range(n)]
cnt = 0
for i in range(n - 1):
    for j in range(i + 1, n):
        dis = 0
        for k in range(d):
            dis += (x[i][k] - x[j][k]) ** 2
            #print(x[i][k], x[j][k])

        temp = int(dis ** 0.5)
        if temp ** 2 == dis:
            cnt += 1
print(cnt)

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}

struct UF{
	vector<int> p;
	UF() {}
	UF(int n) : p(n, -1) {}
	int find(int a){ return p[a] < 0 ? a : p[a] = find(p[a]); }
	bool unite(int a, int b) {
		a = find(a); b = find(b);
		if(a == b) return false;
		if(-p[a] < -p[b]) swap(a, b);
		p[a] += p[b]; p[b] = a;
		return true;
	}
	bool same(int a, int b){ return find(a) == find(b); }
};

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n, m;
	cin >>n >>m;
	VI p(n);
	rep(i, n){ cin >>p[i]; p[i]--;}
	UF ufa(n);
	rep(i, m){
		int x, y;
		cin >>x >>y;
		ufa.unite(x-1, y-1);
	}
	int ans = 0;
	rep(i, n){
		if(ufa.same(i, p[i])) ans++;
	}
	cout <<ans <<"\n";
	return 0;
}


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

int main(){
  int n;
  string s;
  cin >> n;
  cin >> s;
  int count = 0;
  int max_sum = 0;
  rep(i, n){
    if (s[i] == 'I') {
      count++;
    }
    else if (s[i] == 'D') {
      count--;
    }
    max_sum = max(max_sum, count);
  }
  
  cout << max_sum << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int a[4];

int main() {
  int n, m;
  cin >> n >> m;
  int x = 0;
  while (m--){
    int s, c;
    cin >> s >> c;
    if ((s == 1 and c == 0) and n >= 2) //nu se poate ca prima cifra sa fie 0
      x = -1;
    if (x == 0){
      if (a[s] != 0 and a[s] != c) //nu e voie sa se schimbe valoarea cifrei de pe pozitia s
        x = -1;
      else
        a[s] = c;
    }
   }
   if (x == -1) {
     cout << x;
     return 0;
   }
   if (a[1] == 0 and n >= 2) {
     cout << 1;
     for (int i = 2; i <= n; i++)
       cout << a[i];
       return 0;
     }
  for (int i = 1; i <= n; i++)
    cout << a[i];
  return 0;
}


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
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;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}
struct edge {
  ll to, cost;
};

int main() {
  int a; cin >> a;
  int ans = a + pow(a, 2) + pow(a, 3);
  cout << ans << endl;
}

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

using namespace std;

bool is_prime(long long x){
    if(x == 2)
        return true;
    if(x % 2 == 0)
        return false;
    for(long long a=3; a*a<=x; a+=2){
        if(x%a == 0)
            return false;
    }
    return true;
}

int main(void){

    long long x;

    cin >> x;

    long long ans = 0;

    while(!is_prime(x)){
        x++;
    }

    cout << x << endl;

    return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
problems = [0] * N
miss = 0
for i in range(M):
  p, S = input().split()
  p = int(p)
  if problems[p - 1] != "AC":
    if S == "WA":
      problems[p - 1] += 1
    elif S == "AC":
      miss += problems[p - 1]
      problems[p - 1] = "AC"
ans = sum([1 for i in problems if i == "AC"])
print(ans, miss)

Measured memory_bytes: 4632
#include<algorithm>
#include<iostream>
#include<cstring>
#include<string>
#include<vector>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
const int MAXN=1e5+5;
int read()
{
    int s=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){s=s*10+ch-'0';ch=getchar();}
    return s*f;
}
int main()
{
    ll x;
    while(cin>>x)
    {
        double p=x*1.0/3;
        printf("%.6lf\n",p*p*p);
    }
    return 0;
}


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

int main() {
  int n, k;
  vector<int> a;

  cin >> n >> k;
  for (int j = 0; j < n; j++) {
    int tmp;
    cin >> tmp;
    a.push_back(tmp);
  }

  for (int i = k; i < n; i++) {
    if (a[i] > a[i - k]) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 4316
import re
S = input()

flag = 0
if S[0] == "A":
    for i in S[2:-1]:
        if i == "C":
            flag += 1
    if flag == 1:
        if len(re.findall(r'[A-Z]',S)) == 2:
            print("AC")
            quit()
print("WA")


Measured memory_bytes: 3188
from collections import deque
N = int(input())
A = []
for i in range(N):
    A.append(int(input()))
A.sort()
Aup = deque(A)
Adown = deque(A)
up = deque([])
down = deque([])
up.append(Aup.pop())
down.append(Adown.popleft())

i = 0
while True:
    for i in range(2):
        if i % 2 == 0:
            if up[0] > up[-1]:
                up.appendleft(Aup.popleft())
            else:
                up.append(Aup.popleft())

            if down[0] < down[-1]:
                down.appendleft(Adown.pop())
            else:
                down.append(Adown.pop())

        else:
            if up[0] < up[-1]:
                up.appendleft(Aup.pop())
            else:
                up.append(Aup.pop())

            if down[0] > down[-1]:
                down.appendleft(Adown.popleft())
            else:
                down.append(Adown.popleft())

        if len(Aup) == 0:
            break
    if len(Aup) == 0:
        break
    i += 1
upans = 0
downans = 0
up = list(up)
down = list(down)
for i in range(1,N):
    upans += abs(up[i] - up[i-1])
    downans += abs(down[i] - down[i-1])
print(max(upans,downans))


Measured memory_bytes: 83824
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <functional>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <iomanip>
#if __cplusplus >= 201103L
#include <unordered_map>
#include <unordered_set>
#endif
#define ls x<<1
#define rs x<<1|1
#define fi first
#define se second
#define ll long long
#define pb push_back
#define mp make_pair
#define fun function
#define vi vector<int>
#define lowbit(x) x&(-x)
#define pii pair<int,int>
#define all(x) x.begin(),x.end()
#define mem(a,b) memset(a,b,sizeof(a))
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);

using namespace std;

const int INF = 0x3f3f3f3f;


int main() {
	IOS;
#ifdef xiaofan
	freopen("1.in","r",stdin);
	freopen("1.out","w",stdout);
#endif

	int a,b;
	cin>>a>>b;
	if(a<10)
		b=b+100*(10-a);
	cout<<b<<endl; 




	return 0;
}



Measured memory_bytes: 256
/*
Template for vjudge.net

	Author: Iqbal Hossain Rasel
	CodeForces: The_Silent_Man
	AtCoder   : IHR57
	TopCoder  : IHR57

*/
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define PI acos(-1)
#define pi 3.1415926535897932384
#define INF 2147483647
#define EPS 1e-8
#define MOD 1000000007
#define MAX 100005
using namespace std;

typedef long long ll;

int Set(int mask, int pos){return mask = mask | (1<<pos);}
bool check(int mask, int pos){return (bool)(mask & (1<<pos));}

ll arr[MAX], dp[MAX];

int main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    #ifdef ONLINE_JUDGE
    	freopen("input.txt", "r", stdin);
    	freopen("output.txt", "w", stdout);
    #endif
    int n, m;

    cin>>n>>m;

    map<ll, ll> mp;

    ll sum = 0;
    mp[0]++;
    for(int i = 1; i <= n; i++){
        cin>>arr[i];
        sum += (ll) arr[i];
        dp[i] = dp[i-1] + mp[sum % m];
        mp[sum % m]++;
    }

    cout<<dp[n]<<endl;

    return 0;
}


Measured memory_bytes: 5760
#include <iostream>
using namespace std;
int main(void)
{
    int i, j, k, l, m, n;
    cin >> n >> m >> l;
    int A[n][m], B[m][l];
     
    for(i = 0; i < n; i++){
        for(j = 0; j < m; j++){
            cin >> A[i][j];
        }
    }
    for(i = 0; i < m; i++){
        for(j = 0; j < l; j++){
        cin >> B[i][j];
        }
    }
    for(i = 0; i < n; i++){
        long int multip;
        for(j = 0; j < l; j++){
            multip = 0;
            for(k = 0; k < m; k++){
            multip += A[i][k] * B[k][j];
            }
            if(j == l-1) break;
            cout << multip << ' ';
        }
        cout << multip << endl;
    }
}


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

int main(){
  int n;
  cin >> n;
  vector<int> d(n);
  rep(i,n) cin >> d[i];
  int res = 0;
  for (int i = 0; i < n-1 ; i++) {
    for (int j = i+1; j < n ; j++) {
      res += d[i] * d[j];
    }
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
package main

import (
    "fmt"
)

func main() {
    var a, b, sum int
	fmt.Scan(&a, &b)

	// 1st try
	if a > b {
		sum = a
		a--
	} else {
		sum = b
		b--
	}
	
	// 2nd try
	if a > b {
		sum += a
	} else {
		sum += b
	}

	fmt.Println(sum)
}


Measured memory_bytes: 512
// ABC 151-C
// 2020.1.12 bal4u

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

#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif

int in() {   // 非負整数の入力
	int n = 0; int c;
	do c = gc();
	while (isspace(c));
	do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0');
	return n;
}

int WA[100005];
int AC, NG;

int main()
{
	int p, N, M, S;
	
	N = in(), M = in();
	while (M--) {
		p = in(), S = gc(), gc(), gc();
		if (S == 'A') {
			if (WA[p] >= 0) {
				++AC;
				NG += WA[p];
				WA[p] = -1;
			}
		} else {
			if (WA[p] >= 0) ++WA[p];
		}
	}
	printf("%d %d\n", AC, NG);
	return 0;
}


Measured memory_bytes: 512
line = raw_input()
A, B, C, D = line.split()
A = int(A)
B = int(B)
C = int(C)
D = int(D)


if C > B:
    print 0
elif A > D:
    print 0
elif A > C:
    if B > D:
        print D - A
    else:
        print B - A
else:
    if B > D:
        print D - C
    else:
        print B - C 


Measured memory_bytes: 2568
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; i++)
#define all(a) (a).begin(), (a).end()

ll X, Y;

int main () {
  cin >> X >> Y;

  int ans = 0;
  while(X <= Y) {
    X *= 2LL;
    ans++;
  }

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


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

int main() {
    int n, k;
    cin >> n >> k;
    int l[n];
    for (int i = 0; i < n; i++) {
        cin >> l[i];
    }
    partial_sort(l, l + k, l + n, greater<int>() );
    cout << accumulate(l, l + k, 0) << endl;
    return 0;
}

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

int main() {
  int H, W, i;
  cin >> H >> W;
  vector<string> row(H);
  
  //画像の受け取り
  for (i = 0;i < H;i++) {
    cin >> row.at(i);
  }
  
  //＃の出力
  for (i = 0;i < W + 2;i++) {
    cout << "#";
  }
  cout << endl;
  //画像の出力
  for (i = 0;i < H;i++) {
    cout << "#" << row.at(i) << "#" << endl;
  }
  
  for (i = 0;i < W + 2;i++) {
    cout << "#";
  }
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

class Program
{
  static void Main(string[] args)
  {
    var p = Console.ReadLine().Split(' ');
    long A = long.Parse(p[0]);
    long B = long.Parse(p[1]);

  if ( A<=8 && B<=8){
    Console.WriteLine("Yay!");
  }else{
    Console.WriteLine(":(");
  }

  }
}


Measured memory_bytes: 11092
import sys
import os
import math
import string

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: x * y / math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    A, B, C = il()
    print(max(0, C - (A - B )))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3896
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <tuple>
#include <utility>
#define MAX_N 1010
#define LIMIT 1000010
#define CENTER 501
using namespace std;
const int dy[] = {0, -1, 0, 1};
const int dx[] = {1, 0, -1, 0};
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef struct res
{
    int id, num, last;
} table_t;
table_t table[MAX_N][MAX_N];
bool isPrime[LIMIT];
int sy, sx, n, m;
void make_prime()
{
    fill(isPrime, isPrime + LIMIT, true);
    isPrime[0] = isPrime[1] = false;
    for (int i = 2; i * i < LIMIT; i++)
    {
        if (!isPrime[i])
            continue;
        for (int j = i * 2; j < LIMIT; j += i)
            isPrime[j] = false;
    }
}
void init_table()
{
    for(int i = 0; i < MAX_N; i++)
    {
        for(int j = 0; j < MAX_N; j++)
        {
            table[i][j].id = table[i][j].last = 0;
            table[i][j].num = -1;
        }
    }
}
void make_cave()
{
    int dir = 0, ok = 1, cnt = 0, flag = 0;
    int y, x;
    y = x = MAX_N / 2;
    for (int i = 1; i <= m; i++)
    {
        if (i == n)
        {
            sy = y;
            sx = x;
        }
        table[y][x].id = i;
        //dp[y][x].second = i;
        y += dy[dir];
        x += dx[dir];
        cnt++;
        if (cnt == ok)
        {
            dir = (dir + 1) % 4;
            flag++;
            cnt = 0;
            if (flag == 2)
            {
                flag = 0;
                ok++;
            }
        }
    }
}
table_t dfs(int y, int x)
{
    table_t ret;
    int id, num, last;
    if(table[y][x].id == 0)
    {
        ret.id = ret.num = ret.last = 0;
    }
    else if(table[y][x].num >= 0)
        ret = table[y][x];
    else
    {
        num = last = 0;
        id = table[y][x].id;
        for(int i = -1; i <= 1; i++)
        {
            ret = dfs(y + 1, x + i);
            if(ret.num > num)
            {
                num = ret.num;
                last = ret.last;
            }
            else if(ret.num == num)
            {
                last = max(ret.last, last);
            }
        }
        if(isPrime[id])
        {
            if(num == 0)
                last = id;
            num++;
        }
        ret.id = id;
        ret.num = num;
        ret.last = last;
        table[y][x] = ret;
    }
    return ret;
}
int main()
{
    make_prime();
    while (cin >> m >> n, n | m)
    {
        //memset(dp, -1, sizeof(dp));
        init_table();
        //memset(visit, false, sizeof(visit));
        make_cave();
        table_t ans = dfs(sy, sx);
        /*
        for(int i = MAX_N / 2 - 20; i < MAX_N / 2 + 20; i++)
        {
            for(int j = MAX_N / 2 - 20; j < MAX_N / 2 + 20; j++)
                printf("%5d", table[i][j].last);
            cout << endl;
        }
        */
        cout << ans.num << " " << ans.last << endl;
    }
    return 0;
}



Measured memory_bytes: 16144
//#pragma GCC optimize("O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
//#pragma GCC optimize ("unroll-loops")
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using ld = long double;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n, k;
    cin >> n >> k;
    vector<ll> a(n);
    ll tot = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        tot += a[i];
    }
    ll ans = 1;
    vector<ll> d;
    for (ll i = 1; i * i <= tot; i++) {
        if (tot % i == 0) {
            d.push_back(i);
            if (i != tot / i) {
                d.push_back(tot / i);
            }
        }
    }
    for (ll i : d) {
        vector<pair<ll, ll>> b(n);
        ll sum = 0;
        for (int j = 0; j < n; j++) {
            b[j].first = a[j] % i;
            b[j].second = (i - b[j].first) % i;
            sum += b[j].second;
        }
        sort(b.begin(), b.end());
        ll kek = 0;
        for (int j = 0; j < n; j++) {
            kek += b[j].first;
            sum -= b[j].second;
            if (kek >= sum) {
                break;
            }
        }
        if (max(kek, sum) <= k) {
            ans = max(ans, i);
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 384
# -*- coding: utf-8 -*-
O = input()
E = input()


ans = ''
for i in range(len(O) - 1):
    ans += O[i]
    ans += E[i]

ans += O[len(O) - 1]
  
if len(E) == len(O): 
    ans += E[len(O) - 1]
    
print(ans)

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

namespace IO
{
char gc()
{
#ifdef FREAD
	static char buf[1<<21], *P1 = buf, *P2 = buf;
	if(P1 == P2)
	{
		P1 = buf;
		P2 = buf + fread(buf, 1, 1<<21, stdin);
		if(P1 == P2) return EOF;
	}
	return *(P1++);
#else
	return getchar();
#endif
}
template<typename Tp> bool get1(Tp &x)
{
	bool neg = 0;
	char c = gc();
	while( c != EOF && (c < '0' || c > '9') && c != '-' ) c = gc();
	if(c == '-') c = gc(), neg = 1;
	if(c == EOF) return false;
	x = 0;
	for(; c>='0' && c<='9'; c = gc()) x = x*10 + c - '0';
	if(neg) x = -x;
	return true;
}
template<typename Tp> void printendl(Tp x)
{
	if(x<0)putchar('-'),x=-x;
	static short a[40], sz;
	sz = 0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
	puts("");
}
} // namespace IO
using IO::get1;
using IO::printendl;
#define get2(x,y) get1(x) && get1(y)
#define get3(x,y,z) get2(x,y) && get1(z)
#define get4(x,y,z,w) get3(x,y,z) && get1(w)
#define pb push_back
#define mp std::make_pair
#define ff first
#define ss second
typedef long long LL;
typedef unsigned long long uLL;
typedef std::pair<int,int> pii;
const int inf = 0x3f3f3f3f;
const LL Linf = 1ll<<61;

const int maxn = 211;
int n, k, mod;

int fac[maxn], invf[maxn], c[maxn][maxn];
int qpow(int x, int y)
{
	int ret = 1;
	while(y)
	{
		if(y & 1) ret = 1ll * ret * x % mod;
		x = 1ll * x * x % mod;
		y >>= 1;
	}
	return ret;
}

int calc(int n, int k)
{
	if(k < 0) return 0;
	if(n == 0) return 1;
	if(n < 3) return 0;
	
	int ret = 0;
	for(int L=2; L<n; L++)
	{
		int R = n - L;
		static int dp[maxn][maxn];
		memset(dp, 0, sizeof(dp));
		
		dp[0][0] = 1;
		for(int i=0; i<=L; i++) for(int j=0; j<=R; j++)
		{
			if(j+1 <= R)
			{
				int ind = L - i + j;
				if(ind > 0 && ind <= k)
				{
					dp[i][j+1] += dp[i][j];
					if(dp[i][j+1] >= mod) dp[i][j+1] -= mod;
				}
			}
			if(i+1 <= L)
			{
				int ind = R - j + i;
				if(ind > 0 && ind <= k && (i < L - 1 || j == R))
				{
					dp[i+1][j] += dp[i][j];
					if(dp[i+1][j] >= mod) dp[i+1][j] -= mod;
				}
			}
		}
		ret += dp[L][R];
		if(ret >= mod) ret -= mod;
	}
	ret = 1ll * ret * fac[n-1] % mod;
	return ret;
}

int main()
{
	get3(n, k, mod);
	
	fac[0] = invf[0] = 1;
	for(int i=1; i<maxn; i++)
	{
		fac[i] = 1ll * i * fac[i-1] % mod;
		invf[i] = qpow(fac[i], mod - 2);
	}
	for(int i=0; i<maxn; i++)
	{
		c[i][0] = 1;
		for(int j=1; j<=i; j++)
		{
			c[i][j] = c[i-1][j] + c[i-1][j-1];
			if(c[i][j] >= mod) c[i][j] -= mod;
		}
	}
	
	if(k == n - 1) k = n;
	
	int ans = 0;
	for(int i=0; i<=n; i++) ans = (ans + 1ll * fac[n] * invf[n-i] % mod * calc(n - i, k - i)) % mod;
	printendl(ans);
	return 0;
}

Measured memory_bytes: 3988
#include <bits/stdc++.h>
using namespace std;
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define int long long
const int INF = 1e18, MOD = 1e9 + 7;
signed main() {
    int a, b;
  cin>>a>>b;
  cout<<a*b<<endl;
}


Measured memory_bytes: 3632
import sys
def input(): return sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**6)
memo=dict()
def rec(v):
    if v in memo:return memo[v]
    res=0
    for nv in graph[v]:
        res=max(res,rec(nv)+1)
    memo[v]=res
    return res
def main():
    n,m=map(int,input().split())
    XY=[tuple(map(int,input().split())) for i in range(m)]
    global graph
    graph=[[]for _ in range(n)]
    for x,y in XY:
        graph[x-1].append(y-1)
    ans=0
    for v in range(n):
        ans=max(ans,rec(v))
    print(ans)

if __name__=='__main__':
    main()

Measured memory_bytes: 152456
#include <iostream>

using namespace std;
int N,M,K;
int main() {
	cin >> N >> M >> K;
	for(int i=0;i<=N;i++) {
		for(int j=0;j<=M;j++) {
			if(i*j+(N-i)*(M-j)==K) {
				cout << "Yes" << endl;
				return 0;
			}
		}
		
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#define N 9
using namespace std;
int solver(int n, int s, int t){	//t??\????????°n?????§s?????????????????????????????°
	if(n == 0 || s < 0 || t > N) return 0;
	if(n == 1 && s == t) return 1;
	return solver(n-1, s-t, t+1) + solver(n, s, t+1);
}
int main(){
	int n, s;
	while(cin >> n >> s, n){
		cout << solver(n, s, 0) << endl;
	}
	return 0;
}

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

using namespace std;

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

	int n;
	cin >> n;

	if(n % 2 == 0) {
		cout << 1/2.0;
	}
	else {
		cout << (n/2+1)/(1.0*n);
	}

	return 0;
}

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

int main() {
  vector<char> s(3);
  for(int i=0; i<3; i++)
    cin >>s.at(i);
  int N=0;
  for(int i=0; i<3; i++){
    if(s.at(i)=='1')
      N++;
  }
  cout <<N <<endl;
}


Measured memory_bytes: 256
n = int(input())
L = list(map(int,input().split()))
cnt = 0
for i in range(n-2):
    for j in range(i+1,n-1):
        for k in range(j+1,n):
            if L[i] + L[j] > L[k] and L[k] + L[i] > L[j] and L[j] + L[k] > L[i] and L[i] != L[j] and L[i] != L[k] and L[j] != L[k]:
                
                cnt += 1
print(cnt)

Measured memory_bytes: 9200
IDENTIFICATION DIVISION.
PROGRAM-ID. PROGRAM_ID.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 LN         PIC X(21).
01 S          PIC X(10).
01 T          PIC X(10).
01 U          PIC X(10).
01 A          PIC 9(2).
01 B          PIC 9(2).
01 ZA         PIC Z9.
01 ZB         PIC Z9.

PROCEDURE DIVISION.
  ACCEPT LN.
  UNSTRING LN DELIMITED BY SPACE INTO S T.
  ACCEPT LN.
  UNSTRING LN DELIMITED BY SPACE INTO A B.
  ACCEPT U.
  IF S = U
      ADD -1 TO A
  ELSE
      ADD -1 TO B
  END-IF.
  MOVE A TO ZA.
  MOVE B TO ZB.
  DISPLAY ZA ZB.


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  bool ok = 0;
  for (int i = 0; i < s.size(); i++){
    if (s[i] == 'C' && ok == 0)
      ok = 1;
    if (ok == 1 && s[i] == 'F'){
      cout << "Yes\n";
      return 0;
  }
  }
  cout << "No\n";
  
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Random;
import java.util.Arrays;
import java.util.Comparator;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.HashMap;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		
		int[] s = new int[9];
		
		for (int i = 0; i < 9; i++) {
			s[i] = sc.nextInt();
			
		}
		
		if (s[0] + s[4] + s[8] == s[1] + s[5] + s[6] && s[1] + s[5] + s[6] == s[2] + s[3] + s[7]) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
		
}
	
	


Measured memory_bytes: 23764
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN=200000;

int n;
int p[MAXN];
vector<int> out[MAXN];

int outdeg[MAXN];
int q[MAXN],qhead,qtail;

int mark[MAXN];
int a[MAXN];


void run() {
	scanf("%d",&n); REP(i,n) scanf("%d",&p[i]),--p[i];
	REP(i,n) out[i].clear(); REP(i,n) out[p[i]].PB(i);

	REP(i,n) outdeg[i]=0; REP(i,n) ++outdeg[p[i]];
	qhead=qtail=0; REP(i,n) if(outdeg[i]==0) q[qhead++]=i;
	REP(i,n) mark[i]=a[i]=-1;
	while(qtail<qhead) {
		int at=q[qtail++];
		REPSZ(i,out[at]) { int to=out[at][i]; mark[a[to]]=at; }
		a[at]=0; while(mark[a[at]]==at) ++a[at];
		if(--outdeg[p[at]]==0) q[qhead++]=p[at];
	}
	//printf("A:"); REP(i,n) { if(outdeg[i]==0) printf(" %d",a[i]); else printf(" (%d)",p[i]); } puts("");

	REP(at,n) if(outdeg[at]!=0) {
		REPSZ(i,out[at]) { int to=out[at][i]; if(outdeg[to]!=0) continue; mark[a[to]]=at; }
		a[at]=0; while(mark[a[at]]==at) ++a[at];
	}
	//printf("B:"); REP(i,n) { if(outdeg[i]==0) printf(" %d",a[i]); else printf(" (%d)",a[i]); } puts("");

	int onlya=-1,nrem=0; bool asame=true; REP(at,n) if(outdeg[at]!=0) { ++nrem; if(onlya==-1||a[at]==onlya) onlya=a[at]; else asame=false; }
	printf("%s\n",!asame||nrem%2==0?"POSSIBLE":"IMPOSSIBLE");
}

int main() {
	run();
	return 0;
}


Measured memory_bytes: 13696