akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <bits/stdc++.h>
#include <cmath>

using namespace std;


bool is_prime(int x)
{
  // if (x <= 1) return false;
  for (int i = 2; i * i <= x; i++) {
    if (!(x % i)) return false;
  }
  return true;
}


int main(int argc, char const* argv[])
{
  int x;

  scanf("%i", &x);

  int ans;
  ans = x;

  while (!is_prime(ans)) ans++;

  printf("%i\n", ans);

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <set>
#include <cstdlib>
#include <deque>

using namespace std;



int main() {
  int n,k,s;
  cin >> n >> k >> s;
  for(int i = 0; i < k; i++) {
    cout << s << " ";
  }
  for(int i = k; i < n; i++) {
    if(s == 1000000000) {
      cout << 1 << " ";
    }else {
      cout << s+1 << " ";
    } 
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define unless(flg) if ( !(flg) )
#define read cin<<
#define echo cout<<
#define fin <<'\n'
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
#define cinf(n,x) for(int UNCH=0;UNCH<(n);UNCH++) cin >> x[UNCH];
#define fcin(n,x) for(int UNCH=1;UNCH<=(n);UNCH++) cin>> x[UNCH];
#define memmin(x) memset((x),-1,sizeof((x)))
#define memzer(x) memset((x), 0,sizeof((x)))
#define meminf(x) memset((x),0x3f,sizeof((x)))
#define int long long
typedef long long ll;
typedef pair < int , int >  pii;
typedef vector < int > vit;
typedef map < string , int > mstit;
typedef vector < pii > vpi ;
typedef greater < pii > gpi;
typedef priority_queue < pii , vpi , gpi > dijk ;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 1000000009;
static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static const signed int dy[]={0,-1,0,1,-1,1,-1,1};

bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>T abs(T &x){return x<0 ? -x : x;}
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; }
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}

inline void solve(){

  int a, b;
  cin >>a >> b;
  cout << (b-a)*(b-a+1)/2-b fin;

}


struct xyz{ xyz(){ cin.tie(0), ios::sync_with_stdio(false); cout <<fixed<<setprecision(12);};}xyzzy;
signed main(){solve();return 0;}


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

int main(){
    
    long long int p=100;

    long long int  x;
    cin>>x;
    
     double a=1.01;
    int count=0;
    while(x>p){
        count++;
        p=p*a;
    }

    cout<<count<<endl;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
// 尺取り法
int main(void){
    long int N,M;
    int K;
    cin >> N >> M >> K;
    vector<int> A(N + 10);
    vector<int> B(M + 10);
    rep(i,N){ 
        cin >> A[i];
    }
    rep(i,M){
        cin >> B[i];
    }

    long long int count = 0;
    rep(i,M) count += B[i];
    int ans = 0;
    int j = M;
    for(int i=0;i <= N;i++){
        while(j > 0 && count > K){
            --j;
            count -= B[j];
        }
        if(count > K) break;
        ans = max(ans, i+j);
        if(i == N) break;
        count += A[i];

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

Measured memory_bytes: 4852
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using node = pair<string,ll>;
const ll inf = numeric_limits<ll>::max()/3;
const ll mod = 1e9+7;

int main(void){
  int n,k;
  cin >> n >> k;
  ll acc[1010] = {};
  for(int i = 0;i < n;++i){
    ll tmp;
    cin >> tmp;
    acc[i+1] = acc[i] + tmp;
  }
  vector<ll> calc;
  for(int i = 0;i < n;++i){
    for(int j = i+1;j <= n;++j){
      ll val = acc[j] - acc[i];
      calc.push_back(val);
    }
  }
  ll now = 0LL;
  for(int i = 50;i >= 0;--i){
    ll next = (now | (ll)1 << i);
    int cnt = 0;
    for(ll x : calc){
      if(next == (next & x)){
        ++cnt;
      }
    }
    if(cnt >= k)
      now = next;
  }
  cout << now << endl;
  return 0;
}


Measured memory_bytes: 6512
s=input()
s1=s.replace("eraser","0").replace("erase","0").replace("dreamer","0").replace("dream","0")
n=len(s1)
flag=False
for  i in range(0,n):
    if s1[i]!='0':
        flag=True
        break
        
if flag==False:
    print("YES")
else:
    print("NO")
    
    
        


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define PI 3.1415926535
const long long int MOD = 1000000007;
#define pb push_back
#define mp make_pair
#define fill(a)  memset(a, 0, sizeof (a))
#define SORT(v)  sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define MAX(v) *max_element(v.begin(), v.end())
#define MIN(v) *min_element(v.begin(), v.end())
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define watch(x) cout << (#x) << " is " << (x) << endl;
const long long int MAXX = 200000 + 5;
const long long int MINN = 2e5 + 5;
const long long int inf = 1e6;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef vector< iii > viii;

ll lcm(ll a, ll b) {
   return a / __gcd(a, b) * b;
}
int XOR(int x, int y){
  return (x | y) & (~x | ~y);
}
bool cmp(const pair<int,int> &a,const pair<int,int> &b) {
    return (a.second < b.second);
}
// bool isl = binary_search(x.begin(), x.end(), 5);
// __builtin_popcount(x)  - Returns the number of set bits in x
const long long int N = 10050;
const int MAXN = 105;
int binsearch(int lo, int hi){
	while(lo<hi){
		int mid=(lo+hi)/2;
		if((mid))   // check(mid)
			hi=mid;
		else
			lo=mid+1;
	}
	return lo;
}
ll power(ll x,ll y){
    ll res=1;
    while(y>0){
      if(y&1) res=((res*x)%MOD);

      y/=2;
      x=((x*x)%MOD);
    }
    return res%MOD;
}


int main(){
    FAST
    int n;
    cin>>n;
    map<string,int> m;
    for(int i=0;i<n;i++){
        string s;
        cin>>s;
        m[s]=1;
    }
    int cnt=0;
    for(auto it: m){
        cnt++;
    }
    cout<<cnt;
    return 0;
}


Measured memory_bytes: 19244
#include <iostream>
#include <utility>
#include <vector>
#include <queue>
#include <stack>
#include <array>
#include <algorithm>
#include <numeric>
#include <limits>
#include <string>
#include <regex>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

int main()
{
    int N;
    cin >> N;
    double t = 0;
    for (int i = 0; i < N; i++) {
        double _a;
        cin >> _a;
        t += 1.0 / _a;
    }
    t = 1.0 / t;
    printf("%.14f\n", t);
    return 0;
}


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

int squrtInt(int x){
    if(x < 4){
        return 1;
    }else{
        int i = 2;
        while(i < x){
            if(i * i > x){
                return i - 1;
            }
            i++;
        }
    }
    return 1;
}
bool isPrime(int x){
    if(x == 1 || (x > 2 && x % 2 == 0)){
        return false;
    }
    int i = 3, max = squrtInt(x) + 1;
    //cout << x << ", " << max << endl;
    while(i < max){
        if(x % i == 0){
            return false;
        }
        i += 2;
    }
    return true;
}
int main(){
    int n, i, x, cnt = 0;
    vector<int> v;
    cin >> n;
    for(i = 0; i < n; i++){
        cin >> x;
        v.push_back(x);
    }
    vector<int>::iterator ite = v.begin();
    while(ite != v.end()){
        if(isPrime(*ite)){
            /*if(cnt++ != 0){
                cout << " ";
            }
            cout << *ite;
            */
            cnt++;
        }
        ite++;
    }
    cout << cnt <<endl;
    return 0;
}

Measured memory_bytes: 1320
from collections import*
from heapq import*
(n,m),a,*q=[[*map(int,o.split())]for o in open(0)]
t=[-1]*n
def r(x):
 while t[x]>=0:x=t[x]
 return x
def u(x,y):
 x,y=r(x),r(y)
 if x!=y:
  if t[x]>t[y]:x,y=y,x
  t[x]+=t[y];t[y]=x
d=defaultdict(list)
for x,y in q:u(x,y)
i=c=0;b=[];k=(n+~m)*2;f=print
for v in a:d[r(i)]+=v,;i+=1
if k<1:f(0)
elif k>n:f('Impossible')
else:
 for r,p in d.items():p.sort();c+=p.pop(0);b+=p;k-=1
 f(c+sum(sorted(b)[:k]))

Measured memory_bytes: 35492
#include <bits/stdc++.h>   
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
     
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}
using Graph = vector<vector<int>>;
Graph G;

ll dp[110][2][110]; // pos, flag, count 1
int main(){
    string s; cin >> s;
    int n = s.size();
    int k; cin >> k;

    rep(i, 110)rep(j, 2)rep(k, 110) dp[i][j][k] = 0;
    dp[0][0][0] = 1;
    rep(i, n)rep(j, 2)rep(k, i + 1){
        int lim = j ? 9 : s[i] - '0';
        rep(d, lim + 1){
            dp[i + 1][j or d < lim][k + ((d != 0) ? 1 : 0)] += dp[i][j][k];
        }
    }
    ll ans = 0;
    rep(j, 2) ans += dp[n][j][k];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3812
#include <bits/stdc++.h>
 using namespace std;
 using pii = pair<int, int>;
 using ll = long long;
 #define rep(i, j, n) for(int i = j; i < (int)(n); i++)
 const ll MOD = 1000000007;
 const ll INFL = (1LL << 60);
 const int INFI = (1 << 30);

 int main() {
   int N; cin >> N;
   if (N % 1000 == 0) cout << 0 << endl;
   else cout << (N / 1000 + 1) * 1000 - N << endl;
 }


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

int main() {
  int n, k, x, y;
  cin >> n >> k >> x >> y;
  int ans;
  if (n >= k) {
    ans = k*x + (n-k)*y;
  } else {
    ans = n*x;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
#include<cassert>
#include<climits>
#include<cstring>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int inf = 1e9 + 7;
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};
#define ceil(a, b) a / b + !!(a % b)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)

int n;
int h[100001];
int memo[100001];
int recur(int i) {
    if (i >= n - 1) return 0;
    if (memo[i] != inf) return memo[i];
    int a = (i + 1 < n ? abs(h[i] - h[i + 1]) + recur(i + 1) : inf);
    int b = (i + 2 < n ? abs(h[i] - h[i + 2]) + recur(i + 2) : inf);
    return memo[i] = min(a, b);
}
int main() {
    cin >> n;
    rep(i, n) cin >> h[i];
    rep(i, 100001) memo[i] = inf;
    cout << recur(0) << endl;
}


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

const long long mod = 1e9 + 7;
vector <vector <long long>> c;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, k;
	cin >> n >> k;
	c.resize(n + 1);
	for (int i = 0; i <= n; i++){
		c[i].resize(n + 1);
	}
	c[0][0] = 1;
	for (int i = 1; i <= n; i++){
		c[i][0] = 1;
		for (int j = 1; j <= i; j++){
			c[i][j] = c[i - 1][j - 1] + c[i - 1][j];
			c[i][j] %= mod;
		}
	}
	for (int i = 0; i < k; i++){
		cout << c[n - k + 1][i + 1] * c[k - 1][i] % mod << '\n';
	}
}

Measured memory_bytes: 31616
def main():
    n, m = map(int, input().split())

    if n == 1 and m == 0:
        print(0)
        return

    d = [-1] * (n + 1)
    for _ in range(m):
        s, c = map(int, input().split())
        if d[s] == -1:
            d[s] = c
        elif d[s] != c:
            print(-1)
            return

    if d[1] == 0:
        if n == 1:
            print(0)
            return
        else:
            print(-1)
            return

    ret = ''
    for i in range(1, n + 1):
        if d[i] == -1:
            if i == 1:
                ret += '1'
            else:
                ret += '0'
        else:
            ret += str(d[i])

    print(ret)


if __name__ == '__main__':
    main()

# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()
# int(input())
# map(int, input().split())


Measured memory_bytes: 3064
/*input
2 2
1 2
1 2
*/
#include <bits/stdc++.h>
using namespace std;
long long a[305][305],mx[305];
queue<int> v[305];
bool hsh[305];
int main(){
	ios_base::sync_with_stdio(0);
	long long n,m,k,ans=1e9,sum=0,pos;
	memset(hsh,false,sizeof(hsh));
	cin>>n>>m;
	for(int i=1;i<=n;++i)
		for(int j=1;j<=m;++j){
			cin>>a[i][j];
			v[i].push(a[i][j]);
		}
	for(int x=0;x<m;++x){
		memset(mx,0,sizeof(mx));
		sum=pos=-1;
		for(int i=1;i<=n;++i)
			if(++mx[v[i].front()]>sum)
				sum=mx[v[i].front()],pos=v[i].front();
		hsh[pos]=true;
		ans=min(ans,sum);
		for(int i=1;i<=n;++i)
			while(!v[i].empty() and hsh[v[i].front()]) 
				v[i].pop();
	}
	cout<<ans;
}

Measured memory_bytes: 1536
#include<iostream>
#include<bits/stdc++.h>
#include<math.h>
#include<map>

using namespace std;
int main()
{


  long long int k,a,b,z=0;


      cin >> k>>a>>b;

for(int i=a;i<=b;i++)
{

    if (i%k==0)
    {

        cout << "OK" <<endl;
        z++;
        break;


    }


}

if(z==0) cout << "NG"<<endl;



return 0;
}


Measured memory_bytes: 3620
a,b = list(map(int,input().split()))
l = []

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

dl = list(set(make_divisors(a)) & set(make_divisors(b)))
dl.sort(reverse = True)

#ユークリッド
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a

del dl[dl.index(1)]
ans = [1]
flag=True
j=0
while(j<len(dl)):
    x = dl.pop(0)
    for i in dl:
        if gcd(x,i)==1:
            next
        else:
            flag=False
            break
    if flag:
        ans.append(x)
    flag=True
print(len(ans))


Measured memory_bytes: 5068
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(int argc, char** argv){
    string S;
    int Q;
    cin >> S >> Q;
    int rev = 0;
    string buf = "";
    for (int i=0; i<Q; i++){
        int T;
        cin >> T;
        if (T==1){
            rev = (rev + 1)%2;
        }
        else {
            int F;
            char C;
            cin >> F >> C;
            if ((F+rev)%2 == 1){
                buf += C;
            } else {
                S += C;
            }
        }
    }

    reverse(buf.begin(), buf.end());
    S = buf + S;

    if (rev == 1) reverse(S.begin(), S.end());
    cout << S << "\n";

    return 0;
}


Measured memory_bytes: 1116
#include<stdio.h>
int main(void)
{
	int n,m,f,x;
	while(f=scanf("%d%d",&n,&m),n)
	{
		while(m--)scanf("%d",&x),f=f&&x-1;
		printf("%f\n",f?n/2.:0.);
	}
	return 0;
}

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

#define ll long long

const int mxN=1e5, M=998244353;
int n, a[3*mxN], d[4];
string s;
map<char, int> mp{{'R', 0}, {'G', 1}, {'B', 2}};
vector<int> v[3];
ll ans=1;

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

	cin >> n >> s;
	for(int i=0; i<3*n; ++i)
		v[mp[s[i]]].push_back(i);
	for(int i=0; i<n; ++i) {
		a[min({v[0][i], v[1][i], v[2][i]})]=-1;
		a[max({v[0][i], v[1][i], v[2][i]})]=1;
	}
	d[0]=n;
	for(int i=0; i<3*n; ++i) {
		ans=ans*d[a[i]+1]%M;
		--d[a[i]+1];
		++d[a[i]+2];
	}
	cout << ans;
}

Measured memory_bytes: 3340
#ifdef __APPLE__
#include <iostream>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <random>
#else
#include <bits/stdc++.h>
#endif

using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define tc(t) for (int tc=1; tc<=t; tc++)
typedef vector<int> VI;
typedef vector<long long int> VLLI;
typedef vector<pair<int, int> > VPI;
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<ll, ll> PLL;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll modInverse (ll a) {ll p = mod - 2; return powmod(a, p);}
// head

int main() {
    ll n;
    cin >> n;
    ll sum = (n*(n+1))/2;
    sum -= (((n/3)*(n/3 + 1))/2)*3;
    sum -= (((n/5)*(n/5 + 1))/2)*5;
    sum += (((n/15)*(n/15 + 1))/2)*15;
    cout <<  sum << "\n";
}



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

int main()
{
	int n, m;
    cin >> n >> m;
	int ara[n], vote = 0;
	double adds = 0;
	for (int i = 0; i < n; ++i)
	{
		cin >> ara[i];
		vote += ara[i];
	}
	sort(ara, ara + n, greater<int>());
	adds = (vote*1.0) / (4 * m);
	for (int k = 0; k < m; ++k)
	{
		if (ara[k] < adds)
		{
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 3608
n=int(input())
l=[0]*10**5
A=list(map(int,input().split()))

for a in A:
    l[a-1]+=1

ans=sum(A)

q=int(input())
for i in range(q):
    b,c=map(int,input().split())
    tmp=l[b-1]
    l[b-1]=0
    l[c-1]+=tmp
    
    ans+=tmp*(c-b)
    
    print(ans)

Measured memory_bytes: 21840
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include<numeric>
#include<cmath>
#include<map>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> pll;
const ll mod = 1000000007;

ll mpow(ll x, ll n){
    ll ans = 1;
    while(n){
        if(n % 2){
            ans = ans * x % mod;
        }
        x = x * x % mod;
        n >>= 1;
    }
    return ans;
}

ll gcd(ll a,ll b){
    if(a == 0 && b == 0) return 0;
    else if(a == 0) return b;
    else if(b == 0) return a;
    else{
        if(a < 0) a = -a;
        if(b < 0) b = -b;
        if(a < b) swap(a,b);
        while(true){
            ll p = a % b;
            a = b;
            b = p;
            if(p == 0)break;
        }
        return a;
    }
}

int main(){
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	//cout << fixed < cin >> N;
    vector<int> A,B;
    int N; cin>>N;
    ll none = 0;
    map<pll,pll> iwashi;
    REP(i,N){
        ll a,b;
        cin >> a >> b;
        if(a == 0 && b == 0) none++;
        else if(a == 0){
            iwashi[pll(0,0)].second++;
        }
        else if(b == 0){
            iwashi[pll(0,0)].first++;
        }
        else{
            ll g = gcd(a,b);
            a = a/g;
            b = b/g;
            if(b < 0){  //全ての点のy座標を正に
                a = -a; b = -b;
            }
            //else if(b == 0 && a < 0)a = -a;
            if(a<0){
                ll tmp = a;
                a = b;
                b = -tmp;
                iwashi[pll(a,b)].second++;
            }
            else{
                iwashi[pll(a,b)].first++;
            }
        }
    }
    ll ans = 1;
    for(auto i : iwashi){
        //i->
        ll now = (mpow(2,i.second.first) + mpow(2,i.second.second)-1) % mod;
        ans = ans* now % mod;
    }
    ans--;
    ans += none;
        
    cout << (ans+mod) % mod << endl;
    //cout << __gcd(10,-10) << endl;
}

Measured memory_bytes: 19228
#include <iostream>

using namespace std;

int main(void){
  int N;
  int count = 0, ans = 0;
  cin >> N;
  for(int i=1; i<=N; i+=2){
    count = 0;
    for(int j=1; j<=i; j+=2){
      if(i%j == 0){
        count++;
      }
    }
    if(count == 8){
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

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

typedef long long lint;

using namespace std;

int main(){
  int N=100001;
  int ans[N];
  REP(i,N)ans[i]=N;
  ans[0]=0;
  REP(i,N){
    int k=1;
    if(i+k<N){
      if(ans[i+k]>ans[i]+1)ans[i+k]=ans[i]+1;
    }
    k=6;
    while(i+k<N){
      if(ans[i+k]>ans[i]+1)ans[i+k]=ans[i]+1;
      k*=6;
    }
    k=9;
    while(i+k<N){
      if(ans[i+k]>ans[i]+1)ans[i+k]=ans[i]+1;
      k*=9;
    }
  }
  int n;
  cin>>n;
  cout<<ans[n]<<endl;

  return 0;
}


Measured memory_bytes: 640
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>  // https://boostjp.github.io/tips/math.html
#include <boost/dynamic_bitset.hpp>  // https://boostjp.github.io/tips/dynamic_bitset.html

constexpr int64_t DIV1097 = 1000000007LL;

using namespace std;

/**
   ceil(0, 2) == 0
   ceil(1, 2) == 1
   ceil(2, 2) == 1
   ceil(3, 2) == 2
   ceil(4, 2) == 2
*/
template<class T>
T ceil(T dividend, T divisor)
{
    return (dividend + (divisor - 1)) / divisor;
}

int main()
{
    int64_t D, G;
    std::cin >> D >> G;

    std::vector<int64_t> P, C;
    for (decltype(D) i = 0; i < D; ++i) {
        int64_t p, c;
        std::cin >> p >> c;
        P.push_back(p);
        C.push_back(c);
    }

    int64_t ans = INT64_MAX;

    std::vector<int> order(D);
    std::iota(std::begin(order), std::end(order), 0);

    std::sort(order.begin(), order.end());
    do {
        int64_t count = 0;
        int64_t g = G;
        for (int64_t i = 0; i < D; ++i) {
            auto idx = order[i];
            auto cnt = ceil(g, (int64_t)((idx+1) * 100));
            if (cnt <= P[idx]) {
                count += cnt;
                ans = std::min(ans, count);
                goto done;
            }
            else {
                g -= (idx+1) * 100 * P[idx];
                count += P[idx];
            }
            g -= C[idx];
            if (g <= 0) {
                ans = std::min(ans, count);
                goto done;
            }
        }
    done:
        int a;
    } while (std::next_permutation(order.begin(), order.end()));

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF ((1<<30)-1)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()


//osa_k法 高速素因数分解 前処理O(n loglog n)　本計算O(log n)
#define MAX_N 1000000
int prime[MAX_N];//i番目の素数
bool is_prime[MAX_N + 1];
int min_factor[MAX_N + 1];//最小の素因数
int sieve(int n) {
	int p = 0;
	memset(is_prime, true, sizeof(is_prime));
	is_prime[0] = is_prime[1] = false;
	min_factor[0] = 0;
	min_factor[1] = 1;
	for (int i = 2; i <= n; i++) {
		if (is_prime[i]) {
			min_factor[i] = i;
			prime[p++] = i;
			for (int j = 2 * i; j <= n; j += i) {
				is_prime[j] = false;
				if (min_factor[j] == 0)min_factor[j] = i;
			}
		}
	}
	return p;
}
int gcd(int a, int b) {
	if (b == 0)return a;
	return gcd(b, a % b);
}


int n;
int a[1000000];

bool pairwise() {
	unordered_set<int> s;
	rep(i, n) {
		unordered_set<int> t;
		int b = a[i];
		while (b > 1) {
			if (s.count(min_factor[b])) {
				return false;
			}
			t.insert(min_factor[b]);
			b /= min_factor[b];
		}
		s.insert(all(t));
	}
	return true;
}


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

	sieve(1000000);

	cin >> n;
	rep(i, n) {
		cin >> a[i];
	}


	if (pairwise()) {
		cout << "pairwise coprime" << endl;
	}
	else {
		int g = a[0];
		rep(i, n)g = gcd(g, a[i]);
		if (g == 1)cout << "setwise coprime" << endl;
		else cout << "not coprime" << endl;
	}



	return 0;
}


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

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int a,b,c;
  cin>>a>>b>>c;
  if((a==b && b!=c) || (a==c && c!=b) || (b==c && c!=a)){
    cout<<"Yes";
  }
  else{
    cout<<"No";
  }
  return 0;
}

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

void inserionsort(int *pbuff, int n){
	int v;
	int j;
	for(int i=1;i<n;i++){
		v=pbuff[i];
		j=i-1;
		while(pbuff[j]>v && j>=0){
			pbuff[j+1]=pbuff[j];
			j--;
		}
		pbuff[j+1]=v;
		for(int j=0;j<n-1;j++) cout << pbuff[j]<<" ";
		cout << pbuff[n-1]<<endl;
	}

	return ;
}

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

	int buff[100];

	for(int j=0;j<n;j++) cin >> buff[j];

	for(int j=0;j<n-1;j++) cout << buff[j]<<" ";
	cout << buff[n-1]<<endl;
	inserionsort(buff,n);
	return 0;
}



Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
using lli = long long;
#define rep(i,n) for(int i=0;i<n;i++)
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; }

lli n;

int main(void){
	cin >> n;
	vector<lli> a(n);
	rep(i, n) cin >> a[i];
	lli maxv = -1;
	lli ans = 0;
	rep(i, n){
		maxv = max(maxv, a[i]);
		if(maxv > a[i]) ans += maxv-a[i];
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4748
#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

int main(int argc, char *argv[])
{
  int N, M;
  map<string,  int> m;
  string s[200], t[200];
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> s[i];
    m[s[i]] += 1;
  }
  cin >> M;
  for (int i = 0; i < M; i++) {
    cin >> t[i];
    m[t[i]] -= 1;
  }

  int maxv = -2000;
  for (auto i = m.begin(); i != m.end() ; ++i ) {
    maxv = max(maxv, i->second);
  }

  if (maxv < 0) {
    cout << 0 << endl;
  } else {
    cout << maxv << endl;
  }

  return 0;
}


Measured memory_bytes: 256
//ProblemD

#ifdef _MYPC
#include "mypc.h"
#endif // _MYPC

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <memory>
#include <cstdio>
#include <cstring>

using namespace std;

//ProblemD
#define MAXL 300

class Solve {
private:
	string S;
	int K;
	int n;

	int dp[MAXL+1][MAXL+1][MAXL+1]{};

	void solve() {
		cin >> S >> K;
		n = S.length();

		for (int k = 0; k <= K; k++) {
			for (int i = 0; i < n; i++) {
				dp[k][i][i + 0] = 1;
			}

			for (int l = 1; l < n; l++) {
				for (int i = 0; i < n - l; i++) {
					int j = i + l;

					if (S[i] == S[j]) {
						dp[k][i][j] = 2 + dp[k][i + 1][j - 1];
					}
					else {
						dp[k][i][j] = max(dp[k][i+1][j], dp[k][i][j-1]);
						if (k > 0) {
							dp[k][i][j] = max(dp[k][i][j], 2 + dp[k-1][i+1][j - 1]);
						}
					}
				}
			}
		}

		cout << dp[K][0][n - 1] << endl;
	}

public:
	Solve() { solve(); }
};

int main(int argc, char* argv[]) {
	unique_ptr<Solve> solve = make_unique<Solve>();
	return 0;
}


Measured memory_bytes: 106752
#include<iostream>
#include<string>
using namespace std;
int main(){
	int n,x,c=10000,d=0;
	cin>>n>>x;
	int a[103];
	for (int b=0;b<n;b++){
		cin>>a[b];
		if (c>a[b])
		c=a[b];
		d+=a[b];
	}
	if (d==x)
	cout<<n<<endl;
	else {
		int e=(x-d)/c;
		cout<<n+e<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<set>

using namespace std;

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

typedef pair<int,int> pii;
typedef pair<pii,int> piii;

piii mk(int a, int b, int c){
	return piii(pii(a,b), c);
}

int main(){
	A:;
	
	int teemwrong[55][11]={0};
	int teemcost[55]={0};
	int teemac[55]={0};
	
	int M,T,P,R;
	cin>>M>>T>>P>>R;
	
	if(M==0&&T==0&&R==0&&P==0)return 0;
	
	rep(i,R){
		int m,t,p,j;
		cin>>m>>t>>p>>j;
		
		if(j==0){
			teemac[t]++;
			teemcost[t]+=m+teemwrong[t][p]*20;
		}else{
			teemwrong[t][p]++;
		}
	}
	
	vector<piii> rank;
	reps(i,1,T+1){
		rank.push_back(mk(teemac[i], -teemcost[i], i));
	}
	
	sort(rank.begin(),rank.end());
	reverse(rank.begin(),rank.end());
	
	rep(i,rank.size()){
		if(i!=0){
			if(rank[i].first==rank[i-1].first)printf("=");
			else printf(",");
		}
		printf("%d",rank[i].second);
	}puts("");
	
	
	goto A;
}

Measured memory_bytes: 1188
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int n,m,X,Y; cin>>n>>m>>X>>Y;
	int x[100],y[100];
	for(int i=0;i<n;i++) cin>>x[i];
	for(int i=0;i<m;i++) cin>>y[i];
	int maxx=x[0],miny=y[0];
	for(int i=1;i<n;i++) maxx=max(maxx,x[i]);
	for(int i=1;i<m;i++) miny=min(miny,y[i]);
	bool ans=false;
	for(int i=X+1;i<=Y;i++){
		if(maxx<i && i<=miny) ans=true;
	}
	if(ans) cout << "No War" << endl;
	else cout << "War" << endl;
	
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long x = sc.nextLong();
		long a = 0;
		long count = 1;
		if(x <= 6){
		System.out.println(count);
		}
		if(x > 6){
			count = 2*(x/11);
			x = x - (11*(x/11));
//			System.out.println(x);
			if(x == 0){
				System.out.println(count);
			}else if(x <= 6){
				System.out.println(count+1);
			}else{
				System.out.println(count+2);
			}
		}
	}
}

Measured memory_bytes: 9044
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)

using namespace std;
using ll = long long;
using P = pair<int, int>;

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

    int N;
    cin>>N;
    vector<string> as(N);
    rep(i, N) cin>>as[i];
    vector<string> bs(N);
    copy(as.begin(), as.end(), bs.begin());

    bool flag = true;
    while(flag) {
        flag = false;
        rep(i, N - 1) {
            if (as[i][1] > as[i + 1][1]) {
                swap(as[i], as[i + 1]);
                flag = true;
            }
        }
    }
    rep(i, N) {
        int minj = i;
        for(int j = i + 1; j < N; ++j) {
            if (bs[minj][1] > bs[j][1]) minj = j;
        }
        swap(bs[i], bs[minj]);
    }
    string stable = "Stable";
    rep(i, N) {
        if (as[i] != bs[i]) {
            stable = "Not stable";
            break;
        }
    }
    rep(i, N - 1) cout<<as[i]<<" ";
    cout<<as[N - 1]<<endl;
    cout<<"Stable"<<endl;

    rep(i, N - 1) cout<<bs[i]<<" ";
    cout<<bs[N - 1]<<endl;
    cout<<stable<<endl;
}


Measured memory_bytes: 3192
#include <bits/stdc++.h>
#define HMAX (long long)((long long)(1e9)+7)
using namespace std;

int main(){
	int n; cin >> n;
	vector<int> h(n,0);
	vector<int> ih(n,0);
	for(int i = 0; i < n; ++i){
		cin >> h[i];
	}
	for(int i = 0; i < n; ++i){
		cin >> ih[i];
	}
	int err = -1,check = h[n-1];
	for(int i = n-1; i != -1; --i){
		//	cout << i << " ";
		if(h[i] == ih[i]){
			err = h[i];
			break;
		}
		if(h[i] > ih[i]){
			h[i] = ih[i];
		}
	}
	if(err != check || err != ih[0]){
		cout << 0 << endl;
		return 0;
	}

//	for(int i = 0; i < n; ++i)cout << h[i] << " ";
	long long ans = 1;
	for(int i = 1; i < n-1; ++i){
		if(h[i] == err){
			if(h[i-1] == h[i] && h[i] == h[i+1]){
				//cout << i << " " << h[i] << " ";
				ans = (ans * (long long)h[i]) % HMAX;
			}
		}
		else{
			if(h[i-1] == h[i]){
				//cout << i << " " << h[i] << " ";
				ans = (ans * (long long)h[i]) % HMAX;
			}
		}
	}
	if(h[n-1] != err && h[n-1] == h[n-2]){
		ans = (ans * (long long)h[n-1]) % HMAX;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
#include<random>
#include <bitset>
using namespace std;
#define N (1000000000+7)
//#define N 998244353
#define INF 1e16
typedef long long ll;
typedef pair<int,int> P;

ll dp[3010][3010][4];

int main(){
    dp[0][0][0]=0;
    int R,C,k;
    cin>>R>>C>>k;
    vector<ll>r(k),c(k),v(k);
    map<pair<int,int>,ll>mp;
    for(int i=0;i<k;i++){
        cin>>r[i]>>c[i]>>v[i];
        r[i]--;
        c[i]--;
        mp[P(r[i],c[i])]=v[i];
    }
    for(int i=0;i<R;i++){
        for(int j=0;j<C;j++){
            if(mp.find(P(i,j))!=mp.end()){
                for(int k=1;k<=3;k++){
                    if(k==1){
                        dp[i+1][j+1][1] = max(dp[i+1][j+1][1],dp[i+1][j][1]);
                        dp[i+1][j+1][1] = max(dp[i+1][j+1][1],dp[i+1][j][0]+mp[P(i,j)]);
                        dp[i+1][j+1][1] = max(dp[i+1][j+1][1],dp[i][j+1][1]+mp[P(i,j)]);
                        dp[i+1][j+1][1] = max(dp[i+1][j+1][1],dp[i][j+1][2]+mp[P(i,j)]);
                        dp[i+1][j+1][1] = max(dp[i+1][j+1][1],dp[i][j+1][3]+mp[P(i,j)]);
                    }
                    if(k==2){
                        dp[i+1][j+1][2] = max(dp[i+1][j+1][2],dp[i+1][j][2]);
                        dp[i+1][j+1][2] = max(dp[i+1][j+1][2],dp[i+1][j][1]+mp[P(i,j)]);
                    }
                    if(k==3){
                        dp[i+1][j+1][3] = max(dp[i+1][j+1][3],dp[i+1][j][3]);
                        dp[i+1][j+1][3] = max(dp[i+1][j+1][3],dp[i+1][j][2]+mp[P(i,j)]);
                    }
                }
            }
            else{
                for(int k=0;k<=3;k++)dp[i+1][j+1][k] = max(dp[i+1][j+1][k],max(dp[i+1][j][k],dp[i][j+1][k]));
            }
        }
    }
    ll ans = max(dp[R][C][0],max(dp[R][C][1],max(dp[R][C][2],dp[R][C][3])));
    cout<<ans<<endl;
}

Measured memory_bytes: 302496
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Arrays;

public class Main{

  public static void main(String [] args)throws IOException{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    int [] moun = new int[10];
    for(int i = 0; i < 10; i++)
      moun[i] = Integer.parseInt(br.readLine());
    Arrays.sort(moun);
    System.out.println(moun[9]);
    System.out.println(moun[8]);
    System.out.println(moun[7]);
  
  }


}

Measured memory_bytes: 9260
#include<iostream>
#include<vector>
#include<string>
#include<math.h>
#include<algorithm>
using namespace std;
int main() {
	int N;
	cin >> N;
	vector<int> d(N);
	for (int i = 0; i < d.size(); i++) {
		cin >> d.at(i);
	}
	sort(d.begin(), d.end());
	cout << d.at(N / 2) - d.at(N / 2 - 1) << endl;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main(void) {

    int x, y;
  
    cin >> x >> y;
  
    int g_num[13] = {0,1,3,1,2,1,2,1,1,2,1,2,1};
  
    if (g_num[x] == g_num[y]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
  
    return 0;

}


Measured memory_bytes: 3604
sgn n = if n >= 0 then 1 else -1

ans [a,b] = 
    (a' `div` b') * s
    where
        a' = abs a
        b' = abs b
        s  = (sgn a) * (sgn b)

main = do
    l <- getLine
    let i = map read $ words l :: [Integer]
        o = ans i
    print o


Measured memory_bytes: 4456
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<time.h>
#include<tuple>
#include<set>
#include<map>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
#define tget(a,b) get<a>(b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

ll N, M;
ll fac[300001];//n!(mod M)
ll ifac[300001];//k!^{M-2}(mod M)

map<int, int>prime_factor(ll n) {//mの素因数をリターン
	map<int, int>res;
	for (int i = 2; i*i <= n; i++) {
		while (n%i == 0) { ++res[i]; n /= i; };
	}
	if (n != 1)res[n] = 1; return res;
}
ll modpow(ll x, ll n) {//n次数　x基数
	if (n == 0)return 1;
	ll res = modpow(x*x%MOD, n / 2);
	if (n & 1)res = res * x%MOD;
	return res;
}
ll comb(ll a, ll b) {
	ll ret= fac[a]*ifac[a-b]%MOD;
	ret = ret * ifac[b] % MOD;
	return ret;
}
ll ans=1;
int main(void) {
	cin >> N >> M;
	map<int, int>mp = prime_factor(M);
	fac[0] = 1;
	ifac[0] = 1;
	FOR(i, 1, 300001) {
		fac[i] = fac[i - 1] * i % MOD;
		ifac[i] = modpow(i, MOD - 2)*ifac[i-1] % MOD;
	}
	for (auto it = mp.begin(); it != mp.end(); it++) {
		ll cur = it->second;
		if(cur>0)ans = (ans * comb(cur + N - 1, N - 1)) % MOD;
		
	}
	ct(ans);
	return 0;
}

Measured memory_bytes: 4992
# coding: utf-8
# Your code here!
import sys
from operator import itemgetter

def input():
    return sys.stdin.readline().rstrip()

N = int(input())
a = [list(map(int, input().split())) for _ in range(N)]
s = sorted(a, key=itemgetter(1))
current_t = 0

for i in range(N):
    current_t += s[i][0]
    if current_t > s[i][1]:
        print("No")
        break
else:
    print("Yes")

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

int main(){
    int n;
    cin >> n;
    vector<int> l(0);
    int input = 0;
    for(int i=0;i<n;i++){
        cin >> input;
        l.push_back(input);
    }
    sort(l.begin(),l.end());
    int ans = 0;
    for(int i=0;i<n-2;i++){
        for(int j=i+1;j<n-1;j++){
            int right = lower_bound(l.begin(),l.end(),l.at(i)+l.at(j)) - l.begin();
            int left = j+1;
            ans += right - left;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < n;i++)
int main(void) {
	int n,ans =0;map<string, int>m;
	cin >> n;vector<string> s(n),g;
	set<string> l;
	rep(i, n) {
		cin >> s[i];
		l.insert(s[i]);
		++m[s[i]];
	}
	string t;
	rep(i, n) {
		if (m[s[i]] > ans) {
			ans = m[s[i]];
			t = s[i];
		}
		else if (m[s[i]] == ans && t > s[i]) {
			t = s[i];
		}
		else continue;
	}
	for(auto it = l.begin();it != l.end();it++) {
		if (m[t] == m[*it]) {
			g.push_back(*it);
		}
	}
	sort(g.begin(), g.end());
	rep(i, g.size()) {
		cout << g[i] << endl;
	}
}

Measured memory_bytes: 37876
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	static final int MOD = 10000;
	static int dp[][][][];
	static int n, k;
	static int day[];

	public static int dp(int p1, int p2, int p3, int d) {
		if (0 <= dp[p1][p2][p3][d]) {
			return dp[p1][p2][p3][d];
		}
		if (p1 == p2 && p2 == p3) {
			return dp[p1][p2][p3][d] = 0;
		}

		if (d <= 2) {
			return dp[p1][p2][p3][d] = 1;
		} else {
			int count = 0;
			if (day[d - 3] == -1) {
				for (int i = 0; i < 3; i++) {
					count += dp(i, p1, p2, d - 1);
					count %= MOD;
				}
			} else {
				count += dp(day[d - 3], p1, p2, d - 1);
				count %= MOD;
			}
			return dp[p1][p2][p3][d] = count;
		}
	}

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

		n = sc.nextInt();
		k = sc.nextInt();
		day = new int[n];
		Arrays.fill(day, -1);
		for (int i = 0; i < k; i++) {
			day[sc.nextInt() - 1] = sc.nextInt() - 1;
		}

		dp = new int[3][3][3][n];
		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 3; j++) {
				for (int l = 0; l < 3; l++) {
					Arrays.fill(dp[i][j][l], -1);
				}
			}
		}

		int count = 0;
		for (int i = 0; i < 3; i++) {
			if (day[n - 3] == -1 || day[n - 3] == i) {
				for (int j = 0; j < 3; j++) {
					if (day[n - 2] == -1 || day[n - 2] == j) {
						for (int l = 0; l < 3; l++) {
							if (day[n - 1] == -1 || day[n - 1] == l) {
								count += dp(i, j, l, n - 1);
								count %= MOD;
							}
						}
					}
				}
			}
		}

		System.out.println(count);
	}
}

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

int A, B, C, D;

int main () {
	cin >> A >> B >> C >> D;
	if (A*B==C*D) {
		cout << A*B << endl;
	} else if (A*B>C*D) {
		cout << A*B << endl;
	} else {
		cout << C*D << endl;
	}
}


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

int main(){
  ll A, B, C, K;
  cin >> A >> B >> C >> K;
  ll max = 0;
  if(A >= K){
    max = K;
    cout << max << endl;
    return 0;
  }
  if(A + B >= K){
    max = A;
    cout << max << endl;
    return 0;
  }
  ll count = A + B;
  max = A;
  //cout << count << endl;
  while(count != K){
    count ++;
    max --;
    //cout << count << endl;
  }
  cout << max << endl;
  
}

Measured memory_bytes: 3628
#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 <unordered_map>
#include <set>
#include <deque>

long long mod = 1e9+7;
class Mint {
public:
  long long x;
  Mint(){}; // 引数なしでも定義できるように引数なしコンストラクタも用意しておく
  Mint(long long a){
    x = a%mod;
    while(x<0){
      x += mod;
    }
  };
  Mint& operator += (const Mint &a){
    x+=a.x;
    x%=mod;
    return *this;
  }
  Mint& operator -= (const Mint &a){
    x += (mod - a.x);
    x%=mod;
    return *this;
  }
  Mint& operator *= (const Mint &a){
    x*=a.x;
    x%=mod;
    return *this;
  }

  // a^n mod を計算する
  // Useaeg: Mint z = y.pow(y, n);
  Mint pow(Mint a, long long n) const {
    Mint y(1);
    Mint b(a);
    while (n > 0) {
      if (n & 1) y *= b;
      b *= b;
      n >>= 1;
    }
    return y;
  }

  // a^{-1} mod を計算する
  Mint modinv(const Mint &a) const {
    return pow(a, mod-2);
  }

  Mint& operator /= (const Mint &a) {
    x *= modinv(a).x;
    x %= mod;
    return *this;
  }

  Mint operator + (Mint &a) const {
    Mint y(*this);
    y += a;
    return y;
  }

  Mint operator - (Mint &a) const {
    Mint y(*this);
    y -= a;
    return y;
  }

  Mint operator * (Mint &a) const {
    Mint y(*this);
    y *= a;
    return y;
  }

  Mint operator / (Mint &a) const {
    Mint y(*this);
    y/=a;
    return y.x;
  }

  // nCk @mod を計算する
  Mint nCk(Mint &n, const long long k) const {
    Mint y = Mint(1);
    for (Mint i(0); (i.x)<k; i.x++){
      y *= (n-i);
      y /= i;
    }
    return y;
  }

  // nPk @mod を計算する
  Mint nPk(Mint &n, long long k) const {
    Mint y(1);
    for (Mint i(0); (i.x)<k; i.x++){
      y *= (n-i);
    }
    return y;
  }
};

int main(){
  std::vector<long long > power2;
  long long multiple = 1;
  while(multiple<1e16){
    power2.push_back(multiple);
    multiple *= 2;
  }
  int N;
  std::cin >> N;
  std::vector<long long > A(N);
  std::multiset<long long > st;
  std::vector<bool > used(N+4, false);
  for (int i=0; i<N; i++){
    std::cin >> A[i];
    st.insert(A[i]);
  }
  //std::sort(A.begin(), A.end());
  int ans = 0;
  //std::reverse(st.begin(), st.end());
  while(st.size()>1){
    auto stritr = st.end();
    stritr--;
    long long value = *(stritr);
    st.erase(stritr);
    auto itr2 = std::upper_bound(power2.begin(), power2.end(), value);
    long long target = *itr2;
    long long need = target - value;
    auto itr = st.lower_bound(need);
    if (itr!=st.end() && *itr==need){
      ans++;
      st.erase(itr);
    }
  }
  std::cout << ans << std::endl;
  return 0;
}

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

typedef long long ll;
vector<vector<int> > v(100007);
int n;
ll mod = 1e9+7;
ll dp[100007][2];
/*int answer(int a, int curr, vector<int> color){
	if(v[a].size() == 0) {return 1;}
	if(v[a].size() == 1 && color[v[a][0]] != -1) return 1;
	if(dp[a][curr] != -1){return dp[a][curr];}
	//if(dp[a] != -1) return dp[a];
	int ans = 1;
	//cout << "vertex " << a << " color : " << curr << endl;
	color[a] = 1;
	for(auto x : v[a]){
		if(color[x] == -1){
			color[x] = 1;
			if(curr == 0){
				ans *= (answer(x, 0, color) + answer(x, 1, color))%mod;
				ans %= mod;
			//	cout << ans << a << curr << endl;
			}
			else  {ans *= answer(x, 0, color); ans %= mod;}// cout << ans << a << curr << endl;}
		}
	}
	return dp[a][curr] = ans;
}
*/
ll answer1(int a, int curr, int par){
	//if(v[a].size() == 0) {return 1;}
	ll &ans = dp[a][curr];
	//if(v[a].size() == 1 && color[v[a][0]] ) return 1;
	if(ans != -1){return ans;}
	//if(dp[a] != -1) return dp[a];
	ans = 1;
	//cout << "vertex " << a << " color : " << curr << endl;
	//color[a] = 1;
	for(auto x : v[a]){
		if(x != par){
			//color[x] = 1;
			if(curr == 0){
				ans = (ans * ((answer1(x, 0, a) + answer1(x, 1, a))%mod))%mod;
				ans %= mod;
			//	cout << ans << a << curr << endl;
			}
			else  {ans *= answer1(x, 0, a); ans %= mod;}// cout << ans << a << curr << endl;}
			ans %= mod;
		}
	}
	return ans;
}
int main(){
	cin >> n;
	int a, b;
	vector<int>color(n+1, -1);
	memset(dp, -1, sizeof(dp));
	//memset(color, -1, sizeof(color));
	for(int i=1; i<=n-1; i++){
		cin >> a >> b;
		v[a].push_back(b);
		v[b].push_back(a);
	}
//cout << answer(1, 0, color) + answer(1, 1, color) << endl;
	ll ans = (answer1(1, 0, 0) + answer1(1, 1, 0)) % mod;
	cout << ans;
	return 0;
}



Measured memory_bytes: 17408
n,l=map(int,raw_input().split())
a=map(int,raw_input().split())
ans=[]
f=-1
for i in range(n-1):
    if a[i]+a[i+1]>=l:
        f=i
        break
if f==-1:
    print 'Impossible'
else:
    print 'Possible'
    for i in range(f):
        print i+1
    for i in range(n-1,f,-1):
        print i

Measured memory_bytes: 11340
#include<bits/stdc++.h>
#define vi vector<int>
#define vvi vector<vector<int> >
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vectors<decltype(inner)>(x, inner); }
using ll = long long;
using ld =long double;
#define int ll
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
int dx[]={0,0,1,-1};
int dy[]={1,-1,0,0};
int W,H;
bool inrange(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
using namespace std;
typedef pair<int, int> pii;
typedef pair<int,pii> piii;
#define MP make_pair
signed main(){
	int n;
	while(cin >> n,n){
		vector<vector<int>>dp(n,vector<int>(n,0));
		vector<int>array(n);
		rep(i,n) cin >> array[i];
		loop(k,2,n + 1)rep(i,n){
			int j = i + k - 1;
			if(j>=n)continue;
			if((abs(array[i]-array[j])<=1 && dp[i+1][j-1] + 2 == k)){
				dp[i][j] = k;
			}
			for(int l = i; l<j;l++){
				cmax(dp[i][j],dp[i][l] + dp[l+1][j]);
			}
		}
		cout << dp[0][n - 1] << endl;
	}
}



Measured memory_bytes: 3596