akhauriyash/Code-Regression huggingface dataset:
/*
 *  Created on: 3 / 5 / 2020
 *  Author:     Eslam Waheed
 */
#include <bits/stdc++.h>
//#include <bits/BIGINT.h>
//#include <bits/Int128.h>
using namespace std;

//#define _CRT_SECURE_NO_WARNINGS
//#define __USE_MINGW_ANSI_STDIO
#define Eslam__Waheed ios_base::sync_with_stdio(false);cout.tie(NULL);cin.tie(NULL);

#define ll   long long
#define ull  unsigned ll
#define dd   double
#define ld   long dd
#define ss   string

#define pb      push_back
#define all(c)  c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define stp(n)  cout << fixed << setprecision(n);
#define iq(v)   v.resize(unique(v.begin(),v.end())-v.begin())
#define sz(s)   (ll)(s.size())
#define endl    '\n'

#define loop(i,m,n)  for(ll i=m;i<n;i++)

ll gcd(ll a, ll b) { return !b ? abs(a) : gcd(b, a % b); }
ll lcm(ll a, ll b) { return abs(a / gcd(a, b)) * b; }

//const ll mod = 1e9 + 7;
//__int128
/*
 you can ^_^ (•‿•)

( إن الله وملائكته يصلون على النبي يا أيها الذين آمنوا صلوا عليه وسلموا تسليما )
*/
int main()
{
    //stp(0)
    Eslam__Waheed
        ss s; cin >> s;
    if (s[2] == s[3] && s[4] == s[5])
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }
}

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

int main() {
  int N;
  cin >> N;

  vector<int> a(N);

  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
  }

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

  int alice = 0;
  int bob = 0;
  for (int i = 0; i < N; i++) {
    if (i % 2 == 0) {
      alice += a.at(i);
    } else {
      bob += a.at(i);
    }
  }

  cout << alice - bob << endl;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
const int MOD=1e9+7;


int main() {
    int a,b;
    cin >> a >> b;
    cout << max(max(a+b,a-b),a*b) << endl; 
}

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

int main()
{
    int N;
    cin >> N;
    vector<int> A(N), B(N);
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
        int sub = A[i] - (i + 1);
        B[i] = sub;

        // if (sub > 0)
        // {
        //     B[i] = sub;
        // }
        // else
        // {
        //     B[i] = 0;
        // }
    }
    sort(B.begin(), B.end());

    long long int ans = 0LL;
    if (N % 2 == 1)
    {
        int med = B[N / 2];
        for (int i = 0; i < A.size(); i++)
        {
            ans += abs(A[i] - (med + (i + 1)));
        }
    }
    else
    {
        int med1 = B[N / 2 - 1];
        int med2 = B[N / 2];
        long long int ans1 = 0LL, ans2 = 0LL;
        for (int i = 0; i < A.size(); i++)
        {
            ans1 += abs(A[i] - (med1 + (i + 1)));
            ans2 += abs(A[i] - (med2 + (i + 1)));
        }
        ans = min(ans1, ans2);
    }

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

Measured memory_bytes: 1920
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
    long long n, a, b, ans=0, x[100000], i;
    cin >> n >> a >> b;
    for(i=0;i<n;i++){
        cin >> x[i];
    }

    for(i=0;i<n-1;i++){
        ans=ans+min((x[i+1]-x[i])*a, b);
    }
    cout << ans <<endl;
    return 0;
}

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

int main() {
    vector<int> s; int n; cin >> n;
    for (int i = 0; i < n; ++i) {
        int t; cin >> t;
        s.push_back(t);
    }
    s.push_back(-1);
    int q; cin >> q;
    int c = 0;
    for (int i = 0; i < q; ++i) {
        int t; cin >> t;
        s[s.size() - 1] = t;
        int ind = 0;
        for (ind = 0; ind <= n; ++ind) {
            if (s[ind] == t) { break; }
        }
        if (ind < n) { c++; }
    }
    cout << c << endl;
}

Measured memory_bytes: 3264
import java.io.*;
import java.util.*;

public class Main{
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String muse = "ksthp";

		while(true){
			StringBuilder s = new StringBuilder(br.readLine());
			if(s.charAt(0) == '#') break;

			boolean flg = false; //ツ債カツ療猟づ個陛ェツ可ケツつェツ鳴ウツ青コツ可サツつウツづェツつスツつゥ

			for(int i=1;i<s.length();i++){
				char ch = s.charAt(i);
				if(ch == 'i' || ch == 'u'){
					if(flg){flg = false; continue;}
					if((muse.contains(s.substring(i-1,i)) || i>=2 && s.charAt(i-1)=='y' && muse.contains(s.substring(i-2,i-1))) &&
						 (i+1==s.length() || muse.contains(s.substring(i+1,i+2)))){
						s.insert(i+1,")");
						s.insert(i,"(");
						i += 2;
						flg = true;
					}
				}

				else if(ch == 'a' || ch == 'o'){
					if(flg){flg = false; continue;}
					int lastIdx = i;
					for(int j=i;j<s.length();j++){
						char c = s.charAt(j);
						if(c == 'n' || c == 'i' || c == 'u' || c == 'e' ||
							 c == 'a' && ch != 'a' || c == 'o' && ch != 'o') break;
						if(c != ch) continue;

						char l1 = s.charAt(j-1);
						char l2 = j-2>=0 ? s.charAt(j-2) : '?'; //ツ適ツ督鳴づ按閉カツ篠堋づーツ禿シツづェツづつィツつュ
						char l3 = j-3>=0 ? s.charAt(j-3) : '*'; //ツ適ツ督鳴づ按閉カツ篠堋づーツ禿シツづェツづつィツつュ

						if(!muse.contains(""+l1) && !(l1=='y' && muse.contains(""+l2))) break;

						//ツ堕」ツ可ケツ・ツ陳キツ可ケツつェツ債ャツつエツづづつ「ツづゥツ湘ェツ債陳断
						if(c == 'a' && l1=='a' ||
							 j != i && (l1 == l2 || l1 == 'y' && l2 == l3) &&
							 l2 != 'n' && l2!='i' && l2!='u' && l2!='e') break;

						lastIdx = j;
					}

					for(int j=i;j<=lastIdx-1;j++){
						if(s.charAt(j) == ch){
							if(flg){flg=false;continue;}
							s.insert(j+1,")");
							s.insert(j,"(");
							j += 2;
							lastIdx += 2;
							flg = true;
						}
					}
					flg = false;
					i = lastIdx;
				}
				else if(ch == 'e'){
					if(flg){flg = false; continue;}
				}
			}

			System.out.println(s);
		}
	}
}

