akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define whlie while
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repr(i,N) for(int i = (N) - 1; i >= 0; i--)
#define rep1(i,N) for(int i = 1; i <= (N) ; i++)
#define repr1(i,N) for(int i = (N) ; i > 0 ; i--)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define vrep(v,it) for(auto it = v.begin(); it != v.end(); it++)
#define vrepr(v,it) for(auto it = v.rbegin(); it != v.rend(); it++)
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
using namespace std; void solve();
using ll = long long; using vl = vector<ll>;
using vi = vector<int>; using vvi = vector< vector<int> >;
constexpr int inf = 1001001001;
constexpr ll infLL = (1LL << 61) - 1;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(7);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cerr << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,...) do { cerr << #v << " = "; array_out(v , __VA_ARGS__ );} while(0)
#else
  #define trc(...)
  #define trca(...)
  int main(){solve();}
#endif
 
using P = pair<ll,ll>; using vp = vector<P>;
constexpr int MOD = /**/ 1000000007; //*/ 998244353;
/////////////////

int dp[110][10200];

void solve(){
  ini(N);
  vi v(9 , 0);
  rep(i , N){
    ini(x); v[min(8 , x / 400)]++;
  }
  int cnt = 0;
  rep(i , 8) cnt += (v[i] != 0);
  int mi = cnt + (v[8] != 0 && cnt == 0);
  int ma = cnt + v[8];
  out(mi , ma);
}



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

typedef long long llint;
typedef long double ld;

#define inf 1e18
#define mod 1000000007
priority_queue<llint,vector<llint>,greater<llint> > que;
priority_queue<llint> Que;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


string s;
llint k;

void solve(){
  cin >> s;
  cin >> k;
  llint n=s.size();
  llint ans=0;
  llint cnt=1;
  for(int i=1;i<n;i++){
      if(s[i-1]==s[i])cnt++;
      if(s[i-1]!=s[i] && cnt>1){
          ans+=(cnt/2)*k;
          cnt=1;
      }
  } 
  if(n==cnt)ans+=(n*k)/2;
  else if(cnt>1)ans+=(cnt/2)*k;
  if(s[0]==s[n-1] && n!=cnt){
      llint a=0,b=0;
      for(;s[a]==s[0];a++);
      for(;s[n-b-1]==s[n-1];b++);
      ans-=(((a/2)+(b/2))-(a+b)/2)*(k-1);
  }
  cout << ans << endl; 
}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 256
while s=gets
  s = s.chomp.split(',').map(&:to_i)
  v1 = s[10].to_f
  v2 = s[11].to_f
  sum = 0.0
  for i in 0...10
    sum += s[i].to_f
  end
  t = sum/(v1+v2)
  l = v1*t;
  sum = 0.0
  id = 0
  for i in 0...10
    sum += s[i]
    if l <= sum
      id = i+1
      break
    end
  end
  puts id
end

Measured memory_bytes: 8624
#include <iostream>

using namespace std;

int main()
{
  int a, b;
  int n;

  while (cin >> a >> b >> n){
    int s = 0;
    for (int i = 0; i < n; i++){
      a *= 10;
      s += a / b % 10;
      a %= b;
    }
    cout << s << endl;
  }

  return (0);
}

Measured memory_bytes: 1160
"""
now...今注目する値
used...使った数字の数
sum...それまでの合計

dp[now][used][sum]...nowまででused個の数字を使って合計sumの場合の数

dp[now][used][sum] = dp[now - 1][used - 1][sum - now] + dp[now - 1][used][sum] (used >= 1 and sum >= now)
                     dp[now - 1][used][sum]                                    (used == 0  or  sum < now)


2次元化

dp[used][sum]...used個の数字を使って合計sumの場合の数

dp[used][sum] = dp[used - 1][sum - now] + dp[used][sum] (used >= 1 and sum >= now)

ただし、usedの大きい順に更新する(更新がかぶるため)
"""

dp = [[0 for _ in range(1001)] for _ in range(10)]
dp[1][0] = 1
dp[0][0] = 1

for now in range(1, 101):
  for used in range(9, 0, -1):
    for s in range(now, 1001):
      dp[used][s] = dp[used - 1][s - now] + dp[used][s]

while True:
  n, s = map(int, input().split())
  if not n:
    break
  print(dp[n][s])


Measured memory_bytes: 5732
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
////////////////////////////

ll n;
#define N 500005
ll has[N+1];
ll base=1007;
ll po(ll i,ll p){
    if(p==0)return 1;
    else{
        i=mod(i);
        if(p==1)return i;
        if(p%2==0)return po(mod(i*i),p/2);
        return mod(i*po(i,p-1));
    }
}

bool same(ll hasi,ll pw,ll j,ll len){
    ll endj=j+len;
    ll hasj=mod(has[endj]-has[j]*pw);
    if(hasi>hasj)swap(hasi,hasj);
    if(mod(hasj-hasi)==0)return true;
    return false;
}

bool check(ll len){
    rep(i,0,n-1){
        if(i+len+len>n)break;
        ll pw=po(base,len);
        ll endi=i+len;
        ll hasi=mod(has[endi]-has[i]*pw);
        rep(j,i+len,n-1){
            if(j+len>n)break;
            if(same(hasi,pw,j,len))return true;
        }
    }
    return false;
}
int main(){fastio
    cin>>n;
    string s;cin>>s;
    has[0]=0;
    rep(i,0,n-1){
        has[i+1]=mod(has[i]*base+s[i]);
    }
    //rep(i,0,n)cout<<has[i]<<endl;
    ll ok=0,ng=n;
    while(abs(ok-ng)>1){
        ll mid=(ok+ng)/2;
        if(check(mid)){
            ok=mid;
        }else{
            ng=mid;
        }
    }
    cout<<ok<<endl;
    return 0;
}


Measured memory_bytes: 384
n,x,y=map(int,input().split())
l=[0]* n
for i in range(1,n):
    for j in range(i+1,n+1):
        length=min(j-i,max(y-j,j-y)+max(x-i,i-x)+1)
        l[length]+=1
for k in range(1,n):
    print(l[k])


Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
int a[100001],b[100001];
int main()
{
	int n;
	cin>>n;
	for (int i=1;i<=n;i++)  cin>>a[i];
	for (int i=1;i<=n;i++)  b[a[i]]=i;
	for (int i=1;i<=n;i++)  cout<<b[i]<<' ';
	cout<<endl;
	return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <cstdio>
#include <utility>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstring>
#include <cstdlib>
#include <iomanip>
#include <string>
#include <ctype.h>

const int INF =100000000;

using namespace std;

int main(){

  int sa = 4280;

  while(1){


    int w;

    cin >> w;

    if(w == -1){
      break;
    }

    int m=1150;

    if(w > 10){

      m += 125*(min(w-10,10));

      if(w > 20){

	m += 140*(min(w-20,10));

	if(w > 30){

	  m += 160*(w-30);
	}
      }
    }

    cout << sa -m << endl;
  }
}


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

#define all(x) (x).begin(), (x).end()
#define int long long


signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int a, b, n;
    cin >> a >> b >> n;
    int ans = 0;
    int i = 0;
    for (int x = min(n, b - 1); x <= n && i <= 5e6; ++x, ++i) {
        ans = max(ans, (a * x) / b - a * (x / b));
    }
    cout << ans;
}


Measured memory_bytes: 3652
#include<stdio.h>

int n,A[50];

int solve(int i,int m){
  if(m==0) return 1;
  if(i>=n) return 0;
  int res = solve(i+1,m)||solve(i+1,m-A[i]);
  return res;
}


int main(){

  int m,i,q;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }

  scanf("%d",&q);
  
  for(i=0;i<q;i++){
    scanf("%d",&m);
    if(solve(0,m))printf("yes\n");
    else printf("no\n");
  }

  return 0;

}
    



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

