akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
 
using namespace std;
 
#define ll long long 
#define ull unsigned long long 
#define ld long double
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#define er erase
#define line cout<<"\n";
#define mod  1000000007
int main()
{
    int n;
    cin>>n;
    int arr[200];
    for(int x=1; x<=2*n; x++)
    {
        cin>>arr[x];
    }
    int sum=0;
    for(int x=1; x<=2*n-5; x++)
    {
        
        if(arr[x]==arr[x+1])
        {
            if(arr[x+2]==arr[x+3] && arr[x+4]==arr[x+5])
         {   sum++;
         break;
        }
        }
        
        
    }
    if(sum==0)
    cout<<"No";
    else
    cout<<"Yes";
    
    
    
    
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;

int k, a, b, r;
LL d;

int main() {
scanf("%d %d %d", &k, &a, &b);
if (a >= b - 2 || k < a + 1) {
	printf("%d\n", k + 1);
	return 0;
}
k -= (a - 1);
r = b - a;
d = a;
d += (k / 2) * 1LL * r;
if (k % 2) d++;
printf("%lld\n", d);
return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        int x = Integer.parseInt(sc.next());

        int[] c = new int[n];
        int[][] a = new int[n][m];

        for (int i = 0; i < n; i++) {
            c[i] = sc.nextInt();
            for (int j = 0; j < m; j++) {
                a[i][j] = sc.nextInt();
            }
        }

        int ans = Integer.MAX_VALUE;
        boolean flag = false;
        loop: for (int i = 0; i < (1 << n); i++) {
            int[] s = new int[m];
            int tmp = 0;
            for (int j = 0; j < n; j++) {
                if ((1 & i >> j) == 1) {
                    tmp += c[j];
                    for (int k = 0; k < m; k++) {
                        s[k] += a[j][k];
                    }
                }
            }

            for (int j = 0; j < m; j++) {
                if (s[j] < x) {
                    continue loop;
                }
            }
            ans = Math.min(ans, tmp);
            flag = true;
        }

        System.out.println(flag ? ans : -1);
        sc.close();
    }

}

Measured memory_bytes: 37544
def slove():
    import sys
    import collections
    input = sys.stdin.readline

    n = int(input().rstrip('\n'))
    ls = []

    for i in range(1, n + 1):
        t = i
        for j in range(2, int(t ** 0.5) + 1):
            while True:
                if t % j == 0:
                    t //= j
                    ls.append(j)
                else:
                    break
        if t > 1:
            ls.append(t)

    ls = collections.Counter(ls)
    ls2 = []

    for k, v in ls.items():
        if v >= 74:
            ls2.append(75)
        if v >= 24:
            ls2.append(25)
        if v >= 14:
            ls2.append(15)
        if v >= 4:
            ls2.append(5)
        if v >= 2:
            ls2.append(3)

    ls2 = collections.Counter(ls2)
    cnt = 0
    cnt += (ls2[75])
    cnt += (ls2[25] * max(ls2[3]-1, 0))
    cnt += (ls2[15] * max(ls2[5]-1, 0))
    cnt += (ls2[5] * max(ls2[5]-1, 0) * max(ls2[3]-2, 0) // 2)
    print(cnt)


if __name__ == '__main__':
    slove()


Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 9999999999;
vector<int> x4 = {0, 1, 0, -1};
vector<int> y4 = {1, 0, -1, 0};
vector<int> x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y8 = {1, 1, 0, -1, -1, -1, 0, 1};
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;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
  T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }


int main() {
  int A,B,M; cin >>A >>B >>M;
  vector<int> a(A), b(B);
  rep(i, A) cin >>a.at(i);
  rep(i, B) cin >>b.at(i);
  int res = 10000000;
  rep(i, M){
    int x,y,c; cin >>x >>y >>c;
    x--; y--;
    chmin(res, a.at(x) + b.at(y) - c);
  }
  sort(all(a)); sort(all(b));
  chmin(res, a.at(0) + b.at(0));
  cout <<res <<endl;
}

Measured memory_bytes: 1152
#include<cstdio>
#include<iostream>
#include<queue>
#include<string>
#include<cmath>
#include<algorithm>
#include<limits.h>
#include<sstream>
#define rep(i,l,p) for(int i=l; i<=p; i++)
#define drep(i,p,l) for(int i=p; i>=l; i--)
using namespace std;

int n;
int main(){
	scanf("%d",&n);
	int t = 0;
	int x = 0,y = 0;
	int tt,xx,yy;
	int flag = true; 
	rep(i,1,n){
		scanf("%d%d%d",&tt,&xx,&yy);
		int gap = tt - t;
		t = tt;
		int moved = abs(xx - x) + abs( yy - y);
		x = xx;
		y = yy;
		if ( gap - moved >= 0 && (gap - moved) % 2 == 0 ) ;
		else flag = false;	
		if ( !flag ) break;
	} 
	if ( flag ) printf("Yes");
	else printf("No");
}


Measured memory_bytes: 256
#include "iostream"
#include "vector"

using namespace std;

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

    string S, T;
    int result = 0;

    cin >> S;
    cin >> T;

    for (int i = 0; i < 3; i++){
        if(S[i] == T[i])
            result++;
    }

    cout << result << "\n";
    return 0;
}

Measured memory_bytes: 888
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <cmath>
using namespace std;

bool isOverBmiLimit(double w, double h);

int main()
{
    int ans = 0;
    string in_str;
    while(getline(cin, in_str))
    {
        istringstream stream(in_str);
        string field;
        vector<string> in_data;
        while (std::getline(stream, field, ',')) 
        {
            in_data.push_back(field);
        }
        double w = stod(in_data[1]);
        double h = stod(in_data[2]);
        if(isOverBmiLimit(w, h))
        {
                cout << in_data[0] << endl;
        }
    }
    return 0;
}

