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

template<typename T, typename U>
using pv=vector<pair<T,U>>;
template<typename T>
using pque=priority_queue<T>;
template<typename T>
using lpque=priority_queue<T,vector<T>,greater<T>>;

using ll=long long;
using intpair=pair<int,int>;
using llpair=pair<ll,ll>;
using ilpair=pair<int,ll>;
using lipair=pair<ll,int>;
using intvec=vector<int>;
using llvec=vector<ll>;
using intq=queue<int>;
using llq=queue<ll>;
using intmat=vector<intvec>;
using llmat=vector<llvec>;

#define PI 3.141592653589793
#define INTINF ((1<<30)-1)
#define LLINF ((1LL<<62)-1)
#define MPRIME 1000000007
#define MPRIME9 998244353
#define MMPRIME ((1ll<<61)-1)

#define len length()
#define pushb push_back
#define fi first
#define se second

#define setpr fixed<<setprecision(15)
#define all(name) name.begin(),name.end()
#define rall(name) name.rbegin(),name.rend()
#define gsort(vbeg,vend) sort(vbeg,vend,greater<>())

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

template<class T>
inline void init(T& v) {
	for(auto &a: v) cin>>a;
}
template<class T, class U>
inline void init(vector<pair<T,U>>& v) {
	for(auto &a: v) cin>>a.first>>a.second;
}
template<class T, class N>
inline void init(T& v, N n) {
	v.resize(n);
	for(auto &a: v) cin>>a;
}
template<class T, class U, class N>
inline void init(vector<pair<T,U>>& v, N n) {
	v.resize(n);
	for(auto &a: v) cin>>a.first>>a.second;
}

inline void out() {
	cout<<endl;
}
template<class T, class... U>
inline void out(T a, U... alist) {
	cout<<a<<" ";
	out(forward<U>(alist)...);
}

template<class N>
void resiz(N n) {
	//empty
}
template<class N, class T, class... U>
void resiz(N n, T&& hd, U&&... tl) {
	hd.resize(n);
	resiz(n,forward<U>(tl)...);
}

bool isout(int h, int w, int H, int W) {
	return ( h<0 || h>=H || w<0 || w>=W );
}

ll binpow(ll a, ll ex, ll p) {
	ll result=1;
	while(ex>0) {
		if(ex&1) result=result*a%p;
		ex>>=1;
		a=a*a%p;
	}
	return result;
}


int N;
ll ans;

void input() {
	cin>>N;
}

void solve() {
	for(int A=1; A<N; A++) {
		ans += (N-1)/A;
	}

	cout<<ans<<endl;
}

int main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(15);
	int t=1;
	while(t) {
		input();
		solve();
		t--;
	}
}


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

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

  vector<vector<int>> roads(m, vector<int>(2));
  for (int i = 0; i < roads.size(); i++) {
    cin >> roads.at(i).at(0) >> roads.at(i).at(1);
  }
  // vector<int> counts(n);

  for (int i = 0; i < n; i++) {
    int counts = 0;
    for (int j = 0; j < m; j++) {
      if (roads.at(j).at(0) == i + 1) {
        counts++;
      }
      if (roads.at(j).at(1) == i + 1) {
        counts++;
      }
    }
    cout << counts << endl;
  }

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
public static void main(String[] args){
Scanner scan = new Scanner(System.in);

int n = scan.nextInt();
int[] a = new int[n];
for(int j = 0;j<n;j++){
a[j]= scan.nextInt();}
for(int i = n-1;i>=0;i--){
if(i>0){System.out.print(a[i] + " ");
}
else{System.out.println(a[0]);}
}}}

Measured memory_bytes: 26256
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan=new Scanner(System.in);
        int x=scan.nextInt();
        int y=scan.nextInt();
        
        while(!(x==0&&y==0)){
            for(int i=0; i<x; i++){
                for(int j=0; j<y; j++)
                    System.out.print("#");
                System.out.println();
            }
            System.out.println();
            
        x=scan.nextInt();
        y=scan.nextInt();
        }
    }
}


Measured memory_bytes: 34912
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
  	cin >> n;
  set<int> a;
  while(n--){
    int b;
    cin >> b;
    if (a.find(b) != a.end()) a.erase(b);
    else a.insert(b);
  }
  cout << a.size() << endl;
}

Measured memory_bytes: 4864
#include <iostream>
#include <algorithm>



using namespace std;


int A, B;


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

	if (A > B) {
		swap(A, B);
	}

	int ans = 0;

	if (A == 1) {
		if (B == 2) {
			ans = 3;
		}
		else {
			ans = 2;
		}
	}
	else{
		ans = 1;
	}
	cout << ans << endl;

	return 0;
}



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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a/gcd(a, b) * b;
}

