akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<queue>
#include<set>
#include<vector>
#include<stack>
#include<map>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;

#define mod 998244353
#define inf 0x7f7f7f7f
#define maxn 500005
#define N 300005
typedef long long ll;

inline int read()
{
    int x = 0;
    int f = 1;
    char c = getchar();
    while (c<'0' || c>'9')
    {    
        if (c == '-')
            f = -1;
        c = getchar();
    }
    while (c >= '0'&&c <= '9')
    {
        x = x * 10 + c - '0';
        c = getchar();
    }
    return x*f;
}

//_scc[u]存u点所在强连通分量的标号,out[x]存标号为x的强连通分量的出度,
//cot[x]存标号为x的连通量的点的数目
ll a, b;

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

int is_ok(ll x) {
    for (int i = 2; i <= sqrt(x); i++) {
        if (!(x % i)) return 0;
    }
    return true;
}

int m, v[100000005], prime[10000004];

void primes() {
    memset(v, 0, sizeof(v));
    m = 0;
    for (int i = 2; i <= 100000000; i++) {
        if (!v[i]) {
            v[i] = i;
            prime[++m] = i;
        }
        for (int j = 1; j <= m; j++) {
            if (prime[j] > v[i] || prime[j] > 100000000 / i) break;
            v[i * prime[j]] = prime[j];
        }
    }
}
int cnt;
int main() {
    cin >> a >> b;
    ll k = gcd(a, b);
    primes();
    for (int i = 1;i <= m;i++) {
        int flag = 0;
        while (!(k %prime[i])) {
            k /= prime[i];
            flag = 1;
        }
        if (flag) cnt++;
    }
    if (is_ok(k) && k != 1) cnt++;
    cout << cnt + 1 << endl;
}   

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

int main() {
  int N;
  cin >> N;
  int A[300][300];
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < N; ++j) {
      cin >> A[i][j];
    }
  }
  for (int k = 0; k < N; ++k) {
    for (int i = 0; i < N; ++i) {
      for (int j = 0; j < N; ++j) {
        if (A[i][j] > A[i][k] + A[k][j]) {
          cout << "-1" << endl;
          return 0;
        }
      }
    }
  }
  for (int k = 0; k < N; ++k) {
    for (int i = 0; i < N; ++i) {
      for (int j = 0; j < N; ++j) {
        if (A[i][j] == 0 || A[i][k] == 0 || A[k][j] == 0)
          continue;
        if (A[i][j] == A[i][k] + A[k][j]) {
          A[i][j] = 0;
          A[j][i] = 0;
        }
      }
    }
  }
  int64_t sum = 0;
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < N; ++j) {
      sum += A[i][j];
    }
  }
  sum /= 2;
  cout << sum << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL)
int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    boost;

    char ch;
    cin >> ch;
    if (ch >= 'A' && ch <= 'Z')
    {
        cout << "A";
    }
    else
    {
        cout << "a";
    }

}

Measured memory_bytes: 3608
def slove():
    import sys
    import collections
    input = sys.stdin.readline
    n, m = list(map(int, input().rstrip('\n').split()))
    ad = collections.defaultdict(list)
    bd = collections.defaultdict(list)
    for i in range(m):
        a, b = list(map(int, input().rstrip('\n').split()))
        if a == 1:
            ad[b] = 1
        if b == 1:
            ad[a] = 1

        if a == n:
            bd[b] = 1
        if b == n:
            bd[a] = 1
    for k, v in ad.items():
        if k in bd:
            print("POSSIBLE")
            exit()
    print("IMPOSSIBLE")


if __name__ == '__main__':
    slove()


Measured memory_bytes: 62044
#include <stdio.h>