bool isOverBmiLimit(double w, double h)
{
    bool is_over25 = false;
    double bmi = w / h / h;
    if(isgreaterequal(bmi,25.0))
    {
        is_over25 = true;
    }
    return is_over25;
}

Measured memory_bytes: 3184
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
typedef long long int ll;


int main(){
  ll  h,w;
  ll a[100000],b[100000];
  ll ans=0;
  cin>>h>>w;
  rep(i,h) cin>>a[i];
  rep(i,w) cin>>b[i];
  sort(a,a+h);sort(b,b+w);
  ll aa=0,bb=0;
  while(1){
    if(h==0) break;
    else{
      if(a[aa]<=b[bb]){
	ans+=a[aa]*w;
	h--;
	aa++;
      }else{
	ans+=b[bb]*h;
	w--;
	bb++;
      }
    }
  }
  cout<<ans<<endl;

  return 0;
}



Measured memory_bytes: 4724
#include <stdio.h>

//#define MyPrint fprintf
#define MyPrint

#define INPUT_MAX_SIZE (200)
#define INPUT_MAX_DATA (1000000000)

//3
//8 12 40

//6
//382253568 723152896 37802240 379425024 404894720 471526144

static int get_int1(void)
{
    int input;
    char ch;

    while (scanf("%d", &input) != 1) {
        while ((ch = getchar()) != '\n')
            putchar(ch);        // dispose of bad input
        MyPrint(stderr, " is not an integer.\nPlease enter an integer value.\n");
    }

    while (getchar() != '\n')   // discard rest of line
        continue;
    return input;
}

int main(int argc, char *argv[])
{
    int ncnt = 0;
    int val[INPUT_MAX_SIZE];
    int i, j;
    int input;
    int even_chk = 1;
    int try_cnt = 0;

    MyPrint(stdout, "Please input integer value.\n");

    ncnt = get_int1();
    if ((ncnt < 1) || (ncnt > INPUT_MAX_SIZE)) {
        MyPrint(stdout, "your input number is error.\n");
        return -1;
    }
    MyPrint(stdout, "Your input value is %d.\n", ncnt);

    MyPrint(stdout, "Please input data of A1, A2,... An.\n");
    i = 0;
    while (i < ncnt) {  // 整数値の個数分(最大N)ループ
        if (scanf("%d", &input) < 1) {
            break;
        }
        if ((input < 1) || (input > INPUT_MAX_DATA)) {
            MyPrint(stdout, "your input number is error.\n");
            return -1;
        }
        MyPrint(stdout, "val%d : %d\n", i+1, input);
       if (input % 2 == 0) {
            MyPrint(stdout, "Even\n");
            val[i] = input;
        }
        else {
            MyPrint(stdout, "Odd\n");
            even_chk = 0;
        }
        i++;
    }

    /* すべての入力が偶数の場合 */
    if ((i >= 1) && (even_chk == 1)) {
        MyPrint(stdout, "i : %d\n", i);
        try_cnt++;
        
        while (1) {
            even_chk = 1;
            for (j = 0; j < i; j++) {
                val[j] /= 2;
                if ((val[j] % 2 == 0) && (val[j] != 0)) {
                    MyPrint(stdout, "Even\n");
                }
                else {
                    MyPrint(stdout, "Odd\n");
                    even_chk = 0;
                    break;
                }
            }
            /* すべての入力が偶数の場合 */
            if (even_chk == 1) {
                MyPrint(stdout, "All Even! try_cnt=%d\n", try_cnt);
                try_cnt++;
            }
            else {
                break;
            }
        }
    }
    
    MyPrint(stdout, "Your input result : ");
    fprintf(stdout, "%d\n", try_cnt);
    
    return 0;
}


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

