akhauriyash/Code-Regression huggingface dataset:
import sys

class Node:
    def __init__(self, key=None, parent=None, left=None, right=None):
        self.key = key
        self.parent = parent
        self.left = left
        self.right = right

def insert(key):
    global root
    # The first node
    if root.key is None:
        root.key = key
        return
    # The second note and so forth
    else:
        newNode = Node(key)
        x = root
        while x is not None:
            tmpParent = x # parent 候補として保持
            if newNode.key < x.key:
                x = x.left
            else:
                x = x.right
        newNode.parent = tmpParent
        if newNode.key < tmpParent.key:
            tmpParent.left = newNode
        else:
            tmpParent.right = newNode

def find(key):
    """
    Find a node with the key
    :param key: Key to search
    :return: A node that has the key. Returns None if there is no match,
    """
    global root
    x = root
    while x is not None and x.key != key:
        if key < x.key:
            x = x.left
        else:
            x = x.right
    return x

def inorder(node, result):
    if node is None:
        return
    inorder(node.left, result)
    result.append(node.key)
    inorder(node.right, result)

def preorder(node, result):
    if node is None:
        return
    result.append(node.key)
    preorder(node.left, result)
    preorder(node.right, result)

def printOrderedResult(node, orderFunction):
    """
    :param node: node (root)
    :param orderFunction: inorder or preorder (function)
    :return: nothing
    """
    result = []
    orderFunction(node, result)
    result = [i for i in map(str, result)]
    print(' ', end='')
    print(' '.join(result))


# sys.stdin = open('input.txt')

root = Node()
n = int(input())

for i in range(n):
    command = input()
    try:
        command, key = command.split()
        key = int(key)
        if command == 'insert':
            insert(key)
        elif command == 'find':
            if find(key) is None:
                print('no')
            else:
                print('yes')
    except ValueError: # command == 'print'
        printOrderedResult(root, inorder)
        printOrderedResult(root, preorder)


Measured memory_bytes: 121696
#include <iostream>
#include <math.h>
//#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
//#include <queue>

using namespace std;
#define n_max 10000
#define INF 10001000

#define rep(i, a, n) for(int i = a; i < n; i++)
#define rep2(i, a, n) for(int i = a; i <= n; i++)
#define rrep(i, a, n) for(int i = a; i > n; i--)
#define rrep2(i, a, n) for(int i = a; i >= n; i--)
#define lrep(i, a, n) for(long int i = a; i < n; i++)
#define in(a) cin >> a
#define out(a) cout << a << endl

int main()
{
    string s;

    cin >> s;

    rep(i, 0, s.size()) { 
        if(i%2) {
            if(s[i] == 'R') { cout << "No" << endl; return 0;}
        } else {
            if(s[i] == 'L') { cout << "No" << endl; return 0;}
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int x, y;
    cin >> x >> y;
    int ans;
    if(x < y)   ans = min(y-x, abs(y+x)+1);
    else        ans = min(x-y+2, abs(y+x)+1);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	
	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		int max = Integer.MIN_VALUE;
		int min = Integer.MAX_VALUE;
		for(int i=0; i<3; i++) {
			int a = sc.nextInt();
			max = Math.max(max,a);
			min = Math.min(min, a);
		}
		
		System.out.println(max-min);
		

	}

}

Measured memory_bytes: 21844
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] vs = new int[n];
        int[] cs = new int[n];
        for (int i = 0; i < n; i++) {
            vs[i] = sc.nextInt();
        }
        for (int i = 0; i < n; i++) {
            cs[i] = sc.nextInt();
        }
        int ans = 0;
        for (int i = 0; i < n; i++) {
            int a = vs[i] - cs[i];
            if (a > 0) {
                ans += a;
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 23252
#include "bits/stdc++.h"
using namespace std;
pair<int,int> Array[200005];
long long Update[200005];
int Pos[200005];

int BinarySearch( int low , int high , int key ){
    if( low >= high ){
        if( Array[low].first > key ) return ( low - 1 );
        else return low;
    }
    else{
        int middle = ( low + high ) >> 1;
        if( Array[middle].first > key ) return BinarySearch( low , middle - 1 , key );
        else return BinarySearch( middle + 1 , high , key );
    }
}

void PreProcess( int N , int D ){
    for( int i = 1 ; i <= N ; ++i ){
        if( Array[N].first - Array[i].first < 2 * D ){
            Pos[i] = N + 1;
            continue;
        }

        Pos[i] = BinarySearch( 1 , N , Array[i].first + 2 * D ) + 1;
    }
}

long long FindAns( int N , int D , int A ){
    long long Ans = 0LL , Cur = 0LL , Temp;
    int i = 1;

    while( i <= N ){
        Cur -= Update[i];
        Temp = Array[i].second - Cur;

        if( Temp <= 0 ){
            ++i;
            continue;
        }

        Ans += Temp;
        Cur += Temp;
        Update[Pos[i]] += Temp;
        ++i;
    }

    return Ans;
}   

int main(){
    int N , D , A , i;
    scanf( "%d%d%d" , &N , &D , &A );

    for( i = 1 ; i <= N ; ++i ){
        scanf( "%d%d" , &Array[i].first , &Array[i].second );
        if( Array[i].second % A == 0 ) Array[i].second = ( Array[i].second / A );
        else Array[i].second = ( Array[i].second / A ) + 1; 
    }

    sort( Array + 1 , Array + N + 1 );
    PreProcess( N , D );

    printf( "%lld\n" , FindAns( N , D , A ) );
    return 0;   
}

Measured memory_bytes: 4096
A, B, C, D = map(int, input().split())
if B < C or D < A:
  ans = 0
elif A <= C <= B:
  if B <= D:
    ans = B - C
  else:
    ans = D-C
elif C <= A <= D:
  if B <= D:
    ans = B - A
  else:
    ans = D -A
print(ans)
  

Measured memory_bytes: 61736
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i < (ll)(n); i++)
const ll mo = 1000000007;
const ll INF = 1 << 30;
ll ans = 0;
ll d[10][10];
ll ko[10] = {};

int main()
{
    ll h, w;
    cin >> h >> w;
    rep(i, 10) rep(j, 10)
    {
        cin >> d[i][j];
    }
    rep(i, h) rep(j, w)
    {
        ll te;
        cin >> te;
        if (te >= 0)
            ko[te]++;
    }
    
    for (int k = 0; k < 10; k++)
        for (int i = 0; i < 10; i++)
            for (int j = 0; j < 10; j++)
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
        rep(i,10){
        ans+=d[i][1]*ko[i];
    }
    cout << ans << endl;
    return 0;
}

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


int main() {
	int n, m, x;
	cin >> n >> m >> x;
	vector<int>A(m);
	int up = 0;
	int down = 0;
	for (int i = 1;i <= m;++i) {
		cin >> A[i];
		if (A[i] < x)down++;
		else up++;
	}
	if (up <= down) {
		cout << up << endl;
	}
	else {
		cout << down << endl;
	}
	return 0;
}


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

int main() {
    double a,b,h,m; cin >> a >> b >> h >> m;
    double rb = m*6.0;
    double ra = h*30.0+m*0.5;
    double r = fabs(rb - ra);
    r = min(r,360.0-r);
    const double pi = 3.141592653589793;
    double ans = sqrt(a*a+b*b-2*a*b*cos(r*pi/180.0));
    cout << setprecision(20) << ans << endl;
}

Measured memory_bytes: 4256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		long ans = k;

		for (int i = 1; i < n; i++) {
			ans = ans * (k - 1);
		}
		System.out.println(ans);
	}

}


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