/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))
#define isin(a, b, c) (b <= a && a <= c)
#define println cout << "\n";
#define sz(v) (int)v.size()
#define bin(x) static_cast<bitset<16> >(x)


/* alias */
template<class T> using vec = vector<T>;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef tuple<int, int, int> ti;
typedef map<int, int> mi;
typedef set<int> si;


/* constant */
const int inf = 1LL << 62;
const int mod = 1e9 + 7;
const int dx[8]={1,0,-1,0,-1,1,-1,1};
const int dy[8]={0,1,0,-1,-1,-1,1,1};
const string alphabet = "abcdefghijklmnopqrstuvwxyz";

/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T, class U, class V> void printx(tuple<T, U, V> t){cout << "{" << get<0>(t) << "," << get<1>(t) <<"," << get<2>(t) << "}" << endl;}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}
template<class T> void printans(vec<T> v){rep(i,0,sz(v)){cout << v[i] << (i == sz(v) - 1 ? "" : " ");}cout << endl;}


/* general_method */
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 T>T cut(T &a, int l, int r){return T(a.begin()+l, a.begin()+r);}


/* math_method */
int ceil(int a, int b){return a / b + (a % b > 0);}


/* main */

int n;
vec<vi> arr;
void in(){
    cin >> n;
    arr.push_back({0, 0, 0});
    rep(i,0,n){
        int t, x, y;
        cin >> t >> x >> y;
        arr.push_back({t, x, y});
    }
}

void solve(){

    bool isok = true;

    rep(i,0, n){
        int tg = arr[i + 1][0] - arr[i][0];
        int dg = abs(arr[i + 1][1] - arr[i][1]) + abs(arr[i + 1][2] - arr[i][2]);

        if(dg > tg){
            isok = false;
        }

        if(tg % 2 != dg % 2){
            isok = false;
        }
    }

    if(isok){
        print("Yes");
    }else{
        print("No");
    }


}

signed main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    in();
    solve();
    
}