bool IsPrime(ll num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

int main() {
    ll N,K,R,S,P;
    string T;
    cin >> N >> K;
    cin >> S >> P >> R; // 相手の手により勝利時のポイントを定義
    cin >> T;
    ll ans = 0;
    for(int i=K;i<T.size();i++){
        if(T.at(i)==T.at(i-K)) T.at(i)='-';
    }
    for(int i=0;i<T.size();i++){
        if(T.at(i)=='r') ans += R;
        else if(T.at(i)=='s') ans += S;
        else if(T.at(i)=='p') ans += P;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long int
#define pb push_back
#define fe first
#define se second
#define pii pair<int,int>
#define PI  3.14159265358979323846

const int N=1e5+10;
int n,m,cnt;
int vis[N],d[N],maxi,in_degree[N];
vector<int> v[N];

void dfs(int u)
 { vis[u]=1;
 	 for(auto i: v[u])
 	 	 { d[i]=max(d[i],d[u]+1);
 	 	 	--in_degree[i];
 	 	 	if(in_degree[i]==0 && !vis[i])
 	 	 		 dfs(i);
 	 	 }
 }	 	 
 	 	

 
void solve()
{ int n,m;
	cin>>n>>m;
	for(int i=0;i<m;i++)
		 { int x,y;
		 	cin>>x>>y;
		 	v[x].pb(y);
		 	in_degree[y]++;
		 }
	for(int i=1;i<=n;i++)
	   { if(!vis[i] && in_degree[i]==0)
	   	   { dfs(i);
	   	   }
	   }

	   for(int i=0;i<=n;i++)	
	     { maxi=max(d[i],maxi);

	     }

	     cout<<maxi;
}

int main()
{  cool;
   int t=1;
   while(t--)   
     solve(); 

  return 0; 
}



  











Measured memory_bytes: 9984
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pii;
typedef pair<pii,ll> piii;
typedef pair<ll,pii> ipii;
#define MOD 998244353 
#define mod(a) ((a)%MOD)
#define pb push_back
#define ft first
#define sd second
#define mp make_pair
#define dbg(x) cout<<#x<<" = "<<x<<"\n"
#define dbg2(x,y) cout<<#x<<" = "<<x<<" , "<<#y<<" = "<<y<<"\n"
#define dbg3(x,y,z) cout<<#x<<" = "<<x<<" , "<<#y<<" = "<<y<<" , "<<#z<<" = "<<z<<"\n"
#define INF (1LL<<60)
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;*/
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define all(v) v.begin(),v.end()
#define endl '\n'
ll gcd(ll a,ll b){if(a==0) return b; return gcd(b%a,a);}
ll powm(ll base,ll exp,ll mod=MOD) {base%=mod;ll ans=1;while(exp){if(exp&1LL) ans=(ans*base)%mod;exp>>=1LL,base=(base*base)%mod;}return ans;}


ll h[100005];
ll dp[100005];
int main(){
      sync;
      ll n;
      cin>>n;
      for(ll i=1; i<=n; i++){
             cin>>h[i];
       }
    
       dp[1]=0;
       dp[2]=dp[1]+abs(h[2]-h[1]);
       for(ll i=3; i<=n; i++){
             dp[i]=min(abs(h[i]-h[i-1])+dp[i-1],abs(h[i]-h[i-2])+dp[i-2]);
       }
 
        cout<<dp[n]<<endl;

} 


Measured memory_bytes: 1792
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    move(vector<vector<T>>(h,move(vector<T>(w))))
#define VVI(T,h,w,i) move(vector<vector<T>>(h,move(vector<T>(w,i))))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

int main()
{
	string s; cin >> s;
	cout << s.front() << s.length() - 2 << s.back() << endl;
}

Measured memory_bytes: 384
// Created by PRATEEK RANJAN
#include <bits/stdc++.h>
using namespace std;
 
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

#define int long long
const int mod = 1e9+7;
int cal(int x)
{
    int res = 0;
    while(x){
        res++;
        x/=10;
    }
    return res;
}
 
void solve(int N)
{
    int ans = cal(N);
    for(int x=2;x*x<=N;++x)if(N%x==0){
        ans=min(ans,max(cal(x),cal(N/x)));
    }
    cout << ans;
}
 
int32_t main()
{
    int N;
    cin >> N;
    solve(N);
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();
    if (A + B >= C) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }  
  }
}

Measured memory_bytes: 22356
# -*- coding: utf-8 -*-
### 標準入力(秒) を 時刻:分:秒に変換する。
###
sec_input = input()
hour = sec_input / (60**2)
minute = (sec_input - hour * 60**2) / 60
second = sec_input - (hour * 60**2 + minute * 60)

print(repr(hour) + ':' + repr(minute) + ':' + repr(second))



Measured memory_bytes: 4652
#define _CRT_SECURE_NO_WARNINGS

/* include ***********************/
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

/* define *************************/
//for
#define REP(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define REPS(i,n) for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define RREPS(i,n) for(int i=(int)(n);i>0;i--)
#define FOR(i,s,n) for(int i=(int)(s),i##_len=(int)(n);i<i##_len;i++)
#define RFOR(i,s,n) for(int i=(int)(n)-1,i##_len=(int)(s);i>=i##_len;i--)

//printf
#define PRINTD(d) printf("%d\n",(d))
#define PRINTL(d) printf("%lld\n",(d))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

#define INF 1e9
#define MOD 1000000007

typedef long long ll;
typedef unsigned long long ull;

int diff[4][2] = {
	{ 0, -1 },
	{ -1, 0 },
	{ 1, 0 },
	{ 0, 1 },
};
//今回の変数

int Min(int a, int b) {
	return (a)<(b) ? (a) : (b);
}
int Max(int  a, int  b) {
	return (a) > (b) ? (a) : (b);
}
ll Minl(ll a, ll b) {
	return (a)<(b) ? (a) : (b);
}
ll Maxl(ll a, ll b) {
	return (a)>(b) ? (a) : (b);
}
void hSwap(ll x[], int i, int j)
{
	ll temp;

	temp = x[i];
	x[i] = x[j];
	x[j] = temp;
}
void ShowData(ll x[], int left, int right)
{
	int i;
	for (i = left; i <= right; i++)printf("%lld  ", x[i]);
	printf("\n");
}
void QSort2(ll x[], ll y[], int left, int right, int n) {
	int i, j;	//左端,右端
	ll pivot;	//軸

	i = left;
	j = right;
	pivot = x[(left + right) / 2];

	while (1) {
		if (n > 0) {				//n>0なら昇順、n<=0なら降順
			while ((x[i] < pivot) && (i <= right))i++;	//軸値より大きい要素
			while ((pivot < x[j]) && (i <= right))j--;	//軸値より小さい要素
		}
		else {
			while ((x[i] > pivot) && (i <= right))i++;	//軸値より小さい要素
			while ((pivot > x[j]) && (i <= right))j--;	//軸値より大きい要素
		}
		if (i >= j)	break;
		hSwap(x, i, j);
		hSwap(y, i, j);
		i++; j--;
	}
	//ShowData(x, left, right);

	if (left < i - 1)QSort2(x, y, left, i - 1, n);
	if (j + 1 <  right)QSort2(x, y, j + 1, right, n);
}

int main() {
	int n;
	scanf("%d", &n);

	ll x[50], y[50];
	REP(i, n) {
		scanf("%lld%lld", &x[i], &y[i]);
	}
	if (n == 1) {
		PRINTD(1);
		return 0;
	}
	QSort2(x, y, 0, n - 1, 1);
	//ShowData(x, 0, n - 1);
	//ShowData(y, 0, n - 1);

	ll min = 1e9;

	REP(i, n - 1) {
		FOR(j, i + 1, n) {
			//printf("i:%d j:%d\n", i, j);
			ll dx = x[j] - x[i];
			ll dy = y[j] - y[i];
			ll score = n;
			REP(k, n - 1) {
				FOR(l, k + 1, n) {
					ll ndx = x[l] - x[k];
					ll ndy = y[l] - y[k];
					//printf("k:%d l:%d %lld:%lld %lld:%lld\n", k, l, ndx,dx, ndy,dy);
					if (ndx == dx&&ndy == dy || ndx == -dx&&ndy == -dy) {
						score--;
					}
				}
			}
			min = Minl(min, score);
			//PRINTL(min);
		}
	}

	PRINTL(min);
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String args[]){
		Scanner in = new Scanner(System.in);
		int w = in.nextInt();
		int n = in.nextInt();
		int end[] = new int [w + 1];
		int change[][] = new int [n][2];
		for(int i = 0;i < n;i++){
			String[] num = in.next().split(",");
			change[i][0] = Integer.valueOf(num[0]);
			change[i][1] = Integer.valueOf(num[1]);
		}
		for(int i = 1;i <= w;i++){
			int ans = i;
			for(int j = 0;j < n;j++){
				if(ans == change[j][0]){
					ans = change[j][1];
				}else if(ans == change[j][1]){
					ans = change[j][0];
				}
			}
			end[ans] = i;
		}
		for(int i = 1;i <= w;i++){
			System.out.println(end[i]);
		}
	}
}

