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

int main(void){
    int n,ascore,bscore;
    while(true){
        cin >> n;
        if(n==0) break;
        ascore = 0;
        bscore = 0;
        int a[n],b[n];
        for(int i=0;i<n;i++){
            cin >> a[i] >> b[i];
            if(a[i]>b[i]) ascore += (a[i]+b[i]);
            else if(a[i]<b[i]) bscore += (a[i]+b[i]);
            else {
                ascore += a[i];
                bscore += b[i];
            }
        }
        cout << ascore << " " << bscore << endl;
    }
    return 0;
}


Measured memory_bytes: 3152
#include <iostream>
#include <vector>
#include <algorithm>
#define F(i,a,n) for(long long i = (a); i < (n); ++i)
using namespace std;
int main(){
  int N,K;
  cin >> N >> K;
  int A[200010] = {};
  F(i,0,N){
    int x;
    cin >> x;
    A[x] += 1;
  }
  vector<int> a(A,A+200010);
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  long long ans = 0;
  F(i,K,a.size()){
    ans += a.at(i);
  }
  cout << ans << endl;
  return 0;
}


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

#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define ACC(c) (accumulate(ALL(c), 0LL))
#define PRINT(x) cout << (x) << "\n"

using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;

inline int std_in(int& a) {return scanf("%d", &a);}
auto pint_compare = [](pint x, pint y) -> bool{return (x.first < y.first);};
const int MOD = 1000000007;

signed main(){
    string S;
    cin >> S;
    int N = S.length();
    bool ok = true;
    REP(i, N){
        if(S[i] != S[N - 1 - i]) ok =false;
    }
    REP(i, N / 2){
        if(S[i] != S[N / 2 - 1 - i]) ok = false;
    }
    REP(i, N / 2){
        if(S[i + N / 2 + 1] != S[N - 1 - i]) ok = false;
    }
    if(ok) PRINT("Yes");
    else PRINT("No");
    return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)
var foothold []string

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func updateCost(loc int) {
	if loc == 0 {
		return
	}
	for i := 1; i <= Min(K, loc); i++ {
		cost[loc] = Min(cost[loc], cost[loc-i]+Abs(h[loc]-h[loc-i]))
	}
	return
}

var N int
var K int
var h []int
var cost []int

func main() {
	N = nextInt()
	K = nextInt()
	h = nextInts(N)
	cost = make([]int, N)
	for i := 0; i < len(cost); i++ {
		cost[i] = 1<<31 - 1
	}
	cost[0] = 0
	for i := 0; i < N; i++ {
		updateCost(i)
	}
	fmt.Println(cost[N-1])
}

func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}

func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}

var nextReader func() string

func init() {
	nextReader = NewScanner()
}

func NewScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}

func Min(a int, b int) int {
	if a > b {
		return b
	}
	return a
}

func Abs(a int) int {
	if a < 0 {
		return a * -1
	}
	return a
}


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

using namespace std;

#define int long long
#define ff first
#define ss second
#define pb emplace_back

const int MAXN = 100009;
int a[MAXN];
int n, m;

signed main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> m >> n;
    pair<int, int> x(-1, -1);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        if (a[i] % 2 == 1)
        {
            if (x.ff == -1)
                x.ff = a[i];
            else if (x.ss != -1)
            {
                cout << "Impossible";
                return 0;
            }
            else
                x.ss = a[i];
        }
    }
    vector<int> ans;
    if (x.ff != -1)
    {
        cout << x.ff << " ";
        for (int i = 1; i <= x.ff; i += 2)
            ans.pb(2);
    }
    else
        ans.pb(1);
    for (int i = 0; i < n; i++)
    {
        int y = a[i];
        if (y % 2 == 1)
            continue;
        cout << y << " ";
        if ((y / 2) % 2 == 1)
        {
            int e = 2;
            for (; e <= y / 2 - 3; e += 4)
                ans.pb(4);
            ans.pb(2);
            e += 2;
            for (; e < y; e += 4)
                ans.pb(4);
        }
        else
        {
            for (int e = 2; e < y; e += 4)
                ans.pb(4);
        }
    }
    if (x.ss == -1)
    {
        if (ans.back() == 2)
            ans.back() = 1;
        else if (ans.back() == 4)
        {
            ans.back() = 1;
            ans.pb(2);
        }
        else
            ans.pop_back();
    }
    else
    {
        cout << x.ss << " ";
        for (int e = 2; e < x.ss; e += 2)
            ans.pb(2);
    }
    cout << "\n";
    cout << ans.size() << "\n";
    for (int e : ans)
        cout << e << " ";
}


Measured memory_bytes: 892
import scala.io.StdIn.readLine

object Main {
  def sum(n:Int, s:Int, x:Int):Int = {
    if(n==1) { if(s >= 0 && s<=9 && s > x ) 1 else 0 }
    else { for(i <- x+1 to 9 if s>=i ) yield sum(n-1,s-i,i) }.sum
  }

  def getSum(sb:StringBuilder):Unit = {
    val r = readLine.split(" ").map(_.toInt)

    if(r(0)==0 && r(1)==0) print(sb.result)
    else {
      println(sum(r(0),r(1),-1))
      getSum(sb)
    }
  }

  def main(args:Array[String]) = getSum(new StringBuilder)
}

Measured memory_bytes: 45928
N = int(input())
C = list(map(int,input().split()))

X = []
temp = 0

for i in range(1,N,2):
    temp += C[i]
X.append( sum(C) - 2 * temp)

for j in range(N-1):
    X.append( 2 * C[j] - X[-1] )

Y = map(str,X)

print(' '.join(Y))

Measured memory_bytes: 19148
#include<cstdio>

using namespace std;

