akhauriyash/Code-Regression huggingface dataset:
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr=input.trim().split("\n");
while(true){
   var n=arr.shift()-0;
   if(n===0)break;
   var tv=[];
   for(var i=0;i<30;i++)tv[i]=0;
   var obj={};
   for(var i=0;i<n;i++){
      var ary=arr.shift().split(" ");
      var name=ary.shift();
      ary.shift();
      obj[name]=ary.map(Number);
      ary.forEach(function(v){tv[v]++;});
   }
   var ans=[];
   for(var k in obj){
      var sum=0;
      obj[k].forEach(function(v){
         sum+=(n+1)-tv[v];
      });
      ans.push([sum,k]);
   }
   ans.sort(function(a,b){
      if(a[0]==b[0])return a[1]>b[1];
      else return a[0]-b[0];
   });
   console.log(ans[0][0]+" "+ans[0][1]);
}

Measured memory_bytes: 17840
import sys
import os

N, L = map(int,input().split())
A = list(map(int,input().split()))
for i in range(N-1):
    if A[i] + A[i+1] >= L:
        print("Possible")
        for j in range(i):
            print(j+1)
        for j in range(N-1,i,-1):
            print(j)
        sys.exit()
print("Impossible")


Measured memory_bytes: 14432
#include <stdio.h>
#include <algorithm>
#include <map>

using namespace std;

#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
	
struct Node{
	Node *l,*r,*p;
	int s,v,m;
	Node():l(NULL),r(NULL),p(NULL){}
	static inline int Size(Node* x){
		return x?x->s:0;
	}
	static inline int Mini(Node* x){
		return x?x->m:1145141919;
	}
	inline Node* Update(){
		s=1+Size(l)+Size(r);
		m=min({v,Mini(l),Mini(r)});
		return this;
	}
	inline int Pos(){
		if(p&&p->l==this) return -1;
		if(p&&p->r==this) return 1;
		return 0;
	}
	void Rotate(){
		Node *q=p,*c;
		if(Pos()==1){
			c=l;
			l=p;
			p->r=c;
		}else{
			c=r;
			r=p;
			p->l=c;
		}
		if(c) c->p=p;
		p=p->p;
		q->p=this;
		if(p&&p->l==q) p->l=this;
		if(p&&p->r==q) p->r=this;
		q->Update();
	}
	Node* Splay(){
		while(p){
			int a=Pos(),b=p->Pos();
			if(b&&a==b) p->Rotate();
			if(b&&a!=b) Rotate();
			Rotate();
		}
		return Update();
	}
	Node* Idx(int i){
		if(i<Size(l)) return l->Idx(i);
		else if(i>Size(l)) return r->Idx(i-Size(l)-1);
		return Splay();
	}
} d[200000];

pair<Node*,Node*> Split(Node* x,int i){
	if(i<0) return MP((Node*)NULL,x);
	x=x->Idx(i);
	Node* c=x->r;
	if(c) c->p=NULL;
	x->r=NULL;
	return MP(x->Update(),c);
}

Node* Merge(Node* a,Node* b){
	if(!a||!b) return a?a:b;
	while(a->r) a=a->r;
	b->p=a->Splay();
	a->r=b;
	return a->Update();
}

int main(){
	int n,q;
	scanf("%d%d",&n,&q);
	Node* w=NULL;
	REP(i,n){
		scanf("%d",&d[i].v);
		w=Merge(w,d[i].Update());
	}
	REP(_,q){
		int x,y,z;
		scanf("%d%d%d",&x,&y,&z);
		if(x==0){
			auto r=Split(w,z);
			auto q=Split(r.first,z-1);
			auto p=Split(q.first,y-1);
			w=Merge(Merge(p.first,q.second),Merge(p.second,r.second));
		}else if(x==1){
			auto q=Split(w,z);
			auto p=Split(q.first,y-1);
			printf("%d\n",p.second->m);
			w=Merge(Merge(p.first,p.second),q.second);
		}else{
			w=w->Idx(y);
			w->v=z;
			w->Update();
		}
	}
}

Measured memory_bytes: 10560
import sys
import math
import bisect

def solve(a, b, k):
    ans = []
    for i in range(k):
        if a + i <= b:
            ans.append(a + i)
        if b - i >= a:
            ans.append(b - i)
    ans = sorted(set(ans))
    return ans

def main():
    a, b, k = map(int, input().split())
    for a in solve(a, b, k):
        print(a)

if __name__ == "__main__":
    main()


Measured memory_bytes: 38256
s = list(input())

bl = False
s1 = s[1]
s2 = s[2:len(s)-1]
s3 = s[-1]

if s[0] == 'A' and s[2:len(s)-1].count('C') == 1:
    s2.remove('C')
    s2 = ''.join(s2)
    ss = s1+s2+s3
    if ss.islower():
        bl = True

print('AC' if bl else 'WA')


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

typedef long long ll;

int main()
{
    int N;
    int A[10005], B[10005];
    int sa[10005];
    ll add = 0, sub = 0;

    cin >> N;
    for(int i = 0; i < N; i++) cin >> A[i];
    for(int i = 0; i < N; i++) {
        int B;
        cin >> B;
        if(B > A[i]) add += (B - A[i]) / 2;
        if(A[i] > B) sub += A[i] - B;
    }
    if(add >= sub) cout << "Yes" << endl;
    else cout << "No" << endl;

    return (0);
}


Measured memory_bytes: 256
import Control.Monad
import Data.Maybe
import Debug.Trace
import Data.List
import qualified Data.Map.Strict as Map
import qualified Data.IntMap.Strict as IntMap
import qualified Data.Set as Set
import qualified Data.IntSet as IntSet

main :: IO ()
main = do
  (n:m:_) <- fmap (map read . words) getLine :: IO [Int]
  s <- getLine :: IO String
  t <- getLine :: IO String
  print $ solve n m s t

solve :: Int -> Int -> String -> String -> Int
solve n m s t = if check then l else (-1)
  where
    l = lcm n m
    check = all id $ Map.intersectionWith (==) smap tmap
    ss = map (+1) . map (l `div` n *) $ [0..(n-1)]
    ts = map (+1) . map (l `div` m *) $ [0..(m-1)]
    smap = Map.fromList $ zip ss s :: Map.Map Int Char
    tmap = Map.fromList $ zip ts t


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

int N, M;
vector<vector<bool>> g;
vector<bool> vertex;
int ans;