Measured memory_bytes: 17200
# -*- coding: utf-8 -*-
"""
Created on Sun Apr 19 21:27:49 2020

@author: arute
"""


from sys import stdin

import time
import numpy as np
import math



def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

############################################

# read data for n sequences.
temp = stdin.readline().split()
N = int(temp[0])
M = int(temp[1])

# すべての場合の数を計算。
probs = np.zeros(1).astype("int64")

for i,m in enumerate(range(M,N+2)):
    # 作れる最小は？
    if i == 0:
        small = np.sum(np.arange(m))
        #
        large = np.sum(np.arange(N+1-m,N+1))
    else:
        small = (small+m-1).astype("int64")
        large = (large + (N+1-m)).astype("int64")
    probs = probs + (large - small + 1)

print(int(probs%(1e9+7)))


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

using ll=long long;

const int N=305;

int n, m, s[3*N][3*N], t[3*N][3*N];
char b[3*N][3*N];
ll r;

int main(){
    scanf("%d%d", &n, &m);
    for(int i=0; i<n; i++) scanf("%s", b[i+N]+N);
    for(int i=0; i<6*N; i++) for(int x=i, y=0; y<3*N; x--, y++)
        if(0<=x&&x<3*N-1) s[x][y]=s[x+1][y-1]+(b[x][y]=='#');
    for(int i=-3*N; i<3*N; i++) for(int x=i, y=0; y<3*N; x++, y++)
        if(0<x&&x<3*N) t[x][y]=t[x-1][y-1]+(b[x][y]=='#');
    for(int i=N; i<=N+n+m-2; i++)
        for(int x=i, y=N; y<N+m; x--, y++) for(int z=x-1, w=y+1; w<N+m; z--, w++)
            if(b[x][y]=='#'&&b[z][w]=='#'){
                int u=w-y; r+=s[x][w+u]-s[x+u][w]+s[z-u+1][y-1]-s[z+1][y-u-1]; }
    for(int i=N-m+1; i<=N+n-1; i++)
        for(int x=i, y=N; y<N+m; x++, y++) for(int z=x+1, w=y+1; w<N+m; z++, w++)
            if(b[x][y]=='#'&&b[z][w]=='#'){
                int u=w-y; r+=t[z+u][y]-t[z][y-u]+t[x-1][w+u-1]-t[x-u-1][w-1]; }
    printf("%lld\n", r);
    return 0;
}

