akhauriyash/Code-Regression huggingface dataset:
N, L = map(int, input().split()) #mapでリストに関数を適用する
A = []#配列用意
for i in range(N):
    A.append(input()) #Nこの文字列を読み込み　行列
A.sort() #ソートする
ans = "" #文字列の変数用意
for i in range(N):
    ans += A[i]#変数に代入していく
print(ans)


Measured memory_bytes: 3060
# -*- coding: utf-8 -*-
import heapq as hq

n = int(input())
v = list(map(int, input().split()))

hq.heapify(v)

while len(v) > 1:
    v1 = hq.heappop(v)
    v2 = hq.heappop(v)
    hq.heappush(v, (v1+v2)/2)

print(hq.heappop(v))


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

using namespace std;

#define ll long long
#define rep(i,n) for(int i=1;i<=(n);i++)
#define rep0(i,n) for(int i=0;i<(n);i++)

const ll INF=1e9+7;
ll l,r;
ll minf=INF;
int main()
{
	/*freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);*/
	cin>>l>>r;
	if(r-l>=2019){
		cout<<0;
		return 0;
	}
	for(ll i=l;i<=r;i++){
		for(ll j=i+1;j<=r;j++){
			ll t=(i*j)%2019;
			minf=min(minf,t);
		}
	}
	cout<<minf;
	return 0;
}

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

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

Measured memory_bytes: 3624
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format, std.datetime;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long N, M;
    scan(N, M);
    writeln(N * (N - 1) / 2 + M * (M - 1) / 2);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)


int main(){
  int N, M, a, b, count;
  vector<int> roads_a, roads_b;
  cin >> N >> M;
  rep(i, M){
    cin >> a >> b;
    roads_a.push_back(a);
    roads_b.push_back(b);
  }
  rep(i, N){
    count = 0;
    rep(j, M){
      if (roads_a.at(j) == i+1) count++;
      if (roads_b.at(j) == i+1) count++;
    }
    cout << count <<endl;
  }      
}
    

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

using namespace std;
#define inputInt(a) int a; cin >> a; 
#define inputInt2(a,b) int a; int b; cin >> a >> b; 
#define inputInt3(a,b,c) int a; int b; int c; cin >> a >> b >> c;
#define inputLong(a) long a;cin >> a; 
#define inputIntArray(a,N) int a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputLongArray(a,N) long a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputIntArray2(a,b,N) int a[N]; int b[N]; for(int i=0;i<N;i++){cin >> a[i] >> b[i];}
#define output(answer) cout << answer << endl;
#define fN(i,N)    for(int i=0; i<N; i++)
#define fSE(i,s,e) for(int i=s; i<=e; i++)
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int LIMIT = 1e6;//1e6→50ms,1e7→500ms,1e8→5000ms程度。
const ll MOD = 1e9+7;
vector<ll> FacMod(LIMIT), InvMod(LIMIT), FacInvMod(LIMIT);
const int dpComTableLIMIT = 3e3+1;
vector<vector<ll>> Com(dpComTableLIMIT,vector<ll>(dpComTableLIMIT,0));

void DPComInit(){
  //Com[0][j]は0で初期化されている。
  for(int i=0; i<dpComTableLIMIT; i++){ Com[i][0] = 1; }
  
  for(int i=1; i<dpComTableLIMIT; i++){
    for(int j=1; j<dpComTableLIMIT; j++){
      Com[i][j] = (Com[i-1][j-1]+Com[i-1][j])%MOD;
    }
  }
}

void ComInit(){//tableを作成
  FacMod[0] = FacMod[1] = 1;
  InvMod[0] = 0; InvMod[1] = 1; //InvMod[0]は定義できない
  FacInvMod[0] = FacInvMod[1] = 1;
  
  for(int i=2; i<LIMIT; i++){
    FacMod[i] = FacMod[i-1]*i%MOD;
    InvMod[i] = -InvMod[MOD%i]*(MOD/i)%MOD + MOD;
    FacInvMod[i] = FacInvMod[i-1] * InvMod[i]%MOD;
  }
}

ll ComMod(int n, int k){
  if(n>=0 && k>=0 && n>=k){
    return FacMod[n]*(FacInvMod[k]*FacInvMod[n-k]%MOD)%MOD;
  }else{
    return 0; //戻り値を0にする方が計算結果に影響が少ない。
  }
}

int main()
{
  //input
  int N, K; cin >> N >> K;
  DPComInit();

  //main
  
  
  // output
  
  for(int i=1; i<=K; i++){
    //青いボールの分け方→K-1個の仕切りの中からi-1個選ぶ。→青いボールがi組できる。
    //ll blue = ComMod(K-1,i-1);
    ll blue = Com[K-1][i-1];
    //青いボールの組を1個の青いボールとみなす。→N-K+1個の箱からi個選ぶ。
    ll red = Com[N-K+1][i];
    cout << red*blue%MOD << endl;
  }
  return 0;
}

Measured memory_bytes: 94208
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
int main()
{
    int a, b, c;
    while(~scanf("%d%d%d", &a, &b, &c))
    {
        printf("%d\n", min(c, b/a));
    }
    return 0;
}

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

typedef long long ll;
const int N = 1e5 + 100;

