akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
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;
}
void print() { cout << "\n"; }
template <class T> void print(const T &x) { cout << x << "\n"; }
template <class T, class... Args> void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
template <class T> void printVector(const vector<T> &v) {
    for(const T &x : v) {
        cout << x << " ";
    }
    cout << "\n";
}
using ll = long long;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

// time, event, pos or i
using Event = tuple<int, int, int>;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, q;
    cin >> n >> q;
    vector<Event> e;
    for(int i = 0; i < n; i++) {
        int s, t, x;
        cin >> s >> t >> x;
        e.emplace_back(s - x, 0, x);
        e.emplace_back(t - x, 1, x);
    }
    for(int i = 0; i < q; i++) {
        int d;
        cin >> d;
        e.emplace_back(d, 2, i);
    }
    sort(ALL(e));
    multiset<int> se;
    vector<int> ans(q, -1);
    for(const auto &p : e) {
        int time, query, x;
        tie(time, query, x) = p;
        if(query == 0) {
            se.emplace(x);
        } else if(query == 1) {
            if(se.find(x) != se.end()) {
                se.erase(se.find(x));
            }
        } else {
            ans[x] = (se.empty() ? -1 : *se.begin());
        }
    }
    for(int i = 0; i < q; i++) {
        print(ans[i]);
    }
}

Measured memory_bytes: 18792
#include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	int a,b;
	rep(i,7){
		cin>>a>>b;
		cout<<a-b<<endl;
	}
	return 0;
}

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