int main()
{
    cout << fixed << setprecision(15);
    ll N;
    cin >> N;

    vector<ll> P(N+1, 0);
    for(ll i=1; i<=N; i++){
        for(ll j=i; j<=N; j=j+i){
            P[j]++;
        }
    }

    ll ans = 0;
    for(ll i=1; i<=N; i++){
        // cout << P[i] << endl;
        ans += i*P[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 81400
#include<iostream>
using namespace std;
int main()
{
	int n,i,s=0,s2=0;
	cin>>n; 
	char a[n];
	cin>>a;
	for(i=0;i<n;i++)
	{
		if(a[i]=='I')s++;
		else if(a[i]=='D')s--;
		if(s2<s)s2=s;
	}
	cout<<s2<<endl;
} 

Measured memory_bytes: 384
//https://atcoder.jp/contests/ddcc2020-qual/tasks/ddcc2020_qual_c
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
template<class T>bool chmax(T &a, const T &b) {if (a<b) { a=b; return 1; } return 0;}
template<class T>bool chmin(T &a, const T &b) {if (b<a) { a=b; return 1; } return 0;}
int main() {
#if LOCAL&01
    std::ifstream in("./test/sample-1.in"); //input.txt
    std::cin.rdbuf(in.rdbuf());
#else
    cin.tie(0);
    ios::sync_with_stdio(false);
#endif
    ll H,W,K; cin>>H>>W>>K;
    vector<string> swh(H);
    for(auto&& sw:swh){
        cin>>sw;
    }

    vector<vector<ll>> ans(H,vector<ll>(W,0));
    ll no=1;
    REP(y,swh.size()){
        auto& s=swh.at(y);
        REP(x,W){
            if(s.at(x)=='#'){
                ans[y][x]=no;
                ++no;
            }
        }
    }
    //右にのばす
    REP(y,H){
        REP(x,W){
            if(ans[y][x]==0&&x-1>=0){
                ans[y][x]=ans[y][x-1];
            }
        }
    }
    //左にのばす
    REP(y,H){
        for(ll x=W-1;x>=0;--x){
            if(ans[y][x]==0&&x+1<W){
                ans[y][x]=ans[y][x+1];
            }
        }
    }
    //下にのばす
    REP(y,H){
        REP(x,W){
            if(ans[y][x]==0&&y-1>=0){
                ans[y][x]=ans[y-1][x];
            }
        }
    }
    //上にのばす
    for(ll y=H-1;y>=0;--y){
        REP(x,W){
            if(ans[y][x]==0&&y+1<H){
                ans[y][x]=ans[y+1][x];
            }
        }
    }

    for(auto&& ah:ans){
        REP(x,ah.size()){
            if(x!=0)cout<<" ";
            cout<<ah.at(x);
        }
        cout<<endl;
    }

    return 0;
}

Measured memory_bytes: 1664
import math
import copy
from copy import deepcopy
import sys
import fractions
import numpy as np
from functools import reduce
import statistics
import heapq

# input = sys.stdin.readline
# sys.setrecursionlimit(10**6)

# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum


def getInputListInt():
    outputData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===
n = getInputInt()
data = getInputListInt()

data.sort()
min_num = sys.float_info.max

for i in range(data[0], data[len(data)-1]+1, 1):
    tmp_dis = 0
    for x in data:
        tmp_dis += float(pow(i - x, 2))
    min_num = min(min_num, tmp_dis)

print(int(min_num))

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

long long mod = 1e9+7;

long long  dfs(int curstep,int &n,set<int> &brok,vector<long long> &dp){
    if(curstep == n ) return 1;
    if(curstep>n || brok.count(curstep)) return 0;
    if(dp[curstep]!=-1) return dp[curstep];
    return dp[curstep] = (dfs(curstep+1,n,brok,dp)%mod + dfs(curstep+2,n,brok,dp)%mod)%mod;
}

int main(){
    int n,m;
    cin>>n>>m;
    set<int> broken;
    vector<long long> dp(n+1,-1);
    while(m--){
        int a;
        cin>>a;
        broken.insert(a);
    }
    cout<<dfs(0,n,broken,dp);
}

Measured memory_bytes: 10376
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#include <list>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if(a!=c)cout << 1;
    else cout << 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define debug(x) cout << #x << " : " << x << endl
#define mp make_pair
#include <iostream>
#define fastinput ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);


int main()
{    
    fastinput;
    LL n,i,j,k,t,temp,a,b;
    cin>>n>>a>>b;
    LL diff=a-b;
    if((a-b)%2==0)
    {
        cout<<((b-a)/2)<<endl;
    }
    else
    {
        //option 1
        LL t1=a;
        LL pos_b=b-t1-1;//even
        LL ans1=t1+(pos_b/2);

        //option 2
        LL t2=n-b+1;
        LL pos_a=a+t2;
        LL ans2=t2+(n-(pos_a))/2;
        //debug(ans1);
        //debug(ans2);
        cout<<min(ans1,ans2)<<endl;
    }
    
    
    


    
    return 0;
}


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

using namespace std;

int main(){
	int n;
  	cin >> n;
  	string s;
  cin >> s;
    int cnt1=0;
     int cnt2=0;
       stack<char> st;
     for(int i=0;i<n;++i){
     	if(!st.empty()){
        	if(st.top()=='(' && s[i]==')')st.pop();
          	else st.push(s[i]);
        }
         else st.push(s[i]);
     }
     while(!st.empty()){
     	if(st.top()=='(')cnt1++;
       else cnt2++;
           st.pop();
     }
     cout << string(cnt2,'(') << s << string(cnt1,')');
}


Measured memory_bytes: 3536
# https://atcoder.jp/contests/abc081/tasks/abc081_b

import itertools
import collections
import bisect

# 素因数分解
def prime_dic(n):
    ans = 0

    while n % 2 == 0:
        ans += 1
        n //= 2

    return ans

def main():
    N = int(input())
    A = list(map(int, input().split()))
    A = list(map(lambda x: prime_dic(x), A))
    print(min(A))

if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
<?php
$num = 0;
$acute = 0;
$right = 0;
$obtuse = 0;
// 標準入力を取り込む
while($side = explode(' ',trim(fgets(STDIN)))){
    sort($side);
    if( $side[0] + $side[1] <= $side[2] ){
        break;
    }

    $num++;
    if( pow($side[0],2) + pow($side[1],2) === pow($side[2],2) ){
        $right++;
        continue;
    }

    if( pow($side[0],2) + pow($side[1],2) > pow($side[2],2) ){
        $acute++;
        continue;
    }
    $obtuse++;
}
echo("$num".' '."$right".' '."$acute".' '."$obtuse"."\n");
?>


Measured memory_bytes: 9252
/*
    Vishal Raj
    IIT Kharagpur
*/

#include <bits/stdc++.h>

using namespace std;

#define FOR(i,l,r) for( int i = l; i < r; i++ )

int main() {
    string s,t; cin>>s>>t;
    int n = s.size();
    int m = t.size();
    int dp[n+1][m+1];
    int p[n+1][m+1];
    memset(dp,0,sizeof(dp));
    FOR(i,1,n+1) {
        FOR(j,1,m+1) {
            if( dp[i-1][j] > dp[i][j] ) {
                dp[i][j] = dp[i-1][j];
                p[i][j] = (i-1)*(m+1)+j;
            }
            if( dp[i][j-1] > dp[i][j] ) {
                dp[i][j] = dp[i][j-1];
                p[i][j] = i*(m+1)+j-1;
            }
            if( s[i-1] == t[j-1] ) {
                if( dp[i-1][j-1]+1 > dp[i][j] ) {
                    dp[i][j] = dp[i-1][j-1]+1;
                    p[i][j] = (i-1)*(m+1)+j-1;
                }
            }
        }
    }
    int x = n;
    int y = m;
    int ct = 0;
    vector<char> ans;
    while( ct < dp[n][m] ) {
        int px = p[x][y]/(m+1);
        int py = p[x][y]%(m+1);
        if( px == x-1 && py == y-1 ) {
            ans.push_back(s[x-1]);
            ct++;
        } 
        x = px;
        y = py;
    }
    reverse(ans.begin(),ans.end());
    FOR(i,0,ans.size()) cout<<ans[i];
    cout<<"\n";
    return 0;
}

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

int main(){
  string s;
  cin>> s;
  
  if(s == "SUN") cout << 7 <<endl;
  if(s == "MON") cout << 6 <<endl;
  if(s == "TUE") cout << 5 <<endl;
  if(s == "WED") cout << 4 <<endl;
  if(s == "THU") cout << 3 <<endl;
  if(s == "FRI") cout << 2 <<endl;
  if(s == "SAT") cout << 1 <<endl;
  return 0;
}

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

using namespace std;

#define MAXN 100005
#define INF 0x3f3f3f3f
#define MOD 10007
#define pb push_back

typedef long long ll;
typedef pair <int, int> pii;
typedef vector <int> vi;

ll dp[MAXN];

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

	ll n, w;
	cin >> n >> w;

	ll weight, value;
	memset(dp, 0, sizeof(dp));

	for(int i = 1; i <= n; i++){
		cin >> weight >> value;
		for(int j = w; j >= weight; j--) dp[j] = max(dp[j], dp[j - weight] + value);
	}

	cout << dp[w] << endl;

	return 0;
}

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

int main(){
    long long int ans = 0;
    long long int num = 0;
    cin >> num;
    vector<char> RGB(num);
    long long int R = 0;
    long long int G = 0;
    long long int B = 0;

    for(int i = 0; i < num; i++){
        cin >> RGB[i];

        if(RGB[i] == 'R'){
            R++;
        }else if(RGB[i] == 'G'){
            G++;
        }else{
            B++;
        }

    }

    ans = R*G*B;

    for(int i = 0; i < num ; i++){

        for(int j = 1; i + j + j < num; j++){

            if(RGB[i] != RGB[i + j] && RGB[i + j] != RGB[i + j + j] && RGB[i] != RGB[i + j + j] ){
                ans --;
            }
        }

    }

    cout << ans << endl;

}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    int D;
    cin >> D;
    string ans = "";

    if(D == 25)
        ans = "Christmas";
    if(D == 24)
        ans = "Christmas Eve";
    if(D == 23)
        ans = "Christmas Eve Eve";
    if(D == 22)
        ans = "Christmas Eve Eve Eve";

    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define mod 1e18+10
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
int32_t main() {
	int n,m,x,a=0,b=0,k,i;
	cin>>n>>m>>x;
	for(i=0;i<m;i++)
	{
		cin>>k;
		if(k>x)
			b++;
		else a++;
	}
	cout<<min(a,b);
	
	
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
int n, m;
int num[100010];
bool ok[100010];
int main () {
	scanf ("%d%d", &n, &m);
	ok[1] = true;
	for (int i = 1; i <= n; i++) num[i] = 1;
	while (m--) {
		int x, y;
		scanf ("%d%d", &x, &y);
		if (ok[x]) {
			ok[y] = true;
			if (num[x] == 1) ok[x] = false;
		}
		num[x]--, num[y]++;
	}
	int ans = 0;
	for (int i = 1; i <= n; i++) if (ok[i]) ans++;
	printf ("%d\n", ans);
	return 0;
}

Measured memory_bytes: 768
// Standard I/O
#include <iostream>
#include <sstream>
#include <cstdio>
// Standard Library
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
// Template Class
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
// Container Control
#include <algorithm>
#include <numeric>

using namespace std;

#define rep( i, n ) for( int i = 0; i < n; ++i )
#define irep( i, n ) for( int i = n-1; i >= 0; --i )
#define reep( i, s, n ) for ( int i = s; i < n; ++i )
#define ireep( i, n, s ) for ( int i = n-1; i >= s; --i )
#define foreach(itr, x) for( typeof(x.begin()) itr = x.begin(); itr != x.end(); ++itr)

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define all( v ) v.begin(), v.end()
#define fs first
#define sc second
#define vc vector

// for visualizer.html
double SCALE = 1.0;
double OFFSET_X = 0.0;
double OFFSET_Y = 0.0;
#define LINE(x,y,a,b) cerr << "line(" << SCALE*(x) + OFFSET_X << ","	\
	<< SCALE*(y) + OFFSET_Y << ","										\
	<< SCALE*(a) + OFFSET_X << ","										\
	<< SCALE*(b) + OFFSET_Y << ")" << endl;
#define CIRCLE(x,y,r) cerr << "circle(" << SCALE*(x) + OFFSET_X << ","	\
	<< SCALE*(y) + OFFSET_Y << ","										\
	<< SCALE*(r) << ")" << endl;

typedef long long ll;
typedef complex<double> Point;

typedef pair<int, int> pii;
typedef pair<int, pii> ipii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector< vector<int> > vii;
typedef vector< vector<double> > vdd;

typedef vector<int>::iterator vi_itr;

const int IINF = 1 << 28;
const int MOD = 1e9+7;
const double INF = 1e30;
const double EPS = 1e-10;
const double PI = acos(-1.0);

// Direction : L U R D
const int dx[] = { -1, 0, 1, 0};
const int dy[] = { 0, -1, 0, 1 };

int n;
ll a[100000], b[100000];
pair<ll, int> t[100000];

int main()
{

    cin >> n;
    rep(i, n) cin >> a[i] >> b[i];

    rep(i, n) t[i] = mp(a[i] + b[i], i);
    sort(t, t+n, greater<pair<ll, int>>());

    ll score1 = 0, score2 = 0;
    rep(i, n) {
        if ( i%2 == 0 ) {
            score1 += a[t[i].second];
        } else {
            score2 += b[t[i].second];
        }
    }

    cout << score1 - score2 << endl;
}


Measured memory_bytes: 3328
N,Q=map(int,input().split())
S=input()
AC_or_No=[0]
ans=[]
n=0

while n<=N-2:
    if S[n]=="A" and S[n+1]=="C":
        AC_or_No.append(AC_or_No[n]+1)
    else:
        AC_or_No.append(AC_or_No[n])
    n+=1

for _ in range(Q):
    l,r=map(int,input().split())
    ans.append(AC_or_No[r-1]-AC_or_No[l-1])

for i in ans:
    print(i)

Measured memory_bytes: 10300
#include <cstdio>
#include <queue>
using namespace std;

int main(){
	int n;
	scanf("%d", &n);
	vector <int> ans(n+1, 0);
	for(int i = 1;i <= 200;i ++){
		for(int j = 1;j <= 200;j ++){
			for(int k = 1;k <= 200;k ++){
				if(i*i+j*j+k*k+i*j+j*k+i*k<=n){
					ans[i*i+j*j+k*k+i*j+j*k+i*k]++;
				}
			}
		}
	}
	for(int i = 1;i <= n;i ++)
		printf("%d\n", ans[i]);
}

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

int main() 
{
  string S, T;
  cin >> S;
  cin >> T;
  
  for(int i = 0; i < S.size(); i++)
  {
    if(S.at(i) == T.at(i))
    {
      if(i == S.size() - 1)
      {
        cout << "Yes" << endl;
        return 0;
      }
    }
    else
    {
      cout << "No" << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 3628
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;


public class Main {

    int A,B;

    private void solve() {
        A = nextInt();
        B = nextInt();

        out.println(Math.max(Math.max(A + B, A - B), A * B));
    }
    public static void main(String[] args) {
        out.flush();
        new Main().solve();
        out.close();
    }

    /* Input */
    private static final InputStream in = System.in;
    private static final PrintWriter out = new PrintWriter(System.out);
    private final byte[] buffer = new byte[4096];
    private int p = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (p < buflen)
            return true;
        p = 0;
        try {
            buflen = in.read(buffer);
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (buflen <= 0)
            return false;
        return true;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrint(buffer[p])) {
            p++;
        }
        return hasNextByte();
    }

    private boolean isPrint(int ch) {
        if (ch >= '!' && ch <= '~')
            return true;
        return false;
    }

    private int nextByte() {
        if (!hasNextByte())
            return -1;
        return buffer[p++];
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = -1;
        while (isPrint((b = nextByte()))) {
            sb.appendCodePoint(b);
        }
        return sb.toString();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 22484
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

int main() {
    ll N;
    cin >> N;
    for (ll i = 0; i * 4 <= N; i++) {
        for (ll j = 0; ; j++) {
            if (i * 4 + j * 7 == N) {
                cout << "Yes" << endl;
                return 0;
            } else if (i * 4 + j * 7 > N) {
                break;
            }
        }
    }

    cout << "No" << endl;
}

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

int main(){
//	freopen("input","r",stdin);
	int a,b;
	scanf("%d%d",&a,&b);
	string s;
	cin >> s;
	if(s[a]!='-'){
		printf("No\n");
		return 0;
	}
	for(int i=0;i<s.size();i++){
		if(i==a) continue;
		if(s[i]<'0' || s[i]>'9'){
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
	return 0;
}


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

using namespace std;

int main()
{
	int H, M, H_2, M_2, K;
	cin >> H >> M >> H_2 >> M_2 >> K;
	int H_M_A = (H_2 * 60 + M_2) - (H * 60 + M) - K;
	cout << H_M_A << endl;
	return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#include<numeric>
#include<cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#define ll long long int
#define CON 100010
const long long mod=1e9+7;
const int INF=1001001001;
const int inf=100000;
//const ll inf=1e9+7;
//const ll ful=1e18;
using namespace std;
//namespace mp = boost::multiprecision;
int main() 
{
	int n,x;
	cin>>n>>x;
	vector<int> l(n);
	for(int i=0;i<n;i++)
	{
		cin>>l[i];
	}
	int ans=1;
	int bound=0;
	for(int i=0;i<n;i++)
	{
		bound+=l[i];
		if(bound<=x)
		{
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(a); i++)
typedef long long ll;
template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

/////////////////////////////////////////////////////////////////////

const ll inf = 1LL<<60;
const string yes = "YES";
const string no = "NO";

int main()
{
  ll a;
  cin >> a;
  ll v;
  cin >> v;
  ll b;
  cin >> b;
  ll w;
  cin >> w;
  ll t;
  cin >> t;
  ll c = abs(a-b);
  ll d = (v-w)*t;
  if (c <= d) cout << yes << endl;
  else cout << no << endl;

  return 0;
}


Measured memory_bytes: 3588
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
using namespace std;

typedef vector<int> VI;

int size[13] = {1, 2, 4, 2, 1, 4, 4, 4, 1, 2, 4, 2, 1};
int move[13][4] = {
  {2},
  {2, 5},
  {0, 1, 6, 3},
  {2, 7},
  {5},
  {1, 4, 6, 9},
  {2, 5, 7, 10},
  {3, 6, 8, 11},
  {7},
  {5, 10},
  {6, 9, 11, 12},
  {7, 10},
  {10}
};

VI v;
map<VI, int> mp;
map<VI, int> mp2;

void make(){
  VI goal;
  for(int i = 0 ; i < 13 ; i++){
    if(i == 0 || i == 12) goal.push_back(0);
    else goal.push_back(i);    
  }
  
  queue<VI> que;
  que.push(goal);
  mp2[goal] = 0;
  
  while(!que.empty()){
    VI q = que.front(); que.pop();    
    if(mp2[q] > 13) continue;
    for(int i = 0 ; i < 13 ; i++){
      if(q[i] != 0) continue;
      for(int j = 0 ; j < size[i] ; j++){
	VI t = q;
	swap(t[i], t[ move[i][j] ]);
	if(mp2.find(t) != mp2.end()) continue;	
	mp2[t] = mp2[q] + 1;	
	que.push(t);
      }
    }
  }
}
    


int bfs(){
  queue<VI> que;
  que.push(v);
  mp[v] = 0;  
  while(!que.empty()){
    VI q = que.front(); que.pop();    
    if(mp2.find(q) != mp2.end()){
      return mp2[q] + mp[q];
    }
    
    if(mp[q] > 8) continue;
    for(int i = 0 ; i < 13 ; i++){
      if(q[i] != 0) continue;      
      for(int j = 0 ; j < size[i] ; j++){
	VI t = q;
	swap(t[i], t[ move[i][j] ]);
	if(mp.find(t) != mp.end()) continue;
	mp[t] = mp[q] + 1;
	que.push(t);
      }
    }
  }
  return -1;
}

void init(){
  v.clear();
  mp.clear();  
}

int main(){
  make();
  int n;
  while(cin >> n){
    if(n == -1) break;
    
    init();
    
    v.push_back(n);
    for(int i = 0 ; i < 12 ; i++){ cin >> n; v.push_back(n); }
    
    int ans = bfs();
    if(ans == -1 || ans > 20) cout << "NA" << endl;
    else cout << ans << endl;
  }
  

  return 0;
}

Measured memory_bytes: 26896
#include<cstdio>
#include<cstring>
#define rep(i,j) for(int i=0;i<j;i++)
int d[1024][1024];
int main(){
    int h,w,n,m;
    for(;;){
        scanf("%d%d%d",&h,&w,&n);
        if(!h)break;
        memset(d,0,sizeof(d));
        d[0][0]=--n;
        rep(i,h)rep(j,w){
            scanf("%d",&m);
            d[i][j+1] += (d[i][j]+(1&m))>>1;
            d[i+1][j] += (d[i][j]+(1&~m))>>1;
            d[i][j] = (d[i][j]+m)&1;
        }
        int x=0,y=0;
        while(x!=w && y!=h){
            int t=d[y][x];
            x+=t;
            y+=1-t;
        }
        printf("%d %d\n",y+1,x+1);
    }
    return 0;
}

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

int main() {
  int H, W;
  string image;
  cin >> H >> W;
  
  //一行目の#
  for (int i = 0; i < W + 2; i++) {
    cout << "#";
  }
  cout << endl;
  
  //2行目からH-1行目
  vector<string> inside(H);
  for (int j = 0; j < H; j++) {
    cin >> inside.at(j);
    cout << "#" << inside.at(j) << "#" << endl;
  }
  
  //H行目の#
  for (int k = 0; k < W + 2; k++) {
    cout << "#";
  }
  cout << endl;
}

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

using namespace std;

class Node {
public:
  int location;
  int parent;
  int right;
  int left;

  Node() {}
};

class Point {
public:
  int id, x, y;
  Point() {}
  Point(int id, int x, int y)
    : id(id)
    , x(x)
    , y(y)
    {}

  bool operator < (const Point& p) const {
    return id < p.id;
  }

  void print() {
    printf("%d\n", id);
  }
};

static const int MAX = 1000000;
static const int NIL = -1;

int N;
Point P[MAX];
Node T[MAX];

int np;

bool lessX(const Point& p1, const Point& p2) { return p1.x < p2.x; }
bool lessY(const Point& p1, const Point& p2) { return p1.y < p2.y; }

int makeKDTree(int left, int right, int depth) {
  if (!(left < right)) {
    return NIL;
  }
  int mid = (left + right) / 2;
  int t = np++;
  if (depth % 2 == 0) {
    sort(P + left, P + right, lessX);
  } else {
    sort(P + left, P + right, lessY);
  }
  T[t].location = mid;
  T[t].left = makeKDTree(left, mid, depth + 1);
  T[t].right = makeKDTree(mid + 1, right, depth + 1);

  return t;
}

void find(int v, int sx, int tx, int sy, int ty, int depth, vector<Point>& ans) {
  int x = P[T[v].location].x;
  int y = P[T[v].location].y;

  if (sx <= x && x <= tx && sy <= y && y <= ty) {
    ans.push_back(P[T[v].location]);
  }

  if (depth % 2 == 0) {
    if (T[v].left != NIL) {
      if (sx <= x) {
        find(T[v].left, sx, tx, sy, ty, depth + 1, ans);
      }
    }
    if (T[v].right != NIL) {
      if (x <= tx) {
        find(T[v].right, sx, tx, sy, ty, depth + 1, ans);
      }
    }
  } else {
    if (T[v].left != NIL) {
      if (sy <= y) {
        find(T[v].left, sx, tx, sy, ty, depth + 1, ans);
      }
    }
    if (T[v].right != NIL) {
      if (y <= ty) {
        find(T[v].right, sx, tx, sy, ty, depth + 1, ans);
      }
    }
  }
}

int main() {
  int x, y;
  scanf("%d", &N);
  for (int i = 0; i < N; i++) {
    scanf("%d %d", &x, &y);
    P[i] = Point(i, x, y);
    T[i].left = T[i].right = T[i].parent = NIL;
  }

  np = 0;

  int root = makeKDTree(0, N, 0);

  int q;
  scanf("%d", &q);
  int sx, tx, sy, ty;
  vector<Point> ans;
  for (int i = 0; i < q; i++) {
    scanf("%d %d %d %d", &sx, &tx, &sy, &ty);
    ans.clear();
    find(root, sx, tx, sy, ty, 0, ans);
    sort(ans.begin(), ans.end());
    for (int j = 0; j < ans.size(); j++) {
      ans[j].print();
    }
    printf("\n");
  }

  return 0;
}




Measured memory_bytes: 15832
<?php
#include <stdio.h>
# 整数の入力
fscanf(STDIN, "%d %d %d", $n, $a, $b);
$sum = 0;

for($i=1;$i<$n+1;$i++){
  $stringI = (string)$i;
  $splitArray = [];
  $splitArray = str_split($stringI);
  $sumOfArray = array_sum($splitArray);

  if($sumOfArray >= $a){
    if($sumOfArray <= $b){
      $sum = $sum + $i;
    }
  }
}

echo $sum."\n";

Measured memory_bytes: 3700
#include <iostream>

int main ()
{
	int m, f, r;
	while (true) {
		std::cin >> m >> f >> r;
		if ( m == -1 && f == -1 && r == -1 ) break;
		
		char grade;
		if (m == -1 || f == -1) grade = 'F';
		else if (m+f >= 80) grade = 'A';
		else if (m+f >= 65) grade = 'B';
		else if (m+f >= 50) grade = 'C';
		else if (m+f >= 30) {
			if (r >= 50) grade = 'C';
			else grade = 'D';
		}
		else grade = 'F';
		
		std::cout << grade << std::endl;
	}
	
	return 0;
}




Measured memory_bytes: 3104
public class Main {

  private static void solve() {
    int n = ni() + 2;
    int[] a = new int[n];
    char[] s = ns();
    for (int i = 0; i < n - 2; i ++) {
      a[i + 1] = s[i] - '0';
    }
    
    //i文字目までの最大回数
    long[] dp = new long[n];
    for (int i = 1; i < n - 1; i ++) {
      dp[i + 1] = Math.max(dp[i + 1], dp[i]);
      int prev = i - 1;
      int next = i + 1;
      if (a[prev] == 1 && a[i] == 0 && a[next] == 1) {

        while (a[prev] == 1) {
          dp[i + 1] = Math.max(dp[i + 1], dp[prev - 1] + (i - prev));
          prev --;
        }
        while (a[next] == 1) {
          dp[next] = Math.max(dp[next], dp[i - 2] + (next - i));
          next ++;
        }
      }
    }
    System.out.println(dp[n - 1]);
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = System.getProperty("debug");
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


Measured memory_bytes: 35668
// import kotlin.comparisons.*
// import kotlin.math.*
import java.util.*

const val mod = 1000000007L

fun readI() = readLine()!!.toInt()
fun readL() = readLine()!!.toLong()
fun readD() = readLine()!!.toDouble()
fun readIs() = readLine()!!.split(' ').map(String::toInt)
fun readLs() = readLine()!!.split(' ').map(String::toLong)
fun readDs() = readLine()!!.split(' ').map(String::toDouble)

fun main(args: Array<String>) {
  val n = readI()
  val m = TreeMap<String, Int>()
  var x = 0
  repeat(n) {
    val s = readLine()!!
    val t = m.getOrElse(s) { 0 } + 1
    m[s] = t
    x = Math.max(x, t)
  }
  for ((s, c) in m) {
    if (c != x) continue
    println(s)
  }
}


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

#define FOR(i, a, b) for(long long int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979

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

int main(void) {
	int sum[1001] = {};
	FOR(i, 1, 1000) {
		sum[i] = sum[i - 1] + i;
	}
	
	while (1) {
		int n;
		int count = 0;

		cin >> n;
		if (n == 0) {
			break;
		}
		FOR(i, 0, n-2) {
			FOR(t, i+2, n) {
				if (sum[t] - sum[i] == n) {
					count++;
				}
			}
		}
		cout << count << endl;
	}
}


Measured memory_bytes: 3008
#include<stdio.h>

int main() {
    int r, d, x;
    scanf("%d%d%d", &r, &d, &x);
    int tmp = 0;
    for(int i = 1; i <= 10; i++) {
        printf("%d\n", r * x - d);
        x = r * x -d;
    }
    return 0;
}


Measured memory_bytes: 128
def main():
    S = input()[::-1]
    ans = 0
    mods = [0] * 2019
    mods[0] = 1
    current = 0
    x = 1
    for s in S:
        current = (current + x * int(s)) % 2019
        ans += mods[current % 2019]
        mods[current % 2019] += 1
        x = x * 10 % 2019
    print(ans)

if __name__ == '__main__':
    main()

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

using ll = long long;
using pii = pair<int, int>;

#define     endl               "\n"
#define     fast_io            ios::sync_with_stdio(false); cin.tie(0);
#define     file_io            freopen("input.txt", "r", stdin);   \
                               freopen("output.txt", "w", stdout);
#define     all(x)             begin(x), end(x)
#define     debug(x)           cerr <<"Line "<< __LINE__ <<" : "<< #x " = "<< x <<endl;
 
template<typename T, typename TT>
ostream& operator<<(ostream &os, const pair<T, TT> &t) { return os<<"("<<t.first<<", "<<t.second<<")"; }
template<typename T>
ostream& operator<<(ostream& os, const vector<T> &t) { for(auto& i: t) os<<i<<" "; return os; }
 



int main(int argc, char** argv) {
    fast_io
   
	
	int a, b;
	char op;
	//cin >> a >> op >> b;
	    
	while((cin >> a >> op >> b) && op != '?') {
	    switch(op) {
    	    case '+': cout << a + b << endl; break;
    	    case '-': cout << a - b << endl; break;
    	    case '*': cout << a * b << endl; break;
    	    case '/': cout << a / b << endl; break;
    	}
	}
	
	

    return 0;
}























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

int main(){
	string s;
	int a[ 10 ];
	while ( cin >> s ){
		for ( int i = 0; i < 10; ++i ){
			a[ i ] = static_cast< int >( s[ i ] - '0' );
		}

		for ( int i = 0; i < 10-1; ++i ){
			for ( int j = 0; j < 10-1-i; ++j ){
				a[ j ] = ( a[ j ] + a[ j + 1 ] ) % 10;
			}
		}

		cout << a[ 0 ] << endl;
	}
	return 0;
}

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

int main(){
  int n,h[100010],dp[100010];
  cin>>n;
  fr(i,n) cin>>h[i];
  dp[0]=0;
  dp[1]=abs(h[1]-h[0]);
  fr(i,n-2) dp[i+2]=min(dp[i+1]+abs(h[i+2]-h[i+1]),dp[i]+abs(h[i+2]-h[i]));
  cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1152
package main

import "fmt"

func main() {
	var hp int
	var ap int
	var ans int
	fmt.Scan(&hp, &ap)
	ans = hp/ap + min(hp%ap, 1)
	fmt.Print(ans)
}

func min(left, right int) int {
	if left >= right {
		return right
	}
	return left
}

Measured memory_bytes: 512
from collections import deque
from copy import deepcopy

N,M = map(int,input().split())
Matrix = [[False for x in range(N)] for y in range(N)]

Path = []
for i in range(M) :
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    Path.append((a,b))

for i in range(M) :
    a,b = Path[i]
    Matrix[a][b] = True
    Matrix[b][a] = True
    
ans = 0
for i in range(M) :
    a,b = Path[i]
    Matrix_ = deepcopy(Matrix)
    Matrix_[a][b] = False
    Matrix_[b][a] = False
    INF = 63
    Distance = [INF for i in range(N)]
    Distance[0] = 0
    
    QUEUE = deque([0])
    while QUEUE :
        now = QUEUE.popleft()
        
        for i in range(N) :
            if Matrix_[now][i] :
                Matrix_[now][i] = False
                Matrix_[i][now] = False
                Distance[i] = min(Distance[now]+1,Distance[i])
                QUEUE.append(i)
    #print(Distance)
    if (INF in Distance) :
        ans += 1
print(ans)


Measured memory_bytes: 3564
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;cin>>a>>b;
    if(a>0){printf("Positive\n");return 0;}
    else if(a<=0&&b>=0){printf("Zero\n");return 0;}
    else
    {
        if((b-a+1)%2){printf("Negative\n");return 0;}
        else {printf("Positive\n");return 0;}
    }
}


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

ll gcd(ll a, ll b)
{
  return b ? gcd(b, a % b) : a;
}

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

int main()
{
  ll a, b;
  cin >> a >> b;
  cout << lcm(a, b) << endl;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int [] values = {input.nextInt(), input.nextInt(), input.nextInt()};
        Arrays.sort(values);
        System.out.println(values[0] + values[1]);
    }
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int N,L,a[1000],b=0,c[1000],d=0,sum=0;
	cin>>N>>L;
	for(int i=1;i<=N;i++)
	{
		a[i]=L+i-1;
		sum+=a[i];
		c[i]=abs(a[i]);

	}
	
	for(int i=1;i<=N;i++){
		if(a[i]==0)
		   {
		   b=1;
		break;}
	}
	
	if(b==0)
	{
	sort(c+1,c+N+1);
	 for (int i=1;i<=N;i++)
	 {
	 	if(c[1]==a[i])
	 	{
	 		d=1;
	 	break;
	 	}
	 }
	 if (d==1)
	    cout<<sum-c[1]<<endl;
	  else
	    cout<<sum+c[1]<<endl;
	 
	}
	  else
	cout<<sum<<endl;
	return 0;
}

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

int main(){
    int a,b,c,k,max;
    scanf("%d %d %d %d",&a,&b,&c,&k);

    max = a;
    if(b>max)
        max = b;
    else if(c>max)
        max = c;
    
    if(max==a)
        max = (pow(2,k)*a) + b + c;
    else if (max==b)
        max = (pow(2,k)*b) + a + c;
    else if (max==c)
        max = (pow(2,k)*c) + a + b;

    printf("%d",max);
    return 0;
}

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

using namespace std;

#define lli long long int
#define REP(i,n) for(int i=0;i<n;i++)
#define REP2(i,n) for(int i=1;i<=n;i++)
#define DEBUG 0
#define all(v) begin(v),end(v)
#define inf 1LL<<55



signed main(){

	lli n;
	cin>>n;

	vector<lli> a(n);
	REP(i,n)cin>>a[i];

	/*最初は前から全てをplusにすることを考える*/
	REP(i,n-1){
		if(a[i]<0){
			a[i] *= -1;
			a[i+1] *= -1;
		}
	}

	lli ans=0;
	REP(i,n)ans+=a[i];

	lli sum = ans;
	/*次に後ろから見て行って、sumがどう変わっていくかを見る*/

	for(lli i=n-1;i>0;i--){
		if(a[i]<0){
			sum -= (a[i]+a[i-1]);
			a[i] *= -1;
			a[i-1] *= -1;
			sum += (a[i]+a[i-1]);
			ans = max(ans,sum);
		}
	}
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <complex>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <cstdlib>

#define rep(i, b) for(int i = 0; i < b; i++)
#define repi(i, a, b) for(int i = a; i < b; i++)
#define all(c) c.begin(),c.end()
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define MAX_V 1001
#define MAX_E 401
#define INF INT_MAX
#define MOD 1000000007
#define EPS 1e-7
typedef long long ll;
inline int toInt(std::string s) { int v; std::istringstream sin(s); sin >> v; return v; }
template<class T> inline std::string toString(T x) { std::ostringstream sout; sout << x; return sout.str(); }
using namespace std;

typedef double D;      // 座標値の型。doubleかlong doubleを想定
typedef complex<D> P;  // Point
typedef pair<P, P> L;  // Line
#define X real()
#define Y imag()
typedef pair<int, int> pii;

int main()
{
	ll ans = 0;
	int n;
	cin >> n;
	vector<vector<ll>> A(2, vector<ll>(n, 0));
	rep(i, 2)
		rep(j, n)
			cin >> A[i][j];

	rep(i, n)
	{
		ll res = 0;
		rep(j, i + 1)
		{
			res += A[0][j];
		}
		repi(j, i, n)
		{
			res += A[1][j];
		}
		ans = max(ans, res);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
inp = list(map(int,input().split()))
question = [int(input()) for i in range(inp[2])]
point = []
sinshutu = []
for i in range(inp[0]):
    point.append(inp[1])
    sinshutu.append('No')

for i in range(inp[2]):
    point[question[i]-1] = point[question[i]-1]+1

point = list(map(lambda x:x-inp[2], point))

for i in range(inp[0]):
    if point[i] > 0:
        sinshutu[i] = 'Yes'
    print(sinshutu[i])

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

int main(){
  int n;
  cin >> n;
  vector<int>vec(n);
  
  int cnt=0;
  for(int i=0;i<n;i++){
    cin >> vec[i] ;
    if((i+1)!=vec[i]){
      cnt++;
    }
  }
  if(cnt<=2){
    cout << "YES" ;
  }else{
    cout << "NO" ;
  }
}


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

int main(){
	int n, d;
	cin >> n >> d; // 6 2

	int uni_range = d*2 + 1; // 2*2+1=5
	cout << (n+(uni_range-1))/uni_range << endl;//(6+4)/5=2

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize ("Ofast")
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
using namespace __gnu_pbds;
using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<long long,long long> ii; 	
typedef complex<long double> com;

const ll mod = 1e9+7;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    ll n,s;
    cin >> n >> s;
    if (n <= s){
        cout << "unsafe" << endl;
    } else {
        cout << "safe" << endl;
    }
}


Measured memory_bytes: 3668
from sys import stdin
a,b = [int(x) for x in stdin.readline().rstrip().split()]
if a == 0 and b == 0:
    print("Zero")
elif a > 0 and b > 0:
    print("Positive")
elif a < 0 and b > 0:
    print("Zero")
else:
    if (b - a + 1) % 2 == 0:
        print("Positive")
    else:
        print("Negative")

Measured memory_bytes: 3060
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <sstream>
#include <typeinfo>
#include <queue>
#include <stack>
#include <tuple>

using namespace std;


typedef long long ll;
const int INT_INF = 1 << 29;
const ll INF = 1LL<<55;

typedef pair<int, int> P;
struct edge {
	int to;
	int cap;
	ll cost;
	int rev;
};

const int MAX_V = 20010;
int V;
vector<edge> G[MAX_V];
ll h[MAX_V], dist[MAX_V];
int prevv[MAX_V], preve[MAX_V];

void add_edge(int from, int to, int cap, ll cost) {
	G[from].push_back((edge){to, cap, cost, (int)G[to].size()});
	G[to].push_back((edge){from, 0, -cost, (int)G[from].size()-1});
}

ll min_cost_flow(int s, int t, int f, bool bell = false) {
	ll res = 0;
	fill_n(h, V, 0);
	while (f > 0) {
		fill_n(dist, V, INF);
		dist[s] = 0;
		if (bell) {
			bell = false;
			bool update;
			do {
				update = false;
				for (int v = 0; v < V; v++) {
					if (dist[v] == INF) continue;
					for (int i = 0; i < G[v].size(); i++) {
						edge &e = G[v][i];
						if (e.cap > 0 && dist[e.to] > dist[v] + e.cost) {
							dist[e.to] = dist[v] + e.cost;
							prevv[e.to] = v;
							preve[e.to] = i;
							update = true;
						}
					}
				}
			} while (update);
		} else {
			priority_queue<P, vector<P>, greater<P>> que;
			que.push(P(0, s));
			while (!que.empty()) {
				P p = que.top(); que.pop();
				int v = p.second;
				if (dist[v] < p.first) continue;
				for (int i = 0; i < G[v].size(); i++) {
					edge &e = G[v][i];
					if (e.cap > 0 && dist[e.to] > dist[v] + e.cost + h[v] - h[e.to]) {
						dist[e.to] = dist[v] + e.cost + h[v] - h[e.to];
						prevv[e.to] = v;
						preve[e.to] = i;
						que.push(P(dist[e.to], e.to));
					}
				}
			}
		}
		if (dist[t] == INF) {
			return -1;
		}
		for (int v = 0; v < V; v++) {
			h[v] += dist[v];
		}

		int d = f;
		for (int v = t; v != s; v = prevv[v]) {
			d = min(d, G[prevv[v]][preve[v]].cap);
		}
		f -= d;
		res += d * h[t];
		for (int v = t; v != s; v = prevv[v]) {
			edge &e = G[prevv[v]][preve[v]];
			e.cap -= d;
			G[v][e.rev].cap += d;
		}
	}
	return res;
}

const int MAX_N = 10010, MAX_K = 10010;

int main(int argc, char *argv[]) {
	int M, N, K;
	cin >> M >> N >> K;
	int w[MAX_N];
	for (int i = 0; i < N; i++) {
		scanf("%d", &w[i]);
	}
	int a[MAX_K], r = 0;
	for (int i = 0; i < K; i++) {
		scanf("%d", &a[i]);
		a[i]--;
		r+= w[a[i]];
	}
	int b[MAX_N];
	fill_n(b, MAX_N, -1);
	for (int i = 0; i < K; i++) {
		add_edge(i, i+1, INT_INF, 0);
		int j = b[a[i]];
		if (j != -1) {
			if (j == i) {
				r -= w[a[i]];
			} else {
				add_edge(b[a[i]], i, 1, -w[a[i]]);
			}
		}
		b[a[i]] = i+1;
	}
	V = K+1;
	printf("%lld\n", r + min_cost_flow(0, K, M-1, true));
    return 0;
}

Measured memory_bytes: 3252