int main(){
	for(int n,a,b,c,x;scanf("%d%d%d%d%d",&n,&a,&b,&c,&x),n;){
		int y[100];
		for(int i=0;i<n;i++)	scanf("%d",y+i);

		bool ok=false;
		int t,pos=0;
		for(t=0;t<=10000;t++){
			if(x==y[pos])	pos++;
			if(pos==n){ ok=true; break; }
			x=(a*x+b)%c;
		}
		if(ok)	printf("%d\n",t);
		else	puts("-1");
	}

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <iomanip>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>
#include <cstdint>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

constexpr ll inf = INT64_MAX / 4;
constexpr ll mod = 1000000007;

constexpr int maxn = 200000;

int n, a[maxn + 1], c[maxn + 1], r[maxn + 1];

set<int> prime;

map<int, int> fac_p(int m) {
    int k = m;
    map<int, int> s;
    for (auto e:prime) {
        while (k % e == 0) {
            k = k / e;
            s[e]++;
        }
    }
    if(k != 1) s[k]++;
    return s;
}

set<int> divisor(int m) {
    auto t = fac_p(m);
    set<int> s[2];
    s[1].insert(1);
    int i = 0;
    for (auto e:t) {
        for (auto f:s[(i+1) % 2]) {
            for (int j = 0; j <= e.second; j++) {
                s[i % 2].insert(f * pow(e.first, j));
            }
        }
        s[(i+1) % 2].clear();
        i++;

    }
    return s[(i+1) % 2];
}

int main() {
    for (int i = 2; i * i <= maxn; i++) {
        bool flag = true;
        for (auto e:prime) {
            if (i % e == 0) {
                flag = false;
                break;
            }
        }
        if (flag) prime.insert(i);
    }
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    for (int i = n; i > 0; i--) {
        if (c[i] != a[i]) {
            r[i] = 1;
            for(auto e:divisor(i)) {
                c[e] = (c[e]+1)%2;
            }
        }
    }
    set<int> v;
    for(int i = 1;i <= n;i++) if(r[i]) v.insert(i);
    cout << v.size() << endl;
    for(auto e:v) cout << e << " ";
    cout << endl;
}

Measured memory_bytes: 9088
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=1005;
int n,m,num[N],flag[N],ll,cnt,ti[N],f[N],A,B;
char s[N][N];
void up(int x){
	if (x==1)return;
	if (num[f[x]]>num[f[x/2]]){
		swap(f[x],f[x/2]);
		up(x/2);
	}
}
void down(int x){
	int i=x;
	if (x*2<=ll&&(num[f[x*2]]>num[f[i]]))i=x*2;
	if (x*2<ll&&(num[f[x*2+1]]>num[f[i]]))i=x*2+1;
	if (i!=x){
		swap(f[x],f[i]);
		down(i);
	}
}
signed main(){
	scanf("%lld%lld%lld%lld",&n,&m,&B,&A);
	for (int i=0;i<=m;i++)
		for (int j=0;j<=n;j++)
			if (A*i+(m-i)*(n-A)==B*j+(n-j)*(m-B)&&!s[0][0]){
				for (int k=0;k<m;k++){
					if (k<i)num[k]=A;
					else num[k]=n-A;
				}
				for (int k=0;k<n;k++){
					for (int p=1;p<=m;p++)f[p]=p-1;
					ll=m;
					for (int p=m;p;p--)down(p);
					if (k<j){
						memset(flag,0,sizeof flag);
						for (int l=0;l<B;l++){
							int now=f[1];
							num[now]--;
							ti[now]=++cnt;
							flag[now]=1;
							s[k][now]='0';
							f[1]=f[ll--];
							down(1);
						}
						for (int l=0;l<m;l++)
							if (!flag[l])s[k][l]='1';
					}
					else {
						memset(flag,0,sizeof flag);
						for (int l=0;l<m-B;l++){
							int now=f[1];
							num[now]--;
							ti[now]=++cnt;
							flag[now]=1;
							s[k][now]='0';
							f[1]=f[ll--];
							down(1);
						}
						for (int l=0;l<m;l++)
							if (!flag[l])s[k][l]='1';						
					}
				}
			}
	if (!s[0][0]){
		puts("-1");
		return 0;
	}		
	for (int i=0;i<n;i++){
		for (int j=0;j<m;j++)putchar(s[i][j]);
		puts("");
	}
}

Measured memory_bytes: 2176
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int DX[] = {0, 1, 0, -1};
const int DY[] = {-1, 0, 1, 0};


//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main(int argc, char const *argv[])
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	int w, n;
	int index = 1;
	while(true){
		cin >> w;
		if(w == 0) break;
		cin >> n;
		VVI dp(n + 1, VI(w + 1));
		char comma;
		VI values(n);
		VI weights(n);
		REP(i, n){
			cin >> values[i] >> comma >> weights[i];
		}
		REP(i, n){
			REP(j, w + 1){
				if(j + weights[i] <= w){
					int &value = dp[i + 1][j + weights[i]];
					 value = max(value, values[i] + dp[i][j]);
				}
				dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
			}
		}
		int weight = max_element(ALL(dp[n])) - dp[n].begin();
		int value_sum = dp[n][weight]; 
		cout << "Case " << index << ":" << endl;
		cout << value_sum << endl;
		cout << weight << endl;

		index++;
	}



	return 0;
}

Measured memory_bytes: 5032
#include <bits/stdc++.h>
using namespace std;
int main() {
	int N;
	cin >> N;
    int X = 0; 
    int M = 0;
	vector<int>A(N);
	for(int i = 0; i < N; i++) {
	cin>>A[i];
	if (A[i]%2 == 0 && (A[i]%3 == 0 || A[i]%5 == 0)) {
       X++;
    }
    if (A[i]%2 == 0){
       M++;
    }
    }
    if(X == M){
      cout << "APPROVED" <<endl;
    }
    else {
      cout << "DENIED" <<endl;
    }
}