using namespace std;

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

  vector<int> m(n), d(n), v(n), s(n);
  for (int i = 0; i < n; i++) {
    cin >> m[i] >> d[i] >> v[i] >> s[i];
  }
  
  
  int t[360] = {};
  for (int i = 0; i < 360; i++) {
    for (int j = 0; j < n; j++) {
      int day = (m[j] - 1) * 30 + (d[j] - 1);
      if ((i - day + 360) % 360 <= v[j] - 1) {
        t[i] = max(t[i], s[j]);
      } else {
        t[i] = max(t[i], max(0, s[j] - min((day - i + 360) % 360, (i - (day + v[j] - 1) + 360) % 360)));
      }
    }
  }

  int ans = 1e9;
  for (int i = 0; i < 360; i++) {
    ans = min(ans, t[i]);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3096
#include<stdio.h>
int main(void){
	int a, b, comp;
	int x[1000], y[1000];
	scanf("%d", &a);
	for(int i = 0; i < a; i++){
	    scanf("%d", &x[i]);
	}
	scanf("%d", &b);
    for(int i = 0; i < b; i++){
        scanf("%d", &y[i]);
    }
    if (a>b) comp = b;
    else comp = a;
    for (int i = 0; i < comp; i++){
        if (x[i] > y[i]){
            printf("0\n");
            break;
        }
        else if (x[i] < y[i]){
            printf("1\n");
            break;
        }
        else if (x[i] == y[i]){
            //do nothing
        }
        if (i == comp - 1){
            if (a>b) printf("0\n");
            else if (a<b) printf("1\n");
            else printf("0\n");
            break;
        }
    }
	return 0;
}


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

int main()
{
    int n, q;
    cin >> n >> q;
    vector<vector<int>> G(n);
    for (int i = 0; i < n - 1; i++)
    {
        int a, b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    
    vector<int> ans(n, 0);
    for (int i = 0; i < q; i++)
    {
        int p, x;
        cin >> p >> x;
        p--;
        ans[p] += x;
    }

    vector<int> dist(n, -1); // 全頂点を「未訪問」に初期化
    queue<int> que;

    dist[0] = ans[0];
    que.push(0);
    while (!que.empty())
    {
        int v = que.front();que.pop();

        for (int nv : G[v])
        {
            if(dist[nv] != -1)continue;

            dist[nv] = dist[v] + ans[nv];
            que.push(nv);
        }
    }

    for (int i = 0; i < n; i++)
    {
        if(dist[i] == -1)cout << 0 << " ";
        else cout << dist[i] << " ";
    }
    cout << endl;
}

Measured memory_bytes: 17380
#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

const int maxN = 1e5; int n, m;
bool solved[maxN];
int penalties[maxN];
pair<int, string> submissions[maxN];

int main()
{
  while (scanf("%d %d", &n, &m) != EOF)
  {
    memset(solved, false, sizeof(solved));
    memset(penalties, 0, sizeof(penalties));
    for (int i = 0; i < m; i ++)
    {
      int p; char s[3]; scanf("%d %s", &p, s); p --;
      submissions[i] = {p, string(s)};
    }

    int totalSolved = 0, totalPenalties = 0;
    for (int i = 0; i < m; i ++)
      if (!solved[submissions[i].first])
      {
        if (submissions[i].second == "WA")
          penalties[submissions[i].first] ++;
        else
          totalSolved ++, totalPenalties += penalties[submissions[i].first], solved[submissions[i].first] = true;
      }
    printf("%d %d\n", totalSolved, totalPenalties);
  }
  return 0;
}

Measured memory_bytes: 7040
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
using namespace std;
#define fr first
#define sc second
#define rep(i,n) for(int i = 0 ; i < n ; i++ )
typedef pair< int , int > Pt;
typedef long long ll;
const int dx[] = { 0, 1, -1, 0}, dy[] = { 1, 0, 0, -1};
struct P{
  Pt nkmr;
  vector< Pt > pnl,cnt;
  bool operator<(const P& right)const{
    return nkmr < right.nkmr;
  }
};
typedef pair< int , P > IP;
Pt Goal;
int h, w;
char mas[10][10];
int search_cnt(int y,int x,P& n){
  rep(i,n.cnt.size()) if(n.cnt[i] == Pt(y,x)) return i;
  return -1;
}
int search_panel(int y,int x,P& n){
  rep(i,n.pnl.size()) if(n.pnl[i] == Pt(y,x)) return i;
  return -1;
}
bool isused(map<ll,bool>& used,P& p){
  ll ret = (p.nkmr.fr << 4) + p.nkmr.sc;
  for(int i = 0 ; i < p.pnl.size() ; i++ ){
    ret <<= 4;
    ret += p.pnl[i].fr;
    ret <<= 4;
    ret += p.pnl[i].sc;
  }
  for(int i = 0 ; i < p.cnt.size() ; i++ ){
    ret <<= 4;
    ret += p.cnt[i].fr;
    ret <<= 4;
    ret += p.cnt[i].sc;
  }
  if(used[ret]++) return true;
  return false;
}
int Dijkstra(P& St){
  //priority_queue<pair<int,P>,vector<pair<int,P> >,greater<pair< int,P> > > que;
  queue<pair< int , P > > que;
  map < ll , bool >  used;
  que.push(IP(0,St));
  while(!que.empty()){
    int _cost = que.front().fr;
    P p = que.front().sc;
    que.pop();
    if(p.nkmr == Goal) return _cost;
    if(isused(used,p)) continue;
    rep(i,4){
      P next = p;
      int ny = p.nkmr.fr + dy[i], nx = p.nkmr.sc + dx[i],contena,panel;
      if(mas[ny][nx] == '#' || search_panel(ny,nx,next) != -1) continue;
      if((contena = search_cnt(ny,nx,next)) != -1){ //コンテナあった
        int ty = ny + dy[i], tx = nx + dx[i];
        if(mas[ty][tx] != '.' || search_cnt(ty,tx,next) != -1) continue;
        while(mas[ty][tx] == '.' &&
              search_cnt(ty,tx,next) == -1 && search_panel(ty,tx,next) == -1){
          ty += dy[i], tx += dx[i];
        }
        if((panel = search_panel(ty,tx,next)) != -1){
          next.cnt[contena] = Pt(-1,-1);
          next.pnl[panel] = Pt(-1,-1);
        }else next.cnt[contena] = Pt(ty - dy[i],tx - dx[i]);
        que.push(IP(_cost,next));
      }else que.push(IP(_cost+1,(P){Pt(ny,nx),p.pnl,p.cnt}));
    }
  }
  return -1;
}
int main(){
  while(cin >> h >> w , h ){
    P p = (P){Pt(),vector<Pt>(),vector<Pt>()};
    int cpa = 0,ccn = 0;
    rep(i,h) rep(j,w){
      cin >> mas[i][j];
      if(mas[i][j] == '@') p.nkmr = Pt(i,j), mas[i][j] = '.';
      else if(mas[i][j] == 'w'){
        p.pnl.push_back(Pt(i,j)), mas[i][j] = '.';
      }else if(mas[i][j] == 'c'){
        p.cnt.push_back(Pt(i,j)), mas[i][j] = '.';
      }else if(mas[i][j] == 'E') Goal = Pt(i,j), mas[i][j] = '.';
    }
    cout << Dijkstra(p) << endl;
  }
}

Measured memory_bytes: 6212
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

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

    int tot = 1900 * m + 100 * (n - m);
    int ans = tot;
    for (int i = 0; i < m; i++) {
        ans *= 2;
    }

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

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<typeinfo>
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
using namespace std;
int main()
{
	int x,a,b;
	cin >> x >> a >> b;

  	x-=a;
  	x%=b;
  	cout << x << endl;
	return 0;
}

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

#define all(v)  begin(v), end(v)
#define endl    '\n';
#define int     long long
#define pii     pair<int, int>
#define sz(x)   (int) x.size()

void test_case() {
    int n;
    cin >> n;

    vector<int> v(n);
    for (int& x : v)
        cin >> x;

    int x = 0;
    for (int i = 1; i < n; i++) {
        if (v[i-1] > v[i]) {
            x += v[i-1] - v[i];
            v[i] = v[i-1];
        }
    }

    cout << x << endl;
}

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

    int t = 1;
    // cin >> t;

    while (t--) { 
        test_case();
    }
    return 0;
}


Measured memory_bytes: 4788
#include<cstdio>
#include<iostream>
#include<cstring>
#include<vector>
#include<queue>
#define RG register
using namespace std;
const int N=5e5+10;
struct dabt{ int next,to; }e[N<<2];
int head[N],k,n,m,tree[N<<2],ru[N],pos[N],p[N],cnt,ans[N];
priority_queue<int, vector<int> ,greater<int> > pn;
inline void add(int from,int to){e[++k]=(dabt){head[from],to}; head[from]=k; ru[to]++;}
inline int read(){
	char ch=getchar(); int x=0, f=1;
	while(ch<'0' || ch>'9') {if(ch=='-') f=-1;ch=getchar();}
	while(ch>='0' && ch<='9') {x=x*10+ch-'0'; ch=getchar();}
	return x*f;}
inline int mi(int a,int b){return a<b ? a : b;}
inline int mx(int a,int b){return a>b ? a : b;}
int sum(int l,int r,int st,int ed,int o)
{
	if(st<=l && r<=ed) return tree[o];
	if(l==r) return 2e9;
	int mid=l+(r-l)/2, ans=2e9;
	if(mid>=st) ans=mi(ans,sum(l,mid,st,ed,o<<1));
	if(mid<ed) ans=mi(ans,sum(mid+1,r,st,ed,o<<1|1));
	return ans;
}
void upd(int l,int r,int pos,int kk,int o)
{
	if(l==r) 
	{
		tree[o]=kk;
		return ;
	}
	int mid=l+(r-l)/2;
	if(pos<=mid) upd(l,mid,pos,kk,o<<1);
	else upd(mid+1,r,pos,kk,o<<1|1);
	tree[o]=mi(tree[o<<1],tree[o<<1|1]);
}
inline void topo()
{
	for(RG int i=1;i<=n;i++) if(!ru[i]) pn.push(i);
	while(!pn.empty())
	{
		int x=pn.top(); pn.pop(); ans[x]=++cnt;
		for(RG int i=head[x];i;i=e[i].next) if(--ru[e[i].to]==0) pn.push(e[i].to);
	}
}
int main()
{
//	freopen("Wide Swap.in","r",stdin);
	n=read(); m=read();
	for(RG int i=1;i<=(n<<2);i++) tree[i]=2e9;
	for(RG int i=1;i<=n;i++) pos[p[i]=read()]=i;
	for(RG int i=n,x;i;i--)
	{
		x=sum(1,n,pos[i]+1,mi(pos[i]+m-1,n),1);
		if(x<2e9) add(pos[i],pos[x]);
		x=sum(1,n,mx(pos[i]-m+1,1),pos[i]-1,1);
		if(x<2e9) add(pos[i],pos[x]);
		upd(1,n,pos[i],i,1);
	}
	topo();
	for(RG int i=1;i<=n;i++) printf("%d\n",ans[i]);
	return 0;
}

Measured memory_bytes: 30336
#include <bits/stdc++.h>
#define ll long long
#define pq priority_queue
using namespace std;
const ll INF=(ll)1e9;
const ll MOD=(ll)1e9+7;
const ll MAX=100100;
vector<int> dx={1,0,-1,0},dy={0,1,0,-1};
template<class T> inline bool chmax(T& a, T b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a>b) { a=b; return 1; } return 0; }