int n, k, cnt, ans, p = 1;
string s;
vector<int> vec;

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> n >> k >> s;
	cnt = (s[0] == '0');
	for (int i = 0; i < n; i++) {
		if(i && s[i] == '1' && s[i - 1] == '0')
			cnt--;
		while(p < n) {
			if(s[p - 1] == s[p])
				p++;
			else if(s[p] == '1')
				p++;
			else if(cnt < k)
				cnt++, p++;
			else
				break;
		}
		ans = max(ans, p - i);
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 512
N = gets.to_i
 
paths = Hash.new { |h, k| h[k] = {} }
 
(N - 1).times do
  a, b = gets.chomp.split.map(&:to_i)
  paths[a][b] = 1
  paths[b][a] = 1
end
 
cnt = Hash.new(0)
 
queue = []
check_list = Hash.new
queue << [1, 0]
queue << [N, 1]
 
until queue.empty?
  i, color = queue.shift
  next if check_list[i]
  check_list[i] = color
  cnt[color] += 1
 
  paths[i].each_key do |j|
    queue << [j, color]
 end
end
 
if cnt[0] > cnt[1]
  puts 'Fennec'
else
  puts 'Snuke'
end


Measured memory_bytes: 47740
import java.awt.geom.*;
import java.io.*;
import java.math.*;
import java.text.*; 
import java.util.*;
import java.util.regex.*;

/*
		  br = new BufferedReader(new FileReader("input.txt"));
		  pw = new PrintWriter(new BufferedWriter(new FileWriter("output.txt")));
		  br = new BufferedReader(new InputStreamReader(System.in));
		  pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
 */

public class Main {
	private static BufferedReader br;
	private static StringTokenizer st;
	private static PrintWriter pw;

	public static void main(String[] args) throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
		//int qq = 1;
		int qq = Integer.MAX_VALUE;
		//int qq = readInt();
		for(int casenum = 1; casenum <= qq; casenum++) {
			String s = readLine();
			String[] good = new String[] {"dream", "dreamer", "erase", "eraser"};
			boolean[] poss = new boolean[s.length()+1];
			poss[0] = true;
			for(int i = 0; i < s.length(); i++) {
				if(!poss[i]) continue;
				for(String out: good) {
					if(i + out.length() > s.length()) continue;
					int match = 0;
					for(int a = 0; a < out.length(); a++) {
						if(out.charAt(a) == s.charAt(i+a)) {
							match++;
						}
					}
					if(match == out.length()) {
						poss[i+match] = true;
					}
				}
			}
			pw.println(poss[s.length()] ? "YES" : "NO");
		}
		exitImmediately();
	}

	
	private static void exitImmediately() {
		pw.close();
		System.exit(0);
	}

	private static long readLong() throws IOException {
		return Long.parseLong(readToken());
	}

	private static double readDouble() throws IOException {
		return Double.parseDouble(readToken());
	}

	private static int readInt() throws IOException {
		return Integer.parseInt(readToken());
	}

	private static String readLine() throws IOException  {
		String s = br.readLine();
		if(s == null) {
			exitImmediately();
		}
		st = null;
		return s;
	}

	private static String readToken() throws IOException  {
		while(st == null || !st.hasMoreTokens())  {
			st = new StringTokenizer(readLine().trim());
		}
		return st.nextToken();
	}
}

