akhauriyash/Code-Regression huggingface dataset:
/**
 *   @FileName	e.cpp
 *   @Author	kanpurin
 *   @Created	2020.06.21 21:18:50
**/

#include "bits/stdc++.h" 
using namespace std; 
typedef long long ll;

int main() {
    int n;cin >> n;
    vector<int> a(n);
    int x = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        x ^= a[i];
    }
    for (int i = 0; i < n; i++) {
        cout << (x ^ a[i]) << " ";
    }
    cout << endl;
    return 0;
}

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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define DUMPP(xs) for (auto x:xs) cout<<'('<<x.first<<','<<x.second<<')'<<' ';cout<<endl
#define FOR(i,a,b) for (ll i=(ll)(a);i<(ll)(b);++i)
#define OUT(x) cout<<x<<endl
#define OUTP(x) cout<<'('<<x.first<<','<<x.second<<')'<<endl;
#define REP(i,n) FOR(i,0,n)
#define YES(cond) cond ? OUT("YES") : OUT("NO")
#define Yes(cond) cond ? OUT("Yes") : OUT("No")

template<class T> T gcd(const T x,const T y){if(!y){return x;}return gcd(y,x%y);}
template<class T> T lcm(const T x,const T y){return x/gcd(x,y)*y;};
template<class T> T modpow(T x,T n,const T mod) {
  T res=1;while(n>0){if(n%2)res=res*x%mod;x=x*x%mod;n/=2;};return res;
}
template<class T> T modinv(T x,const T mod){return modpow(x,mod-2,mod);}
template<class T> bool alltrue(const T &a){return all_of(ALL(a),[](bool x){return x;});}
template<class T> bool anytrue(const T &a){return any_of(ALL(a),[](bool x){return x;});}
template<class T> bool contain(const T &a,const T &b){for(auto x:b){if (a.find(x)==a.end()){return false;}}return true;}
template<class T> bool mmax(T &m,const T q){ if (m < q) {m = q; return true;} else return false; }
template<class T> bool mmin(T &m,const T q){ if (m > q) {m = q; return true;} else return false; }
template<class T> int siz(const T &a) {return (int)a.size();}
template<class T> set<T> devisers(T n) {
  set<T> res;for(T i=1;i<(T)sqrt(n)+1;i++){if(n%i==0){res.insert(i);res.insert(n/i);}}return res;
}
template<class T> void concat(T &a, const T &b){a.insert(a.end(),ALL(b));}
template<class T> void getand(const T &a,const T &b,T &c) {
  set_intersection(ALL(a),ALL(b),inserter(c,c.end()));
}
template<class T> void getor(const T &a,const T &b,T &c) {
  set_union(ALL(a),ALL(b),inserter(c,c.end()));
}
template<class T> void getdiff(const T &a,const T &b,T &c) {
  set_difference(ALL(a),ALL(b),inserter(c,c.end()));
}
template<class T> T deg2rad(T deg) {return deg*2*M_PI/360;}
template<class T> T rad2deg(T rad) {return rad*360/(2*M_PI);}

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

const ll MOD=1e9+7;
const ll MAX=5e6;

int main() {
  int K;cin>>K;
  ll ans = 0;
  FOR(i,1,K+1)FOR(j,1,K+1)FOR(k,1,K+1) {
    ans += gcd(gcd(i,j), k);
  }
  OUT(ans);

  return 0;
}


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

int main(){
    int H,W;
    while(1){
        cin >> H >> W;
        if (H == 0 && W == 0)break;
        for ( int i = 0; i < H; i++)
        {
            for (int j = 0; j < W; j++)
            {
                if ((i+j) %2 == 0){
                    cout << "#";
                }else{
                    cout << ".";
                }
            }
        cout << endl;
        }
    cout << endl;
    }
return 0;
}


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

long long gcd(long long a,long long b) {
    if (b==0) return a;
    else  gcd(b,a%b);
}