namespace A___Serval_vs_Monster
{
    class Program
    {
        static void Main(string[] args)
        {
            var value = Console.ReadLine();
            string[] split = value.Split(' ');
            var health = int.Parse(split[0]);
            var damage = int.Parse(split[1]);
            var count = 0;
            while (health>0)
            {
                health -= damage;
                count++;
            }
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define SIZE 100005

string words[4];
char S[SIZE];

int main(){


	int len[4];

	words[0] = "dream";
	words[1] = "dreamer";
	words[2] = "erase";
	words[3] = "eraser";

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

		len[i] = words[i].length();
	}


	scanf("%s",S);

	int length;
	for(length = 0; S[length] != '\0'; length++);

	int loc = length-1;

	while(loc >= 0){

		int tmp = -1;
		for(int i = 0; i < 4; i++){
			if(loc+1 < len[i])continue;

			bool FLG  = true;
			for(int k = 0; k < len[i]; k++){
				if(S[loc-k] != words[i][len[i]-1-k]){
					FLG = false;
					break;
				}
			}
			if(FLG){
				tmp = i;
				break;
			}
		}

		if(tmp == -1)break;

		loc -= len[tmp];
	}

	if(loc == -1){

		printf("YES\n");

	}else{

		printf("NO\n");
	}

	return 0;
}


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

/*方針*/
/*辺をそれぞれ壊す。(全パターン)
　その辺の両端の頂点のうち、いずれかの点から全ての頂点へ行ければ、そこは橋ではない*/

//➀辺をpairに入れる。
//➁➀の辺それぞれを壊すことを考える。
//➂壊した辺の両端の頂点のうち、いずれかの点からdfsを行う。
//➃➂でdfsをして、全頂点に行ければ橋ではない。行っていない頂点が一つでもあれば橋なので、ans++
int main(){
	int n,m,ans=0;cin>>n>>m;
	
	vector<vector<int>> G(n);//隣接行列
	
	vector<pair<int,int>> P;
/*➀*/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);
		P.push_back(make_pair(a,b));//辺を記憶
	}

