akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(),x.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
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;}
const long long MOD = 1000000007;
typedef long long ll;

ll n,k;
string s,t;
int a[100005];

int main() {
  rep(i,3) cin >> a[i];
  set<int> st;
  rep(i,3) st.insert(a[i]);
  cout << (st.size()==2 ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
# †全方位木DP†

import sys
input = lambda : sys.stdin.readline().strip()

n,m = map(int, input().split())
mod = m
G = [[] for i in range(n)]
for i in range(n-1):
    a,b = map(int, input().split())
    a,b = a-1,b-1
    G[a].append(b)
    G[b].append(a)

from collections import deque
def dfs(root):
    que = deque()
    que.append((root, -1))
    order = []
    while que:
        cur,prev = que.popleft()
        order.append(cur)
        for to in G[cur]:
            if to != prev:
                que.append((to, cur))
    return order

order = dfs(0)

child = set()
down = [1]*n
for cur in reversed(order):
    tmp = 1
    for to in G[cur]:
        if to in child:
            tmp *= (down[to]+1)
            tmp %= mod
    down[cur] = tmp
    child.add(cur)

ans = [0]*n
que = deque()
que.append((0, -1, 1))
while que:
    cur, prev, parent = que.popleft()

    left = [1]
    for to in G[cur]:
        tmp = down[to]
        if to == prev:
            tmp = parent
        left.append(left[-1]*(tmp+1)%mod)

    right = [1]
    for to in reversed(G[cur]):
        tmp = down[to]
        if to == prev:
            tmp = parent
        right.append(right[-1]*(tmp+1)%mod)
    ans[cur] = left[-1]

    m = len(G[cur])
    for i, to in enumerate(G[cur]):
        if to != prev:
            que.append((to, cur, left[i]*right[m-i-1]))

print(*ans, sep="\n")

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

typedef long long ll;

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

    ll mod = pow(10, 9) + 7LL;

    int N;
    cin >> N;

    vector<vector<ll> > dp(N, vector<ll>(4));

    for(int i = 0; i < 4; i++) {
        dp[0][i] = 1;
        dp[1][i] = 4;
        dp[2][i] = 16;
    }

    dp[2][1] -= 2;
    dp[2][2] -= 1;

    for(int i = 3; i < N; i++) {
        for(int j = 0; j < 4; j++) {
            for(int k = 0; k < 4; k++) {
                dp[i][j] += dp[i - 1][k];
                dp[i][j] %= mod;
            }
        }

        dp[i][1] -= (dp[i - 3][0] * 3) % mod;
        if(dp[i][1] < 0) dp[i][1] += mod;
        dp[i][1] -= (dp[i - 3][0] * 2) % mod;
        if(dp[i][1] < 0) dp[i][1] += mod;
        dp[i][1] -= (dp[i - 2][2] - dp[i - 3][0]) % mod;
        if(dp[i][1] < 0) dp[i][1] += mod;
        dp[i][1] -= (dp[i - 2][0] - dp[i - 3][0]) % mod;
        if(dp[i][1] < 0) dp[i][1] += mod;

        dp[i][2] -= (dp[i - 2][0] - dp[i - 3][2]) % mod;
        if(dp[i][2] < 0) dp[i][2] += mod;
    }

    ll count = 0;

    for(int i = 0; i < 4; i++) {
        count += dp[N - 1][i];
        count %= mod;
    }

    cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define fi first
#define se second
#define debug(...) cerr<<__LINE__<<" ["<<#__VA_ARGS__<<"]:",debug_out(__VA_ARGS__)
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec)
{ for (auto v : vec) os << v << ' '; os << '\n'; return os; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa)
{ os << '(' << pa.first << ',' << pa.second << ')'; return os; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T)
{ cerr << " " << H; debug_out(T...); }
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; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

void solve() {
    int a, b;
    cin >> a >> b;
    cout << max(0, a - 2 * b) << endl;
}

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


Measured memory_bytes: 3660
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"

using namespace std;
using namespace __gnu_pbds;


#define ll long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(),a.end()

typedef tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

int main(void)
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a, b, c;
    cin>>a>>b>>c;
    cout<<c<<" "<<a<<" "<<b<<"\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	int m = 0;
	int sum = 0;
	cin >> n;
	vector<int> vec(n);
	for (int i = 0; i < n; i++) {
		cin >> vec.at(i);
		if (m < vec.at(i)) m = vec.at(i);
		sum += vec.at(i);
	}
	if (m * 2 >= sum) cout << "No" << endl;
	else cout << "Yes" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String args[]){
	Scanner in = new Scanner(System.in);
	String str = in.nextLine();
	String str2 = in.nextLine();
	
	String str3 = str+str;
	boolean flag = false;
	for(int i=0;i<str.length();i++){
	    if(str2.compareTo(str3.substring(i,i+str2.length()))==0){
		flag =true;
		break;
	    }
	}
	if(flag)System.out.println("Yes");
	else System.out.println("No");
    }
}
       
	
	


Measured memory_bytes: 26300
local s = io.read()
local k = io.read("*n")
local n = #s
local t = {}
local sch = string.char
for i = 1, n - 1 do
  local ti = s:sub(i, i):byte() - 97
  if 0 < ti then
    local cost = 26 - ti
    if cost <= k then
      k = k - cost
      ti = 0
    end
  end
  t[i] = sch(ti + 97)
end
local last = (s:sub(n, n):byte() - 97 + k) % 26
t[n] = sch(last + 97)
print(table.concat(t))


Measured memory_bytes: 1884
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <chrono>

    #pragma GCC optimize("O3")
    #pragma GCC optimize("Ofast")
    #pragma GCC optimize("unroll-loops")
    /*#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
    #pragma GCC target ("avx2")*/

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;