Measured memory_bytes: 11000
#include<bits/stdc++.h>
#define INF 2147483647
#define SYOU(x) setprecision(x)
#define abs(x,y) max(x,y)-min(x,y)
using namespace std;
long long i[10000000];
long long u[11111110];
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long a,b,c,d=0,e=0,f=0,g=0,h=0;
  string s;
  cin >>s;
  for(int n=1;n<s.size();n++){
    if(s[n]!=s[n-1]) d++;
  }
  cout <<d<<'\n';
  return (0);
}


Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

ll dp[11111][2][100];
string s;
int d;


ll rec(int idx,int f,int x){
    if(dp[idx][f][x]!=-1)return dp[idx][f][x];
    if(idx==s.size())return x==0;
    ll ret=0;
    if(f){
        rep(i,10){
            ret+=rec(idx+1,f,(x-i+d)%d);
        }
    }
    else {
        int m=s[idx]-'0';
        rep(i,m){
            ret+=rec(idx+1,1,(x-i+d)%d);
        }
        ret+=rec(idx+1,0,(x-m+d)%d);
    }
    return dp[idx][f][x]=ret%mod;
}

int main(){
    cin>>s;
    cin>>d;
    memset(dp,-1,sizeof(dp));
    cout<<(rec(0,0,0)+mod-1)%mod<<endl;
    return 0;
}


Measured memory_bytes: 18432
def     process(tab, tour, current, result,skill, N, M, X):
    finish = True
    for i in skill:
        if (i < X):
            finish = False
            break
    if (finish):
        if (result == -1):
            return current
        else:
            return min(result, current)
    if (tour == N or (current > result and result > -1)):
        return result

    current += tab[tour][0]
    for i in range(1, M+1):
        skill[i-1] += tab[tour][i]
    avec = process(tab, tour + 1, current, result, skill, N, M, X)
    
    if (result == -1 or (avec < result and avec > -1)):
        result = avec
    current -= tab[tour][0]
    for i in range(1, M+1):
        skill[i-1] -= tab[tour][i]
    sans = process(tab, tour + 1, current, result, skill, N, M, X)
    
    if (result == -1 or (sans < result and sans > -1)):
        result = sans
    return result


data = input().split()
n,m,x = int(data[0]), int(data[1]), int(data[2])


tab = []
for i in range (n):
    data = input().split()
    t = []
    for j in range (m+1):
        t.append(int(data[j]))
    tab.append(t)


skill = [0] * m
result = process(tab, 0, 0, -1, skill, n,m,x)
print(result)




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

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

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sz(a) ((int)(a).size())
#define rep(i,a,b) for(int i=(a); i<(b); i++)
#define trav(it, a) for(auto& it : a)
#define allin(it, a) for(auto it : a)
#define read(v, a, b) for(int i=(a); i<(b); i++) scanf("%d", &v[i]);
#define clr(a,v) memset(a, v, sizeof(a))
#define all(a) (a).begin(),(a).end()
#define FAST cin.tie(0), cout.tie(0), ios::sync_with_stdio(0)
#define db(x) cerr << #x << " == " << x << endl

const int maxn = 1e5 + 100;

//dp[i] is True if the first player (that is the player who plays right now)
// can win, otherwise it is false. And to get if the player at round i can win
// we check for every possible stone thrown if theere is some in which the last
// guy can't win

int main(){
	int n, k;
	scanf("%d %d", &n, &k);
	vi a(n);
	read(a,0,n);
	vector<bool> dp(k+1);
	dp[0] = 0;
	for(int i = 1; i <= k; i++) {
		for(auto x : a) {
			if(i - x < 0)
				break;
			if(!dp[i-x])
				dp[i] = 1;
		}
	}
	puts(dp[k]? "First" : "Second");
}


Measured memory_bytes: 256
def check_trial(n):
  num = n.split()
  if int(num[0]) > 10:
    return True
  else:
    return False
def in_rating(n, result):
  if result:
    num = n.split()
    return int(num[1])
  else:
    num = n.split()
    out_rating = int(num[1]) + 100*(10-int(num[0]))
    return out_rating
def main():
  n=input()
  result = check_trial(n)
  print(in_rating(n, result))
main()

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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 30;
int dx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
int dy[8] = {1, 1, 0, -1, -1, -1, 0, 1};

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


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

