akhauriyash/Code-Regression huggingface dataset:
while True:
    h,w = map(int, input().split())
    if h == w ==0:
        break
    else:
        if w %2 ==0:
            for i in range(h//2):
                print("#."*(w//2))
                print(".#"*(w//2))
            if h %2 ==1:
                print("#."*(w//2))
        else:
            for i in range(h//2):
                print("#."*(w//2), "#", sep="")
                print(".#"*(w//2), ".", sep="")
            if h %2 ==1:
                print("#."*(w//2), "#", sep="")
        print("")


Measured memory_bytes: 5616
#include<stdio.h>
#include<math.h>

int main(){
  long long n,min=999999999999; scanf("%lld",&n);
  for(long long i=1; i<=(int)sqrt(n); i++)
    if(n%i==0)if(min>i+n/i-2)min=i+n/i-2;
  printf("%ld\n",min);
  return 0;
}

Measured memory_bytes: 256
/*..........AAKASH GOYAL............*/
/*............DAIICT................*/

#include <bits/stdc++.h>
using namespace std;
 
#define    int                      long long int
 
#define    f(i,j,n)                 for(int i = j; i <= n; i++)
#define    r(i,n,j)                 for(int i = n; i >= j; i--)
#define    mod                      1000000007
#define    speed                    ios_base::sync_with_stdio(false);
#define    upp                      cin.tie(NULL);
#define    pb                       push_back
#define    mp                       make_pair
#define    T                        int tt; cin >> tt; while(tt--)
#define    ff                       first
#define    ss                       second
#define    all(container)           container.begin() , container.end()
#define    sz(container)            (int)container.size()
#define    pii                      pair <int , int>
#define    pll                      pair <long long int , long long int>
#define    ppl                      pair <long long int , pll>              //pair of ll and pair ll 
#define    sp(x)                    setprecision(x)

int power(int x, int y) 
{ 
    int res = 1;    
  
    x = x % mod; 
    while (y > 0) 
    {
        if (y & 1) 
            res = (res*x) % mod; 
  
        y = y>>1; 
        x = (x*x) % mod;   
    } 
    return res; 
} 
int32_t main()
{
    speed upp
    int n,k,mi=0,ma=0;
    cin>>n>>k;
    int a[n+1],f[n+3],inv[n+3];
    f[0]=1;
    f(i,1,n+1)
        f[i]=(f[i-1]*i)%mod;
    f(i,0,n+1)
        inv[i]=power(f[i],mod-2);
    f(i,1,n)
        cin>>a[i];
    sort(a+1,a+n+1);
    f(i,1,n-k+1)
    {
        int temp=f[n-i];
        temp=(temp*inv[k-1])%mod;
        temp=(temp*inv[n-i-k+1])%mod;
        temp=(a[i]*temp + mod)%mod;
        mi=(mi+temp + mod)%mod;
    }
    int b[n+1];
    f(i,1,n)
        b[i]=a[n-i+1];
    f(i,1,n-k+1)
    {
        int temp=f[n-i];
        temp=(temp*inv[k-1])%mod;
        temp=(temp*inv[n-i-k+1])%mod;
        temp=(b[i]*temp + mod)%mod;
        ma=(ma+temp +mod)%mod;
    }
    cout<<(ma-mi+mod)%mod;
}

Measured memory_bytes: 3328
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan = new java.util.Scanner(System.in);
        String s = scan.next();
        boolean b = false;
        if(s.charAt(0) == s.charAt(1) && s.charAt(2) == s.charAt(3)){
            b = true;
        }else if(s.charAt(0) == s.charAt(2) && s.charAt(1) == s.charAt(3)){
            b = true;
        }else if(s.charAt(0) == s.charAt(3) && s.charAt(1) == s.charAt(2)){
            b = true;
        }
        if(s.charAt(0) == s.charAt(1) && s.charAt(1) == s.charAt(2) && s.charAt(2) == s.charAt(3)){
            b = false;
        }
        if(b){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

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

int main(){
    int n;
    cin >> n;
    int a = n%10;
    if (a==2 || a==4 || a==5 || a==7 || a==9){
        cout << "hon" <<endl;
    }
    else if (a==0 || a==1 || a==6 || a==8){
        cout << "pon" <<endl;
    }
    else {
        cout <<"bon" <<endl;
    }
    return 0;
}

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

int main(){
  string s;
  cin >> s;
  char n='0';
  int cnt=0,ans=0;
  for(int i=0;i<s.size();i++){
    if(cnt==0){
      n=s.at(i);
      cnt++;
    }else{
      if(n==s.at(i)){
        cnt++;
      }else{
        cnt--;
        ans+=2;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3760
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <string>
#include <typeinfo>
#include <vector>
//#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;

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

int main()
{
  int n;
  string s;
  cin >> n >> s;

  vi nums;
  char c = '#';
  int cnt = 0;
  rep(i, n)
  {
    if (s.at(i) == c)
    {
      cnt++;
    }
    if (cnt > 0 && s.at(i) != c)
    {
      nums.push_back(cnt);
      cnt = 1;
      c = s.at(i);
    }
  }
  if (cnt > 0 && c != '#')
  {
    nums.push_back(cnt);
  }

  int temp = 0;
  int ans = 0;

  for (int i = 1; i < nums.size(); i += 2)
  {
    ans += nums.at(i);
  }
  temp = ans;
  if (nums.size() != 0)
  {
    for (int i = 1; i < nums.size() / 2 + 1; i++)
    {
      temp -= nums.at(2 * i - 1);
      temp += nums.at(2 * (i - 1));
      ans = min(temp, ans);
    }
  }

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

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

using namespace std;



#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define euc_dis(x, y) sqrt(x*x + y*y)

#define pb push_back
#define mp make_pair
#define INF 999999999
#define sp ' '
#define beg begin()
#define end end()

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
void pnum(int n){cout << n << endl;}
typedef long long ll;
typedef pair<int, int> pint;
typedef vector<int> vint;
typedef vector<string> vstr;

vector<string> split(const string &str, char sep)
{
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.pb(buffer);
    }
    return v;
}




int main(){

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

    int w, a, b;
    cin >> w >> a >> b;

    if(a<=b&&b<=a+w || b<=a+w && a+w<=b+w)
        pnum(0);
    else if(a+w <= b)
        pnum(b-a-w);
    else
        pnum(a-b-w);

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int n,i,k,a[100000];
	scanf("%d %d",&n,&k);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	printf("%d",(n-1+(k-2))/(k-1));
	return 0;
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    int k;
    cin >> k;
    ll ans = 0;
    for(int i = 1; i <= k; i++){
        for(int j = 1; j <= k; j++){
            for(int l = 1; l <= k; l++){
                ans += gcd(gcd(i,j),l);
            }
        }
    }
    cout << ans << endl;
	return 0;
}

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

#define MOD 1000000007

int main(){
    string S;
    cin >> S;
    if (S.at(1) == 'B') cout << "ARC" << endl;
    else cout << "ABC" << endl;
    return 0;
}


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

int main(){
  string s,t,u;
  int a,b;
  cin >>s >>t >>a >>b >>u;
  if(u==s) cout << a-1 << " " << b << endl;
  if(u==t) cout << a << " " << b-1 << endl;
  return 0;
}


Measured memory_bytes: 256
n,k=list(map(int,input().split()))
p=list(map(int,input().split()))
kitaiti=[]
for i in p:
    kitaiti.append((i+1)/2)
from itertools import accumulate
ruiseki=list(accumulate(kitaiti))
ruiseki=[0]+ruiseki
ans=0
for i in range(k,n+1):
    ans=max(ans,ruiseki[i]-ruiseki[i-k])
print(ans)

    

Measured memory_bytes: 26240
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
  cin>>n;
  vector<int >nos(n,0);
  for(int i=0;i<n;i++)cin>>nos[i];
  sort(nos.begin(),nos.end());
  int sumi=0;
  for(int i=0;i<n;i++)sumi+=nos[i];
  if(sumi%10!=0)cout<<sumi;
  else{
  	for(int i=0;i<n;i++){
    	if((sumi-nos[i])%10!=0){cout<<sumi-nos[i];return 0;}
    }
    cout<<0;
  }
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
const ll INF = 1e18;
/* テンプレートここまで */
const ll t = 1e9;
void pa(ll a, ll b, ll c, ll d){
  cout << 0 << " " << 0 << " " << a << " " << b << " " << c  << " " << d << endl;
  exit(0);
}

int main() {
  ll n; cin >> n;
  // t = 10^9とする
  //|ad-bc| = n を満たす
  //a,b,c,d<=tを求めればよい

  /* n<=t のとき，自明な解が存在 */
  if(n<=t) pa(1,0,0,n);
 
  /* t<n<=t^2のとき */
  //nがtの倍数のとき，自明な解が存在
  if(n%t == 0) pa(t,0,0,n/t);

  // nがtの倍数でないとき
  // m-t<n<m を満たすtの倍数mを求める
  // すると，m-n < t なのでad = m, bc = m-nとすればよい
  ll m = (n+t-1)/t*t;
  pa(t,1,m-n,m/t);
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
typedef long long ll;
int main()
{
    int n;
    cin>>n;

    double out=0.0;
    for (int i = 0; i < n; i++) {
      int a;
      cin >> a;
      out+=1./a;
    }

    cout << 1./out << endl;
    return 0;
}


Measured memory_bytes: 256
/*///////////////////////////////////////////////////////////////////////////////
							
							YEH DUNIYA NAHI BACHEGI
*/

// #include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <iterator>
#include <functional>
#include <limits>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <stack>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define trace(x) cerr << #x << ": " << x << " " << endl;
 
typedef int64_t ll;
 
#define endl '\n'
#define int ll
#define ld long double
ll mod=1e9+7;
ll mod1=1e9+5;
 
ll power(ll a,ll b)
{
    if(b==0) return 1;
    else if(b%2==0)
        return power((((a%mod)*(a%mod))%mod),b/2)%mod;
    else return ((a%mod)*(power((((a%mod)*(a%mod))%mod),b/2)%mod))%mod;
}
     
 //using namespace __gnu_pbds;
 //#define ordered_set tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update>
//find_by_order(k)  returns iterator to kth element starting from 0;
//order_of_key(k) returns count of elements strictly smaller than k;
//erase,insert same as normal set
// mt19937 mrand(chrono::high_resolution_clock::now().time_since_epoch().count()); for randomized solution

using cd = complex<ld>;
const ld PI = acos(-1);
 
void fft(vector<cd> & a, bool invert) {
    ll n = a.size();
    if (n == 1)
        return;
 
    vector<cd> a0(n / 2LL), a1(n / 2LL);
    for (int i = 0; 2 * i < n; i++) {
        a0[i] = a[2LL*i];
        a1[i] = a[2LL*i+1LL];
    }
    fft(a0, invert);
    fft(a1, invert);
 
    ld ang = 2LL * PI / n * (invert ? -1LL : 1LL);
    cd w(1LL), wn(cos(ang), sin(ang));
    for (int i = 0; 2 * i < n; i++) {
        a[i] = a0[i] + w * a1[i];
        a[i + n/2] = a0[i] - w * a1[i];
        if (invert) {
            a[i] /= 2;
            a[i + n/2] /= 2;
        }
        w *= wn;
    }
}
 
vector<ll> multiply(vector<ll> const& a, vector<ll> const& b) {
vector<cd> fa(a.begin(), a.end()), fb(b.begin(), b.end());
ll n = 1;
while (n < a.size() + b.size()) 
    n <<= 1;
fa.resize(n);
fb.resize(n);
 
fft(fa, false);
fft(fb, false);
for (int i = 0; i < n; i++)
    fa[i] *= fb[i];
fft(fa, true);
 
vector<ll> result(n);
for (int i = 0; i < n; i++)
    result[i] = round(fa[i].real());
return result;
}

int32_t main()
{
    IOS
    int n,k;
    cin>>n>>k;
    vector<int> c(100001,0);
    for(int i=0;i<n;i++)
    {
    	int x;
    	cin>>x;
    	c[x]++;
    }
    auto d=multiply(c,c);
    int ans=0;
    for(int i=200000;i>=1;--i)
    {
    	if(d[i])
    	{
    		int pre=min(d[i],k);
    		ans+=pre*i;
    		k-=pre;	
    	}
    }
    cout<<ans;
}       


Measured memory_bytes: 33936
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let n = get!(String);
    let k = get!(usize);
    let len = n.len();
    let mut dp = vec![vec![vec![0;4]; 2]; len+1];
    dp[0][0][0] = 1;
    for (i,e) in n.chars().enumerate() {
        let e = e as usize - '0' as usize;
        for j in 0..4 {
            dp[i+1][1][j] += if j>0 {
                9*dp[i][1][j-1] + dp[i][1][j]
            } else {
                dp[i][1][j]
            };
            dp[i+1][1][j] += match e {
                0 => 0,
                _ => if j>0 {
                    dp[i][0][j] + (e-1)*dp[i][0][j-1]
                } else {
                    dp[i][0][j]
                },
            };
            dp[i+1][0][j] += match e {
                0 => dp[i][0][j],
                _ => if j>0 {
                    dp[i][0][j-1]
                } else {
                    0
                },
            };
        }
    }
    println!("{}", dp[len][0][k]+dp[len][1][k]);
}


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

int main(){
  int n,k;
  cin >> n >> k;
  double ans,rep;
  for (int i = 0;i < n;i++){
    rep = i+1;
    int cnt = 0;
    while(rep < k){
      rep *= 2;
      cnt++;
    }
    ans += 1.0/n * pow(1.0/2,cnt);
  }
  printf("%.10f\n",ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>

#define fin cin

using namespace std;
 
int main(void){

   // ifstream fin("input2.txt");

    int Case = 1;
    int maxWeight;
 
    //??????????????????
    while(fin >> maxWeight, maxWeight) {

        int n, sumWeight = 0;
        int w[1000], v[1000];
        int dp[1001] = {0};
        fin >> n;
        for(int i = 0; i < n; i++){

            //value
            string str_in;
            getline(fin, str_in, ',');
            v[i] = stoi(str_in);

            //weight
            getline(fin, str_in);
            w[i] = stoi(str_in);
        }

        //?????????
        for(int i = 1; i <= maxWeight; i++)
            dp[i] = -1;
 
        for(int i = 0; i < n; i++) {
            for(int j = maxWeight - w[i]; j >= 0; j--) {
                if(0 <= dp[j] && j + w[i] <= maxWeight) {
                    dp[j + w[i]] = ((dp[j + w[i]] > dp[j] + v[i]) ? dp[j + w[i]] : (dp[j] + v[i]));
                }
            }
        }
 
        for(int i = 0; i <= maxWeight; i++)
            if(dp[i] > dp[sumWeight]) sumWeight = i;
 
        cout << "Case " << Case++ << ":" << endl;
        cout << dp[sumWeight] << endl;
        cout << sumWeight << endl;
    }
 
    return 0;
}

Measured memory_bytes: 3172
S = input()

def solve(S):
    mod = 10**9+7
    N = len(S)
    Aquest = []
    Cquest = []
    cntA,cntquest = 0,0
    for i in range(N):
        if S[i] in 'B?':
            Aquest.append([cntA,cntquest])
        if S[i]=='A':
            cntA += 1
        if S[i]=='?':
            cntquest += 1
    cntC,cntquest = 0,0
    for i in range(N-1,-1,-1):
        if S[i] in 'B?':
            Cquest.append([cntC,cntquest])
        if S[i]=='C':
            cntC += 1
        if S[i]=='?':
            cntquest += 1
    Cquest = Cquest[::-1]
    ans = 0
    for aquest,cquest in zip(Aquest,Cquest):
        a = aquest[0]*pow(3,aquest[1],mod)
        if aquest[1]>0:
            a += aquest[1]*pow(3,aquest[1]-1,mod)
        c = cquest[0]*pow(3,cquest[1],mod)
        if cquest[1]>0:
            c += cquest[1]*pow(3,cquest[1]-1,mod)
        ans += a*c%mod
    ans %= mod
    return ans
print(solve(S))

Measured memory_bytes: 30708
#include <stdio.h>
int main(void)
{
    int a , b , c;
    scanf("%d %d %d" , &a , &b , &c);
    if(a < b && b < c)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
    return 0;
}




Measured memory_bytes: 2032
#include<iostream>
#include<vector>
#include<map>


#define mod 1000000007
using namespace std;

int main(){
    int N;
    
    cin>>N;
    int *C=new int[N];
    for(int i=0;i<N;i++) cin>>C[i];
    
    map<int,vector<int>> dic;
    for(int i=0;i<N;i++){
        dic[C[i]].push_back(i);
    }
    
    int *dp=new int[N];
    dp[N-1]=1;
    int matu;
    for(int i=N-2;i>-1;i--){
        matu=dic[C[i]].back();
        if(matu==i) dp[i]=dp[i+1];
        else if(matu==i+1){
            dp[i]=dp[i+1];
            dic[C[i]].pop_back();
        }else{
            dp[i]=(dp[i+1]+dp[matu])%mod;
            dic[C[i]].pop_back();
        }
    }
    cout<<dp[0]<<endl;
    delete[] C;
    delete[] dp;
    return 0;
}

Measured memory_bytes: 23680
import numpy as np

H, W = map(int, input().split())
F = np.array([[1 if i == "." else 0 for i in input()] for _ in range(H)])
FU = np.zeros((H, W), dtype=int)
FD = np.zeros((H+1, W), dtype=int)
FL = np.zeros((H, W), dtype=int)
FR = np.zeros((H, W+1), dtype=int)

for i in range(H):
    FU[i] += (FU[i-1]+1)*F[i]

for i in range(H-1, -1, -1):
    FD[i] += (FD[i+1]+1)*F[i]

for i in range(W):
    FL[:, i] += (FL[:, i-1]+1)*F[:, i]

for i in range(W-1, -1, -1):
    FR[:, i] += (FR[:, i+1]+1)*F[:, i]

FV = FU + FD[:-1] - 1
FH = FL + FR[:, :-1] - 1
ans = np.max(FV+FH)
if ans >= 2:
    print(ans-1)
else:
    print(ans)


Measured memory_bytes: 284904
//ABC 050-B
#define _USE_MATH_DEFINES

#include <iostream>
#include <cmath>
#include <stdlib.h>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cstring>
#include <numeric>
#include <string>
#include <map>
#include <sstream>
using namespace std;

int main() {
	int N, T[100], M, P, X, TotalTime = 0, ans[100];
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> T[i];
		TotalTime += T[i];
	}
	cin >> M;
	for (int i = 0; i < M; i++) {
	cin >> P >> X;
	ans[i] =TotalTime - T[P-1] + X;
//	cout << TotalTime - T[P-1] + X << endl;
	}
	for (int i = 0; i < M; i++) cout << ans[i] << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int i, j, k, x, y, h, w;
    char shape='#', dot='.';
    cin >> h >> w;
    
    for(x=1; x<=1000; x++)
 {
    for(i=1;i<=w;i++) //first line
    {
        cout << shape;
    }
    cout << endl;   //first lin0e
    
    for(k=1;k<=(h-2);k++)  //second to second last line
    {
    cout << shape; //frame (left)
    for(j=1;j<=(w-2);j++) //width(dots)
    {
        cout << dot;
    }
     cout << shape; //frame (right)
     cout << endl;
    }
    
    
   for(y=1;y<=w;y++) //last line
    {
        cout << shape;
    }
    cout << endl;
    cout << endl;
    cin >> h >> w;
    if (h==0 && w==0)
    break;
 }

   return 0;
}



Measured memory_bytes: 3100
import numpy as np

N = int(input())
S = list(input())

S_map = [1 if i=="." else 0 for i in S]
cumsum = np.array(S_map).cumsum()
cumsum = np.insert(cumsum, 0, 0)
ans = []

for i in range(N+1):
    if(i == 0 or i == N or S[i-1] != S[i]):
        if(i != 0):
            left_white = cumsum[i]
            left_black = i - left_white
        else:
            left_white = 0
            left_black = 0
        if(i != N):
            right_white = cumsum[-1] - cumsum[i]
            right_black = (N - i) - right_white
        else:
            right_white = 0
            right_black = 0
        ans.append(min(left_white+right_white, left_black+right_black, left_black+right_white))
print(min(ans))

Measured memory_bytes: 26452
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long LL;
int n;
int a[100005], b[100005], c[100005];

LL checka(int p)
{
	LL l = 0, r = n + 1;
	while(l <= r) {
		LL mid  = (l + r) / 2;
		if(a[mid] >= p) {
			r = mid - 1;
		}
		else {
			l = mid + 1;
		}
	}
	return r;
}

LL checkc(int p)
{
	LL l = 0, u = n + 1;
	while(l <= u) {
		LL mid  = (l + u) / 2;
		if(c[mid] <= p) {
			l = mid + 1;
		}
		else {
			u = mid - 1;
		}
	}
	return l;
}

int main()
{
	while(~scanf("%d", &n))
	{
		memset(a, 0, sizeof(a));
		memset(b, 0, sizeof(b));
		memset(c, 0, sizeof(c));
		long long sum = 0;
		a[0] = b[0] = c[0] = -1000000;
		a[n + 1] = b[n + 1] = c[n + 1] = 1000000000;
		for(int i = 1; i <= n; i++) scanf("%d", &a[i]);
		for(int i = 1; i <= n; i++) scanf("%d", &b[i]);
		for(int i = 1; i <= n; i++) scanf("%d", &c[i]);
		sort(a + 1, a + 1 + n);
		sort(b + 1, b + 1 + n);
		sort(c + 1, c + 1 + n);
		for(int i = 1; i <= n; i++)
		{
			long long ans = 1;
			long long  ca = checka(b[i]);
			long long cc = checkc(b[i]);
		//	if(ca == 0) ca = 1;
		//	if(cc == 0) cc = 1;
			sum = sum + ca * (n - cc + 1);
		}
		printf("%lld\n", sum);
	}
	return 0;
}

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

class N
{
	static void Main()
	{
		var n = int.Parse(Console.ReadLine());
		var a = Console.ReadLine().Split().Select(int.Parse).ToArray();

		var s = new long[n, n];
		for (int l = 0; l < n; l++)
			for (int r = l; r < n; r++)
				s[l, r] = (r > 0 ? s[l, r - 1] : 0) + a[r];
		var dp = new long[n, n];
		for (int i = 1; i < n; i++)
			for (int l = 0; l + i < n; l++)
				dp[l, l + i] = s[l, l + i] + Enumerable.Range(1, i).Min(j => dp[l, l + j - 1] + dp[l + j, l + i]);
		Console.WriteLine(dp[0, n - 1]);
	}
}


Measured memory_bytes: 18632
from collections import defaultdict
N = int(input())
d = defaultdict(int)

for _ in range(N):
  s = input()
  if s == 'AC':
    d[s] += 1
  elif s == 'WA':
    d[s] += 1
  elif s == 'TLE':
    d[s] += 1
  else:
    d[s] += 1
    
    
for k in ['AC', 'WA', 'TLE', 'RE']:
  print('{} x {}'.format(k, d[k]))
    

Measured memory_bytes: 9480
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>

using namespace std;
using ll = long long;

int gcd(int a, int b) { return (b == 0) ? a : gcd(b, a % b); }

#define CIN(T, x) T x; cin >> x;
#define CINS(T, x, N) vector<T> x(N); for(int i = 0; i < (N); i++) { cin >> x[i]; }
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << " "; } cout << "\n";
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << "\n";


int main() {

    CIN(int, N);
    CINS(int, A, N);

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

    ll m2 = 0, m4 = 0;
    ll i2 = 0;

    for (int i = N - 1; i > 0; i--) {
        if ( m2 == 0 && A[i] == A[i-1] ) {
            m2 = A[i];
            i2 = i - 2;
            break;
        }
    }

    for (int i = i2; i > 0; i--) {
        if ( m4 == 0 && A[i] == A[i-1] ) {
            m4 = A[i];
        }
    }

    cout << (m2*m4) << "\n";
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
int INF = 1000000000;
vector<int> dijkstra(int s, int v, vector< vector< pair<int,int> > > G){
  //s: ?§????, v: ????????°, G: ??£??\??????????????????????????£??§??\????????????
  priority_queue< pair<int, int> > wait;
  vector<int> result(v, INF);
  result[s] = 0;
  wait.push(make_pair(0, s));
  while(!wait.empty()){
    int nowpoint = wait.top().second;
    int nowcost = wait.top().first;
    wait.pop();
    if(nowcost <= result[nowpoint]){
      for(int i = 0; i < G[nowpoint].size(); ++i){
	int nextpoint = G[nowpoint][i].second;
	int nextcost = -nowcost + G[nowpoint][i].first;
	if(nextcost < result[nextpoint]){
	  wait.push(make_pair(-nextcost, nextpoint));
	  result[nextpoint] = nextcost;
	}
      }
    }
  }
  return result;
}

long long int count(vector< vector<pii> > &G, int s, int t, int N){
  vector<int> r1 = dijkstra(s,N,G), r2 = dijkstra(t,N,G);
  int l = r1[t], d1[l+1], d2[l+1];
  fill(d1,d1+l+1,0);
  fill(d2,d2+l+1,0);
  for(int i = 0; i < N; ++i){
    if(r1[i] <= l) ++d1[r1[i]];
    if(r2[i] <= l) ++d2[r2[i]];
  }
  long long int ret = 0;
  for(int i = 0; i < l-1; ++i){
    ret += (long long int)d1[i]*d2[l-2-i];
  }
  return ret;
}

int main(){
  int N, M, s, t, x, y;
  cin >> N >> M >> s >> t;
  --s;--t;
  vector< vector<pii> > G(N);
  for(int i = 0; i < M; ++i){
    cin >> x >> y;
    --x;--y;
    G[x].push_back(make_pair(1,y));
    G[y].push_back(make_pair(1,x));
  }
  cout << count(G,s,t,N) << endl;
  return 0;
}

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

int main() {
  char c;
  cin >> c;
  
  if(c=='a' || c=='e' || c=='i' || c=='o' 
     || c=='u') {
    cout << "vowel" << endl;
    }
  
  else cout << "consonant" << endl;
  }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b) - 1; (i) >= (a); --(i)) //Reversi for
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}
ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll fac(ll n){
    if (n > 0) {
        return  n * fac(n - 1);
    }else{
        return 1;
    }
}

int main()
{
    ll n,X,ans,cnt;
    cin >> n >> X;
    vector<ll> x(n + 1);
    x[n] = X;
    rep(i, n)cin >> x[i];
    sort(x.begin(), x.end());
    ans = x[1] - x[0];
    nfor(i, 1, n){
        cnt = x[i + 1] - x[i];
        if (cnt % ans != 0) {
            ans = gcd(ans, cnt);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#
# 7b
#

def main():
    while True:
        n, x, = map(int, input().split())
        if n == x == 0:
            break
        ans = 0
        for i in range(1, n+1):
            for j in range(i+1, n+1):
                if j+1 <= x - i - j <= n:
                    ans += 1
        print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 5596
#include<iostream>
using namespace std;
void Sort(int A[], int N){
    int i, j, v;
    for(i = 1; i < N; i++){
        v = A[i];
        j = i - 1;
        while (j >= 0 && A[j] > v){
            A[j+1] = A[j];
            j --;
        }
        A[j+1] = v;
        for(int i = 0; i < N; i++){
            cout <<A[i];
            if(i!=N-1){
                cout<<" ";
            }
            else cout<<endl;
        }
    }
}
int main(){
    int N;
    int A[1000];
    cin >>N;
    for (int i = 0; i < N; i++){
        cin >>A[i];
    }
    for(int i = 0; i < N; i++){
            cout <<A[i];
            if(i!=N-1){
                cout<<" ";
            }
            else cout<<endl;
        }
    Sort(A, N);
    
    return 0;
}



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

int main(){
  int te[3] = {1,2,3};
  int paper[10],Min;
  while(true){
    Min = 10000000;
    map<int,int> exist;
    cin >> paper[0];
    exist[paper[0]]++;
    Min = min(Min,paper[0]);
    if(paper[0] == 0)break;
    for(int i=1;i<5;i++){
      cin >> paper[i];
      Min = min(Min,paper[i]);
      exist[paper[i]]++;
    }
    if(exist[1]!=0 && exist[2]!=0 && exist[3]!=0){
      for(int i=0;i<5;i++)cout << 3 << endl;
    }
    else if(exist[1] == 5 || exist[2] == 5 || exist[3] == 5){
for(int i=0;i<5;i++)cout << 3 << endl;
    }
    else if(exist[1]!=0 && exist[3]!=0 && exist[2] == 0){
      for(int i=0;i<5;i++){
	if(paper[i] == 3)cout << 1 << endl;
	else cout << 2 << endl;
      }
    }
    else {
      for(int i=0;i<5;i++){
	if(paper[i] == Min)cout << 1 << endl;
	else cout << 2 << endl;
      }

    }
  }
  return 0;
}

Measured memory_bytes: 1196
n,m = map(int,input().split())
if(n % 2 == 0):
    d = n // 2 - 1
    c = 0
    i = 1
    while(d > 0):
        print(i,i+d)
        d -= 2
        i += 1
        c += 1
        if(c == m):exit()
    d = n // 2 - 2
    i = n // 2 + 1
    while(d > 0):
        print(i,i+d)
        d -= 2
        i += 1
        c += 1
        if(c == m):exit()


else:
    for i in range(m):
        print(i+1,n-i)


Measured memory_bytes: 9204
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
typedef pair<LL, LL> P;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
constexpr long long MMOD = 500000004;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)      (x).begin(),(x).end()
# define UNIQ(c)     (c).erase(unique(ALL((c))), end((c)))
# define mp          make_pair
# define eb          emplace_back
# define FOR(i,a,b)  for(int i=(a);i<(b);i++)
# define RFOR(i,a,b) for(int i=(a);i>=(b);i--)
# define REP(i,n)    FOR(i,0,n)
# define INIT        std::ios::sync_with_stdio(false);std::cin.tie(0)

int maze[3][3];

int main() {
	REP(i,3){
		REP (j,3)cin >> maze[i][j];
		maze[i][1] -= maze[i][0]; maze[i][2] -= maze[i][0]; maze[i][0] = 0;
	}
	REP(i,3) {
		if (!(maze[0][i] == maze[1][i] && maze[1][i] == maze[2][i])) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(std::unique(all(x)), x.end());
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
const double PI = acos(-1);
using namespace std;
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>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    int n;
    string s, t;
    cin >> n >> s >> t;
    rep(i, n) cout << s[i] << t[i];
    cout << endl;
}


Measured memory_bytes: 256
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
c = [int(x) for x in input().split()]
if (max(b) < min(c)) and (max(b) < a[3]) and (min(c) > a[2]):
    print("No War")
else:
    print("War")


Measured memory_bytes: 2940
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

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

	ll A, B;
	
	cin >> A >> B ;

	if (A+B <= 1)
	{
		cout << "Brown" << endl;
	}
	else
	{
		if (abs(A-B) <= 1)
		{
			cout << "Brown" << endl;
		}
		else
		{
			cout << "Alice" << endl;
		}
	}

	
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
// #include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
// #include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

/*
unsigned seed1 = std::chrono::system_clock::now().time_since_epoch().count();
mt19937 g1.seed(seed1);
*/
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<pii, pii> ppiipii;
typedef pair<int, ppiipii> pippiipii;
typedef pair<int, pii> pipii;
typedef pair<pii, int> ppiii;
typedef pair<int, ppiii> pippiii;
typedef pair<int, ll> pill;
typedef pair<int, double> pid;
// note to self, the below two triggers someone
typedef pair<ll, ll> pll;
typedef pair<ll, int> plli;
typedef long double ld;

int n;
int l[105];

int solve(int x) {
  int r = 0;
  for(int i = 0; i < n; i++) {
    int dd = x - l[i];
    r += dd * dd;
  }
  return r;
}

int main() {
  scanf("%d", &n);
  for(int i = 0; i < n; i++) {
    scanf("%d", &l[i]);
  }
  int ret = 1 << 30;
  for(int d = -100; d <= 100; d++) {
    ret = min(ret, solve(d));
  }
  printf("%d\n", ret);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 9223372036854775807LL
#define inf 1000000007
#define SYOU(x) setprecision(x+1)
#define lol long long
#define mp make_pair
#define fi first
#define se second
using namespace std;
lol abs(lol x,lol y){return(x>y?x-y:y-x);}
lol max(lol x,lol y){if(x>y)return x;return y;}
lol min(lol x,lol y){if(x<y)return x;return y;}
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >>n;
    int ans=0;
    int a[10][10]={};
    for(int i=1;i<=n;i++){
      int l,r;
      r=i%10;
      int m=i;
      while(m>=10) m/=10;
      l=m;
      a[l][r]++;
    }
    for(int i=1;i<10;i++){
      for(int j=1;j<10;j++){
	ans+=a[i][j]*a[j][i];
      }
    }
    cout <<ans<<'\n';
    return (0);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 3e5 + 5;

int n;
ll sum;
int a[N];

int main() {
    scanf("%d", &n);
    for(int i = 1; i <= 3 * n; i++) {
        scanf("%d", &a[i]);
        a[i] *= -1;
    }
    sort(a + 1, a + (3 * n) + 1);
    for(int i = 1; i <= (3 * n); i++) {
        a[i] *= -1;
    }
    sum = 0;
    for(int i = 2; i <= (2 * n); i += 2) {
        sum += a[i];
    }
    printf("%lld\n", sum);
}

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

int main() {
  int N; cin >> N; vector<int> emp(N);
  for (int i =0; i<N-1; i++) 
  { int a; cin >> a; emp.at(a-1)++; }
  for (int i =0; i<N; i++) 
  { cout << emp.at(i) << endl; }
}
  

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

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	
	int ans = 0;
	for(int i = 0; i < n; i++){
		if(a[i]-1 > i){
			if(a[a[i]-1]-1 == i){
				ans++;
			}
		}
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std; 
typedef long long ll;
int n; 
ll a[200005];
ll x; 
int main() {
    ios::sync_with_stdio(0); 
    cin >> n >>x; 
    ll ans = 0;
    for(int i=0; i<n; i++) {
        cin >> a[i];
        if (i) {
            ll sum = a[i] + a[i-1]; 
            ll now = max(0LL, sum - x);
            a[i] -= now; 
            a[i] = max(a[i],0LL);
            ans += now;
        }
    }
    cout << ans << "\n";
    return 0;
}

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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

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

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int n;
  cin >> n;
  string o;
  set<string> d;
  for (int i = 1; i <= n; i++) {
    string s;
    cin >> s;
    if ((i > 1 && o.back() != s.front()) || d.count(s)) {
      cout << "No" << '\n';
      return 0;
    }
    o = s;
    d.insert(s);
  }
  cout << "Yes" << '\n';
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 998244353;

const int Nmax=200010;

ll mpow(ll a, ll p){
    ll x=a;
    ll y=1;
    while(p > 0){
        if((p & 1) == 1){
            y = x*y%MOD;
        }
        x = x*x%MOD;
        p >>= 1;
    }
    return y;
}
 
ll minv(ll a){
    return mpow(a, MOD-2);
}
 
ll fact[333333];
ll ncr[333333];
void init_ncr(ll n){
    ll t=1;
    fact[0] = 1;
    for(ll i=1;i <= n;i++){
        t = (t * i) % MOD;
        fact[i] = t;
    }
    for(ll r=0;r <= n/2;r++){
        ncr[r] = fact[n] * minv(fact[n-r]*fact[r]%MOD) %MOD;
    }
    for(ll r=0;r <= n/2;r++){
        ncr[n-r] = ncr[r];
    }
}

int main() {
	ll N,R,B,K;
	cin >> N >> R >> B >> K;
	//NブロックR点B点K目標
	init_ncr(N);
	ll cnt=0,aa,b;
	for(ll a=0;a <= N;a++){//a:Rの個数,b:Bの個数
		aa = K-a*R;
		if(aa < 0) continue;
		if(aa % B == 0){
			b = aa/B;
			if(b >= 0 && b <= N)cnt = (cnt + (ncr[a] * ncr[b])%MOD)%MOD;
		}
	}
	
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 5248
n = int(input())
def sum_keta(m):
	sum_wa = 0
	while m>0:
		sum_wa = sum_wa + m%10
		m = int(m/10)

	return sum_wa

if sum_keta(n) == 1:
	print(10)
else:
	print(sum_keta(n))


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


void solve(long long N){
    ll ans=0;
    if(N%2==0) ans=N/2-1;
    else ans=(N-1)/2;
    cout<<ans<<endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::cout<<std::fixed<<std::setprecision(10);//誤差小数10桁まで
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


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

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define SORT(v, n) sort(v, v+n)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define ddvi vector<vector<int>>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
// ここに処理を記述

    char a, b;

    cin >> a >> b;

    string ans = "";
    if(a < b){
        REP(i,int(b - '0')){
            ans += a;
        }
    }
    else{
        REP(i,int(a-'0')){
            ans += b;
        }
    }

    cout << ans << endl;

return 0;
}

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

//const double PI = acos(-1.0); 

void solve();

void fastio()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
}

int main()
{
    fastio(); 

    // int t;
    // cin >> t;

    // while (t--) 
    solve(); 

    return 0;
}

void solve()
{
    int a, b;
    cin >> a >> b;
    cout << a * b << "\n";

}

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

#define int long long

int32_t main()
{
	string sa, sb, sc;
	cin >> sa >> sb >> sc;
	int ia = 0, ib = 0, ic = 0;
	int j = 1;
	while(ia < sa.size()+1 and ib < sb.size()+1 and ic < sc.size()+1)
	{
		//cout << j << '\n';
		
		if(j == 1)
		{
			if(sa[ia] == 'b') j = 2;
			else if(sa[ia] == 'c') j = 3;
			
			ia++;
		}
		else if(j == 2)
		{
			if(sb[ib] == 'a') j = 1;
			else if(sb[ib] == 'c') j = 3;
		
			ib++;
		}
		else
		{
			if(sc[ic] == 'b') j = 2;
			else if(sc[ic] == 'a') j = 1;
			
			ic++;
		}
	}
	
	if(ia == sa.size()+1) cout << "A\n";
	else if(ib == sb.size()+1) cout << "B\n";
	else cout << "C\n";
}

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

#define pb push_back
#define mp make_pair
#define all(n) (n).begin(),(n).end()
#define fi first
#define se second

typedef pair<int, int> PII;
typedef long long ll;

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

	int n,w;
	cin >> n >> w;
	int a[101][2];
	for (int i = 0; i < n; i++) cin >> a[i][1] >> a[i][0];

	ll dp[100005];
	memset(dp,0,sizeof(dp));
	for (int j = 0; j < n; j++) {
		for (int k = w; k >= a[j][1]; k--) {
			dp[k]=max(dp[k],dp[k-a[j][1]]+a[j][0]);
		}
	}
	cout << dp[w] << "\n";
}

Measured memory_bytes: 4340
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    string s,t;
    cin>>s>>t;
    ll mx=1e18;
    int m=t.length();
    for(int i=0;i+m<=s.length();i++)
    {
        ll aa=0;
       for(int j=i;j<i+m;j++)
        if(s[j]!=t[j-i])
        aa++;
       mx=min(mx,aa);
    }
    cout<<mx;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
static const double pi = 3.141592653589793;

int main()
{
    double a,b,h,m;cin >> a >> b >> h >> m;
  	
  	double m_angle = m * 6 * (double)(pi / 180);
  	double m_x = cos(m_angle) * b;
    double m_y = sin(m_angle) * b;
  	
  	double h_angle = (h + (double)(m / 60)) * 30  * (double)(pi / 180);
  	double h_x = cos(h_angle) * a;
    double h_y = sin(h_angle) * a;

  	printf("%.30lf\n", sqrt(pow(h_x - m_x, 2.0) + pow(h_y - m_y, 2.0)));

    return 0;
}

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

int a, b, c, x;

bool ok(int p, int q) {
  return abs(p - q) <= x;
}

int main() {
  cin >> a >> b >> c >> x;
  cout << (ok(a, c) || (ok(a, b) && ok(b, c)) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define mod 1000000007
#define size_f 100002
int main()
{
   ll x;
   cin>>x;
   for(int a=0;a<=200;a++)
   {
       for(int b=-200;b<=200;b++)
       {
           if(a*a*a*a*a-b*b*b*b*b==x)
           {
               cout<<a<<" "<<b<<"\n";
               return 0;
           }
       }
   }
    return 0;
}


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

template<size_t mx>
class SnukeNumber{
private:
    constexpr long long int dsum(long long int a){
        long long int ret = 0;
        while(a){
            ret += a % 10;
            a /= 10;
        }
        return ret;
    }

    constexpr long double f(long long int a){
        long long int ret = dsum(a);
        return a / static_cast<long double>(ret);
    }

public:
    long long int ans[mx];

    constexpr SnukeNumber() : ans(){
        size_t cnt = 0;
        long double a = f(1), b = f(2);
        long long int s = 1, t = 1;
        for(long long int i = 1; cnt < mx; i += s){
            b = f(i + s);
            if(a < b){
                s = t;
                b = f(i + s);
            }
            if(a > b){
                if(s == t)t *= 10;
            }else{
                ans[cnt] = i;
                ++cnt;
            }
            long double tmp = a;
            a = b;
            b = tmp;
        }
    }
};

constexpr SnukeNumber<792> S = SnukeNumber<792>();

long long int K;

int main(){
    scanf("%lld", &K);
    for(int i = 0; i < K; ++i)printf("%lld\n", S.ans[i]);
    return 0;
}

Measured memory_bytes: 256
A,V = map(int,input().split())
B,W = map(int,input().split())
T = int(input())
dif =abs(A - B)
if W >= V:
  print("NO")
else:
  oni = V*T - W*T
  if oni >= dif:
    print("YES")
  else:
    print("NO")


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

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

sortV = sorted(V, key=lambda x:x[1])

sum_value = 0
result = "Yes"
for val in sortV:
    sum_value += val[0]
    if sum_value > val[1]:
        result = "No"
        break

print(result)

Measured memory_bytes: 55260
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstdlib>
using namespace std;
int A,B,C,D,E,F,G,H;
void Print(){
	printf("%d %d %d %d\n",E,F,G,H);
	return;
}
void solve1(){
	E=C;F=D+C-A;
	G=A;H=F;
	Print();
	exit(0);
}
void solve2(){
	E=C-(D-B);F=D;
	G=E;H=B;
	Print();
	exit(0);
}
void solve3(){
	int a=D-B,b=C-A;
	E=C-a;F=D+b;
	G=A-a;H=B+b;
	Print();
	exit(0);
}
void solve4(){
	int a=D-B,b=A-C;
	E=C-a;F=D-b;
	G=E+b;H=F-a;
	Print();
	exit(0);
}
int main(){
	scanf("%d%d%d%d",&A,&B,&C,&D);
	if(B==D)solve1();
	if(A==C)solve2();
	if(C>A)solve3();
	solve4();
	return 0;
}

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

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

int main()
{
	int n; cin>>n;
	vector<int> a(n);
	rep(i,n) cin>>a[i];
	bool can=true;
	rep(i,n) if(a[i]%2==0){
		if(a[i]%3!=0&&a[i]%5!=0) can=false;
	}		
	if(can) cout<<"APPROVED"<<endl;
	else cout<<"DENIED"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
using namespace std;
typedef int64_t ll;
typedef vector<ll> vll;
struct Solution {
    void solve(std::istream& in, std::ostream& out) {
        ll N, K;
        in >> N >> K;
        vll l(N);
        rep (i, N) {
            in >> l[i];
        }
        sort(l.begin(), l.end());
        
        ll ans = 0;
        reu(i, N-K, N) {
            ans += l[i];
        }
        out << ans << endl;
    }
};
void solve(std::istream& in, std::ostream& out)
{
    out << std::setprecision(12);
    Solution solution;
    solution.solve(in, out);
}
#include <fstream>
#include <iostream>
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    istream& in = cin;
    ostream& out = cout;
    solve(in, out);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <math.h>
#include <unordered_map>
#include <numeric>
#include <sstream>
using namespace std;

int main()
{
	int x;

	std::cin >> x;

	if(x<1000){
		printf("ABC\n");
	}else{
		printf("ABD\n");
	}

	return 0;
}


Measured memory_bytes: 256