int main(){
    ll N,ans=0,a=10;
    cin>>N;
    if(N%2==0){
        while(N/a!=0){
            ans+=N/a;
            a*=5;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

int main()
{
    string s;
    cin >> s;
    int n = s.size();
    s = string("0") + s;

    irep(i, n)
    {
        if (s[i] != s[n - i]) {
            cout << -1 << endl;
            return 0;
        }
    }
    if (s[n] == '1' || s[1] == '0') {
        cout << -1 << endl;
        return 0;
    }

    int root = 1;
    for (int i = 1; i < n; i++) {
        if (s[i] == '0') {
            cout << root << " " << i + 1 << endl;
        } else {
            cout << i + 1 << " " << root << endl;
            root = i + 1;
        }
    }
    return 0;
}

Measured memory_bytes: 1660
#include <iostream>
#include <set>
#include <algorithm>
#include <climits>
#include <vector>
using namespace std;

int pos;
string line;
string table = "+/*-";
 
void view(set<int> a){
	for(set<int>::iterator it = a.begin() ; it != a.end() ; ++it){
		cout << *it << " ";
	}
	cout << endl;
}
int mcalc(int a,int b,char c){
	switch(c){
		case '+': return a+b;
		case '-': return a-b;
		case '*': return a*b;
		case '/': return b?a/b:INT_MAX;
	}
}
set<int> real(vector<int> num,vector<char> &op2){
	vector<int> src = num;
	int o[] = {0,1,2,3,4,5,6,7,8,9} , n = op2.size();
	set<int> answer;
	do{
		vector<int> posi(n+1);
		vector<pair<int,char> > op(n);
		for(int i = 0 ; i < n ; i++) op[i] = make_pair(i,op2[i]);
		
		for(int i = 0 ; i < posi.size() ; i++) posi[i] = i;
		for(int i = 0 ; i < n ; i++){
			for(int j = 0 ; j < op.size() ; j++){			
				if( op[j].first == o[i]){
					int p = j;
					int r = mcalc(num[p],num[p+1],op[p].second);
					if(r == INT_MAX) goto fail;
					num[p] = num[p+1] = r;
					num.erase(num.begin()+p);
					op.erase(op.begin()+p);
					break;
				}
			}
		}
		//or(int i = 0 ; i < num.size() ; i++) cout << o[i] << " ";cout << endl;
		//for(int i = 0 ; i <= n ; i++) cout << num[i] << " ";cout << "=" << num[o[n-1]] << endl;
		answer.insert(num[0]);
		fail:;
		num = src;
	}while(next_permutation(o,o+n));
	//for(int i = 0 ; i <= n ; i++) cout << num[i] << " ";cout << endl;
	//cout << answer.size() << " |" ; view(answer);
	return answer;
}

vector< vector<int> > var;
vector<int> current;
void func(vector<int> &cur,vector< set<int> > &num){
	if(cur.size() == num.size()){
		var.push_back(cur);
	}else{
		int p = cur.size();
		for(set<int>::iterator it = num[p].begin() ; it != num[p].end() ; ++it){
			cur.push_back(*it);
			func(cur,num);
			cur.pop_back();
		}
	}
}

set<int> calc(vector< set<int> > num,vector<char> op){
	var.clear();
	current.clear();
	func(current,num);
	
	set<int> answer;
	for(int i = 0 ; i < var.size() ; i++){
		set<int> result = real(var[i],op);
		answer.insert(result.begin(),result.end());
	}
	return answer;
}
set<int> go(int depth){
	int cur = 0;
	vector< set<int> > num;
	vector<char> op;
	while(1){
		//cout << depth << ":" << pos << " " << line[pos] << " " << num.size() << endl;
		char c = line[pos++];
		if( c== '('){
			num.push_back(go(depth+1));
		}else if(c == ')'){
			//cout << "[" << depth << endl;
			//for(int i = 0 ; i < op.size() ; i++)
			//	cout << op[i] << " " ; cout << endl;
			//
			//for(int i = 0 ; i < num.size() ; i++)
			//	cout << num[i].size() << " " ; cout << endl;
			if(num.size() == 1) return num[0];
			else return calc(num,op);
		}else if(table.find(c) != -1){
			op.push_back(c);
		}else{
			int number = c-'0';
			//cout << c << endl;
			while(line[pos] >= '0' && line[pos] <= '9') number = number * 10 + line[pos] - '0' , pos++;
			set<int> add;
			add.insert(number);
			num.push_back(add);
		}
	}
}
int main(){
	while(getline(cin,line) && line != "#"){
		pos = 0;
		line += ")";
		cout << go(0).size() << endl;
	}
}

Measured memory_bytes: 972
#include <queue>
#include <iostream>
/*que struct{
  string name;
  int time;
  }*/
int counter = 0;
using namespace std;
int main(){
  queue<string> Q1;
  queue<int> Q2;
  int n,q;
  cin >> n >> q;
  for(int i = 0; i < n; i++){
    string name;
    int time;
    cin >> name;
    cin >> time;
    Q1.push(name);
    Q2.push(time);
  }
  while((!Q1.empty()) && (!Q2.empty())){
    if(Q2.front() <= q){
      cout << Q1.front() <<" ";
      cout << Q2.front() + counter << endl;
      counter = counter + Q2.front(); 
      Q1.pop();
      Q2.pop();
    }
    else{
      Q1.push(Q1.front());
      Q1.pop();
      Q2.push(Q2.front()-q);
      Q2.pop();
      counter = counter + q;
    }
  }
}

Measured memory_bytes: 5600
#include "bits/stdc++.h"
using namespace std;

int main(){
  int cnt = 0,n;

  cin >> n;
  
  int *a = new int[n];

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

  
  bool flag = true;
  while(flag){
    flag = false;
    for(int i=n-1;i>0;--i){
      if(a[i] < a[i-1]){
	swap(a[i], a[i-1]);
	flag = true;
	++cnt;
      }
    }
  }

  for(int i=0;i<n;++i){
    cout << a[i];
    if(i != n-1) cout << " ";
  }
  cout << endl << cnt << endl;
  
  delete[] a;
  return 0;
}



Measured memory_bytes: 3084
#include <iostream>

using namespace std;
int A[300];

int rec(char c , string s){
    bool ok =1 ;
    for(auto a : s) if(c!=a)ok =0;
    if(ok ) return 0 ;
    string ss;
    for(int i = 0 ; i< s.size()-1 ; i++){
        if(s[i]==c ||s[i+1]==c)ss+=c;
        else ss+=s[i];
    }
    return 1 + rec(c,ss);
}

int main()
{
    string s ;
    cin >> s ;
    int m = 100 ;
    for(char c = 'a' ; c<='z' ; c++){
        m = min ( m , rec(c,s));
    }
    cout<<m ;
    return 0;
}


Measured memory_bytes: 256
import sys

input_methods=['clipboard','file','key']
using_method=2
input_method=input_methods[using_method]

IN=lambda : map(int, input().split())
mod=1000000007

#+++++

def main():
	a = int(input())
	for i in range(10):
		if a <= i*111:
			return i*111
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

int main(){
  int N;
  cin >> N;
  vector<ll> A(N);
  vector<ll> B(N);
  vector<ll> C(N);

  for(int i = 0;i < N;i++)cin >> A[i];
  for(int i = 0;i < N;i++)cin >> B[i];
  for(int i = 0;i < N;i++)cin >> C[i];

  sort(A.begin(),A.end());
  sort(B.begin(),B.end());
  sort(C.begin(),C.end());

  vector<ll> BA(N);
  ll now_sum = 0;
  BA[0] = lower_bound(A.begin(),A.end(),B[0]) - A.begin();
  for(int i = 1;i < N;i++){
    BA[i] = BA[i-1] + (lower_bound(A.begin(),A.end(),B[i]) - A.begin());
  }



  ll ans = 0;
  for(int i = 0;i < N;i++){
    ll index = lower_bound(B.begin(),B.end(),C[i]) - B.begin() - 1;
    if(index >= 0)ans += BA[index];
  }

  cout << ans << endl;
}


Measured memory_bytes: 3328
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(N: int):
    if '7' in [c for c in str(N)]:
        print(YES)
    else:
        print(NO)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9176
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <time.h>
#include <random>

using namespace std;
typedef long long ll;

int N = 26;
int D;
ll c[26];
ll s[366][36];
int t[366];
set<int> st[26];

random_device seed_gen;
default_random_engine engine(seed_gen());
uniform_real_distribution<> rand_dist(0.0, 1.0);

void input(){
    cin >> D;
    for(int i = 0; i < N; i++) {
        cin >> c[i];
        st[i].insert(0); st[i].insert(D+1);
    }
    for(int i = 1; i <= D; i++){
        for(int j = 0; j < N; j++) cin >> s[i][j];
    }
}


ll calc_score(){
    vector<int> last(N);
    ll S = 0;
    for(int d = 1; d <= D; d++){
        last[t[d]]  = d;
        for(int i = 0; i < N; i++){
            S -= c[i]*(d-last[i]);
        }
        S += s[d][t[d]];
    }
    return S;
}

ll calc_change(ll prev, int d, int q){
    prev -= s[d][t[d]]; prev += s[d][q];
    // t[d]がなくなる
    {
        auto l = st[t[d]].find(d); l--;
        auto r = st[t[d]].upper_bound(d);
        ll dif_l = d-*l, dif_r = *r-d;
        prev -= (dif_l)*(dif_r)*c[t[d]];
    }
    // qが増える
    {
        auto l = st[q].lower_bound(d); l--;
        auto r = st[q].upper_bound(d);
        ll dif_l = d-*l, dif_r = *r-d;
        prev += (dif_l)*(dif_r)*c[q];
    }
    return prev;
}

void change(int d, int q){
    st[t[d]].erase(d); st[q].insert(d);
    t[d] = q;
}

void output(){
    for(int i = 1; i <= D; i++) cout << t[i]+1 << endl;
}

void make_random_ans(){
    for(int i = 1; i <= D; i++){
        t[i] = rand()%N;
        st[t[i]].insert(i);
    }
}

double TIME_LIMIT = 1.5;

double p_th(double cur_time){
   return 0.8+(1.0-0.8)*(cur_time/TIME_LIMIT);
}

ll solve(){
    make_random_ans();
    clock_t start = clock();
    ll prev_sat = calc_score();
    int cnt = 0;
    while(true){
        clock_t cur_time = clock();
        int d = (rand()%D)+1, q = (rand()%N);
        ll cur_sat = calc_change(prev_sat, d, q);
        if(t[d] == q) continue;
        if(cur_sat > prev_sat){
            prev_sat = cur_sat;
            change(d, q);
        }else{
            if(rand_dist(engine) > p_th((double)(cur_time-start)/CLOCKS_PER_SEC)) {
                change(d, q);
                prev_sat = cur_sat;
            }
        }
        if((double)(cur_time-start)/CLOCKS_PER_SEC >= TIME_LIMIT) break;
    }
    return prev_sat;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    input();
    solve();
    output();
}

Measured memory_bytes: 3796
from itertools import combinations as co
n,m,x=map(int,input().split())
A=[]
ansl=[]

for i in range(n):
    A.append(list(map(int,input().split())))
a0,a,b,c,d,e,f,g,h,i,j,k,l=0,0,0,0,0,0,0,0,0,0,0,0,0
alp=[i,(i,j),(i,j,k),(h,i,j,k),(g,h,i,j,k),(f,g,h,i,j,k),(e,f,g,h,i,j,k),(d,e,f,g,h,i,j,k),(c,d,e,f,g,h,i,j,k),(b,c,d,e,f,g,h,i,j,k),(a,b,c,d,e,f,g,h,i,j,k),(a0,a,b,c,d,e,f,g,h,i,j,k)]
for t in range(n):
    for alp[t] in co(range(n),t+1):
        for l in range(1,m+1):
            if sum([A[al][l] for al in alp[t]])<x:
                break
            if l==m:
                ansl.append(sum([A[al][0] for al in alp[t]]))
    if n==t+1:
        print(min(ansl) if len(ansl)>0 else "-1")
        quit()



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

int main()
{
    int n,l;
    cin>>n>>l;
    string s[n];
    for (int i=0; i<n; i++)
	   cin>>s[i];
    sort(s,s+n);
    for (int i=0; i<n; i++)
	   cout<<s[i];
	return 0;
}

Measured memory_bytes: 256
n,m = map(int,input().split())

li1 = []
lin = []

for _ in range(m):
    a,b = map(int,input().split())
    if a == 1:
        li1.append(b)
    elif b == n:
        lin.append(a)

li1.sort()
lin.sort()

tmp = 0

if not len(lin):
    print('IMPOSSIBLE')
    exit()

for i in li1:
    while i > lin[tmp]:
        tmp += 1
        if tmp == len(lin):
            print('IMPOSSIBLE')
            exit()
    if i == lin[tmp]:
        print('POSSIBLE')
        exit()


print('IMPOSSIBLE')


Measured memory_bytes: 11420
#include<bits/stdc++.h>
using namespace std;
typedef long long int llint;
int main(){
    int n;
    scanf("%d",&n);
    char c[n][n];
    for(int i=0;i<n;i++)for(int j=0;j<n;j++){
        c[i][j]=' ';
        while(c[i][j]>'z'||c[i][j]<'a')scanf("%c",&c[i][j]);
    }
    char d[n][n];
    int ans=0;
    for(int s=0;s<n;s++){
        for(int i=0;i<n;i++)for(int j=0;j<n;j++){
            d[i][j]=c[(i+s)%n][j];
        }
        bool sym=true;
        for(int i=0;i<n;i++)for(int j=0;j<n;j++)if(d[i][j]!=d[j][i])sym=false;
        if(sym)ans++;
    }
    ans*=n;
    printf("%d\n",ans);
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
void arraycout(int *arrayy,int n){
    for(int u=0;u<n;u++){//出力
        if(u==n-1){
            cout<<arrayy[u]<<endl;
        }else{
            cout<<arrayy[u]<<' ';
        }
    }
    
}


int selectionSort(int* suu,int n){
    int ans=0;
    for(int i=0;i<n;i++){
        int minj = i;
        for(int j=i;j<n;j++){
            if(suu[j]<suu[minj]){
               
                minj=j;
                
            }
           
        }
         if(i!=minj)ans++;
        swap(suu[i],suu[minj]);
        
    }
    
    
    
    
    return ans;
}

int main(){
   
    int n;
    cin>>n;
    int suu[n];
    for(int i=0;i<n;i++){
        cin>>suu[i];
    }
    
    int ans=selectionSort(suu,n);
    arraycout(suu,n);
    cout<<ans<<endl;


return 0;
}


Measured memory_bytes: 3132
import java.util.*
 
fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val t = (1..n).map { sc.nextInt() }
 
    var ans = 0
    for (i in 1 until n-1) {
        if (t[i - 1] < t[i] && t[i] < t[i + 1] ||
                t[i - 1] > t[i] && t[i] > t[i + 1]) {
            ans++
        }
    }
    println(ans)
}

Measured memory_bytes: 31400
#include <iostream>
#include <iomanip>
#include<vector>
#include <algorithm>
#include <queue>
#include<string>
#include <map>
#include <cmath>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <utility>
#include <set>
typedef long long ll;
typedef long double ld;


#define REP(i,s,n)for(ll i=s;i<(n);++i)
#define rep(i,n) REP(i,0,n)
using namespace std;
ll S[1000] = { 0 };
ll N,M,Q;


int main() {
	set<ll>A;
	cin >> Q;
	rep(i, Q) {
		ll a, b;
		cin >> a >> b;
		if (a==0) {
			A.insert(b);
			cout << A.size() << endl;
		}
		else {
			if (A.find(b)!=A.end()) {
				cout << 1 << endl;
			}
			else {
				cout << 0 << endl;
			}
		}
	}
	return 0;
}





Measured memory_bytes: 12456
#include<stdio.h>
#define INF 10000000

int time[101][101],cost[101][101],m;

void warshall_floyd_cost(void);
void warshall_floyd_time(void);
int min(int,int);
void init(void);

int main(void){
  int i,j,n,k,a,b,cos,tim,p,q,r;

  while(scanf("%d %d",&n,&m),n,m){

    init();

    for(i=0;i<n;i++){
      scanf("%d %d %d %d",&a,&b,&cos,&tim);
      cost[a][b]=cost[b][a]=cos;
      time[a][b]=time[b][a]=tim;
    }

    warshall_floyd_cost();
    warshall_floyd_time();

    scanf("%d",&k);
    for(i=0;i<k;i++){
      scanf("%d %d %d",&p,&q,&r);
      printf("%d\n",r?time[p][q]:cost[p][q]);
    }
  }
  
  return 0;
}

void init(void){
  int i,j;
  for(i=0;i<101;i++){
    for(j=0;j<101;j++){
      time[i][j]=cost[i][j]=INF;     
    }
    time[i][i]=cost[i][i]=0;
  }
}

void warshall_floyd_cost(void){
  int i,j,k;
  for(k=0;k<=m;k++)
    for(i=0;i<=m;i++)
      for(j=0;j<=m;j++)
	cost[i][j]=min(cost[i][j],cost[i][k]+cost[k][j]);
}

void warshall_floyd_time(void){
  int i,j,k;
  for(k=0;k<=m;k++)
    for(i=0;i<=m;i++)
      for(j=0;j<=m;j++)
	time[i][j]=min(time[i][j],time[i][k]+time[k][j]);
}

int min(int x,int y){
  return x<y?x:y;
}

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

int main(){
  int n,m;
  cin>>n>>m;
  vector<int>q(m);
  for(int i=0;i<m;i++)cin>>q[i];
  
  vector<int>used(n+1,0),ans;
  for(int i=q.size()-1;i>=0;i--)
    if(!used[q[i]]++)ans.push_back(q[i]);
  for(int i=1;i<=n;i++)if(!used[i])ans.push_back(i);
  for(int i=0;i<n;i++)cout<<ans[i]<<endl;

  return 0;
}

Measured memory_bytes: 5004
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

const int MAX = 2010000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

long long FINV(int n){
    if (n < 0) return 0;
    return finv[n];
}

int main() {
    int x,y;
    cin >> x >> y;
    int n = x + y;
    if(n % 3 != 0){
        cout << '0' << endl;
        return 0;
    }

    

    n /= 3;
    if(x < n || y < n){
        cout << '0' << endl;
        return 0;
    }
    

    x -= n;
    y -= n;
    COMinit();
    cout << COM(x + y, x) << endl;
    return 0;
}
 
 


Measured memory_bytes: 47488
import java.util.Scanner;

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(b>a&&b<c)
		{
			System.out.println("Yes");
		}
		else
		{
			System.out.println("No");
		}
	}
}



Measured memory_bytes: 26144
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000000000000
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define pb push_back
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[2000010];
struct edge{int to,cost;};
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
void init_fact(){
    kaijo[0]=1;
    for(int i=1;i<=2000000;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=MOD;
    }
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%MOD;
    int memo=modpow(a,b/2);
    return memo*memo%MOD;
}
int comb(int a,int b){
    if(!kaijo[0])init_fact();
    return kaijo[a]*modpow(kaijo[a-b],MOD-2)%MOD*modpow(kaijo[b],MOD-2)%MOD;
}
int inv(int x){
    x=modpow(x,MOD-2);
    return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
    double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
    double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
    double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
    double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
    return tc*td<0&&ta*tb<0;
}
double dist(double ax,double ay,double bx,double by){
    return sqrt((bx-ax)*(bx-ax)+(ay-by)*(ay-by));
}
int n;
pair<int,int>p[100010];
signed main(){
    cin>>n;
    rep(i,n){
        cin>>p[i].first;
        p[i].second=i+1;
    }
    sort(p,p+n);
    cout<<p[0].second<<endl;
    return 0;
}



Measured memory_bytes: 4664
using System;
using System.Collections.Generic;
using System.Linq;
class Program{
	const int mod=1000000007;
	static void Main(){
		int n=int.Parse(Console.ReadLine());
		int h=int.Parse(Console.ReadLine());
		int w=int.Parse(Console.ReadLine());
		
		Console.WriteLine("{0}",(1+n-h)*(1+n-w));
	}
}


Measured memory_bytes: 13140
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String args[]) throws IOException {
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	String message = br.readLine();
	message = message.replaceAll("[a-z]", "x");
	System.out.println(message);
    }
}