Measured memory_bytes: 6964
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
int gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define MOD 1000000007
#define YPB 380000
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    double x;
    string str;
    double s=0;
    cin >> n;
    rep(i,n) {
        cin >> x >> str;
        if (str=="JPY") {
            s+=x;
        }
        else if (str=="BTC") {
            s+=x*YPB;
        }
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
def main():
    s=set()
    for digit in range(16):
        for i in range(1,1000):
            c=i*10**digit+int('9'*digit or 0)
            if c<10**15:
                s.add(c)
    c=sorted(s)
    for i,n in enumerate(c):
        sn=n/sum(map(int,str(n)))
        for m in c[i+1:i+50]:
            sm=m/sum(map(int,str(m)))
            if sm<sn:
                s.remove(n)
                break
    print(*sorted(s)[:int(input())],sep='\n')
main()

Measured memory_bytes: 44892
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
    int n;
    cin >> n;
    double ans = 0;
    rep(i,n) {
        double x;
        string u;
        cin >> x >> u;
        if(u == "JPY") ans += x;
        else ans += x*380000;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define X first
#define Y second
#define debug(x) cerr << #x << ": " << x << endl;
#define ll long long int
#define endl '\n'
#define mp make_pair
#define pb push_back
#define rep(i,l,r) for (ll i=l; i<r; i++)
#define repr(i,r,l) for (ll i=r; i>=l; i--)
using namespace std;
const long long int N=2e3+30;
pair <ll,ll> d[N];
int main(){
    ll n;
    cin >> n;
    rep (i,0,n) cin >> d[i].X >> d[i].Y;
    rep (i,2,n){
        if (d[i].X == d[i].Y && d[i-1].X == d[i-1].Y && d[i-2].X == d[i-2].Y){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}



Measured memory_bytes: 3564
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include<set>
using namespace std; 
 
int main(void){
    int N;
  	scanf("%d",&N);
  	vector<string> S(N);
    for(int i=0;i<N;i++){
      cin >> S.at(i);
  	}
  	int ac=0;
    int wa=0;
    int tle=0;
    int re=0;
  	for(int j=0;j<N;j++){
      if(S.at(j)=="AC"){
         ac++;
      }else if(S.at(j)=="WA"){
        wa++;
      }else if(S.at(j)=="TLE"){
        tle++;
      }else if(S.at(j)=="RE"){
        re++;
      }
    }
      printf("AC x %d\n",ac);
      printf("WA x %d\n",wa);
      printf("TLE x %d\n",tle);
      printf("RE x %d\n",re);
}

Measured memory_bytes: 6404
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,n) for(int i=1;i<(int)(n);i++)

typedef long long ll;
using namespace std;
int main()
{
  ll a,b,c,d;
  cin>>a>>b>>c>>d;
  cout<<max(0LL,(min(b,d)-max(a,c)))<<endl;

  return 0;
}


Measured memory_bytes: 3540
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()

using ll = long long;
using ull = unsigned long long;
using namespace std;

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  if (C - (A - B) <= 0) {
    cout << 0 << endl;
  } else {
    cout << C - (A - B) << endl;
  }
  return 0;
}


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

int main(){
    int n, num;
    char cap;
    cin >> n;
    int cards[4][14]={};
    
   
    
    for(int k =0; k<n; k++){
        cin >> cap ;
        
        if(cap == 'S'){
            cin >>  num; 
            cards[0][num] = 1;
        }else if(cap == 'H'){
            cin >> num;
            cards[1][num] = 1;
        }else if(cap == 'C'){
            cin >> num;
            cards[2][num]= 1 ;
        }else if(cap == 'D'){
            cin >> num;
            cards[3][num] = 1;
        }
        
    }
    for(int i = 0; i<4 ; i++){
        for(int j = 1; j<=13; j++){
            if(cards[i][j] ==0){
                if(i==0){
                    cout << "S" << " " << j << endl;
                }else if(i == 1){
                    cout << "H" << " " << j << endl;
                }else if(i == 2){
                    cout << "C" << " " << j << endl;
                }else if(i == 3){
                    cout << "D" << " " << j << endl;
                }
            }
        }
    }
    return 0;
    
}


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

happinesses_each_day = []
for n in range(N):
    happinesses_each_day.append(list(map(int, input().split())))

dp = [[0, 0, 0] for x in range(N+1)]

for i, happinesses in enumerate(happinesses_each_day):
    for j, happiness in enumerate(happinesses):
        for k in range(3):
            if j == k:
                continue
            if dp[i + 1][k] < (dp[i][j] + happiness):
                dp[i + 1][k] = (dp[i][j] + happiness)

print(max(dp[N]))

Measured memory_bytes: 47320
# # Make IO faster
# import sys
# input = sys.stdin.readline

# # get single (or) multiple str
# X = input()

# # get single int
# N = int(input())
# # get multiple int (e.g., 2)
# X, Y = map(int, input().split())
# # get multiple int (e.g., 2) for N lines
# XY = [list(map(int, input().split())) for _ in range(N)]

# from IPython import embed; embed(); exit();

# 全部入り
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
import numpy as np
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

from bisect import bisect_left

A, B, K = MAP()
s = set()
for i in range(K):
    x = A + i
    if A <= x <= B:
        s.add(x)
for i in range(K):
    x = B - K + 1 + i
    if A <= x <= B:
        s.add(x)
for x in sorted(s):
    print(x)


Measured memory_bytes: 27324
#include <cstdio>
#include <algorithm>
using namespace std;
int main(){
	int n;
	scanf("%d", &n);
	int b[n - 1];
	for (int i = 0; i < n - 1; i++) scanf("%d", &b[i]);
	int sum = b[0] + b[n - 2];
	for (int i = 1; i < n - 1; i++) sum += min(b[i - 1], b[i]);
	printf("%d\n", sum);
}

Measured memory_bytes: 128
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        int X = sc.nextInt();
        sc.close();
        int val = K * 500;
        if(val >= X){
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }

}

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

int main()
{
    char x;
    cin >> x;

    if (x == 'a' || x == 'i'|| x == 'u' || x == 'e' || x == 'o'){
        cout << "vowel";
    }
    else{
        cout << "consonant";
    }
}

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

#define rep(i,n) for(long long int (i)=0;(i)<n;(i)++)
#define repa(i,n) for(long long int (i)=0;i<=n;i++)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define co(a) cout<<(a)<<endl;
typedef long long ll;
using namespace std;

int main(){
  int n;
  //int a,b;
  //string s;
  //string a,b;


  //cin >> a >> b;
  cin >> n;
  //cin >> s;
  if(n%2==0){
  	co(n);
  } 
  else{
  	co(n*2);
  }



  //co(ans);
  return 0;
}


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

int main(){
    int N;
    cin >> N;
    ll ans = 0;
    for (ll i = 1; i <= N; i++) {
        ans += i*(N-i+1);
    }
    
    for (int i = 0; i < N-1; i++) {
        ll u, v;
        cin >> u >> v;
        if (u > v) swap(u, v);
        ans -= u * (N-v+1);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3588
# from math import factorial,sqrt,ceil,gcd
# from itertools import permutations as permus
# from collections import deque,Counter
# import re
# from functools import lru_cache # 簡単メモ化 @lru_cache(maxsize=1000)
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

import numpy as np
# import networkx as nx
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix
# from scipy.special import comb

# slist = "abcdefghijklmnopqrstuvwxyz"
N,P = map(int,input().split())
# arrA = list(map(int,input().split()))
arrA = np.array(input().split(),dtype=np.int64)

A = arrA % 2
if not (1 in A):
    if P == 1:
        print(0)
        exit()
    else:
        print(2**N)
        exit()

even = 1
odd = 1
for i in sorted(A)[::-1][1:]:
    if i == 0:
        even *= 2
        odd *= 2
    else:
        even,odd = odd + even , odd + even
if P==0:
    print(even)
else:
    print(odd)
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))


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

bool finder(int now_place, string &S, string &T) {
  int tmp = 0;
  int S_size = S.size();
  for(int i = now_place; i < S_size; i++) {
    if(S.at(i)==T.at(tmp) || S.at(i) == '?') {
      tmp++;
      if (tmp >= T.size()) {
        return true;
      }
    } else {
      return false;
    }
  }
  return false;
}

int main() {
  string S, T, ans;
  cin >> S; cin >> T;
  int S_size = S.size(), T_size = T.size();
  vector<int> checker(S_size, 0);

  int key = -1;

  for (int i = 0; i < S_size; i++){
    if (S.at(i) == '?') {
      checker.at(i) = 1;
    }
    if(finder(i, S, T)) key = i;
  }

  if (key == -1) {
    cout << "UNRESTORABLE";
  } else {
    for(int i = 0; i < S_size; i++){
      if(checker.at(i) == 1) {
        if(i - key < 0 || i - key >= T_size) {
          S.at(i) = 'a';
        } else {
          S.at(i) = T.at(i - key);
        }
      }
    }
  cout << S << endl;
  }
}

Measured memory_bytes: 3612
import sys
import math

input = sys.stdin.readline
sys.setrecursionlimit(10 ** 5)


def main():
    N = int(input())
    name = ""
    while N:
        N, mod = divmod(N, 26)
        if mod ==0:
            name +="z"
            N-=1
        else:
            name += chr(96+mod)

    print(name[::-1])

if __name__ == "__main__":
    main()

Measured memory_bytes: 9080
N, K = gets.chomp.split(' ').map(&:to_i)
A = gets.chomp.split(' ').map(&:to_i)

count = Hash.new(0)
A.each do |ai|
  count[ai] ||= 0
  count[ai] += 1
end

ans = 0
count.values.sort.reverse.each.with_index do |c, i|
  next if i < K
  ans += c
end

print ans

Measured memory_bytes: 34160
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long min = n-1;

		for(long i =1; i * i <= n;i++) {
			if(n % i != 0) {
				continue;
			}else {
				if(min > i + n/i -2) {
					min = i + n/i -2;
				}
			}
		}
		System.out.println(min);

	}
}

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

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<(o)<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = (1LL << 31) - 1;
const int MOD = (int)(1e9 + 7);