ll MAX = 1e15;
double PI = 3.141592653589793238463;
//double PI = acos(-1);
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

ll md = 998244353;

void solve(){
    ll n,s;
    cin >> n >> s;
    vector<ll> nums(n);
    for(ll i=0; i<n; i++){
        cin >> nums[i];
    }
    vector<vector<ll>> dp(n+1, vector<ll>(s+1));
    dp[0][0]=1;
    for(ll i=1; i<=n; i++){
        for(ll j=0; j<=s; j++){
            dp[i][j]+=dp[i-1][j];
            dp[i][j]%=md;
            dp[i][j]*=2;
            dp[i][j]%=md;
            ll prev = j-nums[i-1];
            if(prev>=0){
                dp[i][j]+=dp[i-1][prev];
                dp[i][j]%=md;
            }
        }
    }


    cout << dp[n][s];

}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif


    ll t=1;
    //cin >> t;
    while(t--){
        solve();
    }


    return 0;
}


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

int main() {
  int N;
  cin >> N;
  
  int total = 0;
  for (double i = 0; i < 8; i++) {
    int diff = (N % (int)pow(10., i + 1)) - (N % (int)pow(10., i));
    total += diff / (int)pow(10., i);
  }
  
  if ((N % (int)total) == 0) {
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
Option Strict On
Module ProblemA

    Sub Main()
        Dim prm() As Integer = Array.ConvertAll(Of String, Integer)(Console.ReadLine.Split(" "c), AddressOf Integer.Parse)
        Console.WriteLine(If(prm(0) + prm(1) + prm(2) <= 21, "win", "bust"))
    End Sub

End Module


Measured memory_bytes: 11092
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;

int main() {
	int a, b, x;
	cin >> a >> b >> x;
	if (a <= x && x <= (a + b)) cout << "YES" << endl;
	else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	scanf("%d",&n);
	if(n==1)
	{
		printf("Hello World");
		return 0;
	}
	else
	{
		int a,b;
		scanf("%d%d",&a,&b);
		printf("%d",a+b);
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int N,S;

int main() {
	while (cin >> N && N>0) { // By while (), adopt the form of std in 
		int sum = 0;
		int max = 0;
		int min = 0;
		for (int i=0; i<N; i++) {
			cin >> S;
			if (i==0) min = S; // initialize min
			sum += S; // calculate sum
			if (max < S) max = S; // search max
			if (min > S) min = S; // search min
		}
		int ans;
		ans = (sum-max-min)/(N-2);
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 3028
import sys
h,w=map(int,input().split())
a=[list(input()) for i in range(h)]
l=[chr(i) for i in range(97, 97+26)]
ctl=[0]*26
for i in range(h):
  for j in range(w):
    ctl[l.index(a[i][j])]+=1

if h%2==0 and w%2==0:
  ct1=0;ct2=0;ct4=h*w
elif h%2==1 and w%2==1:
  ct1=1;ct2=h+w-2;ct4=h*w-ct1-ct2
elif h%2==0 and w%2==1:
  ct1=0;ct2=h;ct4=h*w-ct2
else:
  ct1=0;ct2=w;ct4=h*w-ct2
ct2=ct2//2;ct4=ct4//4

for i in range(26):
  while ctl[i]>=4 and ct4!=0:
    ctl[i]-=4
    ct4-=1
  if ct4==0:
    break
if ct4!=0:
  print('No')
  sys.exit()

for i in range(26):
  while ctl[i]>=2 and ct2!=0:
    ctl[i]-=2
    ct2-=1
  if ct2==0:
    break
if ct2!=0:
  print('No')
  sys.exit()

for i in range(26):
  while ctl[i]>=1 and ct1!=0:
    ctl[i]-=1
    ct1-=1
  if ct1==0:
    break
if ct1!=0:
  print('No')
  sys.exit()

print('Yes')

Measured memory_bytes: 3188
/*
    -ensure correct output format
    -ensure printing required output
    -reread the problem statement
  */

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define F first
#define S second
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>
#define pb push_back
#define eb emplace_back
#define ischar(x)  (('a' <= x && x <= 'z') || ('A' <= x && x <= 'Z'))
#define isvowel(ch) ((ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')||(ch=='A'|| ch=='E' || ch=='I'|| ch=='O'|| ch=='U'))
#define bug cout<<"BUG"<<endl;
const int Max = 2e6 + 10;
const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;
bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
       return (a.first > b.first);
}
ll lcm(ll a,ll b)
{
    if(a==0 || b==0)return 0;

    return a/__gcd(a,b)*b;
}

void input(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)cin>>ara[i];
}
void print(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)
        cout<<ara[i]<<" ";
    cout<<endl;
}

long long bigmod(long long b,long long p,ll mod)
{

   if(p==0)return 1;

   ll x=bigmod(b,p/2,mod);

    x=(x*x)%mod;

   if(p&1)x=(x*b)%mod;

   return x;
}

ll n;

string str;

ll call(ll i)
{
    if(i==n)
    {
        if(str[i]=='1')return 3;

        else return 1;
    }

    if(str[i]=='0')
        return call(i+1)%Mod;

    return (bigmod(3,n-i,Mod)+(2*call(i+1))%Mod)%Mod;


}
int main()
{

   fastread();


      bool flag=false;


      cin>>str;

      n=str.size()-1;

      cout<<call(0)<<endl;













}



Measured memory_bytes: 5332
#include<bits/stdc++.h>
#define int long long
using namespace std;
vector < vector<int>>edges;
void dfs(int v, vector<int>& add, vector<int>& ans, int prev) {
	add[v] += add[prev];
	for (auto u : edges[v]) {
		if (u != prev)dfs(u, add, ans, v);
	}
}
signed main(void)
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n, q;
	cin >> n >> q;
	edges = vector < vector<int>>(n + 1);
	for (int i = 0; i < n - 1; i++) {
		int x, y;
		cin >> x >> y;
		edges[x].push_back(y);
		edges[y].push_back(x);
	}
	vector<int>add(n + 1);
	vector<int>ans(n + 1);
	for (int i = 0; i < q; i++) {
		int p, x;
		cin >> p >> x;
		add[p] += x;
	}
	dfs(1, add, ans, 0);
	for (int i = 1; i <= n; i++)cout << add[i] << " ";
	return 0;
}


Measured memory_bytes: 28928
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	int N, K, possible, lack;

	cin >> N >> K;

	possible = (N - 1) * (N - 2) / 2;
	if (possible < K) {
		cout << -1 << endl;
		return 0;
	}

	lack = possible - K;
	cout << N - 1 + lack << endl;

	repc(i, 2, N) cout << 1 << ' ' << i << endl;

	repc(i, 2, N - 1) {
		if (lack <= 0) break;

		repc(j, i + 1, N) {
			cout << i << ' ' << j << endl;
			lack--;
			if (lack <= 0) break;
		}
	}

	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.IO;

namespace SolutionCS
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int N = int.Parse(s[0]);
            int M = int.Parse(s[1]);

            List<int>[] lists = new List<int>[N];
            for (int i = 0; i < N; i++)
            {
                lists[i] = new List<int>();
            }

            for (int i = 0; i < M; i++)
            {
                s = Console.ReadLine().Split(' ');
                int i0 = int.Parse(s[0]) - 1;
                int i1 = int.Parse(s[1]) - 1;

                lists[i0].Add(i1);
                lists[i1].Add(i0);
            }

            foreach(int i in lists[0])
            {
                foreach(int j in lists[i])
                {
                    if (j == N-1)
                    {
                        Console.WriteLine("POSSIBLE");
                        return;
                    }
                }
            }

            Console.WriteLine("IMPOSSIBLE");
        }
    }
}


