akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<complex>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e9;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

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

using Graph=vector<vector<ll>>;

#define ketasitei setprecision(15) //15桁表示

const ll MOD = 1000000007;


int main(void)

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

	string s; 
	cin >> s;
	ll q;
	cin >> q;
	deque<char> ss;
	for (int i = 0; i < s.size(); i++)
	{
		ss.push_back(s[i]);
	}
	int fb = 1; //back:1 front:-1

	for (int i = 0; i < q; i++)
	{
		int t;
		cin >> t;
		if (t == 1)
		{
			fb *= -1;
		}
		else
		{
			int f; char c;
			cin >> f >> c;

			if (fb == 1)
			{
				if (f == 1)
				{
					ss.push_front(c);
				}
				else
				{
					ss.push_back(c);
				}
			}
			else
			{
				if (f == 1)
				{
					ss.push_back(c);
				}
				else
				{
					ss.push_front(c);
				}
			}
		}
	}

	for (int i = 0; i < ss.size(); i++)
	{
		if (fb == 1)
		{
			cout<<ss[i];
		}
		else
		{
			cout << ss[ss.size() - 1 - i];
		}
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 976
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define Endl "\n"
#define endl "\n"
#define in(x) int x;cin>>x;
#define all(x) x.begin(),x.end()
#define fo(i,n) for(int i=0;i<n;i++)
#define take(a,n) vector<int> a(n);fo(i,n)cin>>a[i];
#define print(a) for(auto x:a)cout<<x<<" ";cout<<endl;
#define eb emplace_back
#define pii pair<int,int>


void fastio()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);cout.tie(0);
  #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
  #endif
}

const int MAX = 1000001; 
  
// structure to store queries 
struct Query 
{ 
    int l, r, idx; 
}; 
  
// cmp function to sort queries according to r 
bool cmp(Query x, Query y) 
{ 
    return x.r < y.r; 
} 
  
// updating the bit array 
void update(int idx, int val, int bit[], int n) 
{ 
    for (; idx <= n; idx += idx&-idx) 
        bit[idx] += val; 
} 
  
// querying the bit array 
int query(int idx, int bit[], int n) 
{ 
    int sum = 0; 
    for (; idx>0; idx-=idx&-idx) 
        sum += bit[idx]; 
    return sum; 
} 
  
void answeringQueries(int arr[], int n, Query queries[], int q) 
{ 
    // initialising bit array 
    int bit[n+1]; 
    memset(bit, 0, sizeof(bit)); 
  
    // holds the rightmost index of any number 
    // as numbers of a[i] are less than or equal to 10^6 
    int last_visit[MAX]; 
    memset(last_visit, -1, sizeof(last_visit)); 
  
    // answer for each query 
    int ans[q]; 
    int query_counter = 0; 
    for (int i=0; i<n; i++) 
    { 
        // If last visit is not -1 update -1 at the 
        // idx equal to last_visit[arr[i]] 
        if (last_visit[arr[i]] !=-1) 
            update (last_visit[arr[i]] + 1, -1, bit, n); 
  
        // Setting last_visit[arr[i]] as i and updating 
        // the bit array accordingly 
        last_visit[arr[i]] = i; 
        update(i + 1, 1, bit, n); 
  
        // If i is equal to r of any query  store answer 
        // for that query in ans[] 
        while (query_counter < q && queries[query_counter].r == i) 
        { 
            ans[queries[query_counter].idx] = 
                     query(queries[query_counter].r + 1, bit, n)- 
                     query(queries[query_counter].l, bit, n); 
            query_counter++; 
        } 
    } 
  
    // print answer for each query 
    for (int i=0; i<q; i++) 
        cout << ans[i] << endl; 
} 


void solve()
{
	int n,q;cin>>n>>q;
	int a[n];
	for(int i=0;i<n;i++)cin>>a[i];
	Query queries[q];
	for(int i=0;i<q;i++)
	{
		cin>>queries[i].l>>queries[i].r;
		queries[i].l--;
		queries[i].r--;
		queries[i].idx = i;
	}
	sort(queries, queries+q, cmp);
	answeringQueries(a, n, queries, q);
}

int32_t main()
{
    // fastio();
    
        solve();
    return 0;
}

Measured memory_bytes: 35068
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
struct edge { int u, v; ll w; };
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
  int N;
  ll result = 1; 
  cin >> N;
  
  for (int i = 1; i <= N; i++)
    result = (result * i) % MOD;

  cout << result % MOD << endl;
  return 0;
}


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

int main()
{
	int a,b;
	cin>>a>>b;
	int total=0;
	int count=0;
	for (int i=0;i<a;i++)
	{
		int x;
		cin>>x;
		total=total+x;
		if (total<=b)
		{
			count=count+1;
		}
	}
	cout<<count+1<<endl;
}

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

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()
#define clr(a,v) memset(a, v, sizeof(a))

#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)
#define reflex ios_base::sync_with_stdio(false)

#define nl '\n'
#define ioi exit(0);

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

typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int N= (int)2e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
const ll linf = (ll)1e18 + 7;

const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int kx[] = {-1,1,2,2,1,-1,-2,-2};
const int ky[] = {2,2,1,-1,-2,-2,-1,1};

string conv(int a){
	stringstream ss;
	ss << a;
	string str = ss.str();
	return str;
}


string conv(char a){
	stringstream ss;
	ss << a;
	string str = ss.str();
	return str;
}

int conv(string a){
    stringstream geek(a); 
    int x = 0; 
    geek >> x;   
	return x;
}


string cad;
char s[N];

int memoA[N];
int memoB[N];

int B(int i){
	int &m = memoB[i];
	if(m != -1)
		return m;
	if(i == 0)
		return 0;
	if(s[i] == '.'){
		m = B(i-1);
		return m;
	}
	else{
		m = B(i-1) + 1;
		return m;
	}
}