Measured memory_bytes: 7168
#include <bits/stdc++.h>
#define whlie while
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repr(i,N) for(int i = (N) - 1; i >= 0; i--)
#define rep1(i,N) for(int i = 1; i <= (N) ; i++)
#define repr1(i,N) for(int i = (N) ; i > 0 ; i--)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define vrep(v,it) for(auto it = v.begin(); it != v.end(); it++)
#define vrepr(v,it) for(auto it = v.rbegin(); it != v.rend(); it++)
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
using namespace std; void solve();
using ll = long long; using vl = vector<ll>;
using vi = vector<int>; using vvi = vector< vector<int> >;
constexpr int inf = 1001001001;
constexpr ll infLL = (1LL << 61) - 1;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(7);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cerr << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,N) do { cerr << #v << " = "; array_out(v , N);cout << endl;} while(0)
#else
  #define trc(...)
  #define trca(...)
  int main(){solve();}
#endif

using P = pair<ll,int>; using vp = vector<P>;
constexpr int MOD = /** 1000000007; //*/ 998244353;
///////////////////////////////////////////////////////////

void solve(){
  ins(S);
  string T = "AKIHABARA";
  int idx = 0;
  for(int i = 0; i < sz(T);){
    trc(i,idx);
    if(idx == sz(S)){
      if(T[i] == 'A') i++;
      else die("NO");
    }
    else if(S[idx] == T[i]) {idx++,i++;}
    else if(T[i] == 'A') i++;
    else die("NO");
  }
  out(idx==sz(S) ? "YES" : "NO");
  
}



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

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#ifdef Debug
#define dump(x)  cerr << #x << " = " << (x) << endl
#else
#define dump(x)
#endif

int data[30][30];
int h;


int dell(int data[30][30]){
	int ret=0;
	rep(i,h){
		rep(j,3){
			int num=1;
			rep(k,5){
				if(j+k>=5)break;
				if( data[i][j+k]!=-1 && data[i][j+k]==data[i][j+k+1])num++;
				else break;
			}
			if(num>=3){
				rep( k,num ){
					data[i][k+j]=-1;
				}
				ret++;
			}
		}
	}
	return ret;
}


void fall(int data[30][30]){
	rep(k,h){
	for(int i=h-1;i>=1;i--){
		rep(j,5){
			if(data[i][j]==-1)swap(data[i][j],data[i-1][j]);
		}
	}
	}
}


int main(){
	while(cin>>h){
		if(h==0)break;
		int bef=0;
		rep(i,h)
			rep(j,5){
				cin>>data[i][j];
				bef+=data[i][j];
			}
		while(1){
			if( dell(data)==0 )break;
			fall(data);
		}

		int af=0;
		rep(i,h)rep(j,5)if(data[i][j]!=-1)af+=data[i][j];

		cout<<bef-af<<endl;


	}
}

Measured memory_bytes: 1160
N,K = map(int,input().split())
S = input()

L =list(S)
if L[K-1]=='A':
  L[K-1]='a'
elif L[K-1]=='B':
  L[K-1]='b'
elif L[K-1]=='C':
  L[K-1]='c'
 
S=''.join(L)

print(S)  

Measured memory_bytes: 3060
//Can you get AC?
#include <bits/stdc++.h>
using namespace std;

int main(){
    string S;
    cin>>S;
    for(int i=0;i<S.size()-1;i++){
        if(S.at(i)=='A'&&S.at(i+1)=='C'){
            goto out;
        }
    }
    cout<<"No"<<endl;
    return 0;
    out:
        cout<<"Yes"<<endl;
        return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#define endl "\n"
#define ll long long
using namespace std;

int main()
{
    int s, w;
    cin >> s >> w;

    if(w >= s)
    	cout << "unsafe" << endl;
    else
    	cout << "safe" << endl;
}

Measured memory_bytes: 3588
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int change = 0;
  
  for(int i = 1000;; i+=1000)
  { if(i >= n)
  { change = i -n;
   break;}
  }
   cout<<change;
  return 0;}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/03/22  Problem: ABC 054 A / Link: http://abc054.contest.atcoder.jp/tasks/abc054_a  ----- */


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

	LL A, B; cin >> A >> B;
	string ans;
	if (A == 1)A += 100;
	if (B == 1)B += 100;
	if (A == B)ans = "Draw";
	else if (A < B)ans = "Bob";
	else ans = "Alice";
	
	
	cout << (ans) << "\n";

	return 0;
}


Measured memory_bytes: 256
//Link : https://codeforces.com/problemset/problem/1303/D

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 16
#define M 2000
#define mod 1000000007

int in[N+2];


map<pair<pair<int,int>,pair<int,int> >,ll> dp;
int t = 0;
ll solveDp(int l,int lv,int r,int rv) {
  if(l>r) {
    return 0;
  }
  t = max(t, max(lv,rv));
  assert(max(lv,rv)<M);
  if(dp.count(make_pair(make_pair(l,lv),make_pair(r,rv)))) {
    return dp[make_pair(make_pair(l,lv),make_pair(r,rv))];
  }
  ll ret = 4e18;
  for(int i=l;i<=r;++i) {
    ret = min(ret, (ll)in[i]*(lv+rv) +  solveDp(l,lv+rv,i-1,rv) + solveDp(i+1,lv,r,lv+rv) );
  }
  dp[make_pair(make_pair(l,lv),make_pair(r,rv))] = ret;
  return ret;
}
void solve() {
  int n;scanf("%d ", &n);
  ll ret = 0;
  for(int i=0;i<n;++i) {
    scanf("%d ", &in[i]);
  }
  ret += in[0] + in[n-1];
  for(int i=0;i<n-1;++i) {
    in[i] = in[i+1];
  }
  n-=2;
  if(n>0) {
    ret += solveDp(0,1,n-1,1);
  }
  printf("%lld\n", ret);
}

int main() {
    //freopen("input.txt","r",stdin);
    solve();
    return 0;
}


Measured memory_bytes: 16640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define pp pair<ll,ll>
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
int inf=1000001000;
ll INF=1e18;
ll MOD=INF;
ll mod=INF;


int main() {
  int n;
  cin >> n;
  vector<int> a(4,0);
  rep(i,n){
      string s;
      cin >> s;
      if (s=="AC") a[0]++;
      if (s=="WA") a[1]++;
      if (s=="TLE") a[2]++;
      if (s=="RE") a[3]++;
  }
  cout << "AC" << " " << "x" << " " << a[0] << endl;
  cout << "WA" << " " << "x" << " " << a[1] << endl;
  cout << "TLE" << " " << "x" << " " << a[2] << endl;
  cout << "RE" << " " << "x" << " " << a[3] << endl;
}


Measured memory_bytes: 3596
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <deque>
#include <vector>
#include <bitset>
#include <cmath>
#include <utility>
#define Maxn 100005
#define Maxm 1000005
#define lowbit(x) x&(-x)
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define PI acos(-1.0)
#define LL long long 
#define Inf (1LL<<62)
#define inf 0x3f3f3f3f
#define input freopen("input.txt","r",stdin)
#define output freopen("output.txt","w",stdout)
using namespace std;
int main()
{
	int r,g,b;
	while(cin>>r>>g>>b)
	{
		printf("%s\n",(r*100+g*10+b)%4?"NO":"YES");
	}
	return 0;
}

Measured memory_bytes: 256
L= input().split( )
a=int(L[0])
b=int(L[1])
c=int(L[2])
if a>b:
    a,b=b,a
if a>c:
    a,b,c=c,a,b
if b>c:
    b,c=c,b
print(f"{a} {b} {c}")