int main()
{
 long long a,b,c,d,lcm,div,aan,ban,av,bv;
 aan=0;
 ban=0;
 cin>> a >> b >> c >> d;
 lcm=c*d/gcd(c,d);
 div=lcm-(lcm/c+lcm/d-1);
 aan+=div*((a-1)/lcm);
 ban+=div*(b/lcm);
 aan+=((a-1)%lcm)-(((a-1)%lcm)/c)-(((a-1)%lcm)/d);
 ban+=(b%lcm)-((b%lcm)/c)-((b%lcm)/d);
 cout<<ban-aan;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
#define mx 100005
#define ll long long
#define mod 1000000007

int ar[mx];
char ch[mx];
set<int>v[mx];
int n,m;

void solve()
{
     scanf("%d%d",&n,&m);
     for(int i=1;i<=n;i++)scanf("%d",&ar[i]);
     while(m>0)
     {
         int x,y;
         scanf("%d%d",&x,&y);
         v[x].insert(y);
         v[y].insert(x);
         m--;
     }
     int re=0;
     for(int i=1;i<=n;i++)
     {
         if(v[i].size()==0){
            re++;
            continue;
         }
         int val=ar[i];
         bool f=true;
         for(auto it:v[i])
         {
             if(ar[it]>=val)
             {
                 f=false;
                 break;
             }
         }
        // cout<<i<<" "<<f<<" "<<re<<endl;
         if(f)re++;
     }
     printf("%d\n",re);
}

int main()
{
    int t=1;
   // scanf("%d",&t);
    while(t--)solve();
    return 0;
}


Measured memory_bytes: 18236
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<string>
#include<iomanip>
#include<cstdio>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define MOD 1000000007
#define MAXS(x,y) (x = max(x,y))
#define MINS(x,y) (x = min(x,y))

using namespace std;

typedef long long int ll;

const ll INF=(ll)1e18;


int N;
vector<vector<int> > a;
vector<vector<ll> > dp;

int main(){
  cin >> N;

  a.resize(N);
  REP(i,N)a[i].resize(N);

  ll P = 1 << N;
  dp.resize(N+1);
  REP(i,N+1)dp[i].resize(P);

  REP(i,N)REP(j,N)cin >> a[i][j];

  dp[0][0] = 1;
  REP(i,N){
    REP(j,P){
      if (__builtin_popcount(j) != i)continue;
      REP(k,N){
        int p = 1 << k;
        if(a[i][k]){
          if((j&p) == 0){
            (dp[i+1][j|p] += dp[i][j]) %= MOD;
          }
        }
      }
    }

    // REP(j,N){
    //   cout << dp[i][j] << " ";
    // }
    // cout << endl;
  }
  cout << dp[N][P-1] << endl;

}

Measured memory_bytes: 360832
#include <bits/stdc++.h>
#define int long long
using namespace std;
long long ta,ao;
signed main(){
	int n;
	cin>>n;
	vector<int>a(n),b(n);
	pair<int,int>sum[n];
	for(int i=0;i<n;i++){
		cin>>a[i]>>b[i];
		sum[i].first=a[i]+b[i];
		sum[i].second=i;
	}
	sort(sum,sum+n);
	reverse(sum,sum+n);
	for(int i=0;i<n;i+=2){
		ta+=a[sum[i].second];
	}
	for(int i=1;i<n;i+=2){
		ao+=b[sum[i].second];
	}
	cout<<ta-ao<<endl;
}

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


// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

#define int               long long
#define endl              '\n'
#define ff                first
#define ss                second
#define mp                make_pair
#define pb                push_back
#define vii               vector<int> 
#define pii               pair<int,int>
#define vpii              vector< pii >
#define all(v)            v.begin(),v.end()
#define loop(i,s,e)       for(int i=s;i<e;i++)
#define rloop(i,e,s)      for(int i=e;i>=s;i--)
#define mset(a,f)              memset(a,f,sizeof(a))
#define M                 1000000007
#define fastio            ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define prvec(v)          loop(i_u_j,0,v.size())cout << v[i_u_j] <<" "; cout << endl;
#define prarr(arr,n)      loop(i_u_j,0,n)cout << arr[i_u_j] << " "; cout << endl;
#define bug(...)        __f (#__VA_ARGS__, __VA_ARGS__)


template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
     const char* comma = strchr (names + 1, ',');
     cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //
const int N = 3e5 + 7;
int n;
int arr[N][3];
int dp[N][4];

int getans(int id, int p)
{           
      if( dp[id][p] != -1 ) return dp[id][p];
      if( id == n ) return 0;
      int ans = 0;
      loop(i,0,3)
      {
            if( i != p ) ans = max(ans, arr[id][i] + getans(id+1, i) );
      }
      return dp[id][p] = ans;

}


void solve()
{
      cin >> n;
      loop(i,0,n)
      {
            cin >> arr[i][0] >> arr[i][1] >> arr[i][2];
      }
      mset(dp,-1);
      cout << getans(0,3);
}

int32_t main() {
    fastio;

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


}


// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //















Measured memory_bytes: 20352
#[allow(unused_macros)]
macro_rules! parse_line {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            iter.next().unwrap().parse::<$t>().unwrap()
        }
    );

    ( $( $t:ty), +) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
        }
    );
}

#[allow(unused_macros)]
macro_rules! read_line {
    () => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        line.pop();
        line
    }};
}

#[allow(unused_macros)]
macro_rules! parse_vec {
    ( $t:ty ) => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        let iter = line.split_whitespace();
        iter.map(|v| v.parse::<$t>().unwrap()).collect::<Vec<_>>()
    }};
}

fn main() {
    let (a, b, k) = parse_line!(usize, usize, usize);
    let mut i = 101;
    let mut j = k;
    while j > 0 {
        i -= 1;
        if a % i == 0 && b % i == 0 {
            j -= 1
        }
    }
    println!("{}", i);
}

Measured memory_bytes: 4352
#!/usr/bin/env python3
import sys, math, itertools, heapq, collections, bisect, fractions
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**8)
inf = float('inf')
ans = count = 0

def num(s):
    data=["a","b","c"]
    return data.index(s)

S=[input() for i in range(3)]
ijk=[0,0,0]
goal=[len(si) for si in S]

def game(s):
    ijk[num(s)]+=1
    if ijk[num(s)]-1==goal[num(s)]:
        # print(s)
        print(s.upper())
        exit()
    game(S[num(s)][ijk[num(s)]-1])

game("a")

Measured memory_bytes: 64364
#include <iostream>
#include <stack>
#include <math.h>
#include <vector>
#include <string>
#include <algorithm>
#include <map>

#define rep(i,n) for(int i=0; i < n; i++)
using ll =  long long;
using namespace std;
#define pi 3.14159265358979