int A(int i){
	int &m = memoA[i];
	if(m != -1)
		return m;
	if(i == 0)
		return inf;
	if(s[i] == '.'){
		m = min(A(i-1),B(i-1)) + 1;;
		return  m;
	}
	else{
		m = min(A(i-1),B(i-1));
		return m;
	}
}


int main(void) 
{	
	
	clr(memoA,-1);
	clr(memoB,-1);
	
	int x; cin>> x;
	cin>> cad;
	int n = (int)cad.size();
	rep(i,0,n-1)
		s[i+1] = cad[i];
	
	//cout<< A(n) <<" "<< B(n)<<endl;
	cout<< min(A(n), B(n));
	return 0;
} 



Measured memory_bytes: 8580
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include <set>
#include <vector>
#include <queue>
using namespace std;

int main(){
	int n, m;
	cin >> n >> m;
	int inf = 1000 * 100 * 10;
	vector<vector<int>> weight(n,vector<int>(n,inf));
	for (int i = 0; i < n; ++i) weight[i][i] = 0;
	vector<pair<pair<int, int>,int>> edge;
	for (int i = 0; i < m; ++i) {
		int ai, bi, ci;
		cin >> ai >> bi >> ci;
		ai--; bi--;
		weight[ai][bi] = weight[bi][ai] = ci;
		edge.push_back(make_pair(make_pair(ai, bi),ci));
	}

	for (int k = 0; k < n; ++k) {
		for (int i = 0; i < n; ++i) {
			for (int j = 0; j < n; ++j) {
				if (weight[i][j] > weight[i][k] + weight[k][j]) {
					weight[i][j] = weight[j][i] = weight[i][k] + weight[k][j];
				}
			}
		}
	}
	int cnt = 0;
	for (auto e : edge) {
		int from = min(e.first.first,e.first.second);
		int to = max(e.first.first,e.first.second);
		int org_weight = e.second;
		bool flag = false;
		for (int i = 0; i < n; ++i) {
			for (int j = i + 1; j < n; ++j) {
				if (weight[i][from] + org_weight + weight[to][j] == weight[i][j]) {
					flag = true;
				}
				if (weight[i][to] + org_weight + weight[from][j] == weight[i][j]) {
					flag = true;
				}
			}
		}
		if (!flag) cnt++;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1}; // 移動方向

ll n, m;

void input(){
    cin >> n >> m;
}

ll kaijyo(int x){
    if(x == 1) return 1;
    return (x * kaijyo(x - 1)) % MOD;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    ll ans;
    if(llabs(n-m)>=2){
        cout << 0 << endl;
        return 0;
    }
    if(llabs(n - m) == 1){
        ans = kaijyo(n) * kaijyo(m) % MOD;
        cout << ans << endl;
    }
    else if (llabs(n - m) == 0){
        ans = (kaijyo(n) * kaijyo(m) % MOD) * 2 % MOD;
        cout << ans << endl;
    }
    return 0;
}

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

const int MaxN = 100000;
unsigned long long S[ MaxN + 10 ];

int main()
{
unsigned long long i;
unsigned long long N;
unsigned long long M;
unsigned long long A;
unsigned long long x;
unsigned long long iCnt;
unsigned long long iSum;

	scanf( "%llu %llu", &N, &M );

	iSum = 0;
	iCnt = 0;
	for( i = 1; i <= N; i++ )
	{
		scanf( "%llu", &A );

		iSum += A;
		iSum %= M;
		S[ i ] = iSum;
	}

	sort( S, S + ( N + 1 ) );

	x = 0;
	for( i = 1; i <= N; i++ )
	{
		if( S[ i - 1 ] == S[ i ] )
			x++;
		else
		{
			iCnt += ( x + 1 ) * x / 2;
			x = 0;
		}
	}

	if( x > 0 ) iCnt += ( x + 1 ) * x / 2;

	printf( "%llu\n", iCnt );

	return 0;
}






Measured memory_bytes: 1024
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
static const double EPS = 1e-5;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)

int main(void){
  int grid[9][9];
  int n;
  cin>>n;
  bool fst = false;
  while(n--){
    if(fst){
      cout<<endl;
    }else{
      fst = true;
    }
    REP(y,9)REP(x,9)cin>>grid[y][x];
    REP(y,9){
      REP(x,9){
        bool f=false;
        int bx = x-x%3;
        int by = y-y%3;
        REP(sx,9){
          if(x==sx) continue;
          if(grid[y][x]==grid[y][sx]) f = true;
        }
        REP(sy,9){
          if(y==sy) continue;
          if(grid[y][x]==grid[sy][x]) f = true;
        }
        REP(dy,3)REP(dx,3){
          if(by+dy==y&&bx+dx==x) continue;
          if(grid[y][x]==grid[by+dy][bx+dx]) f=true;
        }
        if(f) cout<<"*";
        else cout<<" ";
        cout<<grid[y][x];
      }
      cout<<endl;
    }
  }
  return 0;
}

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

using namespace std;

const int mod = 998244353, N = 3030;

int dp[N][N + N], C[N][N];

void add(int & var, int val) {
  var += val;
  if (var >= mod)
    var -= mod;
}

