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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;


const int mod = (int)1e9 + 7;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main()
{
		//cin.tie(0); ios_base::sync_with_stdio(false);
	int n, k;
	cin >>n >>k;
	vector<ll> a(n) , l={0},r={0};
	rep(i,n) cin >>a[i];
	
	rep(i,n){
		if(a[i]<0) l.push_back(-a[i]);
		else r.push_back(a[i]);
	}
	sort(all(l));
	
	
	ll ans =1LL<<60;
	
	rep(i, sz(l)){
		int j= k-i;
		if(j<0 || j>=sz(r)) continue;
		ll w = min(l[i], r[j]) * 2 + max(l[i],r[j]);
		ans = min(ans,  w);
		//dbg(i, j, ans, l[i]+r[j],w);
	}
	cout << ans <<"\n";
	return 0;
}


Measured memory_bytes: 2424
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
using ll = long long;
using namespace std;
const int INF32       = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7        = 1'000'000'007;
const int MOD9        = 1'000'000'009;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
void print() { std::cout << '\n'; }
void vprint() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}
template <class H, class... T> void vprint(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << '\n';
    vprint(std::forward<T>(args)...);
}
template <class T> void vprint(std::vector<T> &v) {
    for (auto &&i : v) {
        std::cout << i << '\n';
    }
}
template <class T> void mprint(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << "";
        }
    }
}

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

    int N, M;
    cin >> N >> M;
    vector<bool> visited(N);
    vector<vector<int>> g(N);
    REP(i, M) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        g[a].emplace_back(b);
        g[b].emplace_back(a);
    }
    ll ans = 0;

    auto check = [&](vector<bool> &v) {
        for (auto &&i : v) {
            if (i == false)
                return false;
        }
        ans++;
        return true;
    };
    auto dfs = [&](auto f, int now, vector<bool> &vis) -> void {
        if (check(vis))
            return;
        queue<int> nextq;
        REP(i, g[now].size()) {
            int next = g[now][i];
            if (!vis[next])
                nextq.push(next);
        }
        while (!nextq.empty()) {
            int next = nextq.front();
            nextq.pop();
            vis[next] = true;
            f(f, next, vis);
            vis[next] = false;
        }
        return;
    };
    visited[0] = true;
    dfs(dfs, 0, visited);
    print(ans);

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

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

int slovei(int, int);
int slovei(int a, int b) {
  int i, j, k, l, o, p, min, temp, d[4] = {}; 
  min = 268435456; 
  for(i = 1; i <= a; i += 1) {
    if(a % i == 0) {
      for(k = 1; k <= b; k += 1) {
        if(b % k == 0) {
          j = a / i;
          d[0] = i;
          d[1] = j;
          l = b / k;
          d[2] = k;
          d[3] = l;
          for(o = 0; o < 3; o += 1) {
            for(p = 3; p >= o; p -= 1) {
              if(d[p] < d[p - 1]) {
               temp = d[p];
               d[p] = d[p - 1]; 
               d[p - 1] = temp;
              };  
            };  
          };  
          min = minof(min, (d[1] - d[0]) * (d[1] - d[0]) + (d[2] - d[1]) * (d[2] - d[1]) + (d[3] - d[2]) * (d[3] - d[2]));
        };  
      };  
    };  
  };  
  return min;
}

int main() {
  int a, b;

  while(1) {
    scanf("%d %d", &a, &b);
    if(a == 0 && b == 0) {
      break;
    };  
    printf("%d\n", slovei(a, b));
  };

  return 0;
}

Measured memory_bytes: 596
#include<stdio.h>

int main() {
    int i, j, k, N, Y;
    int count;

    int a = -1, b = -1, c = -1;

    scanf("%d %d", &N, &Y);

    for (i=0; i<=N; i++) {
        if (10000*i > Y) continue;

        for (j=0; j<=N; j++) {
            if (Y == 10000*i + 5000*j + 1000*(N-i-j) && (N-i-j)>=0) {
                a=i; b=j; c=N-i-j;
                break;
            }
        }
    }

    printf("%d %d %d\n", a, b, c);

    return 0;
}

Measured memory_bytes: 128
import sys
from math import gcd

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    K = int(rl())
    ans = 0
    for i in range(1, K + 1):
        for j in range(1, K + 1):
            for k in range(1, K + 1):
                tmp = gcd(i, j)
                tmp = gcd(tmp, k)
                ans += tmp
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 67764
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
typedef long long int ll;
typedef pair<int,int> P;
const int INF = 1e9+7;

int main(){
    int a,b;
    cin >> a >> b;
    cout << max(a+b,max(a-b,a*b));
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

const INF = int(1e9)

func init() {
	sc.Buffer([]byte{}, math.MaxInt64)
	sc.Split(bufio.ScanWords)
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	if err := sc.Err(); err != nil {
		panic(err)
	}
	return sc.Text()
}

func abs(a int) int {
	return int(math.Abs(float64(a)))
}

func uniqIntSlice(a []int) []int {
	m := make(map[int]struct{})
	for _, v := range a {
		m[v] = struct{}{}
	}
	u := []int{}
	for k := range m {
		u = append(u, k)
	}
	return u
}
func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

//a:old b:new a>b -> a=b (update) more small
func chmin(a *int, b int) bool {
	if *a > b {
		*a = b
		return true
	}
	return false
}

//a:old b:new a<b -> a=b (update) more large
func chmax(a *int, b int) bool {
	if *a < b {
		*a = b
		return true
	}
	return false
}

func rec(dp, h []int, i int) int {
	if dp[i] < INF {
		return dp[i]
	}
	if i == 0 {
		return 0
	}
	res := INF
	chmin(&res, rec(dp, h, i-1)+abs(h[i]-h[i-1]))
	if i > 1 {
		chmin(&res, rec(dp, h, i-2)+abs(h[i]-h[i-2]))
	}
	dp[i] = res
	return dp[i]
}

func main() {
	n := nextInt()
	k := nextInt()

	h := make([]int, n)
	for i := 0; i < n; i++ {
		h[i] = nextInt()
	}
	dp := make([]int, n)
	for i := range dp {
		dp[i] = INF
	}
	dp[0] = 0

	for i := 1; i < n; i++ {
		for j := 1; j <= k; j++ {
			if i-j < 0 {
				break
			}
			chmin(&dp[i], dp[i-j]+abs(h[i]-h[i-j]))
		}
	}

	fmt.Println(dp[n-1])
}


Measured memory_bytes: 2816
#include<bits/stdc++.h>
#define rp(i,n) for(int i=0; i<n; i++)
using namespace std;
using ll=long long;
typedef pair<int,int> P;

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> ac(n,0);
    vector<int> pen(n,0);
    int acs=0;
    int penalty=0;
    rp(i,m){
        int p; string s;
        cin >> p >> s;
        if(s=="AC"){
            if(ac.at(p-1)==0){
                ac.at(p-1)=1;
                penalty += pen.at(p-1);
                acs++;
            }
        }
        if(s=="WA"){
            pen.at(p-1)++;
        }
    }
    cout << acs << " " << penalty << endl;
    return 0;

}