Measured memory_bytes: 5608
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <stack>
using namespace std;
typedef long long LL;
const int N = 1e5+7 , INF = 0x3f3f3f3f , mz = 1e9+7;
const double PI = acos(0.0) * 2;
template<typename T1>
T1 gcd(T1 a , T1 b){ return b ? gcd(b,a%b) : a;}

struct Edge{
    int from,to;
    LL dist;
    Edge(int u,int v,LL d):from(u),to(v),dist(d){}
};

struct HeapNode{
    int d,u;
    bool operator < (const HeapNode&rhs)const{
        return d > rhs.d;
    }
};

struct Dijkstra{
    int n,m;
    vector<Edge> edges;
    vector<int> G[N];
    bool done[N];
    LL d[N];
    int p[N];

    void init(int n){
        this->n = n;
        for(int i = 0 ; i <= n ; i++)    G[i].clear();
        edges.clear();
    }

    void AddEdge(int from , int to,LL dist){
        edges.push_back(Edge(from,to,dist));
        m = edges.size();
        G[from].push_back(m-1);
    }

    void dijkstra(int s){
        priority_queue<HeapNode> Q;
        for(int i = 0 ; i <= n ; i++)    d[i] = 1e17;
        d[s] = 0;
        memset(done,0,sizeof(done));
        Q.push( (HeapNode){0,s} );
        while( !Q.empty() ){
            HeapNode x = Q.top();Q.pop();
            int u = x.u;
            if( done[u] )   continue;
            done[u] = 1;
            for(int i = 0 ; i < G[u].size();i++){
                Edge& e = edges[G[u][i]];
                if( d[e.to] > d[u] + e.dist ){
                    d[e.to] = d[u] + e.dist;
                    p[e.to] = G[u][i];
                    Q.push( (HeapNode){d[e.to],e.to} );
                }
            }
        }
    }
    LL query(int x,int y){
        return d[x] + d[y];
    }
}ans;

int main(){
#ifdef LOCAL
    freopen("F:\\c++\\in.txt", "r", stdin);
//  freopen("F:\\c++\\out1.txt","w",stdout);
#endif
    int n,u,v,w;
    scanf("%d",&n);
    ans.init(n);
    for(int i = 1 ; i < n ; i++){
        scanf("%d%d%d",&u,&v,&w);
        ans.AddEdge(u,v,1LL*w);
        ans.AddEdge(v,u,1LL*w);
    }
    int q,k;
    scanf("%d%d",&q,&k);
    ans.dijkstra(k);
    while( q-- ){
        scanf("%d%d",&u,&v);
        printf("%lld\n",ans.query(u,v));
    }
    return 0;
}


Measured memory_bytes: 13932
import sys
from io import StringIO
import unittest
import os

# 再帰処理上限(dfs作成時に設定するのが面倒なので限度近い値を組み込む)
sys.setrecursionlimit(999999999)


# 実装を行う関数
def resolve(test_def_name=""):
    n = int(input())
    rw_s = list(input())

    count = rw_s.count("R")
    acted = rw_s[0:count].count("R")

    print(count - acted)


# テストクラス
class TestClass(unittest.TestCase):
    def assertIO(self, assert_input, output):
        stdout, sat_in = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(assert_input)
        resolve(sys._getframe().f_back.f_code.co_name)
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, sat_in
        self.assertEqual(out, output)

    def test_input_1(self):
        test_input = """4
WWRR"""
        output = """2"""
        self.assertIO(test_input, output)

    def test_input_2(self):
        test_input = """2
RR"""
        output = """0"""
        self.assertIO(test_input, output)

    def test_input_3(self):
        test_input = """8
WRWWRWRR"""
        output = """3"""
        self.assertIO(test_input, output)

    # 自作テストパターンのひな形(利用時は「tes_t」のアンダーバーを削除すること
    def tes_t_1original_1(self):
        test_input = """データ"""
        output = """データ"""
        self.assertIO(test_input, output)


# 実装orテストの呼び出し
if __name__ == "__main__":
    if os.environ.get("USERNAME") is None:
        # AtCoder提出時の場合
        resolve()

    else:
        # 自PCの場合
        unittest.main()


Measured memory_bytes: 83340
#!/usr/bin/env python3

M = 998244353
fact = None
factr = None

def comb(n, k):
    if n <= 0 or k < 0 or n < k:
        return 0
    r = fact[n] * factr[k] % M
    r *= factr[n - k]
    r %= M
    return r


