akhauriyash/Code-Regression huggingface dataset:
import java.util.*;


public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        int x = sc.nextInt();
        int ans=0;
        
        for(int i=0; x>499; i++){
            x=x-500;
            ans+=1000;
        }
        
        for(int i=0; x>4; i++){
            x=x-5;
            ans+=5;
        }
        
        System.out.println(ans);
	}
}

Measured memory_bytes: 35732
/*
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_2_C
 */

import java.util.Scanner;

class Card {
	static int[] appears = new int[37];
	String raw;
	int value;
	int appearNum;
	Card(int value, String raw) {
		this.raw = raw;
		this.value = value;
		appearNum = appears[value]++;
	}
}

public class Main {

	int count = 0;

	void swap(Card[] A, int a, int b) {
		Card tmp = A[a];
		A[a] = A[b];
		A[b] = tmp;
		count++;
	}

	void bubbleSort(Card[] A) {
		boolean f = true;
		while (f) {
			f = false;
			for (int i = A.length - 1; i >= 1; i--) {
				if (A[i].value < A[i-1].value) {
					Card tmp = A[i];
					A[i] = A[i-1];
					A[i-1] = tmp;
					f = true;
					count++;
				}
			}
		}
	}

	void selectionSort(Card[] A) {
		for (int i = 0; i < A.length; i++) {
			int minj = i;
			for (int j = i; j < A.length; j++) {
				if (A[j].value < A[minj].value) {
					minj = j;
				}
			}
			if (minj != i) swap(A, i, minj);
		}
	}
	
	boolean isStable(Card[] cards) {
		int prevVal = 0;
		int numCont = 0;
		for (int i = 0; i < cards.length; i++) {
			if (prevVal == cards[i].value) {
				if (numCont == cards[i].appearNum) {
					numCont++;
				} else {
					System.out.println(cards[i].value + " " + numCont);
					return false;
				}
			} else {
				if (cards[i].appearNum != 0) return false;
				prevVal = cards[i].value;
				numCont = 1;
			}
		}
		return true;
	}

	void printCards(Card[] cards) {
		System.out.print(cards[0].raw);
		for (int i = 1; i < cards.length; i++) {
			System.out.print(" " + cards[i].raw);
		}
		System.out.println();
	}

	void run() {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] ary = new int[37];
		Card[] A = new Card[n];
		Card[] B = new Card[n];
		for (int i = 0; i < A.length; i++) {
			String in = scan.next("[A-Z][1-9]");
			int x = Integer.parseInt(in.substring(1));
			A[i] = B[i] = new Card(x, in);
		}
	
		count = 0;
		bubbleSort(A);
		printCards(A);
		if (isStable(A)) {
			System.out.println("Stable");
		} else {
			System.out.println("Not stable");
		}
		
		count = 0;
		selectionSort(B);
		printCards(B);
		if (isStable(B)) {
			System.out.println("Stable");
		} else {
			System.out.println("Not stable");
		}
	}
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		new Main().run();
	}

}



Measured memory_bytes: 26056
using System;
    using System.Linq;
    using System.Collections.Generic;
    using System.Text.RegularExpressions;
    using System.Text;
     
    public class Program
    {
        public void Proc() {
            Reader.IsDebug =false;
            string oddText = Reader.ReadLine();
            string evenText = Reader.ReadLine();

            StringBuilder ans = new StringBuilder();
            for(int i=0; i<evenText.Length; i++) {
                ans.Append(oddText[i]);
                ans.Append(evenText[i]);
            }
            if(oddText.Length != evenText.Length) {
                ans.Append(oddText.Last());
            }
            Console.WriteLine(ans.ToString());

        }

        public class Reader {
            public static bool IsDebug = true;
            private static System.IO.StringReader SReader;
            private static string InitText = @"




xyz
abc





";
            public static string ReadLine() {
                if(IsDebug) {
                    if(SReader == null) {
                        SReader = new System.IO.StringReader(InitText.Trim());
                    }
                    return SReader.ReadLine();
                } else {
                    return Console.ReadLine();
                }
            }
        }
        public static void Main(string[] args)
        {
            Program prg = new Program();
            prg.Proc();
        }
    }

Measured memory_bytes: 11220
#include<bits/stdc++.h>
using namespace std;
int n;
int a[233];
long long ans;
int main() 
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=i+1;j<=n;j++)
		{
			ans+=a[i]*a[j];
		}
	}
	cout<<ans;
    return 0;
}