Measured memory_bytes: 1024
#include <iostream>
#include <string>

using namespace std;

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

  if(s==string(s.rbegin(), s.rend())&&s[1]=='1') {
    int r=1;
    for(int i=2; i<s.size(); i++){
      printf("%d %d\n",r,i);
      if(s[i-1]=='1')r=i;
    }
  }else{
    puts("-1");
  }
}

Measured memory_bytes: 1660
import sys
stdin = sys.stdin

def li(): return [int(x) for x in stdin.readline().split()]
def li_(): return [int(x)-1 for x in stdin.readline().split()]
def lf(): return [float(x) for x in stdin.readline().split()]
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(ns())
def nf(): return float(ns())

from itertools import accumulate
from bisect import bisect_left

x = ni()
jump = [i for i in range(1,10**5)]
jump_cum = list(accumulate(jump))
print(bisect_left(jump_cum, x) + 1)

Measured memory_bytes: 11544
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

#define REP(i, init, n) for(int i = (int)(init); i < (int)(n); i++)

#define vi vector<int>
#define vl vector<long>
#define vvi vector<vector<int>>
#define vvl vector<vector<long>>
#define pint pair<int, int>
#define plong pair<long, long>



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

    vi prime;
    vector<bool> erats(1000001, true);
    REP(i, 2, 1000001){
        if(erats[i]) prime.push_back(i);
        int j = i * 2;
        while(j <= 1000000){
            erats[j] = false;
            j += i;
        }
    }
    //cout << "prime" << endl;
    vi P(1000001, 1), D(1000001, 1), Ans(1000001, 0);
    P[1] = 1;
    REP(i, 2, 1000001){
        for(int p: prime){
            if(i * p < 1000000){
                P[i * p] = i;
            }else{
                break;
            }
        }
    }
    //cout << "div" << endl;
    REP(i, 1, 1000001){
        int j = i;
        int d = 1;
        int prime = 1;
        int count = 0;
        while(1){
            if(j == 1){
                d*= (count + 1);
                break;
            }
            if(j / P[j] > prime){
                d *= (count + 1);
                count = 1;
                prime = j / P[j];
                j = P[j];
            }else{
                count++;
                j = P[j];
            }
            //cout << j << " ";
        }
        //if(i < 101) cout << i <<  ": " << d << endl;
        D[i] = d;
    }
    REP(i, 1, 1000001){
        Ans[i] += D[i] + Ans[i - 1];
    }
    cout << Ans[N - 1] << endl;;
}

Measured memory_bytes: 15532
n, y = map(int, input().split())
ans = []
for i in range(n+1):
    for j in range(n+1-i):
        k = n-i-j
        if 10000*i + 5000*j + 1000*k == y and k >=0:
            ans.append([i,j,k])
            break
                
if len(ans) >=1:
    str_ans = map(str, ans[0])
    print(' '.join(str_ans))
if len(ans) == 0:
    print('-1 -1 -1')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,b,a) for(int i=b;i>=a;i--)
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Forenska(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-x))
#define GREATER(x) x,vector<x>,greater<x>
#define randIn(L,R) (((LL)rand()*rand())%(R-L)+L)
#define __lcm(a,b) ((a)/__gcd(a,b)*(b))
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pLL;
typedef vector<int> vec;
typedef vector<LL> vecL;
typedef vector<pii> vecP;
typedef vector<pLL> vecPL;
typedef vector<string> vecS;
typedef vector<vec> mat;
typedef complex<double> point;
const long double PI=3.14159265358979323846264338327950288419716939937510582097;
const LL INFLL=0x3f3f3f3f3f3f3f3f;
const int INF=0x3f3f3f3f;
const long double EPS=1e-10;
int read()
{
    int x=0;
    char ch=' ';
    bool flag=false;
    while(ch<'0' || ch>'9')
    {
        if(ch=='-')flag=true;
        ch=getchar();
    }
    while(ch>='0' && ch<='9')
    {
        x=(x<<3)+(x<<1)+ch-'0';
        ch=getchar();
    }
    return flag?-x:x;
}

int main()
{
	string s;
	cin>>s;
	sort(all(s));
	puts(s=="abc"?"Yes":"No");
	return 0;
}



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

int main(){
int n;
cin>>n;
int card[100][100];

for(int i=0;i<n;i++){
int num;
string mark;
cin>>mark>>num;

int g;
if (mark=="S") {g=1;}
if (mark=="H") {g=2;}
if (mark=="C") {g=3;}
if (mark=="D") {g=4;}
card[g][num]=1;
}

string str[5]={"G","S","H","C","D"};
for(int x=1;x<=4;x++){
for(int y=1;y<=13;y++){

	if(card[x][y]==1){continue;}
	else{
	cout<<str[x]<<" "<<y<<endl;
	}

}
}


return 0;
}


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