int main() {
    int N;
    std::cin >> N;

    std::vector<int> a(N);
    for (int i = 0; i < N; i++) {
        std::cin >> a[i];
    }

    std::sort(a.begin(), a.end(), std::greater<int>());

    int alice = 0;
    int bob = 0;
    for (int i = 0; i < N; i++) {
        if (i % 2 == 0)
            alice += a[i];
        else
            bob += a[i];
    }

    std::cout << alice - bob << std::endl;

    return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <fstream>
#include<cstdio>
#include<iomanip>
#include<numeric>

#define REP(i, n) for(int i=0;i<n;i++)
#define REP2(i, s, n) for(int i=s;i<n;i++)
#define REP_1(i, n) for(int i=1;i<n+1;i++)
#define bitSearch(bit, n) for(int bit = 0; bit < (1 << N); bit++)
using namespace std;

void printAns(int a) { cout << a << endl; }

void yesno(bool a) { if (a)cout << "Yes" << endl; else cout << "No" << endl; }

void YESNO(bool a) { if (a)cout << "YES" << endl; else cout << "NO" << endl; }

typedef long long ll;
typedef unsigned long ul;
typedef long double ld;

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

ll INF = 10000000;
ll mod = 1000000007;//10^9+7


ll multi(ll A,ll B, ll M){
    ll L=(A-1)/M+1;
    ll R=B/M;
    return R-L+1;
}

ll lcm(ll a, ll b){
    if(a<b){ll tmp=a;a=b;b=tmp;}
    ll x=a*b;
    ll r=a%b;
    while(r!=0){
        a=b;
        b=r;
        r=a%b;
    }
    return x/b;
}

//番号ズレ注意！！
int main() {
    ll A,B,C,D;
    cin>>A>>B>>C>>D;
    cout<<B-A+1-multi(A,B,C)-multi(A,B,D)+multi(A,B,lcm(C,D));
}


Measured memory_bytes: 256
/*  
   |\_/|
   |* *|
   \_+_/
          */
#include<bits/stdc++.h>

#define endl '\n'

using namespace std;

int main(){

  cin.tie(0);     // cout と cin の同期を切る
  ios::sync_with_stdio(false);  /* cの stdioストリーム (printfとか)と*/

  int N,L;

  cin>>N>>L;

  string str[101];

  for(int i=0;i<N;i++){
    cin>>str[i];
  }

  sort(str+0,str+N);

  for(int i=0;i<N;i++){
    cout<<str[i];
  }

  cout<<endl;
  
  
  return 0;

}


Measured memory_bytes: 256
// Template
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;
typedef long long ll;

#define REP(i, n) for(int i = 0;i < n;i++)
#define INF 1 << 30
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

int main(){
    std::ios_base::sync_with_stdio(false);

    bool ok = false;
    string s; cin >> s;

    if(s.length()==7){
        if(s=="keyence"){
            cout << "YES" <<endl; return 0;
        } else{
            cout << "NO" << endl; return 0;
        }
    }

    for(int i=0; i<s.length(); i++){
        for(int j=i+1; j<s.length(); j++){
            //cout << s.substr(0, i) << " " << s.substr(j,s.length()) << endl;
            if(s.substr(0, i)+s.substr(j,s.length()) == "keyence"){
                cout << "YES" <<endl;
                return 0;
            }
        }
    }


    cout << "NO" << endl;

    return 0;
}


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

ll solve() {
    ll N, D, A;
    cin >> N >> D >> A;
    vector<ll> X(N), H(N);
    for ( int i = 0; i < N; i++ ) {
        cin >> X[i] >> H[i];
    }
    vector<pii> xh(N);
    for ( int i = 0; i < N; i++ ) {
        xh[i] = pii(X[i],H[i]);
    }
    sort(xh.begin(), xh.end());
    queue<pii> ae;
    ll ac = 0, ans = 0;
    for ( int i = 0; i < N; i++ ) {
        ll x = xh[i].first, h = xh[i].second;
        while ( !ae.empty() && ae.front().first < x ) {
            ac -= ae.front().second;
            ae.pop();
        }
        ll r = h - ac;
        if ( r > 0 ) {
            ll k = (r+A-1)/A;
            ans += k;
            ac += k*A;
            ae.push(pii(x + 2*D, k*A));
        }
    }
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 8192
#include <stdio.h>
#include <algorithm>

#define LIM_S 200002
#define LIM_N 200001

char str[LIM_S];
int a[5];
int k;

void receive_input() {
	for (size_t i = 0; i < 5; i++) {
		fgets(str, sizeof(str), stdin);
		sscanf(str, "%d", &a[i]);
	}

	fgets(str, sizeof(str), stdin);
	sscanf(str, "%d", &k);
}

void initialize() {
}

int main(void) {
	receive_input();
	initialize();

	int diff = a[4] - a[0];
	printf("%s\n", (diff <= k) ? "Yay!" : ":(");

	return 0;
}


Measured memory_bytes: 128
#include<cstdio>
#include<string>
#include<iostream>
#include<algorithm>
using namespace std;

const long long mod=1e9+7;
const int N=2e5+7;
int n;
int a[105];

int main()
{
	int avg=0;
	int s=0;
	cin>>n;
	for(int i=0;i<n;i++)
	{
	  cin>>a[i];
	  s+=a[i];
    }
    int p=s%n;
    if(p<=n*1.0/2)
    avg=s/n;
    else
    avg=s/n+1;
    s=0;
    for(int i=0;i<n;i++)
    {
    	s+=(a[i]-avg)*(a[i]-avg);
	}
    cout<<s<<endl;
}

Measured memory_bytes: 256
N=int(input())
a=list(map(int,input().split()))

def calc_cost(x,avg):
  return (x-avg)**2

avg = sum(a)//N

delta = [-2,-1,0,1,2]

ans=10**20
for i in range(len(delta)):
  val = sum(map(lambda x:calc_cost(x,avg+delta[i]),a))
  ans = min(ans,val)
  
print(ans)

Measured memory_bytes: 9192
def ints
  gets.split.map(&:to_i)
end

N, M, C = ints
B = ints

ans = 0
N.times do
  _A = ints
  n = _A.zip(B).map{|a, b| a * b }.inject(&:+) + C
  if n > 0
    ans += 1
  end
end
puts ans


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

int main(){
  int i,x;
  i = 1;
  while(1) {
    cin >> x;
    if (x == 0){
      break;
    }
    cout << "Case" << " " << i << ":" << " " << x << endl;
    i = i + 1;
  }
  return 0;
  }



Measured memory_bytes: 3072
//#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#define MAX_INT 2100000000
using namespace std;
typedef long long int ll;
#ifdef COMPILE_IN_VCPP
#include <windows.h>
HWND GetConsoleHwnd(void)
{
#define MY_BUFSIZE 1024 // Buffer size for console window titles.
	HWND hwndFound;         // This is what is returned to the caller.
	char pszNewWindowTitle[MY_BUFSIZE]; // Contains fabricated// WindowTitle.
	char pszOldWindowTitle[MY_BUFSIZE]; // Contains original// WindowTitle.
	// Fetch current window title.
	GetConsoleTitle(pszOldWindowTitle, MY_BUFSIZE);
	// Format a "unique" NewWindowTitle.
	wsprintf(pszNewWindowTitle, "%d/%d",GetTickCount(),GetCurrentProcessId());
	// Change current window title.
	SetConsoleTitle(pszNewWindowTitle);
	// Ensure window title has been updated.
	Sleep(40);
	// Look for NewWindowTitle.
	hwndFound = FindWindow(NULL, pszNewWindowTitle);
	// Restore original window title.
	SetConsoleTitle(pszOldWindowTitle);
	return(hwndFound);
}
#endif
int main()
{
#ifdef COMPILE_IN_VCPP
	SetWindowPos(GetConsoleHwnd(), HWND_TOPMOST, 0, 0, 0, 0,
		(SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW));
#endif
	int r, d, x[11], i, j;
	cin >> r >> d >> x[0];
	for (i = 1; i <= 10; i++)
	{
		x[i] = r * x[i - 1] - d;
		cout << x[i] << endl;
	}
}



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

using namespace std;
using ll = long long;
using vl = vector<ll>;
using pll = pair<ll, ll>;

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

template <class T1, class T2>
inline void chmax(T1 &a, const T2 &b) {
    if (a < b) a = b;
}
template <class T1, class T2>
inline void chmin(T1 &a, const T2 &b) {
    if (a > b) a = b;
}

constexpr ll INF = 0x3f3f3f3f3f3f3f3fLL;
constexpr ll mod = 1000000007;

int main() {
    ll X, Y;
    cin >> X >> Y;
    if (Y % 2 == 1) {
        cout << "No" << endl;
        return 0;
    }

    Y /= 2;
    if (Y < X || X * 2 < Y) {
        cout << "No" << endl;
        return 0;
    }

    cout << "Yes" << endl;
}

Measured memory_bytes: 3628
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        int n = str.length();
        for (int i = 0; i < n; i++) {
            System.out.print("x");
        }
        System.out.println();
    }
}


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