def solve(k, n):
    global fact, factr

    inv = [1] * (k + n + 1)
    for i in range(2, k + n + 1):
        inv[i] = inv[M % i] * (M - M // i) % M
    fact = [1] * (k + n + 1)
    factr = [1] * (k + n + 1)
    for i in range(2, k + n + 1):
        fact[i] = fact[i - 1] * i % M
        factr[i] = factr[i - 1] * inv[i] % M

    if k == 1:
        print(0)
        return
    if k == 2:
        for _ in range(3):
            print(2)
        return


    g0 = (comb(k + n - 2, k - 2) + comb(k + n - 3, k - 2)) % M
    g1 = comb(k + n - 1, k - 1)

    rs0 = [0] * (min(k // 2, n // 2) + 1)
    rs1 = [0] * (min(k // 2, n // 2) + 1)
    for t in range(1, min(k // 2, n // 2) + 1):
        rs0[t] = (comb(k + n - 2 * t - 2, k - 2) + comb(k + n - 2 * t - 3, k - 2)) % M
        rs1[t] = comb(k + n - 2 * t - 1, k - 1)

    results = [0] * (k + 2)

    for i in range(2, k + 2):
        ns = (i - 1) // 2
        ans = g0 if i % 2 == 0 else g1
        p = -1
        for t in range(1, min(ns, n // 2) + 1):
            r = rs0[t] if i % 2 == 0 else rs1[t]
            r *= comb(ns, t)
            r %= M
            ans += M + p * r
            ans %= M
            p = 0 - p
        print(ans)
        results[i] = ans
    for i in range(k + 2, 2 * k + 1):
        print(results[2 * k + 2 - i])


def main():
    k, n = input().split()
    k = int(k)
    n = int(n)

    solve(k, n)


if __name__ == '__main__':
    main()



Measured memory_bytes: 3896
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <iomanip>
#include <vector>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <ctime>
#include <fstream>
#ifdef WIN32
	#include <windows.h>
#endif
using namespace std;
#define ll long long
#define pii pair<int,int>
#define de cout<<1
#define FOR0(NAME,END) for(int NAME=0;NAME<END;NAME++)
#define FOR(NAME,FIRST,END) for(int NAME=FIRST;NAME<=END;NAME++)
#define openi(s) freopen(s,"r",stdin)
#define openo(s) freopen(s,"w",stdout)
const bool debug=false;
const bool INJUDGE=false;
int n,k;
int a[200005];
set<int> s;
map<int,int> m;
int main(){
    scanf("%d%d",&n,&k);
    for(int i=0;i<n;i++){
    	scanf("%d",&a[i]);
    	s.insert(a[i]);
    }
    if(s.size()<=k){
    	puts("0");
    } 
    else{
    	for(int i=0;i<n;i++){
    		m[a[i]]++;
    	}
    	vector<int> v;
    	for(map<int,int>::iterator it=m.begin();it!=m.end();it++){
    		v.push_back(it->second);
    	}
    	sort(v.begin(),v.end());
    	int ss=0;
    	for(int i=k;i<s.size();i++){
    		ss+=v[i-k];
    	}
    	printf("%d\n",ss);
    }
	return 0;
}


Measured memory_bytes: 20988
N, k = gets.split(/ /).map(&:to_i)
to = {}
i = 1
gets.split(/ /).map(&:to_i).each do |a|
  to[i] = a
  i += 1
end

pos = 1
index = 0
visited = { 1 => index }
loop do
  pos = to[pos]
  k -= 1
  if k == 0
    puts pos
    exit
  end
  index += 1
  v = visited[pos]
  if v # loop found
    loop_size = index - v
    k = k % loop_size
  else
    visited[pos] = index
  end
end


Measured memory_bytes: 44420
using System;

class AtCoder {
  static void Main() {
    var N = int.Parse(Console.ReadLine().Trim());
    var S = Console.ReadLine().Trim();
    char[] answer = new char[S.Length];
    
    //int Z = 'A';
    //Console.WriteLine((int)Z);
    
    for(var i = 0; i < S.Length; i++) {
      char c = S[i];
      int c_ = (int)c + N;
      if(c_ > 90) {
        c_ = c_ - 90 + 64;
      }
      c = (char)c_;
      //Console.WriteLine(c);
      answer[i] = c;
    }
    Console.WriteLine(answer);
    
  }
}

Measured memory_bytes: 11176
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(c) (c).begin(), (c).end()
#define pb push_back
#define eb emplace_back
using namespace std;
const long long INF = 1LL<<60; // 仮想的な無限大の値;
using ll = long long;
using P  = pair<int, int>;
#define vi vector<int>
#define vll vector<ll>
#define vs vector<string>
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; }

int main()
{
    string a, b;
    cin >> a >> b;
    string s = a + b;
    int x = stoi(s);
    int y = sqrt(x);
    //cout << y << endl;
    rep2(i, y, 10000){
        if(i*i == x){
            cout << "Yes" << endl; return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3556
//gauravsinghh
#pragma GCC optimize("O3", "unroll-loops")
#pragma GCC target("avx2")
#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 ll long long int
#define ld long double
#define db double
#define pii pair<int,int>
#define pll pair<long long,long long>
#define sii set<int>
#define sll set<long long>
#define vii vector<int> 
#define vll vector<long long>
#define mii map<int,int>
#define mll map<long long, long long>
#define lob lower_bound
#define upb upper_bound
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define pf push_front
#define ins insert
#define mp make_pair
#define w(t) cin >> t;while(t--)
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define os cout<<" "
#define bitcount __builtin_popcount
#define gcd __gcd
#define endl "\n"
#define present(s,x) (s.find(x) != s.end()) 
#define cpresent(s,x) (find(all(s),x) != s.end()) 
#define ford(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++) 
#define fors(container, it, a, b) for(__typeof(container.begin()) it = a; it != b; it++) 
#define EPSILON 1e-9
#define PI 3.14159265358979323846
#define inf 1000000000
#define lim 100005
#define fbo find_by_order
#define ook order_of_key
#define sz(s) (int)s.size()
#define mem(n,m) memset(n,m,sizeof(n))
#define deb(x) cout << #x << " " << x << endl;
#define rep(i,n) for(ll i = 0; i < n; i++)
#define ren(i,n) for(ll i = n-1; i >= 0; i--)
#define all(x) x.begin(),x.end()
#define fo(i, a, b) for(ll i = a; i <= b; i++)
#define ffo(i, a, b) for(ll i = a; i >= b; i--)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
void io_set() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}
 
int main(){
    IOS
    //io_set();
    ll a, b;
    cin >> a >> b;
    cout << 6 - a - b << endl;
    return 0;
} 




































































































 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

int main() {
    int N, M;
    cin >> N >> M;
    vector<vector<int>> s(M,vector<int>(0));
    rep(i,0,M) {
        int k;
        cin >> k;
        rep(j,0,k) {
            int m;
            cin >> m;
            s[i].push_back(m-1);
        }
    }
    vector<int> p(M);
    rep(i,0,M) cin >> p[i];

    int ans = 0;
    rep(bit, 0, 1<<N) {
        bool can = true;
        rep(i,0,M) {
            int sum_on = 0;
            for (auto j : s[i]) {
                if (bit & (1<<j)) sum_on++;
            }
            if (sum_on % 2 != p[i]) {
                can = false;
                break;
            }
        }
        if (can) ans++;
    }
    cout << ans << endl;
}

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

using namespace std;

char cmp[3003];
int dp[3003][3003], pref[3003][3003];

const int mod = 1e9 + 7;

void add_self (int& a, int b) {
  a += b;
  if (a >= mod)
    a -= mod;
}

int main() {
  int n;
  cin >> n >> cmp;
  dp[1][1] = 1;
  for (int len = 2; len <= n; ++len) {
    for (int i = 1; i < len; ++i)
      pref[len - 1][i] = (pref[len - 1][i - 1] + dp[len - 1][i]) % mod;
    for (int b = 1; b <= len; ++b) {
      int L, R;
      if (cmp[len - 2] == '<')
        L = 1, R = b - 1;
      else
        L = b, R = len - 1;
      if (L <= R)
        add_self (dp[len][b], (pref[len - 1][R] - pref[len - 1][L - 1] + mod) % mod);
    }
  }
  int ans = 0;
  for (int b = 1; b <= n; ++b)
    add_self (ans, dp[n][b]);
  cout << ans;
}

Measured memory_bytes: 58700
require 'pp'
require 'set'

n = gets.chomp!.to_i
a_n = []
a_n3 = {}
a_n2 = SortedSet.new
max1 = -1
max2 = -1
n.times do |i|
    a = gets.chomp!.to_i
    a_n3[a] ||= 0
    a_n3[a] += 1
    a_n << a
    a_n2 << a
end

a_n2.reverse_each.with_index(0) do |x, i|
    if i == 0
        max1 = x
    elsif i == 1
        max2 = x
    else
        break
    end
end

if a_n3[max1] >= 2
    max2 = max1
end

a_n.each do |num, cnt|
    if max1 == num
        puts max2
    else
        puts max1
    end
end


Measured memory_bytes: 22364
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int t = sc.nextInt();
		int maxL = 0;
		int lSum = 0;

		for(int i= 0; i < t; i++) {
			int l = sc.nextInt();
			if(l > maxL) {
				lSum += maxL;
				maxL = l;
			} else {
				lSum += l;
			}
		}

		if (maxL < lSum) {

			System.out.println("Yes");
		} else {
			System.out.println("No");

		}



	}

}


Measured memory_bytes: 23252
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <tuple>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
const int INF = 1000000000;
const int MOD = 1000000007;
int main(){
	ll n;
	cin >> n;
	map<ll,ll> mp;
	for(ll i = 2;i * i <= n;i++){
		while(n % i == 0){
			mp[i]++;
			n /= i;
		}
	}
	if(n != 1)mp[n]++;

	ll ans = 0;
	for(auto p:mp){
		ll cnt = p.second;
		ll now = 0;
		for(ll i = 1;;i++){
			if(now + i <= cnt){
				now += i;
				ans++;
			}
			else break;
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 3612
#include <stdio.h>

int main() {
  int number_a, number_b, number_c;
  scanf("%d %d %d", &number_a, &number_b, &number_c);
  if(number_b == number_c) {
    printf("%d\n", number_a);
  } else if(number_c == number_a) {
    printf("%d\n", number_b);
  } else if(number_a == number_b) {
    printf("%d\n", number_c);
  }
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
 #include<stdio.h>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 
 using namespace std;
 
 const double pi=3.1415926535897932384626;
 
 int main()
 {
   double r;
   cin>>r;
   double S=1.0000000000000*pi*r*r;
   double C=2.0000000000000000*pi*r;
   printf("%.6lf %.6lf\n",S,C);
   //while(1);
   return 0;
 }
 
 

Measured memory_bytes: 3272
s = input()
t = input()

s2 = []
t2 = []

sdic = {}
tdic = {}

cnt = 0
for c in s:
    if c in sdic:
        s2.append(sdic[c])
    else:
        s2.append(cnt)
        sdic[c] = cnt
        cnt += 1

cnt = 0
for c in t:
    if c in tdic:
        t2.append(tdic[c])
    else:
        t2.append(cnt)
        tdic[c] = cnt
        cnt += 1

print("Yes" if s2 == t2 else "No")


Measured memory_bytes: 6832
<?php
  
$n = trim(fgets(STDIN));
$p = explode(' ', trim(fgets(STDIN)));
$x = $q = explode(' ', trim(fgets(STDIN)));
sort($x);
$pstr = implode($p);
$qstr = implode($q);

$r = pat($x);

$ansl = $ansr = 0;
$c = 0;
for($i=0; $i<count($r); $i++){
  $c++;
  if ($r[$i] == $pstr){
    $ansl = $i;
  }
  if ($r[$i] == $qstr){
    $ansr = $i; 
  }
}

$ans =  abs($ansl-$ansr);
echo $ans;

function pat($a, $s = '')
{
  $r = array();
  if (count($a) && is_array($a)) {
    foreach ($a as $k => $v) {
      $_s = $s . $v;
      $_a = $a;
      unset($_a[$k]);
      $_r = pat($_a, $_s);
      $r = array_merge($r, $_r);
    }
  } else {
    $r[] = $s;
  }
  return $r;
}

?>

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

using namespace std;

int main() {
    int A, B;
    cin >> A >> B;

    for (int N = 0; N < 20000; N++){
        if ((int)((float)N * 0.08) == A && (int)((float)N * 0.10) == B){
            cout << N << endl;
            return 0;
        }
    }
    cout << "-1" << endl;
    return 0;

}

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

using namespace std;

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

    int count = 0;

    for (int i = 0; i < N; i += 2)
    {
        if (a[i] % 2 == 1)
        {
            count++;
        }
    }
    cout << count << endl;

    return 0;
}

Measured memory_bytes: 3164