int main(){
    int h, n, a, b;
    cin >> h >> n;
    int mp[h+1] = {};
    for(int i=0; i<h; i++) mp[i] = 100000000;
    for(int i=0; i<n; i++){
        cin >> a >> b;
        for(int j=h; j>=0; j--){
            if(j > h-a) mp[j] = min(b, mp[j]);
            else mp[j] = min(mp[j], mp[j+a]+b);
        }
    }
    cout << mp[0];
    return 0;
}

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

typedef long long                   ll;
typedef long double                 ld;
typedef pair<ll,ll>                 pll;
typedef pair<ld,ld>                 pld;


#define all(x)          (x).begin(),(x).end()
#define Sort(x)         sort(all(x))
#define sep             ' '
#define endl            '\n'
#define tab             '\t'
#define X               first
#define Y               second
#define SZ(x)           x.size()
#define kill(x)         return cout<<x<<endl,0;
#define fast_io         ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_io         freopen("in.txt" , "r" , stdin) ; freopen("out.txt" , "w" , stdout);
#define set_random      mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
const ll MOD = 1e9 + 7,
         MAXN= 1e6+10,
         INF=1e18;
ll a,b,c;
int main()
{
    fast_io;
    cin >> a >> b >>c;
    cout<<max(0LL,c-(a-b));
    return 0;
}


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

#define FOR(i,a,b) for(i=(a);i<(b);++i) 
#define REP(i,n) for(i=0;i<(n);++i)

using namespace std;

int main() {
	int N, i, Max;
	vector<int> x1(100),x2(100),ans(100);
	cin >> N;
	REP(i, N) 
		cin >> x1[i];
	REP(i, N)
		cin >> x2[i];
	ans[0] = x1[0];
	REP(i, N)
		ans[0] += x2[i];
	Max = ans[0];
	FOR(i, 1, N) {
		ans[i] = ans[i-1] + x1[i] - x2[i - 1];
		Max = max(Max, ans[i]);
	}
	cout << Max << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int total = 0;
    if(a<b){
      for(int i=1 ; i<b ; i++){
        int c = (int)Math.pow(10,i);
        total = total + c*a;
      }
      total = total + a;
    }else{
      for(int i=1 ; i<a ; i++){
        int c = (int)Math.pow(10,i);
        total = total + c*b;
      }
      total = total + b;
    }
    System.out.println(total);
  }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int a[110];
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i];
	int ans=1e9;
	for(int i=-100;i<=100;i++){
		int cnt=0;
		for(int j=0;j<n;j++){
			cnt+=abs(a[j]-i)*abs(a[j]-i);
		}
		ans=min(ans,cnt);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		StringBuilder sb = new StringBuilder();
		while ((line = br.readLine()) != null && !line.isEmpty()) {
			StringTokenizer st = new StringTokenizer(line);
			int a = Integer.parseInt(st.nextToken());
			int b = Integer.parseInt(st.nextToken());
			sb.append(a - b).append('\n');
		}
		System.out.print(sb.toString());
	}
}

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

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

  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
   cin >> vec.at(i);
  }

  bool ans = true;
  int X;
  for (int i = 0; i < N; i++) {
    X=vec.at(i);
    if (X%2==0 && X%3!=0 && X%5!=0){
       ans=false;
       break;
    }
  }
  
  if (ans) {
    cout << "APPROVED" << endl;
  }
  else {
    cout << "DENIED" << endl;
  }
}

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

vector<pair<int, int>> factorize(int x) {
	vector<pair<int, int>> res;
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0) {
			res.emplace_back(i, 0);
			while (x % i == 0) {
				res.back().second++;
				x /= i;
			}
		}
	}
	if (x > 1) {
		if (!res.empty() && res.back().first == x)
			res.back().second++;
		else
			res.emplace_back(x, 1);
	}
	return res;
}

template<int MOD>
class mod_int {
	unsigned x;
public:
	mod_int() : x(0) { }
	mod_int(int sig) { int sigt = sig % MOD; if (sigt < 0) sigt += MOD; x = sigt; }
	mod_int(long long sig) { int sigt = sig % MOD; if (sigt < 0) sigt += MOD; x = sigt; }
	int get() const { return (int)x; }

	mod_int &operator+=(mod_int that) { if ((x += that.x) >= MOD) x -= MOD; return *this; }
	mod_int &operator-=(mod_int that) { if ((x += MOD - that.x) >= MOD) x -= MOD; return *this; }
	mod_int &operator*=(mod_int that) { x = (unsigned long long)x * that.x % MOD; return *this; }
	mod_int &operator/=(mod_int that) { return *this *= that.inverse(); }

	mod_int operator+(mod_int that) const { return mod_int(*this) += that; }
	mod_int operator-(mod_int that) const { return mod_int(*this) -= that; }
	mod_int operator*(mod_int that) const { return mod_int(*this) *= that; }
	mod_int operator/(mod_int that) const { return mod_int(*this) /= that; }

	bool operator==(const mod_int& that) const { return x == that.x; }