	for(int i=0;i<P.size();i++){//各辺について
		vector<int> visit(n,0);//各頂点を訪れたかどうかの判定(visit:1  !visit:0  切り離し:-1)
		
		stack<int> st;
		st.push(P[i].first);
/*➁*/  visit[P[i].first]=visit[P[i].second]=-1;//辺を一つ切り離す(-1が切り離されたところ)
		
/*➂*/	while(st.size()!=0){
	
			int now=st.top();
			st.pop();
			visit[now]=1;//visit

			visit[now]=1;//visitしたならば1
			for(auto next:G[now]){
				if(now==P[i].first && next==P[i].second) continue;//切り離し
				if(visit[next]==1) continue;//すでにvisit

				st.push(next);
			}
		}

		bool bridge=false;//橋か否か
/*➃*/  for(int j=0;j<n;j++){
			if(visit[j]==0 || visit[j]==-1){bridge=true;}//訪れていないところがあれば橋
		}
		if(bridge){ans++;}
	}

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

Measured memory_bytes: 256
#include<cstdio>
#include<string.h>
using namespace std;
void operate(char a[])
{
	int len=strlen(a);
	char temp=a[len-1];
	int i;
	for(i=len-2;i>=0;i--)
	{
		a[i+1]=a[i];
	}
	a[0]=temp;
	return;
}
int main()
{
	char a[101],b[101];
	scanf("%s",a);scanf("%s",b);
	int i;
	int len=strlen(a);
	for(i=0;i<=len;i++)
	{
		if(!strcmp(a,b)) {printf("Yes"); return 0;}
		operate(a);
	}
	printf("No");
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    string ans = "No";
    for (int a = 1; a <= 9; a++) {
        for (int b = 1; b <= 9; b++) {
            if (a * b == n) ans = "Yes";
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>

typedef long long ll;

using namespace std;

long long GCD(long long a, long long b){if(b==0)return a;return GCD(b,a%b);}

int main() {

    int A, B, C, X, Y; cin >> A >> B >> C >> X >> Y;

    long long res = 0;

    for (int i = 0; i < min(X, Y); i++) {
        res += min (A+B, C*2);
    }

    if (X > Y) {
        res += (X - Y) * min(A, C*2);
    } else {
        res += (Y - X) * min(B, C*2);
    } 

    cout << res << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main()
{   int l;
    scanf("%d",&l);
    if(l%3==0){
        printf("%d",l*l*l/27);
    }else{
        float d=(float)l/3.0;
        printf("%f",d*d*d);
    }
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
	int n;
	cin>>n;
	int arr0[n],arr1[n],arr2[n];
	int dp[n][3];
	for(int i=0;i<n;i++)
	{
		cin>>arr0[i]>>arr1[i]>>arr2[i];
		dp[i][0]=dp[i][1]=dp[i][2]=0;
	}
	dp[0][0]=arr0[0];
	dp[0][1]=arr1[0];
	dp[0][2]=arr2[0];
	for(int i=1;i<n;i++)
	{
		dp[i][0]=max(dp[i-1][1]+arr0[i],dp[i-1][2]+arr0[i]);
		dp[i][1]=max(dp[i-1][0]+arr1[i],dp[i-1][2]+arr1[i]);
		dp[i][2]=max(dp[i-1][0]+arr2[i],dp[i-1][1]+arr2[i]);
		//cout<<dp[i][0]<<" "<<dp[i][1]<<" "<<dp[i][2]<<endl;
	}
	cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
}

Measured memory_bytes: 2560
[<AutoOpen>]
module Program

open System

let read f = stdin.ReadLine() |> f
let reada f = stdin.ReadLine().Split() |> Array.map f
let reads f = stdin.ReadLine().Split() |> Array.toList |> List.map f

[<EntryPoint>]
let main _ =
    let N = read int
    let S = read string |> Seq.toArray

    let mutable cnt = 0
    for i = 0 to 999 do
        let c = [| i / 100; (i / 10) % 10; i % 10 |]
        seq {
            let mutable f = 0
            for j = 0 to N - 1 do
                if int S.[j] = (int '0' + c.[f]) then
                    f <- f + 1
                if f = 3 then yield ()
        }
        |> fun s ->
            if not (Seq.isEmpty s) then cnt <- cnt + 1

    printfn "%i" cnt
    0

Measured memory_bytes: 14428
implicit none
integer :: n,w
integer,allocatable :: t(:)
integer(8) :: x,s,e
integer :: i

read *,n,w
allocate(t(n))
read *,t

x = 0
s = 0
e = 0
do i = 1, n
   s = max(e, t(i))
   e = s + w
   if (i < n) then
      if (t(i+1) < e) then
         e = t(i+1)
      endif
   endif
   x = x + e - s
enddo

print '(i0)',x
end

Measured memory_bytes: 1536
from sys import stdin

def main():
    nums = int(stdin.readline())
    l = []
    actual = int(stdin.readline())
    total = 0
    for x in range(nums-1):
        total += actual//2
        temp = int(stdin.readline())
        if temp != 0:
            actual = actual%2 + temp
        else:
            actual = temp

    print(total+actual//2)
        
        
    
main()


Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<cmath>
#include<queue>
#include<limits>
#include<cassert>
#include<set>
#include<tuple>
#include<map>
#include<string.h>
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define None cout<<"None"<<endl
typedef long long ll;
using namespace std;

int main() {
	int A,B,C; cin >> A >> B >> C;
	int sum = 0;
	for (int i = 0; i < A * B; ++i) {
		sum += A;
		if (sum % B == C) {
			cout << "YES" << endl;
			return 0;
		}
	}
	cout << "NO" << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};

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

struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};




signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    // Timer TM;
    
    
    ll n,m;
    cin>>n>>m;
    cout<<n*m-(n+m-1)<<endl;


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
const ll mod = 1e9 + 7;
int main()
{
	SPEED
	ll n, temp;
	cin >> n;
	ll arr[n];
	unordered_map<ll, ll> count_no;
	ll m = INT_MIN;

	for (ll i = 0; i < n; ++i)
	{
		cin >> temp;
		m = max(m, temp);
		arr[i] = temp;
		if (count_no.count(temp))
		{
			count_no[temp]++;
		}
		else
		{
			count_no[temp] = 1;
		}
	}

	ll ans = 0;
 
    for(ll i =1; i <= m; i++)
	{
		ans += count_no[i]*(count_no[i]-1)/2;
	}
    //cout << "total pairs : " << ans << '\n';

	for (ll i = 0; i < n; ++i)
	{
		ll t = arr[i];
		ll t2 = count_no[t] - 1;

		cout << ans - t2 << '\n';
	}	
	return 0;
}

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

#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef vector<int> vi;

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

	int n;
	cin >> n;
	vi a(n);
	double sum = 0.0;
	rep(i, n){
		cin >> a[i];
		sum += (1.0 / a[i]);
	}

	cout << fixed;
	cout << setprecision(6) << 1 / sum << endl;




    return 0;
}



Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx2")
#pragma GCC optimize("Os")
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);
#define FO cout.tie(NULL);
#define FI cin.tie(NULL);
#define IN cin>>
#define OUT cout<<
#define loop(i,a,n) for(int i=a; i<n; i++)
#define rloop(i,a,n) for(int i=a; i>=n; i--)
#define endl "\n";
#define pb push_back
#define mp make_pair
#define set_bits(a) __builtin_popcountll(a)
#define ll long long int
#define ld long double
#define vll vector<long long int>
#define pll pair<long long int, long long int>
#define mod 1000000007
#define M 998244353
using namespace std;
ll gcd(ll a, ll b)
{
    return (b?gcd(b,a%b):a);
}
ll P(ll B, ll power, ll modulo)
{
    ll ans=1LL;
    while(power>0LL)
    {
        if(power%2LL==1LL)
        {
            ans=(ans*B)%modulo;
        }
        B=(B*B)%modulo;
        power/=2LL;
    }
    return ans;
}
bool isPrime(ll n)
{
    if(n<=1LL)
    {
        return false;
    }
    if(n<=3LL)
    {
        return true;
    }
    if(n%2==0LL || n%3==0LL)
    {
        return false;
    }
    for(ll i=5LL; (i*i)<=n; i+=6LL)
    {
        if(n%i==0LL || n%(i+2LL)==0LL)
        {
            return false;
        }
    }
    return true;
}
void vok()
{
    FAST
    FO
    FI
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
}
int main()
{
    vok();
    vector<int> v(5);
    loop(i,0,5)
    {
        IN v[i];
    }
    loop(i,0,5)
    {
        if(v[i]==0)
        {
            OUT i+1<<endl
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3604
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <set>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

int n, m, p;
int pos;
char str[10000];
map<string, vector<int> > mapto;
map<vector<int>, string> mapfrom;
map<string, string> convert;
vector<int> error;

vector<int> formula();
vector<int> factor() {
  vector<int> lhs;
  if (str[pos] == '(') {
    pos++;
    lhs = formula();
    pos++;
  } else {
    if (!isalpha(str[pos])) { return error; }
    string s;
    while (isalpha(str[pos])) { s += str[pos++]; }
    if (!convert.count(s)) { return error; }
    if (!mapto.count(convert[s])) { return error; }
    lhs = mapto[convert[s]];
  }
  return lhs;
}

vector<int> term() {
  vector<int> lhs = factor();
  if (lhs == error) { return error; }
  while (str[pos] == '*' || str[pos] == '/') {
    int s = str[pos] == '*' ? 1 : -1;
    pos++;
    vector<int> rhs = factor();
    if (rhs == error) { return error; }
    REP(i, n) {
      lhs[i] += s * rhs[i];
    }
  }
  return lhs;
}

vector<int> formula() {
  vector<int> lhs = term();
  if (lhs == error) { return error; }
  while (str[pos] == '+' || str[pos] == '-') {
    pos++;
    vector<int> rhs = term();
    if (rhs == error) { return error; }
    REP(i, n) {
      if (lhs[i] != rhs[i]) { return error; }
    }
  }
  return lhs;
}

int main() {
  error = vector<int>(1, -1000000000);
  while (scanf("%d %d %d", &n, &m, &p), n|m|p) {
    pos = 0;
    mapto.clear();
    mapfrom.clear();
    REP(i, m) {
      string s;
      cin >> s;
      vector<int> vect(n, 0);
      REP(i, n) {
        scanf("%d", &vect[i]);
      }
      mapto[s] = vect;
      mapfrom[vect] = s;
    }
    scanf("%s", str);
    REP(i, p) {
      string from, to;
      cin >> from >> to;
      convert[from] = to;
    }
    vector<int> ans = formula();
    if (ans[0] <= -100000) {
      puts("error");
    } else if (mapfrom.count(ans)) {
      printf("%s\n", mapfrom[ans].c_str());
    } else {
      puts("undefined");
    }
  }
}

Measured memory_bytes: 0
import sys
N,W = map(int, raw_input().split())
src = []
wmax = vmax = 0
for i in range(N):
  w,v = map(int, raw_input().split())
  src.append((w,v))
  wmax += w
  vmax += v
w1 = src[0][0]

if w1 > W:
  print(0)
  sys.exit()
if wmax <= W:
  print(vmax)
  sys.exit()

wend = 3*N+1
dp = [[0 for w in range(wend)] for n in range(N+1)]
for i in range(N):
  wi,vi = src[i]
  wi -= w1 # 0 <= wi <= 3
  maxn = min(N,i+1)
  for n in reversed(range(1,maxn+1)):
    for w in range(wi,wend):
      dp[n][w] = max(dp[n][w], dp[n-1][w-wi] + vi)

ans = 0
for n in range(1,N+1):
  remain = W - w1*n
  if remain < 0: break
  w = min(remain, wend-1)
  ans = max(ans, dp[n][w])

print(ans)

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

using namespace std;

#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define repr(i, j) for(int i = j; i >= 0; --i)
#define INF (1 << 30)
#define MOD 1e9 + 7

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

int N, a[100000];
int dp[100000];

int main() {
	scanf("%d", &N);
	rep(i, N) scanf("%d", &a[i]);
	fill(dp, dp + N, INF);
	rep(i, N) {
		*lower_bound(dp, dp + N, a[i]) = a[i];
	}
	printf("%d\n", lower_bound(dp, dp + N, INF) - dp);
	return 0;
}

Measured memory_bytes: 3988
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
      	int b = sc.nextInt();
      	int c = sc.nextInt();
      	int d = sc.nextInt();
      	while(true){
          if(c - b <= 0){
              System.out.println("Yes");  
              break;
          }else{
              c -= b;
          }          
          
          if(a - d <= 0){
              System.out.println("No");  
              break;
          }else{
              a -= d;
          }
        }
    }
}

Measured memory_bytes: 35600
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))


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

    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;

    vs64 A(a), B(b), C(c);
    rep (i, a) cin >> A[i];
    rep (i, b) cin >> B[i];
    rep (i, c) cin >> C[i];

    sort(A.begin(), A.end(), greater<s64>());
    sort(B.begin(), B.end(), greater<s64>());
    sort(C.begin(), C.end(), greater<s64>());

    s64 ans = 0;
    rep (i, x) ans += A[i];
    rep (i, y) ans += B[i];

    int aidx = x - 1;
    int bidx = y - 1;
    rep (i, c)
    {
        if (aidx >= 0 && bidx >= 0 && C[i] > A[aidx] && C[i] > B[bidx])
        {
            if (A[aidx] > B[bidx])
            {
                ans += C[i] - B[bidx];
                --bidx;
            }
            else if (A[aidx] <= B[bidx])
            {
                ans += C[i] - A[aidx];
                --aidx;
            }
        }
        else if (C[i] > A[aidx] && aidx >= 0)
        {
            ans += C[i] - A[aidx];
            --aidx;
        }
        else if (C[i] > B[bidx] && bidx >= 0)
        {
            ans += C[i] - B[bidx];
            --bidx;
        }
        else
        {
            break;
        }
    }

    cout << ans << "\n";
    return 0;
}



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

int dp1[200005],dp2[200005],rest[200005];

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n,k,c;
	cin >> n >> k >> c;
	string a = " ",b;
	cin >> b;
	a += b;
	for (int i = 1; i <= n; i++)
	{
		if( a[i] == 'o' )
		{
			dp1[i] = dp1[i-1] + 1;
			rest[i] = c;
			for (int j = 1; j <= c; j++)
			{
				if( i + j > n ) break;
				dp1[i+j] = dp1[i];
				rest[i+j] = c - j;
			}
			i += c;
		}else dp1[i] = dp1[i-1],rest[i] = 0;
	} 
	for (int i = n; i >= 1; i--)
	{
		if( a[i] == 'o' )
		{
			dp2[i] = dp2[i+1] + 1;
			for (int j = 1; j <= c; j++)
			{
				if( i - j < 1 ) break;
				dp2[i-j] = dp2[i];
			}
			i -= c;
		}else dp2[i] = dp2[i+1];
	}
	for (int i = 1; i <= n; i++)
	{
		if( dp1[i-1] + dp2[min(max(i-1+rest[i-1]+1,i+1),n+1)] < k )
		{
			cout << i << '\n';
		}
	}
	return 0;
}


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