int main()
{
	int h, w;
	cin >> h >> w;
	string line;
	rep(i, h)
	{
		cin >> line;
		cout << line << endl << line << endl;
	}
	return 0;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
typedef long long int LL;
#define MAX(a, b) (a > b) ? a : b;
#define MIN(a, b) (a < b) ? a : b;
#define IsInteger(a) (fabs(a-round(a))<0.00001)
#define swap(a, b) \
    {              \
        a = a + b; \
        b = a - b; \
        a = a - b; \
    }
int h[100001];
long long int cost[100001];

long long int mincost(int currpos)
{
    if(cost[currpos]==-1)
    {
        cost[currpos]=min((mincost(currpos-1)+(LL)(fabs(h[currpos]-h[currpos-1]))),(mincost(currpos-2)+(LL)(fabs(h[currpos]-h[currpos-2]))));
       // cout<<"COST FOR POSITION "<<currpos<<" IS "<<cost[currpos]<<endl;
    }
    return cost[currpos];
}




int main()
{
    LL n;
    cin>>n;
    h[0]=-1;
    for(int i=1;i<=n;i++)
    {
        cin>>h[i];
        cost[i]=-1;
    }
    for(int i=n+1;i<100001;i++)
    {
        h[i]=-1;
        cost[i]=-1;
    }
    
    cost[1]=0;
    //cout<<"h[1] is "<<h[1];
    //cout<<"h[2] is "<<h[2];
    cost[2]=fabs(h[2]-h[1]);
    //cout<<cost[2]<<endl;
    

    LL ans=mincost(n);
    cout<<ans<<endl;
    


    return 0;
}

Measured memory_bytes: 3712
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main()
{
    string S;
    cin >> S;
    
    size_t size = S.size();
    
    //01をいっぱい作る
    string trueans = "01";
    for(int i=0;i<size;i++){
        trueans = trueans+"01";
    }
    int ans1 = 0;
    int ans2 = 0;
        for(int i=0;i<size;i++){
            if(S[i]!=trueans[i]){
                ans1++;
            }
            if(S[i]!=trueans[i+1]){
                ans2++;
            }
        }
    cout << min(ans1,ans2) << endl;
    return 0;
}


Measured memory_bytes: 1472
from collections import defaultdict
mod = 10**9+7
N,K = map(int,input().split())
A = list(map(int,input().split()))

d1 = defaultdict(lambda:0)
d2 = defaultdict(lambda:0)

for i in range(N):
    for j in range(N):
        if A[i]>A[j]:
            if i<j:
                d1[i]+=1
            d2[i]+=1

ans = 0
for i in range(N):
    ans += (K*(K-1))//2%mod*d2[i]+K*d1[i]
    ans %= mod

print(ans)

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

#define int long long
const long long LINF=1e18;
template<typename T>
void chmin(T &a,T b){
  if(a>b)a=b;
}

signed main(){
  int n,x;cin>>n>>x;
  vector<int> v(n);
  for(int i=0;i<n;i++)cin>>v[i];
  vector<int> w(n);
  for(int i=0;i<n;i++)w[i]=v[i];
  int ans=LINF;
  for(int k=0;k<n;k++){
    int tmp=k*x;
    for(int i=0;i<n;i++)tmp+=w[i];
    chmin(ans,tmp);
    for(int i=0;i<n;i++)chmin(w[(i+k+1)%n],v[i]);
  }
  cout<<ans<<endl;
}


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

int main() {
	int N, a, b = 0, c = 0;
	cin >> N;
	for (int i = 0; i < N; ++i) {
		cin >> a;
		if (0 == a % 4) ++b;
		else if (0 == a % 2) ++c;
	}
	if (N / 2 <= b + c / 2) cout << "Yes";
	else cout << "No";
}

Measured memory_bytes: 384
import java.util.Scanner;



public class Main {
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)) {
			String str = sc.next();
			for(int i=0; i<str.length(); i++) {
				System.out.print(str.charAt(str.length()-1-i));
			}
			System.out.println();
			

			
		}
	}
}






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

using namespace std;