	mod_int inverse() const {
		long long a = x, b = MOD, u = 1, v = 0;
		while (b) {
			long long t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		return mod_int(u);
	}
};

template<int MOD>
istream& operator >> (istream& is, mod_int<MOD>& val) {
	long long x;
	is >> x; val = x;
	return is;
}

template<int MOD>
ostream& operator << (ostream& os, const mod_int<MOD>& val) {
	os << val.get();
	return os;
}

const int mod = 1e9 + 7;
using mint = mod_int<mod>;

mint nCr(int n, int r) {
	mint a = 1, b = 1;
	for (int i = 1; i <= r; i++) {
		a *= n - i + 1;
		b *= i;
	}
	return a / b;
}

int main()
{
	int N, M;
	cin >> N >> M;
	mint res = 1;
	for (auto p : factorize(M)) {
		res *= nCr(N - 1 + p.second, p.second);
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <numeric> //lcm


#define ERROR() cout << "ERROR!!" << endl; return 0;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = n-1; i >= 0; --i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)

#define debug(vec) for(auto v : vec) cout << v << " "; cout << endl;

#define debug2D(vec2D) for(auto vec : vec2D) { for (auto v : vec) cout << v << " "; cout << endl; } 

using namespace std;

typedef long long ll;

const long long int INF = 1 << 29; //<10^10
//const ll MOD = 998244353;
const ll MOD = 1000000007;

inline bool maxch(int &a, int b) { if (a < b) {a = b; return true;} else return false;}

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

	int n;
	cin >> n;

	char ch[4] = {'A', 'G', 'C', 'T'};
	int dp[101][4][4][4];
	rep(i,101) rep(a,4) rep(b,4) rep(c,4) dp[i][a][b][c] = 0;
	dp[0][3][3][3] = 1;
	rep(i, n) rep(a, 4) rep(b, 4) rep(c, 4) {
	  int ng = -1;
		if ((a == 0 || b == 0) && c == 1 
		   || a == 0 && b == 1 
			 || b == 1 && c == 0) {
			ng = 2;
		}
		else if (b == 0 && c == 2) ng = 1;

		rep(j, 4) {
			if (j != ng) {
				dp[i + 1][b][c][j] += dp[i][a][b][c];
				dp[i + 1][b][c][j] %= MOD;
			}  
		}
	}

	ll ans = 0;
	rep(a,4) rep(b,4) rep(c,4) { 
	  ans += dp[n][a][b][c];
		ans %= MOD;
	}
	cout << ans << endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    ll n;
    cin>>n;
    if(0==n%1000)cout<<0;
    else cout<<1000-n%1000;
}


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

int main(){
  int A,B;
  cin >> A >> B;
  
  if (A == 1 && B == 2){
    cout << 3 << endl;
  }
  else if (A == 2 && B == 1){
    cout << 3 << endl;
  }
  else if (A == 1 && B == 3){
    cout << 2 << endl;
  }
  else if (A == 3 && B == 1){
    cout << 2 << endl;
  }
  else{
    cout << 1 << endl;
  }
}
  

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
int pro[1001];

int main(){
	int n, s[1001];
	while(scanf("%d", &n), n){
		double m = 0, t = 0;
		for(int i = 0;i < n;i++){
			scanf("%d", &s[i]);m += s[i];
		}m /= n;
		for(int i = 0;i < n;i++){
			t += (s[i] - m)*(s[i] - m);
		}t /= n;
		printf("%f\n", sqrt(t));
		}
	return 0;
}

Measured memory_bytes: 2652
N = int(input())

l = ["a"]

c = ["a","b","c","d","e","f","g","h","i","j"]

while N-1:
  new_l = []
  for item in l:
    s = len(set(list(item)))
    for i in range(s+1):
      new_l.append(item+c[i])
      
  l = new_l
  N -= 1
  
for item in l:
  print(item)

Measured memory_bytes: 56412
#include <iostream>
using namespace std;
using ll = long long;

int main() {
    ll X;
    int K;
    cin >> X >> K;

    ll r[K + 1];
    r[0] = 0;
    for (int i = 1; i <= K; ++i) {
        cin >> r[i];
    }

    pair<ll, ll> l[K + 1], u[K + 1];
    // l[i] = (潰されないaの下限値,
    //         a=下限値の場合, 時刻r[i]にてAに入っている砂の量)
    // rは上限

    l[0] = make_pair(0LL, 0LL);
    u[0] = make_pair(X, X);

    for (int i = 1; i <= K; ++i) {
        if (i % 2 > 0) {
            // A->Bへ砂が移る
            ll s = u[i - 1].second - (r[i] - r[i - 1]);
            if (s >= 0) {
                u[i] = make_pair(u[i - 1].first, s);
            } else {
                // aがどれだけ小さくても潰れる
                u[i] = make_pair(0, 0);
                l[i] = make_pair(0, 0);
                continue;
            }

            s = l[i - 1].second - (r[i] - r[i - 1]);
            if (s >= 0) {
                l[i] = make_pair(l[i - 1].first, s);
            } else {
                l[i] = make_pair(l[i - 1].first - s, 0);
            }
        } else {
            // B->Aへ砂が移る
            ll s = l[i - 1].second + (r[i] - r[i - 1]);
            if (s <= X) {
                l[i] = make_pair(l[i - 1].first, s);
            } else {
                // aがどれだけ大きくても潰れる
                l[i] = make_pair(X, X);
                u[i] = make_pair(X, X);
                continue;
            }

            s = u[i - 1].second + (r[i] - r[i - 1]);
            if (s <= X) {
                u[i] = make_pair(u[i - 1].first, s);
            } else {
                u[i] = make_pair(u[i - 1].first - (s - X), X);
            }
        }
    }

    int Q;
    cin >> Q;
    for (int q = 0; q < Q; ++q) {
        ll t, a;
        cin >> t >> a;

        // r[i] <= tなる最大のiを探る
        int ok = 0, ng = K + 1;
        while (ng - ok > 1) {
            int mid = (ok + ng) / 2;
            if (r[mid] <= t) {
                ok = mid;
            } else {
                ng = mid;
            }
        }

        // 時刻r[i]における砂の量を求める
        ll s = 0;
        if (a < l[ok].first) {
            s = l[ok].second;
        } else if (a > u[ok].first) {
            s = u[ok].second;
        } else {
            s = a - l[ok].first + l[ok].second;
        }

        // 時刻tにおける砂の量を限度無視で求める
        if (ok % 2 == 0) {
            s -= t - r[ok];
        } else {
            s += t - r[ok];
        }

        cout << max(0LL, min(s, X)) << endl;
    }
    return 0;
}


Measured memory_bytes: 5120
h, n  = map(int,input().split())
am = [list(map(int, input().split())) for i in range(n)] 

dp = [float('inf')]*(h+1)
dp[0] = 0
for i in range(1,h+1):
    dp_val = dp[i]
    for a, m in am:
        if a >= i:#overkill
            dp_val = min(dp_val, m)
        else:
            dp_val = min(dp_val, dp[i-a]+m)
    dp[i] = dp_val
print(dp[h])
    


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

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> vec(H, vector<char>(W));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> vec.at(i).at(j);
    }
  }
  vector<int> num_sharp_in_row(H);
  vector<int> num_sharp_in_column(W);
  for (int i = 0; i < vec.size(); i++) {
    for (int j = 0; j < vec.at(0).size(); j++) {
      if (vec.at(i).at(j) == '#') {
        num_sharp_in_row.at(i)++;
        num_sharp_in_column.at(j)++;
      }
    }
  }

  for (int i = 0; i < vec.size(); i++) {
    for (int j = 0; j < vec.at(0).size(); j++){
      if (num_sharp_in_row.at(i) == 0 || num_sharp_in_column.at(j) == 0){
        continue;
      }
      cout << vec.at(i).at(j);
    }
    cout << endl;
  }
}