int main(){
	
	int K,A,B;
	cin >> K >> A >> B;
	int loop,ok=0;
	for(loop=0;K*loop<=B;loop++){
		if(K*loop>=A){
			ok=1;
		}
	}
	if(ok){
		cout << "OK" << endl;
	}else{
		cout << "NG" << endl;
	}
	return 0;
}

Measured memory_bytes: 3628
#include <stdio.h>

int main(void){
    int a, b, add,sub,mul;
    scanf("%d %d",&a,&b);
    add = a + b;
    sub = a - b;
    mul = a * b;

    int max = add;
    if(sub > max){
        max = sub;
    }
    if (mul > max){
        max = mul;
    }
    printf("%d\n",max);
    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
int main(void)
{
  int N = 0;
  scanf("%d", &N);

  char s[100001];
  scanf("%s", s);
  
  int ans = 1;
  for(int i = 1; i < N; i ++){ 
     if(s[i] != s[i-1]){ 
        ans ++;
    }
  }
  printf("%d",ans);
  return 0;
}


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

using namespace std;

const int NS = (int)2e5+4;

vector < int > way[NS];
int ans;
int chk[NS];

int sol(int x){
    chk[x] = 1;
    vector < int > val;
    for(auto&nxt:way[x]) if(!chk[nxt]){
        val.push_back(sol(nxt));
    }
    sort(val.begin(), val.end());
    reverse(val.begin(), val.end());
    if(!(int)val.size()){
        ans = max(ans, 1); return 1;
    }
    else{
        if((int)val.size() >= 2) ans = max(ans, val[0]+val[1]+1);
        else{
            ans = max(ans, val[0]+1);
        }
        return val[0]+1;
    }
}

int main(){
    int N;
    scanf("%d", &N);
    for(int i = 1; i < N; ++i){
        int a, b; scanf("%d %d", &a, &b);
        way[a].push_back(b), way[b].push_back(a);
    }
    sol(1);
    if(ans%3==2) puts("Second");
    else puts("First");
    return 0;
}


Measured memory_bytes: 27008
#include <stdio.h>

int main(void){
  int P;//A-B
  int Q;//B-C
  int R;//C-A
  int minimum;

  char buf[256];
  fgets(buf,256,stdin);
  sscanf(buf,"%d %d %d",&P, &Q, &R);//入力

  minimum = P + Q;
  if(Q + R < minimum) minimum = Q + R;
  if(R + P < minimum) minimum = R + P;
  printf("%d\n", minimum);
  return 0;
}


Measured memory_bytes: 128
n,m = map(int,input().split())
ka = [list(map(int,input().split())) for _ in range(n)]
a = [i[1:] for i in ka]

mcount = [0]*(m+1)
for mi in range(1,m+1):
  for ai in a:
    if mi in ai:
      mcount[mi] += 1
print(mcount.count(n))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for(int i= 0; i < (n); i++)
using ll= long long int;
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; }
ll mod= 1e9 + 7;




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

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define F first
#define S second

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