Measured memory_bytes: 22356
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void)
{
  int n;
  cin >> n;
  ll s = 0;
  for(ll i = 1;i<n+1;i++)
  {
      if(i%3!=0 && i%5!=0) s+=i;
  }
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define ALL(v) std::begin(v),std::end(v)
using lint=long long;
using lubl=long double;
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
    lint n;std::cin>>n;
    std::vector<lint>a(8);
    lint ans=0;
    while(n--){
        lint x;std::cin>>x;
        x/=400;
        if(8<=x)ans++;
        else a.at(x)=1;
    }
    lint min=std::accumulate(ALL(a),0ll);
    std::cout<<std::max(min,1ll)<<' '<<ans+min<<'\n';
}


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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
#define LINF 1e15
typedef long long ll;

struct Edge{
    int to,dist;
};

int main() {
    int N,M; cin >> N >> M;

    vector<vector<Edge>> G(N);
    REP(i,M){
        int L,R,D; cin >> L >> R >> D;
        L--;
        R--;
        G[L].push_back({R,D});
        G[R].push_back({L,-D});
    }

    vector<ll> X(N,LINF);

    
    REP(i,N){
        if(X[i] == LINF){
            X[i]=0;

            queue<int> q;
            q.push(i);
            while(!q.empty()){
                int pos = q.front(); q.pop();
                
                for(auto next: G[pos]){
                    if(next.to == pos) continue;

                    if(X[next.to] == LINF){
                        X[next.to] = X[pos] + next.dist;
                        q.push(next.to);
                    }else{
                        if(X[next.to] != X[pos] + next.dist){
                            cout << "No" << endl;
                            return 0;
                        }
                    }
                }
            }
        }
    }

    cout << "Yes" << endl;




    return 0;
}

