akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<int(n);i++)
#define FOR(i,n,m) for(int i=n;i<int(m);i++)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
using namespace std;
 
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
 
int vx[]={0,0,-1,1};
int vy[]={1,-1,0,0};
int dx[]={1,0,-1,1,-1,1,0,-1};
int dy[]={1,1,1,0,0,-1,-1,-1};
 
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b/gcd(a,b);}	
 
const ll mod=1e9+7;
const int INF=INT_MAX/2;

int main(){
	string s;
	cin>>s;
	for(int i=0;i<s.size();i+=2){
		if(s[i]=='h' && s[i+1]=='i')continue;
		else{
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
}
 

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string.h>
#include <queue>
#include <map>
#include <string>
#include <stack>
#include <utility>
#include <queue>
#include <cmath>
#define mp make_pair
#define pii pair<int,int> 
#define ff first
#define ss second
#define ll long long 
#define vi vector<int>
#define vvi vector <vi>

using namespace std;

int a[5];

int main()
{
	while(scanf("%d %d %d",&a[0],&a[1],&a[2])!=EOF)
	{
		sort(a,a+3);
		printf("%d %d %d\n",a[0],a[1],a[2]);
	}
	return 0;
}

Measured memory_bytes: 1204
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<map>
#include<list>
#include<set>
using namespace std;
int search(int A[],int n,int key){
  int i=0;
  A[n]=key;
  while(A[i]!=key){
    i++;
  }
  return i!=n;
}
int main(){
  int i,n,A[10000+1],q,key,sum=0;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> A[i];
  }
  cin >> q;
  for(int i=0;i<q;i++){
    cin >> key;
    if(search(A,n,key)){
      sum++;
    }
  }
  cout << sum << endl;
  return 0;
}



Measured memory_bytes: 3100
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)

struct INIT{
    INIT(){
        std::ios::sync_with_stdio(false);
        std::cin.tie(0);
        cout << fixed << setprecision(13);
    }
}INIT;

int n;
int l[303030];
int main(){
	cin >> n;
	REP(i, n)cin >> l[i];
	sort(l, l + n);
	LL ans = 0;
	REP(i, n){
		for(int j = i + 1;j < n;j++){
			int na = lower_bound(l, l + n, l[i] + l[j]) - l - 1;
			if(na < 0)continue;
			int nb = upper_bound(l, l + n, max(l[i] - l[j], l[j] - l[i])) - l;
			int num = na - nb + 1;
			if(max(l[i] - l[j], l[j] - l[i]) < l[i] && l[i] < l[i] + l[j])num--;
			if(max(l[i] - l[j], l[j] - l[i]) < l[j] && l[j] < l[i] + l[j])num--;
			if(num < 0)continue;
			ans += num;
		}
	}
	cout << ans/3 << endl;
}

Measured memory_bytes: 384
#include <stdio.h>

int main(void){
	int a, b, c;

	scanf("%d%d%d", &a, &b, &c);

	if(a>b) {
		a^=b^=a^=b;
	}
	if(b>c) {
		b^=c^=b^=c;
	}
	if(a>b) {
		a^=b^=a^=b;
	}

	if(a==5 && b==5 && c==7) {
		printf("YES");
		return 0;
	}
	printf("NO");

	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
	cout << fixed << setprecision(10);
	string s;
	cin >> s;
	int ans = 0;
	rep(i,s.size()){
		if(s[i]=='+') ans++;
		else ans--;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}
 
int main() {
 int N;
 cin>>N;
 vector<tuple<string,int,int>>v(N);
 for(int i=0;i<N;i++){
   string s;
   int p;
   cin>>s>>p;
   v[i]=make_tuple(s,-p,i+1);
 }
 sort(v.begin(),v.end());
 for(auto r:v){
   string s;
   int p,y;
   tie(s,p,y)=r;
   cout<<y<<endl;
 }
 return 0;
}

Measured memory_bytes: 3632
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace attocoda
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b;
            var word = Console.ReadLine().Split(' ');
            a = int.Parse(word[0]);
            b = int.Parse(word[1]);
           if(a>b*2)
            {
                Console.WriteLine(a - b * 2);
            }
           else if(a<=b*2)
            {
                Console.WriteLine(0);
            }
            Console.ReadKey();
        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define F first
#define S second
#define pb push_back
#define forn(b) for(int i = 0; i < b; i++)
#define rforn(b) for(int i = b - 1 ;i >= 0; i--)
#define It(m) for(auto it = m.begin(); it != m.end(); it++)
#define N 500500
#define PI 3.14159265358979323846264338327950L
#define speed ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);
	
const ll mod = (ll)1e9 + 7;
	
int main(){
	speed;
	int n, m, k; cin >> n >> m >> k;
	char c[n][m];
	map<int, int> r;
	map<int, int> col;
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < m; j++) {
			cin >> c[i][j];
		}
	}
	for(int i = 0; i < n; i++) {
		int cnt = 0;
		for(int j = 0; j < m; j++) {
			if(c[i][j] == '#') {
				cnt++;
			}
		}
		r[i] = cnt;
	}
	int sum = 0;
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < m; j++) {
			if(c[i][j] == '#') {
				sum++;
			}
		}
	}
	for(int i = 0; i < m; i++) {
		int cnt = 0;
		for(int j = 0; j < n; j++) {
			if(c[j][i] == '#') cnt++;
		}
		col[i] = cnt;
	}
	int ans = 0;
	vector<vector<int>> row;
	vector<vector<int>> column;
	for(int mask = 0 ; mask < (1 << n); mask++) {
		vector<int> a;
		for(int i = 0; i < n; i++) {
			if(mask & (1 << i)) {
				a.push_back(i);
			}
		}
		row.push_back(a);
	}
	for(int mask = 0 ; mask < (1 << m); mask++) {
		vector<int> a;
		for(int i = 0; i < m; i++) {
			if(mask & (1 << i)) {
				a.push_back(i);
			}
		}
		column.push_back(a);
	}
	for(int i = 0; i < row.size(); i++) {
		for(int j = 0; j < column.size(); j++) {
			vector<int> a = row[i];
			vector<int> b = column[j];
			int cnt = sum;
			map<pii, bool> ma;
			for(int i1 = 0; i1 < a.size(); i1++) {
				for(int i2 = 0; i2 < m; i2++) {
					if(c[a[i1]][i2] == '#') {
						cnt--;
						ma[{a[i1], i2}] = true;
					}
				}
			}
			//cout << j << endl;
			if(cnt < k) continue;
			for(int i1 = 0; i1 < b.size(); i1++) {
				for(int i2 = 0; i2 < n; i2++) {
					if(c[i2][b[i1]] == '#' && ma[{i2, b[i1]}] == false) {
						cnt--;
					}
				}
			}
			if(cnt == k) ans++;
			
		}
	}
	cout << ans;

	return 0;
}