Measured memory_bytes: 3632
import java.util.*;

public class Main {

    public static void main(String [] commandLineArgument){

        Scanner input = new Scanner(System.in);
        int n = input.nextInt() , m = input.nextInt();
        int answer = (m * (m - 1))/2;
        answer += (n * (n - 1))/2;
        System.out.println(answer);
        input.close();

    }

}



Measured memory_bytes: 23764
from collections import *
n = int(input())
a = [int(i) for i in input().split()]

b = deque()

b.append(a[0])
for i in range(1, n):
    if(i%2 == 1):
        b.append(a[i])  
    else:
        b.appendleft(a[i])
   

if(n % 2 == 0):
    b.reverse()
    

print(' '.join(map(str, b)))


Measured memory_bytes: 36144
using System;
using System.Linq;

namespace ConsoleApp4
{
    class Program
    {
        static void Main()
        {
            var str = Console.ReadLine().Split(' ');
            var N = int.Parse(str[0]);
            var X = int.Parse(str[1]);

            var m = new int[N];

            for (var i = 0; i < N; i++)
            {
                m[i] = int.Parse(Console.ReadLine());
            }

            var x = X - m.Sum();

            Console.WriteLine(N + x / m.Min());
            
        }

    }
}


Measured memory_bytes: 13268
import java.util.*

data class Query(val q: Int, val f: Int = 0, val c: String = "")

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val s = sc.next()
    val q = sc.nextInt()
    val queries = (0 until q).map {
        val q = sc.next().toInt()
        if (q == 1) Query(q) else Query(q, sc.nextInt(), sc.next())
    }
    println(problem158d(s, q, queries))
}

fun problem158d(s: String, q: Int, queries: List<Query>): String {
    val list = LinkedList<String>()
    list.add(s)
    var reverse = false
    for (i in 0 until q) {
        val qi = queries[i]
        if (qi.q == 1) {
            reverse = !reverse
        } else {
            if (qi.f == 1) {
                if (reverse) {
                    list.add(qi.c)
                } else {
                    list.add(0, qi.c)
                }
            } else {
                if (reverse) {
                    list.add(0, qi.c)
                } else {
                    list.add(qi.c)
                }
            }
        }
    }
    var sb: String = list.joinToString("")
    if (reverse) {
        sb = sb.reversed()
    }
    return sb
}

Measured memory_bytes: 122420
import sys
sys.setrecursionlimit(1000000)

while True:
  w, h = map(int, input().split())
  if w == 0:
    break

  mp = ["X" + input() + "X" for _ in range(h)]
  mp.insert(0, "X" * (w + 2))
  mp.append("X" * (w + 2))

  visited_w = [[False] * (w + 2) for _ in range(h + 2)]
  visited_b = [[False] * (w + 2) for _ in range(h + 2)]
  vec = ((0, 1), (0, -1), (1, 0), (-1, 0))
  def search(x, y, visited):
    for dx, dy in vec:
      nx, ny = x + dx, y + dy
      if not visited[ny][nx] and mp[ny][nx] == ".":
        visited[ny][nx] = True
        search(nx, ny, visited)
  
  for y in range(1, h + 1):
    for x in range(1, w + 1):
      if mp[y][x] == "W":
        search(x, y, visited_w)
      elif mp[y][x] == "B":
        search(x, y, visited_b)

  ans_w = ans_b = 0
  for y in range(1, h + 1):
    for x in range(1, w + 1):
      if visited_w[y][x] and not visited_b[y][x]:
        ans_w += 1
      elif not visited_w[y][x] and visited_b[y][x]:
        ans_b += 1

  print(ans_b, ans_w)



Measured memory_bytes: 6836
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        while(h != 0 && w != 0){
            for(int i=0;i<h;i++){
                for(int j=0;j<w;j++){
                    if((i + j) % 2 == 0 ){
                        System.out.print("#");
                    }else{
                        System.out.print(".");
                    }
                }
                System.out.println("");
            }
            System.out.println("");
            h = sc.nextInt();
            w = sc.nextInt(); 
        }
        sc.close();
    }
}


Measured memory_bytes: 34884
#include <bits/stdc++.h>
//#include <iostream>
//#include <cstdio>

#define repl(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) repl(i, 0, n)
#define MOD 1000000007
#define INF 2000000000

typedef long long ll;
typedef unsigned long long ull;
//typedef Pair<int,int> P;

using namespace std;