class RangeUpdateQuery {
public:
	int n;
	vector<int> d;
	vector<int> timestamp;
	int time;
	RangeUpdateQuery(int m) {
		for (n = 1; n < m; n *= 2);
		d.assign(n * 2, INF);
		time = 0;
		timestamp.assign(n * 2, 0);
	}
	//[l, r)
	void update(int l, int r, int x) {
		time++;
		for (; l && l + (l&-l) <= r; l += l&-l) {
			d[(n + l) / (l&-l)] = x;
			timestamp[(n + l) / (l&-l)] = time;
		}
		for (; l < r; r -= r&-r) {
			d[(n + r) / (r&-r) - 1] = x;
			timestamp[(n + r) / (r&-r) - 1] = time;
		}
	}
	int get(int i) {
		int ret = d[n + i];
		int max_time = timestamp[n + i];
		for (int j = (n + i) / 2; j > 0; j >>= 1) {
			if (max_time > timestamp[j])continue;
			max_time = timestamp[j];
			ret = d[j];
		}
		return ret;
	}
};

signed main() {
	int n, q; cin >> n >> q;
	RangeUpdateQuery RUQ(n);
	rep(i, 0, q) {
		int com; cin >> com;
		if (com == 0) {
			int s, t, x; cin >> s >> t >> x;
			RUQ.update(s, t + 1, x);
		}
		else {
			int i; cin >> i;
			cout << RUQ.get(i) << endl;;
		}
	}
	return 0;
}