int main(){
    long long n,m,l;
    cin >> n >> m >> l;
    vector<vector<long long> > A(n,vector<long long>(m,0));
    vector<vector<long long> > B(m,vector<long long>(l,0));

    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin >> A[i][j];
        }
    }
    for(int i=0;i<m;i++){
        for(int j=0;j<l;j++){
            cin >> B[i][j];
        }
    }
    
    vector<vector<long long> > ans(n,vector<long long>(l,0));

    for(int i=0;i<n;i++){
        for(int j=0;j<l;j++){
            for(int k=0;k<m;k++){
                ans[i][j]+=A[i][k]*B[k][j];
            }
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<l;j++){
            cout << ans[i][j];
            if(j!=l-1)cout << " ";
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 3268
class Edge:
    def __init__(self, u, v, cost):
        self.u = u
        self.v = v
        self.cost = cost
        # self.n = n


class Coordinate:
    def __init__(self, x, y, n):
        self.x = x
        self.y = y
        self.n = n

    def __repr__(self):
        return repr((self.x, self.y))


# union find。初期化
def init(_n):
    for i in range(0, _n):
        par[i] = i
        rank[i] = 0


# 木の根を求める
def find(_x):
    if par[_x] == _x:
        return _x
    else:
        par[_x] = find(par[_x])
        return par[_x]


# 集合を併合
def unite(_x, _y):
    _x = find(_x)
    _y = find(_y)
    if _x == _y:
        return

    if rank[_x] < rank[_y]:
        par[_x] = _y
    else:
        par[_y] = _x
        if rank[_x] == rank[_y]:
            rank[_x] += 1


# 同じ集合かどうか
def same(_x, _y):
    return find(_x) == find(_y)


def comp(edge1, edge2):
    return edge1.cost < edge2.cost


def kruskal():
    sorted_edges = sorted(Edges, key=lambda edges: edges.cost)
    init(V)
    res = 0
    # for i in range(E):
    # # print("u" + str(sorted_edges[i].u) + "v" + str(sorted_edges[i].v) + "cost" + str(sorted_edges[i].cost))

    for i in range(0, E):
        tmp_edge = sorted_edges[i]
        if not same(tmp_edge.u, tmp_edge.v):
            unite(tmp_edge.u, tmp_edge.v)
            # print("tmp_edge.cost" + str(tmp_edge.cost))
            res += tmp_edge.cost

    return res


if __name__ == '__main__':
    N = int(input())
    x = []
    y = []
    Coordinates = []
    for i in range(0, N):
        tmp_x, tmp_y = list(map(int, input().split()))
        # x.append(tmp_x)
        # y.append(tmp_y)
        Coordinates.append(Coordinate(tmp_x, tmp_y, i))

    sorted_by_x = sorted(Coordinates, key=lambda coordinate: coordinate.x)
    sorted_by_y = sorted(Coordinates, key=lambda coordinate: coordinate.y)

    Edges = []
    for i in range(0, N - 1):
        cost_x = min(abs(sorted_by_x[i].x - sorted_by_x[i + 1].x), abs(sorted_by_x[i].y - sorted_by_x[i + 1].y))
        Edges.append(Edge(sorted_by_x[i].n, sorted_by_x[i + 1].n, cost_x))
        # Edges.append(Edge(sorted_by_x[i + 1].n, sorted_by_x[i].n, cost_x))
        cost_y = min(abs(sorted_by_y[i].x - sorted_by_y[i + 1].x), abs(sorted_by_y[i].y - sorted_by_y[i + 1].y))
        Edges.append(Edge(sorted_by_y[i].n, sorted_by_y[i + 1].n, cost_y))
        # Edges.append(Edge(sorted_by_y[i + 1].n, sorted_by_y[i].n, cost_y))

    par = [0 for i in range(N)]
    rank = [0 for i in range(N)]
    V = N
    E = 2 * (N - 1)

    print(kruskal())


Measured memory_bytes: 81100
A, B, K = map(int, input().split())
count = 0

def cookie(x, y, k, c):

    if x % 2 == 1:
        x -= 1
    y = y + x//2
    x = x//2
    k -= 1
    c += 1
    
    if k == 0:
        if c % 2 == 1:
            print(x, y)
        else:
            print(y, x)
        return 0
    
    cookie(y, x, k, c)

cookie(A, B, K, count)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e9
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;
int h[100010];
signed main(){
   int n,k;
   cin>>n>>k;
   int cnt=0;
   REP(i,n) cin>>h[i];
   for (int i = 0; i < n; i++)
   {
       if(h[i]>=k) cnt++;
   }
   cout<<cnt<<endl;
   
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
int ctoi(const char c){
  switch(c){
    case '0': return 0;
    case '1': return 1;
    case '2': return 2;
    case '3': return 3;
    case '4': return 4;
    case '5': return 5;
    case '6': return 6;
    case '7': return 7;
    case '8': return 8;
    case '9': return 9;
    default : return -1;
  }
}

int main(){
  string s;
  cin >> s;
  int s0=0;
  int s1=0;
  rep(i,s.size()){
    if(ctoi(s[i])-i%2 != 0) s0++;
    else s1++;
//    cout << ctoi(s[i]) << endl;
  }
  cout << min(s0,s1) << endl;
}
    

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<utility>
#include<functional>
#include<stack>
#include<queue>
#include<cmath>

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
# define MOD 1000000000+7
# define INF 1000000000
typedef long long ll;
using namespace std;
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }


int main() {
	int a, b, c;
	cin >> a >> b >> c;
	cout << min(a * b, c) << endl;
	
}



Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;
 
public class Main {
 
    public static void main(String[] args) throws IOException {
             
       Scanner sc = new Scanner(System.in);
       int s = sc.nextInt();
       int h = 0;
       int m = 0;
       
       while(s>=3600){
    	   s = s-3600;
       h++;
       }
       
       while(s>=60){
           s = s-60; 
       m++;
       
       
       }
      
       
       System.out.println(h+":"+m+":"+s);
           
         
    }
}

Measured memory_bytes: 17228
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    a = LI()

    return sum(a) - max(a)


print(main())





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

db dp[3000][1600];

db fun(int c,int h,db *a)
{
    if(h==0)return 1;
    if(c==0)return 0;
    if(dp[c][h]>-0.9)return dp[c][h];
    return dp[c][h]=a[c-1]*fun(c-1,h-1,a)+(1-a[c-1])*fun(c-1,h,a);
}
void solve()
{
    int n;
    cin>>n;
    db a[n];
    for(int i=0; i<n; i++){
        cin>>a[i];
    }
    int h=(n+1)/2;
    memset(dp,-1,sizeof(dp));
    fun(n,h,a);
    cout<<fixed<<setprecision(10)<<dp[n][h];
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    t=1;
    while(t--){
        solve();
        cout<<endl;
    }
}


Measured memory_bytes: 79096
#include <bits/stdc++.h>
#define ld long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define per(i, a, b) for(int i = b-1; i>=a ; i--)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define Unique(v) sort(all(v));v.erase(unique(all(v)),v.end());
#define sz(v) (int)v.size()
#define int long long
using namespace std;
typedef vector<int> vi;
#define y1 abacaba
#define left sefude
#define db(x) cerr << #x <<" == "<<x << endl;
#define db2(x,y) cerr<<#x <<" == "<<x<<", "<<#y<<" == "<<y<<endl;
#define db3(x,y,z) cerr << #x<<" == "<<x<<", "<<#y<<" == "<<y<<", "<<#z<<" == "<<z<<endl; 
#define prl cerr<<"called: "<< __LINE__<<endl;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
inline ll mod(ll n, ll m ){ ll ret = n%m; if(ret < 0) ret += m; return ret; }
ll gcd(ll a, ll b){return (b == 0LL ? a : gcd(b, a%b));}
ll exp(ll a,ll b,ll m){
    if(b==0LL) return 1LL;
    if(b==1LL) return mod(a,m);
    ll k = mod(exp(a,b/2,m),m);
    if(b&1LL){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);
}

const int M = 1e9 + 7;
int32_t main(){
  fastio;
  ll res=0;
  int n;
  cin>>n;
  ll sum=0;
  for(int i=1;i<=n;i++){
    ll x;
    cin>>x;
    res = (res + sum * x)%M;
    sum+=x;
    sum%=M;
  } 
  cout << res << endl;
  // math -> gcd it all
  // Did u check N=1? Did you switch N,M?
}

Measured memory_bytes: 3616
from bisect import bisect_right
n = int(input())
d = {}
for a in map(int, input().split()):
  if a in d:
    d[a] += 1
  else:
    d[a] = 1
amax = max(d.keys())
t = 1
power_of_two = []
while t < 2 * amax:
  t *= 2
  power_of_two.append(t)
result = 0
keys = list(sorted(d.keys(), reverse = True))
for a in keys:
  if a not in d:
    continue
  t = power_of_two[bisect_right(power_of_two, a)] - a
  while True:
    if t not in d:
      break
    if a == t and d[a] == 1:
      break
    result += 1
    if d[a] == 1:
      del d[a]
    else:
      d[a] -= 1
    if d[t] == 1:
      del d[t]
    else:
      d[t] -= 1
    if a not in d:
      break
print(result)


Measured memory_bytes: 44592
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
#define all(c) (c).begin(), (c).end()
#define loop(i,a,b) for(ll i=a; i<ll(b); i++)
#define rep(i,b) loop(i,0,b)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#ifdef DEBUG
#define dump(...) (cerr<<#__VA_ARGS__<<" = "<<(DUMP(),__VA_ARGS__).str()<<" ["<<__LINE__<<"]"<<endl)
struct DUMP:ostringstream{template<class T>DUMP &operator,(const T&t){if(this->tellp())*this<<", ";*this<<t;return *this;}};
#else
#define dump(...)
#endif
template<class T> ostream& operator<<(ostream& os, vector<T> const& v){
    rep(i,v.size()) os << v[i] << (i+1==(int)v.size()?"":" ");
    return os;
}

int N,M,A,B,C,T;
int S[55];

#define MCR mat const&
template<typename T>
struct mat {
    vector<vector<T>> dat;
    int height, width;
    mat(int height = 0, int width = 0): dat(height, vector<T>(width)), height(height), width(width){}
    vector<T> const & operator [] (int i) const { return dat[i]; };
    vector<T> & operator [] (int i){ return dat[i]; };
    mat & operator += (MCR v){ rep(i,height) rep(j,width) dat[i][j]+=v[i][j]; return *this; }
    mat & operator -= (MCR v){ rep(i,height) rep(j,width) dat[i][j]-=v[i][j]; return *this; }
    mat & operator *= (MCR b){
        mat res(height, b.width);
        rep(i,height) rep(k,b.height) rep(j,b.width) (res[i][j] += dat[i][k]*b[k][j]) %= M;
        return *this = res;
    }
    mat operator +  (MCR v) const { return mat(*this) += v; }
    mat operator -  (MCR v) const { return mat(*this) -= v; }
    mat operator *  (MCR v) const { return mat(*this) *= v; }
    bool operator <  (MCR v) const { return dat < v.dat; }
    mat exp(ll t) const { int n = height; mat e = *this, res(n,n); rep(i,n) res[i][i] = 1; for(; t; e*=e, t>>=1) if(t&1) res *= e; return res; }
    mat trans() const { mat t(width, height); rep(i,width) rep(j,height) t[i][j] = dat[j][i]; return t; }
};

typedef mat<int> matrix;

int main(){
#ifdef LOCAL
    freopen("in","r", stdin);
#endif
    while(cin>>N>>M>>A>>B>>C>>T && N){
        matrix a(N,N), x(N,1);
        rep(i,N) cin >> x[i][0];
        rep(i,N){
            if(i!=0) a[i][i-1] = A;
            a[i][i] = B;
            if(i!=N-1) a[i][i+1] = C;
        }
        auto p = a.exp(T);
        rep(i,p.dat.size()){
            dump(i,p.dat[i]);
        }
        cout << (p * x).trans()[0] << endl;
    }
}

Measured memory_bytes: 1288
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using Pair = pair<int64_t, int64_t>;
constexpr int64_t kInf = INT64_MAX / 2L;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  int64_t L, X;
  cin >> L >> X;
  vector<int64_t> N(L + 1, 1);
  vector<int64_t> P(L + 1, 1);
  for (int64_t i = 1; i <= L; ++i) {
    N[i] = 2 * N[i - 1] + 3;
    P[i] = 2 * P[i - 1] + 1;
    // cerr << i << ", " << P[i] << endl;
  }
  auto Get = [&](auto &&Func, const int64_t level, const int64_t n) -> int64_t {
    if (level == 0) {
      return 1;
    } else if (n <= 1) {
      return 0;
    } else if (n >= N[level]) {
      return P[level];
    } else if (n <= N[level - 1] + 1) {
      return Func(Func, level - 1, n - 1);
    } else if (n <= N[level - 1] + 2) {
      return Func(Func, level - 1, n - 1) + 1;
    } else {
      return P[level - 1] + 1 + Func(Func, level - 1, n - 2 - N[level - 1]);
    }
  };
  cout << Get(Get, L, X) << endl;
  return 0;
}


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

int main() {
    int n;
    cin >> n;
    long r = 1, e = 1e18;
    for(int i = 0; i < n; i++) {
        long a;
        cin >> a;
        if(r && a >= (e + r) / r)
            r = 2e18;
        else
            r *= a;
    }
    cout << (r > e ? -1 : r) << endl;
    return 0;
}


Measured memory_bytes: 3636
N,K=gets.chomp.split(' ').map{|n| n.to_i}
X=gets.chomp.split(' ').map{|n| n.to_i}

INT_MAX = 100000000000000000000
min = INT_MAX
for i in 0..(N-1-(K-1))
	tmp = (X[i+K-1]-X[i]).abs
	val = [tmp+X[i+K-1].abs,tmp+X[i].abs].min
	min > val ? min = val : 0
end
puts min


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

#define ll long long
#define F first
#define S second
#define ii pair < int , int >
#define ever (;;)

const int N = 200100;

char A[N];
string s;
int n;
vector <int> r,w;

int main()
{
    scanf("%d%s",&n,&A);
    s = A;

    for(int i=0;i<n;i++)
    {
        if( s[i] == 'R' )
            r.push_back(i);
        else
            w.push_back(i);
    }

    int szr = (int)(r.size());
    int szw = (int)(w.size());

    if( !szr || !szw )
    {
        printf("0\n");
        return 0;
    }

    int pr = szr-1;
    int pw = 0;
    int ans = 0;

    while( pr != -1 && pw != szw )
    {
        if( r[pr] < w[pw] )
            break;

        ans++;
        pr--;
        pw++;
    }

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


Measured memory_bytes: 5000
#include <bits/stdc++.h>
using namespace std;
const int MAX = 410000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];
//invの要素にはiの逆元が格納されている
//前処理
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;//i!(mod MOD)を計算
        inv[i] = MOD - inv[MOD%i]* (MOD / i) % MOD;//iの逆元を計算
        finv[i] = finv[i - 1] * inv[i] % MOD;//i!(mod MOD)の逆元を計算
    }
}