Measured memory_bytes: 37572
#include<bits/stdc++.h>
#define lint long long int 
using namespace std;

int main()
{
        lint n;
        cin>>n;
        lint arr[2][n];
        lint i,j;
        for(i=0;i<2;i++)
        {
                for(j=0;j<n;j++)
                {
                        cin>>arr[i][j];
                }
        }
        lint sum[2][n];
        sum[0][0]=arr[0][0];
        sum[1][0]=arr[1][0];
        for(i=1;i<n;i++)
        {
                sum[0][i]=sum[0][i-1]+arr[0][i];
                sum[1][i]=sum[1][i-1]+arr[1][i];
        }
        lint maxsum=sum[0][0]+sum[1][n-1];
        for(i=1;i<n;i++)
        {
                lint ss=sum[0][i]+sum[1][n-1]-sum[1][i-1];
                if(ss>maxsum)
                maxsum=ss;
        }
        cout<<maxsum<<endl;
        
        return 0;
}

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

int main() {
  int n;
  cin >> n;
  int a[n];
  map<int, int> mp;
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    mp[a[i]]++;
    sum += a[i];
  }
  int q;
  cin >> q;
  for (int i = 0; i < q; i++) {
    int b, c;
    cin >> b >> c;
    if (!mp.count(b)) cout << sum << endl;
    else {
      sum += mp.at(b) * (c - b);
      cout << sum << endl;
      mp[c] += mp[b];
      mp[b] = 0;
    }
  }
}

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

int N, M;
int k[11];
vector<int> v[11];
int p[11];