int main(void){
	int H,W;
	cin>>H>>W;
	rep(i,H){
		string s;
		cin>>s;
		cout<<s<<endl;
		cout<<s<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, k, n) for(int i = (k); i < (n); i++)
#define FORe(i, k, n) for(int i = (k); i <= (n); i++)
#define FORr(i, k, n) for(int i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(int i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using ll = long long;

const int INF = 1001001001;

int main(void){
  string s;
  cin >> s;
  int y = (s[0]-'0')*1000+(s[1]-'0')*100+(s[2]-'0')*10+(s[3]-'0');
  int m = (s[5]-'0')*10+(s[6]-'0');
  int d = (s[8]-'0')*10+(s[9]-'0');
  if((y == 2019 && m >= 5) || y > 2019) cout << "TBD" << endl;
  else cout << "Heisei" << endl;
  return 0;
}

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

#define Nmax 2005

using namespace std;

int N;
int A[Nmax];
int S;
bitset <2000002> dp[Nmax];

int main()
{
    cin >> N;
    for(int i = 1; i <= N; i++)
        cin >> A[i], S += A[i];
    dp[0][0] = 1;
    for(int i = 1; i <= N; i++)
        dp[i] = dp[i - 1] | (dp[i - 1] << A[i]);
    for(int j = S / 2; j >= 0; j--)
        if(dp[N][j])
        {
            cout << S - j << "\n";
            return 0;
        }
    return 0;
}


Measured memory_bytes: 490368
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define ub upper_bound
#define lb lower_bound
#define all(v) ((v).begin()),((v).end())
#define allr(v) ((v).rbegin()),((v).rend())
#define ff first
#define ss second
#define mp make_pair
#define pll pair<ll,ll> 
#define fo(i,n) for(ll i=0;i<n;i++)
#define foa(i,s,e) for(ll i=(s);i<e;i++)
#define fod(i,s,e) for(ll i= (s);i>=(e);i--)
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
#define sz(x) (ll)(x.size())
#define ANS cout<<ans<<'\n'
#define YES cout<<"YES\n"
#define NO cout<<"NO\n"
#define Yes cout<<"Yes\n"
#define No cout<<"No\n"
const ld pi = 3.14159265358979323846;
ll MOD = 1e9 + 7;
//ll MOD = 998244353;
const char nl = '\n';
const ll inf = 1e15;
#define fill(a,b) memset(a, b, sizeof(a))
#define setbits(x) __builtin_popcountll(x)
#define print2d(dp,n,m) fo(i, n){fo(j, m)cout<<dp[i][j]<<" ";cout<<"\n";}
ll nxt(){ll x; cin >> x; return x;}
ll mul(ll x,ll y){
    return (1ll* (x%MOD)*(y%MOD));
}
ll modpow(ll x,ll y){ll z=1;while(y>0){if(y%2)z=mul(z,x);x =mul(x,x) ;y/=2;}return z;}
ll power(ll x,ll y){ll z=1;while(y>0){if(y%2)z=z*x;x =x*x ;y/=2;}return z;}
ll gcd(ll a,ll b){if(a<b) return gcd(b,a);if(b==0) return a;return gcd(b,a%b);} 
ll min(ll a,ll b){if(a<b)return a;return b;}
ll max(ll a,ll b){if(a>b)return a;return b;}
ll sq(ll a){
    ll ans = (1ll*a*a);
    return ans;
}

void solve(){
    ll x, k, d;
    cin >> x >> k >> d;
    x = abs(x);
    if(x/d >= k){
        cout << x - k*d << nl;
        return;
    }  
    if(k % 2 == (x/d) % 2){
        cout << x%d << nl;
    }
    else{
        cout << d  - x%d << nl;
    }

}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("inputf.txt" , "r" , stdin) ;
    freopen("outputf.txt" , "w" , stdout) ;
    freopen("error.txt" , "w" , stderr) ;
    #endif
    
    ll TC = 1;
    //cin>>TC;
    while(TC--){
        solve();
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}


Measured memory_bytes: 3804
#include<stdio.h>
#include<math.h>
int main(){
  int n=0,i=0;
  int num[10000];
  int count=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&num[i]);
  }
  for(i=0;i<n;i++){
    if(Sosu(num[i])==2){
      count++;
    }
  }
  printf("%d\n",count);
  return 0;
}
int Sosu(int x){
  int i=0;
  if(x==2)return 2;
  if(x%2==0||x<2)return 1;
  
  for(i=3;i<=sqrt((double)x);i+=2){
    if(x%i==0)return 1;
  }
  return 2;
}



Measured memory_bytes: 2040
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define pb push_back
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f
#define MAXN 2*int(1e5)+5
#define endl '\n'
#define ll long long
#define f first
#define s second
#define FAST cin.tie(0), cout.tie(0), ios::sync_with_stdio(0)
#define debug(x) cout << "DEBUG " << x << endl
#define debug2(x, y) cout << "DEBUG " << x << " " << y << endl
#define debug3(x, y, z) cout << "DEBUG " << x << " " << y << " " << z<< endl
#define int long long
#define debug4(x, y, z, o) cout << "DEBUG " << x << " " << y << " " << z<< " " << o << endl
using namespace std;
typedef pair<ll, ll> pii;
typedef vector<vector<ll>> mat;
const ll mod = 1e9+7;

int32_t main() {
	int s, w;
	cin >> s >> w;
	cout << (w >= s ? "unsafe" : "safe") << endl;
}






Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <algorithm>
using namespace std;
 
typedef pair<int,int> P;
 
int main(){
    int N, Q;

    while( cin >> N >> Q, N || Q ){
        // m[name] := 和暦nameに対応する(和暦,西暦の最大)の組を返す.
        map<string, P> m;
        // v := 和暦の名前を保持
        vector<string> v;
         
        for(int i = 0 ; i < N ; i++ ){
            // name := 和暦の名前, y1 := 和暦, y2 := 西暦
            string name;
            int y1, y2;
             
            cin >> name >> y1 >> y2;
            if( m.count(name) ){
                if( m[name].second < y2 ){
                    m[name] = P(y1, y2);
                }
            }else{
                m[name] = P(y1, y2);
                v.push_back( name );
            }
        }
         
        for(int i = 0 ; i < Q ; i++ ){
            int q;
            cin >> q;
            
            // flag := 解が存在するかどうか.
            bool flag = false; 
            for(int j = 0 ; j < v.size() ; j++ ){
                int y1 = m[v[j]].first;
                int y2 = m[v[j]].second;
                
                // 和暦[1,y1] <=> 西暦[y2-y1+1, y2] と対応している.
                // 対応があるとき
                if( y2 - y1 + 1 <= q && q <= y2 ){ 
                    flag = true;
                    int ans = q - (y2 - y1);
                    // 解の出力
                    cout << v[j] << " " << ans << endl;
                    break;
                }
            }
            
            // 解が存在しないとき
            if( !flag ){
                cout << "Unknown" << endl;
            }
        }
    }
}

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

