akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))

ll a[10010];
ll b[10010];
int main(){
	ll n;
	scanf("%lld",&n);
	rep(i,0,n)scanf("%lld",a+i);
	rep(i,0,n)scanf("%lld",b+i);
	ll s=0,cnt=0;
	rep(i,0,n){
		s+=b[i]-a[i];
		cnt+=max(0,(b[i]-a[i]+1)/2);
	}
	puts(cnt<=s?"Yes":"No");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define x first
#define pb push_back
#define y second
const int NMAX=100666;
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;

int a,b;

int main()
{
    //freopen("input.in", "rt", stdin);
    cin>>a>>b;
    if(a<=0 && b>=0){
        cout<<"Zero";
        return 0;
    }
    else
    {
        if(b<0){
            if((b-a+1)%2)
                cout<<"Negative";
            else
                cout<<"Positive";
        }
        else
            cout<<"Positive";
    }


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define int long long int



main() {
	string s;
	cin>>s;
	int last=2;
	int ans=0;
	int i=0;
	while(i<s.size()){
		if(last==2){
			i++;
			last=1;
			ans++;
			continue;
		}
		if(last==1){
			if(s[i]==s[i-1] && i==s.size()-1){
				i++;
				i++;
				continue;
			}
			if(s[i]==s[i-1]){
				last=2;
				i++;
				i++;
				ans++;
				continue;
			}
			else{
				last=1;
				i++;
				ans++;
				continue;
			}
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3708
#include <iostream>
#include <cstdlib>
#include <string>

unsigned long int amari(int N, int wari){
if (N == 1){
return 1;
}

unsigned long int tmp = N*amari(N-1, wari);

return tmp%wari;
}

int main(){
std::string line;
std::getline(std::cin, line);
int N = atoi(line.c_str());

std::cout << amari(N, 1000000000+7) << std::endl;

return 0;
}

Measured memory_bytes: 3328
a,b,c,k=map(int,raw_input().split())
ans=0
if a<=k:
	ans+=a
	k-=a
else:
	ans=k
	k=0
if k!=0:
	if b<=k:
		k-=b
	else:
		k=0
if k!=0:
	if c<=k:
		ans-=c
	else:
		ans-=k
print ans

Measured memory_bytes: 84172
c1 = list(map(int,input().split()))
c2 = list(map(int,input().split()))
c3 = list(map(int,input().split()))


for a in range(0,101):
    for b in range(0,101):
        for c in range(0,101):
                        a1 = a
                        a2 = b
                        a3 = c
                        b1 = c1[0] - a1
                        b2 = c1[1] - a1
                        b3 = c1[2] - a1
                        if a1 + b1 == c1[0] and a1 +b2 == c1[1] and a1 + b3 ==c1[2] \
                            and a2 + b1 == c2[0] and a2 +b2 == c2[1] and a2 + b3 ==c2[2] \
                                and a3 + b1 == c3[0] and a3 +b2 == c3[1] and a3 + b3 ==c3[2]:
                                print("Yes")
                                exit()
print("No")


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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

const ll MOD = 1000000007;

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

  int N;
  cin >> N;
  string S1, S2;
  cin >> S1 >> S2;

  vector<int> op;
  for(int i = 0; i < S1.length(); i++){
    if(S1[i] != S2[i]){
      op.push_back(1);
      i++;
    }else{
      op.push_back(0);
    }
  }

  ll ans;
  if(op[0] == 0){
    ans = 3;
  }else{
    ans = 6;
  }

  for(int i = 0; i + 1 < op.size(); i++){
    if(op[i] == 0 && op[i+1] == 0){
      ans = (ans * 2) % MOD;
    }else if(op[i] == 0 && op[i+1] == 1){
      ans = (ans * 2) % MOD;
    }else if(op[i] == 1 && op[i+1] == 1){
      ans = (ans * 3) % MOD;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using P = pair<int,int>;

int main()
{
  int N,K;
  cin >> N >> K;
  vector<int> A(N);
  REP(i, N) cin >> A[i];
  sort(ALL(A));
  reverse(ALL(A));
  ll ans = 0;
  FOR(i,K,N){
    ans+=A[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 3976
#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
#define idfc ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
//:/
#define pb push_back
#define mp make_pair
#define nt _ll128
#define ld long double
long double PI =3.14159265358979323846;
using ll = long long;



const ll modo=1e9+7;
const ll inf=1e17;
const ll ms=(5e5)+5;


int ar[10][10];
int cost[10];


void go(int v,int c)
{
    cost[v]=c;
    for(int i=0;i<=9;i++)
    {
        if(cost[i]>(c+ar[i][v]))
        {
            go(i,c+ar[i][v]);
        }
    }
}


int main()
{
    idfc;

    int r,c;
    cin>>r>>c;
    int i,j;
    for(i=0;i<=9;i++) { for (j = 0; j <= 9; j++){cin >> ar[i][j];} }

    for(i=0;i<=9;i++)cost[i]=INT_MAX;
    go(1,0);
   // for(i=0;i<=9;i++)cout<<cost[i]<<"\n";
    int ans=0;

    r*=c;

    while(r--)
    {
        cin>>i;
        if(i!=-1)ans+=cost[i];
    }
    cout<<ans;

    return 0;
}

Measured memory_bytes: 3592
// g++ macro.cpp -std=c++14
#include <bits/stdc++.h> //STL include
typedef long long ll;// long long int
const ll INF = 10000000000;//INFinity
using namespace std;//namespace

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}//transform
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//#define int long long // yabai

#define dump(x)  cout << #x << " = " << (x) << endl;// debug cout

#define FOR(i,a,b) for(int i=(a);i<(b);++i)// for macro
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define ALL(obj) (obj).begin(),(obj).end()// iterator

#define pb(a) push_back(a)//push_back
#define mp make_pair// make_pair


int main(){

    int n,y;
    cin>>n>>y;
    
    int a,b,c;

    y/=1000;

    int sum=0;
    REP(i,n+1){
        for(int j=0;i+j<=n;++j){
            sum=i*4+j*9;
            if(n+sum==y){cout<<j<<" "<<i<<" "<<n-i-j<<endl;return 0;}
            if(n+sum>y)break;
        }
    }

    cout<<"-1 -1 -1"<<endl;




    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define forn(i, n) for (ll i = 0; i < (n); i++)
#define fori(i, b, e) for (ll i = (b); i < (e); i++)
#define forr(i, b, e) for (ll i = (b); i >= (e); i--)
#define allele(v) v.begin(), v.end()
#define fi first
#define se second
#define Mat vector<vector<ll>>
#define Arr vector<ll>

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    long double a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << (a * b / 2) << ' ' << (c * 2 == a && d * 2 == b);
    return 0;
}

Measured memory_bytes: 256
# include<cstdio>

int main(void)
{
	int r, g, b;
	while(scanf("%d%d%d", &r, &g, &b) == 3)
	{
		int sum;
		sum = r*100 + g*10 + b;
		if(sum % 4 == 0)
			printf("YES\n");
		else
			printf("NO\n");
	}
	return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
int fib[45];
int main(){
int n,i;
for(i=0;i<45;i++)fib[i]=-1;
scanf("%d",&n);
printf("%d\n",f(n));
return 0;
}
int f(int n){
if(n==0) return fib[n] = 1;
else if(n==1) return fib[n] = 1;
if(fib[n]!=-1) return fib[n];
return fib[n]= f(n-1)+f(n-2);
}



Measured memory_bytes: 2108
#include<cstdio>
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<queue>

using namespace std;

#define reps(i,f,n) for(int i=f;i<int(n);i++)
#define rep(i,n) reps(i,0,n)

int main()
{
	string s;
	cin>>s;
	
	int st = 0;
	int en = s.size()-1;
	
	bool ok = false;
	int ans = 0;
	
	while(1)
	{
		if(st>=en){
			ok=true;
			break;
		}
		
		if(s[st]!=s[en])
		{
			if(s[st]=='x'){
				st++;
				ans++;
			}else if(s[en]=='x'){
				en--;
				ans++;
			}else
			{
				break;
			}
		}else
		{
			st++;
			en--;
		}
	}
	
	if(!ok) ans = -1;
	
	printf("%d\n",ans);
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string str;
  cin>>str;
  int ans;
  ans=0;
  if(str.at(2)==str.at(3)){
    ans++;
  }
  if(str.at(4)==str.at(5)){
    ans++;
  }
  if(ans==2){
  cout << "Yes" << endl;
  }else{
    cout<<"No"<<endl;
  }
}

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

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        PrintWriter pw = new PrintWriter(System.out);

        long a = sc.nextLong();
        long b = sc.nextLong();

        long gcd = EuclideanAlgorithm(a, b);
        long cnt = 1;

        for (long i = 2; i <= Math.sqrt(gcd); i++) {
            if (gcd % i == 0) {
                cnt++;
                while (gcd % i == 0)
                    gcd /= i;
            }
        }

        if (gcd > 1)
            cnt++;
        
        System.out.println(cnt);
    }

    static long EuclideanAlgorithm(long a, long b) {
        long max = Math.max(a, b);
        long min = Math.min(a, b);

        long re = max % min;
        if (re == 0)
            return min;
        return EuclideanAlgorithm(min, re);
    }

    static class MyScanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;

        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException ignored) {
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}

Measured memory_bytes: 21332
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#define ll long long
#define fi first
#define se second
#define pb push_back
#define me memset
const int N = 1e6 + 10;
const int mod = 1e9 + 7;
using namespace std;
typedef pair<int,int> PII;
typedef pair<long,long> PLL;

int n;

int main() {
    ios::sync_with_stdio(false);cin.tie(0);
    cin>>n;
     int res=n%10;
     if(res==2 || res ==4 || res==5|| res==7 || res==9) puts("hon");
     else if(res==3) puts("bon");
     else puts("pon");
     
    return 0;
}

Measured memory_bytes: 3656
using namespace std;
#include <math.h>
#include <stdio.h>

int main(void){
    double x1,y1,x2,y2;
    scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
    printf("%lf",sqrt((y1-y2)*(y1-y2)+(x1-x2)*(x1-x2)));
    return 0;
}



Measured memory_bytes: 2720
# include <bits/stdc++.h>
#define INF 9223372036854775807
using namespace std;

int main(){

  string S;
  cin >> S;
  int y, m, d;
  y = stoi(S.substr(0, 4));
  m = stoi(S.substr(5, 2));
  d = stoi(S.substr(8, 2));
  string ans;
  if(y > 2019){
    ans = "TBD";
  } else if (y < 2019){
    ans = "Heisei";
  } else {
    if(m > 4){
      ans = "TBD";
    } else {
      ans = "Heisei";
    }
  }

  cout << ans << endl;

}

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

/* -------------------------------- Template -------------------------------- */

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()

using namespace std;

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

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

template<typename T> T inf() { assert(false); }
template<> constexpr int inf<int>() { return 1e9; }
template<> constexpr ll inf<ll>() { return 1e18; }
template<> constexpr ld inf<ld>() { return 1e30; }

struct yes_no : numpunct<char> {
  string_type do_truename()  const { return "Yes"; }
  string_type do_falsename() const { return "No"; }
};

/* -------------------------------- Library -------------------------------- */

/* ---------------------------------- Main ---------------------------------- */

using T = tuple<int,int,int,int>;

T face[512];

T min_tuple(T x) {
  int c[4];
  tie(c[0], c[1], c[2], c[3]) = x;
  tuple<int,int,int,int> t1 = make_tuple(c[0], c[1], c[2], c[3]);
  tuple<int,int,int,int> t2 = make_tuple(c[1], c[2], c[3], c[0]);
  tuple<int,int,int,int> t3 = make_tuple(c[2], c[3], c[0], c[1]);
  tuple<int,int,int,int> t4 = make_tuple(c[3], c[0], c[1], c[2]);
  return min({ t1, t2, t3, t4 });
}

int cnt_tuple(T x) {
  int c[4];
  tie(c[0], c[1], c[2], c[3]) = x;
  tuple<int,int,int,int> t1 = make_tuple(c[0], c[1], c[2], c[3]);
  tuple<int,int,int,int> t2 = make_tuple(c[1], c[2], c[3], c[0]);
  if (t1 == t2) return 4;
  tuple<int,int,int,int> t3 = make_tuple(c[2], c[3], c[0], c[1]);
  if (t1 == t3) return 2;
  return 1;
}

ll prod(ll x, ll y) {
  ll res = 1;
  REP(i,y) res *= x - i;
  return res;
}

int main() {
  locale loc(locale(), new yes_no);
  cout << boolalpha;
  cout.imbue(loc);

  int N;
  cin >> N;
  map<T,int> cnt;
  REP(i,N) {
    int x1, x2, x3, x4;
    cin >> x1 >> x2 >> x3 >> x4;
    face[i] = min_tuple(T(x1, x2, x3, x4));
    ++cnt[face[i]];
  }
  ll res = 0;
  REP(i,N) REP(j,i) {
    int x0, x1, x2, x3;
    int x4, x5, x6, x7;
    tie(x0, x1, x2, x3) = face[i];
    tie(x4, x5, x6, x7) = face[j];
    REP(k,4) {
      tie(x0, x1, x2, x3) = make_tuple(x1, x2, x3, x0);
      map<T,int> mapsto;
      ++mapsto[min_tuple(T(x3, x2, x5, x4))];
      ++mapsto[min_tuple(T(x2, x1, x6, x5))];
      ++mapsto[min_tuple(T(x1, x0, x7, x6))];
      ++mapsto[min_tuple(T(x0, x3, x4, x7))];
      ll v = 1;
      for (auto p: mapsto) {
        int n = cnt.count(p.first) ? cnt[p.first] : 0;
        if (p.first == face[i]) --n;
        if (p.first == face[j]) --n;
        REP(l,p.second) v *= n - l;
        int c = cnt_tuple(p.first);
        REP(l,p.second) v *= c;
      }
      res += v;
    }
  }
  cout << res / 3 << endl;
  return 0;
}


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

#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(x) (x).begin(),(x).end()
#define MSG(x) cout << x << endl;
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
using ll = long long;

int main(int argc, char *argv[]) {
    ll w, h, x, y;
    cin >> w >> h >> x >> y;

    cout << fixed << setprecision(20) << (double)w*h/(double)2 << " ";

    if (x == w / 2 && y == h / 2 && x != 0 && y != 0 && (w % x == 0) && (h % y == 0)) {
        MSG(1)
    } else {
        MSG(0)
    }

    return 0;
}


Measured memory_bytes: 256
s = int(input())
lst = [0,0,1]
num = 10**9 + 7
if s>= 4:
  for i in range(4,s+1):
    ans = (lst[i-2] + lst[i-4])%num
    lst.append(ans)
  print(lst[-1]%num)
elif s == 3:
  print(1)
else:
  print(0)

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

int main(){
	int n,cnt[3] = {};
	cin >> n;
	for(int i = 0;i < n;i++){
		int a;
		cin >> a;
		if(a % 4 == 0) cnt[2]++;
		else if(a % 2 == 0) cnt[1]++;
		else cnt[0]++;
	}
	bool ans = false;
	for(int t = 0;t < 3;t++){
		int now = t;
		if(cnt[now] >= 1) cnt[now]--;
		else continue;
		bool flag = true;
		for(int i = 1;i < n;i++){
			if(!now){
				now = 2;
				cnt[2]--;
				if(cnt[2] < 0) flag = false;
			}else if(now == 1){
				if(cnt[1] <= 0) now = 2;
				cnt[now]--;
				if(cnt[2] < 0) flag = false;
			}else{
				if(cnt[0] <= 0 && cnt[1] <= 0) now = 2;
				else if(cnt[0] <= 0) now = 1;
				else now = 0;
				cnt[now]--;
				if(cnt[now] < 0) flag = false;
			}
		}
		if(flag) ans = true;
	}
	if(ans) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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

int main(){
int a,b;
cin>>a>>b;
int c[a]={0};
for(int i=0;i<a;i++)  cin>>c[i];
sort(c,c+a);
int sum=0;
for(int i=a-1;i>=a-b;i--){
	sum+=c[i];
}
cout<<sum;
}

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

#define PI 3.141592653
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descSort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;
ll gcd(ll x,ll y){
    if(x%y==0)return y;
    return gcd(y,x%y);
}


int main(void){
    int n;
    cin>>n;
    vector<pair<ll,ll>> p(n);
    rep(i,0,n){
        int a,b;
        cin>>a>>b;
        p[i]=make_pair(b,a);
    }
    sort(p.begin(),p.end());
    ll sum=0;
    bool isyes=true;
    for(auto i:p){
        sum+=i.second;
        if(sum>i.first){
            isyes=false;
            break;
        }
    }
    if(isyes)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3328
(N, K) = tuple([int(s) for s in input().split()])
d = {i: 0 for i in range(1, N + 1)}
for _ in range(K):
    n = int(input())
    A = [int(s) for s in input().split()]
    for a in A:
        d[a] += 1
print(len([i for i in d if d[i] == 0]))

Measured memory_bytes: 67536
#include<bits/stdc++.h>
#define ll long long
#define clr(x,i) memset(x,i,sizeof(x))
using namespace std;
const int N=200005;
const ll mod=1e9+7;
inline int read()
{
    int x=0,f=1; char ch=getchar();
    while(ch<'0'||ch>'9') {if(ch=='-') f=-1; ch=getchar();}
    while(ch>='0'&&ch<='9') {x=x*10+ch-'0',ch=getchar();}
    return x*f;
}
ll n,k;
int main()
{
	cin>>n>>k;
	n%=k;
	if(n*2>k) n=abs(n-k);
	cout<<n<<endl;
}

Measured memory_bytes: 256
from math import ceil

def check(arr,n,k,w):
    res=0
    for i in range(n):
        res+=ceil(arr[i]/w)-1
    if res<=k:
        return 1
    return 0
    
n,k=map(int,input().split())
arr=list(map(int,input().split()))

minn=1
maxx=max(arr)
while(1):
    val=ceil((minn+maxx)/2)
    if maxx==val:
        if check(arr,n,k,val) and (val==1 or not(check(arr,n,k,val-1))):
            print(val)
            break
        else:
            print(val-1)
            break
    if check(arr,n,k,val):
        maxx=val
    else:
        minn=val
    





 

Measured memory_bytes: 104400
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
  ll a,b,n,val1,val2,val;
  cin>>a>>b>>n;
  ll num=((n/b)*b)-1;
  if (num>=0)
    n=num;
  val1=(a*n)/b;
  val2=a*(n/b);
  val=val1-val2;
  cout<<val<<endl;
  return 0;
}

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

using namespace std;

typedef unsigned long long ull;
typedef long double ld;
typedef long long ll;
typedef pair<int,int> pi;

const int MAXN = 1e5 + 1;
char g[52][52];
int n,m;
int vis[52][52];
int stp=0;




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


    cin >> n >> m; int wcnt(0);
    for(int i=0;i<n;++i) for(int j=0;j<m;++j)
    {
        cin >> g[i][j];
        if(g[i][j]=='.') ++wcnt;
    }

    vis[0][0]=1;
    bool check = false;
    queue<pair<pi,int> > q;
    q.push(make_pair(pi(0,0),1));
    while(!q.empty())
    {
        pair<pi,int> u = q.front();

        q.pop();
        int i = u.first.first,j =u.first.second;stp=u.second;
        if(i==n-1 && j==m-1) {check=true;break;}

        if(i+1<n && !vis[i+1][j] && g[i+1][j]=='.') vis[i+1][j]=1,q.push(make_pair(pi(i+1,j),stp+1));
        if(i-1>=0 && !vis[i-1][j] && g[i-1][j]=='.') vis[i-1][j]=1,q.push(make_pair(pi(i-1,j),stp+1));
        if(j+1<m && !vis[i][j+1] && g[i][j+1]=='.') vis[i][j+1]=1,q.push(make_pair(pi(i,j+1),stp+1));
        if(j-1>=0 && !vis[i][j-1] && g[i][j-1]=='.') vis[i][j-1]=1,q.push(make_pair(pi(i,j-1),stp+1));
    }
    if(check) cout << wcnt - stp;
    else cout << -1;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define itn int
#define REP(i, n) for (int i = 0; i < n; i++)
#define IREP(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(a, b) for (int i = a; i < b + 1; i++)
#define all(v) v.begin(), v.end()
#define SENTINEL 2000000000
#define NIL -1
using namespace std;
typedef long long ll;

const ll INF = 1LL << 60;
const ll MOD = 1000000007;
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 main()
{
    ll x,y,a,b,c;
    cin >> x >> y >> a >> b >> c;
    vector<ll> p(a+1);
    vector<ll> q(b+1);
    vector<ll> r(c);
    REP(i,a){
        cin >> p[i];
    }
    REP(i,b){
        cin >> q[i];
    }
    REP(i,c){
        cin >> r[i];
    }
    sort(all(p),greater<ll>());
    sort(all(q), greater<ll>());
    sort(all(r), greater<ll>());
    p[a]=INF;
    q[b]=INF;
    int nowa=x-1;
    int nowb=y-1;
    REP(i,c){
        if(nowb==b&&nowa==a){
            break;
        }
        if (p[nowa] > r[i] && q[nowb] > r[i]){
            break;
        }
        if(p[nowa]>q[nowb]){
            q[nowb]=r[i];
            nowb--;
            if(nowb<0){
                nowb=b;
            }
        }
        else{
            p[nowa] = r[i];
            nowa--;
            if (nowa < 0)
            {
                nowa = a;
            }
        }
    }
    ll ans=0;
    REP(i,x){
        ans+=p[i];
    }
    REP(i, y)
    {
        ans += q[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 2560
fun main(args: Array<String>) = println(run {
    val (h,w) = readLine()!!.split(" ").map { it.toInt() }
    val a = (1..h).map { readLine()!! }

    "#".repeat(w+2).let { "$it\n${a.joinToString("\n") { "#$it#" }}\n$it" }

})


Measured memory_bytes: 36176
#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 h,n,a,sum;

signed main() {
    cin >> h >> n;
    rep(i,n) cin >> a,sum+=a;
    if (h > sum) cout << "No" << endl;
    else cout << "Yes" << endl;
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int num_right=0, num_acute=0, num_obtuse=0;
    while(true){
        int x, y, z;
        cin >> x >> y >> z;
        if(x<y) swap(x, y);
        if(x<z) swap(x, z);
        if(x>=y+z) break;
        if(x*x==y*y+z*z) ++num_right;
        else if(x*x<y*y+z*z) ++num_acute;
        else ++num_obtuse;
    }
    cout << num_acute+num_right+num_obtuse << " "
         << num_right << " "
         << num_acute << " "
         << num_obtuse << "\n";
    return 0;
}


Measured memory_bytes: 3120
def check(s):
    if (s[0] != 'A'): return False
    
    c = 0
    for i in range(2, len(s) - 1):
        if (s[i] == 'C'):
            c += 1
    if c != 1: return False

    upper = 0
    for i in range(len(s)):
        if ('A' <= s[i] <= 'Z'):
            upper += 1
    if upper != 2: return False
    return True

S = input()
print('AC' if check(S) else 'WA')

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int n, a[100], s[2];

int main() {
	cin >> n;
	inc(i, n) { cin >> a[i]; }
	sort(a, a + n, greater<int>());
	
	inc(i, n) { s[i % 2] += a[i]; }
	
	cout << s[0] - s[1] << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F(i,s,e) for(int i=s;i<e;++i)

int main()
{
    int n;
    cin >> n;
    int x[n];
    F(i,0,n) cin >> x[i];

    long ans=100000000,sum=0;
    F(p,0,101){
        F(i,0,n)
            sum+=pow(x[i]-p,2);
        ans=min(ans,sum);
        sum=0;
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> d(N);
  for (int i = 0; i < N; i++) cin >> d.at(i);
  sort(d.begin(), d.end());
  if (d.at(N/2 - 1) == d.at(N/2)) {
    cout << 0 << endl;
  } else {
    cout << d.at(N/2) - d.at(N/2 - 1) << endl;
  }
}

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

vector<int> A;
int N,K;
const int inf=1000000000000000001;

void solve(int &l,int &r){
	//l,r以下の数が何個あるかで二分探索
	while(l+1<r){
		int x=(l+r)/2;
		int sum=0;
		for(int i=0;i<N;i++){
			if(A[i]>=0){
				int left=-1,right=N;
				while(left+1<right){
					int c=(left+right)/2;
					if(A[c]*A[i]<x)left=c;
					else right=c;
				}
				sum+=right;
			}else{
				int left=-1,right=N;
				while(left+1<right){
					int c=(left+right)/2;
					if(A[c]*A[i]<x)right=c;
					else left=c;
				}
				sum+=N-right;
			}
			if(A[i]*A[i]<x)sum--;
		}
		sum/=2;
		if(sum<K)l=x;
		else r=x;
	}	
}

signed main(){
	cin>>N>>K;
	A.assign(N,0);
	for(int i=0;i<N;i++)cin>>A[i];
	sort(A.begin(),A.end());
	int l=-inf,r=inf;
	solve(l,r);
	cout<<l<<endl;
	return 0;
}

Measured memory_bytes: 1792
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

a,b,c,x,y=get_i
ans=0
while x>0 or y>0
    if x>0 and y>0 and a+b>c*2
      min=x>y ? y : x
      ans+=c*2*min
      x-=min
      y-=min
    elsif x>0
        if a>c*2
            ans+=c*2*x
        else
            ans+=a*x
        end
        x=0
    elsif y>0
        if b>c*2
            ans+=c*2*y
        else
            ans+=b*y
        end
        y=0
    end
end

puts ans

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 10000000000000000
#define endl '\n'
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

class UnionFindS{
private:
    vector<int> par;
public:
    UnionFindS(int n){
        par=vector<int>(n,-1);
    }
    int find(int x){
        if(par.at(x)<0) return x;
        else return par.at(x)=find(par.at(x));
    }
    int size(int x){
        return -par.at(find(x));
    }
    void unite(int x, int y){
        x=find(x);
        y=find(y);
        if(x==y) return;
        if(size(x)<size(y)) swap(x,y);
        par.at(x)+=par.at(y);
        par.at(y)=x;
    }
    bool same(int x, int y){
        return find(x)==find(y);
    }
};

signed main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m; cin>>n>>m;
    UnionFindS uni(n);
    rep(i,m){
        int x,y,z; cin>>x>>y>>z;
        uni.unite(x-1,y-1);
    }
    set<int> st;
    rep(i,n){
        st.insert(uni.find(i));
    }
    cout<<st.size()<<endl;
}

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


int main()
{
    /*
    int a,b,c,d;
    cin>>a>>b>>c>>d;

    int x=c%b;
    int y=a%d;

    //cout<<x<<" "<<y<<endl;


    if(x<=y) cout<<"Yes"<<endl;
    else    cout<<"No"<<endl;
*/

    int n;
    cin>>n;

    map<string,int>m;
    map<string,int>::iterator it;

    while(n--){
        string s;
        cin>>s;

        m[s]++;
    }


    cout<<m.size()<<endl;





    return 0;
}


Measured memory_bytes: 19152
#include <stdio.h>

int main(void)
{
	int array[10000], n, i, j, min, temp;
	long sum;
	
	while (scanf("%d", &n), n != 0){
		sum = 0;
		
		for (i = 0; i < n; i++){
			scanf("%d", &array[i]);
		}
		
		for (i = 0; i < n - 1; i++){
			min = i;
			for (j = i + 1; j < n; j++){
				if (array[min] > array[j]){
					min = j;
				}
			}
			
			temp = array[i];
			array[i] = array[min];
			array[min] = temp;
		}
			
		for (i = 1; i < n; i++){
			for (j = 0; j < i; j++){
				sum += array[j];
			}
		}
		
		printf("%ld\n", sum);
	}
	
	return (0);
}

Measured memory_bytes: 636
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF (1e9+1)
//#define INF (1LL<<59)

//??¨?????´??? verified AOJ GRL_5_A
#define MAX_V 800

struct edge{ int to,weight; };
pii dfs(int prev, int v, const vector<edge> graph[MAX_V]){   //searching farthest node
    pii r(0,v);
    
    rep(i,graph[v].size()){
        struct edge e = graph[v][i];
        if(e.to == prev) continue;
        pii tmp = dfs(v,e.to,graph);
        tmp.first += e.weight;
        if(r.first < tmp.first) r = tmp;
    }
    return r;
}

int v;

int diameter( const vector<edge> graph[MAX_V] ) {
    int s = 0;
    while(graph[s].size()==0&&s<v)s++;
    if(s==v)return 0;
    pii r = dfs(-1, s, graph);
    pii t = dfs(-1, r.second, graph);
    return t.first; // (r.second, t.second) is farthest pair
}

int main(){
    while(cin>>v&&v){
        int sum=0,lsum=0;
        vector<edge> G[MAX_V];
        vector<int> tmp(v-1);
        rep(i,v-1)cin>>tmp[i];
        rep(i,v-1){
            int c;
            cin>>c;
            G[i+1].pb(edge{tmp[i]-1,c});
            G[tmp[i]-1].pb(edge{(int)i+1,c});
            sum+=c;
        }
        bool used[MAX_V][MAX_V]={};
        rep(i,v){
            if(G[i].size()==1){
                int from = min<int>(i,G[i][0].to);
                int to = max<int>(i,G[i][0].to);
                if(used[from][to])continue;
                used[from][to]=true;
                lsum+=G[i][0].weight;
            }
        }
        
        vector<bool> isLeaf(v,false);
        rep(i,v)if(G[i].size()==1)isLeaf[i]=true;
        
        vector<edge> gr[MAX_V];
        rep(i,v){
            if(isLeaf[i])continue;
            for(auto &e:G[i]){
                if(isLeaf[e.to])continue;
                gr[i].pb(e);
            }
        }

        
//        cout<<sum<<" "<<lsum<<" "<<diameter(gr)<<endl;
        cout<<sum*3 - lsum*2 - diameter(gr)<<endl;
    }
}

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

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

  ll N; cin >> N;
  ll M; cin >> M;
  ll S; cin >> S;
  vector<ll> C(N), D(N);

  vector< pair<ll, pair<ll, ll>> > G[N]; // to, coin, time

  for (ll i = 0; i < M; i++) {
    ll u, v, a, b;
    cin >> u >> v >> a >> b;
    u--, v--;
    G[u].push_back(make_pair(v, make_pair(a, b)));
    G[v].push_back(make_pair(u, make_pair(a, b)));
  }
  for (ll i = 0; i < N; i++) {
    cin >> C[i] >> D[i];
  }

  S = min(S, (ll) 2500);
  ll INF = 1e18;
  vector<vector<ll>> dp(N, vector<ll>(2550, INF));
  queue< pair<ll, pair<ll, ll>> > q; // time, location, coin
  q.push(make_pair(0, make_pair(0, S)));
  while (!q.empty()) {
    pair<ll, pair<ll, ll>> c = q.front(); q.pop();
    ll mins = c.first, loc = c.second.first, coin = c.second.second;
    if (dp[loc][coin] <= mins) continue;
    dp[loc][coin] = mins;

    for (auto n: G[loc]) {
      ll new_mins = mins + n.second.second;
      ll new_loc = n.first;
      ll new_coin = coin - n.second.first;
      if (new_coin < 0) continue;
      q.push(make_pair(new_mins, make_pair(new_loc, new_coin)));
    }

    ll new_mins = mins + D[loc];
    ll new_coin = coin + C[loc];
    if (new_coin > 2500) new_coin = 2500;
    q.push(make_pair(new_mins, make_pair(loc, new_coin)));
  }

  for (ll i = 1; i < N; i++) {
    ll ans = INF;
    for (ll j = 0; j < 2550; j++) {
      ans = min(ans, dp[i][j]);
    }
    cout << ans << '\n';
  }
  return 0;
}

Measured memory_bytes: 14140
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	public void run() {
		Scanner sc = new Scanner(System.in);
		int r = sc.nextInt();
		System.out.println(3*r*r);
		sc.close();
	}
}


Measured memory_bytes: 35672
import java.util.Scanner;

public class Main {
    static Scanner scan = new Scanner(System.in);
    public static void main(String[] args) {
        int N = scan.nextInt();
        for(int i=0; i<N; i++){
            int money = scan.nextInt();
            int year = scan.nextInt();
            int n = scan.nextInt();
            int max = 0;
            for(int j=0; j<n; j++){
                int method = scan.nextInt();
                double rate = scan.nextDouble();
                int fee = scan.nextInt();
                if(method == 0){
                    int m = Simple(money, year, rate, fee);
                    if(max < m){
                        max = m;
                    }
                } else {
                    int m = Compound(money, year, rate, fee);
                    if (max < m) {
                        max = m;
                    }
                }
            }
            System.out.println(max);
        }
    }

    public static int Simple(int money, int year, double rate, int fee){
        int result = money, interest = 0;
        for(int i=0; i<year; i++){
            interest += (result * rate);
            result -= fee;
        }
        result += interest;
        return result;
    }

    public static int Compound(int money, int year, double rate, int fee){
        int result = money;
        for(int i=0; i<year; i++){
            result += result * rate;
            result -= fee;
        }
        return result;
    }

}

Measured memory_bytes: 41988
#include <cstdio>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)

constexpr int MAX_N = 100000;

using ll = long long;

ll N;
ll A[MAX_N];
ll d[MAX_N], S;

int main()
{
  scanf( "%lld", &N );
  rep( i, N )
    scanf( "%lld", A+i ), S += A[i];

  if( S % (N*(N+1)/2) )
  {
    puts("NO");
    
    return 0;
  }

  ll k = S / (N*(N+1)/2);

  rep( i, N-1 )
    d[i] = A[i+1]-A[i];

  bool fl = true;
  rep( i, N-1 )
  {
    fl &= d[i] <= k;
    fl &= (d[i]-k)%N == 0;
  }

  puts( fl ? "YES" : "NO" );

  return 0;
}

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

using namespace std;

int n, a[100005];

int main() {
    long long cur = 0, ans = 0;
    cin >> n;
    for(int i = 1; i <= n; i++) cin >> a[i];
    for(int i = 1; i <= n + 1; i++) {
        if(a[i] == 0) {
            ans += cur / 2;
            cur = 0;
        }
        cur += a[i];
    }
    cout << ans << endl;
    return 0;
}
//16:05:23

Measured memory_bytes: 640
#include <stdio.h>

typedef struct { char suit, value; } Card;

void bubble(Card A[], int N) {
  int i,j;
  Card t;
  for(i = 0; i<N; i++) {
    for(j = N-1; j >= i; j--) {
      if(A[j].value < A[j-1].value) {
        t = A[j]; A[j] = A[j-1]; A[j-1] = t;
      }
    }
  }
}

void selection(Card A[], int N) {
  int i,j,minj;
  Card t;
  for(i=0;i<N;i++) {
    minj = i;
    for(j=i+1; j<N; j++) {
      if(A[j].value < A[minj].value) minj = j;
    }
    t = A[i]; A[i] = A[minj]; A[minj] = t;
  }
}

void print(Card A[], int N) {
  int i;
  for(i=0; i<N; i++) {
    if(i>0) printf(" ");
      printf("%c%d",A[i].suit,A[i].value);
  }
  printf("\n");
}

int isStable(Card C1[], Card C2[], int N) {
  int i;
  for(i=0; i<N; i++) {
    if(C1[i].suit != C2[i].suit) return 0;
  }
  return 1;
}

/* オリジナル関数を追加 */
void str2Card(Card *t,char str[]) {
    t->suit  = str[0];
    t->value = str[1] - '0';
}

int main(void) {
  Card C1[100], C2[100];
  int N,i;
  char str[3];

  scanf("%d",&N);
  for(i=0;i<N; i++) {
    scanf("%s",str);
    str2Card(&C1[i],str);
  }

  for(i=0; i<N; i++) C2[i] = C1[i];

  bubble(C1,N);
  selection(C2,N);

  print(C1,N);
  printf("Stable\n");
  print(C2,N);
  if(isStable(C1,C2,N)) {
    printf("Stable\n");
  } else {
    printf("Not stable\n");
  }

  return 0;
}



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

int main(){
  int N,M;
  cin>>N>>M;
  int ans;
  if(N==1){
    ans=0;
  }
  
  if(N==2){
    ans=10;
  }
  
  if(N==3){
    ans=100;
  }
  
  int s,c;
  int o=0;
  int a=0;
  int b=0;
  int d=0;
  int a2, b2, d2;
  rep(i,M){
    cin>>s>>c;
    if(N!=1 && s==1 && c==0){
      o=1;
      break;
    }
    
    if(s==1){
      if(a==0){
      a++;
      a2=c;
      if(N==3){
      ans+=(c-1)*100;
      }
        if(N==2){
      ans+=(c-1)*10;
      }
        if(N==1){
      ans+=c*1;
      }
      
      
      }
      else{
        if(c!=a2){
          o=1;
          break;
        }
      }
    }
      if(s==2){
      if(b==0){
      b++;
      
      b2=c;
        
        if(N==3){
      ans+=c*10;
      }
        if(N==2){
      ans+=c*1;
      }
      
      }
      else{
        if(c!=b2){
          o=1;
          break;
        }
      }
      }
    
    
     if(s==3){
      if(d==0){
      d++;
      
      d2=c;
        
        if(N==3){
      ans+=c;
      }
      
      }
      else{
        if(c!=d2){
          o=1;
          break;
        }
      }
      }
      
    
    
    
  }
  
  if(o==1){
    cout<<-1<<endl;
  }
  
  else{
    cout<<ans<<endl;
  }
}
    


Measured memory_bytes: 256
class SetItem:
    def __init__(self, a, b, sub):
        self.a = a
        self.b = b
        self.sub = sub

    def get_total(self, a_list, b_list):
        a_value = a_list[self.a-1]
        b_value = b_list[self.b-1]
        return a_value + b_value - self.sub


a, b, m = map(int, input().split())
a_list = list(map(int, input().split()))
b_list = list(map(int, input().split()))
set_list = []
for _ in range(m):
    a, b, sub = map(int, input().split())
    set_item = SetItem(a, b, sub)
    set_list.append(set_item.get_total(a_list, b_list))

set_list.sort()
a_list.sort()
b_list.sort()
ans = a_list[0]+b_list[0] if a_list[0]+b_list[0] < set_list[0] else set_list[0]
print(ans)


Measured memory_bytes: 18148
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define soja(i,a,n) for(ll i=a;i<=n;i++)
int main()
{
    ll n,m,k,sum=0,t,pos,neg,ac=0,tle=0,wa=0,re=0;
    cin>>n;
    string s;
while(n--)
{
    cin>>s;
    if(s=="AC")
        ac++;
    else if(s=="TLE")
        tle++;
        else if(s=="WA")
        wa++;
            else if(s=="RE")
        re++;
}
cout<<"AC x "<<ac<<endl;
cout<<"WA x "<<wa<<endl;
cout<<"TLE x "<<tle<<endl;
cout<<"RE x "<<re<<endl;

    return 0;
}


Measured memory_bytes: 3544
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
 
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define PB push_back
#define SP << " " <<
 
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
 
__attribute__((constructor))
void initial(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed <<setprecision(15);
}
 
 
int main(void){
	double r;
    cin >> r;
    cout << 2*3.1415926535*r << endl;
    return 0;
}

Measured memory_bytes: 3772
m,d = map(int,input().split())
ans = 0
for i in range(m):
  for j in range(d):
    d1 = int((j+1)%10)
    d10 = int((j+1)/10)
    if(d1>=2 and d10>=2 and i+1==d1*d10):
      ans = ans + 1
print(ans)

Measured memory_bytes: 3060
// God put a smile upon your face <3

#include <bits/stdc++.h>`

#define slld(longvalue) scanf("%lld", &longvalue)

#define ll long long
#define ull unsigned long long
#define pll pair < long long, long long >

#define fastio ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0)

#define pb push_back

#define bug printf("BUG\n")

#define mxlld LLONG_MAX
#define mnlld -LLONG_MAX

#define mxd 2e8
#define mnd -2e8

#define pi 3.14159265359

#define mod 958585860497

#define base 2001487

using namespace std;

bool check(ll n, ll pos)
{
	return n & (1LL << pos);
}

ll Set(ll n, ll pos)
{
	return n = n | (1LL << pos);
}

const ll maxn  = 1000002;
vector < ll > primes;
bool vis[maxn+10];

void sieve()
{
    vis[0] = 1;
    vis[1] = 1;

    for(ll i = 4; i <= maxn; i += 2)
    {
        vis[i] = 1;
    }

    for(ll i = 3; i * i <= maxn; i += 2)
    {
        if(vis[i] == 0)
        for(ll j = i * i; j <= maxn; j += i)
        {
            vis[j] = 1;
        }
    }

    for(ll i = 2; i <= maxn; i++)
    {
        if(vis[i] == false)
        primes.pb(i);
    }

}

int main()
{
    ll i, j, k, l, m, n, o, r, q;
    ll testcase;
    ll input, flag, tag, ans;

//    freopen("input.txt", "r", stdin);

//    freopen("output.txt", "w", stdout);

    sieve();

    while(cin >> n)
    {
		ans = 0;

		for(ll i = 0; primes[i] * primes[i] <= n && i < primes.size(); i++)
		{
			ll tmp = primes[i];

			while(n % tmp == 0) ans++, n /= tmp, tmp *= primes[i];
			while(n % primes[i] == 0) n /= primes[i];
		}

		if(n > 1) ans++;

		cout << ans << '\n';
    }

}





Measured memory_bytes: 5136
#include<iostream>
using namespace std;
#define N 100005
#define rep1(i,n) for((i)=1;(i)<=(n);(i)++)

int n,ans;
int a[N];
int l[N],r[N];
int gcd(int x,int y)
{
	if(y==0) return x;
	return gcd(y,x%y);
}

int main()
{
	
	int i;
	cin>>n;
	rep1(i,n) cin>>a[i];
	rep1(i,n) l[i]=gcd(a[i],l[i-1]);
	for(i=n;i>=1;i--) r[i]=gcd(a[i],r[i+1]);
	rep1(i,n) ans=max(ans,gcd(l[i-1],r[i+1]));
	cout<<ans<<'\n';
	
	return 0;
}

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

int main() {
    long long int x, n, i, count=0;
    cin >> n;
    for(i=0; i<n; i++) {
        cin >> x;
        if(x % 2 == 0) {
            while(x % 2 == 0) {
                x /= 2;
                count++;
            }
        }
    }
    cout << count << endl;
}

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

ll rec(int n, ll x) {
    if (n == 0) return 1;
    ll len = (1LL<<(n+1)) - 3;
    ll num = (1LL<<n) - 1;
    if (x == 1) return 0;
    else if (x <= len + 1) return rec(n-1, x-1);
    else if (x == len + 2) return num + 1;
    else if (x <= (len + 1) * 2) return num + 1 + rec(n-1, x-len-2);
    else return num * 2 + 1;
}

int main(){
    int n;
    ll x;
    cin >> n >> x;
    ll ans = rec(n,x);
    cout << ans << endl;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
const ll mod = 1e9+7;

ll modulo(ll a, ll k) {
	if (k == 0) return 1;
	ll tmp = modulo(a, k / 2);
	if (k % 2 == 0)
		return tmp * tmp % mod;
	return tmp * tmp % mod * a % mod;
}

ll inversemod(ll a){
  return modulo(a,mod-2);
}

ll comb(ll n, ll a){
  ll num = 1, den = 1;
  for(ll i=0;i<=a-1;i++){
    num*=(n-i);
    num%=mod;
  }
  for(ll i=1;i<=a;i++){
    den*=i;
    den%=mod;
  }
  return num*inversemod(den)%mod;
}


int main(){
  ll n,a,b;
  cin >> n >> a >> b;
  ll res = modulo(2,n)-1;
  res = (res-comb(n,a))%mod;
  res = (res-comb(n,b))%mod;
  res = (res+mod)%mod;
  cout<<res<<endl;
}


Measured memory_bytes: 256
#include <utility> // pair make_pair
using std::swap; // c++11
using std::pair;
using std::make_pair;
#include <tuple> // tuple(c++11) make_tuple(c++11)
using std::tuple; // get<address>(variable)
using std::make_tuple;
#include <string> // string stoi(c++11) stoll(c++11) to_string(c++11)
using std::string;
using std::stoi;
using std::stoll;
using std::to_string;
#include <queue> // queue priority_queue
using std::queue;
using std::priority_queue;
#include <stack> // stack
using std::stack;
#include <vector> // vector
using std::vector;
#include <map> // map
using std::map;
#include <set> // set
using std::set; // insert erase find count
#include <algorithm> // min max
using std::sort;
using std::lower_bound; // iterator,  >=
using std::upper_bound; // iterator,  >
using std::min;
using std::max;
using std::min_element; // iterator
using std::max_element; // iterator
#include <complex> // complex
using std::complex; // real imag
#include <iostream> // cin cout
using std::cin;
using std::cout;
using std::endl;
#include <iomanip> // setprecision fixed(manipulator)
using std::setprecision;
using std::fixed;
#include <cmath>
#include <cstdio>

#define lli long long int
#define INF (int)1e09
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define EFOR(i, m, n) for (int i = m; i <= n; i++)
#define RFOR(i, m, n) for (int i = m; i > n; i--)
#define REFOR(i, m, n) for (int i = m; i >= n; i--)
#define VSORT(v) sort((v).begin(), (v).end()) // sort vector
typedef pair<int, int> PI;
typedef tuple<int, int, int> TI;
template <typename T> using Vec = vector<T>; // c++11

// Warshall–Floyd Algorithm
void WF (Vec<Vec<int> >& dp, int V) {
    FOR (k, 0, V) {
        FOR (i, 0, V) {
            FOR (j, 0, V) {
                dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
            }
        }
    }
    return;
}

int main(void) {
    int h;
    int w;
    cin >> h >> w;
    Vec<Vec<int> > convert(10, Vec<int>(10));
    FOR (i, 0, 10) {
        FOR (j, 0, 10) {
            cin >> convert[i][j];
        }
    }

    WF(convert, 10);

    int count[10] = {};

    FOR (i, 0, h) {
        FOR (j, 0, w) {
            int temp;
            cin >> temp;
            if (temp != -1) {
                count[temp]++;
            }
        }
    }

    int ans = 0;
    FOR (i, 0, 10) {
        ans += convert[i][1] * count[i];
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256