// 二項係数計算
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;//nCk = n!/(k!*(n-k)!)を計算
}

int main(){
  COMinit();
    int n, k;
    cin >> n >> k;
    if(n - 1 <= k) cout << COM(n + n -1, n) << endl;
    else {
        long long ans = 0;
        if(k == 1) {
            cout << n * (n - 1) << endl;
            return 0;
        }
        for(int i = 0; i <= k; i++){
            ans += COM(n, i) * COM(n - 1, i) % MOD;
            ans %= MOD;
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 9856
a=int(input())
b=int(input())
c=int(input())
x=int(input())
ans=0
for i in range(0,a+1):
  for j in range(0,b+1):
    for k in range(0,c+1):
      if (i*500+j*100+k*50==x):
        ans+=1
        break
      elif (i*500+j*100+k*50>x):
        break

print(ans)

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

int main() {

  while( true ) {

    long long int n, input;

    cin >> n;

    if ( n == 0 ) break;

    bool flag = false;

    long long int ans = 1;

    for ( long long int i = 0; i < n; i++ ) {

      cin >> input;

      if ( input >= 2 ) flag = true;

      if ( input >= 1 ) ans++;

    }

    if ( flag == false ) {
      cout << "NA" << endl;
    }else {
      cout << ans << endl;
    }

  }

  return 0;

}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;

int main() {
  int n;
  cin >> n;
  vi c(n-1); vi s(n-1); vi f(n-1);
  rep(i,n-1) cin >> c[i] >> s[i] >> f[i];
  rep(i,n) {
    int t = 0;
    for(int j = i; j < n-1; j++) {
      if(t<s[j]) t = s[j];
      else if(t%f[j]==0);
      else t += (f[j]-t%f[j]);
      t += c[j]; 
    }
    cout << t << endl;
  }
  return 0;
}

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


typedef long long int ll;


#define MOD 1000000007
#define MAX 100001

using namespace std;

ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int 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;
    }
}

// 二項係数計算
ll 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;
}