int main() {
    cin >> N >> M;
    for(int i = 0; i < M; ++i){
        cin >> k[i];
        for(int j = 0; j < k[i]; ++j){
            int tmp;
            cin >> tmp;
            tmp--;
            v[i].push_back(tmp);
        }
    }
    for(int i = 0; i < M; ++i){
        cin >> p[i];
    }

    int ans = 0;
    for(int i = 0; i < 1 << N; ++i) {
        int tmp = 1;
        for(int j = 0; j < M; ++j) {
            int cnt = 0;;
            for(int k: v[j]){
                cnt += ((((1 << k) & i) >> k) & 1);
            }
            tmp &= (cnt % 2) == p[j];
        }
        if(tmp) ans++;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#define ll long long
using namespace std;
template <class T>
inline void rd(T &x) {
	x=0; char c=getchar(); int f=1;
	while(!isdigit(c)) { if(c=='-') f=-1; c=getchar(); }
	while(isdigit(c)) x=x*10-'0'+c,c=getchar(); x*=f;
}
const int N=510;
int m;
int a[N][N];
int mp[N*2];
int main() {
	rd(m);
	if(m==1) {
		printf("1\n1\n");
		return 0;
	}
	int n=(m+3)/4*2;
	int tot=n*2;
	int tmp=(4-m%4)%4;
	for(int i=0;i<tot;++i) mp[i]=i;
	int p=2*(n-tmp);
	for(int i=1;i<=tmp;++i) mp[2*(n-i)+1]=mp[2*(n-i)]=p++;
//	for(int i=0;i<tot;++i) cout<<mp[i]<<' '; cout<<endl;
	for(int i=0;i<tot;i+=2) {
		int y=i/2;
		for(int j=0;j<n;++j,y=(y+1)%n)
			a[j][y]=mp[i+(j&1)];
	}
	printf("%d\n",n);
	for(int i=0;i<n;++i,puts(""))
		for(int j=0;j<n;++j)
			printf("%d ",a[i][j]+1);
	return 0;
}

Measured memory_bytes: 2176
def main():
    import sys

    def input(): return sys.stdin.readline().rstrip()

    n = int(input())
    a = list(map(int, input().split()))
    a.sort(reverse=True)
    mdl = a[0]//2
    if a[0]%2 == 0:
        dist = [abs(x-mdl) for x in a[1:]]
    else:
        dist = [abs(x-mdl) if x <= mdl else abs(x - mdl - 1) for x in a[1:]]
    idx = min(range(1,n), key=lambda i: dist[i-1])
    print(a[0], a[idx])
    
        
    
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 19784
a = list(map(int, input().split()))
ans = 0

if a[0]==0:
    ans = 1
if a[1]==0:
    ans = 2
if a[2]==0:
    ans = 3
if a[3]==0:
    ans = 4
if a[4]==0:
    ans = 5

print(ans)

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

using namespace std;

int main(){
  int a[1001];

  int c[1001];

  int b, mn;

  mn = 1000000;

  while(1){

    cin >> b;

    if(b == 0) break;
    
    mn = 1000000;
    
    for(int i=0;i<b;i++){
      cin >> a[i];
    }
    for(int j=0;j<b;j++){
      for(int i=0;i<b-1;i++){
	if(a[i] < a[i+1]) swap(a[i],a[i+1]);
      }
    }
    for(int i=0;i<b-1;i++){
      c[i] = a[i] - a[i+1];
    }

    for(int i=0;i<b-1;i++){
      if(c[i]<mn) mn = c[i];
    }

    cout << mn << endl;

  }


}


Measured memory_bytes: 3084
let n = Scanf.scanf " %d" (+) 0
let a_s = Array.init n @@ fun _ -> Scanf.scanf " %d" (+) 0
let s = Array.fold_left (fun (s, p) a -> s + abs (p - a), a) (abs a_s.(n - 1), 0) a_s |> fst
let f i = if i < 0 || i = n then 0 else a_s.(i)
let g i = s - abs (f (i - 1) - f i) - abs (f i - f (i + 1)) + abs (f (i - 1) - f (i + 1))
let _ = Array.iteri (fun i a -> Printf.printf "%d\n" @@ g i) a_s

Measured memory_bytes: 5760
//CakesandDonuts.cpp (B)
#include <iostream>
using namespace std;

int main(){
  int N;
  bool flag = false;
  cin >> N;
  for(int i = 0; i <= N/7; i++){
    for(int j = 0; j <= N/4; j++){
      if(7*i+4*j==N) flag = true;
    }
  }
  if(flag) printf("Yes\n");
  else printf("No\n");
}


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

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  for (int i = 0; i < s.size(); i++) {
    s[i] = (s[i] - 'A' + n)%26 + 'A';
  }
  cout << s << endl;
  return 0;
}

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

using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    deque<int> A;
    int q;
    cin >> q;
    for(int i = 0; i < q; i++){
        int x;
        cin >> x;
        int y, z;
        if(x == 0){
            cin >> y >> z;
            if(y == 0){
                A.push_front(z);
            }else{
                A.push_back(z);
            }
        }else if(x == 1){
            cin >> y;
            cout << A[y] << "\n";
        }else{
            cin >> y;
            if(y == 0){
                A.pop_front();
            }else{
                A.pop_back();
            }
        }
    }


    return 0;
}


Measured memory_bytes: 4588
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
//解説閲覧済
int main()
{   ll n;
    cin>>n;
    ll ans = 9223372036854775807;
    for (ll i = 1; i < sqrt(n)+1; ++i)
    { if(n%i==0){ans=min(ans,(n/i)+i-2);}
    }
    cout<<ans<<endl;
    return 0;
}

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