Measured memory_bytes: 12944
import java.util.Scanner;

/**
 * https://abc045.contest.atcoder.jp/tasks/abc045_a
 */
public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int h = sc.nextInt();
		sc.close();
		
		System.out.println(((a+b)*h)/2);

	}

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define PI 3.14159265359
#define MAX 10000
#define NIL -1
using namespace std;
const int64_t MOD = 1e9 + 7;

struct Node { int parent, left, right; };

Node T[MAX];
int n, D[MAX], H[MAX];

void setDepth(int u, int d) {
	if (u == NIL) return;
	D[u] = d;
	setDepth(T[u].left, d + 1);
	setDepth(T[u].right, d + 1);
}

int setHeight(int u) {
	int h1 = 0, h2 = 0;
	if (T[u].left != NIL) h1 = setHeight(T[u].left) + 1;
	if (T[u].right != NIL) h2 = setHeight(T[u].right) + 1;
	return H[u] = (h1 > h2 ? h1 : h2);
}

int getSibling(int u) {
	if (T[u].parent == NIL) return NIL;
	if (T[T[u].parent].left != u && T[T[u].parent].left != NIL) {
		return T[T[u].parent].left;
	}
	if (T[T[u].parent].right != u && T[T[u].parent].right != NIL) {
		return T[T[u].parent].right;
	}
	return NIL;
}