int main(void){
    int N,K;
    cin >> N >> K;
    COMinit();
    vector<int> v;
    for(int i=0;i<N;i++){
      int tmp;
      cin >> tmp;
      v.push_back(tmp);
    }
    sort(v.begin(),v.end());
    ll ans = 0;
    for(int i=K;i<=N;i++){
      ans = ans + (v[i-1] * COM(i-1,K-1))%MOD;
    }
    for(int i=0;i<=N-K;i++){
      ans = (ans + MOD - (v[i]*COM(N-i-1,K-1))%MOD)%MOD;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3196
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  long long k,s=1,t=1;
  int d[n],e[n];
  for(int i=0;i<n;i++){
    cin >> d[i];
    e[i]=0;
  }
  e[0]=1;
  for(int i=1;i<n;i++){
    if(d[i]==0){
      cout << "0" << endl;
      return 0;
    }
  }
  if(d[0]!=0){
    cout << "0" << endl;
    return 0;
  }
  else{
    for(int i=1;i<n;i++){
      k=d[i];
      e[k]++;
    }
    for(int i=1;i<n;i++){
      if(e[i]==0){
        for(int l=i+1;l<n;l++){
          if(e[l]!=0){
            cout << "0" << endl;
            return 0;
          }
          else{
            cout << s << endl;
            return 0;
          }
        }
      }
      else{
        for(int z=0;z<e[i];z++){
          t=t*e[i-1]%998244353;
        }
        s=s*t%998244353;
        t=1;
      }
    }
  }
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define MAX 2010
#define MOD 1000000007
using namespace std;

int arr[MAX];
int brr[MAX];
int dp[MAX][MAX];

int add(int a, int b)
{
	return (a + b) % MOD;
}

int sub(int a, int b)
{
	return (MOD + a - b) % MOD;
}

int get(int a, int b)
{
	if (a < 0 || b < 0) return 1;
	if (dp[a][b] != -1) return dp[a][b];
	int ans = add(get(a - 1, b), get(a, b - 1));
	if (arr[a] != brr[b]) ans = sub(ans, get(a - 1, b - 1));
	dp[a][b] = ans;
	return ans;
}

int main(void)
{
	int N, M;
	cin >> N >> M;
	for (int i = 0; i < N; i++) cin >> arr[i];
	for (int i = 0; i < M; i++) cin >> brr[i];
	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < M; j++) dp[i][j] = -1;
	}
	cout << get(N - 1, M - 1) << endl;
	return 0;
}