int main(){
    string S,T;
    cin >> S >> T;
    int ans = 0;
    for(int i = 0 ; i < 3; i++){
        if(S[i] == T[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
long long gcd(long x,long y){
    if(y==0)return x;

    return gcd(y,x%y);
}
long long lcm(long x,long y){
    return x*y/gcd(x,y);
}

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

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

    if(S.length()==2){
        cout<<S<<endl;
    }else{
        swap(S[0],S[2]);
        cout<<S<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.stream.IntStream;
import java.io.UncheckedIOException;
import java.util.stream.Stream;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        LightScanner in = new LightScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B3CardGameForThreeABCEdit solver = new B3CardGameForThreeABCEdit();
        solver.solve(1, in, out);
        out.close();
    }

    static class B3CardGameForThreeABCEdit {
        public void solve(int testNumber, LightScanner in, PrintWriter out) {
            String[] s = in.string(3);
            int turn = 0;
            while (!s[turn].isEmpty()) {
                int c = s[turn].charAt(0) - 'a';
                s[turn] = s[turn].substring(1);
                turn = c;
            }
            out.println((char) (turn + 'A'));
        }

    }

    static class LightScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;

        public LightScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        public String string() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new UncheckedIOException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public String[] string(int length) {
            return IntStream.range(0, length).mapToObj(x -> string()).toArray(String[]::new);
        }

    }
}



Measured memory_bytes: 27988
#!/mnt/c/Users/moiki/bash/env/bin/python

import sys
sys.setrecursionlimit(10**9)

N,K = map(int, input().split())
A = list(map(int, input().split()))
A = list(filter(lambda x: x<=K, A))
m = min(A)

# $B%a%b2=:F5"(B
dp = [ -1 for _ in range(K+1)]

for i in range(m):
    dp[i] = 0
for a in A:
    dp[a] = 1

def rec(i):
    global dp
    if dp[i] == -1:
        for a in A:
            if i-a >= 0 and dp[i-a] == -1:
                rec(i-a)
            
        dp[i] = 1 if any(dp[i-x] == 0 for x in A if i-x >= 0) else 0 # ( 0 if all(dp[i-x] == 1 for x in A) else 1)
        return dp[i]
    else:
        return dp[i]

print("First" if rec(K) else "Second")
# print(dp)


Measured memory_bytes: 166048
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
ans = sum(b)
for i in range(n-1):
  if a[i]+1==a[i+1]: ans += c[a[i]-1]
print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define lp(i,n) for(int i=0;i<(n);i++)
#define lps(i,j,n) for(int i=j;i<n;i++)

#define fordebug int hoge;cin>>hoge;

#define DEKAI 1000000007
#define floot10 cout<<fixed<<setprecision(15)
#define all(v) v.begin(),v.end()
double PI = acos(-1);

signed main(){
  int n;
  cin>>n;

  //各桁の和を計算する
  int sum=0;
  int x=n;
  while(1){
    sum+=x%10;//一番下の桁の数字
    x/=10;//一番下の桁を消す
    if(x==0) break;//前部の桁が消えたら おわり
  }
  //S（N）がsumに入った
  //割り切れる？
  if(n%sum==0){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
  return 0;
}


Measured memory_bytes: 3564
R, G, B, N = map(int, input().split())

C = sorted([R, G, B], reverse=True)

print(sum((1 for c1 in range(0, N+1, C[0]) for c12 in range(c1, N+1, C[1]) if (N - c12) % C[2] == 0 )))


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL MOD = 1000000007;
#define lcm(x, y) ((x) * (y) / __gcd((x), (y)))
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define debug(x) cout << #x << " : " << x << endl
#define part cout << "----------------------------------\n";
#include <iostream>

#define fastinput                     \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);

int main()
{
    fastinput;
    LL n,i,j,k,t,temp,tc;
    char ch,ans;
    cin>>ch;
    if(ch>='a' && ch<='z')
    {
        ans='a';
    }
    else
    {
                ans='A';

    }
    cout<<ans<<endl;
    

    return 0;
}



Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>
#include<deque>
#include<random>
#include<set>

using namespace std;
typedef long long ll;
typedef double lldo;
#define mp make_pair
#define pub push_back
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
ll gcd(ll a, ll b) { if (a % b == 0) { return b; } else  return gcd(b, a % b); }
ll lcm(ll a, ll b) { if (a == 0) { return b; }return a / gcd(a, b) * b; }
template<class T>ll LBI(vector<T>& ar, T in) { return lower_bound(ar.begin(), ar.end(), in) - ar.begin(); }
template<class T>ll UBI(vector<T>& ar, T in) { return upper_bound(ar.begin(), ar.end(), in) - ar.begin(); }

ll N;

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

Measured memory_bytes: 256
n=int(input())
a=[int(i) for i in input().split()]
ans=0
m=100000000000
p=0
for i in a:
    if i<0:
        p+=1
    m=min(m,abs(i))
    ans+=abs(i)

if p%2==0:
    print(ans)
else:
    print(ans-m*2)

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

int main() {
  int n;
  cin >> n;
  string ans = "";

  do {
    int now = abs(n%2);
    ans += to_string(now);
    n -= now;
    n /= -2;
  } while ( n != 0 );

  reverse(ans.begin(), ans.end());
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
// Custom Header <<<
#define ALL(x) x.begin(), x.end()
#define iostreamBooster() do{ cin.tie(nullptr); ios_base::sync_with_stdio(false); }while(0)
#define rep(i, s, n)      for(int i(s); i < int(n); ++i)
using namespace std;
using i64 = long long;
using pii = pair<int, int>;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD  = int(1e9) + 7;
// >>>

signed main()
{
    int a, b, c;
    cin >> a >> b >> c;
    cout << min({a+b, b+c, a+c}) << endl;
    return 0;
}

/* vim:set foldmethod=marker foldmarker=<<<,>>> : */


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

#define ll long long
#define mx 100005

int main()
{
    map<string,ll>m;

    ll t,re=0;
    cin>>t;

    while(t--)
    {
        string s;
        cin>>s;
        sort(s.begin(),s.end());

        m[s]++;
    }

    for(auto it: m)
    {
        re+=(it.second*(it.second-1))/2;
    }

    cout<<re<<endl;
    return 0;
}



Measured memory_bytes: 11136
#include <bits/stdc++.h>
#define REP(i, n) for(long long i=0; i<n; i++)
#define REPR(i, n) for(long long i=n-1; i>=0; i--)
#define FOR(i, m, n) for(long long i=m; i<=n; i++)
#define FORR(i, m, n) for(long long i=m; i>=n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;
using ll = long long;
using ull = unsigned long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;
const ll inf = 1e15;
ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}


int main(){FIN
    ll n,k;cin>>n>>k;
    vll a(n);REP(i,n) cin>>a[i];
    REP(i,n-k){
        if (a[i] < a[i+k]) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    return 0;
}


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

int main() {
	ll A,B,N,t,r;
	cin >> A >> B >> N;

	t = N/B;
	if(t*B+(B-1) <= N)
		r = t*B+(B-1);
	else
		r = max(t*B-1, 1ll);
	
	cout << max(A*r/B-A*(r/B), max(A*(N-1)/B-A*((N-1)/B), A*N/B-A*(N/B))) << endl;
}

Measured memory_bytes: 3592
#include<iostream>
#include<vector>
#include<string>
using namespace std;
vector <int> a;
void insert(int k) {
	int n = a.size();
	a.push_back(k);
		while (n!=0 && a[(n - 1) / 2] < a[n]) {
			swap(a[n], a[(n - 1) / 2]);
			n = (n - 1) / 2;
		}
}
void maxheapify(int i) {
	int l = 2 * i + 1;
	int r = 2 * i + 2;
	int largest = i;
	if (l<(int)a.size() && a[l]>a[i]) {
		largest = l;
	}
	if (r<(int)a.size() && a[r]>a[largest]) {
		largest = r;
	}
	if (largest != i) {
		swap(a[i], a[largest]);
		maxheapify(largest);
	}
}
int extractmax() {
	int c;
	c = a[0];
	a[0] = a.back();
	a.pop_back();
	maxheapify(0);
	cout << c << endl;
	return 0;
}

int main() {
	string x;
	int y;
	while (1) {
		cin >> x;
		if (x == "end") {
			return 0;
		}
		else if (x == "insert") {
			cin >> y;
			insert(y);
		}
		else if (x=="extract"){
			extractmax();
		}
	}
}

Measured memory_bytes: 7048
s1=input()
s2=input()
n1=len(s1)
n2=len(s2)
dp=[[0 for i in range(n2+1)] for j in range(n1+1)] 
for i in range(1,n1+1):
    for j in range(1,n2+1):
        if s1[i-1]==s2[j-1]:
            dp[i][j]=1+dp[i-1][j-1]
        else:
            dp[i][j]=max(dp[i-1][j],dp[i][j-1]) 
s=""
i,j=n1,n2
while dp[i][j]:
    if dp[i][j]==dp[i][j-1]:
        j-=1 
    elif dp[i][j]==dp[i-1][j]:
        i-=1 
    else:
        s=s1[i-1]+s
        i-=1 
        j-=1 
print(s)

Measured memory_bytes: 152752
// {{{ Boilerplate Code <--------------------------------------------------
// vim:filetype=cpp:foldmethod=marker:foldmarker={{{,}}}

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>

#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define ALL(A)     (A).begin(), (A).end()

using namespace std;

// }}}

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

        bool flag=true;

        int prevt=0;
        int prevx=0;
        int prevy=0;

        FOR(i,0,N){
                int nextt, nextx,nexty;
                cin>>nextt>>nextx>>nexty;

                int distance = abs(nextx-prevx) + abs(nexty-prevy);

                if (distance>nextt-prevt){
                        flag=false;
                }

                if(distance%2 != (nextt-prevt)%2) {
                        flag=false;
                }
        }

        cout << (flag?"Yes":"No") << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
int dp[2][10000];
pair<pair<int,int>,pair<int,int> >event[20000];
int main(){
	int a,b;
	while(scanf("%d%d",&a,&b),a){
	int xm=0;
	int ym=0;
	for(int i=0;i<a;i++){
		int p,q,r,s;
		scanf("%d%d%d%d",&p,&q,&r,&s);
		event[i*2]=make_pair(make_pair(p,1),make_pair(q,s));
		event[i*2+1]=make_pair(make_pair(r,-1),make_pair(q,s));
		xm=max(xm,r);
		ym=max(ym,s);
	}
	std::sort(event,event+a*2);
	
	for(int i=0;i<2;i++)
		for(int j=0;j<ym;j++)
			dp[i][j]=0;
	int S=0;
	int D=0;
	int at=0;
	for(int i=0;i<=xm;i++){
		int u=i&1;
		for(int j=0;j<ym;j++)dp[u][j]=dp[!u][j];
		for(;at<2*a&&event[at].first.first==i;at++){
			for(int j=event[at].second.first;j<event[at].second.second;j++)dp[u][j]+=event[at].first.second;
		}
		for(int j=0;j<ym;j++)if(dp[u][j])S++;
		for(int j=0;j<ym;j++)if((dp[u][j]||dp[!u][j])&&!(dp[u][j]&&dp[!u][j]))D++;
		for(int j=0;j<ym-1;j++)if((dp[u][j]||dp[u][j+1])&&!(dp[u][j]&&dp[u][j+1]))D++;
		if(dp[u][0])D++;
		if(dp[u][ym-1])D++;
	}
	printf("%d\n",S);
	if(b==2)printf("%d\n",D);
}}

Measured memory_bytes: 1420
#!/usr/bin/env python
# coding: utf-8


def main():
    n = int(input())
    s = input()
    lw = 0
    for i in range(len(s)):
        if s[i] == '#':
            break
        lw += 1
    rb = len(s)
    for i in range(len(s)):
        if s[len(s)-i-1] == '.':
            break
        rb -= 1
    w = sum(1 for c in s[lw:rb] if c == '.')
    b = len(s[lw:rb]) - w
    best = min(w, b)
    flag = True
    db = 0
    dw = 0
    s = s[lw:rb]
    # print(dw, db, s)
    for i, c in enumerate(s):
        if flag and c == '#':
            db += 1
            continue
        flag = False
        if c == '.':
            dw += 1
            continue
        # print(dw, db, s[i:])
        best = min(best, w-dw+db)
        db += 1
        flag = True
    best = min(best, w-dw+db)
    print(best)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define LL long long
#define RG register
#define R RG int
using namespace std;
const int N=1e5+9;
char s[N];
int e[N];
int main(){
	R n,i,x=1;
	cin>>(s+1);n=strlen(s+1);
	if(s[n]&1||!(s[1]&1))return puts("-1"),0;
	for(i=1;i<n;++i)
		if(s[i]!=s[n-i])return puts("-1"),0;
	for(i=2;i<=n;++i){
		e[i]=x;if(s[i-1]&1)x=i;
	}
	for(i=2;i<=n;++i)cout<<e[i]<<' '<<i<<endl;
	return 0;
}


Measured memory_bytes: 1920
from collections import deque


s = list(input())
q = int(input())
query = [list(input().split()) for i in range(q)]

deq = deque(s)

flag = 1
for i in range(q):
    if query[i][0] == "1":
        flag ^= 1
    else:
        _, f, c = query[i]
        f = int(f) % 2
        if flag ^ f:
            deq.append(c)
        else:
            deq.appendleft(c)

ans = "".join(deq)
if flag:
    print(ans)
else:
    print(ans[::-1])


Measured memory_bytes: 119800
#include<iostream>
#include<map>
#include<string>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;

int main() {
    int n; cin >> n;
    map<string, int> mp;
    rep(i, n) {
        string s; cin >> s;
        mp[s]++;
    }
    int mx = 0;
    for (auto p : mp) mx = max(mx, p.second);
    for (auto p : mp) {
        if (p.second != mx) continue;
        cout << p.first << endl;
    }
    return 0;
}

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

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

  if(N >= M / 2) {
    cout << M / 2 << endl;
    return 0;
  }else {
    cout << N + (M - 2 * N) / 4 << endl;
    return 0;
  }


}


Measured memory_bytes: 256
use proconio::{fastout, input, marker::Usize1};
use std::cmp::min;
use std::collections::BinaryHeap;

const INF: usize = 1001001001001001001;

#[fastout]
fn main() {
   input! {
      n: usize,
      m: usize,
      mut s: usize,
      uvab: [(Usize1, Usize1, usize, usize); m],
      cd: [(usize, usize); n]
   }
   let max_s = 2 * n * 50;
   let mut edges = vec![Vec::new(); n];
   for (u, v, a, b) in uvab {
      edges[u].push((v, a, b));
      edges[v].push((u, a, b));
   }

   let mut dp = vec![vec![INF; max_s + 1]; n];
   let mut q = BinaryHeap::<Data>::new();
   s = min(max_s, s);
   q.push(Data::new(0, s, 0));
   dp[0][s] = 0;
   while let Some(data) = q.pop() {
      let v = data.v;
      let s = data.s;
      let x = data.x;
      if dp[v][s] < x {
         continue;
      }

      let (c, d) = cd[v];
      let ns = min(max_s, s + c);
      if dp[v][ns] > x + d {
         dp[v][ns] = x + d;
         q.push(Data::new(v, ns, x + d));
      }

      for (u, a, b) in edges[v].iter().copied() {
         if s >= a && dp[u][s - a] > x + b {
            dp[u][s - a] = x + b;
            q.push(Data::new(u, s - a, x + b));
         }
      }
   }

   for i in 1..n {
      let mut ans = INF;
      for j in 0..=max_s {
         ans = min(ans, dp[i][j]);
      }
      println!("{}", ans);
   }
}

use std::cmp::{Eq, Ord, Ordering, PartialEq, PartialOrd};
use std::fmt::Debug;
#[derive(Debug, Copy, Clone, Eq)]
struct Data {
   v: usize,
   s: usize,
   x: usize,
}
impl Data {
   fn new(v: usize, s: usize, x: usize) -> Self { Data { v: v, s: s, x: x } }
}
impl Ord for Data {
   fn cmp(&self, other: &Self) -> Ordering { other.x.cmp(&self.x) }
}
impl PartialEq for Data {
   fn eq(&self, other: &Data) -> bool { self.x == other.x }
}
impl PartialOrd for Data {
   fn partial_cmp(&self, other: &Data) -> Option<Ordering> { Some(other.x.cmp(&self.x)) }
}


Measured memory_bytes: 7432
import sys
H,W = map(int,input().split())

if H == 1 or W == 1:
    print (1)
    sys.exit()

if H % 2 == 0:
    t = H // 2
    u = H // 2
else:
    t = H // 2 + 1
    u = H // 2

if W % 2 == 0:
    print ((t+u) * (W//2))
else:
    print (t * (W//2+1) + u * (W//2))


Measured memory_bytes: 38256
#include <iostream>

using namespace std;

int main() {
    int a, b;
    cin >> a >> b;

    int ans = 0;
    for (int i=0; i<2; i++) {
        if (a > b) {
            ans += a;
            a--;
        }
        else {
            ans += b;
            b--;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)

	as := make([]Item, n)
	bs := make([]Item, n)
	var a, b int
	for i := 0; i < n; i++ {
		fmt.Scan(&a, &b)
		as[i] = Item{i, a, b}
		bs[i] = Item{i, a, b}
	}

	sort.Sort(SortByA(as))
	sort.Sort(SortByB(bs))

	used := map[int]bool{}
	suma, sumb := 0, 0
	ai, bi := 0, 0
	for i := 0; i < n; i++ {
		if i%2 == 0 {
			var item Item
			for ai < len(as) {
				item = as[ai]
				ai++
				if !used[item.i] {
					break
				}
			}
			used[item.i] = true
			suma += item.a
		} else {
			var item Item
			for bi < len(bs) {
				item = bs[bi]
				bi++
				if !used[item.i] {
					break
				}
			}
			used[item.i] = true
			sumb += item.b
		}
	}

	fmt.Println(suma - sumb)
}

// Item .
type Item struct {
	i, a, b int
}

// SortByA .
type SortByA []Item

func (s SortByA) Len() int      { return len(s) }
func (s SortByA) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
func (s SortByA) Less(i, j int) bool {
	v1 := s[i].a - s[j].b
	v2 := s[j].a - s[i].b
	if v1 == v2 {
		return s[i].a > s[j].a
	}
	return v1 > v2
}

// SortByB .
type SortByB []Item

func (s SortByB) Len() int      { return len(s) }
func (s SortByB) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
func (s SortByB) Less(i, j int) bool {
	v1 := s[i].b - s[j].a
	v2 := s[j].b - s[i].a
	if v1 == v2 {
		return s[i].b > s[j].b
	}
	return v1 > v2
}


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

#define lld long long int
#define llu unsigned long long

int main()
{
    //freopen("input.txt", "w", stdin);

    int x,a,b;

    while(cin>>x>>a>>b)
    {
        if(abs(x-a) > abs(x-b))
            cout<<"B"<<endl;
        else
            cout<<"A"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
main(){
int i,j,k,l,m;
while(cin>>m){
    int x[m];
    for(i=0;i<m;i++)cin>>x[i];
    sort(x,x+i); k=0;
     for(i=0;i<m;i++) {k+=x[i];
     k--;}
     if(k<0)k=0;
    cout<<k<<endl;
} return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>
#include <bitset>

using namespace std;
typedef long long ll;

int main() {
  int N;
  string S;
  int Q;
  cin >> N >> S >> Q;
  vector<set<int> > sets(26);
  for (int i = 0; i < N; ++i) {
    char ch = S[i];
    sets[ch - 'a'].insert(i);
  }
  
  for (int iter = 0; iter < Q; ++iter) {
    int cmd;
    cin >> cmd;
    if (cmd == 1) {
      int i;
      char ch;
      cin >> i >> ch;
      --i;
      char old_ch = S[i];
      sets[old_ch - 'a'].erase(i);
      S[i] = ch;
      sets[ch - 'a'].insert(i);
    } else {
      int l, r;
      cin >> l >> r;
      --l; --r;
      int ans = 0;
      for (char ch = 'a'; ch <= 'z'; ++ch) {
      	const set<int> &s = sets[ch - 'a'];
	// std::lower_bound is O(N)!!
      	// auto it = lower_bound(s.begin(), s.end(), l);
	// std::set::lower_bound is O(log N)
	auto it = s.lower_bound(l);
      	if (it != s.end() and *it <= r) ++ans;
      }
      cout << ans << endl;
    }      
  }
  return 0;
}


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

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_poizcy.hpp>
typedef long long  ll;
#define pb                push_back
#define mp                make_pair
#define all(a)            (a).begin(), (a).end()
#define mem(a,h)          memset(a, (h), sizeof(a))
#define fi first
#define se second
#define por(a,b) (((a%MOD) * (b%MOD))%MOD)
#define forg(i, b, e, c)    for (ll i = (ll)b; i < (ll)e; i+=c)
#define forr(i, b, e)    for (ll i = b; i < e; i++)
 
 
using namespace std;
//using namespace __gnu_pbds;
typedef double lldb;
typedef pair<int, int>  ii;
typedef pair<double, double>  iidb;
typedef pair<ii, int>  iii;
typedef vector<ll>     vi;
typedef vector<vi>     vvi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
//typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
const ll INF = 1e9+7;
const double PI = acos(-1);
#define initseg ll new_nodo=(pnodo*2),mid=(iz+der)/2;
 
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define tam 1010000
#define offset 200
#define ptr nodo*


using namespace std;
ll v[tam];
vector<int> g[tam];
int peso[tam];
int main()
{
	memset(peso,-1,sizeof peso);
    ios::sync_with_stdio(false);cin.tie(0);
   	int n;
   	cin>>n;
   	int iz,der;
   	forr(i,0,n-1)
   	{
   		cin>>iz>>der;
   		g[iz].pb(der);
   		g[der].pb(iz);
   	}
   	queue<int> cola;
   	peso[1]=1;
   	peso[n]=2;
   	cola.push(1);
   	cola.push(n);
   	while(!cola.empty())
   	{
   		int num=cola.front();
   		cola.pop();
   		for(int v:g[num])
   		{
   			if (peso[v]==-1)
   			{
   				peso[v]=peso[num];
   				cola.push(v);
   			}
   		}
   	}
   	int cblack=0;
   	forr(i,1,n+1)
   	{
   		//cout<<peso[i]<<' ';
   		if (peso[i]==peso[1])
   			cblack++;
   		else
   			cblack--;
   	}
   	//cout<<cblack<<endl;
   	if (cblack>0)
   		cout<<"Fennec\n";
   	else
   		cout<<"Snuke\n";
}

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

const int P = 924844033;
const int N = 2010;

long long jc[N], g[N << 1], f[N << 1][N][2], cnt;

int main() {

  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
    
  int n, k;
  std::cin >> n >> k;
   
  jc[0] = 1;
  for (int i = 1; i <= n; ++i) jc[i] = (jc[i - 1] * i) % P;
  for (int i = 1; i <= k; ++i) {
    for (int j = i; j <= n; j += k) g[++cnt] = (i == j);
    for (int j = i; j <= n; j += k) g[++cnt] = (i == j);
  } 
  f[0][0][0] = 1;
  for (int i = 1; i <= cnt; ++i) {
    for (int j = 0; j <= std::min(i, n); ++j) {
      f[i][j][0] = (f[i - 1][j][1] + f[i - 1][j][0]) % P;
      if (!g[i]) f[i][j][1] = f[i - 1][j - 1][0];
    }
  } 
  long long ans = 0;
  for (int i = 0; i <= n; ++i) {
    long long tmp = (f[cnt][i][0] + f[cnt][i][1]) % P;
    tmp = (tmp * jc[n - i]) % P;
    if (i & 1) ans = (ans - tmp + P) % P;
    else ans = (ans + tmp) % P;
  }
  std::cout << ans << '\n';
       
  return 0;
}


Measured memory_bytes: 105284
using System;
using System.Linq;
namespace Sample
{
  class Sample
  {
    static void Main(string[] args)
    {
    string[] str=Console.ReadLine().Split(' ');
      int A=int.Parse(str[0]);
      int B=int.Parse(str[1]);
      int[] arr=new int[3];
      arr[0]=A+B;
      arr[1]=A-B;
      arr[2]=A*B;
      Array.Sort(arr);
      Console.WriteLine(arr[2]);
    }
    
  }

}


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

int main(){
  int a = 0;
  string s;
  cin >> s;
  for(int i = 0; i < (s.size() + 1) / 2; i++){
    if(s[i] != s[s.size() - i - 1])
      a++;
  }
  cout << a << endl;
}

Measured memory_bytes: 256