int main(){
    int x = 1;
    int y = 1;
    while (x != 0 || y != 0){
        scanf("%d %d", &x, &y);
        if (x == 0 && y == 0){
            exit(0);
        }
        for (int i = 1; i <= x; i++){
            for (int j = 1; j <= y; j++){
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }
}



Measured memory_bytes: 2048
#include <iostream>
#include <cstdint>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
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; }
struct io { io() { ios::sync_with_stdio(false); cin.tie(0); } };
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

signed main(void)
{
    ll n, x, m;
    cin >> n >> x >> m;
    vb used(m*2);
    vll one_cycle;
 
    ll start = 0;
    ll now = x;
    
 	rep(i, n) {
        used[now] = true;
        one_cycle.pb(now);
        now = now * now % m;
        if (used[now]) {
            for(ll j = 0; j < (ll)one_cycle.size(); ++j) if (one_cycle[j] == now) {
                start = j;
                break;
            }
        break;
        }
    }
 
    ll s1 = 0, s2 = 0, loop = one_cycle.size() - start;
    
    rep(i, start) s1 += one_cycle[i];
    
    for(int i = start; i < one_cycle.size(); ++i) s2 += one_cycle[i];
    
    ll ans = s1 + (n - start) / loop * s2;
    
    for(int i = 0; i < (n - start) % loop; ++i) {
        ans += now;
        now = now * now % m;
    }
    
    mes(ans);
    
    return 0;
}

Measured memory_bytes: 3792
#include <iostream>
#include <string>

using namespace std;

string str;

bool check(int a, int b){
  if(a == b){
    if(str[a] == 'i' || str[a] == 'w') return true;
    return false;
  }
  if(str[a] == 'i' && str[b] == 'i') return true;
  if(str[a] == 'w' && str[b] == 'w') return true;
  if(str[a] == '(' && str[b] == ')') return true;
  if(str[a] == ')' && str[b] == '(') return true;
  return false;
}

main(){
  cin >> str;
  if(str.size() == 0) cout << 0 << endl;
  int size = (str.size() + 1) / 2;
  int ans = 0;
  for(int i=0;i<size;i++){
    if(!check(i, (int)str.size()-1-i)) ans++;
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())

signed main(){

	lli n;
	cin>>n;

	string s;
	cin>>s;

	set<lli> s1,s2,s3;

	REP(i,0,n){
		lli now=s.at(i)-'0';

		for(auto e:s2)s3.insert(e*10+now);
		for(auto e:s1)s2.insert(e*10+now);
		s1.insert(now);
	}

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

	return 0;
}

Measured memory_bytes: 384
n = int(input())
a = list(map(int,input().split()))
d = dict()
ans = 0

d[n-1-a[-1]] = 1

for i in range(n-2,-1,-1):
    if a[i] + i in d:
        ans += d[a[i]+i]
    
    if i - a[i] in d:
        d[i-a[i]] += 1
    else:
        d[i-a[i]] = 1

print(ans)


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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;

class CommonIO {
public:
    CommonIO() {
        std::cin.tie(0);
        std::ios::sync_with_stdio(false);
    }
    ~CommonIO() {}

    template <class T>
    void scan(T &v) {
        std::cin >> v;
    }
    template <class T, class... Rest>
    void scan(T &v, Rest&... rest) {
        scan(v);
        scan(rest...);
    }

    template <class T>
    void print(T v) {
        std::cout << v;
    }
    template <class T>
    void print(std::vector<T> &v) {
        if (v.size() == 0) return;
        print(*v.begin());
        for (auto it = ++v.begin(); it != v.end(); ++it) {
            print(' ');
            print(*it);
        }
    }
    template <class T>
    void print(std::vector< std::vector<T> > &grid) {
        if (grid.size() == 0) return;
        print(*grid.begin());
        for (auto it = ++grid.begin(); it != grid.end(); ++it) {
            print('\n');
            print(*it);
        }
    }
    template <class T, class... Rest>
    void print(T v, Rest... rest) {
        print(v);
        print(' ');
        print(rest...);
    }

    template <class T>
    void printl(T v) {
        print(v);
        std::cout << '\n';
    }
    template <class T, class... Rest>
    void printl(T v, Rest... rest) {
        print(v);
        print(' ');
        printl(rest...);
    }
} io;

ll factor(ll n) {
    ll sq = floor(sqrt(n) + 0.5);
    for (ll i = sq; i > 1; --i) {
        if (n % i == 0) return i;
    }
    return 1;
}

int main() {
    ll n; io.scan(n);
    ll f = factor(n);
    io.printl((f-1) + (n/f-1));
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(auto i=(a); i < (b); ++i)
#define pb push_back
#define fs first
#define sc second
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;

const double EPS = 1e-9;

int main() {
    cin.sync_with_stdio(false);
    int k; cin >> k;
    rep(i,0,k) {
        cout << "ACL";
    }
    cout << endl;
}


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

int getDigits(int n) {
    int res = 0;
    while (n != 0) {
        res ++;
        n /= 10;
    }
    return res;
}

int main() {
    string line;
    while (getline(cin, line)) {
        stringstream ss(line);
        int a, b;
        ss >> a >> b;
        cout << getDigits(a + b) << endl;
    }
}

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

using namespace std;
using llong = long long;
using P = pair<llong, llong>;

#define BE(x) x.begin(), x.end()

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

int main(){
	llong N;
	llong mini = -inf, score;

	cin >> N;
	int a,b;
	for(int i = 0; i < N; i++){
		cin >> a >> b;
		if(a > mini)
			mini = a, score = b;
	}

	cout << mini + score << endl;

	return 0;
}

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

int main(){
  int N,X,m[100];
  cin>>N>>X;
  for (int i(0);i<N;i++)cin>>m[i];
  int sum(0);
  for (int i(0);i<N;i++) sum+=m[i];
  int mini(100000);
  for (int i(0);i<N;i++) mini=min(mini,m[i]);
  cout << (X-sum)/mini+N << endl;
  return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#define RANGE 10010
 
int C[RANGE] = {0};
 
int main()
{
    int i, j;
    int N;
    int a;
    scanf("%d", &N);
    for (i=0; i<N; i++) {
        scanf("%d", &a);
        C[a]++;
    }
     
    int last = 0;
    for (i=0; i<RANGE; i++) {
        if (C[i] != 0) {
            last = i;
        }
    }
     
    for (i=0; i<last; i++) {
        for (j=0; j<C[i]; j++) {
            printf("%d ", i);            
        }
    }
    for (i=0; i<C[last]-1; i++) {
        printf("%d ", last);
    }
    printf("%d\n", last);
     
    return 0;
}



Measured memory_bytes: 2056
import math
import itertools
N,D = map(int, input().split())
X = []
count = 0
for i in range(N):
    a1 = list(map(int, input().split()))
    X.append(a1)
p3 = 0   
a2 = list(itertools.combinations(range(N),2))

for i,e in a2:
    for j in range(D):
        p = X[i][j]
        p1 = X[e][j]
        p3 += pow(p-p1,2)
    p4 = math.sqrt(p3)
    if p4.is_integer():
        count += 1
    p3 = 0
print(count)


Measured memory_bytes: 3064
import java.util.HashMap;
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
 
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		String anser = "YES";
 
		HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
 
		int A = 0;
		for (int i = 0; i < N; i++) {
			A = scan.nextInt();
 
			if (map.containsKey(A)) {
				anser = "NO";
				break;
			} else {
				map.put(A, i);
			}
		}
 
		System.out.println(anser);
	}
 
}

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

bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}

bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}