Measured memory_bytes: 23380
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main() {
    int n,m;
    cin >> n >>m;
    vector<int> a(2*m);
    for(int j=0;j<2*m;j++) cin >> a[j];
    for(int i=0;i<n;i++){
        int b=0;    
        for(int j=0;j<2*m;j++){
            if(a.at(j)==i+1){
                b++;
            }
        }
        cout << b <<endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL) ;
#define MOD 1000000007
#define int long long 
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vpii vector<pair<int,int>>
#define ff first
#define ss second
#define INF (1LL<<61)

using namespace std;


int n ;
int com[23][23];
int dp[23][(1<<22)];


int solve(int i , int womSet){
    if(i==n+1){
        if(womSet ==0)return 1;
        return 0;
    }

    if(dp[i][womSet] != -1) return dp[i][womSet];

    int ans =0;

    for(int wom =0 ; wom < n ; wom++ ){
        
        int ava = ((womSet&(1<<wom))==0 )? 0 : 1 ;

        if(ava && com[i][wom+1]){
           ans = (ans + solve(i+1 , womSet^(1<<wom)) )%MOD;
        }
    }

    return dp[i][womSet] =  ans ;
}

int32_t main(){   

fastio
// #ifndef ONLINE_JUDGE
// freopen("input.txt", "r", stdin);
// freopen("output.txt","w", stdout);
// #endif


memset(dp , -1 , sizeof(dp));
cin>>n;
for(int i =1; i<=n ; i++){
    for(int j =1 ; j<=n ; j++)cin>>com[i][j];
}


cout<<solve(1 , ((1<<n) -1));


return 0;
}



Measured memory_bytes: 757300
#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
#include <map>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;

int n, k, ans;
int a[100];
int main() {
	cin >> n >> k;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	sort(a + 1, a + 1 + n);
	reverse(a + 1, a + 1 + n);
	for (int i = 1; i <= k; i++) {
		ans += a[i];
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
def main():
    from itertools import permutations
    import sys
    input=sys.stdin.readline
    n=int(input())
    p=tuple(map(int,input().split()))
    q=tuple(map(int,input().split()))
    
    cnt=1
    for i in permutations(range(1,n+1)):
        if i==p:
            pi=cnt
        if i==q:
            qi=cnt
        cnt+=1
    
    print(abs(pi-qi))
if __name__=='__main__':
    main()

Measured memory_bytes: 3188
#include <iostream>
using namespace std;
int main(void)
{
	int a=0,b=0,s=0,t=0;
	for(int i=0;i<4;i++){
		cin >> a;
		s+=a;
	}
	for(int i=0;i<4;i++){
		cin >> b;
		t+=b;
	}
	if(s<t){
		cout << t << endl;
	}
	else{
		cout << s << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3108
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.*;


public class Main {

    public static void main(String[] args) throws IOException {
        Scanner s = new Scanner(System.in);
        System.out.println((char)(s.next().charAt(0)+1));

    }

}




class Scanner
{
    StringTokenizer st;
    BufferedReader br;

    public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

    public String next() throws IOException
    {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }

    public int nextInt() throws IOException {return Integer.parseInt(next());}

    public long nextLong() throws IOException {return Long.parseLong(next());}

    public String nextLine() throws IOException {return br.readLine();}

    public double nextDouble() throws IOException
    {
        String x = next();
        StringBuilder sb = new StringBuilder("0");
        double res = 0, f = 1;
        boolean dec = false, neg = false;
        int start = 0;
        if(x.charAt(0) == '-')
        {
            neg = true;
            start++;
        }
        for(int i = start; i < x.length(); i++)
            if(x.charAt(i) == '.')
            {
                res = Long.parseLong(sb.toString());
                sb = new StringBuilder("0");
                dec = true;
            }
            else
            {
                sb.append(x.charAt(i));
                if(dec)
                    f *= 10;
            }
        res += Long.parseLong(sb.toString()) / f;
        return res * (neg?-1:1);
    }

    public boolean ready() throws IOException {return br.ready();}


}

Measured memory_bytes: 25340
program sample
    implicit none
  
    integer(8) :: i,j,m,n
    real(8)::a,b
    integer(8),allocatable :: x(:),y(:)
  
    read(*,*) i,j
    do n =10*j,10*j+9
       if (real(i)<= real(n)*0.080_8 ) then
        if  (real(i)+1.0_8 > real(n)*0.080_8 ) then
            write(*,*)n
            stop
        end if
     end if

    end do    
    write(*,*) -1
  
    stop
end program sample
  



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

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

using namespace std;
typedef long long ll;
typedef pair<int, int> pint;

constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;

int main() {
    int n, m; cin >> n >> m;
    vector<int> a(m); rep(i, m) cin >> a[i];

    vector<int> cnt = {-1, 2, 5, 5, 4, 5, 6, 3, 7, 6};

    vector<int> dp(n+10, -INF);
    vector<int> prev(n+10, -1);
    dp[0] = 0;
    rep(i, n) {
        rep(j, m) {
            if ((dp[i+cnt[a[j]]] < dp[i] + 1) || ((dp[i+cnt[a[j]]] == dp[i] + 1) && prev[i+cnt[a[j]]] < a[j])) {
                dp[i+cnt[a[j]]] = dp[i] + 1;
                prev[i+cnt[a[j]]] = a[j];
            }
        }
    }

    vector<int> ans;
    int i = n;
    while (i > 0) {
        int num = prev[i];
        ans.push_back(num);
        i -= cnt[num];
    }
    sort(ans.rbegin(), ans.rend());
    rep(i, ans.size()) {
        cout << ans[i];
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 384
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>

struct Point{
  int x;
  int y;
  int h;
};

bool operator> (const Point &p0, const Point &p1){
  return p0.h > p1.h;
}

bool record(Point *p, std::vector<std::vector<int>> &pyramid, std::queue<Point> *q){
  int x = p->x;
  int y = p->y;
  
  if(x >= 0 && x <= 100 && y >= 0 && y <= 100 && pyramid.at(x).at(y) == -1){
    q->push(*p);
    return true;
  }else{
    return false;
  }
}

bool climb(Point *p, std::vector<std::vector<int>> &pyramid, std::queue<Point> *q){
  bool ret = false;
  Point next;
  
  int x = p->x;
  int y = p->y;
  int h = p->h;
  
  ret = record(&(next = {x + 1, y, h + 1}), pyramid, q)
     | record(&(next = {x, y + 1, h + 1}), pyramid, q)
     | record(&(next = {x - 1, y, h + 1}), pyramid, q)
     | record(&(next = {x, y - 1, h + 1}), pyramid, q);
  
  return ret;
}

Point explore(std::vector<std::vector<int>> &pyramid, std::vector<Point> &points){
  std::priority_queue<Point, std::vector<Point>, std::greater<Point>> unsearched;
  for(Point p : points) unsearched.push(p);
  
  std::queue<Point> q;
  
  q.push(unsearched.top());
  unsearched.pop();
  while(!unsearched.empty() && unsearched.top().h == q.front().h){
    q.push(unsearched.top());
    unsearched.pop();
  }
  
  std::vector<Point> candidates;
  
  while(!q.empty()){
    Point p = q.front();
    q.pop();
    if(pyramid.at(p.x).at(p.y) == -1){
      pyramid.at(p.x).at(p.y) = p.h;
    }else{
      continue;
    }
    
    while(!unsearched.empty() && unsearched.top().h == p.h + 1){
      q.push(unsearched.top());
      unsearched.pop();
    }
    
    if(!climb(&p, pyramid, &q)) candidates.push_back(p);
  }
  
  Point ret;
  for(Point c : candidates){
    bool is_center = true;
    
    for(Point p : points){
      if(c.h != p.h + abs(c.x - p.x) + abs(c.y - p.y) && p.h != 0){
        is_center = false;
        break;
      }
    }
    
    if(is_center){
      ret = c;
      break;
    }
  }
  
  return ret;
}

int main(){
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  
  int n;
  std::cin >> n;
  
  std::vector<std::vector<int>> pyramid(101, std::vector<int>(101, -1));
  std::vector<Point> observation_points(n);
  
  for(int i = 0; i < n; i++){
    int x, y, h;
    std::cin >> x >> y >> h;
    
    observation_points.at(i).x = x;
    observation_points.at(i).y = y;
    observation_points.at(i).h = h;
  }
  
  Point center = explore(pyramid, observation_points);
  std::cout << center.x << ' ' << center.y << ' ' << center.h << std::endl;
  
  return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define mp make_pair
#define ss second
#define ff first
#define ll long long int
#define tcase ll t;cin>>t;while(t--)
#define sz(a) int((a).size())
#define pb push_back
#define present(c,x) (©.find(x) != ©.end())
#define cpresent(c,x) (find(all©,x) != ©.end())
#define YES cout<<"YES\n";
#define NO cout<<"NO\n";
#define Yes cout<<"Yes\n";
#define No cout<<"No\n";
#define f(i,a) for(int i=0;i<a;i++)
#define MAX 500
using namespace std;


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


        int n;
        cin>>n;
        int r=n%10;
        if(r==2 || r==4 || r==5 || r==7 || r==9)
            cout<<"hon";
        else if(r==0 || r==1 || r==6 || r==8)
            cout<<"pon";
        else
            cout<<"bon";

	return 0;
}


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

typedef long long ll;
#define ar array
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<long long>
#define fork(i, n) for (ll i = 0; i < (n); i++)
#define forn for (ll i = 0; i < (n); i++)
#define fori(i, k, n) for (ll i = k; i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define en '\n'
#define FILL(x, v) memset(x, v, sizeof(x))
#define pb push_back
#define fast                 \
	ios::sync_with_stdio(0); \
	cin.tie(0);              \
	cout.tie(0);

template <typename A, typename B>
inline void chmin(A &a, B b)
{
	if (a > b)
		a = b;
}
template <typename A, typename B>
inline void chmax(A &a, B b)
{
	if (a < b)
		a = b;
}
template <typename T>
void print(vector<T> &a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}
template <typename T>
void print(deque<T> &a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}
template <typename T>
void print(vector<vector<T>> &a)
{
	for (int i = 0; i < a.size(); i++)
	{
		for (int j = 0; j < a[i].size(); j++)
			cout << a[i][j] << ' ';
		cout << en;
	}
}

void solve()
{
	// ll x, c = 100;
	// int ans = 0;
	// cin >> x;
	// while (c < x)
	// {
	// 	c += c / 100;
	// 	ans++;
	// }
	// cout << ans << en;
	int k, n;
	cin >> k >> n;
	vi a(n);
	int ans = k;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	for (int i = 0; i < n; i++)
	{
		// chmin(ans, (i > 0 ? k - abs(a[i] - a[i - 1]) : k - abs(a[i] - a[n - 1])));
		int prev = (i == 0) ? a[n - 1] : a[i - 1];
		int dist = abs(a[i] - prev);
		chmin(ans, max(dist, k - dist));
	}
	cout << ans << en;
}

int main()
{
	fast;
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	solve();
	return 0;
}

Measured memory_bytes: 3988
#include <stdio.h>
int main(void){
	char st[11],ri[11],ng[11];
	scanf("%s %s %s",st,ri,ng);
	st[0]=st[0]-32;
	ri[0]=ri[0]-32;
	ng[0]=ng[0]-32;
	printf("%c%c%c",st[0],ri[0],ng[0]);
	return 0;
}

Measured memory_bytes: 128
//In The Name of Allah
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N = 2e5 + 10;
const ll mod = 1e9 + 7;

ll c[N], pw[N];

ll f(ll x){
    if (x == 0)
        return 1;
    return (x + 2) * pw[x - 1] % mod;
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    ll n;
    cin >> n;
    for (ll i = 1; i <= n; i ++)
        cin >> c[i];
    sort(c + 1, c + n + 1);
    pw[0] = 1;
    for (ll i = 1; i < N; i ++)
        pw[i] = pw[i - 1] * 2 % mod;
    ll ans = 0;
    for (ll i = 1; i <= n; i ++)
        ans = (ans + f(n - i) * pw[i - 1] % mod * c[i] % mod) % mod;
    ans = ans * pw[n] % mod;
    cout << ans;
    return 0;
}


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

vector<int> adj[100100];
int deg[100100];

bool dfs(int i, int p, int goal) {
    for (int j : adj[i]) {
        if (j == p) continue;
        if (j == goal) return true;
        if (deg[j] == 4) return false;
        if (dfs(j, i, goal)) return true;
    }
    return false;
}

int main() {
    int n, m; cin >> n >> m;
    while (m--) {
        int a, b; cin >> a >> b;
        adj[a].push_back(b);
        adj[b].push_back(a);
        deg[a]++; deg[b]++;
    }
    int c = 0;
    for (int i = 1; i <= n; i++) {
        if (deg[i] % 2) { cout << "No\n"; return 0; }
    }
    for (int i = 1; i <= n; i++) {
        if (deg[i] >= 6) { cout << "Yes\n"; return 0; }
        if (deg[i] == 4) c++;
        if (c >= 3) { cout << "Yes\n"; return 0; }
    }
    if (c <= 1) cout << "No\n";
    else
        for (int i = 1; i <= n; i++) {
            if (deg[i] == 4) {
                cout << (dfs(i, -1, i) ? "Yes\n" : "No\n");
                return 0;
            }
        }
}


Measured memory_bytes: 7296
#include<cstdio>
#include<iostream>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<deque>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<limits>
#include<boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
using namespace std;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define rep(I,N) up(I,0,N-1)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                                      ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}
inline                                              void out(ld p){printf("%.12Lf\n",p);}
template<class T>inline                             void outml(T p){for_each(all(p),out<decltype(p[0])>);}
template<class T>inline void outol(T V){int n=V.size();rep(i,n)cout<<V[i]<<" \n"[i==n-1];}
long L[1<<18],R[1<<18];
long N,K,C;
string S;
inline void solve(void){
  in(N,K,C,S);
  for(long i=0,pos=0;i<N;++i)if(S[i]=='o'){L[pos++]=i;i+=C;}
  for(long i=N-1,pos=K-1;i>=0;--i)if(S[i]=='o'){R[pos--]=i;i-=C;}
  rep(i,K)if(L[i]==R[i])out(L[i]+1);
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 5396
eval"N,K,S,T,*A="+`dd`.split*?,
A.select!{1>~_1&S|_1&~T}
c=[1]*-~N
c.map{$*<<c[K]-1
t=0
c.map!{t+t=_1}}
p (S..T).sum{|u|~u&S|u&~T<1?A.map{_1&u}.tally.sum{$*[_2]}*(1-('%b'%(u-S)).count(?1)%2*2):0}

Measured memory_bytes: 14604
n = int(input())
A = list(map(int, input().split()))

zero_each_dig = [0 for _ in range(60)]
one_each_dig = [0 for _ in range(60)]

for i in range(n):
     for j in range(60):
        if (A[i] >> j) & 1 == 1:
            one_each_dig[j] += 1
        else:
            zero_each_dig[j] += 1

Multi = []
for k in range(60):
    Multi.append(zero_each_dig[k] * one_each_dig[k] * (2**k) % (10**9 +7))

ans = sum(Multi) % (10**9 +7)
print(ans)

Measured memory_bytes: 125624
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <cstring>
#include <math.h>
#include <bitset>
#include <time.h>
#include <set>
#include <algorithm>
#define MAXN 100000
#define ll long long
using namespace std;

int counts[MAXN+2];

// 1,1,2,2,3,3,5
// 1,2,3,3,4,4,5


vector<int> nums[MAXN+2];
int pairs[MAXN+2];


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

    for(int i=1;i<=N;i++)
    {
        int x;
        cin>>x;
        nums[x%M].push_back(x);
    }
    
    for(int i=0;i<M;i++) {
        sort(nums[i].begin(),nums[i].end());
        pairs[i]=0;
        for(int j=0;j<(int)nums[i].size()-1;) {
            if (nums[i][j]==nums[i][j+1]) {
                pairs[i]++;
                j+=2;
            } else {
                j++;
            }
        }
    }
    
    
    int answer = 0;
    for(int i=0;i<M;i++) {
        if (i > M-i)
            break;
        
        
        if (i==0 || (i*2)%M==0) {
            answer += nums[i].size()/2;
        } else {
            if (nums[i].size() > nums[M-i].size()) {
                answer += nums[M-i].size();
                int left = nums[i].size()-nums[M-i].size();
                if (left%2)
                    left--;
                answer += min(left/2,pairs[i]);
            } else {
                answer += nums[i].size();
                int left = nums[M-i].size()-nums[i].size();
                if (left%2)
                    left--;
                answer += min(left/2,pairs[M-i]);
            }
        }
    }
    
    cout << answer << endl;
    
    
    
    
}

Measured memory_bytes: 6144
#include<iostream>
    #include<algorithm>
    #include<vector>
    #include<queue>
    #include<cmath>
    #include<tuple>
    #include<string>
    typedef long long int ll;
    #define rep(i,a,b) for(int i=(a);i<(b);i++)
    #define F first
    #define S second
    using namespace std;
    const ll INF = 10000000000000;
     
    int main() {
      int N;
      string s;
      cin >> N;
      cin >> s;
      if(N>=3200)cout<<s<<endl;
      else cout<<"red"<<endl;
      return 0;
    }

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>



int main()
{
    int N;
    scanf("%d",&N);
    int A[N],i,j,tmp;
    for(i=0;i<N;i++){
        scanf("%d",&A[i]);
    }

    for (i=0; i<N; i++) {
        for (j=i+1; j<N; ++j) {
            if (A[i] > A[j]) {
                tmp =  A[i];
                A[i] = A[j];
                A[j] = tmp;
            }
        }
    }

    printf("%d\n",A[N-1]-A[0]);


    return 0;
}

Measured memory_bytes: 128
print(
  [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51][int(input())-1]
)

Measured memory_bytes: 2940
// #define DEBUGGING
#include <bits/stdc++.h>
#define endl '\n'
#define ALL(V) (V).begin(), (V).end()
#define ALLR(V) (V).rbegin(), (V).rend()
template <typename T> using V = std::vector<T>;
template <typename T> using VV = V<V<T>>;
using ll = std::int64_t;
using ull = std::uint64_t;
using PLL = std::pair<ll, ll>;
using TLL = std::tuple<ll, ll, ll>;
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return std::min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return std::max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return std::max(low, std::min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { return t = clamp(t, low, high); }
namespace init__ { struct InitIO { InitIO() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(30); } } init_io; }
#define mv_rec make_v(init, tail...)
template <typename T> T make_v(T init) { return init; }
template <typename T, typename... Tail> auto make_v(T init, size_t s, Tail... tail) { return V<decltype(mv_rec)>(s, mv_rec); }
#undef mv_rec
using namespace std;
#ifdef DEBUGGING
#include "../../debug/debug.cpp"
#else
#define DEBUG(...) 0
#define DEBUG_SEPARATOR_LINE 0
#endif

const ll mod = 1e9 + 7;

ll mod_pow(ll n, ll k) {
    ll ret = 1;
    ll cur = n;
    while(k) {
        if(k & 1) ret = (ret * cur) % mod;
        cur = cur * cur % mod;
        k /= 2;
    }
    return ret;
}

int main() {
    ll N;
    cin >> N;
    V<ll> A(N);
    for(auto &&ele : A) cin >> ele;

    ll cnt[64] = {};

    for(auto &&ele : A) {
        for(ll i = 0; i <= 60; i++) {
            if((ele >> i) & 1) cnt[i]++;
        }
    }

    ll ans = 0;
    for(auto &&ele : A) {
        for(ll i = 0; i < 60; i++) {
            ll val = (1ll << i) % mod;
            ll c;
            if((ele >> i) & 1) c = N - cnt[i];
            else c = cnt[i];
            ans += c * val % mod;
            ans %= mod;
        }
    }

    ans = ans * mod_pow(2, mod - 2) % mod;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2560
<?php
    while(1){
    fscanf(STDIN,"%d %d",$x,$y);
        if( $x == 0 && $y == 0 ){
                break;
        }else if( $x > $y ){
            echo $y." ".$x."\n";
        }else{
            echo $x." ".$y."\n";
        }
    }

Measured memory_bytes: 15252
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string a,b,ans1,ans2;
    cin>>a>>b;
    stringstream ss(a);
    int x=0;
    ss>>x;
    stringstream ss1(b);
    int y=0;
    ss1>>y;
    for(int i=1;i<=y;i++)
    {
        ans1+=a;
    }
    for(int j=1;j<=x;j++)
    {
        ans2+=b;
    }
    if(ans1<ans2)
    {
        cout<<ans1<<endl;
    }
    else
    {
        cout<<ans2<<endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	 long long n,k;
	cin>>n>>k;
	long long t= n%k;
	if(abs(t-k)<t)
	cout<<abs(t-k)<<endl;
	else 
	cout<<t<<endl;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const double PI = acos(-1);
const ll MOD = 1000000007;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////////////////////
template <std::uint_fast64_t Modulus> class modint {
using u64 = std::uint_fast64_t;

public:
u64 a;

constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
constexpr u64 &value() noexcept { return a; }
constexpr const u64 &value() const noexcept { return a; }
constexpr modint operator+(const modint rhs) const noexcept {
return modint(*this) += rhs;
}
constexpr modint operator-(const modint rhs) const noexcept {
return modint(*this) -= rhs;
}
constexpr modint operator*(const modint rhs) const noexcept {
return modint(*this) *= rhs;
}
constexpr modint operator/(const modint rhs) const noexcept {
return modint(*this) /= rhs;
}
constexpr modint &operator+=(const modint rhs) noexcept {
a += rhs.a;
if (a >= Modulus) {
a -= Modulus;
}
return *this;
}
constexpr modint &operator-=(const modint rhs) noexcept {
if (a < rhs.a) {
a += Modulus;
}
a -= rhs.a;
return *this;
}
constexpr modint &operator*=(const modint rhs) noexcept {
a = a * rhs.a % Modulus;
return *this;
}
constexpr modint &operator/=(modint rhs) noexcept {
u64 exp = Modulus - 2;
while (exp) {
if (exp % 2) {
*this *= rhs;
}
rhs *= rhs;
exp /= 2;
}
return *this;
}
};

using mint = modint<MOD>;
int H,W;
vector<vector<char>> board;
vector<vector<mint>> dp; 

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    cin >> H >> W;
    board.assign(H+2, vector<char>(W+2,'#'));
    rep(i,H) rep(j,W) cin >> board[i+1][j+1];

    dp.assign(H+2, vector<mint>(W+2));
    vector<vector<bool>> check(H+2, vector<bool>(W+2,false));
    dp[1][1] = 1;
    queue<pair<int, int>> que;
    que.emplace(1,1);
    while(!que.empty()) {
        int y,x;
        tie(y,x) = que.front(); que.pop();
        if (y != 1 || x != 1) dp[y][x] = dp[y-1][x] + dp[y][x-1];
        if (board[y+1][x] == '.' && !check[y+1][x]) {
            que.emplace(y+1,x);
            check[y+1][x] = true;
        }
        if (board[y][x+1] == '.' && !check[y][x+1]) {
            que.emplace(y,x+1);
            check[y][x+1] = true;
        }
    }

    cout << dp[H][W].a << endl;
}


Measured memory_bytes: 9344
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

const int MOD = (1e9 + 7);

int add(int a, int b)
{
	a+=b;
	while(a>=MOD) a-=MOD;
	return a;
}
int mult(int a, int b)
{
	return (a*1LL*b)%MOD;
}
int modpow(int a, int b)
{
	int r=1;
	while(b)
	{
		if(b&1) r=mult(r,a);
		a=mult(a,a);
		b>>=1;
	}
	return r;
}

struct Combi
{
	vector<int> fact;
	vector<int> ifact;
	vector<int> inv;
	vector<int> pow2;
	int choose(int a, int b)
	{
		if(a<b) return 0;
		if(b==0) return 1;
		if(a==b) return 1;
		return mult(fact[a],mult(ifact[b],ifact[a-b]));
	}
	int inverse(int a)
	{
		return modpow(a,MOD-2);
	}
	void init(int _n)
	{
		fact.clear(); ifact.clear(); inv.clear(); pow2.clear();
		fact.resize(_n+1);
		ifact.resize(_n+1);
		inv.resize(_n+1);
		pow2.resize(_n+1);
		pow2[0]=1;
		ifact[0]=1;
		fact[0]=1;
		for(int i=1;i<=_n;i++)
		{
			pow2[i]=add(pow2[i-1],pow2[i-1]);
			fact[i]=mult(fact[i-1],i);
		}
		ifact[_n] = inverse(fact[_n]);
		for(int i=_n-1;i>=1;i--)
		{
		    ifact[i] = mult(ifact[i + 1], i + 1);
		}
		for(int i=1;i<=_n;i++)
		{
		    inv[i] = mult(fact[i-1],ifact[i]);
		}
	}
};


Combi combi;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n,m,k; cin>>n>>m>>k;
	combi.init(999999);
	int ans=0;
	int coeff=modpow(3,m+k);
	int res=1;
	int oldl=0; int oldr=0;
	for(int i=n;i<=n+m+k;i++)
	{
		int res2=mult(res,mult(coeff,combi.choose(i-1,n-1)));
		ans=add(ans,res2);
		coeff=mult(coeff,combi.inv[3]);
		if(i>=n+m+k) break;
		int newl = max(i+1-n-k,0); int newr = min(m,i+1-n);
		res=add(res,res);
		res=add(res,MOD-combi.choose(i-n,oldl));
		res=add(res,MOD-combi.choose(i-n,oldr));
		while(oldl>=newl)
		{
			res=add(res,combi.choose(i+1-n,oldl));
			oldl--;
		}
		oldl++;
		while(oldl<newl)
		{
			res=add(res,MOD-combi.choose(i+1-n,oldl));
			oldl++;
		}
		oldr++;
		while(oldr<=newr)
		{
			res=add(res,combi.choose(i+1-n,oldr));
			oldr++;
		}
		oldr--;
		while(oldr>newr)
		{
			res=add(res,MOD-combi.choose(i+1-n,oldr));
			oldr--;
		}
		oldl=newl; oldr=newr;
	}
	cout<<ans<<'\n';
}


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

using namespace std;

typedef long long int64;

const int64 INF = 1LL << 58;


int main()
{
  int N, M, L, S, T;
  int64 g[300][300];
  int x[16], y[16];
  int64 dp[1 << 16][16];

  while(scanf("%d %d %d %d %d", &N, &M, &L, &S, &T), N) {

    --S;
    fill_n(*g, 300 * 300, INF);
    for(int i = 0; i < 300; i++) g[i][i] = 0;
    fill_n(*dp, (1 << 16) * 16, INF);

    for(int i = 0; i < M; i++) {
      int A, B, C;
      scanf("%d %d %d", &A, &B, &C);
      --A, --B;
      g[A][B] = g[B][A] = C;
    }
    for(int i = 0; i < L; i++) {
      scanf("%d %d", &x[i], &y[i]);
      --x[i];
    }

    for(int k = 0; k < N; k++) {
      for(int i = 0; i < N; i++) {
        for(int j = 0; j < N; j++) {
          g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
        }
      }
    }

    for(int i = 0; i < L; i++) {
      dp[1 << i][i] = g[S][x[i]] + y[i];
    }
    for(int i = 0; i < 1 << L; i++) {
      for(int j = 0; j < L; j++) {
        if(dp[i][j] == INF) continue;
        for(int k = 0; k < L; k++) {
          if((i >> k) & 1) continue;
          dp[i | (1 << k)][k] = min(dp[i | (1 << k)][k], dp[i][j] + g[x[j]][x[k]] + y[k]);
        }
      }
    }

    int ret = 0;
    for(int i = 0; i < 1 << L; i++) {
      for(int j = 0; j < L; j++) {
        if(dp[i][j] + g[x[j]][S] <= T) {
          ret = max(ret, __builtin_popcount(i));
        }
      }
    }

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

Measured memory_bytes: 12012
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

int main() {
    ll n;
    cin>>n;
    vector<ll> a(n);
    rep(i,n)cin>>a[i];
    vector<ll> ans;
    ll t=a[0]+1;
    ll u=-1;
    while(true){
        vector<ll> kari;
        ll mid=(t+u)/2;
        ll pre=mid;
        ll s=mid;
        ll next=a[0]-pre;
        bool f=true;
        bool f2=true;

        kari.push_back(mid*2);
        for(int i=0;i<n;i++){
            next=a[i]-pre;
            if(next<0){
                if(i%2)f2=false;
                else f=false;
                break;
            }else {
                kari.push_back(next * 2);
                pre=next;
            }
        }


        if(next==s){
            ans=kari;break;

        }else if(f==false||f2==false||next>s){
            if(f2==false||next>s)u=mid;
            else t=mid;

        }else{
            t=mid;
        }
        //cout<<t<<u<<endl;
    }

    rep(i,ans.size()-1){
        cout<<ans[i]<<" ";
    }

    return 0;
}


Measured memory_bytes: 3808
/// Contest : AtCoder Beginner Contest 086 Problem: A
/// 20-01-2018
/// MD:NUR ALAM
/// Eastern University of Bangladesh

#include "bits/stdc++.h"

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = (a); i < (b); ++i)
#define fo(i, a, b) for (int i = (a); i <(b); ++i)
#define fors(i, s) for (int i = 0; s[i]; ++i)
#define rs(x) scanf("%s", (x))
#define mp make_pair
#define pb push_back
#define mso(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define len(X) strlen(x)

using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef long double lu;
typedef pair<int,int> pii;
typedef vector<ll> vi;
typedef vector<pii> vpll;
typedef pair<ll,ll> Pll;
typedef map<string,int>msi;
typedef set<ll>se;

template<class t> void _r(t &x) { cin >> x; }
void _r(int &x) { scanf("%d", &x); }
void _r(int64_t &x) { scanf("%lld", &x); }
void _r(double &x) { scanf("%lf", &x); }
void _r(char &x) { scanf(" %c", &x); }
void _r(char *x) { scanf("%s", x); }
void r() {}
template<class t, class... u> void r(t &head, u &... tail) { _r(head); r(tail...); }
template<class t> void _w(const t &x) { cout << x; }
void _w(const int &x) { printf("%d", x); }
void _w(const int64_t &x) { printf("%lld", x); }
void _w(const double &x) { printf("%.16f", x); }
void _w(const char &x) { putchar(x); }
void _w(const char *x) { printf("%s", x); }
template<class t,class u> void _w(const pair<t,u> &x) {_w(x.f); putchar(' '); _w(x.s);}
void w() {}
template<class t, class... u> void w(const t &head, const u &... tail) { _w(head); putchar(sizeof...(tail) ? ' ' : '\n'); w(tail...); }
template<class t, class... u> void debug(const t &head, const u &... tail) {
#ifdef HOME
#endif
}

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

int main()
{
   ll a,b;
   r(a,b);
   ll c=abs(a*b);
   if(c%2==0) w("Even\n");
   else w("Odd\n");

}


Measured memory_bytes: 256
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
ll dp[52][101][101];
int main()
{
	int num;
	scanf("%d", &num);
	vector<int>v;
	for (int i = 0; i < num + num - 1; i++)
	{
		int z;
		scanf("%d", &z);
		v.push_back(z);
	}
	sort(v.begin(), v.end());
	dp[1][1][0] = 1;
	for (int i = 1; i < num; i++)
	{
		int a1 = int(v[num - 1 - i] != v[num - i]), a2 = int(v[num - 1 + i] != v[num - 2 + i]);
		for (int j = 1; j <= i + i - 1; j++)
		{
			for (int k = 0; k < j; k++)
			{
				for (int l = 0; l < k + a1; l++)
				{
					dp[i + 1][j + a1 + a2 - (k + a1 - l - 1)][l] += dp[i][j][k];
					dp[i + 1][j + a1 + a2 - (k + a1 - l - 1)][l] %= mod;
				}
				dp[i + 1][j + a1 + a2][k + a1] += dp[i][j][k];
				dp[i + 1][j + a1 + a2][k + a1] %= mod;
				for (int l = k + a1 + 1; l < j + a1 + a2; l++)
				{
					dp[i + 1][j + a1 + a2 - (l - 1 - k - a1)][k + a1 + 1] += dp[i][j][k];
					dp[i + 1][j + a1 + a2 - (l - 1 - k - a1)][k + a1 + 1] %= mod;
				}
			}
		}
	}
	ll ans = 0;
	for (int i = 0; i <= num + num - 1; i++)
	{
		for (int j = 0; j < i; j++)
		{
			ans = (ans + dp[num][i][j]) % mod;
		}
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 2816
def Reverse(str, A, B):
    a = int(A)
    b = int(B)
    if a == 0:
        str = str[0:a] + str[b::-1] + str[b + 1:]
    else:
        str = str[0:a] + str[b:a - 1:-1] + str[b + 1:]
    return str

def Replace(str, a, b, c):
    str2 = ''
    Str = list(str)
    for i in range(int(b) - int(a) + 1):
        Str[i + int(a)] = c[i]
    for i in range(len(Str)):
        str2 += Str[i]
    return str2

str = input()
n = int(input())
for i in range(n):
    a = input()
    A = a.split()
    if A[0] == 'print':
        print(str[int(A[1]):int(A[2]) + 1])
    elif A[0] == 'reverse':
        str = Reverse(str, A[1], A[2])
    elif A[0] == 'replace':
        str = Replace(str, A[1], A[2], A[3])



Measured memory_bytes: 5624
import sys
sys.setrecursionlimit(10**9)

def dfs1(v):
  for u in g[v]:
    if checked[u]==0:
      checked[u]=1
      g2[v].append(u)
      g3[v].append(u)
      g3[u].append(v)
      dfs1(u)
      
def dfs2(v):
  for u in g2[v]:
    if checked[u]==0:
      checked[u]=1
      dfs2(u)
      if cnt[u]%2==1:
        ans.append((u,v))
        cnt[u]+=1
      else:
        ans.append((v,u))
        cnt[v]+=1
      
n,m=map(int,input().split())
g=[[] for _ in range(n+1)]
g2=[[] for _ in range(n+1)]
g3=[[] for _ in range(n+1)]
cnt=[0]*(n+1)
ans=[]
ansset=set()
for _ in range(m):
  a,b=map(int,input().split())
  g[a].append(b)
  g[b].append(a)
if m%2==1:
  print(-1)
else:
  checked=[0]*(n+1)
  checked[1]=1
  dfs1(1)
  for v in range(1,n+1):
    for u in g[v]:
      if u not in g3[v]:
        if (u,v) not in ansset:
          ans.append((v,u))
          ansset.add((v,u))
          cnt[v]+=1
  checked=[0]*(n+1)
  checked[1]=1
  dfs2(1)
  for v,u in ans:
    print(v,u)

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

#define CARD_TYPE 4
#define CARD_RANK 13
#define CARD_MAX 52

int main()
{	
	bool cards[CARD_TYPE][CARD_RANK] = { false };
	int N;
	int type, rank;
	char ctype;
	
	cin >> N;
	for(int i = 0; i < N; i++)
	{
		cin >> ctype >> rank;
		
		switch( ctype )
		{
		case 'S': type = 0; break;
		case 'H': type = 1; break;
		case 'C': type = 2; break;
		case 'D': type = 3; break;
		}
		rank --;
		cards[type][rank] = true;
	}
	
	for(int i = 0; i < CARD_TYPE; i++)
	{
		for(int j = 0; j < CARD_RANK; j++)
		{
			if(cards[i][j] == false)
			{
				switch( i )
				{
				case 0: cout << "S "; break;
				case 1: cout << "H "; break;
				case 2: cout << "C "; break;
				case 3: cout << "D "; break;
				}				
				
				cout << j + 1 << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define int long long int
#define endl "\n"
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define all(a) a.begin(),a.end()
#define fastm_fast ios_base::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL)
using namespace std;
#define pb push_back
int32_t main()
 {
 fastm_fast;
 int n;
 cin >> n;
 int sum=n;
 int cnt = 1;
 while(sum%360!=0)
 {
 	sum+=n;
 	cnt++;
 }
 cout<<cnt;
 return 0;
 }

Measured memory_bytes: 3648
#include"bits/stdc++.h"
#include<unordered_set>
#include<unordered_map>
#include<random>
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9+7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)
int dx[4]={ 1,0,-1,0 };
int dy[4]={ 0,1,0,-1 };

ll L, R;

ll dp[64][2][2];
ll solve(ll i, int girix, int giriy){
    if(i == -1)return 1;
    if(dp[i][girix][giriy] != -1) return dp[i][girix][giriy];
    ll ret = 0;

    // x=0, y=0
    if(girix==0){
        if(giriy==1 && ((R>>i)&1LL)==0) ret += solve(i-1, 0, 1);
        else ret += solve(i-1, 0, 0);
    }
    else if(((L>>i)&1LL) == 0){
        if(giriy==1 && ((R>>i)&1LL)==0) ret += solve(i-1, 1, 1);
        else ret += solve(i-1, 1, 0);
    }
    
    // x=0, y=1
    if(girix==0){
        if(giriy==1 && ((R>>i)&1LL)==0) ret += 0;
        else if(giriy==1 && ((R>>i)&1LL)==1) ret += solve(i-1, 0, 1);
        else ret += solve(i-1, 0, 0);
    }
    else if(((L>>i)&1LL) == 0){
        if(giriy==1 && ((R>>i)&1LL)==0) ret += 0;
        else if(giriy==1 && ((R>>i)&1LL)==1) ret += solve(i-1, 1, 1);
        else ret += solve(i-1, 1, 0);
    }
    
    // x=1, y=1
    if(girix==0 || ((L>>i)&1LL) == 0){
        if(giriy==1 && ((R>>i)&1LL)==0) ret += 0;
        else if(giriy==1 && ((R>>i)&1LL)==1) ret += solve(i-1, 0, 1);
        else ret += solve(i-1, 0, 0);
    }
    else{
        if(giriy==1 && ((R>>i)&1LL)==0) ret += 0;
        else if(giriy==1 && ((R>>i)&1LL)==1) ret += solve(i-1, 1, 1);
        else ret += solve(i-1, 1, 0);
    }

    return dp[i][girix][giriy] = ret % MOD;
}

signed main(){
    cin >> L >> R;
    ll ans = 0;
    memset(dp, -1, sizeof(dp));
    rep(i, 61){ // 最上位 bit の位置
        if((1LL<<i) > R || (1LL<<i+1)-1 < L) continue;
        ans += solve(i-1, (1LL<<i) < L, (1LL<<i+1)-1 > R);
    }
    cout << ans%MOD << endl;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0; i<n; i++)
    cin >> a.at(i);
  
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  
  int alice=0, bob=0;
  for(int i=0; i<n; i++){
    if(i % 2 == 0)
      alice += a.at(i);
    else
      bob += a.at(i);
  }
  cout << alice - bob << endl;
}

Measured memory_bytes: 256