int main() {
  // 入力
  int A, B, C;
  cin >> A >> B >> C;

  string s =  "No";
  if (A == B) {
    if (A != C) {
      s = "Yes";
    }
  }
  if (B == C) {
    if ( B != A) {
      s = "Yes";
    }
  }
  
  if (A == C) {
    if ( A != B) {
      s = "Yes";
    }
  }
  
  // 出力
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using static System.Math;

class F
{
	static void Main()
	{
		var vs = new int[int.Parse(Console.ReadLine())].Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray()).ToArray();

		var d = vs.SelectMany((v, i) =>
		{
			var a = Atan2(v[1], v[0]);
			return new[] { new { i, isIn = true, a = a > -PI / 2 ? a - PI / 2 : a + 3 * PI / 2 }, new { i, isIn = false, a = a <= PI / 2 ? a + PI / 2 : a - 3 * PI / 2 } };
		})
		.GroupBy(_ => _.a).OrderBy(g => g.Key).ToDictionary(g => g.Key, g => g.ToArray());
		var vis = d.Where(p => p.Key > 0).SelectMany(p => p.Value.Where(_ => _.isIn)).Select(_ => _.i).ToList();

		var M = 0.0;
		foreach (var p in d)
		{
			foreach (var _ in p.Value)
			{
				if (_.isIn) vis.Add(_.i);
				else vis.Remove(_.i);
			}
			M = Max(M, SumNorm(vis.Select(i => vs[i]).ToArray()));
		}
		Console.WriteLine(M);
	}

	static double SumNorm(int[][] vs)
	{
		double x = vs.Sum(v => v[0]);
		double y = vs.Sum(v => v[1]);
		return Sqrt(x * x + y * y);
	}
}


Measured memory_bytes: 14164
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;

namespace MyProject
{
    class Program
    {
        static void Main(string[] args)
        {
#if Local
            var sw = new Stopwatch();
            sw.Start();
            Console.SetIn(new StreamReader("input.in"));
#endif

            var solver = new Solver();
            solver.Solve();
#if Local
            Console.WriteLine($"{sw.ElapsedMilliseconds}ms");
#endif
        }
    }

    class Solver
    {
        private bool Is1(string S)
        {
            foreach (var i in Enumerable.Range(0, S.Length / 2))
            {
                var left = S[i];
                var right = S[S.Length - 1 - i];
                if (left != right)
                {
                    return false;
                }
            }

            return true;
        }

        private bool Is2(string S)
        {
            foreach (var i in Enumerable.Range(0, S.Length / 2 / 2))
            {
                var left = S[i];
                var right = S[S.Length / 2 - 1 - i];
                if (left != right)
                {
                    return false;
                }
            }

            return true;
        }

        private bool Is3(string S)
        {
            foreach (var i in Enumerable.Range(0, S.Length / 2 / 2))
            {
                var left = S[S.Length / 2 + 1 + i];
                var right = S[S.Length - 1 - i];
                if (left != right)
                {
                    return false;
                }
            }

            return true;
        }

        public void Solve()
        {
            var S = Console.ReadLine();
            var answer = Is1(S) && Is2(S) && Is3(S) ? "Yes" : "No";
            Console.WriteLine(answer);
        }
    }
}


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

int main() {
  string s;
  int64_t k;
  cin >> s;
  cin >> k;
  int sl = s.size();

  char c;
  c = s.at(0);
  int x1=1;
  for (int i=1;i<s.size();i++) {
    if (c == s.at(i)) x1++;
  }
  
  if (x1 == s.size()) {
    int64_t tmp;
    tmp = ((int64_t)(s.size()) * k) / 2;
    cout << tmp;
  } else {

    vector <int64_t> aa(s.size());
    vector <int64_t> bb(s.size());

    char c;
    int last_i;
    last_i = 0;
    c = s.at(0);
    aa.at(0) = 1;
    for (int j = 1; j< s.size(); j++ ) {
      if (s.at(j) != c) {
        last_i++;
        c = s.at(j);
      }
      aa.at(last_i)++;
    }

  if ( s.at(0) == s.at(s.size()-1) ) {
    bb.at(0) = aa.at(0) / 2;
    for (int i=1; i<last_i; i++ ) {
      bb.at(i) = (aa.at(i)/2) * k; 
    }
    bb.at(last_i) = aa.at(last_i) / 2;
    bb.at(last_i+1) = ((aa.at(0) + aa.at(last_i)) / 2) * (k-1);
 } else {
    for (int i = 0; i < s.size(); i++) {
      bb.at(i) = (aa.at(i)/2) * k; 
    }
  }

  int64_t tmp;
  tmp = 0;
  for (int i = 0; i < s.size(); i++) {
    tmp = tmp + bb.at(i);
  }
  cout << tmp << endl;
    
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)

int main() {
	int n,m,ans=1,inf=1000000007;
	cin>>n;
	vector<int>a(n),zen,go;
	rep(i,n)cin>>a[i];
	rep(i,n){
	    if(i%2)zen.push_back(a[i]);
	    else go.push_back(a[i]);
	}
	int z=zen.size(),g=go.size();
	if(n%2==0){
	    rep(i,z){
	        cout<<zen[z-1-i]<<' ';
	    }
	    rep(i,g){
	        cout<<go[i]<<' ';
	    }
	}
	else{
	    rep(i,g){
	        cout<<go[g-1-i]<<' ';
	    }
	    rep(i,z){
	        cout<<zen[i]<<' ';
	    }
	}
	return 0;
}


Measured memory_bytes: 3956
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstring>
#define f(i,j,n) for(int i=j;i<=n;i++)
using namespace std;
int main()
{
	long long int a[4];
	for(int i=1;i<=3;i++)cin>>a[i];
	sort(a+1,a+3+1);
	if(a[1]%2==0||a[2]%2==0||a[3]%2==0)
	{
		cout<<0<<endl;
		return 0;
	}
	cout<<a[1]*a[2]<<endl;
	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10000000)
# input = sys.stdin.readline
from bisect import *
# from collections import *
# from heapq import *
# import functools
# import itertools
# import math
INF = 500000
MOD = 10**9+7

ps = []
is_p = [True] * 10**6
for i in range(2, 10**6):
    if is_p[i]:
        for j in range(i+i, 10**6, i):
            is_p[j] = False
        ps.append(i)
# print(ps)
print(ps[bisect_left(ps, int(input()))])


Measured memory_bytes: 14180
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  string s;
  cin >> s;
  ll n=s.size();
  map<char,ll> cnt;
  for(ll i=0;i<n;i++) {
    cnt[s[i]]++;
  }
  ll f=1;
  for(auto p:cnt) {
    if(p.second%2)f=0;
  }
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

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

using namespace std;

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

  int maxx=x;
  rep(i,n){
    int t;cin>>t;
    maxx=max(maxx,t);
  }

  int miny=y;
  rep(i,m){
    int t;cin>>t;
    miny=min(miny, t);
  }

  if(maxx<miny){
    cout<<"No War";
  }else{
    cout<<"War";
  }
  
  return 0;
}