void Dfs(int v) {
  vertex[v] = true;

  int visit = 0;
  for (int i = 0; i < N; ++i)
    visit += vertex[i];
  if (visit == N)
    ++ans;

  for (int i = 0; i < N; ++i)
    if (!vertex[i] && g[v][i])
      Dfs(i);

  vertex[v] = false;
}

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

  g.resize(N, vector<bool>(N));
  for (int i = 0; i < M; ++i)
    g[a[i] - 1][b[i] - 1] = true, g[b[i] - 1][a[i] - 1] = true;

  vertex.resize(N);
  Dfs(0);
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,ans;
string s;
bool check(int x){
    if(x==0)
        return true;
        map<string,int> L,R,m;
    for(int k=0;k<s.size()-x+1;k++){
       string  a=s.substr(k,x);
     if(m[a]==0){
       L[a]=k;
       R[a]=k;
       m[a]=1;
    }
    else{
    L[a]=min(L[a],k);
    R[a]=max(R[a],k);
    m[a]=1;
    }
    if(L[a]+a.size()-1<R[a])
   return true;
    }
return false;
}
int main(){
cin>>n>>s;
int l=0,r=s.size();
while(r-l>1){
   int mid=(l+r)/2;
   if(check(mid))
    l=mid;
   else r=mid;
}
if(check(r))
    cout<<r;
else cout<<l;

return 0;
}


Measured memory_bytes: 6936
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define fr(i,s,e) for(i=s;i<e;i++)
#define rf(i,s,e) for(i=s-1;i>=e;i--)
#define pb push_back
#define mp make_pair
 
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<pair<long long,long long> > vpll;
typedef vector<vector<ll> > vvll;
 
#define PI 3.141592653589793
#define MOD 1000000007
 
int main()
{
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    if(k<=a)
    {
    	cout<<k;
	}
	else if(k<=(a+b))
	{
		cout<<a;
	}
	else
	{
		cout<<a-(k-(a+b));
	}
    
	return 0;
}

Measured memory_bytes: 3584
#include<iostream>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<map>
#include<utility>
#include<cmath>
#include<tuple>
#include<string>
#include<bitset>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
using namespace std;
typedef long long ll;