int main() {
  for (int i = 0; i < N; ++i) {
    C[i][0] = C[i][i] = 1;
    for (int j = 1; j < i; ++j)
      C[i][j] = (C[i-1][j-1] + C[i-1][j]) % mod;
  }
  int n, x;
  scanf("%d %d", &n, &x);
  if (x == 1) {
    int ans = 1;
    for (int i = 0; i < n; ++i)
      ans = (ans * 2) % mod;
    printf("%d\n", ans);
    return 0;
  }
  if (x == 2) {
    printf("%d\n", n + 1);
    return 0;
  }
  dp[0][0] = 1;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < x; ++j) {
      for (int k = 0; k <= 2; ++k) {
        if (j + k >= x) continue;
        add(dp[i+1][j+k], dp[i][j]);
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < x; ++i)
    add(ans, dp[n][i]);
  for (int len = 3; len <= n; ++len) {
    for (int i = 1; i * 2 < len; ++i) {
      int tengah = len - 2 * i;
      int sisa = x-1 - 2 * i;
      if (sisa < tengah || sisa > 2 * tengah) continue;
      ans = (ans + 1LL * C[tengah][sisa-tengah] * C[n][len]) % mod;
    }
  }
  if (x & 1) {
    for (int len = (x - 1); len <= n; ++len) {
      ans = (ans + C[n][len]) % mod;
    }
  }
  ans %= mod;
  if (ans < 0) ans += mod;
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 105856
from pprint import *
N,K=map(int,input().split())
dpw=[[0 for _ in range(2*K+1)] for _ in range(2*K+1)]
dpb=[[0 for _ in range(2*K+1)] for _ in range(2*K+1)]
def getmatnum(x1,y1,x2,y2,mat):#左上を(x1,y1)右下を(x2,y2)にしてmatの中の左上~右下の領域の和をdpから算出
    if (x2==0)or(y2==0):
        return 0
    else:
        if (x1==-1):
            x1=0
        if (y1==-1):
            y1=0
        return mat[y2][x2]-mat[y1][x2]-mat[y2][x1]+mat[y1][x1]








for i in range(N):
    x,y,c=input().split()
    x=int(x)
    y=int(y)
    #print(x,y,c)
    if c=="W":
        dpw[(y%(2*K))+1][(x%(2*K))+1]=dpw[(y%(2*K))+1][(x%(2*K))+1]+1
    else:
        dpb[(y % (2*K))+1][(x % (2*K))+1] = dpb[(y % (2*K))+1][(x % (2*K))+1] + 1
#pprint(dpw)
#pprint(dpb)

for i in range(1,2*K+1):
    for j in range(1,2*K+1):
        dpb[i][j]=dpb[i][j-1]+dpb[i][j]

for i in range(1,2*K+1):
    for j in range(1,2*K+1):
        dpb[i][j]=dpb[i-1][j]+dpb[i][j]

for i in range(1,2*K+1):
    for j in range(1,2*K+1):
        dpw[i][j]=dpw[i][j-1]+dpw[i][j]

for i in range(1,2*K+1):
    for j in range(1,2*K+1):
        dpw[i][j]=dpw[i-1][j]+dpw[i][j]
ans=0
for i in range(K):
    for j in range(K):
        k=i+K
        l=j+K
        b1=getmatnum(-1,-1,i,j,dpb)+getmatnum(k,-1,2*K,j,dpb)+getmatnum(i,j,k,l,dpb)+getmatnum(-1,l,i,2*K,dpb)+getmatnum(k,l,2*K,2*K,dpb)
        w1=getmatnum(i,-1,k,j,dpw)+getmatnum(-1,j,i,l,dpw)+getmatnum(k,j,2*K,l,dpw)+getmatnum(i,l,k,2*K,dpw)
        b2=getmatnum(-1,-1,i,j,dpw)+getmatnum(k,-1,2*K,j,dpw)+getmatnum(i,j,k,l,dpw)+getmatnum(-1,l,i,2*K,dpw)+getmatnum(k,l,2*K,2*K,dpw)
        w2=getmatnum(i,-1,k,j,dpb)+getmatnum(-1,j,i,l,dpb)+getmatnum(k,j,2*K,l,dpb)+getmatnum(i,l,k,2*K,dpb)
        ans=max(ans,b1+w1,b2+w2)

        #print(i,j,k,l)
print(ans)
        #
#pprint(dpw)
#pprint(dpb)

Measured memory_bytes: 144208
from heapq import heappush,heappop,heapify
n=int(input())
a=list(map(int,input().split()))
ans=-float("inf")
l=a[:n]
heapify(l)
t=sum(a[:n])
ls=[t]
for i in range(n,2*n):
    t+=a[i]
    heappush(l,a[i])
    t-=heappop(l)
    ls.append(t)
r=[-i for i in a[2*n:]]
heapify(r)
t=sum(a[2*n:])
rs=[t]
for i in range(2*n-1,n-1,-1):
    t+=a[i]
    heappush(r,-a[i])
    t+=heappop(r)
    rs.append(t)
for i in range(n+1):
    ans=max(ans,ls[i]-rs[-i-1])
print(ans)

Measured memory_bytes: 39132
N = int(input())
W = [input() for _ in range(N)]

if len(set(W)) != len(W):
    print('No')
    exit(0)

prev = W[0]
for w in W[1:]:
    if prev[-1] != w[0]:
        print('No')
        exit(0)
    prev = w
print('Yes')

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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

int main(){

    int n, l;
    cin >> n >> l;
    vector<string> s(n);
    for(int i = 0; i < n; i++){
        cin >> s[i];
    }
    sort(s.begin(), s.end());
    for(int i = 0; i < n; i++){
        cout << s[i];
    }
    cout << endl;
    
    return 0;
}

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

int main() {
  int H,W;
  cin >> H >> W;
 vector<vector<char>> C(H, vector<char>(W));
  for(int i = 0;i<H;i++){
    for(int j = 0;j<W;j++){
      cin >> C[i][j];
    }
  }

  vector<int> y = {1,-1,0,0};
  vector<int> x = {0,0,1,-1};
  
  bool flag  =true;
  for(int i = 0;i<H;i++){
    for(int j = 0;j<W;j++){
      if(C[i][j] == '#'){
        int c = 0;
        for(int k = 0;k<=3;k++){
          int di = i+y[k];
          int dj = j+x[k];
          if(di < H && di>=0 && dj < W && dj >=0
            && C[di][dj] == '#'){//上下左右に移動可能な時
            c++;
          }
        }
          
          if(c == 0) flag = false;
      }
    }
  }
 
      
  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;
            
        
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repr(i,from,to) for(int (i)=(from);(i)<(to);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
#define all(x) begin((x)), end((x))
#define vprint(x) for(auto a:(x)) cout << x << endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
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;
}


int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a;
    long double b;
    cin >> a>>b;
    cout << ll(b*a) << endl;
    return 0;
}


Measured memory_bytes: 3752
import java.io.*;
import java.lang.reflect.Array;
import java.nio.channels.ScatteringByteChannel;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
 
public class Main {
    public static void main (String[] args) throws IOException
    {
    	  Scanner sc = new Scanner(System.in);
    	  int N = sc.nextInt();
    	  long a[] = new long [N];
    	  long s[] = new long [N];
    	  a[0] = sc.nextInt();
    	  s[0] = a[0];
    	  
    	  for (int i = 1;i < N;i++){
    		  a[i] = sc.nextInt();
    		  s[i] = s[i-1] + a[i];
    	  }
          
    	  long sum = s[N-1];
    	  
          if (N==2){
        	  System.out.println(Math.abs (a[1] - a[0]));
          } else {
        	  
        	  long ans = 1000000000000L;
        	  
        	  
        	  for (int i = 1;i <N-1;i++){
        		  if (ans > (Math.abs(sum-(2*s[i]))) ){
        			  ans = (Math.abs(sum-(2*s[i])));
        		  }
        	  }
        	  
        	  System.out.println(ans);
        	  
          }
          
          
          
    }
    
}
    

Measured memory_bytes: 89704
#include "bits/stdc++.h"
using namespace std;

int check(int n) {
  int cnt = 0;
  while(1) {
    if (n%2 != 0 || n == 0) break;
    n /= 2;
    cnt++;
  }
  return cnt;
}

int main() {
  int n;
  int p = 100000000;
  cin >> n;
  while (n--) {
    int x;
    cin >> x;
    int tmp = check(x);
    p = min(p, tmp);
  }
  cout << p << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int N,d[100],ans1;
	int sum = 0;
	scanf("%d", &N);
	for (int i = 0; i <= N-1; i++) {
		scanf("%d", &d[i]);
	}
	for (int j = 0; j <= N - 2; j++) {
		for (int k = j + 1; k <= N - 1; k++) {
			ans1 = d[j] * d[k];
			sum = sum + ans1;
		}
	}
	printf("%d", sum);
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <iomanip>
#include <queue>
#include <stack>
#include <functional>
#define rep(i,n) for(int i=0;i<n;i++)
using ll = long long;
using namespace std;
int main() {
	ll n, m, ans = 0, A[10101];
	cin >> n >> m;
	if (n + m == 15)
		cout << "+" << endl;
	else if (n*m == 15)
		cout << "*" << endl;
	else
		cout << "x" << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 7)

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

def main():
    N, D, A = lr()
    XH = [lr() for _ in range(N)]
    XH.sort()

    over = [N] * N # over[i]はi番目のモンスターを攻撃した時影響のないモンスターの最小値（最大はNで対象なし）
    cur = 1
    for i in range(N):
        while cur < N and XH[i][0] + D + D >= XH[cur][0]:
            cur += 1
        over[i] = cur

    damage = 0 # 今までの累計のダメージ数　(影響のないダメージは引く)
    reset = [0] * (N+1) # これ以降関係のないダメージ
    answer = 0
    for i in range(N):
        x, h = XH[i]
        damage -= reset[i]
        h -= damage
        if h > 0:
            time = (h+A-1)//A
            answer += time
            damage += A * time
            reset[over[i]] += A * time

    print(answer)

if __name__ == "__main__":
    main()

Measured memory_bytes: 67692
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace ABC145A
{
  class Program
  {
    static void Main(string[] args)
    {
      int r, x;
      
      r = int.Parse(Console.ReadLine());
      
      x = r * r;
      
      Console.WriteLine(x);
      
      Console.ReadKey();
    }
  }
}

Measured memory_bytes: 11220
#include<iostream>
#include<math.h>

using namespace std;
#define int int64_t
signed main() {
	int A, B, X, tmp, r;
	cin >> A >> B;
	X = A * B;
	if (A > B) {
		tmp = A;
		A = B;
		B = tmp;
	}
	r = A % B;
	while (r != 0) {
		A = B;
		B = r;
		r = A % B;
	}
	cout << X / B;

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstdio>
#include <climits>
#include <set>
using namespace std;

int a[100010];

int main()
{
    int n;
    cin >> n;
    set<int> s;

    for(int i = 0; i < n; i++)
    {
        int y;
        cin >> y;

        if(s.count(y))
        {
            s.erase(y);
        }
        else
        {
            s.insert(y);
        }
        
    }

    cout << s.size() << endl;

    return 0;
}

Measured memory_bytes: 4864
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define PB push_back
#define SP << " " <<

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VLL;

__attribute__((constructor))
void initial(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed <<setprecision(15);
}


int main(void){
	int N;
    cin >> N;
    vector<string> S;
    rep(i,N){
        string s;
        cin >> s;
        S.PB(s);
    }
    sort(rall(S));
    if(N==2){
        if(S[0]== S[1]){
            cout << S[0] << endl;
        }else{
            cout << S[1] << endl;
            cout << S[0] << endl;
        }
    }else{
        VVI X;
        VI x0;
        x0.PB(1);
        x0.PB(0);
        X.PB(x0);
        string s0 = S[0];
        int a = 1;
        int b = 0;
        rep(i,N-1){
            VI x;
            if(S[i+1] == S[i]){
                a++;
            }else{
                b = i+1;
                a = 1;
            }
            if(i == N-2){
                if(S[i+1] == S[i]){
                    b = i;
                    
                }
            }
            x.PB(a);
            x.PB(b);
            X.PB(x);
        }
        
        //rep(i,N){
        //    cout << X[i][0] SP X[i][1] SP S[X[i][1]]<< endl;
        //}
        sort(rall(X));

        //cout << endl;
        //rep(i,N){
        //   cout << S[i] << endl;
        //}
        //cout << endl;
        int flg = 1;
        rep(i,N-1){
            if(X[i][0] == X[i+1][0]){
                cout << S[X[i][1]] << endl;
            }else{
                cout << S[X[i][1]] << endl;
                flg = 0;
                break;
            }
        }
        if(flg == 1){
            cout << S[0] << endl;
        }
    }
    
    return 0;
}


Measured memory_bytes: 25832
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
struct xxx{long long x,y;}d[201000];
bool cmp(xxx a,xxx b){return a.x<b.x;}
int main()
{
	int n;scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d",&d[i].x,&d[i].y);
		if(d[i].x>d[i].y)swap(d[i].x,d[i].y);
	}
	sort(d+1,d+n+1,cmp);
	long long Min1=2e9,Max1=-2e9,Min2=2e9,Max2=-2e9,ans=2e18,Min3=2e9,Max3=-2e9;
	for(int i=1;i<=n;i++)
	{
		Min1=min(Min1,d[i].x);
		Max1=max(Max1,d[i].x);
		Min2=min(Min2,d[i].y);
		Max2=max(Max2,d[i].y);
	}
	ans=min(ans,(Max1-Min1)*(Max2-Min2));
	for(int i=1;i<n;i++)
	{
		Max3=max(Max3,d[i].y);Min3=min(Min3,d[i].y);
		ans=min(ans,(max(Max2,d[i].x)-d[1].x)*(max(Max3,d[n].x)-min(Min3,d[i+1].x)));
	}
	printf("%lld",ans);return 0;
}

Measured memory_bytes: 3328
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.ARC_C
{
    class _077
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            int[] nm = ReadInts();
            int n = nm[0];
            int m = nm[1];
            int[] array = ReadInts();
            long res = long.MaxValue;
            long now = 0;
            List<int>[] ups = new List<int>[m];
            List<int>[] downs = new List<int>[m];
            for(int i = 0; i < m; i++)
            {
                ups[i] = new List<int>();
                downs[i] = new List<int>();
            }
            int cnt = 0;
            for(int i = 0; i < n-1; i++)
            {
                now += Min((m + array[i + 1] - array[i]) % m, array[i + 1] % m + 1);
                ups[(array[i] + 1) % m].Add(i);
                downs[array[i + 1] % m].Add(i);

                if ((array[i + 1] + 1) % m < (array[i] + 1) % m)
                {
                    cnt++;
                }
            }
            res = now;

            for (int i = 1; i < m; i++)
            {
                for (int j = 0; j < downs[i - 1].Count; j++)
                {
                    int index = downs[i - 1][j];
                    now += (m + array[index + 1] - array[index]) % m - 1;
                    cnt--;
                }

                now -= cnt;
                res = Min(res, now);

                for(int j = 0; j < ups[i].Count; j++)
                {
                    cnt++;
                }
            }

            WriteLine(res);
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 38632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        int cnt = 1, j = i;
        while (j/10 > 0) {
            j/=10; cnt++;
        }
        if (cnt%2) ans++;
    }

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

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

ll gcd(ll x,ll y){ return y ? gcd(y,x%y) : x;}

ll func(ll x){
    vector<ll> v;
    for(ll i=2;i*i<=x;i++){
        if(x%i==0){
            v.push_back(i);
            x/=i;
        }
        while(x%i==0){
            x/=i;
        }
    }
    if(x!=1) v.push_back(x);
    return (ll)v.size();
}

int main(){
    ll a,b;
    cin>>a>>b;
    ll x=gcd(a,b);
    cout<<func(x)+1<<endl;
}

Measured memory_bytes: 3624
# 32bit整数
INT_MAX = 2147483647
UINT_MAX = 4294967295
# 64bit整数
LONGLONG_MAX = 9223372036854775807
ULONGLONG_MAX = 18446744073709551615

class Solver
  def main
    n, k = gets.split.map(&:to_i)

    # 区間（キャンドル本数）固定して全探索
    min_dist = ULONGLONG_MAX
    candles = gets.split.map(&:to_i)
    (k-1).upto(n-1) do |i|
      r_pos = candles[i]
      l_pos = candles[i - (k - 1)]
      r_dist = r_pos.abs
      l_dist = l_pos.abs

      # 両端のキャンドル間の距離は必ず歩くので
      dist = r_pos - l_pos

      # 0に近い方の端までの距離を加算
      if r_dist <= l_dist
        # 右端のほうが近い
        dist += r_dist
      else
        dist += l_dist
      end

      min_dist = dist if dist < min_dist
    end

    puts min_dist
  end
end

if __FILE__ == $0
  Solver.new.main
end


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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_N = (int)(3e2 + 5);
const int MAX_M = (int)(3e2 + 5);

int n, m;
int a[MAX_N][MAX_M];

bool remain[MAX_M];

pair<int, int> next_pop(vector<queue<int>>& qs) {
  vector<int> cnt(m + 1, 0);

  for (int i = 1; i <= n; ++i) {
    cnt[qs[i].front()] += 1;
  }

  int max_sport = 1;
  int max_times = cnt[1];
  for (int i = 1; i <= m; ++i) {
    if (cnt[i] > max_times) {
      max_sport = i;
      max_times = cnt[i];
    }
  }

  return make_pair(max_sport, max_times);
}

void pop_one(vector<queue<int>>& qs) {
  for (int i = 1; i <= n; ++i) {
    while (!remain[qs[i].front()]) {
      qs[i].pop();
    }
  }
}

int main(void) {
  // Here your code !
  scanf("%d %d", &n, &m);

  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      scanf("%d", &(a[i][j]));
    }
  }

  for (int i = 1; i <= m; ++i) remain[i] = true;

  vector<queue<int>> qs(MAX_N);

  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      qs[i].push(a[i][j]);
    }
  }

  int ans = MAX_M;

  if (m == 1) {
    ans = next_pop(qs).second;
  } else {
    for (int i = 1; i < m; ++i) {
      auto tmp = next_pop(qs);
      int target = tmp.first;

      ans = min(ans, tmp.second);

      remain[target] = false;
      pop_one(qs);
    }
  }

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

  return 0;
}