Measured memory_bytes: 764
#include <bits/stdc++.h> 
using namespace std; 
#define for_(i, s, e) for (int i = s; i < e; i++)
#define for__(i, s, e) for (ll i = s; i < e; i++)
#define SSTR(x) static_cast<std::ostringstream&>((std::ostringstream() << std::dec << x)).str()
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
#define endl '\n'


int main() {
	#ifndef ONLINE_JUDGE
	freopen("test.in", "r", stdin);
	#endif
	
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int k; cin >> k;
	unordered_set<int> rems = {7};
	int v = 7;
	
	for_(i, 1, k+1) {
		if (v % k == 0) {
			cout << i << endl;
			return 0;
		}
		
		v = (v * 10 + 7) % k;
	}
	
	cout << -1 << endl;

	return 0;
}


Measured memory_bytes: 3612
A, B, C, X, Y = map(int, input().split())
temp = A * X + B * Y
while True:
    if min(X, Y) > 0:        
        X -= 1
        Y -= 1
        now = temp - A - B + 2 * C
        if min(temp, now) == temp:
            break
        else:
            temp = now
    elif max(X, Y) > 0:
        if X == 0:
            Y -= 1
            now = temp - B + 2 * C
            if min(temp, now) == temp:
                break
            else:
                temp = now
        else:
            X -= 1
            now = temp - A + 2 * C
            if min(temp, now) == temp:
                break
            else:
                temp = now
    else:
        break
print(temp)

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

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var strings = Console.ReadLine().Split(' ').ToList();
            Console.WriteLine($"{strings[1]}{strings[0]}");
        }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>  // clang-format off
using namespace std;
using Int = long long;
#define REP_(i, a_, b_, a, b, ...) for (int i = (a), lim_i = (b); i < lim_i; i++)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
struct SetupIO { SetupIO() { cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(13); } } setup_io;
#ifndef _MY_DEBUG
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Thu Mar 19 18:56:59 JST 2020
 **/

signed main() {
    Int n;
    cin >> n;
    vector<string> s(n);
    vector<int> p(n);
    REP(i, n) cin >> s[i] >> p[i];

    vector<int> ord(n);
    REP(i, n) ord[i] = i;
    sort(ord.begin(), ord.end(), [&](int i, int j) {
        return s[i] == s[j] ? p[i] > p[j] : s[i] < s[j];
    });
    for (int x : ord) cout << x + 1 << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main()
{
    long long int a, b,c,d,e;
    scanf("%lld%lld%lld", &a, &b, &c);
    d = 4 * (a * b);
    e = (c - a - b) * (c - a - b);
    if (c <= a + b || d >= e)
    {
        printf("No");
    }
    else
    {
        printf("Yes");
    }
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll N,i,c=0,e=0,d,s=0;
    cin>>N;
    ll A[N];
    for(i=0;i<N;i++){
        cin>>A[i];
    }
    for(i=1;i<N;i++){
        if(A[i]<A[i-1]){
            s+=(A[i-1]-A[i]);
            A[i]=A[i-1];
        }
    }
    cout<<s<<endl;
}

Measured memory_bytes: 5120
# Pyramid
n = int(input())
data = []
h_ = 0
for i in range(n):
    data.append(list(map(int, input().split())))
data = sorted(data, key=lambda x: x[2], reverse=True)
for cx in range(101):
    for cy in range(101):
        for j in range(n):
            if j == 0:
                h_ = data[0][2] + abs(cx - data[0][0]) + abs(cy - data[0][1])
            else:
                if data[j][2] == max(0, h_ - abs(cx - data[j][0]) - abs(cy - data[j][1])):
                    if j == n - 1:
                        print('{0} {1} {2}'.format(cx, cy, h_))
                        exit()
                    else:
                        continue
                else:
                    break


Measured memory_bytes: 3064
import sys
sys.setrecursionlimit(10 ** 6)

# to enable variable use in global
global tree, point

# v : current node, f : parent node 
def dfs(v, f):
    global tree, point
    for next_v in tree[v]:
        if next_v == f:
            continue
    
        point[next_v] += point[v]
        dfs(next_v, v)

n , q = map(int, input().split())
tree = [[] for _ in range(n)]
point = [0] * n
for _ in range(n - 1):
    a , b = map(int,input().split())
    tree[b - 1].append(a - 1)
    tree[a - 1].append(b - 1)

for _ in range(q):
    p , x = map(int, input().split())
    point[p - 1] += x

dfs(0, 0)
print(*point)

Measured memory_bytes: 233108
//B - Strings with the Same Length
 
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
	int n;
	scanf("%d",&n);
	char a[n],b[n];
	scanf("%s %s",&a,&b);
	for(int i=0; i<n; i++){
		printf("%c%c",a[i],b[i]);
	}	
	printf("\n");
	return 0;
}	

Measured memory_bytes: 256
class ob(object):
  
  def __init__(self, H):
    self.H = H
    self.connect = []
    
  def road(self, m):
    self.connect.append(m)
    
N, M = tuple(map(int, input().split()))

obs = []

for h in list(map(int, input().split())):
  obs.append(ob(h))
  
for m in range(M):
  a, b = tuple(map(int, input().split()))
  obs[a-1].road(obs[b-1].H)
  obs[b-1].road(obs[a-1].H)
  
c = 0
  
for o in obs:
  if len(o.connect) == 0:
    c += 1
  elif max(o.connect)<o.H:
    c += 1
    
print(c)