void print(int u) {
	cout << "node " << u << ": ";
	cout << "parent = " << T[u].parent << ", ";
	cout << "sibling = " << getSibling(u) << ", ";
	int deg = 0;
	if (T[u].left != NIL) deg++;
	if (T[u].right != NIL) deg++;
	cout << "degree = " << deg << ", ";
	cout << "depth = " << D[u] << ", ";
	cout << "height = " << H[u] << ", ";

	if (T[u].parent == NIL) {
		cout << "root" << endl;
	}
	else if (T[u].left == NIL && T[u].right == NIL) {
		cout << "leaf" << endl;
	}
	else {
		cout << "internal node" << endl;
	}
}

int main() {
	int v, l, r, root = 0;
	cin >> n;

	for (int i = 0; i < n; i++) {
		T[i].parent = NIL;
	}

	for (int i = 0; i < n; i++) {
		cin >> v >> l >> r;
		T[v].left = l;
		T[v].right = r;
		if (l != NIL) T[l].parent = v;
		if (r != NIL) T[r].parent = v;
	}

	for (int i = 0; i < n; i++) {
		if (T[i].parent == NIL) root = i;
	}

	setDepth(root, 0);
	setHeight(root);

	for (int i = 0; i < n; i++) {
		print(i);
	}

	return 0;
}