Measured memory_bytes: 4948
#include <iostream>
#include <vector>

using namespace std;

int main(){
    int N;
    cin >> N;
    vector<long long> table(100);
    table[0] = 2;
    table[1] = 1;
    for(int i = 2; i <= N; ++i){
        table[i] = table[i-1] + table[i-2];
    }
    cout << table[N] << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<stack>
#include<map>
#include<string>
#include<algorithm>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define P pair<int,int>
#define ll __int64
#define __int64 long long
const ll M=1000000007;
int n,sum,pos;
int t[211];
int v[211];
int r[211];
double x[211111];


bool che(int nnow,double nnv){

	int now=nnow;
	int sum=0;
	double nv=nnv;

	for(int i=pos;i<n;i++){
		int mi;
		if(i==pos){
			if(pos==0)mi=t[i]-now;
			else mi=t[i]-now+r[i-1];
		}
		else mi=t[i];

		if(nv>v[i])return 0;
		nv-=mi*0.5;
		now=t[i];
	}
	if(nv>0)return 0;
	return 1;
}

int main(){
	cin>>n;
	rep(i,n)cin>>t[i];
	rep(i,n)t[i]*=2;
	rep(i,n)sum+=t[i];
	rep(i,n)r[i]=t[i];
	for(int i=1;i<n;i++)r[i]+=r[i-1];
	rep(i,n)cin>>v[i];
	
	int cnt=t[0];

	for(int i=1;i<sum*2;i++){

		double last=0;
		double l=-0.5,r=0.5,mid=0;
		if(i>0)last=x[i-1];
		
		rep(j,50){
			if(che(i,last+mid))l=mid;
			else r=mid;
			mid=(l+r)/2;
		}
		
		x[i]=max(0.0,last+mid);
		//cout<<i<<" "<<pos<<" "<<x[i]<<endl;
		if(i>=cnt){
			cnt+=t[++pos];
		}

	}

	


	double ans=0;
	for(int i=1;i<=2*sum;i++){
			if(x[i]==x[i-1])ans+=x[i]*0.5;
			else{
				double ma=max(x[i],x[i-1]),mi=min(x[i],x[i-1]);
				ans+=mi*0.5+(ma-mi)/2*0.5;
			}
	}

	printf("%.20lf\n",ans);

	return 0;
}

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

#define MAX 300000000

string charKind = "ACGT";
bool isExistInDic[MAX] = {false};

int convertCharTable[128];

void makeConvTable(void) {
    for (int i = 0; i < charKind.size(); i++) {
        convertCharTable[charKind[i]] = i + 1;
    }
}

int getHash(const string s)
{
    int ret = 0;
    int sz = charKind.size() + 1;

    for (int i = 0; i < s.size(); i++)
        ret = ret * sz + convertCharTable[s[i]];

    return ret;
}

int main(int, char**)
{
    makeConvTable();

    int n;
    cin >> n;

    string command, arg;
    for (int i = 0; i < n; i++) {
        cin >> command >> arg;
        if (command == "insert")
            isExistInDic[getHash(arg)] = true;
        else {
            if (isExistInDic[getHash(arg)])
                cout << "yes" << endl;
            else 
                cout << "no" << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 8368
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define pye cout << "yes" << endl;
#define pno cout << "no" << endl;
#define pYe cout << "Yes" << endl;
#define pNo cout << "No" << endl;
#define pYE cout << "YES" << endl;
#define pNO cout << "NO" << endl;
#define prin(num) cout << num << endl;
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define INF 1000000000000000000
#define MOD 1000000007LL
#define MAX_V 10005
#define MAX_E 30005
#define NIL -1
#define WHITE 0
#define BLACK 1
#define mp make_pair
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;

ll N;
ll a[300001];
ll sm[2][100001];

int main(void) {
    cin >> N;
    ll i;
    for(i=0; i<N*3; i++) {
        cin >> a[i];
    }
    priority_queue<ll, vector<ll>, greater<ll>> pque1;
    for(i=0; i<N; i++) {
        sm[0][0]+=a[i];
        pque1.push(a[i]);
    }
    for(i=0; i<N; i++) {
        sm[0][i+1]=sm[0][i];
        sm[0][i+1]+=a[N+i];
        pque1.push(a[N+i]);
        sm[0][i+1]-=pque1.top();
        pque1.pop();
    }
    priority_queue<ll> pque2;
    for(i=0; i<N; i++) {
        sm[1][N]+=a[N*2+i];
        pque2.push(a[N*2+i]);
    }
    for(i=0; i<N; i++) {
        sm[1][N-1-i]=sm[1][N-i];
        sm[1][N-1-i]+=a[N*2-i-1];
        pque2.push(a[N*2-i-1]);
        sm[1][N-1-i]-=pque2.top();
        pque2.pop();
    }
    
    ll ans=-INF;
    for(i=0; i<=N; i++) {
        ans=max(ans, sm[0][i]-sm[1][i]);
    }
    
    prin(ans);
}

Measured memory_bytes: 5876
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <fstream>
#include <functional>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

#define ll long long int
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(x, a) for (auto &(x) : (a))
#define ALL(a) (a).begin(), (a).end()
#define OUT(x) out << (x) << endl;
#define M0(x) memset(x, 0, sizeof(x))
#define MINF(x) memset(x, 0x3f, sizeof(x))
#define MMINUS(a) memset(a, 0xff, sizeof(a))
#define ten(n) ((int)1e##n)

const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
const double EPS = 1.0 / LINF;
const char ENDL = '\n'; // for JetBrains IDE only supports yen

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 gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

using namespace std;

int N, M;
int use[] = { 0, 2, 5, 5, 4, 5, 6, 3, 7, 6 };
int dp[2*ten(4)+1]; // max keta with match i-hon

void updateDp(vector<int> kazu) {
    fill(dp, dp + N, -INF);
    dp[0] = 0;
    for (int i = 1; i <= N; i++) {
        int res = -INF;
        FOREACH(num, kazu) if (i - use[num] >= 0) chmax(res, dp[i - use[num]] + 1);
        dp[i] = res;
    }
}

int next(vector<int> kazu, int match) {
    FOREACH(num, kazu) {
        int nokori = match - use[num];
        if (nokori < 0) continue;
        if (dp[nokori] == dp[match] - 1) return num;
    }
}

void sol(vector<int> kazu, int match) {
    while (match > 0) {
        int n = next(kazu, match);
        cout << n;
        match -= use[n];
    }
    cout << endl;
}

int main() {
    cin >> N >> M;
    vector<int> kazu; int tmp;
    REP(i, M) { cin >> tmp; kazu.push_back(tmp); }
    sort(ALL(kazu), greater<int>());
    updateDp(kazu);
    sol(kazu, N);
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>

using namespace std;
typedef pair<string, int> P;

void solve()
{
	int N, H;
	cin >> N >> H;
	vector<P> input(N);
	for (int i = 0; i < N; ++i)
	{
		cin >> input[i].first >> input[i].second;
	}
	int mistake = 0;
	int count = 0;
	int word = 0;
	int pos = 0;
	while (word < N)
	{
		cout << "? " << input[word].first << endl;
		string s;
		cin >> s;
		++count;
		if (input[word].first[pos] == s[0] ||
			input[word].first[pos] == s[0] + 32 || 
			input[word].first[pos] == s[0] - 32)
		{
			input[word].first[pos] = '_';
			++pos;
			if (pos == input[word].first.size())
			{
				++word;
				pos = 0;
			}
		}
		else
		{
			++mistake;
			if (input[word].second == 0)
			{
				--H;
				if (H == 0)
				{
					cout << "! Game Over" << endl;
					fflush(stdout);
					return;
				}
				else
				{
					++word;
					pos = 0;
				}
			}
			else
			{
				--input[word].second;
			}
		}
	}
	printf("! Game Clear %.1lf\n", (int)((double)(count - mistake) / count * 1000) / 10.0);
	fflush(stdout);
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1300
package main

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

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	l := getNextFloat64(scanner)
	fmt.Fprintln(writer, l*l*l/27)
}


Measured memory_bytes: 1784
#include <stdio.h>
#include<stdlib.h>
#define N 100
int main(){
  int a[N], i = 0, x, y;
  char hoge[N];
  while( scanf("%s",hoge) != EOF ){
    if(*hoge == '+'){
        x = a[--i];
        y = a[--i];
        a[i++] = y + x;
    }else if(*hoge == '-'){
        x = a[--i];
        y = a[--i];
        a[i++] = y - x;
    }else if(*hoge == '*'){
        x = a[--i];
        y = a[--i];
        a[i++] = y * x;
    }else if(*hoge == '/'){
        x = a[--i];
        y = a[--i];
        a[i++] = y / x;
    }else{
        a[i++] = atoi(hoge);
    }
    
  }
  printf("%d\n", a[--i]);
  return 0;
}




Measured memory_bytes: 2048
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
cnt = 0
n,d = iim()

for _ in range(n):
    x,y = iim()
    if x**2+y**2 <= d**2:
        cnt += 1

print(cnt)

Measured memory_bytes: 9184
#include <iostream>
#include <stdio.h>
#define INF 10000
using namespace std;

struct edge {
    int from, to, cost;
};

edge es[100];
int d[11];
int n,maxV=0;

int shortest_path(int s){
    int sum=0;
    for(int i=0;i<maxV+1;i++){
        d[i] = INF;
    }
    d[s] = 0;
    while(1){
        bool update = false;
        for(int i=0;i<2*n;i++){
            edge e = es[i];
            if(d[e.from] != INF && d[e.to] > d[e.from] + e.cost){
                d[e.to] = d[e.from] + e.cost;
                update = true;
            }
        }
        if(!update){
            break;
        }
    }
    for(int i=0;i<maxV+1;i++){
        if(d[i] != INF){
        	// cout << i << " " << d[i] << endl;
            sum += d[i];
        }
    }
    return sum;
}

int main(void){
    
    while(cin >> n && n){
    	maxV = 0;
        int a, b, c, tmp, min,sum2=100000;
        for(int i=0;i<n;i++){
            cin >> a >> b >> c;
            es[i].from = a;
            es[i].to = b;
            es[i].cost = c;

            es[i+n].from = b;
            es[i+n].to = a;
            es[i+n].cost = c;
            
            if(maxV < b){
           		maxV = b;
           	}
           	if(maxV < a){
           		maxV = a;
           	}
           	
        }
        //??????????????°?????????
        for(int i=0;i<maxV+1;i++){
            int tmp = shortest_path(i);
            // cout << tmp << endl;
            if(sum2 > tmp){
                sum2 = tmp;
                min = i;
            }
        }
        cout << min << " " << sum2 << endl;
    }
    return 0;
}

Measured memory_bytes: 3088
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	int gcd(int a, int b){ return a == 0 ? b : gcd(b % a, a);}
	public void Solve(){
		
		bool setwise = false;
		int g = A[0];
		for(int i=0;i<N;i++) g = gcd(A[i], g);
		if(g == 1) setwise = true;
		
		int M = (int)1e6 + 10;
		List<int>[] P = new List<int>[M];
		for(int i=0;i<M;i++) P[i] = new List<int>();
		for(int i=2;i<M;i++){
			if(P[i].Count > 0) continue;
			for(int j=i;j<M;j+=i) P[j].Add(i);
		}
		
		int[] cnt = new int[M];
		for(int i=0;i<N;i++){
			foreach(var n in P[A[i]]) cnt[n]++;
		}
		
		bool pairwise = true;
		for(int i=0;i<M;i++) pairwise &= (cnt[i] <= 1);
		
		Console.WriteLine(pairwise ? "pairwise coprime" : setwise ? "setwise coprime" : "not coprime");
		
		
	}
	int N;
	int[] A;
	public Sol(){
		N = ri();
		A = ria();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 178232
K, A, B = map(int, input().split())

ans = 1
if A + 1 >= B  or A >= K:
    ans += K
else:
    # ビスケットがA がたまるまでの操作回数
    K -= A - 1
    # A枚→1円→B枚で2回操作
    r = K // 2
    m = K % 2
    ans = A +  r * (B - A) + m

print(ans)


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

// ある数Nが九九で表せるか?

int main(){
    int N;
    cin >> N;
    for (int i=1; i<=9; i++){
        for (int j=1; j<=9; j++){
            if (N == i*j){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}

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

using namespace std;

#define fin(ans) cout << (ans) << endl;

void Main()
{
    char a, b;
    cin >> a >> b;
    if (a == 'H')
    {
        if (b == 'D')
            fin('D') else fin('H')
    }
    else
    {
        if (b == 'D')
            fin('H') else fin('D')
    }
    return;
}

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

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


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    
    ll h,n;
    cin>>h>>n;
    ll a[n],b[n];
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i];
    }
    ll dp[n+1][h+1];
    for(int i=0;i<=n;i++){
        for(int j=0;j<=h;j++){
            dp[i][j] = 1e15;
        }
    }
    dp[0][0] = 0;
    for(int i=0;i<n;i++){
        for(int j=0;j<=h;j++){
            ll p = max(0LL, j-a[i]);
            
            dp[i+1][j] = min(dp[i+1][j], min(dp[i][j], dp[i+1][p]+b[i]));
            
        }
    }
    cout << dp[n][h] << endl;
}


Measured memory_bytes: 78464
#include <bits/stdc++.h>
using namespace std;
#define endl			"\n"
#define ll				long long
#define all(v)			((v).begin()), ((v).end())
#define sz(v)			((int)((v).size()))
#define clr(v, d)		memset(v, d, sizeof(v))
#define rep(i, v)		for(int i=0;i<sz(v);++i)
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)	for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)	for(int i=(j);i>=(int)(n);--i)
#define vi				vector <int>
#define vl				vector <ll>
#define ii				pair <ll,ll>
#define vii				vector <ii>
#define ull				unsigned long long
const double PI = 2 * acos(0.0);
void run() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr), cout.tie(nullptr);
}
int main() {
	run();
	int n;
	cin >> n;
	vi v(n);
	int mi = 1e9 + 3;
	ll ans = 0;
	int neg = 0;
	for (int i = 0; i < n; i++) {
		cin >> v[i];
		if (v[i] < 0) {
			mi = min(-v[i], mi);
			ans += -v[i];
			neg++;
		} else
			mi = min(mi, v[i]), ans += v[i];
	}

	cout << ans - (neg & 1) * mi * 2;

}


Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;

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

static const int intMAX = 1 << 31 - 1;
static const long long llMAX = 1 << 63 - 1;

int main() {
	int A, B;
	cin >> A >> B;
	
	

	cout << (A+B)%24 << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
int a,i,small,b,tii;
scanf("%d",&small);
for(i=1;i<3;i++){
scanf("%d",&a);
if(small>a){
small=a;
}else{
}
}
scanf("%d %d",&tii,&b);
if(tii>b){
tii=b;
}else{
}
small=small+tii;
small=small-50;
printf("%d\n",small);
return(0);
}


Measured memory_bytes: 2108
#include <bits/stdc++.h>
#define mod 1000000007
#define mod998 998244353
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;

int N, X, L[100], cnt, p;

int main() {
	cin >> N >> X;
	p = 0;
	cnt = 1;
	for (int i = 0; i < N; ++i) {
		cin >> L[i];
		p += L[i];
		if (p <= X)++cnt;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <sstream>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef vector <vector <int>> vii;
typedef vector <long long> vll;
typedef vector <string> vs;
typedef vector <char> vc;
typedef set <int> si;
typedef set <string> ss;
typedef queue <int> qi;
typedef queue <long long> qll;
typedef queue <string> qs;
typedef queue <char> qc;
typedef struct board board;
typedef pair <int, int> pi;
typedef pair <long long, long long> pll;
typedef pair <int, pair<int, int>> pii;

#define eb emplace_back
#define ppb pop_back
#define clr(a) a.clear()
#define F first
#define S second
#define mkp make_pair

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

#define left(x) x * 2
#define right(x) x * 2 + 1

#define meme(a, b, c) fill(a + 1, a + 1 + b, c)

#define max(a, b) (a > b ? a : b)
#define min(a, b) (a > b ? b : a)
#define abs(a) (a > 0? a : -(a))

#define move(s) s += "#"

#define fr(i, a, b) for (ll i = a; i <= b; ++ i)
#define rf(i, a, b) for (ll i = a; i >= b; -- i)

#define eprintf(...) fprintf(stderr, __VA_ARGS__);

void to_pray() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cerr << "Ready\n";
}

const int N = 4e6 + 10;
const int NN = 1e3 + 10;
const int NNN = 2e3 + 9;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const ll LLINF = 1e12 + 7;
const ll P = 53;
const int EPS = 1e-9 - 8;
const int vN = 2e4 + 10;
const int sz = (1 << 22) - 1;
const double PI = acos(-1);

int main () {
    to_pray();

    int a, b;
    cin >> a >> b;
    
    cout << (a * 3 + b) / 2;
    
    cout << '\n';
    return 0;
}

Measured memory_bytes: 256
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

na,nb,m = inm()
a = inl()
b = inl()
mn = min(a)+min(b)
for i in range(m):
    x,y,c = inm()
    v = a[x-1]+b[y-1]-c
    if v<mn:
        mn = v
print(mn)


Measured memory_bytes: 73028
#include <stdio.h>
#include <string.h>
#include <algorithm>
#define MN 100000
int n,a[MN+5],ans,tt;
struct xxx{
	int a,i;
}cnt1[MN+5],cnt2[MN+5];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		if(i&1)
			cnt1[a[i]].a++;
		else
			cnt2[a[i]].a++;
	}
	for(int i=1;i<=MN;i++)
		cnt1[i].i=cnt2[i].i=i;
	std::sort(cnt1+1,cnt1+1+MN,[](xxx a,xxx b)->bool{return a.a>b.a;});
	std::sort(cnt2+1,cnt2+1+MN,[](xxx a,xxx b)->bool{return a.a>b.a;});
	if(cnt1[1].i!=cnt2[1].i)
		printf("%d\n",n-cnt1[1].a-cnt2[1].a);
	else
		printf("%d\n",std::min(n-cnt1[1].a-cnt2[2].a,n-cnt1[2].a-cnt2[1].a));
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
    string s,t;
    cin>>s>>t;
    int lens = s.length();
    int lent = t.length();
    int dp[lens+1][lent+1];

    for(int  i = 0;i<=lens;i++)
    {
        for(int j = 0 ;j<=lent;j++)
        {
                if(i ==0 || j==0){
                  dp[i][j]=0;
                  continue;
                }

                if(s[i-1] == t[j-1])
                  dp[i][j] = dp[i-1][j-1]+1;
                else
                  dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
        }
    }

     int i = lens;int j = lent;
      string res="";
     while(i>0 && j>0)
     {
          if(s[i-1] == t[j-1]){
            res = res+s[i-1];
            i--;j--;
          }
          else
          {
              if(dp[i-1][j] == dp[i][j])
                i--;
              else
                j--;
          }
     }
     reverse(res.begin(),res.end());
     cout<<res<<endl;
}

Measured memory_bytes: 35456