Measured memory_bytes: 39012
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,N) for(ll i=0;i<N;++i)
const ll INF = 1LL<<60;

int main(){
    ll N; cin >> N;
    map<ll,ll> mp;
    rep(i,N){
        ll a; cin >> a;
        mp[a]++;
    }
    ll ans = 0;
    for(auto it : mp){
        if(it.second % 2) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 6528
#include <stdio.h>

int main()
{
	int N, hundred, ten, one, ans;
  	scanf("%d", &N);
  	hundred = N / 100;
  	ten = N / 10 - hundred * 10;
  	one = N - hundred * 100 - ten * 10;
  	if (hundred > ten){
    	ans = hundred * 111;
    } else if (hundred == ten && ten >= one){
    	ans = hundred * 111;
    } else {
    	ans = (hundred + 1) * 111;
    }
  	printf("%d", ans);
}

Measured memory_bytes: 128
#!python3

iim = lambda: map(int, input().rstrip().split())

def resolve():
    N = int(input())
    A = list(iim())
    mx = 10**18
    A.sort()

    if  0 in A:
        print(0)
        return

    ans = 1
    for a in A:
        ans *= a
        if ans > mx:
            print(-1)
            return

    print(ans)

if __name__ == "__main__":
    resolve()


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

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			List<long> nm = Console.ReadLine().Split(' ').Select(long.Parse).ToList();
			long n = nm[0];
			long k = nm[1];
			List<long> a = Console.ReadLine().Split(' ').Select(long.Parse).ToList();
			long x = 0;
			long t = 1;
			while (t <= k) {
				long count0 = 0;
				long count1 = 0;
				for (int i = 0; i < n; i++) {
					if ((a[i] & t) != 0) {
						++count1;
					} else {
						++count0;
					}
				}

				if (count0 >= count1) {
					x |= t;
				}

				t *= 2;
			}

			long[] anss = new long[40];
			for (int i = 0; i < 40; i++) {
				long xx = 0;
				for (int j = 0; j < 40; j++) {
					if (j > i) {
						xx |= k & ((long)1 << j);
					} else if (j == i) {
					} else {
						xx |= x & ((long)1 << j);
					}
				}

				xx = Math.Min(xx, k);
				for (int j = 0; j < n; j++) {
					anss[i] += xx ^ a[j];
				}
			}

			Console.WriteLine(anss.Max());
		}
	}

	
}