Measured memory_bytes: 3140
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

long P = 10^^9+7;
long[10^^5+50] F, RF;

long pow(long x, long n) {
    long y = 1;
    while (n) {
        if (n%2 == 1) y = (y * x) % P;
        x = x^^2 % P;
        n /= 2;
    }
    return y;
}

void init()
{
    F[0] = F[1] = 1;
    foreach (i, ref x; F[2..$]) x = (F[i+1] * (i+2)) % P;

    {
        RF[$-1] = 1;
        auto x = F[$-1];
        auto k = P-2;
        while (k) {
            if (k%2 == 1) RF[$-1] = (RF[$-1] * x) % P;
            x = x^^2 % P;
            k /= 2;
        }
    }
    foreach_reverse(i, ref x; RF[0..$-1]) x = (RF[i+1] * (i+1)) % P;
}

long comb(N)(N n, N k)
{
    auto n_b = F[n];    // n!
    auto nk_b = RF[n-k]; // 1 / (n-k)!
    auto k_b = RF[k];    // 1 / k!

    auto nk_b_k_b = (nk_b * k_b) % P; // 1 / (n-k)!k!

    return (n_b * nk_b_k_b) % P;  // n! / (n-k)!k!
}

void main()
{
    init();
    auto nk = readln.split.to!(long[]);
    auto N = nk[0];
    auto K = nk[1];

    auto NK = N-K;

    foreach (long i; 1..K+1) {
        if (i-1 > K-1 || i > NK+1) {
            writeln(0);
            continue;
        }
        auto b = comb(K-1, i-1);
        auto r = comb(NK+1, i);
        writeln((b*r)%P);
    }
}

Measured memory_bytes: 1792
#include<map>
#include<set>
#include<queue>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<vector>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
#define lc (x<<1)
#define rc (x<<1|1)
#define gc (p1==p2&&(p2=(p1=buf)+fread(buf,1,size,stdin),p1==p2)?EOF:*p1++)
#define mk make_pair
#define pi pair<int,int>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N=1e5+10,size=1<<20,mod=998244353;

char buf[size],*p1=buf,*p2=buf;
template<class o> void qr(o &x) {
	char c=gc; x=0; int f=1;
	while(!isdigit(c)){if(c=='-')f=-1; c=gc;}
	while(isdigit(c)) x=x*10+c-'0',c=gc;
	x*=f;
}
template<class o> void qw(o x) {
	if(x/10) qw(x/10);
	putchar(x%10+'0');
}
template<class o> void pr1(o x) {
	if(x<0)x=-x,putchar('-');
	qw(x); putchar(' ');
}
template<class o> void pr2(o x) {
	if(x<0)x=-x,putchar('-');
	qw(x); puts("");
}

struct edge{int y,next;}a[N];int len,last[N];
void ins(int x,int y) {a[++len]=(edge){y,last[x]};last[x]=len;}

void upd(int &x) {x+=x>>31&mod;}

ll power(ll a,ll b=mod-2) {
	ll c=1;
	for(   ;b;b>>=1,a=a*a%mod)
		if(b&1) c=c*a%mod;
	return c;
}

int n,m,f[N],sum[3][N],sz[3],g[N],num,ans,fir,inv=power(fir=power(10,18));

int main() {
	qr(n);
	for(int graph=0;graph<3;graph++) {
		if(len) memset(last+1,0,n<<2),len=0;
		qr(m); for(int j=1,x,y;j<=m;j++) {
			qr(x),qr(y);
			if(x>y) swap(x,y);
			ins(x,y);
		}
		int now=power(fir,n);
		for(int i=n; i;i--) {
			//��sg����(f)
			++num;
			for(int k=last[i];k;k=a[k].next)
				g[f[a[k].y]]=num;
			f[i]=0;
			while(g[f[i]]==num) f[i]++;
			sz[graph]=max(sz[graph],f[i]);
			upd(sum[graph][f[i]]+=now-mod);
			now=(ll)now*inv%mod;
		}
	}
	for(int i=0;i<=sz[0];i++)
		for(int j=0,k;j<=sz[1];j++) {
			k=i^j;
			upd(ans+=(ll)sum[0][i]*sum[1][j]%mod*sum[2][k]%mod-mod);
		}
	pr2(ans);
	return 0;
}



Measured memory_bytes: 2816
#include <iostream>
#include <map>

using namespace std;
constexpr int64_t MOD = 1'000'000'007;

map< int64_t, int64_t > prime_factor(int64_t n) {
    map< int64_t, int64_t > ret;
    for(int64_t i = 2; i * i <= n; i++) {
        while(n % i == 0) {
        ret[i]++;
        n /= i;
        }
    }
    if(n != 1) ret[n] = 1;
    return ret;
}