int main(){
    string s; cin>>s;
    if(s[2]==s[3]&&s[4]==s[5]) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

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

int main(){
    long long N, K, R, S, P;
    string T;
    cin >> N >> K;
    cin >> R >> S >> P;
    cin >> T;

    long long ans=0;
    vector<long long> seq(N,0ll);
    string U( N, 'a' );
    char UK='a';

    vector < pair <long long, char> > p;
    p.push_back(make_pair(R,'r'));
    p.push_back(make_pair(S,'s'));
    p.push_back(make_pair(P,'p'));
    sort(p.begin(),p.end());

    vector < pair <char, char> > y_i0;
    y_i0.push_back(make_pair('r','p'));
    y_i0.push_back(make_pair('s','r'));
    y_i0.push_back(make_pair('p','s'));

    vector < pair <char, char> > y_i;    

    for(int i=0; i<3; i++){
        for(int j=0; j<3; j++){
            if( p[i].second == y_i0[j].second ){
                y_i.push_back(y_i0[j]);
            }
        }
    }    

    for(long long i=0; i<N; i++){
        if(i>=K){
            UK=U[i-K];
        }

        for( long long j=0; j<3; j++ ){
            if(T[i]==y_i[j].first){
                ans += p[j].first;
                U[i] = p[j].second;
                if( UK==U[i] ){
                    if(i-K>0){
                        seq[i]=seq[i-K]+1;
                    }else{
                        seq[i]++;
                    }
                }
                if( K+i > N || T[K+i]!=y_i[j].first ){
                    ans -= p[j].first * (long long) (( seq[i] + 1 )/2);
                }
            }
        }

        //cout << "i U[i] seq[i] ans " << i << " " << U[i] << " " << seq[i] << " " << ans << endl;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1280
def main():
    N = int(input())
    money = [input().split() for i in range(N)]
    total = 0
    for i in range(N):
        [x, u] = money[i]
        if u == "JPY":
            total += float(x)
        else:
            total += float(x)*380000.0
    print(total)
main()

Measured memory_bytes: 2940
length = int(input())
list_input = list(map(int, input().split()))

list_invert_str = ''
for i in range(length-1, -1, -1):
    item = list_input[i]
    list_invert_str += str(item)
    if i > 0:
        list_invert_str += ' '
        
print(list_invert_str)


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

typedef long long ll;
using namespace std;
int main()
{
	int N, K, X, Y;
	cin >> N >> K >> X >> Y;
	if (N > K) {
		cout << K * X + (N-K) * Y << endl;
	}
	if (N <= K) {
		cout << N * X << endl;
	}
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner kb = new Scanner(System.in);
		int n = kb.nextInt();
		int m = kb.nextInt();
		int p = m;
		int[] a = new int[n];
		int count = 0;
		for (int i = 0; i < n; i++) {
			int j = kb.nextInt();
			count += j;
			a[i] = j;
		}
		for (int b : a) {
			if (count / (4.0 * m) <= b) {
				p -= 1;
			}
		}
		if (p <= 0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

		kb.close();
	}
}


Measured memory_bytes: 21844
x, y = gets.split.map(&:to_i)

if [1, 3, 5, 7, 8, 10, 12].find {|n| n == x} != nil
  if [1, 3, 5, 7, 8, 10, 12].find {|n| n == y} != nil
    puts 'Yes'
  else
    puts 'No'
  end
elsif [4, 6, 9, 11].find {|n| n == x} != nil
  if [4, 6, 9, 11].find {|n| n == y} != nil
    puts 'Yes'
  elsif
    puts 'No'
  end
else
  puts 'No'
end


Measured memory_bytes: 1788
#include <bits/stdc++.h>                         
using namespace std;                             
int main(void){                                  
  int n,q,count = 0,ans;                         
  bool a = false;                                
  string s;                                      
  cin >> n >> q;                                 
  cin >> s;                                      
  int l[q],r[q];                                 
  int ac[n+1];                                   
  for(int i = 0; i < q;++i){                     
    cin >> l[i] >> r[i];                         
  }                                              
  ac[0] = 0;                                     
  for(int i = 0;i < n;++i){                      
    if(s[i] == 'A' && s[i+1] == 'C'){            
      count++;                                   
    }                                            
    ac[i+1] = count;                             
  }                                              
  for(int i = 0; i < q;++i){                     
    cout << ac[r[i]-1] -ac[l[i]-1] << endl;      
  }                                              
  return 0;                                      
}                                                
                                                 
                                                 
                                                 

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

using namespace std;
int main()
{
    int n, m;
    cin >> n >> m;
    vector<vector<int>>s(m);
    for(auto i = 0; i < m; ++i){
        int k;
        cin >> k;
        s[i].resize(k);
        for(auto & in : s[i]){
            cin >> in;
        }
    }
    vector<int>p(m);
    for(auto & in : p){
        cin >> in;
    }
    
    vector<vector<int>> pattern(1 << n);
    for(auto i = 0; i < (1 << n); ++i){
        for(auto j = 0; j < n; ++j){
            if(i&(1 << j)){
                pattern[i].push_back(1);
            } else {
                pattern[i].push_back(0);
            }
        }
    }
    
    int ans = 0;
    for(auto i = 0; i < (1 << n); ++i){
        int c = 0;
        for(auto j = 0; j < m; ++j){
            int nswon = 0;
            for(const auto &x : s[j]){
                if(pattern[i][x-1] == 1){
                    nswon++;
                }
            }
            if(nswon % 2 == p[j]){
                c++;
            }
        }
        if(c == m){
            ans++;
        }
    }
    cout << ans;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define REPA(x, v) for(auto&& x:v)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(v.rbegin(),v.rend())
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> void pr_vec(vector<T> &v, char ep=' '){int n=v.size();REP(ni,n){cout<<v[ni];if(ni!=n-1)cout<<ep;}cout<<endl;};
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    
    ll ans = max({a*c, a*d, b*c, b*d});
    pr(ans);

}

Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>

using namespace std;

const int maxn=500005;
typedef long long ll;

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

int n;
char s[maxn];

ll R[maxn],G[maxn],B[maxn];

ll ans;
char opt;

int main()
{
	cin>>n;
	for(int i=1;i<=n;i++) cin>>s[i];
	for(int i=1;i<=n;i++)
	{
		R[i]=R[i-1]; G[i]=G[i-1]; B[i]=B[i-1];
		if(s[i]=='R') R[i]++;
		if(s[i]=='G') G[i]++;
		if(s[i]=='B') B[i]++;
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=i+1;j<=n;j++)
		{
			if(s[i]==s[j]) continue;
			if(s[i]=='R' && s[j]=='G') opt='B';
			if(s[i]=='R' && s[j]=='B') opt='G';
			if(s[i]=='B' && s[j]=='G') opt='R';
			if(s[i]=='B' && s[j]=='R') opt='G';
			if(s[i]=='G' && s[j]=='R') opt='B';
			if(s[i]=='G' && s[j]=='B') opt='R';
			if(opt=='B') ans+=(B[n]-B[j]);
			if(opt=='G') ans+=(G[n]-G[j]);
			if(opt=='R') ans+=(R[n]-R[j]);
			if(j+(j-i)<=n && opt==s[j+(j-i)]) ans--;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3680
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()
/*
	http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1244

	Source: ACM International Collegiate Programming Contest,
	Asia Regional Aizu, Aizu, Japan, 2003-11-02 

	http://web-ext.u-aizu.ac.jp/conference/ACM/

	構文解析
	
	<term>::=<atom>|<atom><number>|'('<formula>')'<number>
	<formula>::=<term>|<term><formula>
*/

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

map<string, int> table;
int idx;
string s;
bool ok;

#define ASRT if (!ok ) return 0;

int formula(void );

int atom (void ){
	string atom = "";
	if (isupper(s[idx] ) || (idx + 1 < s.size() && islower(s[idx+1] ) ) ){
		if (!islower(s[idx+1] ) ){
			atom += s[idx++];
		}else{
			atom += s[idx++];
			atom += s[idx++];
		} // end if			
	} // end if
	
	if (table.count (atom ) ){
		return table[atom];
	} // end if
	ok = false;

	return 0;
}

int number (void ){
	int res = 0;
	while (isdigit (s[idx] ) ){ res = 10*res + (int)(s[idx++] - '0' ); }

	return res;
}

int term (void ){
	int res = 0;
	if (isalpha (s[idx] ) ){
		res = atom(); ASRT;
		if (isdigit (s[idx] ) ){
			int n = number ();
			res *= n;
		} // end if
	}else
	if (s[idx] == '(' ){
		idx++;
		res = formula (); ASRT;
		idx++; // omit ')';
	}// end if

	if (isdigit(s[idx] ) ){
		int n = number();
		res *= n;
	} // end if

	return res;
}

int formula (void ){
	int res = term(); ASRT;
	while (idx < s.size() && s[idx] != ')' ){
		res += term (); ASRT;
	} // end while

	return res;
}

int parse (string str ){
	s = str;
	idx = 0;
	ok = true;

	int res = formula();

	return (ok ? res : -1 ); 
}

int main()
{
	ios_base::sync_with_stdio(0);
	string str = "";
	table.clear();
	while (getline (cin, str ), str != "END_OF_FIRST_PART" ){
		stringstream ss (str );
		string atom; int wight;
		ss >> atom >> wight;
		table[atom] = wight;
	} // end while

	while (cin >> str, str != "0" ){
		int res = parse (str );
		if (res == -1 ){
			cout << "UNKNOWN" << endl;
		}else{
			cout << res << endl;
		} // end if
	} // end while

	return 0;
}

Measured memory_bytes: 1248
#include<bits/stdc++.h>
#define DIST(x1,x2, y1, y2) (((x1-x2)*(x1-x2))+((y1-y2)*(y1-y2)))
#define DIST3D(x1,x2, y1, y2, z1, z2) (((x1-x2)*(x1-x2))+((y1-y2)*(y1-y2)) + ((z1-z2)*(z1-z2)))
#define CLR(a) a.clear()
#define VCLR(a, n) for(int i=0; i<=n+3; i++) a[i].clear()
#define SIZE(a) a.size()
#define ERASE(a, b) memset(a, b, sizeof a)
#define PB(a, b) a.push_back(b)
#define PB2(a,i,b) a[i].push_back(b)
#define LL long long
#define ULL unsigned long long
#define DBG cout<<"I Am Here"<<endl
#define DBGA(a) cout<<a<<endl
#define DBGI(b,a) cout<<b<<' '<<a<<endl
#define DBGL(i,s,e,b) or(int i=s; i<=e; i++) cout<<b<<endl
#define INF 1e9
#define INV 1e-6
#define sll(a) scanf("%I64d", &a)
#define pll(a) printf("%I64d\n", a)
#define si(a) scanf("%d", &a)
#define pii pair<LL,LL>
#define MAX 100006
#define CASE(i) printf("Case %d: ", i);
#define CSH(i) printf("Case #%d: ", i);
#define PI acos(-1)
#define piis pair<int, string>
#define fast1 ios_base::sync_with_stdio(false);
#define fast2 cin.tie(0)
#define CHECK_BIT(var,pos) ((var & (1 << pos)) == (1 << pos))


LL MOD = 1000000007;

using namespace std;

LL bigmod(LL b, LL p, LL m)
{
    if(p==0)  return 1;
    if(p%2==0)
    {
        LL x = bigmod(b,p/2,m);
        return (x%m * x%m)%m;
    }
    else return ((b%m)*bigmod(b,p-1,m)%m)%m;
}


LL MODINVERSE(LL a)
{
    return bigmod(a, MOD-2, MOD);
}

int arr[29][100005];

int main()
{
    char str[100005];
    scanf("%s", str);
    int len = strlen(str);

    int one = -1, two = -1;
    bool flag = false;
    for(int i=1; i<len; i++)
    {
        if(str[i]==str[i-1]){
            one = i-1, two = i;
            flag = true;
            break;
        }
        if(i>=2){
            if(str[i]==str[i-2]){
                one = i-2, two = i;
                flag = true;
                break;
            }
        }
    }

    if(flag)
        printf("%d %d", one+1, two+1);
    else
        printf("-1 -1");
}



Measured memory_bytes: 384
#!/usr/bin/perl -w

chomp($s=<>);
$a[1]=$s;
for($i=2;;$i++){
    if($a[$i-1]%2==0){
        $m=$a[$i-1]/2;
    }else{
        $m=3*$a[$i-1]+1;
    }
    for($k=1;$k<@a;$k++){
        if($m==$a[$k]){
            print $i;
            exit;
        }

    }
    $a[$i]=$m;
}

Measured memory_bytes: 512
size = int(input())
arr = [str(input()) for i in range(size)]
x = arr.count("AC")
y = arr.count("WA")
z = arr.count("TLE")
w = arr.count("RE")
print("AC x ",x)
print("WA x ",y)
print("TLE x ",z)
print("RE x ",w)

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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    ll n, k, s; cin >> n >> k >> s;

    if (s < 1000000000) {
        for (ll i = 0; i < k; ++i) {
            cout << s << ' ';
        }

        for (ll i = k; i < n; ++i) {
            cout << 1000000000 << ' ';
        }
    } else {
        for (ll i = 0; i < k; ++i) {
            cout << s << ' ';
        }

        for (ll i = k; i < n; ++i) {
            cout << 1 << ' ';
        }
    }
}

Measured memory_bytes: 1280
import java.util.*;
import java.io.*;

class Main{
    static long MOD=1_000_000_007;
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        long n=sc.nextLong(), m=sc.nextLong();
        sc.close();
        System.out.println(solve(n, m));
    }
    public static long solve(long n, long m){
        if(m>n) return solve(m, n);
        if(n>=m+2) return 0;
        long ans=1l;
        for(long i=1;i<=m;i++){
            ans*=i;
            ans%=MOD;
            ans*=i;
            ans%=MOD;
        }
        if(n!=m) ans*=n;
        else ans*=2;
        ans%=MOD;
        return ans;
    }
}


Measured memory_bytes: 22868
MOD = 1000000007


def mod_inv(mod, a):
    old_t, t = 0, 1
    old_r, r = mod, a

    while r != 0:
        quotient = old_r // r

        old_r, r = r, old_r - quotient * r
        old_t, t = t, old_t - quotient * t

    return old_t % mod


def combine(n, k, mod):
    if k > n // 2:
        k = n - k
    u = 1
    for i in range(n - k + 1, n + 1):
        u = u * i % mod

    v = 1
    for i in range(1, k + 1):
        v = v * i % mod

    return u * mod_inv(mod, v) % MOD


def main():
    X, Y = map(int, input().split())
    m1 = X + Y
    if m1 % 3 == 0:
        m = m1 // 3
        if X < m or Y < m:
            print(0)
        else:
            print(combine(m, X - m, MOD))
    else:
        print(0)


if __name__ == '__main__':
    main()


Measured memory_bytes: 8904
#include<stdio.h>
int main(void){
	int a,b,c;
	int x=0;
	scanf("%d %d %d",&a,&b,&c);
	if(a<1||b<1||c>10000){
		printf("error\n");
		return 0;
	}else {
		for(int i=a;i<=b;i++){
			if(c%i==0) x++;
		}
		printf("%d\n",x);
		return 0;
	}
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define dep(i,a,b) for(int i=a;i>=b;i--)
#define ll long long
#define mem(x,num) memset(x,num,sizeof x)
#define reg(i,x) for(int i=last[x];i;i=e[i].next)
using namespace std;
inline ll read(){
    ll f=1,x=0;char ch=getchar();
    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;
}
//******head by yjjr******
const int maxn=2e5+6;
ll a[maxn],n,m,ans=1e18;
inline bool check(int x){
    ll re=0;
    for(int l=x+1,r=n;l<r;l++,r--){
        if(a[l]+a[r]<m)return 0;
        re=max(re,a[l]+a[r]-m);
    }
    for(int l=1,r=x;l<r;l++,r--)re=max(re,a[l]+a[r]);
    ans=min(ans,re);
    return 1;
}
int main(){
    n=read(),m=read();
    n=n*2;
    rep(i,1,n)a[i]=read();
    sort(a+1,a+1+n);
    int l=0,r=n;
    while(l<r){
        int mid=(l+r)>>1;
        if((n-mid)&1)mid--;
        if(check(mid))r=mid;else l=mid+2;
    }
    check(l);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define step(i, s, n, d) for(int i=s; i<n; i+=d)
#define FOR(i,s,n) step(i,s,n,1)
#define rep(i,n) FOR(i,0,n)
#define ll long long
typedef pair<int, int> P;

int main(){
  string n; int res = 0;
  cin >> n;
  rep(i, n.length()) {
    if (n[i] == '2') {
      res += 1;
    }
  }
  cout << res << endl;
}


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

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)

using namespace std;

int main(){
  while(true){
    stringstream ss;
    string tmp;

    if(!getline(cin, tmp)) break;
    ss << tmp;
    while(true){
      getline(cin, tmp);
      if(tmp == "") break;
      ss << tmp;
    }

    string str = ss.str();
    if(str.size() == 0) break;
    string key; getline(cin, key);

    vector<vector<int> > v(128);
    vector<bool> f(128, false);

    FOR(it, key) f[*it] = true;
    REP(i, str.size()){
      if(f[str[i]]){
	v[str[i]].push_back(i);
      }
    }

    int start = 0;
    int end   = str.size();
    int cnt   = 0;

    REP(i, str.size()){
      if(f[str[i]]){
	int e = i + 1;
	FOR(it, key) if(*it != str[i]){
	  vector<int>::iterator it2 =
	    lower_bound(v[*it].begin(), v[*it].end(), i + 1);

	  if(it2 == v[*it].end()) goto next;
	  e = max(e, *it2 + 1);
	}

	if(end - start > e - i){
	  start = i;
	  end   = e;
	  cnt   = 1;
	}else if(end - start == e - i){
	  cnt++;
	}
      next:;
      }
    }

    if(cnt){
      printf("%d\n\n", cnt);

      for(int i = 0; i + start < end; i++){
	putchar(str[i + start]);
	if(i % 72 == 72 - 1) puts("");
	else if(i + start + 1 == end) puts("");
      }
      puts("");
      
    }else{
      puts("0"); puts("");
    }
  }
  return 0;
}

Measured memory_bytes: 1432
#include<stdio.h>
#define MAX 100005
#define NIL -1

struct Node{ int p, l, r;};
struct Node T[MAX];
int n, H, D[MAX];

void getDepth(int u){
  // if(D[u]!=NIL) return ;
 
  int d = 0;
  if(T[u].r!=NIL){
   
    D[T[u].r]=D[u];
    getDepth(T[u].r);
  }
  if(T[u].l!=NIL){ 
    D[T[u].l]=D[u]+1;
    getDepth(T[u].l);
  }
}

void print(int u){
  printf("node %d: parent = %d, depth = %d,",u,T[u].p,D[u]);
  if(T[u].p==NIL) printf(" root, ");
  else if(T[u].l==NIL) printf(" leaf, ");
  else printf(" internal node, ");
  printf("[");
  int a;
  a=u;
  if(T[a].l!=NIL){ 
    printf("%d",T[a].l);   
    if(T[T[a].l].r==NIL) printf("]\n");
    else printf(", ");
    a=T[a].l;
    while(T[a].r!=NIL){
      printf("%d",T[a].r);
      if(T[T[a].r].r==NIL) printf("]\n");
      else printf(", ");
      a=T[a].r;
    }
  }
  else puts("]");
 
}

main(){
  int i, j, d, v, c, l,r;

  scanf("%d", &n);

  for ( i = 0; i < n; i++ ) {
    T[i].p = T[i].l = T[i].r =D[i]= NIL;
  }

  for ( i = 0; i < n; i++ ){
    scanf("%d %d", &v, &d);
    for ( j = 0; j < d; j++ ){
      scanf("%d", &c);
      T[c].p=v;
      if(j>=1){T[r].r=c;}
      if(j==0){T[v].l=c;}
	r=c;
      }
  }
  

  for ( i = 0; i < n; i++ ){
    if(T[i].p==NIL){D[i]=0; getDepth(i); break;}
  }
  /*

    ...

   */

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

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

#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

#define endl '\n'
#define int long long

const int K = 1e5+5, N = 105;
int dp[K][2], a[N], n, k;

int solve(int cur_stones, int cur_player) {
	int &ans = dp[cur_stones][cur_player];
	if(ans != -1) 
		return ans;
	ans = cur_player ^ 1;
	for(int i = 1; i <= n; i ++) {
		if(cur_stones - a[i] >= 0)
			if(solve(cur_stones - a[i], cur_player ^ 1) == cur_player)
				ans = cur_player;
	}
	return ans;
}

int32_t main()
{
	IOS;

	cin >> n >> k;
	for(int i = 1; i <= n; i ++)
		cin >> a[i];
	memset(dp, -1, sizeof(dp));
	int ans = solve(k, 0);

	if(!ans)	
		cout << "First";
	else 
		cout << "Second";

	return 0;
}


Measured memory_bytes: 6528
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        Integer n = Integer.parseInt(scan.next());
        Integer capasity = Integer.parseInt(scan.next());

        int[] v = new int[n];
        int[] w = new int[n];
        for (int i = 0; i < n; i++) {
            v[i] = Integer.parseInt(scan.next());
            w[i] = Integer.parseInt(scan.next());
        }
        scan.close();

        int[][] dp = new int[n + 1][capasity + 1];

        for (int i = 0; i < n; i++) {
            for (int j = 1; j <= capasity; j++) {
                if (w[i] > j) {
                    dp[i+1][j] = dp[i][j];
                } else {
                    dp[i+1][j] = Math.max(dp[i][j], dp[i][j - w[i]] + v[i]);
                }
            }
        }

        System.out.println(dp[n][capasity]);
    }
}



Measured memory_bytes: 30872
from heapq import heappush,heappop
def main():
    Q=int(input())

    ab_list=[]
    query_type=[]

    for i in range(Q):
        query=list(map(int,input().split()))
        query_type.append(query[0])
        if query[0]==1:
            ab_list.append((query[1],query[2]))

    #query_type->[1,1,2,1,2]
    #ab_list->[(a,b),(a,b),(a,b)]

    L=[]
    R=[]

    ini=0

    counter=0
    ab_pointer=0
    minF=0
    for i in query_type:
        if i==1:
            a_new=ab_list[ab_pointer][0]
            b_new=ab_list[ab_pointer][1]
            heappush(L,-1*a_new)
            heappush(R,a_new)
            Lmax=-1*heappop(L)
            Rmin=heappop(R)
            if Lmax<=Rmin:
                heappush(L,-1*Lmax)
                heappush(R,Rmin)
            else:
                heappush(L,-1*Rmin)
                heappush(R,Lmax)
            delta=abs(Lmax-Rmin)
            minF+=delta+b_new
            ab_pointer+=1
        else:
            minX=-1*heappop(L)
            print(str(minX)+" "+str(minF))
            heappush(L,-1*minX)



if __name__=="__main__":
    main()





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

int main (){
    string s;
    cin >> s;
    int before = s.length()/2;
    for(int i=1;i<before;i++){
        s.pop_back();
        s.pop_back();
        if(s.substr(0,s.length()/2)==s.substr(s.length()/2,s.length()/2)){
            cout << s.length() << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>

using namespace std;

int main()
{
	int n, k;
	while (scanf("%d %d", &n, &k), n || k) {
		int N[100001];

		for (int i = 1; i <= n; ++i) scanf("%d", &N[i]);

		int sum = 0;

		for (int i = 1; i <= k; ++i) sum += N[i];

		int a = sum;

		for (int i = k; i < n; ++i) {
			a += N[i+1] - N[i-k+1];
			sum = sum > a ? sum : a;
		}

		printf("%d\n", sum);
	}
}

Measured memory_bytes: 1420
/*Author - Shubham Gupta (@shubham107)*/
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<ll> vl;		typedef vector<int> vi;
typedef vector<vl> vvl;	  	typedef vector<vi> vvi;
typedef pair<ll, ll> pll;	typedef pair<int, int> pii;
#define forn(i,n) for(int i=0;i<n;i++)
#define rforn(i,n) for(int i=n-1;i>=0;i--)
#define forne(i,n) for(int i=1;i<=n;i++)
#define forse(i,s,e) for(int i=s;i<e;i++)
#define rforse(i,s,e) for(int i=e-1;i>=s;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define MOD 1000000007
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define fill(a,x) memset(a,x,sizeof a);
#define trav(a,x) for(auto &a:x)
#define INF	ll(1e18)
#ifdef SHUBHAM107
#include "../trace.h"
#else
#define trace(args...)
#endif

int add(int a, int b) {int res = a + b;if (res >= MOD)return res - MOD;return res;}
int mul(int a, int b) {long long res = a;res *= b;if (res >= MOD)return res % MOD;return res;}
int sub(int a, int b) {int res = a - b;if(res < 0)return res + MOD;return res;}
int modpow(ll a, ll b) {a %= MOD; int res = 1; while (b) {if (b & 1)res = mul(res, a); a = mul(a, a); b >>= 1;} return res;}
ll bpow(ll a, ll b) {ll res = 1; while (b) {if (b & 1)res = res * a; a = a * a; b >>= 1;} return res;}
int modinv(ll a) {return modpow(a, MOD - 2);}

pll simplify(ll a, ll b){
	ll g = __gcd(a, b);
	if(b > 0 && g < 0) g *= -1;
	if(b < 0 && g > 0) g *= -1;
	a /= g;
	b /= g;
	pll ret = {a, b};
	return ret;
}
void solve() {
	int n;
	cin >> n;
	ll a, b;
	map<pll,int> cnt;
	int ans = 1, x1 = 0, x2 = 0, zeros = 0;
	forn(i, n){
		cin >> a >> b;
		if(a == 0 && b == 0){
			zeros++;
		}else{
			cnt[simplify(a, b)]++;
		}
	}
	int tik = 0;
	trav(elem, cnt){
		x1 = elem.S;
		x2 = cnt[simplify(-elem.F.S, elem.F.F)];
		tik = sub(add(modpow(2, x1), modpow(2, x2)), 1);
		ans = mul(ans, tik);
		cnt.erase(simplify(-elem.F.S, elem.F.F));
	}
	ans = add(ans, zeros);
	ans = sub(ans, 1);
	cout << ans;
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifdef SHUBHAM107
	freopen("inp.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
	freopen("err.txt", "w", stderr);
#endif
	int t = 1;
	// cin >> t;
	while (t--) {
		solve();
	}
}


Measured memory_bytes: 16120
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.Collection;
import java.util.Scanner;
import java.util.Arrays;
import java.util.*;
class  Main{
  public   static  void main(String[]args){
Scanner in =new Scanner(System.in);
int k=in.nextInt();
int a=in.nextInt();
int b=in.nextInt();
int l=(b/k)*k;
if (a<=l) {
  System.out.print("OK ");
} else System.out.print("NG");}}

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

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  
  int a,b,c,d,e,f;
  cin>>a>>b>>c>>d>>e>>f;
  set<int> water,sugar;
  int tmp=0,i=0,j=0;
  int imax=f/(100*a)+1,jmax=f/(100*b)+1;
  for(int i=0;i<=imax;i++){
    for(int j=0;j<=jmax;j++){
      tmp=100*a*i+100*b*j;
      if(tmp<=f)water.insert(tmp);
    }
  }
  tmp=0,i=0,j=0;
  imax=f/c+1,jmax=f/d+1;
  for(int i=0;i<=imax;i++){
    for(int j=0;j<=jmax;j++){
      tmp=c*i+d*j;
      if(tmp<=f)sugar.insert(tmp);
    }
  }
  
  double max_conc=0;
  int ans_sw=0,ans_s=0;
  for(auto w=water.begin();w!=water.end();++w){
    for(auto s=sugar.begin();s!=sugar.end();++s){
      if(*s+*w>f)continue;
      int max_sugar=*w/100*e;
      if(*s>max_sugar)continue;
      
      double conc;
      if((*s)+(*w)==0)conc=0;
      else conc=(double)(100*(*s)/(double)((*s)+(*w)));
      if(max_conc<=conc){
        max_conc=conc;
        ans_sw=*s+(*w);
        ans_s=*s;
      }
    }
  }
  cout<<ans_sw<<" "<<ans_s<<endl;
  
}

Measured memory_bytes: 3764
#include<stdio.h>
int main()
{
	int n,t,c,j,a=10000;

	scanf("%d%d",&n,&t);
	while(n--){
		scanf("%d%d",&c,&j);
		if((j<=t)&&(c<a))
			a=c;
	}
	if(a==10000){
		printf("TLE\n");
		return 0;
	}
	printf("%d",a);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll dp[3000];
int main() {
    // cout<<"Hello World!";
    string s;
    cin>>s;
    ll curr=0,pw=1,ans=0;
    dp[0] = 1;
    // dp[2019] = 0;
    for(int i=s.size()-1;i>=0;i--)
    {
        curr+=pw*(s[i]-'0');
        curr%=2019;
        ans+=dp[curr]++;
        pw*=10;
        pw%=2019;
    }
    cout<<ans;
}


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

typedef long long ll;

int main () {
    string s;
    cin >> s;
    string ans;
    for(auto& e : s) {
	if(e == '1')
	    ans += "1";
	if(e == '0')
	    ans += "0";
	if(e == 'B' and ans.size()>0)
	    ans = ans.substr(0,ans.size()-1);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
// Bubble_Sort.cs

using System;

class Bubble_Sort {
	public static void Main() {

		int count = 0;
		string num = Console.ReadLine();
		int n = int.Parse(num);

		int[] a = new int[n];

		string numbers_str = Console.ReadLine();
		string[] number_str = numbers_str.Split();
		for(int i = 0; i < n; i++) {
			a[i] = int.Parse(number_str[i]);
		}

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

				if(a[i] < a[i - 1]) {
					Swap(ref count,ref a[i], ref a[i - 1]);
				} else {
			
				}

			}
		}

		for(int i = 0; i < n; i++) {
			if(i != n - 1)
			Console.Write(a[i] + " ");
			else
			Console.WriteLine(a[i]);
		}
		Console.WriteLine(count);


	}

	static void Swap(ref int count, ref int x, ref int y) {

		int comp = x;
		x = y;
		y = comp;
		count++;

		return;
	}
}

Measured memory_bytes: 9160
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

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

#define MOD 1000000007

void solve(int test_case) {//228
	int n,m;
	cin>>n>>m;
	vi arr(m+1,0);
	REP(i,1,n) {
		int k;
		cin>>k;
		while(k--) {
			int val;
			cin>>val;
			arr[val]++;
		}
	}
	int cnt=0;
	for(int i:arr) {
		if(i==n)cnt++;
	}
	cout<<cnt;
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3600
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <utility>
#include <numeric>
#include <map>

std::vector<intmax_t> divisor(intmax_t n) {
  std::vector<intmax_t> res;
  for (intmax_t i = 1; i*i <= n; ++i) {
    if (n % i) continue;
    res.push_back(i);
    if (n/i != i) res.push_back(n/i);
  }
  std::sort(res.begin(), res.end());
  return res;
}

template <typename InputIt>
auto compress(InputIt first, InputIt last) {
  using value_type = typename InputIt::value_type;
  std::map<value_type, size_t> res;
  while (first != last) res[*first++];
  size_t i = 0;
  for (auto& p: res) p.second = i++;
  return res;
}

template <typename Tp>
Tp gcd(Tp a, Tp b, Tp& x, Tp& y) {
  x = Tp(0);
  y = Tp(1);
  for (Tp u = y, v = x; a;) {
    Tp q = b/a;
    std::swap(x -= q*u, u);
    std::swap(y -= q*v, v);
    std::swap(b -= q*a, a);
  }
  return b;
}

template <typename Tp>
Tp modinv(Tp a, Tp mod) {
  Tp x, y;
  gcd(a, mod, x, y);
  x %= mod;
  if (x < 0) x += mod;
  return x;
}

template <typename Tp>
Tp modadd(Tp a, Tp b, Tp mod) {
  a += b % mod;
  if (a < 0) a += mod;
  if (a >= mod) a -= mod;
  return a;
}

template <typename Tp>
Tp modadd(std::initializer_list<Tp> const& adds, Tp mod) {
  Tp res = 0;
  for (auto const& add: adds) {
    res += add % mod;
    if (res < 0) res += mod;
    if (res >= mod) res -= mod;
  }
  return res;
}

template <typename Tp>
Tp modsub(Tp a, Tp b, Tp mod) {
  a -= b % mod;
  if (a < 0) a += mod;
  if (a >= mod) a -= mod;
  return a;
}

template <typename Tp>
Tp modmul(std::initializer_list<Tp> const& muls, Tp mod) {
  Tp res = 1;
  for (auto const& mul: muls) (res *= mul) %= mod;
  return res;
}

template <typename Tp>
Tp modpow(Tp base, intmax_t iexp, Tp mod) {
  Tp res = 1;
  for (Tp dbl = base; iexp; iexp >>= 1) {
    if (iexp & 1) res = res * dbl % mod;
    dbl = dbl * dbl % mod;
  }
  return res;
}

constexpr intmax_t  operator ""_jd(unsigned long long n) { return n; }
constexpr uintmax_t operator ""_ju(unsigned long long n) { return n; }
constexpr size_t    operator ""_zu(unsigned long long n) { return n; }
// constexpr ptrdiff_t operator ""_td(unsigned long long n) { return n; }

constexpr intmax_t mod = 1e9+7;

int main() {
  intmax_t n, k;
  scanf("%jd %jd", &n, &k);

  std::vector<intmax_t> ds = divisor(n);
  std::vector<size_t> dp(ds.size());
  intmax_t inv2 = modpow(2_jd, mod-2, mod);
  for (size_t i = 0; i < ds.size(); ++i) {
    intmax_t cur = modpow(k, (ds[i]+1)/2, mod);
    for (size_t j = 0; j < i; ++j) {
      if (ds[i] % ds[j]) continue;
      cur = (cur + mod - dp[j]) % mod;
    }
    dp[i] = cur;
  }

  intmax_t res = 0;
  for (size_t i = 0; i < dp.size(); ++i) {
    intmax_t cur = dp[i];
    (cur *= ds[i]) %= mod;
    if (ds[i] % 2 == 0) (cur *= inv2) %= mod;
    (res += cur) %= mod;
  }
  printf("%jd\n", res);
}


Measured memory_bytes: 256
(* O(2^d d) *)
Scanf.scanf " %d %d" @@ fun d g ->
  let pcs = Array.init d @@ fun _ -> Scanf.scanf " %d %d" @@ fun p c -> p, c in
  let ans = ref max_int in
  let rec find acc rest i bits =
    if rest <= 0 then acc
    else if i < 0 then max_int
    else if bits lsr i land 1 = 1 then find acc rest (i - 1) bits
    else
      let p, _ = pcs.(i) in
      let m = (i + 1) * 100 in
      let n = min (p - 1) @@ (rest + m - 1) / m in
      find (acc + n) (rest - n * m) (i - 1) bits in
  let points = Array.init d @@ fun i -> let p, c = pcs.(i) in p, p * (i + 1) * 100 + c in
  let f bits =
    let c, sum = ref 0, ref 0 in
    for i = 0 to d - 1 do
      if bits lsr i land 1 = 1 then
        let p, s = points.(i) in
        sum := !sum + s;
        c := !c + p;
    done;
    !c, !sum in
  for i = 0 to 1 lsl d - 1 do
    let c, s = f i in
    ans := min !ans @@ find c (g - s) (d - 1) i
  done;
  Printf.printf "%d\n" !ans

Measured memory_bytes: 512
#include<iostream>
#include<complex>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<cstdio>

#define EPS (1e-10)
#define EQ(a,b) (abs((a)-(b)) < EPS)
#define fs first
#define sc second
#define pb push_back
#define sz size()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)

using namespace std;

typedef complex<double> P;
typedef pair<P,P> L;
typedef vector<P> Poly;

//for vector

P norm(P p){return p*P(0,1);}

double dot(P x,P y){return real(conj(x)*y);}

double cross(P x,P y){return imag(conj(x)*y);}

//for line(segment)
int ccw(P a,P b,P c){
  b -= a;c -= a;
  if (cross(b,c)>EPS) return 1;   //counter clockwise
  if (cross(b,c)<-EPS) return -1; //clockwise
  if (dot(b, c)<-EPS) return 2;   //c--a--b on line
  if (abs(b)<abs(c)) return -2;   //a--b--c on line
  return 0;                       //on segment
}

P line_cp(L a,L b){
  return a.fs+(a.sc-a.fs)*cross(b.sc-b.fs,b.fs-a.fs)/cross(b.sc-b.fs,a.sc-a.fs);
}

//for polygon

//all vertex is already sorted.
double area(Poly p){
  if(p.size()<3)return 0;
  double res = cross(p[p.size()-1],p[0]);
  for(int i=1;i<p.size();i++)res += cross(p[i-1],p[i]);
  return res/2;
}

//all vertex is already sorted.
Poly convex_cut(Poly p,L l){
  Poly res;
  int n = p.size();
  for(int i=0;i<n;i++){
    int nxt = (i+1)%n;
    if(ccw(l.fs,l.sc,p[i]) != -1)res.pb(p[i]);
    if(ccw(l.fs,l.sc,p[i]) * ccw(l.fs,l.sc,p[nxt]) < 0){
      res.pb( line_cp(l, L(p[i],p[nxt]) ) );
    }
  }
  return res;
}

int main(){
  double ax,ay,bx,by,cx,cy;
  int cnt = 0;

  while(cin >> ax >> ay >> bx >> by >> cx >> cy,(ax||ay||bx||by||cx||cy)){
    P a = P(ax,ay), b = P(bx,by), c = P(cx,cy);
    Poly p;
    p.pb(P(0,0)); p.pb(P(10000,0)); p.pb(P(10000,10000)); p.pb(P(0,10000));

    P mid = (a+b)/2.0;
    p = convex_cut(p,L(mid,mid+norm(b-a)));
    mid = (a+c)/2.0;
    p = convex_cut(p,L(mid,mid+norm(c-a)));
    printf("%d %.10lf\n",++cnt,area(p)*1e-8);
  }
}

Measured memory_bytes: 1260
#include<iostream>
#include<cmath>
#include<cstdio>
#define S second
#define F first
using namespace std;
typedef pair<double,double> P;

double Length(P p,P q){
  return sqrt(pow(p.first - q.first,2)+pow(p.second-q.second,2));
}

int main(){
  P p[3];
  double a,b,c,A,B,C,R,x,y;
  int n;
  cin >> n;
  while(n-- > 0){ 
    cin >> p[0].first >> p[0].second >> p[1].first >>p[1].second >> p[2].first >> p[2].second;
    a = Length(p[0],p[1]);
    b = Length(p[1],p[2]);
    c = Length(p[2],p[0]);
    A = acos((b*b+c*c-a*a)/(2*b*c));
    B = acos((a*a+c*c-b*b)/(2*a*c));
    C = acos((a*a+b*b-c*c)/(2*a*b));
    R = 0.5 * (a/sin(A));
    //x = 0.5*((((pow(p[0].F,2)+pow(p[0].S,2))*(p[1].S-p[2].S)+((pow(p[1].F,2)+pow(p[1].F,2))*(p[2].S-p[0].S))+((pow(p[2].F,2)+pow(p[2].S,2))*(p[0].S-p[1].S))) )   / (p[0].F*(p[1].S-p[2].S)+p[1].F*(p[2].S-p[0].S)+p[2].F*(p[0].S-p[1].S)));
    x = 0.5*( (pow(p[0].F,2)+pow(p[0].S,2))*(p[1].S-p[2].S) + (pow(p[1].F,2)+pow(p[1].S,2))*(p[2].S-p[0].S) + (pow(p[2].F,2)+pow(p[2].S,2))*(p[0].S-p[1].S)                           )/(       
																							 p[0].F*(p[1].S-p[2].S) + p[1].F*(p[2].S-p[0].S) + p[2].F*(p[0].S-p[1].S)            );

    y = 0.5*((pow(p[0].F,2)+pow(p[0].S,2))*(p[1].F-p[2].F)+(pow(p[1].F,2)+pow(p[1].S,2))*(p[2].F-p[0].F)+(pow(p[2].F,2)+pow(p[2].S,2))*(p[0].F-p[1].F))/(p[0].S*(p[1].F-p[2].F)+p[1].S*(p[2].F-p[0].F)+p[2].S*(p[0].F-p[1].F));

    printf("%.3f %.3f %.3f\n",x,y,R);
  }
  return 0;
}

Measured memory_bytes: 1296
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        
        if( N == 1 ){
            System.out.println( "Hello World" );
        } else if( N == 2 ){
            int A = sc.nextInt();
            int B = sc.nextInt();
            System.out.println( A+B );
        } 
    }
}


Measured memory_bytes: 23124
import math
from sys import exit
a,b,x = map(int, input().split())
j = x/a - a * b / 2
if j == 0:
    print(math.degrees(math.atan(b/a)))
elif j > 0:
    ans = (2*x/(a*a) - 2*b) / (-a)
    print(math.degrees(math.atan(ans)))
else:
    print(math.degrees(math.atan(a*b*b/(2*x))))

Measured memory_bytes: 3188
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
using P=pair<int,int>;
using lint=long long;
using ll=long long;
const lint inf=1e18+7;
const int MOD=1000000007;
signed main(){
  int n,a,b;cin>>n>>a>>b;
  if(n<a+b-1){
    cout<<-1<<endl;
    return 0;
  }
  bool flag=a<b;
  if(flag)swap(a,b);
  if(b<(n-1)/a+1){
    cout<<-1<<endl;
    return 0;
  }
  vector<int> ans(n,-1);
  rep(i,a){
    ans[i]=n-a+i+1;
  }
  queue<int> que;
  int nxt=n-2*a+1;
  while(1){
    if(nxt<=0){
      nxt+=a-1;
      rep1(i,nxt){
        que.push(i);
      }
      goto FINE;
    }
    rep(i,a){
      que.push(nxt+i);
    }
    nxt-=a;
  }
  FINE:
  int cnt=1;
  int cur=0;
  int rem=n-a;
  for(int i=a;i<n;++i){
    if(rem+cnt==b){
      break;
    }
    if(cur==0){
      ++cnt;
    }
    int buf=que.front();que.pop();
    ans[i]=buf;
    ++cur;
    --rem;
    if(cur==a){
      cur=0;
    }
  }
  vector<int> add;
  while(!que.empty()){
    int buf=que.front();que.pop();
    add.push_back(buf);
  }
  sort(add.begin(),add.end());
  reverse(ALL(add));
  int ind=0;
  rep(i,n){
    if(ans[i]==-1){
      //cout<<"hoge"<<endl;
      ans[i]=add[ind];
      ind++;
    }
  }
  cur=min(cur,a-cur);
  rep(i,min(rem,cur)){
    if(rem==0)break;
    swap(ans[n-rem+i],ans[n-rem-1-i]);
  }
  sort(ans.begin()+n-rem,ans.end());
  reverse(ans.begin()+n-rem,ans.end());
  if(flag){
    reverse(ALL(ans));
  }
  for(const auto& val:ans){
    cout<<val<<" ";
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 7028