Measured memory_bytes: 3648
n = int(input())

if n%2==0:
    print(n*(n-1)//2-n//2)
    for i in range(1,n+1):
        for j in range(1,i):
            if i+j != n+1:
                print(i,j)
                

else:
    print(n*(n-1)//2-n//2)
    for i in range(1,n+1):
        for j in range(1,i):
            if j + i != n:
                print(i,j)

Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
 
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

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

    ll l0 = 2;
    ll l1 = 1;
    for(int i = 2; i <= n; ++i){
        ll tmp = l1;
        l1 = l0 + l1;
        l0 = tmp;
    }
    cout << l1 << endl;
}

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

#define pb push_back
#define vi vector < int >
#define ii pair < int, int >
#define vii vector < pair < int, int > >
#define vvi vector < vector < int > >
#define ll long long
#define X first
#define Y second
#define mp make_pair
#define FOR( i, lo, hi ) for( int i = (lo);i < (hi);i++ )
#define DFOR( i, hi, lo ) for( int i = (hi);i >= (lo);i-- )
#define pqueue priority_queue

using namespace std;

const int MAXN = 1e5 + 10;

int n;
int A[ MAXN ];

int main()
{
	cin >> n;
	FOR( i, 0, n )
	{
		cin >> A[ i ];
		if ( i > 0 )
		{
			if ( A[ i ] > A[ i - 1 ] )
				A[ i ]--;
		}
		else
		{
			A[ i ]--;
		}
		
		if ( i > 0 && A[ i ] < A[ i - 1 ] )
		{
			cout << "No\n";return 0;
		}  
	}
	cout << "Yes\n";
	return 0;
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	string S="pphbhhphph";
	
	cin>>N;
	cout<<S[N%10]<<"on"<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 3652
package main
import "fmt"
func main() {
  var p int
  fmt.Scan(&p)
  a := make([]int,p)
  for i:=0;i<p;i++ { fmt.Scan(&a[i]) }
  b := make([]int,p)
  f := make([]int,p)
  f[0] = 1
  for i:=1;i<p;i++ { f[i] = (i*f[i-1])%p }
  for i:=0;i<p;i++ {
    if a[i] == 0 { continue }
    h := (f[i]*f[p-i-1])%p
    if (p-i-1)%2 == 1 { h = p-h }
    h = inv(h,p)
    g := make([]int,p+1)
    g[1],g[p] = p-1,1
    for j:=p-1;j>-1;j-- {
      b[j] = (b[j]+h*g[j+1])%p
      g[j] = (g[j]+i*g[j+1])%p
    }
  }
  for i:=0;i<p;i++ { fmt.Println(b[i]) }
}
func inv(n,p int) int {
  a,b,c,x := n%p,p,0,1
  for b != 0 { a,b,c,x = b,a%b,x-(a/b)*c,c }
  x %= p
  if x < 0 { x += p }
  return x
}

Measured memory_bytes: 7552
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


ll fact[220010];

ll extgcd(ll a,ll b,ll &x,ll &y){
	ll d = a;
	if(b != 0){
		d = extgcd(b,a%b,y,x);
		y -= (a/b)*x;
	}else{
		x = 1;
		y = 0;
	}
	return d;
}

ll mod_inverse(ll a,ll m){
    ll x,y;
    extgcd(a,m,x,y);
    return (m+x%m)%m;
}

ll mod_fact(ll n,ll p,ll &e){
	e = 0;
	if(n == 0)return 1;

	int res = mod_fact(n/p,p,e);
	e += n/p;

	if(n/p%2 != 0)return res*(p-fact[n%p])%p;
	return res*fact[n%p]%p;
}

ll nCm(ll n,ll m,ll p){
   if(n < m) return 0;
   ll e1,e2,e3;
    ll a1 = mod_fact(n,p,e1),a2 = mod_fact(m,p,e2),a3 = mod_fact(n-m,p,e3);
    if(e1 > e2+e3)return 0;
    return a1 * mod_inverse(a2*a3%p,p)%p;
}

int main(){

	ll N,M,K;
	scanf("%lld %lld %lld",&N,&M,&K);

	 fact[0] = 1;
	 for(ll i = 1;i <= 220000; i++){
		 fact[i] = fact[i-1]*i%MOD;
	 }

	ll tmp,west_east,north_south,south,ans = 0;
	for(ll west = 0; west <= K; west++){

		south = K-west;

		//左右動と上下動の組み合わせの場合の数
		tmp = nCm(N+M+2*K,N+2*west,MOD); //引き返した分、南であれ西であれ、反対方向（本来の方向）に動くので、移動総数はN+M+2*Kになる

		//西の出た回数>東の出た回数とならない、左右動の場合の数
		west_east = (nCm(N+2*west,N+west,MOD)-nCm(N+2*west,N+west+1,MOD)+MOD)%MOD;

		tmp *= west_east;
		tmp %= MOD;

		//南の出た回数 > 北の出た回数とならない、上下動の場合の数
		north_south = (nCm(M+2*south,M+south,MOD)-nCm(M+2*south,M+south+1,MOD)+MOD)%MOD;

		tmp *= north_south;
		tmp %= MOD;

		ans += tmp;
		ans %= MOD;
	}

	printf("%lld\n",ans%MOD);

	return 0;
}



Measured memory_bytes: 4936
# import sys
# sys.setrecursionlimit(10 ** 6)
# import bisect
# from collections import deque
# from decorator import stop_watch
#
#
# @stop_watch
def solve(N, K, R, S, P, T):
    k_list = [[] for _ in range(K)]
    for i in range(len(T)):
        k_list[i % K].append(T[i])

    ans = 0
    for kl in k_list:
        dp = [[0, 0, 0] for _ in range(len(kl) + 1)]
        for i in range(len(kl)):
            # rock
            dp[i + 1][0] = max(dp[i][1], dp[i][2])
            dp[i + 1][0] += R if kl[i] == 's' else 0
            # scissors
            dp[i + 1][1] = max(dp[i][0], dp[i][2])
            dp[i + 1][1] += S if kl[i] == 'p' else 0
            # paper
            dp[i + 1][2] = max(dp[i][0], dp[i][1])
            dp[i + 1][2] += P if kl[i] == 'r' else 0
        ans += max(dp[-1])

    print(ans)


if __name__ == '__main__':
    N, K = map(int, input().split())
    R, S, P = map(int, input().split())
    T = input()

    # N, K = 10 ** 5, 10 ** 3
    # R, S, P = 100, 90, 5
    # T = 'r' * 10 ** 5

    solve(N, K, R, S, P, T)


Measured memory_bytes: 29600
#define _CRT_SECURE_NO_WARNINGS
#include <array>
#include <string>
using namespace std;

const int ns = 50;
const int ms = 50;

int N, M;

array<string, ns> board;
array<string, ms> pattern;

bool match(int x, int y)
{
    for (int i = 0; i < M; i++)
        for (int j = 0; j < M; j++)
            if (board[x + i][y + j] != pattern[i][j])
                return false;

    return true;
}

int main()
{
    const char *Yes = "Yes";
    const char *No = "No";

    if (scanf("%d%d", &N, &M) < 2) return 0;

    for (int i = 0; i < N; i++)
    {
        char tmp[ns];
        if (scanf("%s", tmp) < 1) return 0;
        board[i] = tmp;
    }

    for (int i = 0; i < M; i++)
    {
        char tmp[ns];
        if (scanf("%s", tmp) < 1) return 0;
        pattern[i] = tmp;
    }

    bool found = false;
    for (int i = 0; i <= N - M; i++)
    {
        for (int j = 0; j <= N - M; j++)
        {
            if (match(i, j))
            {
                found = true;
                break;
            }
        }
        if (found) break;
    }

    printf("%s\n", found ? Yes : No);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>  
#include <cstdio>  
using namespace std;  
  
const int N = 10;  
  
int a[N];  
  
void input()  
{  
    for (int i = 0; i < N; i ++) {  
        scanf("%d", &a[i]);  
    }  
}  
  
void solve()  
{  
    bool res = false;  
    for (int k = 0; k < (1<<10); k++) {  
        int num = 0;  
        int i;  
        for (i = 0; i < N; i ++) {  
            if ( (1 << i)&k ) {  
                if (a[i] > num)  
                    num = a[i];  
                else  
                    break;  
            }  
        }  
        if (i < N)  
            continue;  
        num = 0;  
        for (i = 0; i < N; i ++) {  
            if ( ((1 << i)&k) == 0 ) {  
                if (a[i] > num)  
                    num = a[i];  
                else  
                    break;  
            }  
        }  
        if (i == N) {  
            res = true;  
            //printf("k=%d\n", k);  
            break;  
        }  
    }  
    if (res)  
        printf("YES\n");  
    else  
        printf("NO\n");  
}  
  
int main(void)  
{  
    int t;  
    cin >> t;  
    while (t--) {  
        input();  
  
        solve();  
    }  
  
    return 0;  
}

Measured memory_bytes: 3032
//#include "pch.h"
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>

#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <bitset>

#define ll long long
#define fri(n) for(i=0;i<(n);i++)
#define frj(n) for(j=0;j<(n);i++)
#define min(p,q) ((p)<(q)?(p):(q))
#define max(p,q) ((p)>(q)?(p):(q))
#define INF 1000000000000000000//10^18
#define INFINT 2000000001//2*10^9+1
#define MOD 1000000007
#define MODANOTHER 998244353
#define PI acos(-1)

using namespace std;



int main(void)
{
	//変数の宣言
	int n;
	static int a[500010];
	static ll int ruiseki[500010];
	static ll int c[1050000][3];
	int num0=0;

	//よく使う変数
	int i,j,k,l;
	int flag=0;
	ll int ans=0;
	int count=0;
	ll int temp=0;
	int temp1=0;
	int temp2=0;
	int max=0;
	int min=INFINT;
	int len=0;
	int sum=0;
	int ok=0;
	int ng=0;
	char dummy;



	//データの読み込み


	scanf("%d",&n);
//	scanf_s("%d",&n);


//	scanf("%s",&s);
//	scanf_s("%s",&s,200010);

//	scanf("%c",&dummy);
//	scanf_s("%c",&dummy);


	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
//		scanf_s("%d",&a[i]);
	}

/*	for(i=0;i<n;i++){
//		scanf("%c",&t[i]);
		scanf_s("%c",&t[i]);
	}*/

	//	printf("nは%dです\n", n);
	//	printf("データの読み込み終了\n");
	//実際の処理

	for(i=0;i<n;i++){
		if(i==0){
			ruiseki[0]=a[0];
		}else{
			ruiseki[i]=ruiseki[i-1]^a[i];
		}
	}
	
/*	for(i=0;i<n-1;i++){
		printf("(%lld:%lld)\n",ruiseki[i],ruiseki[n-1]^ruiseki[i]);
	}*/
	
	for(i=0;i<1048577;i++){
		c[i][0]=1;
		c[i][1]=0;
		c[i][2]=0;
	}

	if(ruiseki[n-1]==0){
		for(i=0;i<n-1;i++){
			if(ruiseki[i]!=0){
				c[ruiseki[i]][0]=c[ruiseki[i]][1]*(num0-c[ruiseki[i]][2])+c[ruiseki[i]][0];
				c[ruiseki[i]][1]=c[ruiseki[i]][1]+c[ruiseki[i]][0];
				c[ruiseki[i]][2]=num0;

				c[ruiseki[i]][0]=c[ruiseki[i]][0]%MOD;
				c[ruiseki[i]][1]=c[ruiseki[i]][1]%MOD;
			}else{
				num0++;
			}
		}
		for(i=1;i<1048577;i++){
//			if(c[i][1]!=0) printf("c[%d][1]=%lld\n",i,c[i][1]);
			ans=ans+c[i][1];
			ans=ans%MOD;
		}

		temp=1;
		for(i=0;i<num0;i++){
			temp=temp*2;
			temp=temp%MOD;
		}

//		printf("c[0][1]=%lld\n",temp);
		ans=ans+temp;
		ans=ans%MOD;

	}else{
		for(i=0;i<n-1;i++){
			if(ruiseki[i]==ruiseki[n-1]){
				c[0][1]=c[0][0]+c[0][1];
				c[0][1]=c[0][1]%MOD;
			}else if(ruiseki[i]==0){
				c[0][0]=c[0][0]+c[0][1];
				c[0][0]=c[0][0]%MOD;
			}

//			printf("i=%d,[%lld,%lld]\n",i,c[0][0],c[0][1]);
		}

		ans=c[0][0];
	}


	//	printf("計算部分終了\n");

	//出力

	printf("%lld",ans);


	//	printf("結果の出力終了\n");

	return 0;
}



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

int main(){
	int x,y;
	cin >> x >> y;
	while(!(x==0&&y==0)){
		if(x<y) cout << x << " " << y << endl;
		else cout << y << " " << x << endl;
		cin >> x >> y;
	}
	return 0;
}



Measured memory_bytes: 3004
from collections import deque
H,W,K = map(int,input().split())
sx,sy,gx,gy = map(int,input().split())
sx-=1;sy-=1;gx-=1;gy-=1
Pond = []; INF = float("inf")
for i in range(H):
  temp = str(input());temp = list(temp)
  Pond.append(temp)
#print(Pond)
Q = deque([])
Q.append((sx,sy))
reach = [[INF]*W for _ in range(H)]
reach[sx][sy] = 0
dxdy = [(1,0),(-1,0),(0,1),(0,-1)]
while Q:
  nx,ny = Q.popleft()
  step = K
  for i in range(4):
    for fac in range(1,K+1):
      tx = nx + fac*dxdy[i][0]
      ty = ny + fac*dxdy[i][1]
      #print(i,tx,ty)
      if 0>tx or tx>=H or 0>ty or ty>=W or Pond[tx][ty] == "@": #or reach[tx][ty] != INF:
        #print(i,tx,ty,reach[2][0])
        break #範囲外やハスがあった、到達済みの場合には終了
      #print(i,tx,ty)
      if reach[nx][ny] + 1 > reach[tx][ty]: #もし現時点よりもステップが大きい場合はだめ。
        #同じ場合は向き的に得している場合もあるので残す。
        break
      if reach[nx][ny] + 1 == reach[tx][ty]:
        #同じときはQに加える必要はないが、そのまま先に進んだら得の場合があるのでContinue
        continue
      reach[tx][ty] = reach[nx][ny] + 1
      Q.append((tx,ty))

#print(reach)
ans = reach[gx][gy]
if ans == INF:
  print(-1)
else:
  print(ans)

Measured memory_bytes: 144600
#include <bits/stdc++.h>
#define int long long
#define double long double
using namespace std;
const int MOD = 1000000007;
const int INF = 1e18;
using Graph = vector<vector<int>>;

signed main() {
  int N;
  cin >> N;
  cout << ((N+999)/1000)*1000-N << endl;
}


Measured memory_bytes: 3620
#include <iostream>
#include <fstream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <string>
#include <iomanip>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
using namespace std;
typedef long long ll;

int main(){
	
	int n; cin >> n;
	
	int s[n];
	for(int i=0; i<n; i++){
		cin >> s[i];
	}
	
	vector<int> vs;
	for(int i=0; i<n; i++){
		if(s[i] % 10 != 0){
			vs.push_back(s[i]);
		}
	}
	
	sort(vs.begin(), vs.end());
	
	int sum = accumulate(s, s+n, 0);
	
	if(sum % 10 != 0){
		cout << sum;
	}
	else if(vs.size() == 0){
		cout << 0;
	}
	else{
		cout << sum - vs[0];
	}
	
	return 0;
}

Measured memory_bytes: 256
import itertools

n=int(input())
p=tuple(map(int,input().split()))
q=tuple(map(int,input().split()))

l = [i for i in range(1,n+1)]

r=[]
for v in itertools.permutations(l):
    r.append(v)
    
pp=r.index(p)
qq=r.index(q)
print(abs(pp-qq))

Measured memory_bytes: 7924
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
using namespace std;
typedef long long ll;

int main()
{
  int X;
  int res=0;
  cin >> X;

  FOR(i,X,INF){
    bool prime=true;
    FOR(j,2,i-1){
      if(i%j==0){
        prime = false;
        break;
      }
    }
    if(prime) {
      cout << i << endl;
      return 0;
    }
  }
}


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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}


typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
//#define mp make_pair


int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  ll ans = 0;
  rep (i, 1 << n) {
    string r, b;
    rep (j, n) {
      if (i & (1 << j)) {
        r += s[j];
      }
      else {
        b += s[j];
      }
    }
    reverse(all(b));
    string r_dist = r + b;
    string b_dist = r_dist;
    reverse(all(b_dist));
    vll dp(n + 1, vl(n + 1));
    dp[0][r.size()] = 1;
    rep (j, n) {
      rep (r_i, n + 1) {
        int b_i = n + j - r_i;
        if (!in(b_i, 0, n + 1)) continue;
        if (r_i != n && s[n + j] == r_dist[r_i]) {
          dp[j + 1][r_i + 1] += dp[j][r_i];
        }
        if (b_i != n && s[n + j] == b_dist[b_i]) {
          dp[j + 1][r_i] += dp[j][r_i];
        }
      }
    }
    ans += dp[n][n];
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cmath>
using namespace std;
int main(void){

	// hi = max(H - |X - Cx| - |Y - Cy|, 0) N個のケース100 * 100を捜査して
	int N;		cin >> N;
	int x[101], y[101], h[101];
	int keep = 200;
	for(int i = 0 ; i < N ; i++){
		cin >> x[i] >> y[i] >> h[i];
		//テキトーに高さ1以上の点を保存
		if(h[i] > 0) keep = min(keep, i);
	}

	//中心座標全探索
	for(int i = 0 ; i <= 100 ; i++){
		for(int j = 0 ; j <= 100 ; j++){
		  
		  //保存した点の高さを計算
		  int H = h[keep] + abs(x[keep] - i) + abs(y[keep] - j);
		  bool flag = true;
		  for(int k = 0 ; k < N && flag ; k++){
				if(h[k] !=  max(H - abs(x[k] - i) - abs(y[k] - j), 0))
				  flag = false;
		  }

		  if(flag){
		  		cout << i << " " <<  j << " " << H << endl;
				break;
			}

		}

	}


	return 0;
}

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;


#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    int n,m;
    cin>>n>>m;
    cout<<n*(n-1)/2+m*(m-1)/2<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  long long int k;
  scanf("%lld", &k);
  
  if (k % 2 == 0 || k % 5 == 0)
  {
    printf("-1");
    return 0;
  }
  
  long long int n = 7;
  for (long long int i = 1; i < 2e32; i++)
  {
    if (n % k == 0)
    {
      printf("%lld", i);
      return 0;
    }
    n *= 10;
    n += 7;
    n %= k;
  }
  
  printf("-1");
  return 0;
}
    

Measured memory_bytes: 2152
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <deque>
#include <numeric>
using lint = long long;

lint shortest_path(lint i, lint j, lint h, lint w, const std::vector<std::vector<lint>> &maze, std::vector<std::vector<lint>> &memo)
{

    if (memo[i][j] >= 0)
    {
        return memo[i][j];
    }

    if (i == h - 1 && j == w - 1)
    {
        return 0;
    }

    lint down = 201;
    lint right = 201;

    if (i + 1 < h)
    {
        down = shortest_path(i + 1, j, h, w, maze, memo);
        if (maze[i][j] == 1 && maze[i + 1][j] == 0)
        {
            down++;
        }
    }
    if (j + 1 < w)
    {
        right = shortest_path(i, j + 1, h, w, maze, memo);
        if (maze[i][j] == 1 && maze[i][j + 1] == 0)
        {
            right++;
        }
    }

    lint out = std::min(down, right);
    memo[i][j] = out;

    return out;
}

int main()
{
    lint h, w;
    scanf("%lld", &h);
    scanf("%lld", &w);

    std::vector<std::vector<lint>> maze(h, std::vector<lint>(w, 0));

    for (int i = 0; i < h; ++i)
    {
        std::string s;
        std::cin >> s;

        for (int j = 0; j < w; ++j)
        {
            if (s[j] == '.')
            {
                maze[i][j] = 1;
            }
        }
    }

    std::vector<std::vector<lint>> memo(h, std::vector<lint>(w, -1));

    lint ans = shortest_path(0, 0, h, w, maze, memo);

    if (maze[0][0] == 0)
        ans++;

    printf("%lld", ans);

    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#include<random>
#include<unordered_map>
#include<unordered_set>
using namespace std;

#define MAX 200002

int n;

vector<pair<int, int> > v;

long long int x;
long long int y;

struct UF{
	vector<int> belong;
	vector<int> size;
	void resize(int n){
		belong.assign(n + 1, -1);
		size.assign(n + 1, 1);
	}
	inline int root(int b){
		if (belong[b] == -1){
			return b;
		}
		belong[b] = root(belong[b]);
		return belong[b];
	}
	void merge(int a, int b){
		a = root(a);
		b = root(b);
		if (a == b)return;
		belong[a] = b;
		size[b] += size[a];
	}
};

UF uf;

map<int, int> val[MAX];

vector<int> root;


#define MOD 1000000007
long long int ppow(long long int i, long long int j){
	long long int res = 1LL;
	while (j){
		if ((j & 1LL)){
			res *= i;
			if (res >= MOD){
				res %= MOD;
			}
		}
		j >>= 1;
		i *= i;
		if (i >= MOD){
			i %= MOD;
		}
	}
	return res;
}

long long int k[MAX];
long long int rk[MAX];

int pr[MAX];

vector<int> ich[MAX];

int dif_step(int cur, int col){
	if (cur == 0)return -1;
	cur--;
	if (v[cur].second != col)return cur;
	return pr[cur];
}

int upd[MAX];

int main(){
	k[0] = 1;
	for (int i = 1; i < MAX; i++){
		k[i] = k[i - 1];
		k[i] *= (long long int)(i);
		k[i] %= MOD;
		rk[i] = ppow(k[i], MOD - 2);
	}
	cin >> n;
	cin >> x >> y;
	for (int i = 0; i < n; i++){
		int c, w;
		scanf("%d%d", &c, &w);
		v.push_back(make_pair(w, c));
	}
	uf.resize(n);
	sort(v.begin(), v.end());
	memset(upd, -1, sizeof(upd));
	int idx = -1;
	for (int i = 0; i < v.size(); i++){
		if (i == 0 || v[i - 1].second != v[i].second){
			pr[i] = i-1;
		}
		else{
			pr[i] = pr[i - 1];
		}
		ich[v[i].second].push_back(i);
		if (ich[v[i].second].size()>1){
			int j = ich[v[i].second][0];
			if (v[i].first + v[j].first <= x){
				uf.merge(i, j);
			}
		}
		while (idx + 1 < i&&v[idx + 1].first + v[i].first <= y){
			idx++;
		}
		while (idx >= 0 && v[idx].first + v[i].first > y){
			idx--;
		}
		int cur = idx+1;
		while(cur>=0){
			cur = dif_step(cur, v[i].second);
			if (cur < 0)break;
			int j = cur;
			if (v[i].first + v[j].first <= y){
				uf.merge(i, j);
				if (upd[j] == -1){
					upd[j] = v[i].second;
				}
				else{
					break;
				}
			}
		}
	}
	for (int i = 0; i < v.size(); i++){
		val[uf.root(i)][v[i].second]++;
		root.push_back(uf.root(i));
	}
	sort(root.begin(), root.end());
	root.erase(unique(root.begin(), root.end()), root.end());
	long long int ans = 1;
	for (int i = 0; i < root.size(); i++){
		long long int up = k[uf.size[root[i]]];
		int num = root[i];
		for (auto it = val[num].begin(); it != val[num].end(); it++){
			up *= rk[(*it).second];
			up %= MOD;
		}
		ans *= up;
		ans %= MOD;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 36592
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n;
int main(void){
	cin>>n;
	for(ll i=1;i<50000;i++){
		if(i*108/100==n){
			cout<<i<<endl;
			return 0;
		}
	}
	cout<<":("<<endl;
}

Measured memory_bytes: 256
/* Sometimes you win , sometimes you learn . */
/* Sometimes you win , sometimes you learn . */
#include <bits/stdc++.h>
#define lp(i , N) for(ll i = 0; i < ll (N) ; i++)
#define FAST ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define debug(x) cout<<" [ " << #x << " is: " << x << " ] "<<endl;
using namespace std;
typedef long long ll;
typedef long double ld;
const long double EPS = 1e-6;
const long double pi = acos(-1);
int main(){
    FAST
    ll n , m ;
    cin >> n >> m;
    n--;
    m--;
    ll sum1 = (n * (n + 1)) / 2  , sum2 = (m * (m + 1)) / 2;
    cout << sum1 + sum2 << endl;
    return 0 ;
    }
/*
[#]=============================================================[#]
         ___    ____              ____          ___ _
        |_ _|  / ___|__ _ _ __   |  _ \  ___   |_ _| |_
         | |  | |   / _` | '_ \  | | | |/ _ \   | || __|
         | |  | |__| (_| | | | | | |_| | (_) |  | || |_
        |___|  \____\__,_|_| |_| |____/ \___/  |___|\__|
                     it's just about time

[#]=============================================================[#]
*/


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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set

using namespace std;

const ll MOD = 1000000007;
const ll INF = (1LL << 62);

int main() {
  ll N, K;
  scanf("%lld %lld", &N, &K);

  ll v = N % K;

  ll v2 = abs(v - K);

  ll ans = min(v, v2);

  // cout << v << endl;
  // cout << v2 << endl;

  cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int n, tmp;
    int flag = 0;
    int cnt = 0;
    long int mark = 2147483647;
    long int sum = 0;
    scanf("%d\n", &n);
    int A[n], B[n];
    for(int i=0;i<n;i++){
            scanf("%d", &A[i]);
    }
    for(int i=0;i<n;i++){
        if(A[i]<0){
            B[i] = A[i] * -1;
            cnt++;
        }else if(A[i]==0){
            B[i] = A[i];
            flag = 1;
        }else{
            B[i] = A[i];
        }
    }
    for(int i=0;i<n;i++){
        if(B[i]<mark){
            mark = B[i];
        }
    }
    for(int i=0;i<n;i++){
        sum = sum + B[i];
    }
    if(cnt%2==1 && flag==0){
        sum = sum - (2*mark);
    }
    printf("%ld\n", sum);
    return 0;
}

Measured memory_bytes: 896
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <cmath>
#include <numeric>
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <list>
#include <unordered_map>
#include <tuple>
#include <complex>


#define FOR(i, a, b)		for(int i = (int)(a); i < (int)(b); ++i)
#define FORE(i, a, b)		for(int i = (int)(a); i <= (int)(b); ++i)
#define REP(i, n)			FOR(i, 0, n)
#define REPE(i, n)			FORE(i, 0, n)
#define ALL(x)				(x).begin(),(x).end()
#define DEBUG_DC(x)			cout << #x << ": " << x << endl
#define VEC_TYPE			int
#define INF					1e9+1

using namespace std;
typedef long long ll;
typedef vector<VEC_TYPE> vdef;
typedef vector<vdef> vvdef;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmaxE(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; }
template<class T> inline bool chminE(T& a, T b) { if (a >= b) { a = b; return 1; } return 0; }
template<typename T> inline T mygcd(T a, T b) { return b ? mygcd(b, a%b) : a; }
template<typename T> inline T mylcm(T a, T b) { return a * b / mygcd(a, b); }


int main()
{
	int ans = 0;
	int n;
	cin >> n;

	vdef v(n);
	for (int i = 0; i < n; ++i) cin >> v[i];

	sort(ALL(v));
	double sum = 0.5*((double)v[0] + (double)v[1]);
	for (int i = 2; i < n; ++i)
	{
		sum = 0.5*(sum + (double)v[i]);
	}

	cout << sum << endl;
	return 0;
}

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

using namespace std;

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Ti = tuple<int, int, int>;
using Tl = tuple<ll, ll, ll>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
#define Get(t, i) get<(i)>((t))
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, f, n) for(int i = (int)(f); i < (int)(n); i++)
#define each(a, b) for(auto& a : b)

const int inf = 1 << 25;
const ll INF = 1LL << 55;

struct edge
{
  int to, cap, cost, rev;
  edge(){}
  edge(int to, int cap, int cost, int rev):to(to), cap(cap), cost(cost), rev(rev){}
};

struct PrimalDual
{
  vector< vector<edge> > G;
  vector<int> potential, mincost, prevv, preve;
  PrimalDual(int V):G(V), potential(V), mincost(V), prevv(V), preve(V){}
  void add_edge(int from, int to, int cap, int cost)
  {
    G[from].push_back(edge(to, cap, cost, (int)G[to].size()));
    G[to].push_back(edge(from, 0, -cost, (int)G[from].size()-1));
  }
  int min_cost_flow(int s, int t, int f)
  {
    int ret = 0;
    fill(potential.begin(), potential.end(), 0);
    fill(prevv.begin(), prevv.end(), -1);
    fill(preve.begin(), preve.end(), -1);

    while(f > 0) {
      priority_queue<Pi, vector<Pi>, greater<Pi> > que;
      fill(mincost.begin(), mincost.end(), inf);
      mincost[s] = 0;
      que.push(Pi(0, s));
      while(!que.empty()) {
	Pi p = que.top(); que.pop();
	int v = p.second;
	if(mincost[v] < p.first) continue;
	for(int i = 0; i < (int)G[v].size(); i++) {
	  edge& e = G[v][i];
	  int dual_cost = mincost[v] + e.cost + potential[v] - potential[e.to];
	  if(e.cap > 0 && dual_cost < mincost[e.to]) {
	    mincost[e.to] = dual_cost;
	    prevv[e.to] = v; preve[e.to] = i;
	    que.push(Pi(mincost[e.to], e.to));
	  }
	}
      }

      if(mincost[t] == inf) return ret; // -1;
      for(int v = 0; v < (int)G.size(); v++) potential[v] += mincost[v];
      int d = f;
      for(int v = t; v != s; v = prevv[v]) d = min(d, G[prevv[v]][preve[v]].cap);
      f -= d;
      ret += d * potential[t];
      for(int v = t; v != s; v = prevv[v]) {
	edge& e = G[prevv[v]][preve[v]];
	e.cap -= d;
	G[v][e.rev].cap += d;
      }
    }
    return ret;
  }
};

int main()
{
  int N; cin >> N;
  vector<int> A(N), B(N);
  vector<int> sides;
  rep(i, N) {
    cin >> A[i] >> B[i];
    sides.push_back(A[i]);
    sides.push_back(B[i]);
  }

  sort(all(sides));
  sides.erase(unique(all(sides)), sides.end());

  int dummy = N + sides.size(), s = dummy + 1, t = s + 1;
  PrimalDual flow(t + 1);
  for(int i = 0; i < N; i++) {
    int a = lower_bound(all(sides), A[i])-sides.begin();
    int b = lower_bound(all(sides), B[i])-sides.begin();

    flow.add_edge(s, i, 1, 0);
    flow.add_edge(i, dummy, 1, 0);
    flow.add_edge(i, N + a, 1, -B[i]);
    if(a != b) flow.add_edge(i, N + b, 1, -A[i]);
  }

  for(int i = 0; i < sides.size(); i++) flow.add_edge(N + i, t, 1, 0);
  flow.add_edge(dummy, t, inf, 0);

  cout << -flow.min_cost_flow(s, t, N) << endl; 
  
  return 0;
}

Measured memory_bytes: 3424
import java.util.*;


public class Main{
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();
		long ans=1;
		int []map=new int[26];
		for (int i=0;i<n;i++) {
			map[s.charAt(i)-'a']++;
		}
		for(int i=0;i<26;i++) {
			ans=ans*(map[i]+1)%1000000007;
		}
		ans--;
		int res=(int)ans;
		sc.close();
        System.out.println(res);	
	}
	

}


Measured memory_bytes: 23184
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <array>
#include <vector>
#include <utility>
#include <bitset>
#include <queue>
#include <unordered_map>
#include <unordered_set>

using namespace std;

using ll = long long;
using p = pair<ll, ll>;

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

    ll N;
    cin >> N;
    vector<ll> A(N);
    for (ll i = 0; i < N; i++) {
        cin >> A[i]; 
    }

    unordered_map<ll, ll> m;
    m[0] = 1;
    ll sum = 0;
    ll ans = 0;
    for (ll i = 0; i < N; i++) {
        sum += A[i];

        if (m[sum] != 0) {
            ans += m[sum];
            m[sum]++;
        } else {
            m[sum]++;
        }
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 10056
#include<stdio.h>
int main(){
  int F[100],n,i;
  scanf("%d",&n);
  F[0]=F[1]=1;
  for(i=2;i<=n;i++){
    F[i]=F[i-1]+F[i-2];
  }
  
  printf("%d\n",F[n]);
  return 0;
}



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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);

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

  int diff = 0;
  for(int i=0;i<N;i++) {
    if(vec[i] == i+1) {
      continue;
    } else {
      diff++;
    }
  }

  if(diff == 0) {
    cout << "YES" << endl;
  } else if (diff == 2) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
inputs = gets.chomp.split("")

result = {}

inputs.uniq.each { |x|
	result[x] = inputs.count(x)
}

if result.keys.size == 2 && result.values[0] == 2 && result.values[1] == 2 then
	puts 'Yes'
else
	puts 'No'
end

STDOUT.flush


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

const int DIM = 1e5 + 5;

int arr[DIM];

int main( void ) {
    
    int n;
    cin >> n; n *= 2;
    
    for( int i = 1; i <= n; i ++ )
        cin >> arr[i];
    
    sort( arr + 1, arr + n + 1 );
    
    int ans = 0;
    for( int i = 1; i <= n; i += 2 )
        ans += arr[i];
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import sys, collections
lines = [s.rstrip("\n") for s in sys.stdin.readlines()]
n, = [int(num) for num in lines.pop(0).split(" ")]
blue_list = lines[:n]
lines = lines[n:]
m, = [int(num) for num in lines.pop(0).split(" ")]
red_list = lines
blue = collections.Counter(blue_list)
red = collections.Counter(red_list)
c = blue - red
lis = c.values()
if len(lis):
    ans = max(lis)
else:
    ans = 0
print(ans)


Measured memory_bytes: 9220
def resolve():
    allPt = []
    for i in range(1, 10):
        for j in range(10):
            for k in range(10):
                allPt.append(int(str(i) + str(j) + str(k) + str(j) + str(i)))
    A, B = [int(i) for i in input().split()]
    cnt = 0
    for i in allPt:
        if A <= i and i <= B:
            cnt += 1
    print(cnt)


resolve()


Measured memory_bytes: 9072
def resolve():
    # 整数 1 つ
    # n = int(input())
    # 整数複数個
    a, b, x = map(int, input().split())
    # 整数 N 個 (改行区切り)
    # N = [int(input()) for i in range(N)]
    # 整数 N 個 (スペース区切り)
    # N = list(map(int, input().split()))
    # 整数 (縦 H 横 W の行列)
    # A = [list(map(int, input().split())) for i in range(H)]

    if a % x == 0:
        nmin = int(a / x)
    else:
        nmin = (a // x) + 1

    nmax = b // x

    print(nmax - nmin +1)


resolve()

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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF   = 1e9;
const ll  INFLL = 1e18;
typedef pair<ll, ll> PII;
typedef vector<vector<int>> Graph;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

int main()
{
    ios::sync_with_stdio(false);

    int N;
    ll C;
    cin >> N >> C;
    vector<PII> sushi(N);
    map<int, PII> sushi_l, sushi_r;
    rep(i, N) {
        cin >> sushi[i].first >> sushi[i].second;
    }

    sushi_l[0] = PII(C, 0);
    sushi_r[0] = PII(0, 0);
    rep(i, N) {
        sushi_l[(i+1)] = sushi[N-i-1];
        sushi_r[(i+1)] = sushi[i];
    }

    ll ans = 0LL;


    vector<ll> mx_r(N+1);
    ll sumr = 0;
    for (int r=0; r<N; r++) {
        sumr += sushi_r[r+1].second;
        ans = max(ans, sumr - sushi_r[r+1].first);

        mx_r[r+1] = sumr - sushi_r[r+1].first;
        mx_r[r+1] = max(mx_r[r+1], mx_r[r]);
    }

    vector<ll> mx_l(N+1);
    ll suml = 0;
    for (int l=0; l<N; l++) {
        suml += sushi_l[l+1].second;
        ans = max(ans, suml - (C - sushi_l[l+1].first));
        
        mx_l[l+1] = suml - (C - sushi_l[l+1].first);
        mx_l[l+1] = max(mx_l[l+1], mx_l[l]);
    }

    suml = 0;
    for (int l=0; l<N; l++) {
        suml += sushi_l[l+1].second;
        ll tmp = suml - 2*(C - sushi_l[l+1].first) + mx_r[N - l - 1];
        ans = max(ans, tmp);
        DUMP2(l, tmp);
    }

    sumr = 0;
    for (int r=0; r<N; r++) {
        sumr += sushi_r[r+1].second;
        ll tmp = sumr - 2*sushi_r[r+1].first + mx_l[N - r - 1];
        ans = max(ans, tmp);
        DUMP2(r, tmp);
    }

    cout << ans << endl;
}



Measured memory_bytes: 17920
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <deque>
#include <cstring>
#include <bits/stdc++.h>
using namespace std;
#define X first
#define Y second
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define IOS ios::sync_with_stdio(0);cin.tie(0);
#define de(x,y) cout<<#x<<" :"<<x<<y;
#define int long long
#define SZ(xx) ((int)xx.size())
#define lowbit(xx) (xx&(-xx))
#define pb push_back
typedef pair<int,int> pii;

const int maxn = 4e5+5;

int arr[16][16], dp[(1<<16)];

	

main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cin >> arr[i][j];
		}
	}
	
	for (int i = 1; i < (1<<n); i++) {
		for (int x = 0; x < n; x++) {
			if ((1<<x) & i) {
				for (int y = x + 1; y < n; y++) {
					if ((1<<y) & i) {
						dp[i] += arr[x][y];
					} 
				}
			}
		}
		int tmp = i;
		while (tmp) {
			dp[i] = max(dp[i], dp[tmp] + dp[tmp ^ i]);
			tmp = (tmp - 1) & i;
		}
	}
	cout << dp[(1<<n)-1] << "\n";
}


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

static int stack[100];
static int top = 0;

void push(int v) {
  stack[++top] = v;
}

int pop(void) {
  return stack[top--];
}

int main(void) {
  int a, b;
  char input[100];
  
  while ( scanf("%s", input) != EOF ) {
    switch (input[0]) {
    case '+':
      b = pop();
      a = pop();
      push(a+b);
      break;
    case '-':
      b = pop();
      a = pop();
      push(a-b);
      break;
    case '*':
      b = pop();
      a = pop();
      push(a*b);
      break;
    case '\n':
      break;
    default:
      push(atoi(input));
    }
  }
  printf("%d\n", pop());

  return 0;
}


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

string a,b=" ";

int main(){
	cin>>a;
	a.erase(5,1);
	a.insert(5,b);
	a.erase(13,1);
	a.insert(13,b);
	cout<<a<<endl;
}

Measured memory_bytes: 3600
import math

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

n,m=map(int,input().split())
if n<2 and m>=2:
    print(comb_count(m,2))
elif n>=2 and m<2:
    print(comb_count(n,2))
elif n<2 and m<2:
    print(0)
else:
    print(comb_count(n,2)+comb_count(m,2))

Measured memory_bytes: 3060
N = int(input())
listv = list(map(int, input().split()))
even = [listv[x] for x in range(N) if x%2 == 0]
odd = [listv[x] for x in range(N) if x%2 == 1]
import collections
evenc = collections.Counter(even)
oddc = collections.Counter(odd)
listeven = evenc.most_common()
listodd = oddc.most_common()
ae, be = listeven[0]
ao, bo = listodd[0]
if ae != ao:
    ans = N-be-bo
elif len(listeven) ==1 and len(listodd) ==1:
    ans = N/2    
elif len(listeven) == 1:
    ao1, bo1 = listodd[1]
    ans = N/2-bo1
elif len(listodd) == 1:
    ae1, be1 = listeven[1]
    ans = N/2-bo1    
else:
    ao1, bo1 = listodd[1]
    ae1, be1 = listeven[1] 
    ans = N-bo-max(bo1,be1)
print(int(ans))  

Measured memory_bytes: 21796
#include <bits/stdc++.h>
#include <sstream>
#include <iomanip>
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))
#define nout(ans) cout << (ans) << "\n"
#define sout(ans) cout << (ans) << " "
using namespace std;

const double pi = 3.14159265359;
const ll INF = 1e12;
const ll MOD = 1e9 + 7;
const ll N = 1e5 + 5;
/*
Decimal Places: cout << fixed << setprecision(n) << ans << endl

String to integer:
stringstream dark(s);
int x = 0; dark >> x;
*/

bool compare(const pair<int, int>&i, const pair<int, int>&j)
{
    return i.second < j.second;
}


int n; string s;

void solve()
{
    cin >> n >> s;
    if (n%2) {
        nout("No");
    }else{
        if (s.substr(0,n/2)==s.substr(n/2,n/2)) nout("Yes");
        else nout("No");
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    //cin >> t;
    for (int i=1; i<=t; i++)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3652