Measured memory_bytes: 256
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
T lcm(T)(T x, T y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998_244_353;
//long mod = 1_000_003;
void moda(T)(ref T x, T y) { x = (x + y) % mod; }
void mods(T)(ref T x, T y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(T)(ref T x, T y) { x = (x * y) % mod; }
void modpow(T)(ref T x, T y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }
void modd(T)(ref T x, T y) { y.modpow(mod - 2); x.modm(y); }

void main()
{
	auto N = RD;
	auto K = RD;
	auto rbt = new RedBlackTree!(long[], "a[0] > b[0]", true);
	foreach (i; 0..N)
	{
		auto A = RD;
		auto range = rbt[];
		debug writeln("i:", i, range);
		long[] add;
		while (!range.empty)
		{
			auto e = range.front; range.popFront;
			if (abs(A - e[1]) <= K)
			{
				add = [e[0]+1, A];
				break;
			}
		}
		if (!add.empty)
			rbt.insert(add);
		rbt.insert([1, A]);
	}

	writeln(rbt.front[0]);
	stdout.flush;
	debug readln;
}


Measured memory_bytes: 76744
#include<stdio.h>
#include<string.h>
#define MOD 1000000009+7

int main(){
	char S[100],T[100];
	char tmp;
	scanf("%s",S);
	scanf("%s",T);
	int len,i,j,flag=0;
	for(len=0;S[len]!=0;len++);
	for(i=0;i<len;i++){
		if(strcmp(S,T)==0){
			flag=1;
			break;
		}
		tmp=S[0];
		for(j=0;j<len-1;j++){
			S[j]=S[j+1];
		}
		S[len-1]=tmp;
	}
	if(flag==1)printf("Yes\n");
	if(flag==0)printf("No\n");
	return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
//typedef __int64 LL;
//typedef long long int LL;
typedef pair<int,int> P;

const int MOD=1000000007;

int main()
{
	string ans="No";
	int a[3][3];
	bool flag[3][3];
	for(int i=0;i<3;i++)
	{
		for(int j=0;j<3;j++)
		{
			cin>>a[i][j];
			flag[i][j]=false;
		}
	}	
	
	int n;
	cin>>n;
	
	for(int i=0;i<n;i++)
	{
		int x;cin>>x;
		for(int j=0;j<3;j++)
		{
			for(int k=0;k<3;k++)
			{
				if(a[j][k]==x)flag[j][k]=true;	
			}
		}
	}
	
	for(int i=0;i<3;i++)
	{
		if(flag[i][0] && flag[i][1] && flag[i][2])ans="Yes";
		if(flag[0][i] && flag[1][i] && flag[2][i])ans="Yes";
	}
	if(flag[0][0] && flag[1][1] && flag[2][2])ans="Yes";
	if(flag[0][2] && flag[1][1] && flag[2][0])ans="Yes";
	
	cout<<ans<<"\n";
}

Measured memory_bytes: 256
h1, m1 , h2, m2 , k= gets.split.map(&:to_i)

if h1 == h2
  puts m2-m1-k
elsif h1 < h2
  if m1 != 0
    m1 = 60-m1
    h1 +=1
  end
  puts (h2-h1)*60 + m1+m2-k
else
  if m1 != 0
    m1 = 60-m1
    h1 += 1
  end
  puts (24-h1+h2)*60 + m1+m2-k
end

Measured memory_bytes: 14384
N=int(input())
c=list(map(int, input().split()))
C=[0]
C.extend(c)
C.append(0)
sa=[]
for i in range(1,N+2):
  sa.append(abs(C[i]-C[i-1]))
moto=sum(sa)
for i in range(1,N+1):
  c1=C[i-1]<=C[i] and C[i]<=C[i+1]
  c2=C[i-1]>=C[i] and C[i]>=C[i+1]
  if c1 or c2:
    print(moto)
  else:
    sub=abs(C[i]-C[i-1])+abs(C[i+1]-C[i])
    print(moto-sub+abs(C[i-1]-C[i+1]))

Measured memory_bytes: 20416
n,m=map(int,input().split())
l=["#"+input()+"#" for an  in range(n)]
l=["#"*(m+2)]+l+["#"*(m+2)]
inf=10**7
from queue import Queue as qu
mo=[(1,0),(-1,0),(0,1),(0,-1)]
ret=0
for i in range(1,n+1):
  for j in range(1,m+1):
    if l[i][j]==".":
      q=qu()
      step=[[inf for c in range(m+2)] for x in range(n+2)]
      step[i][j]=0
      q.put((i,j))
      while not q.empty():
        d=q.get()
        for g in mo:
          c,cc=g[0]+d[0],g[1]+d[1]
          if step[c][cc]==inf and l[c][cc]==".":
            q.put((c,cc))
            step[c][cc]=step[d[0]][d[1]]+1
            ret=max(ret,step[c][cc])
print(ret)

Measured memory_bytes: 3952
#include<bits/stdc++.h>
using namespace std;
int n,m,a,b,c;

int s[100000];
vector<int> t[(1<<18)];

void Set(int i,int x){
  i+=(1<<17)-1;
  t[i].push_back(x);
  while(i){
    i=(i-1)/2;
    t[i].push_back(x);
  }
}

int query(int a,int b,int ay,int by,int k,int l,int r){
  if(b<=l || r<=a)return 0;
  if(a<=l && r<=b){
    vector<int> :: iterator it0,it1;
    it0=lower_bound(t[k].begin(),t[k].end(),ay);
    it1=upper_bound(t[k].begin(),t[k].end(),by);
    return it1-it0;
  }
  int m=(l+r)/2;
  return query(a,b,ay,by,k*2+1,l,m)+query(a,b,ay,by,k*2+2,m,r);
}

int main(){
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d",&a);
    Set(i,a);
    s[i]=a;
  }
  
  for(int i=0;i<(1<<18);i++)
    sort(t[i].begin(),t[i].end());

  scanf("%d",&m);
  for(int i=0;i<m;i++){
    scanf("%d %d %d",&a,&b,&c);
    a--,b--;
    printf("%d\n",b-a+1-query(a,b+1,min(s[a],s[b])-c,max(s[a],s[b])+c,0,0,(1<<17)));
  }
  return 0;
}

Measured memory_bytes: 19512
/*
                _____________   ______________       __
               / _________  /\ /_____   _____/\     / /\
              / /\       / /  \\    /  /\    \ \   / /  \
             / /  \_____/ /   / \__/  /  \____\/  / /   /
            / /   /    / /   /    /  /   /       / /   /
           / /   /    / /   /    /  /   /       / /   /
          / /   /    / /   /    /  /   /       / /   /
         / /___/____/ /   /    /  /   /       / /___/________
        /____________/   /    /__/   /       /______________/\
        \            \  /     \  \  /        \              \ \
         \____________\/       \__\/          \______________\/
           ___       ___               ___    ___________
          /  /\     /  /\             /  /\  /_______   /\
         /  /__\___/  /  \           /  /  \ \      /  /  \
        /____    ____/   /          /  /   /  \____/  /   /
        \   /   /\   \  /          /  /   /       /  /   /
         \_/   /  \___\/ ___      /  /   /       /  /   /
          /   /   /     /  /\    /  /   /       /  /   /
         /   /   /     /  /__\__/  /   /       /  /___/____
        /___/   /     /___________/   /       /___________/\
        \   \  /      \           \  /        \           \ \
         \___\/        \___________\/          \___________\/

          A FAN OF FIZZYDAVID

*/

#include <iostream>
#include <fstream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <deque>
#include <queue>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <bitset>
#include <stack>
#include <iomanip>
#include <utility>
#include <functional>
using namespace std;
//orz jzm
#define ll long long
#define ull unsigned ll
#define orz int
#define yjz main
#define fizzydavid return
#define ak 0
#define la ;
#define plusonesecond {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}
#define minusonesecond exit(0)
const double EPS = 1e-8;
const ll PR = 19260817;
const ll inv2 = 500000004;
const ll inv3 = 333333336;
const int N = 100005;
int n, a[N], c[N];
orz yjz() {
	scanf("%d", &n);
	for(int i=0; i<n; i++) {
		scanf("%d", &a[i]);
		c[a[i]+1]++;
	}
	int ans=0, cc;
	for(int i=0; i<=100000; i++) {
		int now=c[i]+(i>0?c[i-1]:0)+c[i+1];
		if(now>ans) {
			ans=now;cc=i-1;
		}
	}
	printf("%d\n", ans);
	fizzydavid ak la
}

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

const int N = 1e+5 + 5;
long long int dp[105][N], w[105], v[105];
long long int n, W;

int main()
{
    cin >> n >> W;
    for (int i = 1; i <= n; i++)
        cin >> w[i] >> v[i];
    for (int i = 0; i <= 104; i++)
        for (int j = 0; j < N; j++)
            dp[i][j] = 1e+16;

    dp[0][0] = 0;
    for (int i = 1; i <= n; i++)
    {
        for (int j = 0; j < N; j++)
        {
            dp[i][j] = dp[i - 1][j];
            if (j >= v[i])
                dp[i][j] = min(dp[i][j], dp[i - 1][j - v[i]] + w[i]);
        }
    }
    int ans=0;
    for(int i=N-5;i>=0;i--)
    {
        if(dp[n][i]<=W)
        {
            ans=i;
            break;
        }
    }
    cout<<ans;
}

Measured memory_bytes: 82304
#include <iostream>
#define max(a, b) (a > b ? a : b)
#define max_3(a, b, c) max( a, max(b, c) )

using namespace std;

int main()
{
    int K, A, B, C;
    cin >> A >> B >> C >> K;
    
    long long answer = max_3( (1 << K)*A + B + C, A + (1 << K)*B + C, A + B + (1 << K)*C );
    cout << answer;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2147483647
#define LINF 9223372036854775807
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
//typedef long long int ll;
signed main(){
    
    int a,b;
    cin>>a>>b;
    /*int c=0;
    cout<<c<<endl;
    for(int i=123;i<500;i++){
        c^=i;
        //cout<<c<<endl;
    }*/
    if(a%2==0){
        int ans=0;
        int h=(b-a+1)%4;
        for(int i=0;i<h;i++){
            ans^=b-i;
        }
        cout<<ans<<endl;
    }
    else{
        int ans=a-1;
        int h=(b-a+1)%4;
        for(int i=0;i<h+1;i++){
            ans^=b-i;
        }
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define erep(i,a,n) for(int i = a;i<=n;i++)
typedef long long ll;
#define int long long
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 1101010101010101010
#define MOD 1000000007
#define P = pair<int,int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

signed main(){
  int n;
  cin >> n;
  vint A(n);
  vint judge(n,0);
  rep(i,0,n){
    cin >> A[i];
    A[i]--;
  }
  rrep(i,n-1,0){
    if(A[i] == n-1){
      judge[A[i]] = 1;
    }
    else{
      judge[A[i]] = judge[A[i]+1]+1;
    }
  }
  //rep(i,0,n) cout << judge[A[i]] << endl;
  int ans = 0;
  rep(i,0,n){
    ans = max(judge[i],ans);
  }
  cout << n - ans << endl;
}

Measured memory_bytes: 3328
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
using namespace std;
#define ll long long

int d = 365;
//int k = 0;
vector<vector<int>> s(d, vector<int>(26, 0));
vector<ll> c(26);

void init() {
    cin >> d;
    for(int i = 0; i < 26; i++) cin >> c[i];
    for(int i = 0; i < d; i++) {
        for(int j = 0; j < 26; j++) {
            cin >> s[i][j];
        }
    }
    return;
}

ll calc(vector<int> out) {
    ll score = 0;
    vector<ll> last(26, 0);
    for(int i = 0; i < out.size(); i++) {
        last[out[i]] = i+1; // タイプ番号
        for(int j = 0; j < 26; j++) {
            score -= c[j]*((i+1)-last[j]);
        }
        score += s[i][out[i]];
        //cout << "score : " << score << endl;
    }

    //int p = min(int(out.size()+k), int(d));
    //cout << p << endl;
    //if(out.size() >= d) return score;
    //cout << k << endl;
    //cout << out.size() << " " << d << endl;
    //int p = min(int(out.size()+k), d);
    //int k = 13;
    //int p = min(int(out.size()+k), d);
    ll q = LLONG_MIN;
    for(int k = 0; k < 26; k++) {
        int p = min(int(out.size()+k), int(d));
        ll tmp = 0;
        for(int i = out.size(); i < p; i++) {
            for(int j = 0; j < 26; j++) {
                //score -= c[j]*((i)-last[j]);
                tmp -= c[j]*((i)-last[j]);
            }
        }
        if(tmp > q) {
            q = tmp;
        }
    }
    return score+q;
}

/*
vector<int> proc(int k) {
    vector<int> out;
    ll ans = 0;
    //ll tmp = 0;
    ll max_v = -1;
    //for(int k = 0; k < 26; k++) {
    //cout << "k: " << k << endl;
    //vector<int> out;
    for(int i = 0; i < d; i++) {
        //max_v = -100000000000;
        max_v = LLONG_MIN;
        int best = 0;
        for(int j = 0; j < 26; j++) {
            out.push_back(j);
            ll tmp = calc(out);
            if(max_v < tmp) {
                max_v = tmp;
                best = j;
            }
            out.pop_back();
        }
        out.push_back(best);
    }
    //}
    return out;
}
*/

int main() {
    init();
    
    vector<int> out;
    ll ans = 0;
    ll max_v = -1;
    //for(int k = 0; k < 26; k++) {
        //cout << "k: " << k << endl;
        //vector<int> out;
    for(int i = 0; i < d; i++) {
        //max_v = -100000000000;
        max_v = LLONG_MIN;
        int best = 0;
        for(int j = 0; j < 26; j++) {
            out.push_back(j);
            //for(int k = 0; k < 26; k++) {
            ll tmp = calc(out);
            if(max_v < tmp) {
                max_v = tmp;
                best = j;
            }
            //}
            out.pop_back();
        }
        out.push_back(best);
    }
    //}
    
    for(int i = 0; i < d; i++) {
        cout << out[i]+1 << endl;
    }
    //cout << max_v << endl;
    return 0;
}

Measured memory_bytes: 3692
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

#define EPS 1e-10
#define INF 100000000
#define mp make_pair
#define pb push_back

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

bool isHated(int n, vi h) {
	while (n > 0) {
		for (int i = 0; i < h.size(); i++) {
			if (n % 10 == h[i]) {
				return true;
			}
		}
		n /= 10;
	}
	return false;
}

int main() {
	int N, K;
	cin >> N;
	cin >> K;
	vi D(K);
	for (int i = 0; i < K; i++) {
		cin >> D[i];
	}
	for (ll i = N; i < INF; i++) {
		if (!isHated(i, D)) {
			cout << i << endl;
			break;
		}
	}
}



Measured memory_bytes: 256
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
  int d, t, s; cin >> d >> t >> s;
  if(s * t >= d) cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

typedef long long ll;

ll gcd(ll a, ll b) {
  if(!b) return a;
  else return gcd(b,a%b);
}

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

  ll n,x; cin>>n>>x;
  cout << 3*(n-gcd(n,x)) << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include <vector>
#include<algorithm>
#include<cmath>
#include<iomanip>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using pii = pair<int, int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define vsort(v) sort(v.begin(), v.end())
#define rv(v) reverse(v.begin(), v.end())
#define ll long long
const ll MOD = 1e9 + 7;

int main() {
	int n;
	cin >> n;
	vector<ll> a(3 * n);
	rep(i, 3 * n) cin >> a[i];
	vsort(a);
	rv(a);
	ll sum = 0;
	rep(i, n) sum += a[2 * i + 1];
	cout << sum << endl;
}


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

int subtree[100005];
int dep[100005];
vector<pair<int,int> > adjl[100005];

int dfs(int node,int parent,int d){
    int ans = 1;
    dep[node] = d;
    for (auto x : adjl[node]){
        if (x.first==parent) continue;
        ans += dfs(x.first,node,d+1);
    }
    return subtree[node] = ans;
}

main(){
    int n;
    scanf("%lld",&n);
    for (int x = 0; x<n-1; x++){
        int a,b,c;
        scanf("%lld%lld%lld",&a,&b,&c);
        adjl[a].push_back({b,c});
        adjl[b].push_back({a,c});

    }
    dfs(1,-1,0);
    long long ans = 0;
    for (int x = 1; x<=n; x++){
        for (auto y :adjl[x]){
            if (dep[y.first]>dep[x]) continue;
            ans += min(subtree[x],n-subtree[x])*2*y.second;
        }
    }
    int num = 0;
    int nd;
    int w;
    for (int x = 1;x<=n; x++){
        bool t = true;
        for (auto y : adjl[x]){
            if (dep[y.first]<dep[x]){
                if (n-subtree[x]>(n)/2) t = false;
            }
            else{
                if (subtree[y.first]>(n)/2) t = false;
            }
        }
        if (t){
            num++;
            if (num==1) nd = x;
            if (num==2){
                for (auto y : adjl[x]){
                    if (y.first==nd){
                        w = y.second;
                    }
                }
            }
        }
    }
    if (num==1){
        int t = 999999999;
        for (auto y : adjl[nd]){
            t = min(t,y.second);
        }
        ans-=t;
    }
    else{
        ans-=w;
    }
    printf("%lld",ans);
}


Measured memory_bytes: 14720
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1LL << 60
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
const int MOD = 1000000007;

// vector<p> cut(M);
// cut[i].second
// cut[i].first;
// REP(i,M){
//     int a,b;cin>>a>>b;
//     cut[i] = make_pair(b,a);//last first の順番
// }
// for(int i=0; i<N;i++){
// }
// sort(cut.begin(),cut.end()); //sort
// char '' str ""
int main(void)
{
    int N; ll K; cin>>N>>K;
    vector<p> v;
    vector<ll> l; vector<ll> r;
    for(int i=0; i<N;i++){
      ll a,b; cin>>a>>b;
      v.push_back(make_pair(a,b));
    }
    sort(v.begin(), v.end());
    l.push_back(0); r.push_back(v[0].second);
    for(int i=1;i<N;i++){
      l.push_back(r[i-1]); r.push_back(l[i]+v[i].second);
    }
    for(int i=0;i<N;i++){
      if(l[i]<K && K<=r[i]) cout<<v[i].first<<endl;
    }

    return 0;
}


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

using namespace std;

typedef long long ll;
typedef long long unsigned int llui;
typedef long long int lli;
typedef long double float64;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector< vector<int> > vvi;

#define INF 1000000000
#define MOD 1000000007
#define EPS 1e-9
#define DEBUG(x) cout<< '>' << #x << ':' << x << "\n";
#define all(x) (x).begin(), (x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define UNIQUE(x) (x).erase(unique((x).begin(),(x).end()),(x).end())
#define tr(container, it) \
    for(typeof(container.begin()) it = container.begin(); it != container.end(); it++) 

// #define sz(a) int((a).size())
// #define pb push_back
// #define fill(a,v) memset(a,v,sizeof a)


#define trace(x) cout << '>' << #x << ':' << x << endl;
#define trace2(x,y) cout<< '>' << #x << ':' << x << " | " << #y << ':' << y << endl;

#define trace3(x,y,z) cout<< '>' << #x << ':' << x \
        << " | " << #y << ':' << y <<" | " << #z << ':' << z << endl;

#define trace4(x,y,z,w) cout<< '>' << #x << ':' << x \
    << " | " << #y << ':' << y <<" | " << #z << ':' << z << " | " << #w << ':' << w << endl;


inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }

#define LSOne(S) (S&(-S))

const double pi = acos(-1);

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

/*bool sortbysec(const pair<int,int> &a,const pair<int,int> &b)
{
    return (a.second < b.second);
}*/

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; } // __gcd(0,0) gives exception

const int MAX_N = 212345;

int main(){
    int n,x;
    ll ans=1;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&x);
        if(x&1)
            ans*=1;
        else
            ans*=2;
    }
    ans=pow(3,n)-ans;
    printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pint pair<int, int>
#define pll pair<ll, ll>
#define vint vector<int >
#define vll vector<ll >
#define ALL(x) (x).begin(), (x).end()
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i,n) for (int i = 0; i < (n); ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    ll sum = 1;
    bool is_zero = false;
    vll a(n);
    REP(i,n){
        cin >> a[i];
        if(a[i]==0) is_zero = true;
    }
    // zero
    if(is_zero == true){
        cout << "0\n";
        return 0;
    }

    // 
    bool f = false;
    REP(i,n){
        sum *= a[i];
        if(a[i] > 1000000000000000000 || sum > 1000000000000000000 || sum <= 0){
            f = true;
            break;
        }
    }
    if(f == true){
        cout << "-1\n";
        return 0;
    }
    cout << sum << "\n";
    return 0;
}

Measured memory_bytes: 3988
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<vector>
#include<stack>
using namespace std;
const int maxn = 100000+55;
const int inf = 0x3f3f3f3f;
#define LL long long

int pos[2][2020];
int num[4020];
int dp[2020][2020];

int w;
void add(int x,int p) { for(int i=x;i<=w;i+=i&-i) num[i]+=p;}

int sum(int x){int ans=0; for(int i=x;i>=1;i-=i&-i) ans+=num[i]; return ans;}


int main()
{
	int n;
	scanf("%d",&n);
	w=2*n;
	for(int i=1;i<=w;i++){
		char c;int x;
		cin>>c>>x;
		pos[c=='W'][x]=i;
		add(i,1);
	}
	pos[0][0]=pos[1][0]=w+1;
	for(int i=0;i<=n;i++){
		add(pos[0][i],-1);
		for(int j=0;j<=n;j++){
			add(pos[1][j],-1);
			if(i||j){
				dp[i][j]=inf;
				if(i)
					dp[i][j]=min(dp[i][j],dp[i-1][j]+sum(pos[0][i]-1));
				if(j)
					dp[i][j]=min(dp[i][j],dp[i][j-1]+sum(pos[1][j]-1));
			}
		}
		for(int j=0;j<=n;j++){
			add(pos[1][j],1);
		}
	}
	printf("%d\n",dp[n][n]);
	return 0;
}


Measured memory_bytes: 16128
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextFloat64() float64 {
	sc.Scan()
	i, e := strconv.ParseFloat(sc.Text(), 64)
	if e != nil {
		panic(e)
	}
	return i
}

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

func main() {
	sc.Split(bufio.ScanWords)

	n := nextInt()
	num := make([]int, 4)

	r := 1000
	for i := 0; i < 4; i++ {
		num[i] = n / r
		n = n % r
		r = r / 10
	}
	op := []rune{'+', '-'}

	for i := 0; i < 2; i++ {
		op1 := op[i]
		var ans1 int
		if op1 == '+' {
			ans1 = num[0] + num[1]
		} else {
			ans1 = num[0] - num[1]
		}
		for j := 0; j < 2; j++ {
			op2 := op[j]
			var ans2 int
			if op2 == '+' {
				ans2 = ans1 + num[2]
			} else {
				ans2 = ans1 - num[2]
			}
			for k := 0; k < 2; k++ {
				op3 := op[k]
				var ans3 int
				if op3 == '+' {
					ans3 = ans2 + num[3]
				} else {
					ans3 = ans2 - num[3]
				}
				if ans3 == 7 {
					fmt.Printf("%d%c%d%c%d%c%d=%d\n", num[0], op1, num[1], op2, num[2], op3, num[3], ans3)
					return
				}
			}
		}
	}

}


Measured memory_bytes: 1772
n = int(input())
mat = [list(map(int, input().split())) for _ in range(n)]
mat.sort(key=lambda x: x[1])
t = 0
for task in mat:
    due = task[1] - t
    if due < task[0]:
        print('No')
        exit()
    else:
        t += task[0]
print('Yes')

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

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

	int h=Integer.parseInt(br.readLine());

	int a[]=new int[h+1];
	String str[]=br.readLine().split(" ");
	
	for(int i=0;i<h;i++){
	    a[i+1]=Integer.parseInt(str[i]);
	}

	for(int i=1;i<=h;i++){
	    System.out.print("node "+i+": key = "+a[i]+", ");
	    if(getParent(i)>=1){
		System.out.print("parent key = "+a[getParent(i)]+", ");
	    }
	    if(getLeft(i)<=h){
		System.out.print("left key = "+a[getLeft(i)]+", ");
	    }
	    if(getRight(i)<=h){
		System.out.print("right key = "+a[getRight(i)]+", ");
	    }
	    System.out.println();
	}
    }
    static int getParent(int i){
	return i/2;
    }

    static int getLeft(int i){
	return 2*i;
    }

    static int getRight(int i){
	return 2*i+1;
    }
}



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