const int MOD=998244353;
int INF=100100100100100;
int pol[3010][6020];
int a[3010];
signed main(){
  int n,s;cin>>n>>s;
  int ans=0;
  rep(i,n)cin>>a[i];
  pol[0][0]=1;
  rep(i,n){
    rep(j,s+1){
      (pol[i+1][j]+=pol[i][j])%=MOD;
      if(j+a[i]<=s)(pol[i+1][j+a[i]]+=pol[i][j])%=MOD;
    }
    pol[i+1][0]++;
    (ans+=pol[i+1][s])%=MOD;
  }
 
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 85904
#pragma region header
#include <bits/stdc++.h>
using namespace std;

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;

constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
constexpr char EL[] = "\n";

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(),(x).end()
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
#define UNIQUE(x) (x).erase(unique(all(x)), (x).end());
#define REPIT(x) for(auto it=(x).begin(), end=(x).end(); it!=end; ++it)
#define perm(c) sort(all(c)); for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<typename T = i64>
T IN() { T x; cin >> x; return (x); }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}

void print() {
  cout << EL;
}
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(tail) != 0) cout << " ";
  print(forward<Tail>(tail)...);
}
template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
	cout << a;
	if (&a != &vec.back()) cout << " ";
  }
  cout << EL;
}
template <class T>
void print(vector<vector<T>> &df) {
  for (auto& vec : df) {
	print(vec);
  }
}

struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

signed solve()
{
	i64 n, m;
	cin >> n >> m;
	if (abs(n - m) > 1)
	{
		print(0);
		return 0;
	}

	i64 fct_n = 1;
	FOR(i, 1, n + 1) { fct_n = (fct_n * i) % MOD; }
	i64 fct_m = 1;
	FOR(i, 1, m + 1) { fct_m = (fct_m * i) % MOD; }
	i64 ans = (fct_n * fct_m) % MOD;
	if (abs(n - m) % 2 == 0)
		ans = (ans * 2) % MOD;
	print(ans);
	return 0;
}

#ifndef LOCALCODE
signed main()
{
	return solve();
}
#endif


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;

int main(){
    //方針
    //毎日満足度は低下し続ける
    //満足度上昇の方法はコンテスト開催のみ
    //開催されてないコンテストを放置すると低下が著しくなる
    //実際にコンテストを開いた時の満足度上昇が最大のものを採用してみる
    //低下をなくせる分を上昇と捉えると、c_i(d-last(d,i)) + s_{d,i} だけペイすると考えられる？→あんまり適当じゃない
    int D;cin>>D;
    int c[26],last[26]={},s[365][26];
    REP(i,26) cin>>c[i];
    REP(i,D) REP(j,26) cin>>s[i][j];
    REP(i,D){
        int tmp = -1e9,res = 0;
        REP(j,26){
            int up = 0;
            REP(k,26){
                if(j==k) up += s[i][k];
                else up -= c[k]*(i-last[k]);
            }
            if(tmp < up){
                tmp = up;
                res = j;
            }
        }
        cout<<res+1<<endl;
    }
}


Measured memory_bytes: 3668
#include <iostream>
#include <vector>

int main() {
  unsigned N, M;
  std::cin >> N >> M;
  std::vector<std::pair<bool, bool>> islands(N + 1, std::make_pair(false, false));
  for (unsigned i = 0; i < M; ++i) {
    unsigned a, b;
    std::cin >> a >> b;
    if (a == 1) {
      islands[b].first = true;
    } else if (b == N) {
      islands[a].second = true;
    }
  }
  for (auto &i : islands) {
    if (i.first && i.second) {
      std::cout << "POSSIBLE" << std::endl;
      return 0;
    }
  }
  std::cout << "IMPOSSIBLE" << std::endl;
  return 0;
}

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

int *init(int size, int init_value) {
    int *array = malloc(sizeof(int) * size);
    int i;
    for (i = 0; i < size; ++i) {
        *(array+i) = init_value;
    }
    return array;
}