Measured memory_bytes: 256
s = input().strip()

l = len(s)
s1 = s[0: (l - 1)//2]
s2 = s[(l + 3) // 2 - 1:]
if s == s[::-1] and s1 == s1[::-1] and s2 == s2[::-1]:
    print ('Yes')
else:
    print('No')


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

void add_zeros(int p) {
  int threshold = 10;
  while(threshold < 1000000) {
    if (p < threshold) {
      std::cout << "0";
    }
    threshold *= 10;
  }
}

void print_city_number(int p, int i) {
  add_zeros(p);
  std::cout << p;
  add_zeros(i);
  std::cout << i;
  std::cout << std::endl;
}

int main() {
  int a, b;
  std::cin >> a >> b;
  const int n = a;
  const int m = b;
  std::vector<std::vector<int>> cities(n);
  std::vector<int> prefectures;
  std::vector<int> years;
  for (int i = 0; i < m; ++i) {
    int p, y;
    std::cin >> p >> y;
    --p;
    cities[p].push_back(y);
    prefectures.push_back(p);
    years.push_back(y);
  }

  std::vector<std::map<int, int>> year_to_number(n);
  for(int c = 0; c < n; c++) {
    std::sort(cities[c].begin(), cities[c].end());
    for (int j = 0; j < cities[c].size(); ++j) {
      int y = cities[c][j];
      year_to_number[c].insert(std::pair<int, int>(y, j));
    }
  }
  for (int i = 0; i < m; ++i) {
    int p = prefectures[i];
    int y = years[i];
    int number = year_to_number[p][y];
    print_city_number(p + 1, number + 1);
  }
  return 0;
}


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

int main() {
  long long n;
  cin >> n;
  long long s=0;
  for(long long  i=1LL; i<=n; i++){
    if(i%3 != 0 && i%5 != 0){
      s+=i;
    }
  }
  cout << s << endl;
	return 0;
}


Measured memory_bytes: 3600
// 6/10
// 3-2-1. 尺取法
// 類題
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;

int main() {
    ll N, Q;
    cin >> N >> Q;
    vector<ll> a(N);
    vector<ll> x(Q);
    rep(i, N) cin >> a[i];
    rep(i, Q) cin >> x[i];

    rep(i, Q) {
        // ll over = 0;
        ll res = 0;
        // ll s = 0, t = 0, sum = 0;
        // while (true) {
        //     while (t < N && sum + a[t] <= x[i]) {
        //         sum += a[t++];
        //         // if (sum <= x[i]) {
        //         //     printf("OK: s, t, sum = %d, %d, %d\n", s, t, sum);
        //         //     res++;
        //         // }
        //         res++;
        //     }
        //     if (t == N) break;

        //     // over++;

        //     sum -= a[s++];
        // }

        ll right = 0;  // 初期設定
        ll sum = 0;

        for (ll left = 0; left < N; left++) {

            while (right < N && sum + a[right] <= x[i]) {
                sum += a[right];
                ++right;
            }

            res += right - left;

            if (right == left) ++right;
            else sum -= a[left];
        }

        cout << res << endl;
    }
}



Measured memory_bytes: 3536
K=int(input())
s=input().split(' ')
a=[int(s[i]) for i in range(len(s))]
n=len(s)

def solve():
	x,y=2,2
	for i in range(n-1,-1,-1):
		u=(x+a[i]-1)//a[i]
		v=y//a[i]
		if (a[i]*v<x): return -1,-1
		x=a[i]*u
		y=a[i]*(v+1)-1
	return x,y

x,y=solve()
if (x==-1): print(-1)
else: print('%d %d'%(x,y))

Measured memory_bytes: 63708
#include <bits/stdc++.h>
using namespace std;
const int INF = (1 << 30) - 1;
int main()
{
	int N;
	int minv = INF;
	cin >> N;
	for ( int i = 0; i < N; i++ ) {
		int A;
		int cnt = 0;
		cin >> A;
		while ( A % 2 == 0 ) {
			cnt++;
			A /= 2;
		}
		minv = min(minv, cnt);
	}
	cout << minv << endl;
	return ( 0 );
}


Measured memory_bytes: 256