int main() {
  stack<int> st;
  vector<string> row(200);
  string S;
  getline(cin,S);
  int ind = 0;
  string l;
  for (char cs:S){
      if (cs == ' '){
          row.at(ind) = l;
          l = "";
          ind++;
      }else{
          l+=cs;
      }
  }
  row.at(ind) = l;


  for (int i = 0;i <= ind;i++){
      string s = row.at(i);
      if (s == "+"){
          int y = st.top(); st.pop();
          int x = st.top(); st.pop();
          int z = x+y;
          st.push(z);
        
      }else if (s == "-"){
          int y = st.top(); st.pop();
          int x = st.top(); st.pop();
          int z = x-y;
          st.push(z);
      }else if (s == "*"){
          int y = st.top(); st.pop();
          int x = st.top(); st.pop();
          int z = x*y;
          st.push(z);
      }else{
          st.push(stoi(s));
      }

  }
  cout << st.top() << endl;


  
  

}


Measured memory_bytes: 3176
#include<iostream>
using namespace std;
#define MAXN 100

int N;
int F[MAXN][5][2];
int P[MAXN][11];

int main(){
  cin>>N;
  for(int i=0;i<N;i++){
    for(int j=0;j<5;j++){
      cin>>F[i][j][0]>>F[i][j][1];
    }
  }
  for(int i=0;i<N;i++){
    for(int j=0;j<=10;j++){
      cin>>P[i][j];
    }
  }
  int joi[5][2];
  int ans=-2000000000;
  for(int bitb=0;bitb<(1<<5);bitb++){
    for(int bita=0;bita<(1<<5);bita++){
      for(int i=0;i<5;i++){
        for(int j=0;j<2;j++){
          joi[i][j]=0;
        }
      }
      if(bitb==0&&bita==0) continue;
      for(int i=0;i<5;i++){
        if((bitb>>i)&1) joi[i][0]=1;
        if((bita>>i)&1) joi[i][1]=1;
      }
      int tmp=0;
      for(int k=0;k<N;k++){
        int cnt=0;
        for(int i=0;i<5;i++){
          for(int j=0;j<2;j++){
            if(joi[i][j]==1&&F[k][i][j]==1) cnt++;
          }
        }
        tmp+=P[k][cnt];
      }
      ans=max(ans,tmp);
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define P pair<int,int>
#define vp vector<P>
#define PP pair<P,int>
#define vpp vector<PP>
#define fi first
#define se second
#define INF (1<<30)
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define all(x) (x).begin(),(x).end()

int f(int a,int b){
    if(a>b)return INF;
    return b-a;
}

int main(){
    int x,y;
    cin>>x>>y;
    int ans=INF;
    REP(i,2){
        REP(j,2){
            int p=x,q=y;
            if(i)p*=-1;
            if(j)q*=-1;
            ans=min(ans,f(p,q)+i+j);
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
S = input()
N = len(S)

from collections import defaultdict

reddic = defaultdict(int)
bludic = defaultdict(int)

redarray = [0] * (N+1)
bluarray = [0] * (N+1)

for e,c in enumerate(S):

    if c == "2":
        bludic[e+1] += 2
        bluarray[e+1] += 2
    elif c == "1":
        reddic[e+1] += 1
        bludic[e+1] += 1

        redarray[e+1] += 1
        bluarray[e+1] += 1
    elif c == "0":
        reddic[e+1] += 2
        redarray[e+1] += 2

for i in range(1,N+1):
    redarray[i] += redarray[i-1]
    bluarray[i] += bluarray[i-1]

# print("redarray: ", redarray)
# print("bluarray: ", bluarray)

dp = [ [0] * (2*N+1) for _ in range(2*N+1)]
dp[0][0] = 1
MOD = 998244353

for p in range(1, 2*N+1):
    for r in range(0, p):
        idx = p if p <= N else N
        if r < redarray[idx]:
            dp[p][r+1] += dp[p-1][r] % MOD
        if p-1-r < bluarray[idx]:
            dp[p][r] += dp[p-1][r] % MOD
    # print("{:3d}".format(p), dp[p])

print(dp[2*N][redarray[N]]%MOD)

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

  int main() {
    int N;
    
    string S;
    string T;
    cin >> N >> S >> T;
    
    

    for(int i=0; i<N; i++){
      cout << S.at(i) << T.at(i);
    }
  }
    

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

int main()
{
    string s;
    cin >> s;
    string ans;
    for (int i = 0; i < s.size(); i++) {
        if (i % 2 == 0) {
            ans += s[i];
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

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

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

long long INF=LLONG_MAX;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	ll k,x; cin >> k >> x;
	k*=500;
	if(k>=x)cout << "Yes" << endl;
	else cout << "No" << endl;
}	


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

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

const int MAX = 1e5 + 10;
const int INF = 1e9;
const int MOD = 1e9 + 7;

string S, T;

int main(){
    cin >> S >> T;

    map<char, vector<char>> m;
    rep(i, T.size()){
        char c = T[i];
        m[c].push_back(S[i]);
    }

    for(auto i : m){
        vector<char> chars = i.second;
        if(2 <= chars.size()){
            rep(j, chars.size() - 1){
                if(chars[j] != chars[j + 1]){
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
    }

    m.clear();
    rep(i, S.size()){
        char c = S[i];
        m[c].push_back(T[i]);
    }

    for(auto i : m){
        vector<char> chars = i.second;
        if(2 <= chars.size()){
            rep(j, chars.size() - 1){
                if(chars[j] != chars[j + 1]){
                    cout << "No" << endl;
                    return 0;
                }
            }
        }
    }

    cout << "Yes" << endl;
}

Measured memory_bytes: 1180
#include <iostream>
#include <string>
#include <cmath>
#include <vector>


using namespace std;

inline int gcd(int a, int b);
inline int gcd(int a, int b, int c);

int main()
{
	int	inNum;

	cin >> inNum;

	int sum = 0;

	for (int i = 1; i <= inNum; i++)
	{
		for (int j = 1; j <= inNum; j++)
		{
			for (int k = 1; k <= inNum; k++)
			{
				sum += gcd(i, j, k);
			}
		}
	}

	cout << sum;

}



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




int gcd(int a, int b, int c)
{
	return gcd(gcd(a, b), c);
}

Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
#include<numeric>
#include<iomanip>
#include<functional>
#include<cstdlib>
#include<queue>
#include<deque>
const double PI = acos(-1);
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
using ll =long long;
const int mod = 1000000007;
class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% mod + mod) % mod) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint & a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator-=(const mint & a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator*=(const  mint & a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint & a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint & a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint & a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint & a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint & a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream & os, const mint & m) {
		os << m.x;
		return os;
	}
};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

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 * b / gcd(a, b);
};
//fixed << setprecision(2)

//小文字=大文字+32

int main() {
	int n;
	cin >> n;
	vector<double>v(n);
	rep(i, n) {
		cin >> v[i];
	}
	int tmp=v[0]-1;
	for(int i=1;i<n;i++) {
		if (tmp <= v[i]-1) {
			tmp=v[i] - 1;
		}
		else if(tmp<=v[i]){
			tmp = v[i];
		}
		else {
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
}
	



Measured memory_bytes: 3952
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,x[200000],sx[200000];
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>x[i];
		sx[i]=x[i];
	}
	sort(sx,sx+n);
	for(int i=0;i<n;i++)
		cout<<(x[i]<sx[n/2]?sx[n/2]:sx[n/2-1])<<endl;
}


Measured memory_bytes: 3712
#include<bits/stdc++.h>
#define rep(i, n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
 
int main(void){
    ll n, m;
    cin>>n>>m;
    ll ans;
    if(n*2<=m){
        ans = n;
        ans += (m-2*n)/4;
    }
    else ans = m/2;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <complex>
#include <ctime>
#include <cstdlib>

using namespace std;

inline int to_int(string s) {int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string to_str(T x) {ostringstream sout; sout << x; return sout.str();}

typedef long long ll;
typedef pair<int, int> P;
const int INF = 1<<22;

// dp[i][j] := [i , j]??????????????????????????則???????????????????属???即????????属
// |(4*5   (5*3)  3*2)|  2*1
int main()
{
	int n, dp[128][128], r[128];
	P T[128];

	cin >> n;

	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < n; j++)
		{
		 	dp[i][j] = INF;
		}
	}
	/*
	for(int i = 0; i < n; i++)
	{
		dp[i][i] = 0;
	}
	*/
	for(int i = 0; i < n; i++)
	{
		cin >> T[i].first >> T[i].second;
		dp[0][i] = 0;
	}
	/*
	r[0] = T[0].first;
	for(int i = 0; i < n; i++)
	{
		r[i+1] = T[i].second;
	}
	*/
	/*
	for(int i = 0; i <= n; i++)
	{
		cout << r[i] << endl
	}
	*/
	/*
	for(int l = 1; l < n; l++)
	{
		for(int i = 0; i < n-l; i++)
		{ 
			int j = i + l;
			for(int k = 1; k <= l; k++)
			{
				dp[i][j] = std::min(dp[i][j], dp[i][i + k - 1] + dp[i + k][j] + T[i].first*T[i + k].first*T[j].second); //r[j]*r[k]*r[i+j+1]);
			}
		}
	}
*/
	for(int i = 1; i < n; i++)
	{
		for(int j = 0; j < n-i; j++)
		{ 
			for(int k = 1; k <= i; k++)
			{
				dp[i][j] = std::min(dp[i][j], dp[k-1][j] + dp[i-k][j+k] + T[j].first*T[j + k].first*T[j + i].second); //r[j]*r[k]*r[i+j+1]);
				//printf("%3d : %3d : %3d => %3d\n", i, j, k, dp[i][j]);
				//puts("run");
			}
		}
	}

	/*
	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < n; j++)
		{
			printf("%10d ",dp[i][j]);
		}
		puts("");
	}
    */	

	cout << dp[n-1][0] << endl;
}

Measured memory_bytes: 1212
#include<bits/stdc++.h>
#include <fstream>
#include <iostream>
#include <string.h>
#include <sstream>
using namespace std;
int main(){

  string S;
  stringstream SS;
  cin>> S;
  char c = S[S.size()-1];
  if(c=='s')
    SS<<S<<"es";
  else
    SS<<S<<"s";
  cout<<SS.str()<<endl;
}

Measured memory_bytes: 3616
#include <stdio.h>

int main() {
	int i;
	int n;
	unsigned long long num[86] = { 2,1 };

	scanf("%d", &n);

	for (i = 2; i < n + 1; i++) {
		num[i] = num[i - 1] + num[i - 2];
	}

	printf("%lld\n", num[n]);

	return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder2 {
	class Program {
		static void Main(string[] args) {

	var inputArray = retreiveLongArray();
			var inputCount = 1;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}
			var N = (int)inputArray[0];

			if (N==1) {//駅が一つしかない場合
				Console.WriteLine(0);
				return;
			}


			var info = new List<long[]>();

			for (int i = 0; i < N-1; i++) {
				var inp = retreiveLongArray();
				info.Add(inp);
			}
			//N番目の駅の情報を足しておく
			var nInfo = new long[] { 0, 0, 0 };
			info.Add(nInfo);


			var arriveTime = new Dictionary<long, long>();

			arriveTime.Add(N - 1, 0);

			for (int i = N-2; i >= 0; i--) {
				var ekiInfo = info[i];
				var nextStation = ekiInfo[1] + ekiInfo[0];
	
				//一駅づつ進んでいく
				var next = nextStation;
				for (int j = i+1; j < N-1; j++) {
					var norikaeInfo = info[j];
					var f = norikaeInfo[2];
					var s = norikaeInfo[1];
					var c = norikaeInfo[0];
						
					if (next <= s) {//始発に追いついた場合
						next = arriveTime[j];
						break;
					}

					var mod = next % f;
					var machi = mod == 0 ? 0 : f - mod;
					next = next + machi + c;
				}
				arriveTime.Add(i, next);
				
			}

			for (int i = 0; i < N; i++) {
				Console.WriteLine(arriveTime[i]);
			}

		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}
	}
}


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

#define rep3(i, s, n ,a) for (int i = (s); i < (int)(n); i+=a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

int main(){
    long a, b, n;
    cin >> a >> b >> n;
    long maxim=-999999, t=a/b;
    if(b-1<=n){
        long x = b-1;
        cout << a*x/b-a*(x/b) << endl;
    }else{
        long x = n;
        cout << a*x/b-a*(x/b) << endl;
    }
    // if(t*b-a>=0){
    //     long x = n / b * b - 1;
    //     long p = a*x/b-a*(x/b), q = a*n/b-a*(n/b);
    //     if(p>q){
    //         cout << p << endl;
    //     }else{
    //         cout << q << endl;
    //     }
    // }else{

    // }
    // rep3(x, b-1, n+1, b){
    //     maxim = max(maxim, t * x - a * (x / b));
    // }
    //cout << maxim << endl;
    return 0;
}

Measured memory_bytes: 3568
#include <iostream>
 
using namespace std;
 
int main(){
  int N;
  int A[100];
  int ju = 1;
  
  cin >> N;
  for(int i = 0;i < N;i++){
    cin >> A[i];
    if(!(A[i] % 2 == 1 || A[i] % 6 == 0 || A[i] % 10 == 0)){
      ju = 0;
    }
  }
  
  if(ju){
    cout << "APPROVED";
  }else{
    cout << "DENIED";
  }
  
  
}

Measured memory_bytes: 256
H, W = map(int, input().split())
S = [input() for _ in range(H)]

dp = [[0]*W for _ in range(H)]
if S[0][0] == "#":
    dp[0][0] = 1

for i in range(1, W):
    if S[0][i-1] == S[0][i]:
        dp[0][i] = dp[0][i-1]
    else:
        dp[0][i] = dp[0][i-1]+1

for i in range(1, H):
    if S[i-1][0] == S[i][0]:
        dp[i][0] = dp[i-1][0]
    else:
        dp[i][0] = dp[i-1][0]+1


for i in range(1, H):
    for j in range(1, W):
        if S[i][j] == S[i-1][j]:
            a = dp[i-1][j]
        else:
            a = dp[i-1][j]+1
        if S[i][j] == S[i][j-1]:
            b = dp[i][j-1]
        else:
            b = dp[i][j-1]+1
        dp[i][j] = min(a, b)

print((dp[H-1][W-1]+1)//2)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long ll;
int main(){
	int money[6]={1,5,10,50,100,500};
	int c[6],sum;
	for(int i=0;i<6;i++){
		scanf("%d",&c[i]);
		sum+=c[i]*money[i];
	}
	if(sum>=1000)printf("1\n");
	else printf("0\n");

}

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

int main(){
  int n;
  cin>>n;
  string s,t;
  cin>>s;
  cin>>t;
  int init = 0;
  int last = s.length()-1;
  
  while(init < n){
    cout<<s[init]<<t[init];
    init++;
  }
  
  
  
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

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

int main()
{
	string a, b;
	cin >> a >> b;
	string c = a + b;
	int t = atoi(c.c_str());
	double s = sqrt((double)t);
	if ((int)s == s) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
from math import floor,ceil,sqrt,factorial,log
from collections import Counter, deque
def S(): return input()
def I(): return int(input())
def MS(): return map(str,input().split())
def MI(): return map(int,input().split())
def LS(): return list(MS())
def LI(): return list(MI())
def LLS(): return [list(map(str, l.split() )) for l in input()]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def LLSN(n: int): return [LS() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]

N = I()
X = LI()

ma = max(X)
mi = min(X)

ans = 10000000000
for i in range(mi, ma+1):
    p = i

    sum = 0
    for x in X:
        sum += pow(x-p, 2)

    if ans > sum:
        ans = sum

print(ans)

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

#define loop(v, f, l) for(int v = (f), v##_ = (l); v < v##_; ++v)

using namespace std;

typedef long long int lint;
static inline int in(){ int x; scanf("%d", &x); return (x); }
static inline lint inl(){ lint x; scanf("%lld", &x); return (x); }

int main()
{
	map<string, vector<int> > index;
	pair<string, vector<int> > word_page;
	string word;
	int page;
	while( cin >> word >> page )
	{
		index[word].push_back(page);
	}

	for(map<string, vector<int> >::iterator it = index.begin(); it != index.end(); it++)
	{
		vector<int> v = it->second;
		sort(v.begin(), v.end());

		cout << it->first << endl;
		vector<int>::iterator itv = v.begin();
		for(; itv + 1 != v.end(); itv++)
		{
			cout << *itv << " ";
		}
		cout << *itv << endl;
	}

	return (0);
}

Measured memory_bytes: 1244
import sys
import numpy as np
import math  # gcdもあるよ
from collections import deque
from collections import defaultdict
from copy import deepcopy
from itertools import accumulate #リストを与えると累積和を返す
def input(): return sys.stdin.readline().rstrip()
from functools import lru_cache #メモ化

def main():
    n = int(input())
    A = list(map(int,input().split()))
    ans = 0
    tmp = 0
    for i in A:
        if tmp < i:
            tmp = i
        else:
            ans += tmp - i
    print(ans)
    return 0

if __name__ == "__main__":
    main()

Measured memory_bytes: 50552
#include <stdio.h>

int main()
{
    int n,i,tmp;

    scanf("%d",&n);

    i=0;
    while(7*i<=n){
        tmp=n-7*i;
        if(tmp%4==0){
            printf("Yes\n");

            return 0;
        }
        i++;
    }

    printf("No\n");

    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
int main(){
 int n,m,j,i,a[100],b[100][100] ,ans[100] = {0};
 scanf("%d",&n);
 scanf("%d",&m);
 for(i = 0; i < m ; i++){
   scanf("%d",&a[i]);
  }
  for(i = 0 ; i <m ;i++){
    for(j = 0; j < n; j++){
      scanf("%d",&b[i][j]);
    }
  }
  for(i = 0 ; i <m ;i++){
    for(j = 0; j < n; j++){  
      if(a[i] == b[i][j]){
        ans[j] ++;
      }else{
        ans[a[i]-1]++;
      }
    }
  }
  for(i = 0 ; i < n ; i++){
    printf("%d\n",ans[i]);
  } 
  return 0;
}

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

using namespace std;

int main(){
    int n,k;
    cin >> n >> k;
    vector<int> h(n);
    for(int i = 0; i < n; i++){
        cin >> h[i];
    }
    sort(h.begin(),h.end());

   int ans = 1e9;

   for(int i = 0; i< n-k+1; i++){
       ans = min(ans, h[i+k-1] - h[i]);
   }

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



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

int main() {
	int n;
	while (cin >> n, n) {
		for (int i = 0;i < n;i++) {
			int m, e, j;
			int flg;
			cin >> m >> e >> j;
			if (m == 100 || e == 100 || j == 100)flg = 1;
			else if (m + e + j >= 240)flg = 1;
			else if (m + e >= 180)flg = 1;
			else if (m + e + j >= 210)flg = 0;
			else if (m + e + j >= 150 && (m >= 80 || e >= 80))flg = 0;
			else flg = -1;

			if (flg == 1)cout << 'A' << endl;
			else if (flg == 0)cout << 'B' << endl;
			else cout << 'C' << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3048
#include <iostream>
#include<string>
#include <cstdio>
#include<utility>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<bitset>
#include<queue>
#include<set>
#include <limits>
#include <numeric>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
typedef pair<double,double>P_D;
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define reprev(i, n) for (int i = (int)n - 1; i >= 0; i--)
#define ALL(a)  (a).begin(),(a).end()
#define C_MAX(a, b) ((a)>(b)?(a):(b))
#define fi first
#define se second
#define MAX 100100
#define MAX_N 200100
#define SENTINEL 2000000000
#define MAX_B 1001001
#define NIL -1
#define MOD 1000000007
#define INF 1 << 29
#define INFTY 1000000000000000000LL

int main(){
  int n;cin>>n;
  int a[MAX];
  a[0]=a[n+1]=0;
  rep(i,n)cin>>a[i+1];
  int sum=0;
  rep(i,n+1)sum+=abs(a[i+1]-a[i]);
  for(int i=1;i<n+1;i++){
    int x=a[i-1],y=a[i],z=a[i+1];
    
    cout<<sum-abs(x-y)-abs(y-z)+abs(z-x)<<endl;
  }
}

Measured memory_bytes: 1664
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll n, m;

int main()
{
  std::cin >> n >> m;

  std::cout << (n-1)*(m-1) << std::endl;

  return 0;
}

Measured memory_bytes: 3536
#include <bits/stdc++.h>
using namespace std;
int a[50],b[50];

int main() {
  int N,M;
  cin >> N >> M;

  for (int i=0; i < M; i++) cin >> a[i] >> b[i];

  int cnt = 0;
  
  for (int j=0; j < N; j++){
    int cnt = 0;
    int s=j+1;
    for (int i=0; i < M; i++){
      if (a[i]==s or b[i]==s) cnt++;
    }
    cout << cnt << endl;
  }
}



Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int compare(const void *a,const void *b){
  int x= (*(int *)a);
  int y= (*(int *)b);
    if( x > y )
        return 1;
    return -1;
}
int main () {
  int n;
  int a[112345];

  scanf("%d", &n);

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

  qsort(a,n,sizeof(int),compare);

  int cont=1,ans=0;
  for (int j=0; j<n; j++)
  {
      if (a[j] == a[j+1]){
          cont++;
      }else {
          ans+= cont%2;
          cont=1;
      }
  }
  printf("%d\n",ans);
  return 0;
}


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

using namespace std;

struct node
{
	int num,l,r,ls,rs;
	node(int _l,int _r)
	{
		num=INT_MAX;
		l=_l;
		r=_r;
	}
};

vector<node> T;

int make(int l,int r)
{
	int id=T.size();
	T.push_back(node(l,r));
	T[id].ls=(l+1==r?-1:make(l,(l+r)/2));
	T[id].rs=(l+1==r?-1:make((l+r)/2,r));
	return id;
}

void update(int id,int x,int t)
{
	if(T[id].l+1==T[id].r)
	{
		if(T[id].l==x) T[id].num=t;
		return ;
	}
	int mid=(T[id].l+T[id].r)>>1;
	if(x<mid)
		update(T[id].ls,x,t);
	else
		update(T[id].rs,x,t);
	T[id].num=min(T[T[id].ls].num,T[T[id].rs].num);
}

int getmin(int id,int l,int r)
{
	if(l==r||T[id].l>=r||T[id].r<=l)
		return INT_MAX; 
	if(T[id].l>=l&&T[id].r<=r)
		return T[id].num;
	int mid=(T[id].l+T[id].r)>>1,mi=INT_MAX;
	if(l<mid)
		mi=min(mi,getmin(T[id].ls,l,r));
	if(r>mid)
		mi=min(mi,getmin(T[id].rs,l,r));
	return mi;
}

int main()
{
	//freopen("in.txt","r",stdin);
	T.reserve(200100);
	int n,q;
	scanf("%d%d",&n,&q);
	//printf("|\n");
	make(0,n);
	//printf("||\n");
	for(int i=0;i<q;i++)
	{
		int com,x,y;
		scanf("%d%d%d",&com,&x,&y);
		if(com==0) update(0,x,y);
		else printf("%d\n",getmin(0,x,y+1));
	}
}

Measured memory_bytes: 6748
# -*- coding: utf-8 -*-


# 入力を整数に変換して受け取る
def input_int():
    return int(input())


# マイナス1した値を返却
def int1(x):
    return int(x) - 1


# 半角スペース区切り入力をIntに変換してMapで受け取る
def input_to_int_map():
    return map(int, input().split())


# 半角スペース区切り入力をIntに変換して受け取る
def input_to_int_tuple():
    return tuple(map(int, input().split()))


# 半角スペース区切り入力をIntに変換してマイナス1した値を受け取る
def input_to_int_tuple_minus1():
    return tuple(map(int1, input().split()))


def main():
    import math
    r = input_int()


    return r * 2 * math.pi


if __name__ == "__main__":
    print(main())


Measured memory_bytes: 9184
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include<math.h>
#define ll long long

int main(){
  char s[4];
  scanf("%s",s);
  if(s[1]=='B'){
    puts("ARC");
  }
  if(s[1]=='R'){
    puts("ABC");
  }
  return 0;
}

Measured memory_bytes: 1664
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <limits.h>
int main(){
    int i,ans=0,stln;
    char s[200020]={},t[200020]={};
    scanf("%s %s",s,t);
    stln=strlen(s);
    for(i=0; i<stln; i++){
        if(s[i]!=t[i])ans++;
    }
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 2120
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<stack>
#include<map>
#include<cstdint>
#include<unordered_map>
#include<boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < ( int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define vi vector<int>
#define vll vector<ll>
#define all(x) (x).begin(),(x).end()
#define F first
#define S second


namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	deque<pair<int, int>>bw;
	deque<int>cp;
	int cnt = 1;
	bool whstart = true;
	rep(i, n - 1) {
		if (s[i] == s[i + 1]) {
			cnt++;
		}
		else {
			if (s[i] == '#') {
				bw.push_back(make_pair(cnt, 1));
			}
			else {
				bw.push_back(make_pair(cnt, 0));
			}
			cnt = 1;
		}
	}

	if (s[n - 1] == '#') {
		bw.push_back(make_pair(cnt, 1));

	}
	else {
		bw.push_back(make_pair(cnt, 0));
	}
	int wmax = 0;
	rep(i, bw.size()) {
		if (bw[i].second == 0) {
			wmax += bw[i].F;
		}
	}
	int bsum = 0, wsum = 0;
	rep(i, bw.size()) {
		if (bw[i].second == 1) {
			bsum += bw[i].first;
		}
		else {
			wsum += bw[i].first;
		}
		cp.push_back(bsum + wmax - wsum);
	}
//	rep(i, cp.size()) {
	//	cout << cp[i] << endl;
	//}
	sort(all(cp));
	cout << min(cp[0],wmax) << endl;
}


Measured memory_bytes: 2948
inputs = []
for i in range(6):
    inputs.append(int(input()))

bar = inputs[:-1]
n = 5
k = inputs[-1]

ok = True

for i in range(n):
    for j in range(n):
        # print("i: {}, j:{}".format(i,j))
        if abs(bar[i] - bar[j]) > k:
            ok = False
            break
            

if ok:
    print("Yay!")
else:
    print(":(")


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define INF 100000000

#define MAX_V 200

int N,M,R;
int d[MAX_V][MAX_V];    //d[u][v] is cost of e(u, v)

void warshall_floyd(){
    for(int k = 0; k < N; k++)
        for(int i = 0; i < N; i++)
            for(int j = 0; j < N; j++)
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
}


int main(){
    cin >> N >> M >> R;
    vector<int> r(R);
    int inp;
    REP(i,R){
        cin >> inp;
        inp--;
        r[i] = inp;
    }

    REP(i,MAX_V) REP(k,N) d[i][k] = INF;
    int A,B,C;
    REP(i,M){
        cin >> A >> B >> C;
        A--,B--;
        d[A][B] = C;
        d[B][A] = C;
    }
    REP(i,N)
        d[i][i] = 0;

    warshall_floyd();

    //REP(i,R-1){
    //    cost += d[r[i]][r[i+1]];
    //}
    
    sort(r.begin(), r.end());
    int ans = INF;
    int cost;
    do{
        cost = 0;
        REP(i,R-1){
            //printf("%d %d %d\n", r[0], r[1], r[2]);
            cost += d[r[i]][r[i+1]];
        }
        ans = min(ans, cost);
    }while(next_permutation(r.begin(), r.end()));

    //REP(i,N){
    //    REP(k,N){
    //        printf("e(%d,%d) = %d\n", i, k, d[i][k]);
    //    }
    //}
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384