int main () {
int n;
int a,b;
int dig,suma,sumb;
int min = 100000;
cin >> n;
for(int i = 1;i < n;i++){
suma=0;
sumb=0;
a = i;
b = n - i;
while(a){
dig = a % 10;
suma = suma + dig;
a = a / 10;
}
while(b){
dig = b % 10;
sumb = sumb+ dig;
b = b / 10;
}
if(suma + sumb < min){
min = suma + sumb;
}
}

cout << min << endl;
return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;
template <class T> inline void chmax(T &a, const T b) { a = max(a, b); }
template <class T> inline void chmin(T &a, const T b) { a = min(a, b); }
template <class T> void pp(T v, int n) { REP(i,n) cout<<v[i]<< ' '; cout << endl; }

void inline TorF(bool tf, const string &trueMessage, const string &falseMessage) {
  cout << (tf ? trueMessage : falseMessage) << endl;
}
void inline YESNO(bool tf) { TorF(tf, "YES", "NO"); }
void inline YesNo(bool tf) { TorF(tf, "Yes", "No"); }

int main() {
#ifdef DEBUG
  int N; cin>>N;
  vector<int> P(N);
  REP(i,N) P[i] = i+1;
  int ans = 0;
  do {
    int tmp = 0;
    REP(i,N) {
      tmp += (i+1) % P[i];
    }
    chmax(ans, tmp);
  } while(next_permutation(P.begin(), P.end()));
  cout << ans << endl;
#endif
  ll N;	cin>>N;
  ll ans = (N -	1LL) * N / 2LL;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
def check(i,j):
    if i > 0:
        k = S[j][i-1] 
        if k in checked and not k in C:
            C.append(k)
    if j > 0:
        l = S[j-1][i]
        if l in checked and not l in C:
            C.append(l)
N = int(input())
S = [list(input()) for _ in range(2)]
ans = 1
checked = {}
for i in range(N):
    for j in range(2):
        p = S[j][i]
        if not p in checked:
            C = []
            check(i,j)
            if j < 1 and S[j+1][i] == p:
                check(i,j+1)
            checked[p] = C
            if len(C) > 1:
                if not C[0] in checked[C[-1]]:
                    ans = ((ans*3)//2)
            else:
                ans = (ans*(3-len(C)))
print(ans%(10**9+7))

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

int main() {
    char a;
    cin >> a;
    switch (a) {
        case 'A':
            cout << 'T' << endl;
            break;
        case 'C':
            cout << 'G' << endl;
            break;
        case 'G':
            cout << 'C' << endl;
            break;
        case 'T':
            cout << 'A' << endl;
            break;
    }
}

Measured memory_bytes: 256
N,C=map(int,input().split())
channel=[tuple(map(int,input().split())) for i in range(N)]
channel=sorted(channel,key=lambda cha: cha[0])

n=0
while(channel!=[]):
    c=[]
    n+=1
    pro=channel[0]
    channel.remove(pro)
    for i in channel:
        if i[0]>pro[1]:
            pro=i
        elif(i[0]==pro[1] and i[2]==pro[2]):
            pro=i
        else:
            c.append(i)
    channel=c
print(n)



Measured memory_bytes: 21376
#include <iostream>
#include <vector>
//#include <string>
#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

typedef long long LL;
//typedef long double LD;
using namespace std;
 
#define MOD 1000000007
#define MAX 100100
//#define NIL -1
//#define INFTY 1000000000000000000

LL mod_pow(LL x, LL n){
    LL ans = 1;
    while(n>0){
        if((n&1)==1){
            ans = (ans * x) % MOD;
        }
        x = x * x % MOD;
        n >>= 1;
    }
    return ans;
}

vector<LL> fac(MAX), finv(MAX);
void COMinit() {
    fac[0] = 1;
    finv[0] = 1;
    for (int i = 1; i < MAX; i++) {
        fac[i] = fac[i-1] * i % MOD;
        finv[i] = mod_pow(fac[i], (LL)MOD - 2) % MOD;
    }
}
 
LL COM(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

int main(){
    LL n;
    LL k;
    cin >> n >> k;
    vector<LL> a(n);
    for(LL i=0; i<n; i++){
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    COMinit();
    LL ans=0;
    for(LL i=n-1; i>=k-1; i--){
        ans=(ans+a[i]*COM(i,k-1))%MOD;
        //cout << ans << endl;
    }
    for(LL i=0; i<n-(k-1); i++){
        ans=(ans-a[i]*COM(n-1-i,k-1))%MOD;
        //cout << ans << endl;
    }
    if(ans<0){
        ans+=MOD;
    }

    cout << ans << endl;

    return 0;
}


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

#define endl '\n'

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

    int n; cin >> n;
    int a[n];
    map<int, int> freq;
    long long ans = 0;
    for (int i=0; i<n; i++){
        cin >> a[i];
        ans += freq[a[i] - i - 1];
        freq[-(a[i] + i + 1)]++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 21448
using System;
using System.Collections.Generic;

class Program
{
	static void Main(string[] args)
	{
		string[] input = Console.ReadLine().Split(' ');

		// 整数の入力
		int Health = int.Parse(input[0]);
        // 必殺技の数
		int max = int.Parse(input[1]);

        // 必殺技の攻撃値
		string[] inputA = Console.ReadLine().Split(' ');

		List<int> attack = new List<int>();

        foreach(string v in inputA)
        {
			attack.Add(int.Parse(v));
        }

		attack.Sort();
		attack.Reverse();

		int sum = 0;
		for(int i = 0; i < max;  i++)
		{
			sum += attack[i];
		}

        if(Health <=  sum)
        {
			Console.WriteLine("Yes");
		}
		else
        {
			Console.WriteLine("No");
		}
	}
}

Measured memory_bytes: 19168
#include <bits/stdc++.h>
using namespace std;
int main() {
    string s1,s2;
    cin>>s1>>s2;
        long int a=0;
        for(long int i=0;i<s1.length();i++)
        {
            if(s1[i]!=s2[i])
            a++;
        }
    cout<<a;
}


Measured memory_bytes: 3820
package main
import (
  "fmt"
  "sort"
)
func main() {
  var n,m int
  var l []int
  fmt.Scan(&n)
  n *= 2
  l = make([]int,n)
  for i:=0;i<n;i++ {
    fmt.Scan(&l[i])
  }
  sort.Sort(sort.Reverse(sort.IntSlice(l)))
  m = 0
  for i:=1;i<n;i+=2 {
    m += l[i]
  }
  fmt.Println(m)
}

Measured memory_bytes: 512
// itne me hi thakk gaye?
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize ("-O3")
#define ll long long 
#define ull unsigned long long
using ld = long double;
const ll mod = 1e9 + 7;
const ll inf = 1e18;
const ll rk = 256;
const ld PI = 3.141592653589793;
#define pb push_back
#define mp make_pair
#define vc vector
#define fs first
#define sec second
#define pq priority_queue
#define lb lower_bound
#define ub upper_bound
#define pll pair<ll,ll> 
#define pls pair<ll,string>
#define psl pair<string,ll>
#define plc pair<ll,char>
#define pcl pair<char,ll>
#define pss pair<string,string>
#define all(x) (x).begin(), (x).end()
#define tol(s) transform(s.begin(),s.end(),s.begin(),::tolower);
#define tou(s) transform(s.begin(),s.end(),s.begin(),::toupper);
#define print(a) for(auto j:a) {cout<<j<<",";} cout << "\n";
#define endl '\n'
#define whatis(x) cout << "> "<<#x << " ==> " << x << endl;
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
 
// // Printing pair
ostream & operator << (ostream & os, pair <ll, ll> const& x) {
    os << x.first << "," << x.second;
    return os;
}
 
// printing vector
template <class T>
ostream & operator << (ostream & os, vector <T> const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ";
    return os << "}";
}
 
// printing set
template <class T>
ostream & operator << (ostream & os, set <T> const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ";
    return os << "}";
}
 
template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ";
    return os << "}";
}
 
template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) {
    return os << "[ " << p.first << ", " << p.second << "]" ;
}
const int mxn = 1e5+5;

int32_t main(){
    int n;cin>>n;
    vc <ll> arr(n);
    for(int i=0; i<n; i++) cin >> arr[i];
    ll ans=0;
    vc <ll> cost(n, 0);
    cost[n-1] = 0;
    cost[n-2] = abs(arr[n-2] -arr[n-1]);
    for(int i=n-3; i>=0; i--) {
        cost[i] = min(cost[i+1] + abs(arr[i] - arr[i+1]), cost[i+2] + abs(arr[i] - arr[i+2]));
    }
    cout << cost[0] << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF    	((ll)1ll<<60)
#define INF     	((int)1<<30)
#define EPS     	(1e-9)
#define MOD     	(1000000007ll)
#define fcout(a)	cout<<setprecision(a)<<fixed
#define fs 			first
#define sc			second
#define PI			(3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s; a=0;} return os;}
template<class T> void chmax(T &a, const T &b){if(a<b)a=b;}
template<class T> void chmin(T &a, const T &b){if(a>b)a=b;}
void YN(bool b){cout<<(b?"YES":"NO")<<endl;}
void Yn(bool b){cout<<(b?"Yes":"No")<<endl;}
void yn(bool b){cout<<(b?"yes":"no")<<endl;}

const int N=3001;
ll dp[1<<16];
ll gs[1<<16];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	fill_n(dp,1<<16,-LINF);
	dp[0]=0;
	ll n;
	cin>>n;
	vvl score(n,vl(n));
	rep(i,n)rep(j,n)cin>>score[i][j],score[j][i]=score[i][j];
	rep(i,1<<n)rep(a,n)rep(b,a)if((i&(1<<a))&&(i&(1<<b)))gs[i]+=score[a][b];

	range(i,1,1<<n){
		for(int sub=i-1;sub>=0;sub--){
			sub&=i;
			chmax(dp[i],dp[sub]+gs[i-sub]);
		}
	}
	cout<<dp[(1<<n)-1]<<endl;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int main(){
    string s;
    cin >> s;
    int n = s.size();
    ll aCnt = 0;
    ll ans = 0;
    int i = 0;
    while(i < n){
        if (i + 2 < n && s.substr(i, 3) == "ABC"){            
            ans += aCnt + 1;
            aCnt++;
            i += 3;
        }
        else if (i + 1 < n && s.substr(i, 2) == "BC"){
            ans += aCnt;
            i += 2;
        }
        else if (s[i] == 'A'){
            aCnt++;
            i++;
        }else{
            aCnt = 0;
            i++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3696
#include<bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
#define int long long
signed main(){
  int N, M;
  cin >> N >> M;
  int H[100010];
  int A[100010], B[100010];
  bool high[100010] = {false};
  for(int i = 1;i <= N;i++)cin >> H[i];
  rep(i,M){
    cin >> A[i] >> B[i];
    if(H[A[i]] >= H[B[i]])high[B[i]] = true;
    if(H[A[i]] <= H[B[i]])high[A[i]] = true;
  }
  int ans = 0;
  for(int i = 1;i <= N;i++){
    if(high[i] == false){ans++;}
  }
  cout << ans;
}


Measured memory_bytes: 6076
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <iomanip>
#include <iostream>
#include <limits>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;

template<typename T>
vector<T> make_vec_nd(T init, ll size) {
    return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, ll size, Args... rest) {
    auto inner = make_vec_nd(init, rest...);
    return vector<decltype(inner)>(size, inner);
}

#define rep(i,a,b) for(ll i=(a);i<(b);i++)
#define rrep(i,a,b) for(ll i=(a)-1;i>=(b);i--)

ll order_in_fact(ll p, ll N) {
    ll ans = 0;
    ll q = p;
    while (q <= N) {
        ans += N / q;
        q *= p;
    }
    return ans;
}

int main() {
    ll N;
    cin >> N;
    ll two = 0;
    ll five = 0;
    if (N % 2 == 0) {
        two = N/2 + order_in_fact(2, N/2);
        five = order_in_fact(5, N/2);
    } else {
        two = order_in_fact(2, N+1) - (N+1)/2 - order_in_fact(2, (N+1)/2);
        five = order_in_fact(5, N+1) - order_in_fact(5, (N+1)/2);
    }
    cout << min(two, five) << endl;
}



Measured memory_bytes: 256
H,W,M = map(int,input().split())
Hinx = [0 for _ in range(H+1)]
Winx = [0 for _ in range(W+1)]
isExist = []
for i in range(M):
    h,w = map(int,input().split())
    Hinx[h] += 1
    Winx[w] += 1
    isExist.append((h,w))

HMinx = []
WMinx = []
Hmax = max(Hinx)
Wmax = max(Winx)
ans = Hmax + Wmax

isExist = set(isExist)
for i in range(1,H+1):
    if Hinx[i] == Hmax:
        HMinx.append(i)
for i in range(1,W+1):
    if Winx[i] == Wmax:
        WMinx.append(i)

cross = 0
not_cross = 0

flag = True
for i in HMinx:
    for j in WMinx:
        if (i,j) not in isExist:
            flag = False
            break
    if flag == False:
        break
if flag == False:
    print(ans)
else:
    print(ans-1)


Measured memory_bytes: 167100
#include <bits/stdc++.h>
#define int long long
using namespace std;
using Graph = vector<vector<int>>;

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

signed main() {
  int H, W;
  cin >> H >> W;
  
  vector<string> meiro(H);
  for( int i = 0; i < H; i++ ) cin >> meiro.at(i);
  
  
  int ans = 0;
  for( int i = 0; i < H; i++ ){
    for( int j = 0; j < W; j++ ){
      if( meiro.at(i).at(j) == '.' ){
        vector<vector<int>> dist(H, vector<int>(W, -1));
        queue<pair<int, int>> que;
        dist.at(i).at(j) = 0;
        que.push(make_pair(i, j));
        
        while (!que.empty()) {
        pair<int, int> current_pos = que.front();
        int x = current_pos.first;
        int y = current_pos.second;
        que.pop();

        // 隣接頂点を探索
        for (int direction = 0; direction < 4; ++direction) {
            int next_x = x + dx[direction];
            int next_y = y + dy[direction];
            if (next_x < 0 || next_x >= H || next_y < 0 || next_y >= W) continue;
            if (meiro[next_x][next_y] == '#') continue;

            
            if (dist[next_x][next_y] == -1) {
                que.push(make_pair(next_x, next_y));
                dist[next_x][next_y] = dist[x][y] + 1;
              if( ans < dist[next_x][next_y] ) ans = dist[next_x][next_y];
            }
        }
    }
      }
    }
  }
      
  cout << ans << endl;
  
  
    
}
  

  

Measured memory_bytes: 256
// B

#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll mod=1e9+7;

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


Measured memory_bytes: 256
N, K = map(int, input().split())
X = []
for i in range(N):
    x, y = map(int, input().split())
    X.append([i, x, y])

X = sorted(X, key = lambda x:x[2])[::-1]

p = 0
L = [0] * (N+1)
bonus = 0
for i in range(K):
    p += X[i][2]
    if L[X[i][1]] == 0:
        bonus += 1
        
    L[X[i][1]] += 1

p += bonus ** 2
ma = p
i = K-1
j = K
while True:
    while j < N and L[X[j][1]]:
        j += 1
    if j == N:
        break
    else:
        while i >= 0 and L[X[i][1]] <= 1:
            i -= 1
        if i < 0:
            break
        else:
            L[X[i][1]] -= 1
            L[X[j][1]] += 1
            p -= X[i][2]
            p += X[j][2]
            p += bonus * 2 + 1
            bonus += 1
            ma = max(ma, p)
            
    i -= 1
    j += 1
        
print(ma)



Measured memory_bytes: 25276
#include<iostream>
#include<set>
#include<algorithm>
#include<string>

using namespace std;


int main()
{
	int n;
	set<string> v;
	string buff,s;

	ios::sync_with_stdio(false);

	cin >> n;
	for (int i = 0; i != n; ++i)
	{
		cin >> buff>>s;
		if (buff == "insert")
		{
			v.insert(s);
		}
		else
		{
			if (v.find(s) != v.end())
			{
				cout << "yes" << endl;
			}
			else
			{
				cout << "no" << endl;
			}
		}
	} 

	return 0;

}


Measured memory_bytes: 29792