Measured memory_bytes: 16384
def main():
    S = list(input())
    SR = list(reversed(S))
    if(S != SR):
        print("No")
        return 0
    s = S[0:(len(S)-1)//2]
    sr = list(reversed(s))
    if(s != sr):
        print("No")
        return 0
    print("Yes")

main()


Measured memory_bytes: 3060
fun main(args: Array<String>){
	readLine()!!
	val a = readLine()!!.split(" ").map { it.toInt() } // Array

  var ave = a.average()

	// println(ave)

  var minDiff = 9999.0
  var ans = -1
  for ((i, v) in a.withIndex()) {
    val diff = Math.abs(v - ave)
    if ( diff < minDiff) {
      minDiff = diff
      ans = i
    }
  }

	println(ans)
}

Measured memory_bytes: 35952
#include<bits/stdc++.h>
using namespace std;
int main(){
    char ch;
    long long n , q ,type , l , r , in , i , ans;
    string s;
    cin >> n >> s >> q;
    set<long long> st[26];
    for(i = 0 ; i < n ; i++){
        st[s[i] - 'a'].insert(i);
    }
    while(q--){
        cin >> type;
        if(type == 1){
            cin >> in >> ch;
            in = in - 1;
            if(s[in] != ch){
                st[s[in] - 'a'].erase(st[s[in] - 'a'].find(in));
                s[in] = ch;
                st[s[in] - 'a'].insert(in);
            }
        }
        else{
            cin >> l >> r;
            ans = 0;
            l--;r--;
            for(i = 0 ; i < 26 ; i++){
                auto itl = st[i].lower_bound(l);
                if(itl == st[i].end())
                    continue;
                in = *itl;
                if(in >= l and in <= r){
                    ans++;
                }
                // itl = st.upper;
        //         in = *itl;
        //         if(itl!= st[i].end() and in >= l and in <= r){
        //               ans++;
        //               continue;
        //         }
            }
            cout << ans << "\n";
        }
    }
    return 0;
}

Measured memory_bytes: 24196
#include <bits/stdc++.h>
using namespace std;
#define forloop(n) for(int i = 0; i < n; i++)
#define ll long long
/*ll sum(vector<ll> vec, int left, int right){
	if(right == left){
		return vec[0];
	}
	return vec[right] + sum(vec, left, right-1);
}*/
int main(){
	int n; cin>>n;
	vector<ll> vec(n);
	ll toplam = 0;
	forloop(n){
		scanf("%d", &vec[i]);
		toplam += vec[i];
	}
	ll sum = 0, min = 2020202020;
	for(int i = 0; i < n; i++){
		if(abs(toplam - 2*sum) < min){
			min = abs(toplam-2*sum);
			if(toplam - 2*sum < 0){
				break;
			}
		}
		sum += vec[i];
	}
	cout<<min;
	return 0;
}

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

#define repv(i, v) for (int (i)(0); (i)<(v.size()); ++(i))
using namespace std;

int main(){
	string s;
	cin >> s;
	int a(0);
	repv(i, s) {
		if (s[i] == '+') {
			++a;
		}
		else {
			--a;
		}
	}
	cout << a << endl;
	return 0;
}

Measured memory_bytes: 256
import pprint
from collections import defaultdict

N, K = map(int, input().split())

bucket = defaultdict(int)
for _ in range(N):
    a, b = map(int, input().split())
    bucket[a] += b

R = 0
for n in range(1, 10 ** 5 + 1):
    if K <= bucket[n]:
        print(n)
        break
    K -= bucket[n]



Measured memory_bytes: 17712
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <complex>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <iterator>

using namespace std;

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define iter(c) __typeof__((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define all(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

const int INFTY=1<<29;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

bool ok(vi b)
{
	int d=b[1]-b[0];
	repi(i,1,b.size())
		if(b[i]-b[i-1]!=d)
			return false;
	return true;
}

int main()
{
	for(int n;cin>>n,n;){
		vi a(n+1);
		rep(i,n+1) cin>>a[i];
		rep(i,n+1){
			vi b;
			rep(j,n+1) if(j!=i)
				b.push_back(a[j]);
			if(ok(b)){
				cout<<a[i]<<endl;
				break;
			}
		}
	}
	
	return 0;
}

Measured memory_bytes: 1220
(n, k, q) = map(int, input().split())
a = [int(input()) for _ in range(q)]
points = [0 for _ in range(n)]

for i, answer in enumerate(a):
    points[answer-1] += 1

for i, p in enumerate(points):
    result = "Yes" if k - q + p > 0 else "No"
    print(result)


Measured memory_bytes: 8632
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def exit(*argv, **kwarg):
    print(*argv, **kwarg)
    sys.exit()


def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))
# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと


def a_int(): return int(read())


def ints(): return list(map(int, read().split()))


def read_col(H):
    '''H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_tuple(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_matrix(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter, xor, add
from itertools import accumulate, product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right
from functools import reduce
from math import gcd


def lcm(a, b):
    # 最小公倍数
    g = gcd(a, b)
    return a // g * b

# https://atcoder.jp/contests/abc059/tasks/arc072_a

# si=a1+..+aiと定義する
# s1...si,si+1,snの符号は+-+-... or -+-+...にしたい←両方試せばいい
# +-+-にするのに最小の操作は？


n = a_int()
A = ints()
S = list(accumulate(A))

#+-+-のとき
now = 1  # 正負
pad = 0
ans1 = 0
for s in S:
    s += pad
    if s * now <= 0:  # 異符号だったら修正する必要あり
        if now == 1:  # +にしたい場合
            n_ope = 1 - s
            pad += n_ope
        else:  # -にしたい場合
            n_ope = s + 1
            pad -= n_ope
        ans1 += n_ope
    now *= -1

#-+-+のとき
now = -1  # 正負
pad = 0
ans2 = 0
for s in S:
    s += pad
    if s * now <= 0:  # 異符号だったら修正する必要あり
        if now == 1:  # +にしたい場合
            n_ope = 1 - s
            pad += n_ope
        else:  # -にしたい場合
            n_ope = s + 1
            pad -= n_ope
        ans2 += n_ope
    now *= -1

# print(S)
# print(ans1, ans2)
print(min(ans1, ans2))


Measured memory_bytes: 95136
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;
using System.Numerics;

public class Program
{
    public static void Main(string[] args)
    {
        int[] nmxy = Console.ReadLine().Split(' ').Select(ti => int.Parse(ti)).ToArray();
        int n = nmxy[0];
        int m = nmxy[1];
        int x = nmxy[2];
        int y = nmxy[3];

        int[] xs = Console.ReadLine().Split(' ').Select(ti => int.Parse(ti)).ToArray();
        int[] ys = Console.ReadLine().Split(' ').Select(ti => int.Parse(ti)).ToArray();

        int xm = xs.Max() + 1;
        int ym = ys.Min();

        bool xin = (x < xm) && (xm <= y);
        bool yin = (x < ym) && (ym <= y);

        bool nc = ym >= xm;
        bool nw = nc && xin && yin;

        Console.WriteLine(nw ? "No War" : "War");
        Console.ReadLine();
    }
}

Measured memory_bytes: 13396
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define p push_back
#define endl "\n"
#define l long long int
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    l n;
    cin>>n;
    (n>=30)?cout<<"Yes":cout<<"No";
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll=long long int;
using ld=long double;
using VI=vector<ll>;
using VD=vector<ld>;
using VVI=vector<VI>;
using VC=vector<char>;
using VVC=vector<VC>;
using VS=vector<string>;
using PLL =pair<ll,ll>;
using PLD=pair<ld,ld>;
using VPLL=vector<PLL>;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element((x).begin(),(x).end())
#define MIN(x) *min_element((x).begin(),(x).end())
#define SORTR(x) sort((x).rbegin(),(x).rend())
#define SORT(x) sort((x).begin(),(x).end())
#define SUM(x) accumulate((x).begin(),(x).end(), 0)
#define FILL(x,a) fill(x.begin(),x.end(),a)
#define EACH(i,x) for(typeof((x).begin()) i=(x).begin(); i!=(x).end(); ++i)

const int INF  = 1<<30;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;
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; }
template <class BidirectionalIterator>
bool next_partial_permutation(BidirectionalIterator first, BidirectionalIterator middle,BidirectionalIterator last){reverse(middle, last); return next_permutation(first , last);}
#define COUT(x) cout<<x<<"\n"

void Main()
{
	ll N;
	ll result=0;
	string S;
	cin>>N;
	if(N==1) {
		COUT("Hello World");
		return;
	}
	else {
		ll A,B;
		cin>>A>>B;
		COUT(A+B);
	}
}

int main()
{
	std::cin.tie(0);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll  long long int 
using namespace std;
int main()
{
	int n,k,r,s,p,i;
	string a;
	cin>>n>>k>>r>>s>>p;
	int dp[100005][3]={0};
	cin>>a;
	ll ans=0;
	for(i=0;i<k;i++)
	{
		if(a[i]=='r')
		{	ans+=p;
			dp[i][2]=1;
		}
		else if(a[i]=='s')
		{
			ans+=r;
			dp[i][0]=1;
		}
		else {
			ans+=s;
			dp[i][1]=1;
		}		
	}
	for(i=k;i<a.size();i++)
	{
		if(a[i]=='r' && dp[i-k][2]==0)
		{	ans+=p;
			dp[i][2]=1;
		}
		else if(a[i]=='s' && dp[i-k][0]==0)
		{
			ans+=r;
			dp[i][0]=1;
		}
		else if(a[i]=='p' && dp[i-k][1]==0)
		{
			ans+=s;
			dp[i][1]=1;
		}
	}
	cout<<ans<<endl;
	
	
}

Measured memory_bytes: 1664
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> IP;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)


int main() {
	string S;
	cin >> S;
	bool AA = false;
	int Z = S.size();
	rep(i, Z - 1) {
		if (S[i] == 'A' && S[i + 1] == 'A') {
			AA = true;
		}
	}
	bool KIH = false;
	rep(i, Z - 2) {
		if (S[i] == 'K' && S[i+1] == 'I' && S[i+2] == 'H') {
			KIH = true;
		}
	}
	string SS;
	rep(i, Z) {
		if (S[i] != 'A') {
			SS.push_back(S[i]);
		}
	}
	if (SS == "KIHBR" && AA == false && KIH == true) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	//cout << SS << ' ' << AA << ' ' << KIH << endl;
}


Measured memory_bytes: 256