Measured memory_bytes: 1152
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <set>
#include <vector>
#include <queue>

using namespace std;

typedef long long ll;
typedef long double ld;

constexpr int INF = 1e9;
constexpr ll BIGINF = 1e18;
constexpr double EPS = 1e-16;

void preambule() {
  cin.tie(0);
  cout.precision(16);
  cout << fixed;
}

string s;

void input() {
  cin >> s;
}

bool good(const string& s) {
  string fir = s.substr(0, s.size() / 2);
  string sec = s.substr(s.size() / 2);

  return fir == sec;
}

void solve() {
  if (s.size() % 2 == 0)
    s.pop_back();

  s.pop_back();

  while (!good(s)) {
    s.pop_back();
    s.pop_back();
  }

  cout << s.length() << '\n';
}

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

  preambule();
  input();
  solve();
}


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

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

using namespace std;

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

    vector<int> countDist(n);
    rep(i, n)
    {
        countDist[i] = 0;
    }

    for (int i = 1; i <= n; i++)
    {
        for (int j = i + 1; j <= n; j++)
        {
            int minDist = 0;
            if (i <= x && x < j && j <= y)
            {
                minDist = min(j-i, x-i+y-j+1);
            }
            else if (i <= x && y <= j)
            {
                minDist = min(j-i, x-i+1+j-y);
            }
            else if (x <= i && i < y && y <= j)
            {
                minDist = min(j-i, i-x+j-y+1);
            }
            else if (j <= x)
            {
                minDist = j-i;
            }
            else if (y <= i)
            {
                minDist = j-i;
            }
            else
            {
                minDist = min(j-i, i-x+y-j+1);
            }
            countDist[minDist]++;
        }
    }

    rep(i,n)
    {
        if (i == 0) continue;
        cout << countDist[i] << endl;
    }
    
    return 0;
}


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