int main()
{
    char input[3];
    if (scanf("%s", input) < 0) return 1;
    int i;
    int *count = init(3, 0);
    
    for (i = 0; i < 3; ++i)
    {
        switch (input[i]) {
            case 'a':
                count[0]++;
                break;
            case 'b':
                count[1]++;
                break;
            case 'c':
                count[2]++;
                break;
        }
    }

    if (count[0] == 1 && count[1] == 1 && count[2] == 1) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <cmath>
using namespace std;
const double INF = 1e18;
const int lim = 200000;

int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	for(int i=0; i<n; i++) cin >> a[i];
	
	vector<double> dp(lim+1, 0);
	for(int i=0; i<n; i++){
		vector<double> ndp(lim+1);
		for(int j=0; j<=lim; j++){
			ndp[j] = max(dp[j], fabs(a[i]-j)/a[i]);
		}
		for(int j=1; j<=lim; j++){
			for(int k=j*2; k<=lim; k+=j){
				ndp[k] = min(ndp[k], ndp[j]);
			}
		}
		dp = ndp;
	}
	double ans = INF;
	for(int i=0; i<=lim; i++){
		ans = min(ans, dp[i]);
	}
	cout << fixed << setprecision(10);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 6284
#include <bits/stdc++.h>
using namespace std;
int n, k;
int a[200005];
long long s[200005];
long long cal(long long s[], int nn) {
    if (nn == 1) return 0;
    long long s1[nn/2+2], s2[nn/2+2];
    for(int i = 1; i <= nn/2; ++i) s1[i] = s[i];
    for(int i = nn/2+1; i <= nn; ++i) s2[i-nn/2] = s[i];
    long long ans1 = cal(s1, nn/2);
    long long ans2 = cal(s2, nn-nn/2);
    sort(s1+1, s1+1+nn/2);
    long long ans3 = 0;
    for(int i = 1; i <= nn-nn/2; ++i) {
        int inf = 1, sup = nn/2, mid, tt = 0;
        while (inf <= sup) {
            mid = inf + sup >> 1;
            if (s1[mid] <= s2[i]) {
                tt = mid;
                inf = mid + 1;
            } else sup = mid - 1;
        }
        ans3 += tt;
    }
    return ans1 + ans2 + ans3;
}
int main() {
   ios_base::sync_with_stdio(0);
cin.tie();
    cin >> n >> k;
    long long sum =0;
    long long ans = 0;
    s[1] = 0;
    for(int i = 1; i <= n; ++i) {
        cin >> a[i];
        sum = sum + a[i];
        long long t = sum - 1LL*k*i;
        s[i+1] = t;
    }
    ans = cal(s, n+1);
    cout << ans << endl;
}

Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
#define int long long
struct BipartiteMatching{
  vector<vector<int> > G;
  int V;
  vector<int> match,used;
  
  BipartiteMatching(){}
  BipartiteMatching(int V):V(V){init();}
  
  void init(){
    for(int i=0;i<(int)G.size();i++) G[i].clear();
    G.clear();
    match.clear();
    used.clear();
    G.resize(V);
    match.resize(V);
    used.resize(V);
  }
  
  void add_edge(int u,int v){
    G[u].push_back(v);
    G[v].push_back(u);
  }

  bool dfs(int v){
    used[v]=true;
    for(int i=0;i<(int)G[v].size();i++){
      int u=G[v][i],w=match[u];
      if(w<0||(!used[w]&&dfs(w))){
	match[v]=u;
	match[u]=v;
	return true;
      }
    }
    return false;
  }

  int bipartite_matching(){
    int res=0;
    fill(match.begin(),match.end(),-1);
    for(int v=0;v<V;v++){
      if(match[v]<0){
	fill(used.begin(),used.end(),0);
	if(dfs(v)){
	  res++;
	}
      }
    }
    return res;
  }
};
signed main(){
  int X,Y,E;
  cin>>X>>Y>>E;
  BipartiteMatching bm(X+Y);
  for(int i=0;i<E;i++){
    int x,y;
    cin>>x>>y;
    bm.add_edge(x,X+y);
  }
  cout<<bm.bipartite_matching()<<endl;
  return 0;
}
/*
  verified on 2017/06/29
  http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_7_A&lang=jp
*/

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

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

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;


//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();}


int main(){
  string s;
  cin >> s;
  ll scnt = 0,ans = 0;
  rep(i,s.size()){
    if(s[i] == 'S') scnt++;
    if(s[i] == 'T'){
      if(scnt > 0){
        ans ++;
        scnt--;
      }
    }



  }
  cout << s.size() - 2*ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define SORT(v, n) sort(v, v+n)
#define VREV(v,n) reverse(v,v+n)
#define REV(v,n) reverse(v,v+n)
#define vi vector<int>
#define pf push_front
#define pb push_back
#define P pair<int,int>
#define Pll pair<ll,ll>

template<class T, size_t N> size_t countof(const T (&array)[N]) { return N; }
template <class T> void chmin(T&a,const T&b) { a = min(a,b); }
template <class T> void chmax(T&a,const T&b) { a = max(a,b); }
 
void print(){cout<<"\n";}
template <class Head, class... Tail>
void print(Head&& h,Tail&&... t){ 
	if(sizeof...(t)==0)
		cout<<h;
	else
		cout<<h<<' ';
	print(move(t)...);
}

void mprint(auto *matrix,auto N){
	REP(i,N) cout<<matrix[i]<<(i!=N-1?' ':'\n');
	return;
}

const double EPS =1e-9;
const int INF =2e+9;
const ll INFL =9e+18;
const long MOD =1e+9+7;
#define PI 3.14159265258979

#define iP pair<int,P>
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

inline int in(){int x; cin>>x; return x;}

int main(void){
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	
	string S;
	cin>>S; 
	SORT(S.begin(),3);

	if(S=="abc") print("Yes");
	else print("No");
	return 0;
}






Measured memory_bytes: 256
import itertools
from collections import Counter
N = int(input())
V = list(map(int,input().split()))
even_counter = Counter(V[::2])
odd_counter = Counter(V[1::2])
even_counter[-1] = 0
odd_counter[-1] = 0
even = even_counter.most_common(2)
odd = odd_counter.most_common(2)
ans = N
for (k1,v1),(k2,v2) in itertools.product(even,odd):
  if k1 == k2:
    continue
  ans = min(ans,N - v1 - v2)
print(ans)

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

#define reps(v, f, l) for (int v = (f), v##_ = (l); v < v##_; ++v)
#define rep(v, n) reps(v, 0, n)
#define lep(v, n) reps(v, 1, n + 1)

using namespace std;

typedef long long int lint;
typedef complex<double> P;
const double EPS = 1e-8;
const double INF = 1e12;
namespace std {
  bool operator<(const P& a, const P& b){
    return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
  }
}
double cross(const P& a, const P& b){ return imag(conj(a) * b); }
double dot(const P& a, const P& b){ return real(conj(a) * b); }
typedef vector<P> G;

#define curr(P, i) P[i]
#define next(P, i) P[(i+1)%P.size()]
enum { OUT, ON, IN };

int contains(const G& x, const P& y){
  bool in_ = false;
  rep(i, x.size()){
    P a = curr(x, i) - y, b = next(x, i) - y;
    if (imag(a) > imag(b)) swap(a, b);
    if (imag(a) <= 0 && 0 < imag(b)){
      if (cross(a, b) < 0) in_ = !in_;
    }
    if (cross(a, b) == 0 && dot(a, b) <= 0) return ON;
  }
  return in_ ? IN : OUT;
}

static inline int in(){ int x; scanf("%d", &x); return x; }
static inline lint inl(){ lint x; scanf("%lld", &x); return x; }
template<typename T> void show(T& a, char del='\n', char last='\n'){ rep(i, a.size() - 1) cout << a[i] << del; cout << a[a.size() - 1] << last; }


int main()
{
  rep(i, in()){
    G area;
    rep(j, 3){
      int x, y;
      x = in();
      y = in();
      area.push_back(P(x, y));
    }
    int x, y;
    x = in();
    y = in();
    P k(x, y);
    x = in();
    y = in();
    P s(x, y);
    if (contains(area, k) != contains(area, s)){
      puts("OK");
    }
    else {
      puts("NG");
    }
  }
  return 0;
}

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

int main(){
  int A=0,B=0;
  string S;
  cin >> S;
  int N = S.size();
  for(int i=0;i<N;i+=2){
    if(S.at(i)!='0'){
    A++;
    }
  }
  for(int i=1;i<N;i+=2){
    if(S.at(i)!='1'){
    A++;
    }
  }
  for(int i=0;i<N;i+=2){
    if(S.at(i)!='1'){
    B++;
    }
  }
  for(int i=1;i<N;i+=2){
    if(S.at(i)!='0'){
    B++;
    }   
  }
  if(A<B){
    cout << A << endl;
    }
  else{
  cout << B << endl;
  }
}

Measured memory_bytes: 512
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <list>
#include <queue>
#include <stack>
#include <string>
#include <vector>
typedef long long ll;
using namespace std;

#include <iostream>
using namespace std;

int main() {
  int a[3];
  int swp;
  cin >> a[0] >> a[1] >> a[2];
  if (a[0] > a[1]) {
    swp = a[0];
    a[0] = a[1];
    a[1] = swp;
  }

  if (a[1] > a[2]) {
    swp = a[1];
    a[1] = a[2];
    a[2] = swp;
  }

  if (a[0] > a[2]) {
    swp = a[0];
    a[0] = a[2];
    a[2] = swp;
  }

  if (a[0] > a[1]) {
    swp = a[0];
    a[0] = a[1];
    a[1] = swp;
  }

  cout << a[0] << " " << a[1] << " " << a[2] << endl;
  return 0;
}



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

int main() {
    /* Input */
    int N, M, X;
    cin >> N >> M >> X;
    
    vector<int> C(N);
    vector<vector<int>> A(N, vector<int>(M));
    rep (i, N) {
        cin >> C.at(i);
        rep (j, M) {
            cin >> A.at(i).at(j);
        }
    }

    /* Main Logic */
    int min_cost = 12345678;

    // Bit all search
    for (int bit = 0; bit < (1 << N); bit++) {
        int sum_cost = 0;
        vector<int> sum_A(M);
        for (int i = 0; i < N; i++) {
            if (bit & (1 << i)) {
                // 金額と理解度を足していく
                sum_cost += C.at(i);
                rep (j, M) sum_A.at(j) += A.at(i).at(j);
            }
        }
        // 理解度がXを超えているか確認
        bool ok_flag = true;
        rep(i, M) if (sum_A.at(i) < X) ok_flag = false;
        // 最小のコストを保存
        if (ok_flag) min_cost = min(min_cost, sum_cost);
    }

    /* Output */
    if (min_cost == 12345678) cout << "-1" << endl;
    else cout << min_cost << endl;

    return 0;
}

Measured memory_bytes: 3588
#include<iostream>
#define ll long long
#define MOD 1000000007

using namespace std;

ll modpow(ll a,ll n){
  ll ans = 1;
  for(int i=1;i <= n;i++){
    ans = ans*a % MOD;
  }
  return ans;
}

int main(){
  ll n;
  cin >> n;
  ll ans = modpow(10,n) - modpow(9,n) - modpow(9,n) + modpow(8,n);
  ans %= MOD;
  ans = (ans+MOD)%MOD;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3608
#!/usr/bin/env python

import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**6)
INF = float("inf")

def main():
    N = int(input())
    S = input().decode().rstrip()

    if N%2==0 and S[0:N//2]==S[N//2:]:
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    main()

Measured memory_bytes: 9184
#include <stdio.h>

// 線形探索
int search(int A[], int n, int key) {
  int i = 0;
  A[n] = key;
  while ( A[i] != key ) i++;
  return i != n;
}

int main() {
  int i, n, A[10000+1], q, key, sum = 0;
  
  scanf("%d", &n);
  for ( i = 0; i < n; i++ ) scanf("%d", &A[i]);
  
  scanf("%d", &q);
  for ( i = 0; i < q; i++ ) {
    scanf("%d", &key);
    if ( search(A, n, key) ) sum++;
  }
  printf("%d\n", sum);
  
  return 0;
}


Measured memory_bytes: 2128