Measured memory_bytes: 31324
#include <stdio.h>
#include<stdlib.h>
#include<string.h>
#include<time.h>
int main(int argc,char **argv){
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    if(a*b<c){
        printf("%d\n",a*b);
    }
    else{
        printf("%d\n",c);
    }
    return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
int n, m;
vector<int> g[100001];
int p;
bool used[100001];
void dfs(int x){
  used[x]=1;
  for(auto y:g[x]){
    if(used[y] || y==p) continue;
    dfs(y);
  }
}
int main()
{
	cin>>n>>m;
  for(int i=0; i<m; i++){
    int a, b; cin>>a>>b;
    a--; b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  for(int i=0; i<n; i++){
    if(g[i].size()%2==1){
      cout<<"No"<<endl;
      return 0;
    }
  }
  int ct4=0;
  for(int i=0; i<n; i++){
    if(g[i].size()>=6){
      cout<<"Yes"<<endl;
      return 0;
    }else if(g[i].size()==4){
      p=i;
      ct4++;
    }
    if(ct4>=3){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  if(ct4<=1){
    cout<<"No"<<endl;
    return 0;
  }
  for(auto y:g[p]){
    dfs(y);
    break;
  }
  for(int i=0; i<n; i++){
    if(i!=p && !used[i]){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 7424
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
// #define mt make_tuple
// typedef tuple<int,int,int,int> tp;
// typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};
#define yes cout<<"Yes\n"
#define no cout<<"No\n"

//nCr mod m
#define MOD 1000000007
#define M 2200000
vector<ll> fact;
bool h=false;
void init(){
	h=true;
	fact=vector<ll>(M);
	fact[0]=fact[1]=1;
	loop(i,2,M)fact[i]=fact[i-1]*i%MOD;
}
// a^b mod MOD
ll powmod(ll a,ll b,ll m=MOD){
	ll out=1;
	ll p=a%m;
	while(b){
		if(b&1)out=out*p%m;
		p=p*p%m;
		b>>=1;
	}
	return out;
}
//nCr
ll nCr(ll n,ll r,ll m=MOD){
	if(!h)init();
	if(n<0||r<0||n<r)return 1;//??????
	ll out=fact[n]*powmod(fact[r]*fact[n-r]%m,m-2,m)%m;
	return out;
}

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

	int a,b;
	cin>>a>>b;
	if(a-b)no;
	else yes;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
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; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }



long long a, b, c;

bool solve() {
    if (a + b >= c) return false;
    return a * b * 4 < (a + b - c) * (a + b - c);
}

int main() {
    while (cin >> a >> b >> c) {
        if (solve()) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}

















Measured memory_bytes: 256
while True:
    n,k = map(int,input().split())
    if n == k == 0:
        break
    N_lis = []
    for i in range(n):
        N_lis.append(int(input()))
    N_max = 0
    N_sum_1 = 0
    N_sum_2 = 0
    for j in range(k):
        N_sum_1 += N_lis[j]
    for l in range(n - k):
        N_sum_2 = N_sum_1 - N_lis[l] + N_lis[l + k]
        if N_sum_2 > N_max:
            N_max = N_sum_2
        N_sum_1 = N_sum_2
    print(N_max)

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

double f(double a, double b, double theta) {
    if (theta > M_PI_2 - 1e-10) {
        return 0.0;
    }
    double ret;
    if (a * tan(theta) <= b) {
        ret = a * a * b - a * a * a * tan(theta) / 2.0;
    } else {
        ret = b * b / tan(theta) * a / 2.0;
    }
    return ret;
}

void Main() {
    double a, b, x;
    cin >> a >> b >> x;
    double ok = M_PI_2;
    double ng = 0.0;
    double eps = 1e-10;

    while (ok - ng > eps) {
        double mid = (ok + ng) / 2.0;
        if (f(a, b, mid) < x) {
            ok = mid;
        } else {
            ng = mid;
        }
    }
    cout << ok / M_PI * 180 << '\n';
}

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


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <string>
#define INF 100000
using namespace std;
int H, W,N;
int sx, sy;
typedef long long ll;

int main(){
    ll L,R;
    cin >> L >> R;

    R = min(R,L+4038);
    int ans =2018;
    for(ll i=L;i<=R;i++){
        for(ll j=i+1;j<=R;j++){
            int x = i*j%2019;
            ans = min(ans,x);
        }
    }
    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){

  for(int n,m,a[10],b[10],r=0;cin>>n>>m&&n&&m;r=0){
  for(int i=0;i<n;i++) cin>>a[i];
  for(int i=0;i<m;i++) cin>>b[i];
  for(int i=0;i<n;i++) for(int j=0;j<m;j++) {
      if(a[i]&&b[j]&&a[i]==b[j]){
	r+=a[i];
	a[i]=0;
	b[j]=0;
      }
    }
  for(int i=0;i<n;i++) r+=a[i];
  for(int i=0;i<m;i++) r+=b[i];
  
  cout<<r<<endl;
  }
  return 0;

}

Measured memory_bytes: 3084
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int su = 0;
		for(int i = 0;;i++){
			su = Integer.parseInt(br.readLine());
			if(su == 0){
				break;
			}
			System.out.println("Case "+ (i + 1) +": "+su);
		}
	}
}

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

using namespace std;

typedef long long ll;

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

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

int main(void) {
    int N, K;
    cin >> N >> K;

    if (N % K == 0) {
        cout << "0" << endl;
    } else {
        cout << "1" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
typedef long long ll;
const ll maxn = 1e5 + 10, INF = 0x3f3f3f3f3f3f3f3f;
ll       n, m, vis[maxn], dis[maxn];
#define pil    pair<ll, ll>
#define vec    vector<pil>
#define pb     push_back
#define mp     make_pair
vector<pil>                             V[maxn];
priority_queue<pil, vec, greater<pil> > q;
void init()
{
    for (int i = 2; i <= n; i++)
        V[i].pb(mp(i - 1, 0));
}
void solve()
{
    dis[1] = 0;
    for (int i = 2; i <= n; i++)
        dis[i] = INF;
    q.push(mp(dis[1], 1));
    while (!q.empty())
    {
        pil p = q.top(); q.pop();
        ll  x = p.second; if (vis[x])
            continue;
        vis[x] = 1;
        for (int i = 0; i < V[x].size(); i++)
        {
            ll y = V[x][i].first, d = V[x][i].second;
            if (vis[y])
                continue;
            if (dis[y] > dis[x] + d)
                dis[y] = dis[x] + d;
            q.push(mp(dis[y], y));
        }
    }
    if (dis[n] != INF)
        cout << dis[n] << endl;
    else
        cout << "-1\n";
}
int main()
{
    ios::sync_with_stdio(0);
    cin >> n >> m;
    init();
    for (int i = 0, u, v, w; i < m; i++)
    {
        cin >> u >> v >> w;
        V[u].pb(mp(v, w));
    }
    solve();
    return 0;
}


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

const int mod = 1e5;
const long long INF = 1LL<<60;
using ll = long long;
using P = pair<int,int>;


int main(){
    int n, m, Q;
    cin >> n >> m >> Q;
    
    vector<int> l(m), r(m);
    rep(i, m) cin >> l[i] >> r[i];
    
    vector<int> p(Q), q(Q);
    rep(i, Q) cin >> p[i] >> q[i];
    
  
    //2-dimentional accumulation of sum
    vector<vector<ll>> s(n+1, vector<ll>(n+1));
    
    //累積和を作る準備をする
    
    rep(i, m){
        s[l[i]][r[i]]++;
    }
    
    
    
    
    //累積和を計算する
    for (int i = 1; i <= n; i++){
        for (int j = 1; j <= n; j++) {
            s[i][j] += s[i - 1][j];
			s[i][j] += s[i][j - 1];
			s[i][j] -= s[i - 1][j - 1];
        }
    }
    
 
 
    //各クエリに対して答えを返す
    rep(i, Q){
        
        // クエリ [x1, x2] × [y1, y2]の長方形区域の和
        int left = p[i];
        int right = q[i];
        int ans = s[right][right] - s[left-1][right] - s[right][left-1] + s[left-1][left-1];
        cout << ans << endl;
    }
    
}

Measured memory_bytes: 5248
n = int(input())
a = [int(item) for item in input().split()]

if n % 2 == 0:
    for i in range(n-1, -1, -2):
        print(a[i])
    for i in range(0, n, 2):
        print(a[i])
else:
    for i in range(n-1, -1, -2):
        print(a[i])
    for i in range(1, n, 2):
        print(a[i])

Measured memory_bytes: 26016
//Pantyhose(black) + glasses = infinity

#include <bits/stdc++.h>
using namespace std;
 
#define debug(x) cerr << #x << " = " << x << '\n';
#define BP() cerr << "OK!\n";
#define PR(A, n) {cerr << #A << " = "; for (int64_t _=1; _<=n; ++_) cerr << A[_] << ' '; cerr << '\n';}
#define PR0(A, n) {cerr << #A << " = "; for (int64_t _=0; _<n; ++_) cerr << A[_] << ' '; cerr << '\n';}
#define FILE_NAME "sol"

const int64_t MAX_N = 200002;
const int64_t INF = 1e9;

int n;
int64_t a[MAX_N], cost0[MAX_N], cost1[MAX_N];
int64_t f0[MAX_N], f1[MAX_N], f2[MAX_N], f3[MAX_N], f4[MAX_N];

void readInput() {
	cin >> n;
	for (int i=1; i<=n; ++i)
		cin >> a[i];
}

void solve() {
	int64_t min_f0, min_f1, min_f2, min_f3;

	min_f0 = min_f1 = min_f2 = min_f3 = 0;

	for (int i=1; i<=n; ++i) {
		cost0[i] = cost0[i-1] + (a[i]==0 ? 2 : a[i]%2);
		cost1[i] = cost1[i-1] + (a[i]+1)%2;

		f0[i] = f0[i-1] + a[i];
		min_f0 = min(min_f0, -cost0[i]+f0[i]);

		f1[i] = cost0[i] + min_f0;
		min_f1 = min(min_f1, -cost1[i]+f1[i]);

		f2[i] = cost1[i] + min_f1;
		min_f2 = min(min_f2, -cost0[i]+f2[i]);

		f3[i] = cost0[i] + min_f2;
		min_f3 = min(min_f3, -f0[i]+f3[i]);

		f4[i] = f0[i] + min_f3;
	}
	// debug(min_f0);

	cout << f4[n];
}

int main() {
	#ifdef GLASSES_GIRL
		freopen(FILE_NAME".inp", "r", stdin);
		freopen(FILE_NAME".out", "w", stdout);
	#endif
	ios::sync_with_stdio(0); cin.tie(0);
	readInput();
	solve();
}

Measured memory_bytes: 12800
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less 
#define pb push_back
#define For(i,s,e) for (ll i=(s); i<(e); i++)
#define Debug_array(a,n) for (ll i=(0); i<(n); i++) cout<<a[i]<<" "
#define Foe(i,s,e) for (ll i=(s); i<=(e); i++)
#define Fod(i,s,e) for (ll i=(s)-1; i>=(e); i--)
#define Mod 1000000007
#define pii pair<ll,ll>
#define fi first
#define se second
#define endl "\n"
#define mp make_pair
#define big_prime 15486277
#define bigger_prime 179424697
#define biggest_prime 32416188691
//#define random_shuffle(indices.begin(), indices.end());
//std::random_device rd;
//std::mt19937 g(rd());
//std::shuffle(v.begin(), v.end(), g);
using namespace __gnu_pbds; 
using namespace std;

typedef long long ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag,tree_order_statistics_node_update> ordered_set; 

#define MAX 5002

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll n,k;cin>>n>>k;
	pii b[n];
	bool c[n];
	For(i,0,n) {
		char temp;
		cin>>b[i].fi>>b[i].se>>temp;
		c[i] = (temp=='W');
	}

	vector<pair<pii , pii>> a;
	For(i,0,n) a.pb({{(k-b[i].se%k),i},b[i]});
	sort(a.begin(),a.end());

	vector<ll> Xi[k+1];
	For(i,0,n) Xi[(k-a[i].se.fi%k)].pb(i);

	ll ans=0;
	ll temp = n;
	ll count=0;
	bool colors[n];
	For(i,0,n){
		ll t1 = ((a[i].se.fi)/k)%2;
		ll t2 = ((a[i].se.se)/k)%2;
		if((!t1 && !t2) || (t1 && t2)) colors[i]=0;
		else colors[i]=1;
		if(colors[i]==c[a[i].fi.se]) count++;
	}
	ans = max(ans,count);
	temp = min(temp,count);

	For(i,0,k){
		for(ll x:Xi[i]){
			colors[x] = !colors[x];
			if(colors[x]==c[a[x].fi.se]) count++;
			else count--;
		}
		ll C=count;
		ans = max(ans,C);
		temp = min(temp,C);
		ll index = 0;
		For(j,0,k){
			while(index<n && a[index].fi.fi==j){
				colors[index] = !colors[index];
				if(colors[index]==c[a[index].fi.se]) C++;
				else C--;
				colors[index] = !colors[index];
				index++;
			}
			ans = max(ans,C);
			temp = min(temp,C);
		}
	}
	cout<<max(ans,n-temp)<<endl;



	
}

Measured memory_bytes: 7920
#include<bits/stdc++.h>
using namespace std;
vector<int> v[100005];
int ans[100005], vis[100005];
void bfs()
{
      queue<int> q;
      q.push(1);
      while(!q.empty())
      {
            int temp=q.front();
            q.pop();
            for (int i=0; i<v[temp].size(); i++)
            {
                  if (0==ans[v[temp][i]])
                  ans[v[temp][i]]=temp;
                  if (vis[v[temp][i]]==0)
                  {
                        vis[v[temp][i]]=1;
                        q.push(v[temp][i]);
                  }
            }
      }
}
int main()
{
      ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
      int n, m;
      cin >> n >> m;
      while(m--)
      {
            int a, b;
            cin >> a >> b;
            v[a].push_back(b);
            v[b].push_back(a);
      }
      bfs();
      cout << "Yes" <<endl;
      for (int i=2; i<=n; i++)
      {
            cout << ans[i] << endl;
      }
	return 0;
}


Measured memory_bytes: 10952
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define all(a)          (a).begin(), (a).end()
#define sort(a)         sort(all(a))
#define uniq(a)         sort(a);(a).erase(unique(all(a)), (a).end())
#define reverse(a)      reverse(all(a))
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }
#define pb              push_back
#define fst             first
#define int             long long
#define INF             __LONG_LONG_MAX__

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

struct UnionFind {
  vector<int> par;
  
  UnionFind(int n) : par(n, -1) { }

  int root(int x) {
    if (par[x] < 0) return x;
    else return par[x] = root(par[x]);
  }
  
  bool issame(int x, int y) {
    return root(x) == root(y);
  }
  
  bool merge(int x, int y) {
    x = root(x); y = root(y);
    if (x == y) return false;
    if (par[x] > par[y]) swap(x, y); // merge technique
    par[x] += par[y];
    par[y] = x;
    return true;
  }
  
  int size(int x) {
    return -par[root(x)];
  }
};

void solve() {
  int N, M, K;
  cin >> N >> M >> K;
  vector<set<int> > dame(N);
  UnionFind uf(N);
  for (int i = 0; i < M; ++i) {
    int a, b; cin >> a >> b; --a, --b;
    dame[a].insert(b);
    dame[b].insert(a);
    uf.merge(a, b);
  }
  for (int i = 0; i < K; ++i) {
    int c, d; cin >> c >> d; --c, --d;
    if (!uf.issame(c, d)) continue;
    dame[c].insert(d);
    dame[d].insert(c);
  }

  for (int i = 0; i < N; ++i) {
    int mem = uf.size(i) - 1; // 同じ連結成分の「自分以外」の人数
    mem -= dame[i].size(); // その中ですでに友達かブロック関係の人数
    cout << mem << " ";
  }
  cout << endl;
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


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

using namespace std;



int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);
    int N, Y;
    int a[4];
    cin >> N >> Y;
    if(Y % 1000)
        cout << "-1 -1 -1\n";
    else
    {
        a[1] = Y / 10000;
        Y %= 10000;
        a[2] = Y / 5000;
        Y %= 5000;
        a[3] = Y / 1000;
        int cnt = a[1] + a[2] + a[3];
        while(cnt < N)
        {
            if(a[1] && cnt + 9 <= N)
            {
                --a[1];
                a[3] += 10;
                cnt += 9;
            }else
            if(a[2] && cnt + 4 <= N)
            {
                --a[2];
                a[3] += 5;
                cnt += 4;
            }else
            if(a[1])
            {
                --a[1];
                a[2]+= 2;
                ++cnt;
            }else
                break;
        }
        if(cnt != N)
            cout << "-1 -1 -1\n";
        else
            cout << a[1] << ' ' << a[2] << ' ' << a[3] << '\n';
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
typedef long long ll;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define FOR(i,n) for(int i=0;i<n;i++)
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e18;


signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    int n=s.length();
    string t = s;
    reverse(t.begin(),t.end());
    if(s!=t){cout<<"No"<<endl;return 0;}
    string u1 = s.substr(0,(n-1)/2);
    string u2 = u1;
    reverse(u2.begin(),u2.end());
    if(u1!=u2){cout<<"No"<<endl;return 0;}
    string v1 =s.substr((n+1)/2,(n-1)/2);
    string v2 = v1;
    reverse(v2.begin(),v2.end());
    if(v1!=v2){cout<<"No"<<endl;return 0;}
    cout<<"Yes"<<endl;return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;
typedef long long ll;
ll N,M,sum = 0;
vector<pair<ll ,ll>> vp;
vector<ll> v;

int main(){
    cin >> N >> M;
    v.resize(N);
    vp.resize(M);
    for (int i = 0;i < N;i++)
        cin >> v[i];
    sort(v.begin(), v.end());
    for (int i = 0;i < M;i++){
        ll a,b;
        cin >> b >> a;
        vp[i].first = a;
        vp[i].second = b;
    }
    sort(vp.begin(), vp.end());
    int t = M-1;
    for (int i = 0; i < N;i++){
        if(vp[t].second < 1)
            t--;
        if(t >= 0 && v[i] < vp[t].first){
            sum += vp[t].first;
            vp[t].second--;
        }else{
            sum += v[i];
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 2560
a, b = map(int,input().split())
if (a and b) < 0:
    if (abs(a - b) + 1) % 2 == 0:
        print('Positive')
    else:
        print('Negative')
elif (a >= 0 and b <= 0) or (a <= 0 and b >= 0):
    print('Zero')
else:
    print('Positive')

Measured memory_bytes: 3060
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>

const int N = 2e2 + 22;
int a, b, d[N][N], f[N][N];

int main() {
	scanf("%d%d", &a, &b);
	for (int i = 1; i <= a; i++)
		for (int j = 1; j <= b; j++) scanf("%d", d[i] + j);
	for (int i = 0; i <= 100; i++)
		for (int j = 0; j <= 100; j++)
			for (int x = 1; x <= a; x++)
				for (int y = 1; y <= b; y++)
					f[i][j] = std::max(f[i][j], d[x][y] - i * x - j * y);
	for (int x = 1; x <= a; x++)
		for (int y = 1; y <= b; y++) {
			int tmp = 1e9;
			for (int i = 0; i <= 100; i++)
				for (int j = 0; j <= 100; j++)
					tmp = std::min(tmp, f[i][j] + i * x + j * y);
			if (tmp != d[x][y]) return puts("Impossible"), 0;
		}
	puts("Possible\n202 10401");
	for (int i = 0; i < 100; i++)
		printf("%d %d X\n%d %d Y\n", i + 1, i + 2, i + 103, i + 102);
	for (int i = 0; i <= 100; i++)
		for (int j = 0; j <= 100; j++) printf("%d %d %d\n", i + 1, j + 102, f[i][j]);
	puts("1 102");
}

Measured memory_bytes: 384
import java.util.*;
 
public class Main{
  public static void main(String[]args){
    Scanner sc =  new Scanner(System.in);
    int N = Integer.parseInt(sc.nextLine());
    String[] S = sc.nextLine().split(" ");
    int count = 0;
    int now = 0;
    for(int i = 0; i < N; i++){
      int n = Integer.parseInt(S[i]);
      if(n > now){
        count += n-now;
        now = n;
      }else if(n < now){
        now = n;
      }
    }
    System.out.println(count);
  }
}

Measured memory_bytes: 25044
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
int main(){
	std::vector<int> a(5);
	for(int i=0;i<5;i++)std::cin>>a[i];
	sort(a.begin(),a.end(),std::greater<int>());
	for(int i=0;i<4;i++)std::cout<<a[i]<<" ";
	std::cout<<a[4]<<std::endl;
	return 0;
}

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

public class Main{

	public static void main(String[] args) throws IOException {
		String s = read(), t = read(); println((s+s).contains(t) ? "Yes" : "No");
		exit();
	}

	final private static int BUFFER_SIZE = 1 << 16;
	private static DataInputStream din = new DataInputStream(System.in);
	private static byte[] buffer = new byte[BUFFER_SIZE];
	private static int bufferPointer = 0, bytesRead = 0;
	static PrintWriter pr = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

	public static String readLine() throws IOException {
		byte[] buf = new byte[64]; // line length
		int cnt = 0, c;
		while ((c = Read()) != -1) {
			if (c == '\n')
				break;
			buf[cnt++] = (byte) c;
		}
		return new String(buf, 0, cnt);
	}

	public static String read() throws IOException {
		byte[] ret = new byte[1024];
		int idx = 0;
		byte c = Read();
		while (c <= ' ') {
			c = Read();
		}
		do {
			ret[idx++] = c;
			c = Read();
		} while (c != -1 && c != ' ' && c != '\n' && c != '\r');
		return new String(ret, 0, idx);
	}

	public static int readInt() throws IOException {
		int ret = 0;
		byte c = Read();
		while (c <= ' ')
			c = Read();
		boolean neg = (c == '-');
		if (neg)
			c = Read();
		do {
			ret = ret * 10 + c - '0';
		} while ((c = Read()) >= '0' && c <= '9');

		if (neg)
			return -ret;
		return ret;
	}

	public static long readLong() throws IOException {
		long ret = 0;
		byte c = Read();
		while (c <= ' ')
			c = Read();
		boolean neg = (c == '-');
		if (neg)
			c = Read();
		do {
			ret = ret * 10 + c - '0';
		} while ((c = Read()) >= '0' && c <= '9');
		if (neg)
			return -ret;
		return ret;
	}

	public static double readDouble() throws IOException {
		double ret = 0, div = 1;
		byte c = Read();
		while (c <= ' ')
			c = Read();
		boolean neg = (c == '-');
		if (neg)
			c = Read();

		do {
			ret = ret * 10 + c - '0';
		} while ((c = Read()) >= '0' && c <= '9');

		if (c == '.') {
			while ((c = Read()) >= '0' && c <= '9') {
				ret += (c - '0') / (div *= 10);
			}
		}

		if (neg)
			return -ret;
		return ret;
	}

	private static void fillBuffer() throws IOException {
		bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
		if (bytesRead == -1)
			buffer[0] = -1;
	}

	private static byte Read() throws IOException {
		if (bufferPointer == bytesRead)
			fillBuffer();
		return buffer[bufferPointer++];
	}

	static void print(Object o) {
		pr.print(o);
	}

	static void println(Object o) {
		pr.println(o);
	}

	static void flush() {
		pr.flush();
	}

	static void println() {
		pr.println();
	}

	static void exit() throws IOException {
		din.close();
		pr.close();
		System.exit(0);
	}
}


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

struct kukan{
	int p;
	int kyori;
};
bool hikaku(const kukan &right,const kukan &left){
	return right.p == left.p ? right.kyori > left.kyori : right.p > left.p;
}

int main(){
	int n,m,d,s,res;
	kukan a;
	vector<kukan> v;
	while(1){
		cin >> n >> m;
		if(n == 0 && m == 0)break;
		v.clear();
		res = 0;
		for(int i = 0;i < n;i++){
			cin >> d >> s;
			if(s == 0)continue;
			a.p = s;
			a.kyori = d;
			v.push_back(a);
			res += d * s;
		}
		if(m == 0){
			cout << res <<endl;
			continue;
		}
		if(v.size() == 0){
			cout << 0 <<endl;
			continue;
		}
		sort(v.begin(),v.end(),hikaku);
		for(int i = 0;i < v.size();i++){
			if(m >= v[i].kyori){
				m -= v[i].kyori;
				res -= v[i].kyori * v[i].p;
				if(m == 0)break;
			}
			else if(m < v[i].kyori){
				res -= v[i].p * m;
				break;
			}
		}
		cout << res <<endl;	
	}
	return 0;
}

Measured memory_bytes: 1344
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>

#define ll long long
#define ull unsigned long long

using namespace std;

int main() {
	string S, T, U;
	int A, B;
	cin >> S >> T >> A >> B >> U;

	int scnt = A;
	int tcnt = B;

	if (S == U){
		scnt--;
	} else{
		tcnt--;
	}

	cout << scnt << " " << tcnt << endl;

	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
typedef long long lint;

int main() {

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

	int N;
	cin >> N;

	vector<int> W(N);
	for (int i = 0; i < N; i++) cin >> W[i];
	for (int i = 1; i < N; i++) W[i] += W[i - 1];

	int ans = INF;
	for (int i = 0; i < N; i++) ans = min(abs(2 * W[i] - W[N - 1]), ans);
	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 256