void swap(int a,int b) {
	int tmp = a;
	a = b;
	b = tmp;
}

int main(void) {
	ll n,m;
	cin >> n >> m;

	vector<ll>a(n);
	float total=0;

	for (int i = 0; i < n;i++) {
		cin >> a[i];
		total += a[i];
	}

	sort(a.begin(),a.end());

	for (int i = 1; i <= m; i++) {
		if (a[n - i] < total/(4*m) ) {
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 3652
N,M,X,Y=map(int,input().split())
 
x=list(map(int,input().split()))
y=list(map(int,input().split()))
 
x.sort()
y.sort()
 
 
for i in range(x[N-1]+1,y[0]+1):
  if i>X and i<=Y:
    print('No War')
    exit()
print('War')

Measured memory_bytes: 3060
import sys
n, k = map(int, input().split())
if k > (n-1)*(n-2)//2:
  print(-1)
  sys.exit()

key = 0
ans = []
for i in range(2, n+1):
  if k == 0:
    for j in range(1, i):
      ans.append((i, j))
  else:
    ans.append((1, i))
    if k >= key:
      k -= key
      key += 1
    else:
      key -= k
      for j in range(2, 2+key):
        ans.append((i, j))
      k = 0

print(len(ans))
for value in ans:
  print(*value)

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

using namespace std;

int main()
{
    string S="",T="",U="";
    int A,B;
    cin >> S >> T;
    cin >> A >> B;
    cin >> U;
    if (U==S)
        cout << A-1 << " " << B;
    else cout << A << " " << B-1;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1e9+7;
template<class T>bool chmin(T &a, const T &b)
{ return (a>b ? (a=b)||1 : 0); }

int main(){
	
	vector<int> d,e;
	for(int i=1; i<=200; i++){
		int m = i*(i+1)*(i+2)/6;
		d.push_back(m);
		if(m%2) e.push_back(m);
	}
	vector<int> dp1(1000001,1e8);
	vector<int> dp2(1000001,1e8);
	dp1.at(0) = 0;
	dp2.at(0) = 0;
	for(int i=0; i<=1000000; i++){
		for(auto j:d){
			if(i+j<=1e6){
				chmin(dp1.at(i+j),dp1.at(i)+1);
			}
		}
		for(auto j:e){
			if(i+j<=1e6){
				chmin(dp2.at(i+j),dp2.at(i)+1);
			}
		}
	}
	while(1){
		int n; cin>>n;
		if(!n) break;
		cout << dp1.at(n)<<' '<<dp2.at(n)<<endl;
	}
	
}




Measured memory_bytes: 10568
N = int(input())
T = [0] + list(map(int, input().split())) + [0]
A = [0] + list(map(int, input().split())) + [0]

MOD = 10 ** 9 + 7


def imp():
    print(0)
    exit()


ans = 1
for i in range(1, N + 1):
    if T[i - 1] < T[i]:
        if A[i] < T[i]:
            imp()
    elif A[i] > A[i + 1]:
        if T[i] < A[i]:
            imp()
    else:
        ans = (ans * min(T[i], A[i]) % MOD)
print(ans)


Measured memory_bytes: 19136
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int n;cin>>n;
  	vector<long long int> a(n);
  	vector<long long int> b(n);
  	for(int i=0;i<n;i++){
    	cin>>a.at(i)>>b.at(i);
    }
  	reverse(a.begin(),a.end());
  	reverse(b.begin(),b.end());
  	long long int count=0;
  	for(int i=0;i<n;i++){
      	a.at(i)+=count;
    	count+=(a.at(i) % b.at(i)==0)?0:(b.at(i)-a.at(i) % b.at(i));
    }
  cout<<count<<endl;
}

Measured memory_bytes: 1792
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; input_inner ! { iter , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let s = { use std :: io :: Read ; let mut s = String :: new ( ) ; std :: io :: stdin ( ) . read_to_string ( & mut s ) . unwrap ( ) ; s } ; let mut iter = s . split_whitespace ( ) ; input_inner ! { iter , $ ( $ r ) * } } ; }
macro_rules ! input_inner { ( $ iter : expr ) => { } ; ( $ iter : expr , ) => { } ; ( $ iter : expr , mut $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let mut $ var = read_value ! ( $ iter , $ t ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , mut $ var : ident $ ( $ r : tt ) * ) => { let mut $ var = $ iter . next ( ) . unwrap ( ) . parse ::< usize > ( ) . unwrap ( ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ iter , $ t ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , $ var : ident $ ( $ r : tt ) * ) => { let $ var = $ iter . next ( ) . unwrap ( ) . parse ::< usize > ( ) . unwrap ( ) ; input_inner ! { $ iter $ ( $ r ) * } } ; }
macro_rules ! read_value { ( $ iter : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ iter , $ t ) ) ,* ) } ; ( $ iter : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ iter , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ iter : expr , chars ) => { read_value ! ( $ iter , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ iter : expr , usize1 ) => { read_value ! ( $ iter , usize ) - 1 } ; ( $ iter : expr , $ t : ty ) => { $ iter . next ( ) . unwrap ( ) . parse ::<$ t > ( ) . unwrap ( ) } ; }
fn main() {
    input! { n, ab: [(usize1, usize1); n-1] };
    let mut graph = vec![vec![]; n];
    for &(a, b) in &ab {
        graph[a].push(b);
        graph[b].push(a);
    }
    let mut visited1 = vec![-1; n];
    visited1[0] = 0;
    let mut stack = vec![0];
    while let Some(x) = stack.pop() {
        let d = visited1[x];
        for &y in &graph[x] {
            if visited1[y] < 0 {
                visited1[y] = d + 1;
                stack.push(y);
            }
        }
    }
    let mut visited2 = vec![-1; n];
    visited2[n - 1] = 0;
    let mut stack = vec![n - 1];
    while let Some(x) = stack.pop() {
        let d = visited2[x];
        for &y in &graph[x] {
            if visited2[y] < 0 {
                visited2[y] = d + 1;
                stack.push(y);
            }
        }
    }
    let cnt = visited1
        .into_iter()
        .zip(visited2.into_iter())
        .filter(|&(x, y)| x <= y)
        .count();
    if cnt <= n - cnt {
        println!("Snuke");
    } else {
        println!("Fennec");
    }
}


Measured memory_bytes: 14588
#include<bits/stdc++.h>
#define int long long
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
s.find_by_order(x) xth element in set
x.order_of_key(x) number of elements <x*/
#define ll long long
#define vi vector<int>
#define si set<int>
#define mii map<int,int>
#define pb push_back
#define pf push_front
#define PI acos(-1)
#define pii pair<int,int>
#define extract_word(s)  stringstream str(s); while(str>>word)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define SET(s) cout<<fixed<<setprecision(s)
#define set0(a) memset(a,0,sizeof(a))
#define endl "\n"
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define lower_string(s) transform(all(s),s.begin(),::tolower())
#define upper_string(s) transform(all(s),s.begin(),::toupper())
template<typename T,typename U>
bool compare(T x,U y){return(abs(x-y)<=1e-9);}
void solve()
{
	int n;
	cin>>n;
	int m1=INT_MIN;
	int m2=INT_MAX;
	int m3=INT_MIN;
	int m4=INT_MAX;
	for(int i=0;i<n;i++)
	{
		int x,y;
		cin>>x>>y;
		m1=max(m1,x+y);
		m2=min(m2,x+y);
		m3=max(m3,x-y);
		m4=min(m4,x-y);
	}
	cout<<max(m1-m2,m3-m4);
	
}
signed main()
{
//code
fastio
int t;
t=1;
while(t--)
{
solve();
cout<<endl;
}
}


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

int main(void) {
  int N;
  int ret = 0;
  cin >> N;

  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    while (a % 2 == 0) {
      ret++;
      a = a / 2;
    }
  }
  cout << ret;
}


Measured memory_bytes: 256
# D-Knapsack 1
N,W = map(int,input().split())
Weight = [0 for _ in range(N)]
Value = [0 for _ in range(N)]
for i in range(N):
    Weight[i],Value[i] = map(int,input().split())

MAX_N = 110
MAX_V = 100100
dp = [[10**15 for i in range(MAX_V)] for j in range(MAX_N)]
dp[0][0] = 0

for i in range(N):
    # あらゆる合計重量sum_wに対して品物iを入れるべきか計算する
    for sum_v in range(MAX_V):
        # i番目を選ぶ場合
        if sum_v - Value[i] >= 0:
            dp[i+1][sum_v] = min(dp[i+1][sum_v], dp[i][sum_v - Value[i]] + Weight[i])

        # i番目を選ばない場合
        dp[i+1][sum_v] = min(dp[i+1][sum_v], dp[i][sum_v])


ans = 0
for sum_v in range(MAX_V):
    if dp[N][sum_v] <= W:
        ans = sum_v
print(ans)

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second

#define DUMP(x) cout<<#x<<":"<<(x)<<endl
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class T>
istream& operator>>(istream& is, vector<T>& xs){
  for(auto& x: xs)
	is >> x;
  return is;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
ostream& operator<<(ostream& os, const vector<T>& xs){
  for(unsigned int i=0;i<xs.size();++i)
	os << (i?" ":"") << xs[i];
  return os;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  LL a, b;
  cin >> a >> b;
  cout << (a*b%2==0? "Even": "Odd") << endl;

  return 0;
}


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

std::vector<bool> Sieve(int n) {
  std::vector<bool> v(n + 1, true);
  v[0] = v[1] = false;
  for (int i = 2; i * i <= n; ++i) {
    if (!v[i]) {
      continue;
    }
    for (int j = i * 2; j <= n; j += i) {
      v[j] = false;
    }
  }
  return v;
}

std::vector<int> Primes(int n) {
  std::vector<bool> sieve = Sieve(n);
  std::vector<int> v;
  for (int i = 2; i <= n; ++i) {
    if (sieve[i]) {
      v.push_back(i);
    }
  }
  return v;
}

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

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

using ll = long long;

using namespace std;

int main() {
  in(int, x);
  vector<bool> sieve = Sieve(200000);
  while (!sieve[x]) ++x;
  out(x);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  double n,sum=0,min=1000,loc;
  cin >> n;
    vector<double> data(n);
  for(int i=0;i<n;i++){
    cin >> data.at(i);
  }
    for(int i=0;i<n;i++){
    sum += data.at(i);
  }
  sum = sum/n;
  for(int i=0;i<n;i++){
    if(min>abs(data.at(i)-sum)){
      loc=i;
      min = abs(data.at(i)-sum);
    }
  }
  cout << loc;
}



Measured memory_bytes: 256
// eddy1021
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL mod7=1000000007LL;
inline LL getint(){
  LL _x=0,_tmp=1; char _tc=getchar();    
  while( (_tc<'0'||_tc>'9')&&_tc!='-' ) _tc=getchar();
  if( _tc == '-' ) _tc=getchar() , _tmp = -1;
  while(_tc>='0'&&_tc<='9') _x*=10,_x+=(_tc-'0'),_tc=getchar();
  return _x*_tmp;
}
inline LL add(LL _x, LL _y, LL _mod=mod7){
  _x+=_y;
  return _x>=_mod ? _x-_mod : _x;
}
inline LL sub(LL _x, LL _y, LL _mod=mod7){
  _x-=_y;
  return _x<0 ? _x+_mod : _x;
}
inline LL mul(LL _x, LL _y ,LL _mod=mod7){
  _x*=_y;
  return _x>=_mod ? _x%_mod : _x;
}
LL mypow(LL _a, LL _x, LL _mod){
  if(_x == 0) return 1LL;
  LL _ret = mypow(mul(_a, _a, _mod), _x>>1, _mod);
  if(_x & 1) _ret=mul(_ret, _a, _mod);
  return _ret;
}
LL mymul(LL _a, LL _x, LL _mod){
  if(_x == 0) return 0LL;
  LL _ret = mymul(add(_a, _a, _mod), _x>>1, _mod);
  if(_x & 1) _ret=add(_ret, _a, _mod);
  return _ret;
}
void sleep(double sec = 1021){
  clock_t s = clock();
  while(clock() - s < CLOCKS_PER_SEC * sec);
}
#define Bye exit(0)
int __ = 1 , _cs;
/*********default*********/

void build(){

}
int ds(int x){
  int ret=0;
  while(x){
    ret+=x%10;
    x/=10;
  }
  return ret;
}
int n;
void init(){
  n=getint();
}
void solve(){
  int ans=1e9;
  for(int i=1; i<n; i++)
    ans=min(ans, ds(i)+ds(n-i));
  cout<<ans<<endl;
}
int main(){
  build();
  //__ = getint();
  while(__ --){
    init();
    solve();
  }
}


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

#define SZ(x) (((int)x.size()))
#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;

using namespace std;

const int mod = 1000000007, maxn = 100*1000+10;
int k, n;
ll dp[maxn], ans;
vector<int> d[maxn];

ll power(ll a, int b, int m)
{
	if (b == 0)
		return 1 % m;
	ll c = power(a, b / 2, m);
	if (b & 1)
		return (((c * c) % m) * a) % m;
	return (c * c) % m;
}

int main()
{
	cin >> n >> k;
	for (int i = 2; i <= k; i++)
	{
		for (int j = i; j <= k; j += i)
			d[j].push_back(i);
	}
	dp[1] = 1;
	for (int i = 2; i <= k; i++)
	{
		dp[i] = (power(i, n, mod) - power(i - 1, n, mod) + mod) % mod;
		for (auto &w : d[i])
		{
			dp[i] += mod - dp[i / w];
			dp[i] %= mod;
		}
	}
	for (int i = 2; i <= k; i++)
	{
		dp[i] += dp[i - 1];
		dp[i] %= mod;
	}
	for (int i = 1; i <= k; i++)
	{
		ans += dp[k / i] * i;
		ans %= mod;
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 14212
#!/usr/bin/ruby
# -*- coding: utf-8 -*-
=begin
Volume0-0009
=end

#require 'prime'
N=1000000
#N=10
f=Array.new(N,true)
# 3 -> 0, 3 -> 1
f[0] = f[1] = false
2.upto(N-1){|i|
  if f[i] then
    (i+i).step(N-1,i){|j|
          f[j] = false
    }
  end
}

while gets do
  n = $_.to_i
  m = 0
  2.upto(n){|i|
    if f[i] then
      m += 1
    end
  }
  puts m
end

Measured memory_bytes: 16608
#include <stdio.h>
typedef long long ll;

ll min(ll a, ll b) {
  return a < b ? a : b;
}

int main(void) {
  ll i, j, k, n, m, p, be, ans = 0, a, b, c;
  scanf("%lld%lld", &n, &m);
  ll sum[n - 1], now = 0;
  for(i = 0; i < n - 1; ++i) sum[i] = 0;
  scanf("%lld", &be);
  be--;
  for(i = 0; i < m - 1; ++i) {
    scanf("%lld", &p);
    p--;
    if(p > be) {
      sum[be]++;
      if(p != n - 1) sum[p]--;
    } else {
      sum[p]++;
      if(be != n - 1) sum[be]--;
    }
    be = p;
  }
  for(i = 0; i < n - 1; ++i) {
    now += sum[i];
    scanf("%lld%lld%lld", &a, &b, &c);
    ans += min(now * a, c + now * b);
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 3520