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

long long MOD = 1e9 + 7;

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

    int n;
    cin >> n;

    vector<long long> A(n + 1, 0);
    for(int i = 2; i <= n; i++){
        int a = i, j = 2;
        while(a > 1){
            if(a % j) j++;
            else{
                a /= j;
                A[j]++;
            }
        }
    }

    long long ans = 1;
    for(int i = 2; i <= n; i++){
        ans = ((ans % MOD) * ((A[i] + 1) % MOD)) % MOD;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
s=input()
s1=s[0]+s[1]
s2=s[2]+s[3]
n1=int(s1)
n2=int(s2)
if 1<=n1<=12:
    if 1<=n2<=12:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if 1<=n2<=12:
        print('YYMM')
    else:
        print('NA')

Measured memory_bytes: 9092
#include <iostream>
#include <cstdio>
#define ll long long

using namespace std;
ll n, ans = 1e15;
int main()
{
	cin >> n;
	for(ll x = 1; x * x <= n; x++)
		if(n % x == 0)
	{
		ll y = n / x;
		ans = min(ans, x+y-2);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<tuple>


#define MOD 1000000007
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back

using namespace std;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){
    int N,H[100001];
    cin>>N;
    rep(i,0,N)cin>>H[i];
    H[0]=H[0]-1;

    bool ok=true;
    rep(i,1,N){
        if(H[i-1]<H[i]){
            H[i]--;
        }
        if(H[i-1]>H[i])ok=false;
    }
    if(ok)cout<<"Yes";
    else cout<<"No";
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std ; 
#define ll long long
typedef pair<ll,ll> pr;
typedef vector<ll> vc;
#define pb push_back
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repr(i,a,b) for(ll i=a;i>=b;i--)
#define reps(i,v) for(ll i=0;i<v.size();i++)
#define test  ll int tcase ; cin>>tcase ; while(tcase--) 
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int main(){
    io ; 
    string s,t ; 
    cin>>s>>t ; 
    int n = s.length() ;  
    if(t.substr(0,n)==s){
        cout<<"Yes\n" ; 
    }else{
        cout<<"No\n" ; 
    }
}



Measured memory_bytes: 3604
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		String[] ne = line.split(" ");
		
		BigDecimal aa = new BigDecimal(ne[0]);
		BigDecimal bb = new BigDecimal(ne[1]);
		BigDecimal CC = new BigDecimal(ne[2]);
		
		// Math.sin(CC);
		
		double a = aa.doubleValue();
		double b = bb.doubleValue();
		double C = CC.doubleValue();
		
		double sin = Math.sin(Math.toRadians(C));
		double cos = Math.cos(Math.toRadians(C));
		
		BigDecimal S = new BigDecimal(a*b*sin/2);
		BigDecimal L = new BigDecimal(a+b+Math.sqrt(a*a+b*b-2*a*b*cos));
		BigDecimal x = new BigDecimal("2");
		BigDecimal ax = new BigDecimal(a);		
		BigDecimal h = S.multiply(x).divide(ax, 5, BigDecimal.ROUND_HALF_UP);;

		System.out.println(S);
		System.out.println(L);
		System.out.println(h);
	}

}

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

typedef std::pair<int, int> ipair;
#define pb push_back
#define ff first
#define ss second
#define fr(i, j, k) for (int i = j; i < k; i++)
#define rf(i, j, k) for (int i = j; i >= k;i--)
#define int long long
#define ld long double
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(),x.rend()
#define mp make_pair

const int mod = 1000000007;
const ld pi = acos(-1);
const int maxn = 200006;

template<class T> ostream& operator <<(ostream &out,vector<T> &A){for(auto x:A) out<<x<<" ";return out;}
template <class T1,class T2>T1 powr(T1 a,T2 b){T1 res = 1;fr(i,1,b+1)res = res*a;return res;}
#define IOS  std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

// ans is number of distint prime factors of n plus 1 for including 1
// i.e no composite factor must be included in this array

int32_t main(){
  int A,B,ans=1;  cin>>A>>B;
  int n = __gcd(A,B);
  for(int i=2;i*i<=n;i++){
    if(n%i == 0){
      ans++;
      while(n%i==0) n/=i;
    }
  }
  if(n>1) ans++;
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstring>
#include<queue>
#include<vector>
#define WHITE 0
#define BLACK 1
#define GRAY 2
using namespace std;
const int MAXN = 10000 + 4;
const int INF = 0x3f3f3f3f;
int status[MAXN], d[MAXN];
int N;
vector< pair<int, int> > ADJ[MAXN];
void Dijkstra (  )
{
    priority_queue< pair<int, int> > PQ;
    memset( status, WHITE, sizeof(status) );
    for ( int i = 0; i < N; i++ ) d[i] = INF;
    d[0] = 0;
    status[0] = GRAY;
    PQ.push(make_pair(0, 0));

    while ( !PQ.empty() ) {
        pair<int, int> f = PQ.top(); PQ.pop();
        int u = f.second;
        status[u] = BLACK;

        if ( d[u] < f.first * (-1) ) continue;

        for ( int j = 0; j < ADJ[u].size(); j++ ) {
            int v = ADJ[u][j].first;
            if ( status[v] == BLACK ) continue;
            if ( d[v] > d[u] + ADJ[u][j].second ){
                d[v] = d[u] + ADJ[u][j].second;
                PQ.push(make_pair(d[v] * (-1), v));
                status[v] = GRAY;
            }
        }
    }
    for ( int i = 0; i < N; i++ ) {
        cout<<i<<' '<<( d[i] == INF ? -1 : d[i] )<<endl;
    }
}

int main()
{
    int u, D, c, v;
    cin>>N;
    for ( int i = 0; i < N; i++ ) {
        cin>>u>>D;
        for ( int j = 0; j < D; j++ ) {
            cin>>v>>c;
            ADJ[u].push_back(make_pair(v, c));
        }
    }

    Dijkstra();
    return 0;
}



Measured memory_bytes: 3344
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
p, pp, np = 0, -1, 0
for i in range(n):
    np = a[i]
    p += b[np - 1]
    if np == pp + 1:
        p += c[pp - 1]
    pp = np
print(p)


Measured memory_bytes: 3064
#include <cstdio>
#include <cstdlib>
#include <iostream>
using namespace std;
const int MAXN = 100100;
int n;
int head[MAXN], to[MAXN << 1], nxt[MAXN << 1], cnt;
inline void addedge(int u, int v) {
    to[++cnt] = v, nxt[cnt] = head[u], head[u] = cnt,
    to[++cnt] = u, nxt[cnt] = head[v], head[v] = cnt;
}
inline int dfs(int u, int v) {
    int res = 0, tmp = head[u];
    while(tmp) {
        if(to[tmp] != v) res ^= dfs(to[tmp], u) + 1;
        tmp = nxt[tmp];
    } return res;
}
int main() {
    int u, v;
    scanf("%d", &n);
    for(int i = 1; i < n; i++) {
        scanf("%d%d", &u, &v);
        addedge(u, v);
    } if(dfs(1, 0)) puts("Alice");
    else puts("Bob");
    return 0;
}

Measured memory_bytes: 4224
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SHIFT_LEFT(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
#define EPS 1e-15
using namespace std;
ll tab[11][11];
ll ans = 0;

string tos(ll num){
  string ret = "";
  for(int i = 0;i < 4; i++){
    ret += (char)(num % 10 + '0');
    num /= 10;
  }
  reverse(ALL(ret));
  return ret;
}

ll toint(string s){
  ll kake = 1;
  ll ret = 0;
  for(int i = s.size() - 1;i >= 0; i--){
    ret += kake * (s[i] - '0');
  }
  return ret;
}

ll checkdigit(string s){
  ll now = 0;
  for(int i = 0;i < 5; i++){
    now = tab[now][s[i] - '0'];
  }
  return now == 0;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  for(int i = 0;i < 10; i++){
    for(int j = 0;j < 10; j++){
      cin >> tab[i][j];
    }
  }

  for(int i = 0;i < 10000; i++){
    string s = tos(i);
    bool fl = true;
    ll cd = 0;
    for(int j = 0;j < 4; j++){
      cd = tab[cd][s[j] - '0'];
    }
    s += (char)(cd + '0');
    for(int j = 0;j < 5; j++){
      string cs = s;
      for(int k = 0;k < 10; k++){
	if(s[j] == (k + '0'))continue;
	cs[j] = (char)(k + '0');
	if(checkdigit(cs)){
	  fl = false;
	}
      }
    }
    for(int j = 0;j < 4; j++){
      string cs = s;
      if(cs[j] == cs[j+1])continue;
      char tmp = cs[j];
      cs[j] = cs[j+1];
      cs[j+1] = tmp;
      if(checkdigit(cs)){
	fl = false;
      }
    }
    if(fl == false){
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3228
#include<iostream>
using namespace std;
int a, b, n;
long long smin, smax;
int main(){
    cin>> n >> a >> b;
    smin = b + (n - 1) * 1LL * a;
    smax = a + (n - 1) * 1LL * b;
    cout<< max(0LL, smax - smin + 1);
}


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

vector<pair<char, int>> runLength(string x)
{
	char now = x[0];
	int count = 1;
	vector<pair<char, int>> ret;
	for (int i = 1; i < x.size(); ++i)
	{
		if(x[i] != now)
		{
			ret.push_back(make_pair(now, count));
			now = x[i];
			count = 1;
		}
		else
		{
			++count;
		}
	}
	ret.push_back(make_pair(now, count));
	return ret;
}

int main()
{
	string in;
	cin >> in;
	auto re = runLength(in);
	int res[100001] = {};
	int count = 0;
	for (int i = 0; i < re.size() - 1; i += 2)
	{
		res[count + re[i].second-1] = 1 + (re[i].second-1) / 2 + re[i+1].second / 2;
		res[count + re[i].second] = 1 + re[i].second / 2 + (re[i+1].second-1)/2;
		count += re[i].second + re[i + 1].second;
	}
	for (int i = 0; i < in.size(); ++i)
	{
		cout << res[i] << " ";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 1908
#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1);

int main(){
	int n, m;
	cin >> n >>m;
	int s = 0;
	for(int i = 1; i <= m; i++){
		int x;
		cin >> x;
		s += x;
	}
	if(s <= n) printf("%d\n", n - s);
	else printf("%d\n", -1);
	return 0;
}

Measured memory_bytes: 3748
#include <iostream>
#include <sstream>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long Int;

int main() {
    Int ans = 0;
    string s;
    while (getline(cin, s)) {
        rep (i, s.size()) if (!isdigit(s[i])) s[i] = ' ';
        istringstream sin(s);
        Int a;
        while (sin >> a) ans += a;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 0
a, b, c, x = map(int, [input() for i in range(4)])
count = 0
for i in range(a + 1):
    for j in range(b + 1):
        for k in range(c + 1):
            if 500 * i + 100 * j + 50 * k == x:
                count += 1
print(count)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <stdio.h>
using namespace std;
typedef long long ll;

#define REP(i, n) for(ll i = 0; i < (n); i++)

int A[30], m[220];
int ans[(1<<20)+100];
int n;
bool check(int m1)
{
    ll asum;
    for(ll b = 0; b < (1<<n); b++) {
        if(ans[b] == -1) {
            asum = 0;
            REP(i, n) {
                if(b & (1 << i)) {
                    asum += A[i];
                }
            }
            ans[b] = asum;
        } else {
            asum = ans[b];
        }
        if(asum == m1) return true;
    }
    return false;
}


int main(void) 
{
    REP(i, (1<<20)+1) ans[i] = -1;
    cin >> n;
    REP(i, n) cin >> A[i];
    int q;
    cin >> q;
    REP(i, q) cin >> m[i];

    REP(i, q) {
        if(check(m[i])) {
            cout << "yes" << endl;
        } else {
            cout << "no" << endl;
        }
    }
}



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

using namespace std;

int n,c[500], s[500], f[500];

void solve(int x) {
	int t = 0;
	for (int i = x; i < n-1; i++) {
		if (t < s[i])t = s[i];
		while (t%f[i] != 0)t++;
		t += c[i];
	}
	cout << t << endl;
}

int main() {
	cin >> n;
	for (int i = 0; i < n-1; i++)cin >> c[i] >> s[i] >> f[i];
	for (int i = 0; i < n-1; i++)solve(i);
	cout << 0 << endl;
	return 0;
}


Measured memory_bytes: 256
n,m = map(int,input().split())
a = [0]*m
b = [0]*m
for i in range(m):
  a[i], b[i] = map(int,input().split())

d = [0]*(n+1)
for i in range(1,n+1):
  d[i] = i
  
s = [0] + [1]*n

g=[ [0] ]*(n+1)
for i in range(1,n+1):
  g[i] = [i]
g[0] = []
#print(g)
#quit()

c = n*(n-1)//2
ans = []
ans.append(c)

for i in range(1,m)[::-1]:
  x = d[a[i]]
  y = d[b[i]]
  x,y = max(x,y),min(x,y)
  if x == y:
    ans.append(c)
    continue
  c -= s[x]*s[y]
  #print(c, "x")
  ans.append(c)
  s[x] += s[y]
  #s[y] = 0
  for i in g[y]:
    d[i] = x
  g[x] += g[y]
  #g[y] = []
for t in ans[::-1]:
  print(t)
  

Measured memory_bytes: 40548
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
    ll n;
    cin>>n;
    ll fac=1ll;
    for(ll i=1ll;i<=n;i++){
        fac=(fac*i)%mod;
    }
    string s;
    cin>>s;
    char B='B',W='W';
    
    ll num=0;
    ll tmp=1;
    for(ll i=0;i<(2*n);i++){
        if(s[i]==B){
            if(num%2==0){
                num++;
            }
            else{
                tmp=(tmp*num)%mod;
                num--;
            }
        }
        else{
            if(num%2==0){
                tmp=(tmp*num)%mod;
                num--;
            }
            else{
                num++;
            }
        }
        if(num<0){
            cout<<0<<endl;return 0;
        }
    }
	if(num==0)
    cout<<(fac*tmp)%mod<<endl;
	else
	cout<<0<<endl;
    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define ll long long
using namespace std;

const ll mod = 1e9 + 7;

ll C[2005][2005];
ll dp[100005][13];

int main(){
    int A,B,N,a = 1,ans=0;
    cin >> N;
    while(a <= N){
        if(10 > a || (1000 > a && a >= 100) || (100000 > a && a >=10000) )ans ++;
        a++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        long K = sc.nextLong();
        sc.close();

        if(N % K == 0){
            System.out.println("0");
        }else{
            long tmp1 = N / K;
            long tmp2 = tmp1 + 1;
            long a = Math.abs(N - K * tmp1);
            long b = Math.abs(N - K * tmp2);
            System.out.println(Math.min(a, b));
        }
    }
}


Measured memory_bytes: 21844
#include <stdint.h>
#include <algorithm>
#include <bitset>
#include <functional>
#include <iostream>
#include <string>
#include <vector>

std::vector<int> nums;

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

  std::cin >> N;

  for (int i = 0; i < N; i++) {
    int v;
    std::cin >> v;
    nums.push_back(v);
  }

  int maxDiff = -1000000000;
  int kmax = nums[N - 1] - 1;
  for (int k = N - 1; k >= 0; k--) {
    if (nums[k] <= kmax) continue;
    kmax = nums[k];
    for (int p = k - 1; p >= 0; p--) {
      if (nums[k] - nums[p] > maxDiff) {
        maxDiff = nums[k] - nums[p];
      }
    }
  }
  std::cout << maxDiff << std::endl;

  return 0;
}

Measured memory_bytes: 3868
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<algorithm>
#include<cmath>
#include<bitset>

#define Vsort(a) sort(a.begin(), a.end())
#define Vreverse(a) reverse(a.begin(), a.end())
#define Srep(n) for(int i = 0; i < (n); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define Lrep(i,a,n) for(int i = (a); i < (n); i++)
#define Brep(n) for(int bit = 0; bit < (1<<n); bit++)
#define rep2nd(n,m) Srep(n) Lrep(j,0,m)
#define vi vector<int>
#define vi64 vector<int64_t>
#define vvi vector<vector<int>>
#define vvi64 vector<vector<int64_t>>

using namespace std;

int count(int n){
    int ans = 1;
    for (int i = 2; i <= sqrt(n); i++) {
    int cnt = 0;
    while (n % i == 0) {
       cnt++;
        n /= i;
    }
    ans *= (cnt + 1);
    if (n == 1) break;
    }
    if (n != 1) ans *= 2;
    return ans;
}

int main(){
    int n;
    cin >> n;
    vi dp(n-1);
    dp[0] = 1;
    Lrep(i,1,n-1){
        int m = count(i+1);
        dp[i] = dp[i-1] + m;
    }
    cout << dp[n-2] << endl;
}

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

char A[100],B[100],C[100];

int main()
{
    scanf(" %s%s%s",A,B,C);
    if(A[strlen(A) - 1] == B[0] && B[strlen(B) - 1] == C[0])
    {
        printf("YES\n");
    }
    else
    {
        printf("NO\n");
    }
    return 0;
}


Measured memory_bytes: 256
// さっきのfmt.Scanをbufio.Scanにした版
// 変えただけで爆速になってて草
//
// 参考: https://atcoder.jp/contests/abc158/submisscons/10628064
// paihuさんありがとうございました。

package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, 0), 1e6)
	sc.Split(bufio.ScanWords)

	sc.Scan()
	var str []byte = []byte(sc.Text())
	sc.Scan()
	psNum, _ := strconv.Atoi(sc.Text())

	var flontStr []byte = make([]byte, 0)
	var reverse bool = false

	for i := 0; i < psNum; i++ {
		sc.Scan()
		T, _ := strconv.Atoi(sc.Text())

		switch T {
		case 1:
			reverse = !reverse
		case 2:
			sc.Scan()
			F, _ := strconv.Atoi(sc.Text())
			sc.Scan()
			var addChar []byte = []byte(sc.Text())

			switch F {
			case 1:
				if reverse {
					str = append(str, addChar...)
				} else {
					flontStr = append(flontStr, addChar...)
				}
			case 2:
				if reverse {
					flontStr = append(flontStr, addChar...)
				} else {
					str = append(str, addChar...)
				}
			}
		}
	}

	flontStr = reverseSlice(flontStr)

	flontStr = append(flontStr, str...)

	if reverse {
		flontStr = reverseSlice(flontStr)
	}

	fmt.Println(string(flontStr))
}

// reverseSlice はbyte型のスライスを逆並びにして返す関数
func reverseSlice(tByte []byte) []byte {
	for i, j := 0, len(tByte)-1; i < j; i, j = i+1, j-1 {
		tByte[i], tByte[j] = tByte[j], tByte[i]
	}
	return tByte
}


Measured memory_bytes: 3840
#include <bits/stdc++.h>
#define drep(i,cc,n) for(int i=(cc);i<=(n);++i)
#define rep(i,n) drep(i,0,n-1)
#define drrep(i,cc,n) for(int i=(cc);i>=(n);--i)
#define rrep(i,n) drrep(i,0,n-1)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,v.size())if(i==0)cout << v[i];else cout << " " << v[i]; cout << endl;
#define arrprint(v,n) rep(i,n)if(i==0)cout << v[i];else cout << " " << v[i]; cout << endl;
#define matprint(v,n,m) rep(i,n){rep(j,m){cout << v[i][j] << " ";}cout << endl;}
#define SORT(v) sort(v.begin(), v.end())
#define REV(v) reverse(v.begin(), v.end())
using namespace std;
const int mod=1000000007;
const int INF=1001001001;
using ll = long long;
using P = pair<int,int>;
template<typename T>
using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>; //小さいものから取り出す

int d;
vector<int> c(26);
vector<vector<int>> s;
vector<int> t, now;
vector<int> last(26, -1);
ll best = 0;

ll score(){
    ll res = 0;
    rep(i,26)last[i] = -1;
    rep(i,d){
        res += s[i][now[i]];
        last[now[i]] = i;
        rep(j,26) res -= c[j] * (i - last[j]);
    }
    return res;
}

int main(){
    random_device seed;
    mt19937 mt(seed());
    uniform_int_distribution<int> rnd1(0,25);

    cin >> d;
    uniform_int_distribution<int> rnd2(0,d-1);
    rep(i,26) cin >> c[i];
    s.resize(d);
    rep(i,d)s[i].resize(26);
    rep(i,d)rep(j,26) cin >> s[i][j];
    t.resize(d);now.resize(d);
    rep(i,d){now[i] = i%26;t[i] = now[i];}
    best = score();
    ll now_s;
    rep(__,10){
        rep(i,d)now[i] = rnd1(mt);
        now_s = score();
        if(best < now_s){
            best = now_s;
            rep(j,d)t[j] = now[j];
        }        
        rep(_,500){
            // cout << best << endl;
            // rep(i,d)now[i] = rnd1(mt);
            int choice = rnd2(mt);
            rep(i,26){
                now[choice] = i;
                now_s = score();
                if(best < now_s){
                    best = now_s;
                    rep(j,d)t[j] = now[j];
                }
            }
        }
    }

    // cout << score() << endl;
    rep(i,d)cout << t[i]+1 << endl;

    return 0;
}

Measured memory_bytes: 3692
#define _USE_MATH_DEFINES
#include<iostream>
#include<fstream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<climits>
#include<set>
#include<map>
#include<cmath>
#include<iomanip>
#include<iterator>
#include<queue>
#include<stack>
#include<cctype>
#include<deque>
#include<time.h>
#include<bitset>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<sstream>
#include<random>
#include<numeric>

//by Skeef79

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

#pragma warning(disable : 4996)
#pragma comment(linker, "/STACK:16777216")
#define pb push_back
#define en '\n'
#define for0(i,n) for(int i = 0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define vec vector
#define pii pair<int,int>
#define pll pair<ll,ll>
#define what_is(x) cout<<#x<<" is "<<x<<en;

using namespace std;

const int INF = 2000000000;
const ll LINF = 2000000000000000000;

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;
	}
}

template <typename T> void input(vector<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cin >> a[i];
}

template<typename T> void input(deque<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cin >> a[i];
}

template<typename T> void input(vector<vector<T>>& a)
{
	for (int i = 0; i < a.size(); i++)
		for (int j = 0; j < a[i].size(); j++)
			cin >> a[i][j];
}

void solve()
{
	int n, m, k;
	cin >> n >> m>>k;
	vector<vector<char>>inp(n, vector<char>(m));
	input(inp);
	vector<vector<int>>a(n, vector<int>(m));
	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++)
			a[i][j] = inp[i][j] - '0';

	int N = (1 << (n - 1));
	int ans = n * m+1;

	for (int mask = 0; mask < N; mask++)
	{
		vector<int>t;
		int sz = 0;
		int cur = 0;
		int tek_ans = 0;

		for (int i = 0; i < n; i++)
			if (mask&(1 << i))
				tek_ans++;

		for (int i = 0; i < n; i++)
		{
			cur += a[i][0];
			if (mask&(1 << i))
			{
				t.pb(cur);
				cur = 0;
			}
		}

		t.pb(cur);

		sz = t.size();
		for (auto to : t)
			if (to > k)
				continue;
		bool bad = false;

		for (int j = 1; j < m; j++)
		{
			cur = 0;
			int tek = 0;
			vector<int> last = t;
			for (int i = 0; i < n; i++)
			{
				cur += a[i][j];
				if (mask&(1 << i))
				{
					t[tek]+= cur;
					tek++;
					cur = 0;
				}
			}
			t[tek]+= cur;

			for(auto to:t)
				if (to > k)
				{
					tek_ans++;
					for (int i = 0; i < t.size(); i++)
						t[i] -= last[i];
				}
			for (auto to : t)
				if (to > k)
				{
					bad = true;
					break;
				}
		}
		if (bad)
			continue;
		else
			ans = min(ans, tek_ans);
	}
	cout << ans;
}

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

#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
#endif

	int tst = 1;
	//cin >> tst;
	while (tst--)
		solve();
}

Measured memory_bytes: 384
#include <cstdio>
#include <stack>
#include <set>
#include <cmath>
#include <map>
#include <time.h>
#include <vector>
#include <iostream>
#include <string>
#include <algorithm>
#include <memory.h>
#include <cstdlib>
#include <queue>
#define P pair<int, int>
#define LL long long
#define LD long double
#define PLL pair<LL, LL>
#define mset(a, b) memset(a, b, sizeof(a))
#define PI acos(-1.0)
#define random(x) rand() % x
using namespace std;
const int inf = 0x3f3f3f3f;
const LL __64inf = 0x3f3f3f3f3f3f3f3f;
const int MAX = 2e5;
const int Mod = 1e9 + 7;

int main()
{
    int a[4];
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a+3);
    cout << a[0] + a[1] << endl;
    return 0;
}

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

using namespace std;

int main()
{
	int N, M;
	cin >> N >> M;
	vector<int> X(M, 0);
	for (int i = 0; i < M; i++) {
		cin >> X[i];
	}
	if (N >= M) {
		cout << 0 << endl;
		return 0;
	}
	sort(X.begin(), X.end());
	vector<pair<int, int>> D(M);
	D[0] = make_pair(0, 0);
	for (int i = 1; i < M; i++) {
		D[i] = make_pair(i, X[i] - X[i-1]);
	}
	sort(D.begin(), D.end(), [](const pair<int, int>& x, const pair<int, int>& y){ return x.second > y.second; });
	sort(D.begin(), D.begin()+(N-1), [](const pair<int, int>& x, const pair<int, int>& y){ return x.first < y.first; });
	int ans = 0;
	int index = 0;
	for (int i = 0; i < N-1; i++) {
		ans += X[D[i].first-1] - X[index];
		index = D[i].first;
	}
	ans += X[M - 1] - X[index];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
vector<vector<int> > adj1;
vector<vector<int> > adj2;
vector<int> visited1;
vector<int> visited2;
void dfs(int s,int parity)
{
    if(parity==0)
    {
        visited1[s]=1;
        for(auto it:adj1[s])
        {
            if(!visited2[it])
            {
                dfs(it,parity^1);
            }
        }
    }
    else
    {
        visited2[s]=1;
        for(auto it:adj2[s])
        {
            if(!visited1[it])
            dfs(it,parity^1);
        }
    }
    
}
int main()
{
    int n,m;
    cin>>n>>m;
    adj1.resize(n+1);
    visited1.resize(n+1);
    adj2.resize(m+1);
    visited2.resize(m+1);
    for(int i=1;i<=n;i++)
    {
        int k;
        cin>>k;
        for(int j=0;j<k;j++)
        {
            int x;
            cin>>x;
            adj2[x].push_back(i);
            adj1[i].push_back(x);
        }
    }
    dfs(1,0);
    for(int i=1;i<=n;i++)
    {
        if(!visited1[i])
        {
            cout<<"NO";
            return 0;
        }
    }
    cout<<"YES"<<endl;
}

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

using ll = long long;

int main(){
	ll i, o, t, j, l, s, z;
	cin >> i >> o >> t >> j >> l >> s >> z;
	ll rez = 2*(i/2) + 2*(j/2) + 2*(l/2) + o;
	if(i && j && l) rez = max(rez, 3ll + 2ll * ((i-1)/2) + 2ll * ((j-1)/2) + 2ll * ((l-1)/2) + o);
	cout << rez << endl;
	return 0; }


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <set>
#include <map>
using namespace std;
int main() {
	char a, b;
	cin >> a >> b;
	if (a > b) {
		cout << ">" << endl;
	}
	else if (a == b) {
		cout << "=" << endl;
	}
	else { cout << "<" << endl; }
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int x, y;
  scanf("%d%d", &x, &y);
  if (x%3 == 0){
    printf("Possible\n");
  }else if(y%3 == 0){
    printf("Possible\n");
  }else if ((x+y)%3 == 0){
    printf("Possible\n");
  }else{
    printf("Impossible\n");
  }
  return 0;
}

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

int main(){
    long long n,m;
    cin >> n >> m;
    if(n == 1 && m == 1){
        cout << 1 << endl;
    }
    else if(n == 1){
        cout << m - 2 << endl;
    }
    else if(m == 1){
        cout << n -2 << endl;
    }
    else{
        cout << (m-2)*(n-2) << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
#define vvec vector<vector<ll>>
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
const int mod = 1000000007;
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll c(ll n, ll k) { ll a = 1; rep(i, 1, k) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; }

#define COMB_MAX (int)50000 + 10
ll f[COMB_MAX], rf[COMB_MAX];
ll inv(ll x) {
	ll res = 1;
	ll k = mod - 2;
	ll y = x;
	while (k) {
		if (k & 1) res = (res * y) % mod;
		y = (y * y) % mod;
		k /= 2;
	}
	return res;
}
void init() {
	f[0] = 1;
	rep(i, 1, COMB_MAX) f[i] = (f[i - 1] * i) % mod;
	rep(i, 0, COMB_MAX) rf[i] = inv(f[i]);
}
//---------------------------------------------------------------------------------------------------
ll C(int n, int k) {
	if (k<0 || k>n || n < 0)return 0;
	ll a = f[n]; // = n!
	ll b = rf[n - k]; // = (n-k)!
	ll c = rf[k]; // = k!

	ll bc = (b * c) % mod;

	return (a * bc) % mod;
}
int main() {
	int n, k;
	cin >> n >> k;
	init();
	rep(i, 1, k + 1) {
		ll r = C(n - k + 1, i) * C(k - 1, i - 1);
		printf("%lld\n", r % mod);
	}
	return 0;
}

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

int main(){
  int n,x,y,count,ls;
  ls=0;
  count=0;
  cin >> n ;
  
  for(int i=0; i<n; i++){
    cin >> x>> y;
    if(x==y){
      count++;
      if(count>=3){
        ls=3;
      }
    }
    else{
      count=0;
    }
    

  }
    if(ls>=3){
  cout << "Yes" << endl;
}
    else{
      cout << "No" << endl;
}
  }

Measured memory_bytes: 3632
import java.util.*;
import java.lang.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int ans = 0;
        for (int i = 1; i * i <= m; i++) {
            if (m % i == 0) {
                if (m / i <= m / n) {
                    ans = Math.max(ans, m / i);
                } else if (i <= m / n) {
                    ans = Math.max(ans, i);
                } else {
                    break;
                }
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 23380
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<algorithm>
#include<utility>
using namespace std;
typedef double du;
typedef pair<du,int> pr;
int a[40010],b[40010],c[40010],n;
pr p[40010];
du v[40010];
int s[40010],M;
int lowbit(int x){return x&-x;}
void modify(int x){
	while(x<=M){
		s[x]++;
		x+=lowbit(x);
	}
}
int query(int x){
	int s=0;
	while(x){
		s+=::s[x];
		x-=lowbit(x);
	}
	return s;
}
int get(int*a,int*b,du k){
	int i,x,t,res;
	for(i=1;i<=n;i++)p[i]=pr(-a[i]/(du)b[i],i);
	sort(p+1,p+n+1);
	for(i=1;i<=n;i++)v[i]=(-a[i]*k+c[i])/b[i];
	sort(v+1,v+n+1);
	M=unique(v+1,v+n+1)-v-1;
	memset(s,0,(M+1)<<2);
	res=0;
	for(i=1;i<=n;i++){
		x=p[i].second;
		t=lower_bound(v+1,v+M+1,(-a[x]*k+c[x])/b[x])-v;
		res+=query(t);
		modify(t);
	}
	return res;
}
int main(){
	int i,k;
	du l,r,mid;
	scanf("%d",&n);
	for(i=1;i<=n;i++)scanf("%d%d%d",a+i,b+i,c+i);
	k=(n*(n-1)/2+1)/2;
	l=-2e8;
	r=2e8;
	for(i=0;i<100;i++){
		mid=(l+r)*.5;
		if(get(a,b,mid)>=k)
			r=mid;
		else
			l=mid;
	}
	printf("%.11lf",l);
	l=-2e8;
	r=2e8;
	for(i=0;i<100;i++){
		mid=(l+r)*.5;
		if(get(b,a,mid)>=k)
			r=mid;
		else
			l=mid;
	}
	printf(" %.11lf",l);
}

Measured memory_bytes: 1664
#include <iostream>
#include <set>
using namespace std;
int main()
{
  int n;
  cin >> n;
  set<int> S;
  for(int i=0; i<n; i++){
    int j;
    cin >> j;
    S.insert(j);
  }
  int q;
  cin >> q;
  int count = 0;
  for(int i=0; i<q; i++){
    int j;
    cin >> j;
    if(S.find(j) != S.end()) count++;
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 1236
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <vector>
using namespace std;

// 入出力
void print() { std::cout << '\n'; }
template <class T>void print(const T &x) {std::cout << x <<'\n';}
template <class T, class... Args>void print(const T &x, const Args &... args) {std::cout << x << " ";print(args...);}

void solve(long long x, long long a, long long b){
    if (abs(x - a) < abs(x - b)) print('A');
    else print('B');
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long x;
    scanf("%lld",&x);
    long long a;
    scanf("%lld",&a);
    long long b;
    scanf("%lld",&b);
    solve(x, a, b);
    return 0;
}


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

int a, b, c, d;
string str, ans;

void dfs(int i, string cur, int val) {
  if (i == 0) {
    dfs(i + 1, cur + "+" + to_string(b), val + b);
    dfs(i + 1, cur + "-" + to_string(b), val - b);
  }
  else if (i == 1) {
    dfs(i + 1, cur + "+" + to_string(c), val + c);
    dfs(i + 1, cur + "-" + to_string(c), val - c);
  }
  else if (i == 2) {
    dfs(i + 1, cur + "+" + to_string(d), val + d);
    dfs(i + 1, cur + "-" + to_string(d), val - d);
  }
  else if (i == 3) {
    if (val == 7) {
      ans = cur;
    }
  }
}

int main(void){
    // Here your code !
    cin >> str;
    a = (int)str[0] - 48;
    b = (int)str[1] - 48;
    c = (int)str[2] - 48;
    d = (int)str[3] - 48;

    dfs(0, to_string(a), a);
    cout << ans + "=7"<< endl;

    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	sum := 0
	for i := 0; i < n; i++ {
		var v int
		fmt.Scan(&v)
		for v%2 == 0 {
			sum++
			v /= 2
		}
	}
	fmt.Println(sum)
}


Measured memory_bytes: 1280
#include <cstdio>
#include <string>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <map>
#include <vector>

using namespace std;
#define ASCII 48

int main() {
	int a, b, c;
	cin >> a >> b >> c;

	int res = a - b;
	c -= res;

	if (c < 0)c = 0;
	cout << c << endl;


	return 0;
}


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

using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define reps(i, m, n) for (int i = m; i <= n; ++i)

using i64 = long long;
using pii = pair<i64, i64>;

template<class A, class B>inline bool chmax(A &a, const B &b){return b > a ? a = b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b < a ? a = b,1 : 0;}

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

i64 power(i64 x, i64 n, i64 M) {
  if (!n) return 1;
  if (n % 2 == 0) {
    i64 t = power(x, n / 2, M);
    return t * t % M;
  }
  return x * power(x, n - 1, M) % M;
}

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

  i64 n, p;
  cin >> n >> p;

  bool alleven = true;
  i64 a;
  rep(i, n) {
    cin >> a;
    if (a % 2 != 0) alleven = false;
  }

  if (alleven) {
    if (p == 0) cout << (i64)pow(2, n) << "\n";
    if (p == 1) cout << 0 << "\n";
  }

  else {
    cout << (i64)pow(2, n-1) << "\n";
  }

  return 0;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  if (a < b) {
    cout << "a < b" << endl;
  }
  else if (a > b) {
    cout << "a > b" << endl;
  }
  else {
    cout << "a == b" << endl;
  }
}


Measured memory_bytes: 3116
#include<stdio.h>
int k[251];

int Parent(int i){
  return k[i/2];
}

int Left(int i){
  if(i*2>=251)
    return -(1<<29);
  return k[2*i];
}

int Right(int i){
  if(i*2+1>=251)
    return -(1<<29);
  return k[2*i+1];
}

main(){

  int size,i;
  for(i=0;i<251;i++)
    k[i]=-(1<<29);


  scanf("%d", &size);
  for(i=1;i<=size;i++)
    scanf("%d", &k[i]);

  for(i=1;i<=size;i++){
    printf("node %d: key = %d, ", i, k[i]);
    if(Parent(i)!=-(1<<29))
      printf("parent key = %d, ", Parent(i));
    if(Left(i)!=-(1<<29))
      printf("left key = %d, ", Left(i));
    if(Right(i)!=-(1<<29))
      printf("right key = %d, ", Right(i));
    printf("\n");
    }

  return 0;

}

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

using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	int c = a * b;
	if (c % 2 == 1) {
		cout << "Odd" << endl;
	}
	else {
		cout << "Even" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		switch (N) {
			case 1:
				sc.close();
				System.out.println("Hello World");
				break;	
			case 2:
				int A = sc.nextInt();
				int B = sc.nextInt();
				sc.close();
				System.out.println(A + B);
				break;
			default:
				break;
		}
	}
}

Measured memory_bytes: 21332
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
#include<sstream>
using namespace std;
typedef long long LL;
const int INF = 0x3f3f3f3f;

int main()
{
    string a,b;
    cin >> a >> b;
    cout << b + a << endl;
    //system("pause");
    return 0;
}

Measured memory_bytes: 256
using namespace std;
#include<iostream>
#include<algorithm>
#include<ctime>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<iomanip>
#include<numeric>
#include<queue>
#include<functional>
#include<tuple>
#include<math.h>
#include<bitset>
#include<stack>
#include<set>
#include<random>
#include<stdlib.h>
#define rip(i,n) for(ll i=0;i<n;i++)
#define Rip(i,n) for(int i=1;i<n;i++)
#define ll long long
#define ld long double
#define pi 3.1415926535897932384626433832795028841971693993
#define ee 2.718281828459045
#define mod 1000000007
#define MOD mod
#define sec setprecision
using namespace std;
ll gcd(ll a, ll b) {
	if (a % b == 0)	return(b);
	else return(gcd(b, a % b));
}
ll lcm(ll a, ll b)
{
	return a * b / gcd(a, b);
}
int ketasuu(ll h) {
	if (h < 0)return(-(ketasuu(-h)));
	else if (h < 10)return(1);
	else return(1 + ketasuu(h / 10));
}
const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
void cominit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (ll i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}
vector<ll> soinnsuubunnkai(ll n) {
	vector<ll>a;
	while (n % 2 == 0) {
		a.push_back(2);
		n /= 2;
	}
	ll f = 3;
	while (f * f <= n) {
		if (n % f == 0) {
			a.push_back(f);
			n /= f;
		}
		else f += 2;
	}
	if (n != 1)
		a.push_back(n);
	return(a);
}
// 二項係数計算
long long com(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
ll pow(ll a, ll b) {
	a = a % mod;
	if (b == 0)return(1);
	else if (b % 2 == 0)return(pow((a * a)%mod, b / 2));
	else return(a * (pow(a, b - 1)));
}
void solve() {
	
}
int main() {
	int n;
	cin >> n;
	int mainasu = 0;
	vector<int>a(n);
	int mi = 1000000000;
	ll sum = 0;
	rip(i, n) {
		cin >> a[i];
		mi = (min(mi, abs(a[i])));
		if (a[i] < 0)mainasu++, sum -= a[i];
		else sum += a[i];
	}
	if (mainasu % 2 == 1)cout << sum -(mi*2) << endl;
	else cout << sum << endl;
}

Measured memory_bytes: 640
/* ex5-4
    toshiwaka */

#include <stdio.h>
#include <string.h>

int main(void) {
  int len = 0, max_len = 0;
  //入力は10文字以内なのでstrの最大要素数は\0を含めて11
  char str[11], *ptr;

  scanf("%s", str);

  ptr = str;

  //ポインタで間接参照
  while(*ptr){
    switch(*ptr){
      //要素が'A''G''C''T'の時
      case 'A':
      case 'G':
      case 'C':
      case 'T':
        //lenの値を更新
        //lenがmax_lenより大きければlen_maxの値を更新
        len++;
        if(len > max_len) max_len = len;
        break;
      //それ以外の時
      default:
        //lenの値を初期化
        len = 0;
        break;
    }
    ptr++;
  }

  printf("%d\n", max_len);

  return 0;
}

Measured memory_bytes: 1680
#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define pb push_back
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<ll> vll;
const int MN = 2e5+5, MOD=1e9+7, LOG=33;
ll lcm (ll a, ll b) {return a*b/__gcd(a,b);}
ll multiplyMod(ll a, ll b) { return (a % MOD * b % MOD) % MOD; }
ll addMod(ll a, ll b) { return (a % MOD + b % MOD) % MOD; }
ll subMod(ll a, ll b) { return (a % MOD - b % MOD) % MOD; }
ll fpow(ll b, ll exp, ll mod){if(exp == 0) return 1;ll t = fpow(b,exp/2,mod);if(exp&1) return t*t%mod*b%mod;return t*t%mod;}
ll divmod(ll i, ll j, ll mod){i%=mod,j%=mod;return i*fpow(j,mod-2,mod)%mod;}
int h, n;
vi a;
vi b;
int dp[10005][1005];
int solve(int health, int pos) {
    if (health <= 0) {
        return 0;
    }
    if (pos == n) {
        return 999999999;
    }
    if (dp[health][pos]) {
        return dp[health][pos];
    }
    int res = min(solve(health, pos+1), min(b[pos]+solve(health-a[pos], pos+1), b[pos]+solve(health-a[pos], pos)));
    return dp[health][pos] = res;
}
int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> h >> n;
    for (int i = 0, z, x; i<n;i++) {
        cin >> z >> x;
        a.pb(z); b.pb(x);
    }
    cout << solve(h, 0) << '\n';


    return 0;

}

Measured memory_bytes: 40192
#include<stdio.h>

int main(void)
{
    int N,K,i,d,h;
    scanf("%d%d",&N,&K);
    d=0;
    for(i=0;i<N;i++){
        scanf("%d",&h);
        if(h>=K) d++;}
    printf("%d\n",d);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

int main(void)
{
    int n;
    cin >> n;
    cout << n * n * n << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define F(i,j,k,in) for(int i=j;i<k;i+=in)
#define DF(i,j,k,in) for(int i=j;i>=k;i-=in)
#define feach(it,l) for (auto it = l.begin(); it != l.end(); ++it)
#define fall(a) a.begin(),a.end()
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define eq equal_range
#define fs first
#define ss second
#define ins insert
#define mkp make_pair
#define endl "\n"
using namespace std;
typedef vector<ll> vll;
typedef vector<int> vin;
typedef vector<char> vch;
typedef vector<string> vst;
typedef vector<vector<ll>> vvll;
typedef vector<vector<int>> vvin;
typedef vector<pair<ll,ll>> vpll;
typedef vector<pair<int,int>> vpin;
typedef set<ll> sll;
typedef set<int> sint;
typedef set<char> sch;
typedef set<string> sst;
typedef queue<ll> qll;
typedef priority_queue<ll> pqll;
typedef queue<int> qin;
typedef priority_queue<int> pqin;
typedef map<ll,ll> mpll;
typedef map<int,int> mpin;
typedef pair<ll,ll> pll;
typedef pair<int,int> pin;
const ll MOD=1000000007;
const long double PI=3.1415926535897932384626433832795;
ll pwr(ll b,ll p){ll res=1;while(p){if(p&1) {res*=b; p--;}else{b*=b; p>>=1;}}return res;}
int main()
{
ios_base::sync_with_stdio(false) , cin.tie(NULL) , cout.tie(NULL);
ll x; cin>>x;
ll cnt=0 , i=1 , rp=0,sv=0;
while (rp<x) {
  sv=rp;
  rp=rp+pwr (26,i);
  ++cnt; ++i;
}
string ans;
x=x-sv;
DF (i,cnt,1,1) {
  ll q= x/(pwr(26,i-1));
  if (x%pwr(26,i-1)) ++q;
  if (!(x%pwr(26,i-1))) {x=pwr(26,i-1);}
  else x=x%pwr(26,i-1);
  ans+=('a'+q-1);
}

cout<<ans;

return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
using lli = long long;
lli n;

int main(void){
  cin >> n;
  lli p = 1;
  for(lli i = 1; i*i <= n; i++){
    if(n%i == 0) p = i;
  }
  lli q = n/p;
  string sp = to_string(p);
  string sq = to_string(q);
  cout << max(sp.size(), sq.size()) << endl;
  return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(i,v) for(auto &(i):(v))
#define eachr(i,v) for(auto &(i)=(v).rbegin();(i)!=(v).rend();(i)++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())
#define endl "\n"

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b=mod-2,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a/gcd(a,b)*b;}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
    oreno_initializer() {
        cin.tie(0);
        ios::sync_with_stdio(0);
    }
} oreno_initializer;



int n, a, b, c, aa, bb, e, res;

const int MAXS = 200200;
ll fact[MAXS+1], factr[MAXS+1], inv[MAXS+1];
ll comb(ll n, ll r) {
    if (fact[0]==0) {
        fact[0] = factr[0] = inv[1] = 1;
        for (int i=2; i<=MAXS; i++) inv[i] = inv[mod%i] * (mod-mod/i) %mod;
        for (int i=1; i<=MAXS; i++) fact[i] = fact[i-1]*i %mod, factr[i] = factr[i-1]*inv[i] %mod;
    }
    if (r<0 || n<r) return 0;
    return fact[n]*factr[r] %mod *factr[n-r] %mod;
}
ll hcomb(ll n, ll r) { return comb(n+r-1,r); }

signed main() {
    cin >> n >> a >> b >> c;
    aa = a * mop(a+b) %mod, bb = b * mop(a+b) %mod;
    e = 100ll * mop(100-c) %mod;
    rep(i,n) res += comb(n-1+i,i) * (mop(aa,n)*mop(bb,i)%mod + mop(aa,i)*mop(bb,n)%mod) %mod * (n+i) %mod;
    cout << res %mod * e %mod << endl;
}

Measured memory_bytes: 4992
# -*- coding: utf-8 -*-
s = input()
t = input()

dp = [[0] * (len(t) + 1) for _ in range(len(s) + 1)]

for i in range(1, len(s) + 1):
    for j in range(1, len(t) + 1):
        if s[i - 1] == t[j - 1]:
            dp[i][j] = dp[i - 1][j - 1] + 1
        else:
            dp[i][j] = max(dp[i - 1][j], dp[i][j - 1])

ans = ''
n, m = len(s), len(t)
while n != 0 and m != 0:
    if dp[n][m] == dp[n - 1][m]:
        n -= 1
    elif dp[n][m] == dp[n][m - 1]:
        m -= 1
    else:
        n -= 1
        m -= 1
        ans = s[n] + ans

print(ans)

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

int main(){
	string s;
	cin >> s;
	int ans = 0;
	if(s.at(0)=='1') ans++; 
	if(s.at(1)=='1') ans++; 
	if(s.at(2)=='1') ans++;
	cout << ans << endl; 
}

Measured memory_bytes: 256
s = int(input())

sec = [s]
i = 1

def f(n):
    if n%2==0:
        result = n/2
        return result
    else:
        result = 3 * n + 1
        return result

def my_index_multi(l,x):
    return [i for i, _x in enumerate(l) if _x == x]

while len(my_index_multi(sec,s))!=2:
    s = f(s)
    sec.append(s)
print(my_index_multi(sec,s)[1]+1)

Measured memory_bytes: 3064