string s, answo;
int n;
int wo[50][30], ans[30], mem[30];

int main(){
    for(int i = 0; i < 30; i++){
        ans[i] = 1000;
    }
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> s;
        for(int j = 0; j < s.length(); j++){
            mem[s[j] - 'a']++;
        }
        for(int j = 0; j < 30; j++){
            ans[j] = min(ans[j], mem[j]);
            mem[j] = 0;
        }
    }

    for(int i = 0; i < 30; i++){
        for(int j = 0; j < ans[i]; j++) answo += (int)'a'+i;
    }
    cout << answo << endl;
}


Measured memory_bytes: 256
/// meowa 

#pragma GCC optimize("O3")

#include<bits/stdc++.h>

#define x first
#define y second
#define pb push_back
#define sz(x) (int) x.size()
 
using namespace std;

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

const int MOD = 1e9 + 7;
const int INF32 = 1e9 + 1e2;

void stndrtn() {
#ifdef hitorie
    freopen(".in", "r", stdin);
#endif        
}

const bool flag = 0;

void maincode() {
    ll a, b;
    cin >> a >> b;
    cout << a*b;            
} 

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr), stndrtn();
    int ts = 1;
    if (flag) {
        cin >> ts;
    }
    while (ts--) {
        maincode(); 
    }
    return 0;
}

Measured memory_bytes: 3652
#include <stdio.h>

int p[10001];

int main(void)
{
  	unsigned i,k, n;
  	for (i = 0; i < 10000; i++){
   		p[i] = 1; 
 	}
	p[0] = 0;   
 
 	for (i = 2; i*i <= 10000; i++) {
    	if (p[i] == 1) {
     		for (k = 2*i; k <=10000 ; k += i){
        		p[k] = 0;  
  			}
		}
	}
	
	while(1){
		scanf("%d" , &n);
		if(n == 0)
			break;
		for(i = n ; i > 1;i--){
			if(p[i]*p[i -2] ==1)
				break;
		}
			if(n >= 5)
				printf("%d %d\n",i-2,i);
	}
		return 0;
}

Measured memory_bytes: 636
#include<iostream>
#include<vector>
#include<functional>
#include<algorithm>
#include<string>
#include<queue>
#include<math.h>

using namespace std;

int main(void){

    int x;
    cin >> x;

    x = (x % 2 == 0 && x != 2 ? x + 1 : x);

    int check = 0;
    for(int i = x;;i += 2){
        for(int j = 3; j <= sqrt(i);j += 2){
            if(i%j == 0){
                check = 1;
                break;
            }
        }
        if(check == 0){
            cout << i << endl;
            return 0;
        }else{
            check = 0;
        }
    }

    return 0;
}


Measured memory_bytes: 256
def to_bit(num,digit):
    bit = [0] * digit
    for i in range(digit):
        bit[i] = num % 2
        num = int((num - (num % 2)) / 2)
    return bit

a = list(input())
a = [int(i) for i in a]

sum_ = 0
for i in range(2 ** (len(a) - 1)):
    bit = to_bit(i,len(a) - 1)

    now_f = 0
    now_n = 0
    #print(bit)
    for j in range(len(a)):
        if j == len(a) - 1 or bit[j] == 1:
            now_n = now_n * 10 + a[j]
            now_f += now_n
            now_n = 0
        else:
            now_n = now_n * 10 + a[j]
    #print(now_f)
    sum_ += now_f


print(sum_)

Measured memory_bytes: 41692
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <vector>
#include <algorithm>
#include <map>

std::string T;
std::vector<int > T_num;
int N, K, R, S, P;
char convert[3]={'r','s','p'};
int score[3];

int getvalue(char aite){
  if (aite=='r'){
    return P;
  } else if (aite=='s'){
    return R;
  } else if (aite=='p'){
    return S;
  }
  return 0;
}

long long optimum(int start){
  std::vector<char > Slist;
  for (int i=start; i<T.length(); i+=K){
    Slist.push_back(T[i]);
  }
  long long ans = 0;
  ans += getvalue((char)Slist[0]);
  //printf("ans added (%c, %d)\n",Slist[0],getvalue((char)Slist[0]));
  bool wait = true;
  for (int i=1; i<Slist.size(); i++){
    //printf("i=%d, wait=%d\n",i,wait);
    if (Slist[i-1]==Slist[i]){
      if (!wait){
        ans += getvalue((char)Slist[i]);
        //printf("ans added (%c, %d)\n",Slist[i],getvalue((char)Slist[i]));
      }
      wait = !wait;
      /*      if (i!=1) {
        wait = !wait;
        }*/
    } else {
      wait = true;
      ans += getvalue((char)Slist[i]);
      //printf("ans added (%c, %d)\n",Slist[i],getvalue((char)Slist[i]));
    }
  }
  return ans;
}