const int64_t MAX = 110000;
int64_t fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int64_t i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
int64_t COM(int64_t n, int64_t k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(void) {
    int N, M;
    cin >> N >> M;
    COMinit();

    int64_t ans = 1;
    for(auto e: prime_factor(M)) {
        ans *= COM(N + e.second - 1, N-1);
        ans %= MOD;
    }

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


Measured memory_bytes: 2816
#include <iostream>
#include <cmath>
#include <climits>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <numeric>
using namespace std;
// scanf
#pragma warning(disable: 4996)
// v:vector  type:型  order:greater or less
#define _sort(v,type,order) do { sort(v.begin(),v.end(),order<type>()); } while(0)
// v:vector  default_value:初期値
#define _sum(v,default_value) accumulate(v.begin(),v.end(),default_value )
// 丸め
#define _round(v) round(v)
// 2乗 / 3乗
#define _square(v) pow(v,2)
#define _cube(v)   pow(v,3)
// 大小判定
#define _max(x,y) max(x,y)
#define _min(x,y) min(x,y)
// string ⇒ int
#define _stringtoi(s) stoi(s)
// double 平方根
#define _sqrt(x) sqrt(x)
// double 引数 x 以上で最小の整数値
#define _ceil(x) ceil(x)

int main()
{
	int32_t a, b, x;
	cin >> a >> b >> x;

	if (a + b < x) { 
		printf("NO\n");
		return 0;
	}
	if (a > x) {
		printf("NO\n");
		return 0;
	}
	printf("YES\n");
	return 0;
	//	std::cout << "Hello World!\n"; 
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int d[100];
int a,b,c;
int main()
{
	cin>>a>>b>>c;
	d[b]++;
	d[a]++;
	d[c]++;
	if(d[5]==2&&d[7]==1)
        cout<<"YES"<<endl;
        else
    cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<functional>
#include<algorithm>
#include<string>
#include<map>
#include<queue>
#include<cmath>

using namespace std;

typedef long long int ll;

int main(void){

    ll h;
    cin >> h;

    int count = 0;
    ll ans = 0;

    while(h > 0){
        count++;
        h /= 2;
    }

    for(int i = 0;i < count;i++){
        ans += pow(2, i);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
int main()
{
	int N;
	int K;
	int X;
	int Y;
	scanf("%d %d %d %d",&N,&K,&X,&Y);
	if(N<=K) printf("%d",N*X);
	else printf("%d",K*X+(N-K)*Y);
	return 0;
}

Measured memory_bytes: 128
# -*- coding: utf-8 -*-

import sys

def parse_input(lines_as_string = None):


    lines = []
    if lines_as_string is None:
        lines.append(input())
    else:
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    tokens = lines[0].split(" ")
    s = tokens[0]

    return (s,)


def solve(s):

    m = 0
    for ss_length in range(len(s) + 1):
        for i in range(len(s)):
            if i+ss_length > len(s):
                break

            ss = s[i:i+ss_length]
#            print("ss=%s" % ss)
            count = 0
            for c in ss:
                if c in "ACGT":
                    count = count + 1
            if count == ss_length and m < ss_length:
                m = ss_length
                break


    return m

def main():
    # 出力

    print("%s" % solve(*parse_input()))

if __name__ == '__main__':

    main()


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

int main() {
  int N;
  int ansx,x,a,b,c;
  ansx=0;x=1000000000;
  cin>>N;
  vector<int>v(N);
  for(int i=0;i<N;i++)cin>>v[i];
  sort(v.begin(),v.end());
  for(int i=0;i<N;i++){
    if(x>abs(v[N-1]-2*v[i])){x=abs(v[N-1]-2*v[i]);a=i;}
  }
  cout<<v[N-1]<<" "<<v[a]<<endl;
}


Measured memory_bytes: 640
import java.util.Scanner;
public class Main{
	public static void main(String args[])throws Exception{
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		String S = sc.next();
		Boolean flag = true;
		char[] C = new char[S.length()];
		for(int i=0;i<S.length();i++) {
			C[i] = S.charAt(i);
			if(i == A && C[i] != '-') {
				flag = false;
			}
			if(i != A && C[i] == '-') {
				flag = false;
			}
		}
		if(flag) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 23252
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
#define double long double
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
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 (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
#define eps 1e-12 
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N; cin >> N;
	int i = 650;
	//while (i<710) {
	//int N = i;

		string ans = "";
		while (N) {
			int a = N % 26;
			a += 25;
			a %= 26;
			char c = 'a' + a;
			ans.push_back(c);
			if (c == 'z')N--;
			N /= 26;
		}

		i++;

		reverse(ans.begin(), ans.end());
		cout << ans << endl;

	//}
	return 0;
}



Measured memory_bytes: 3648
#include<stdio.h>

#define MAX 100000

int a[MAX],n;

int partition(int p,int r){
    int j,t;
    int x=a[r];
    int i=p-1;

    for(j=p;j<r;j++){
        if(a[j]<=x){
            i++;
            t=a[i];
            a[i]=a[j];
            a[j]=t;
        }
    }
    t=a[i+1];
    a[i+1]=a[r];
    a[r]=t;
    
    return i+1;
}

int main(void){
    
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    int q=partition(0,n-1);

    for(int i=0;i<n;i++){
        if(i)printf(" ");
        if(i==q)printf("[");
        printf("%d",a[i]);
        if(i==q)printf("]");
    }
    printf("\n");

    return 0;
    
}


Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = ((int)(s)); i < (int)(n); i++)
int main(){
    int step, max_step = 0;
    cin >> step;
    vector<int> mochi(step);
    rep(i, 0, mochi.size()){
        cin >> mochi.at(i);
    }
    sort(mochi.begin(), mochi.end());
    mochi.erase(unique(mochi.begin(), mochi.end()), mochi.end());
    cout << mochi.size() << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<list>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;

void printList(list<int> v){
  int i = 0;
  for (list<int>::iterator it=v.begin(); it != v.end(); it++){
    if (i++) printf(" ");
    printf("%d", *it);
  }
  printf("\n");
}


int main() {
  int key, n, i;
  char com[20];
  list<int> v;
  scanf("%d",&n);
  for(i=0; i<n; i++){
    scanf("%s%d", com, &key);
    if (com[0] == 'i'){ v.push_front(key);}
    else if (com[0] == 'd'){
      if (strlen(com) > 6){
        if (com[6] == 'F') v.pop_front();
        else if (com[6] == 'L') v.pop_back();
      } else{
        for (list<int>::iterator it=v.begin(); it != v.end(); it++){
          if (*it == key){
            v.erase(it);
            break;
          }
        }
      }
    }
  }
  printList(v);

  return 0;
}

Measured memory_bytes: 34464
/*The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep.*/

//PRABHJOT SINGH A.K.A. PRABHI
//~~~~~conquizztador~~~~~


#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007
const int maxn= 100010;
int f[110]={0};
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int x=0,n=0,y=0,res=INT_MAX,p;
    cin>>x>>n;
    for(int i=0;i<n;++i)
    {
    	cin>>y;
    	++f[y];
    }
    for(int i=0;i<102;++i)
    {
    	if(!f[i])
    	{
    		if(res>abs(x-i))
    		{
    			res=abs(x-i);
    			p=i;
    		}
    	}
    }
    cout<<p<<endl;
}

Measured memory_bytes: 3640