int main(){
  scanf("%d", &N);
  scanf("%d", &K);
  scanf("%d", &R);
  scanf("%d", &S);
  scanf("%d", &P);
  std::cin >> T;
  //score[0]=R;
  //score[1]=S;
  //score[2]=P;

  long long ans = 0;
  for (int i=0; i<std::min(K,N); i++){
    ans += optimum(i);
    //printf("optimum(%d)=%d\n",i,optimum(i));
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main(void){
   char num[9];
   int strl,i,total=0,sum=0;

   scanf("%s",num);

   strl=strlen(num);

   for(i=0;i<strl;i++)
      sum+=num[i]-'0';

   total=atoi(num);

   if(total%sum==0) printf("Yes\n");
   else printf("No\n");
   return 0;
}

Measured memory_bytes: 128
# -*- coding: utf-8 -*-
#ARC102C
import sys

#n= int(input())
tmp = input().split()
n,k = list(map(lambda a: int(a), tmp))

if(k%2==1):
	tmp=n//k
	ans=tmp*tmp*tmp
else:
	tmp=n//k
	ans=tmp*tmp*tmp
	tmp=(n+k//2)//k
	ans+=tmp*tmp*tmp

print(ans)

Measured memory_bytes: 3060
import sys

input = sys.stdin.readline

N, M = map(int, input().split())
L = [[] for i in range(N + 1)]
for i in range(M):
    a, b = map(int, input().split())
    L[a].append(b)

# print(L)
S, T = map(int, input().split())
dist = [[10**9 for i in range(N + 1)] for j in range(3)]
dist[0][S] = 0
# print(dist)
Q = []
for i in L[S]:
    Q.append([i, S, 0])

for i in range(10 ** 7):
    if len(Q) == i:
        break
    if dist[(Q[i][2] + 1) % 3][Q[i][0]] == 10**9:
        dist[(Q[i][2] + 1) % 3][Q[i][0]] = dist[(Q[i][2]) % 3][Q[i][1]] + 1
        for j in L[Q[i][0]]:
            if dist[(Q[i][2] + 2) % 3][j] == 10**9:
                Q.append([j, Q[i][0], Q[i][2] + 1])
if dist[0][T] % 3 == 0:
    print(dist[0][T] // 3)
else:
    print(-1)
    #print(dist[0][:30])

Measured memory_bytes: 87560
def main():
    N = int(input())
    A = list(map(int, input().split()))
    a4 = 0; a2 = 0
    for a in A:
        if a%2 == 0:
            a2 += 1
        if a%4 == 0:
            a4 += 1
    a2 -= a4

    if N//2 <= a4:
        print('Yes')
    else:
        if N - 2*a4 <= a2:
            print('Yes')
        else:
            print('No')

if __name__ == "__main__":
    main()


Measured memory_bytes: 14252
#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>;


int main(){
 int a,b,c,d,e,f;
  cin >> a >> b >> c >>d;
  e = (d+a-1)/d;
  f = (c+b-1)/b;
  //cout << e << endl;
  //cout << f << endl;
  if(e>=f) cout << "Yes" << endl;
  else cout << "No" << endl;
  
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int,int>;
using pll = pair<long long, long long>;
const long long INF = 1<<29;

const int MOD = 1000000007;
long long ruizyou(long long m,long long n){
  if(m == 0)return 0;
  if(m == 1)return 1;
  long long ans = 1;
  long long tmp = m;
  for(int i=0;i<=30;i++){
    if(n & (1<<i)){
      ans *= tmp;
      ans %= MOD;
    }
    tmp *= tmp;
    tmp %= MOD;
  }
  return ans;
}
long long kaizyou(long long x){
  if(x == 0)return 1;
  return x * kaizyou(x-1) % MOD;
}
long long comb(long long x,long long y){
  long long bunsi = kaizyou(x);
  long long bunbo = kaizyou(x-y) * kaizyou(y) % MOD;
  return bunsi * ruizyou((int)bunbo,MOD-2) % MOD;
}
struct unionfind{
  vector<int> par;
  vector<int> hukasa;
  unionfind(int n){
    par = vector<int>(n);
    hukasa = vector<int>(n,0);
    for(int i=0;i<n;i++){
      par.at(i) = i;
    }
  }
  int root(int x){
    if(par.at(x) == x)return x;
    return root(par.at(x));
  }
  void unite(int x,int y){
    int rx = root(x);
    int ry = root(y);
    if(rx == ry)return;
    if(hukasa.at(rx) >= hukasa.at(ry)){
      par.at(ry) = rx;
      hukasa.at(rx) = max(hukasa.at(ry) + 1,hukasa.at(rx));
    }
    else{
      par.at(rx) = ry;
    }
  }
  bool same(int x,int y){
    return root(x) == root(y);
  }
};
int ctoi(char a){
  return a - '0';
}
long long gcd(long long a,long long b){
  long long c = max(a,b);
  long long d = min(a,b);
  if(d % c == 0)return c;
  return gcd(c,d%c);
}
long long lcm(long long a,long long b){
  return a * b / gcd(a,b);
}
int main(){
  int n;
  cin >> n;
  vector<char> s(n);
  for(int i=0;i<n;i++)cin >> s.at(i);
  int countw = 0;
  vector<int> witi;
  for(int i=0;i<n;i++){
    if(s.at(i) == 'W'){
      countw++;
      witi.push_back(i);
    }
  }
  int ans = 0;
  int ww = 0;
  while(countw){
    if(s.back() == 'W'){
      s.pop_back();
      countw--;
    }
    else{
      s.at(witi.at(ww)) = 'R';
      s.at(s.size()-1) = 'W';
      ww++;
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 4464
#include <stdio.h>
#include <stdlib.h>

#define SIZE 2000000

int myatoi(const char* p)
{
  int n=0;
  while (*p!='\n' && *p!='\r' && *p!='\0') {
    n = n*10+*p-'0';
    p++;
  }
  return n;
}

int main() {
  int A[SIZE];
  int H=0;
  int i, l, largest, tmp;
  char com[21];
  do {
    fgets(com, 20, stdin);
    if (com[0] == 'i') {
      A[++H] =myatoi(com+7);
      for (i=H; i>1 && A[i/2]<A[i];i/=2) {
        tmp = A[i/2];
        A[i/2] = A[i];
        A[i] = tmp;
      }

    } else if (com[1]=='x') { // extract
      printf("%d\n", A[1]);
      A[1] = A[H];
      i = 1;
      while (1) {
        l = i*2;
        largest = i;
        if (l < H && A[l] > A[i])        largest = l;
        if (l+1 < H && A[l+1] > A[largest])  largest = l+1;
        if (largest == i) break;
        tmp = A[i];
        A[i] = A[largest];
        A[largest] = tmp;
        i = largest;
      }
      H--;
    }
  } while (com[2]!='d');
  return 0;
}


Measured memory_bytes: 5604
#include <iostream>
#include <vector>
#include <string.h>
#include <algorithm>
#include <cstring>
#include <queue>
#include <assert.h>
#include <cmath>
#include <deque>
#include <unordered_map>
using namespace std;
using ll = long long;
using ld = long double;
const int mod = 1e7+7;

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll N; cin>>N;
	ll cnt = (ll)log10(N)/1ll;
	ll test = 1ll*pow(10, cnt)-1;
	int ret = 0;
	for(ll i=9; i>=0; i--) {
		if(i*pow(10, cnt)+test<=N) {
			ret = i;
			break;
		}
	}
	cout << ret+9*cnt << '\n';
	return 0;	
}

Measured memory_bytes: 256
from functools import reduce
import math

def main():
    # N! を求める
    # f = math.factorial(N)
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    # 1e10

    # 初期値用:十分小さい数(-100億)
    # -1e10
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    a = int(input().rstrip())
    if a >= 1200:
        print('ARC')
    else:
        print('ABC')
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 3572
import java.util.Scanner;

public class Main {

	static Scanner scanner;

	public static void main(String[] args) {
	    scanner = new Scanner(System.in);

	    int N=gi();
	    int D=gi();
	    int[][]X=new int[N][D];

	    for (int i=0; i<N;i++) {
	    	for (int j=0; j<D;j++) {
	        	X[i][j]=gi();
	        }
        }
	    
	    int c=0;
	    for (int i=0; i<N;i++) {
	    	for (int j=i+1; j<N;j++) {
	    		double s=0;
	    		for (int k=0; k<D;k++) {
		        	s+=Math.pow(X[i][k]-X[j][k], 2);
		        }
	    		s=Math.sqrt(s);
	    		if (Math.floor(s) == s) {
	    			c++;
	    		}
	        }
        }

        System.out.print(c);
//        if (s.charAt(0)=='0' && N!=1) {
//        	System.out.println(-1);
//        }else {
//        	System.out.println(s);
//        }
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35712
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;


void solve()
{
    int n, m;
    scanf("%d%d", &n, &m);
    vector<int> x(m), y(m);
    int i,k;
    for (i = 0; i < m; i++) {
        int num;
        scanf("%d%d", &x[i], &num);
        y[i] = 0;
        for (k = 0; k < num; k++) {
            int tmp;
            scanf("%d", &tmp); tmp--;
            y[i] += (1 << tmp);
        }
    }

    vector<ll> aa((1 << n), LINF);
    aa[0] = 0;
    for (i = 0; i < m; i++) {
        vector<ll> bb((1 << n), LINF);

        for (k = 0; k < (1 << n); k++) {
            bb[k] = MIN(bb[k], aa[k]);
            if (aa[k] < LINF) {
                int k2 = k | y[i];
                bb[k2] = MIN(bb[k2], aa[k] + x[i]);
            }
        }
        aa.swap(bb);
    }
    if (aa[(1 << n) - 1] == LINF) {
        printf("-1\n");
    }
    else {
        printf("%lld\n", aa[(1 << n) - 1]);
    }
    return;
}

int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T;
    scanf("%d%d", &T, &B);
    int t;
    for(t=0; t<T; t++) {
        //printf("Case #%d: ", t+1);
        solve();
    }
#endif
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
using ll=long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;


 
 
int main(){
	string s;
	cin>>s;
	rep(i,s.size()){
		if(s[i]==',')s[i]=' ';
	}
	cout<<s<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<utility>
#include<vector>

//nCrをMODで割ったあまりを返す
long long combination_mod(long long n, long long r, long long mod, long long f_max)
{
	//例外処理
	/*if (n < r || n < 0 || r < 0)
	{
		throw - 1;
	}*/

	//階乗をmodで割ったあまりを計算する
	static std::vector<long long>factorial_mod(f_max);
	if (factorial_mod[0] != 1)
	{
		factorial_mod[0] = 1;
		for (long long i = 1; i < f_max; i++)
		{
			factorial_mod[i] = factorial_mod[i - 1] * i % mod;
		}
	}

	long long numerator = factorial_mod[n];
	long long denominator = factorial_mod[r] * factorial_mod[n - r] % mod;//積はMODを超えているかもしれないからもう一回剰余算する

	/*
	nCr ＝ n!/(n-r)!/r!
		≡ (n! % p)*((n-r)! r! % p)^(p-2) (mod p) (但しpは素数)

	証明:

	*/

	////割り切れる場合は普通に返す
	//if (numerator % denominator == 0)
	//{
	//	return numerator / denominator;
	//}
	////割り切れない時
	//else
	{
		long long index = mod - 2, power = 1;
		while (index > 0)
		{
			if (index & 1)
			{
				power *= denominator;
				power %= mod;
			}
			denominator *= denominator;
			denominator %= mod;
			index >>= 1;
		}
		return numerator * power % mod;
	}
}

signed main()
{
	const long long mod = 998244353;
	const long long f_max = 333333;

	long long n, a, b, k;
	std::cin >> n >> a >> b >> k;
	std::vector<std::pair<long, long>>pairs;
	pairs.reserve(n);
	for (long long x = 0; x <= n; x++)
	{
		if ((k - a * x) % b == 0)
		{
			long long y = (k - a * x) / b;
			if (0 <= y && y <= n)
			{
				pairs.push_back(std::make_pair(x, y));
			}
		}
	}
	long long ans = 0;
	for (auto i : pairs)
	{
		ans += combination_mod(n, i.first, mod, f_max) * combination_mod(n, i.second, mod, f_max) % mod;
		ans %= mod;
	}
	std::cout << ans << std::endl;
	return 0;
}

Measured memory_bytes: 6912
N,Y = map(int, input().split())
 
num10000 = -1
num5000 = -1
num1000 = -1
 
total = 0
 
for i in range(0,N+1):
    for j in range(0, N-i+1):
        k = N - i - j
        total = 10000*i + 5000*j + 1000*k
        if total == Y:
            num10000 = i
            num5000 = j
            num1000 = k
 
print(str(num10000)+' ' +str(num5000) + ' ' +str(num1000))

Measured memory_bytes: 3064
import java.util.Scanner;

class Main{
        int high,low,sa;
    
    public void solve(){
        Scanner sc=new Scanner(System.in);
		
        for(int i=0;i<7;i++){
		high=sc.nextInt();
		low=sc.nextInt();
		sa=high-low;
        System.out.println(sa);
        }
    }
	public static void main(String[]args){
		Main obj=new Main();
		obj.solve();
	}
}

Measured memory_bytes: 17368
def get(i, j, S, H, W):
    if 0 <= i < H and 0 <= j < W:
        return int(S[i][j] == "#")
    else:
        return 0


def f(i, j, S, H, W):
    indices = [
        (i - 1, j - 1),
        (i - 1, j),
        (i - 1, j + 1),
        (i, j - 1),
        (i, j + 1),
        (i + 1, j - 1),
        (i + 1, j),
        (i + 1, j + 1),
    ]
    return sum([get(i, j, S, H, W) for i, j in indices])


H, W = map(int, input().split())
S = [input() for _ in range(H)]
M = [[0] * W for _ in range(H)]
for i in range(H):
    for j in range(W):
        if S[i][j] == ".":
            M[i][j] = f(i, j, S, H, W)
        else:
            M[i][j] = "#"
for row in M:
    print(*row, sep="")


Measured memory_bytes: 3444
/*
        HELLO WORLD
        -----------
        SHUBHAM
        -----------
        :) CODING
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define ff                                         first
#define ss                                         second
#define pb                                         push_back
//#define int                                        long long
#define mp                                         make_pair
#define pii                                        pair<int,int>
#define vi                                         vector<int>
#define mii                                        map<int,int>
#define umii                                       unordered_map<int,int>
#define pqb                                        priority_queue<int>
#define pqs                                        priority_queue<int,vi,greater<int>>
#define setbits(x)                                 __builtin_popcountll(x)
#define zerobits(x)                                 __builtin_ctzll(x)
#define mod                                        1000000007
#define inf                                        1e18
#define ps(x,y)                                    fixed<<setprecision(y)<<x
#define mk(arr,n,type)                             type *arr=new type[n]
#define test(t)                                    int t;cin>>t;while(t--)
#define rep(i,n)                                   for(int i=0;i<n;i++)
#define rep1(i,n)                                  for(int i=1;i<=n;i++)
#define fio                                        ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define SIZE                                       100001
#define all(x)                                     (x).begin(),(x).end()
#define sclk()                                     auto start_time = Clock::now()
#define eclk()                                     auto end_time = Clock::now();  cout << "\nTime Taken : " << chrono::duration_cast<chrono::milliseconds>(end_time    - start_time).count() << " ms"
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef std::chrono::high_resolution_clock Clock;

int powmod(int a,int b) {int res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int gcd(int a,int b) { return b?gcd(b,a%b):a;}

void f_io()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif // ONLINE_JUDGE
}
double dp[3001][3001];
double arr[3001];
double solve(int n,int x)
{
    if(x<=0)
        return 1;
    if(n==0)
        return 0;
    if(dp[n][x] < 0)
    {
        dp[n][x]=arr[n]*solve(n-1,x-1)+(1-arr[n])*solve(n-1,x);
    }
    return dp[n][x];
}
int32_t main()
{
    {
        memset(dp,-2,sizeof(dp));
        int n;
        cin>>n;
        rep(i,n)
        cin>>arr[i+1];
        double ans=solve(n,(n+1)/2);
        cout<<ps(ans,11);
    }
    return 0;
}


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

using namespace std;
using llong = long long;
using P = pair<llong, llong>;

#define BE(x) x.begin(), x.end()

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

int main(){
	int n,k;
	cin >> n >> k;

	cout << (n%k == 0 ? 0:1) << endl;

	return 0;
}

Measured memory_bytes: 256
import time
start = time.time()

import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

K =int(input())

suma = 0

for a in range(1,K+1,1):
    for b in range(1, K + 1, 1):
        for c in range(1, K + 1, 1):
            suma += gcd(a, b, c)

print(suma)

Measured memory_bytes: 69804
//AOJ 0100
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<cctype>
using namespace std;
#define MAX_N 100

unsigned long long int a[4001] = {0}, b, i, j, k, ans, n;
char str[1000];

int sort(const void *a, const void *b){
  return *(int*)a - *(int*)b;
}

int main(){
  while(scanf("%lld", &n) != 0){
    if(n == 0) return 0;
    ans = 0;
    for(i = 0; i < 4001; i++)
      a[i] = 0;
    for(i = 0; i < n; i++){
      scanf("%lld %lld %lld", &b, &k, &j);
      if(a[b] >= 1000000) continue;
      a[b] += k * j;
      if(a[b] >= 1000000){
	printf("%lld\n", b);
	ans++;
      }
    }
    if(ans == 0) printf("NA\n");
  }
  return 0;
}

Measured memory_bytes: 1076
IDENTIFICATION DIVISION.
PROGRAM-ID. 173A.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 N          PIC 9(06).
01 S          PIC X(03).
01 TBL.
   03 JUD     PIC 9(06) OCCURS 4.
01 I          PIC 9(06) COMP.
01 OUT        PIC Z(5)9.
*>
PROCEDURE DIVISION.
  ACCEPT N.
*>
  MOVE ZERO TO TBL.
  PERFORM VARYING I FROM 1 BY 1 UNTIL I > N
    ACCEPT S
    EVALUATE S
      WHEN 'AC'
        ADD 1 TO JUD(1)
      WHEN 'WA'
        ADD 1 TO JUD(2)
      WHEN 'TLE'
        ADD 1 TO JUD(3)
      WHEN 'RE'
        ADD 1 TO JUD(4)
    END-EVALUATE
  END-PERFORM.
*>
  MOVE JUD(1) TO OUT.
  DISPLAY 'AC x ' FUNCTION TRIM(OUT).
  MOVE JUD(2) TO OUT.
  DISPLAY 'WA x ' FUNCTION TRIM(OUT).
  MOVE JUD(3) TO OUT.
  DISPLAY 'TLE x ' FUNCTION TRIM(OUT).                                           
  MOVE JUD(4) TO OUT.
  DISPLAY 'RE x ' FUNCTION TRIM(OUT).
  STOP RUN.


Measured memory_bytes: 3920
using System.Linq;
using System;
public class hello
{
    public static void Main()
    {
        var pa = new int[3];
        for (int i = 0; i < 3; i++)
            pa[i] = int.Parse(Console.ReadLine().Trim());
        var j1 = int.Parse(Console.ReadLine().Trim());
        var j2 = int.Parse(Console.ReadLine().Trim());
        Console.WriteLine(pa.Min() + Math.Min(j1, j2) - 50);
    }
}

Measured memory_bytes: 9488
# coding: utf-8
# Your code here!

import bisect

N = int(input())

if N == 0:
    print(0)
else:
    plus = [2 ** x for x in range(0, 35, 2)]
    minus = [2 ** x for x in range(1, 35, 2)]
    
    cum_plus = [sum(plus[:x]) for x in range(1, len(plus))]
    cum_minus = [sum(minus[:x]) for x in range(1, len(minus))]
    
    flags = []
    answer = 0
    while answer != N:
        if N - answer > 0:
            insert_index = bisect.bisect_left(cum_plus, N - answer)
            flags.append(insert_index * 2)
            answer += plus[insert_index]
            cum_plus = cum_plus[:insert_index]
        else:
            insert_index = bisect.bisect_left(cum_minus, abs(N - answer))
            flags.append(insert_index * 2 + 1)
            answer -= minus[insert_index]
            cum_minus = cum_minus[:insert_index]
            
    output = [0] * (flags[0] + 1)
    for flag in flags:
        output[flag] = 1
     
    print(''.join([str(x) for x in output[::-1]]))

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

typedef long long ll;

const int maxn = 1e5 + 5;
int N, a[maxn][3];
ll dp[maxn][3];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    cin >> N;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> a[i][j];
        }
    }
    for (int i = 0; i < 3; i++) {
        dp[0][i] = a[0][i];
    }
    for (int i = 1; i < N; i++) {
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 3; k++) {
                if (k == j) {
                    continue;
                }
                dp[i][j] = max(dp[i][j], a[i][j] + dp[i - 1][k]);
            }
        }
    }
    ll answer = 0;
    for (int i = 0; i < 3; i++) {
        answer = max(answer, dp[N - 1][i]);
    }
    cout << answer;

    return 0;
}

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

struct Data{
  int x,y;

  bool operator < (const Data& data) const{
    if( y != data.y )return y < data.y;
    return x > data.x;

  }
};

int re[1000001];

int main(){

  int x, y;
  int datax, datay;

  priority_queue<Data> Q;

  cin >> x >> y;

  for(int i = 0; i < y; i++){
    // if(i != y){
      cin >> datax >> datay;
      re[datax] += datay;
      Q.push((Data){datax,re[datax]});
      // }
      while( !Q.empty() && Q.top().y != re[Q.top().x]) Q.pop();
    Data data = Q.top();
    cout << data.x << " " << data.y << endl;
  }
   

  return 0;
}

Measured memory_bytes: 6028
[n, m, l] = map(int, input().split())
a = [list(map(int, input().split())) for i in range(n)]
b = [list(map(int, input().split())) for i in range(m)]

c = [[sum([a[i][k]*b[k][j] for k in range(m)]) for j in range(l)] for i in range(n)]
for i in range(n):
    print(" ".join(list(map(str, c[i]))))

Measured memory_bytes: 8944
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};


int main() {
  int N;
  map<string,int> cnt1, cnt2;
  set<string> words;
  cin >> N;
  for (int i = 0; i < N; i++) {
    string s;
    cin >> s;
    cnt1[s]++;
    words.insert(s);
  }
  int M;
  cin >> M;
  for (int i = 0; i < M; i++) {
    string s;
    cin >> s;
    cnt2[s]++;
    words.insert(s);
  }
  int ans = 0;
  for(auto s : words) {
    ans = max(ans, cnt1[s] - cnt2[s]);
  }

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

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

int main(void){
    long long int n,k,h[100000],i,j=0;
    scanf("%lld %lld",&n,&k);
    for (i=0; i<n; i++) {
        scanf("%lld",&h[i]);
        if (h[i]>=k) {
            j++;
        }
    }
    printf("%lld",j);
    return 0;
}



Measured memory_bytes: 896
N = int(input())
ac = 0
wa = 0
tle =0
re =0
for i in range(N):
  S = input()
  if S == 'AC':
    ac+=1
  if S == 'WA':
    wa+=1
  if S == 'TLE':
    tle+=1
  if S == 'RE':
    re+=1
print('AC x',ac)
print('WA x',wa)
print('TLE x',tle)
print('RE x',re)

Measured memory_bytes: 9204
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(v) v.begin(), v.end()
#define revall(v) v.rbegin(), v.rend()
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){ if(y<h && y>=0 && x<w && x>=0) return true; return false; }
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(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int h,w;cin >> h >> w;
	vector<vector<int>> a(h,vector<int>(w));
	rep(i,h) rep(j,w) cin >> a[i][j];
	vector<pair<pii,pii>> ans;
	rep(i,h){
		rep(j,w){
			if(j == w - 1){
				if(a[i][j] % 2 == 1 && i < h - 1){
					ans.pb(mp(mp(i,j), mp(i + 1,j)));
					a[i + 1][j]++;
				}
			}
			if(j < w - 1){
				if(a[i][j] % 2 == 1){
					ans.pb(mp(mp(i,j), mp(i,j + 1)));
					a[i][j + 1]++;
				}
			}
		}
	}
	cout << ans.size() << endl;
	rep(i,ans.size()){
		cout << ans.at(i).first.first + 1 << " " << ans.at(i).first.second + 1 << " " << ans.at(i).second.first + 1 << " " << ans.at(i).second.second + 1 << endl;
	}
}


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

typedef long double ld;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    ld p;
    cin >> n;
    vector<vector<ld>> dp(n + 1, vector<ld>(n + 1));
    dp[0][0] = 1.0;
    for (int i = 1; i <= n; i++) {
        cin >> p;
        dp[i][0] = dp[i-1][0] * (1.0 - p);
        for (int j = 1; j <= i; j++) {
            dp[i][j] = dp[i-1][j] * (1.0 - p);
            dp[i][j] += dp[i-1][j-1] * p;
        } 
    }
    ld sum = 0.0;
    for (int j = n / 2 + 1; j <= n; j++) {
        sum += dp[n][j];
    }
    cout << fixed << setprecision(10) << sum;
    return 0;
}


Measured memory_bytes: 141056
#include <bits/stdc++.h>
using namespace std;
int main() {
  int num = 0;
  cin >> num;
  int *vec = new int[num];
  for(int i = 0; i< num; ++i)
  {
    cin >> vec[i];
  }

  int cont = 0;
  for(int i = 1; i < num-1;++i)
  {
    if((vec[i-1] > vec[i] && vec[i+1] < vec[i])|| (vec[i-1]< vec[i] && vec[i+1] > vec[i]))
    {
      cont++;
    }
  }
cout << cont;
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#define rep0(i,n) for (int i = 0; i <= (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)
using namespace std;
int main() {
	int a, b, c;
	int ans = 0;
	cin >> a >> b >> c;
	ans = a - b;
	c -= ans;
	if (c <= 0)c = 0;
	cout << c << endl;
	return 0;
}


Measured memory_bytes: 256
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools
import copy

def j(q):
    if q==1: print("YES")
    else:print("NO")
    exit(0)


def ct(x,y):
    if (x>y):print("GREATER")
    elif (x<y): print("LESS")
    else: print("EQUAL")

def ip():
    return int(input())


#n = ip()                              #入力整数1つ
#n,m= (int(i) for i in input().split())      #入力整数横2つ
w,a,b = (int(i) for i in input().split())    #入力整数横3つ
#n,a,b,c= (int(i) for i in input().split())  #入力整数横4つ
#a = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[ip() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#a=[input() for i in range(h)]
#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意

print(max(0,b-a-w,a-b-w))

Measured memory_bytes: 13580
#include<stdio.h>

int main(){
	int A;
	int B;

	scanf("%d %d",&A,&B);

	int C=A+B;

	if(A*B>A+B){
		C=A*B;
	}else if(A-B>A+B){
		C=A-B;
	}

	printf("%d",C);

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define limit(x, l, r) max(l, min(x, r))
#define lims(x, l, r) (x = max(l, min(x, r)))
#define isin(x, l, r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)), x.end())
#define show(x) cout << #x << " = " << x << endl;
#define PQ(T) priority_queue<T, v(T), greater<T>>
#define bn(x) ((1 << x) - 1)
#define dup(x, y) (((x) + (y)-1) / (y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() { 
  string s;
  cin >> s;
  int n = sz(s);
  if(n==2){
    if(s[0] == s[1]){
      cout<<1<<" "<<2<<endl;
      return 0;
    }
  }
  rep(i,n-2){
    if(s[i] == s[i+1] || s[i] == s[i+2] || s[i+1] == s[i+2]){
      cout<<i+1<<" "<<i+3<<endl;
      return 0;
    }
  }
  cout<<-1<<" "<<-1<<endl;
  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << '\n';
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = (int)1e9;
const int MOD = (int)1e9 + 7;

int main(void){
	int N;
	cin >> N;
	map<string, int> m;
	for(int i = 0; i < N; i++){
		string s;
		cin >> s;
		sort(s.begin(), s.end());
		m[s]++;
	}	

	ll res = 0;
	for(auto it = m.begin(); it != m.end(); it++){
		ll n = it -> second;
		res += n * (n-1) / 2;
	}

	cout << res << '\n';

	return 0;
}

Measured memory_bytes: 11136