akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
    #include<algorithm>
    using namespace std;
    int d[300+5][300+5];
    int t[5][300+5],s[5][300+5];//3的余数为0,1,2——>枚举所有情况求最优值
    int n,c;
    int x,y,z,ans=(int)1E9;
    int solve(int x,int y)
    {
    	int ret=0;
    	for(int i=1;i<=c;i++)
    		ret+=t[x][i]*d[i][y];
    	return ret;
    }
    int main()
    {
    	scanf("%d %d",&n,&c);
    	for(int i=1;i<=c;i++)
    		for(int j=1;j<=c;j++)
    			scanf("%d",&d[i][j]);//颜色i变成颜色j的代价
    	for(int i=1;i<=n;i++)
    		for(int j=1;j<=n;j++)
    		{
    			scanf("%d",&x);
    			t[(i+j)%3][x]++;//余数为i,颜色为j的方格个数+1
    		}
    	for(int i=0;i<=2;i++)
    		for(int j=1;j<=c;j++)
    			s[i][j]=solve(i,j);
    	for(int i=1;i<=c;i++)
    		for(int j=1;j<=c;j++)
    			for(int k=1;k<=c;k++)
    			{
    				if(i!=j&&i!=k&&j!=k)
    					ans=min(ans,(s[0][i]+s[1][j]+s[2][k]));
    			}
    	printf("%d\n",ans);
    	return 0;
    }


Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int main(void)
{
	int a[4],x,i,min,s;
	x=0;
	for(i=0;i<4;i++){
		scanf("%d",&a[i]);
		x+=a[i];
	}
	min=x/60;
	s=x%60;
	printf("%d\n",min);
	printf("%d\n",s);
	return 0;
}
	

Measured memory_bytes: 1024
using System;
using System.Linq;

class Program
{
    static void Main(string[] args) {
        char[] s = Console.ReadLine().ToCharArray();
        char[] t = Console.ReadLine().ToCharArray();
        int n = s.Length;
        int m = t.Length;
        Array.Sort(s);
        Array.Sort(t);
        Console.WriteLine(solve1(s, t, n, m) || solve2(s, t, n, m) ? "Yes" : "No");
    }
    static bool solve1(char[] s, char[] t, int n, int m) {
        if(n < m) {
            for(int i = 0; i < n; i ++) {
                if(Array.IndexOf(t, s[i]) < 0) return false;
            }
            return true;
        }
        else return false;
    }
    static bool solve2(char[] s, char[] t, int n, int m) {
        Array.Reverse(t);
        for(int i = 0; i < Math.Min(n,m); i ++) if(s[i] < t[i]) return true;
        return false;
    }
}

Measured memory_bytes: 11348
fun main(args: Array<String>) {
    val (x, y) = readLine()!!.split(" ").map(String::toInt)
    val groups = listOf(listOf(1, 3, 5, 7, 8, 10, 12), listOf(4, 6, 9, 11), listOf(2))
    fun getGroup(n: Int): Int {
        /*return groups.mapIndexed { index, group -> index to group }
                .filter { pair -> n in pair.second }
                .map { pair -> pair.first }.first()*/
        return groups.indexOfFirst { group -> n in group }
    }
    println(if (getGroup(x) == getGroup(y)) "Yes" else "No")
}

Measured memory_bytes: 36012
#include<bits/stdc++.h>
#define LL long long
#define pb push_back
#define SZ(x) ((int)x.size()-1)
#define ms(a,b) memset(a,b,sizeof a)
#define F(i,a,b) for (int i=(a);i<=(b);++i)
#define DF(i,a,b) for (int i=(a);i>=(b);--i)
using namespace std;
inline int read(){
	char ch=getchar(); int w=1,c=0;
	for(;!isdigit(ch);ch=getchar()) if (ch=='-') w=-1;
	for(;isdigit(ch);ch=getchar()) c=(c<<1)+(c<<3)+(ch^48);
	return w*c;
}
const int M=100;
struct node{
	bool op;
	int x,y,z;
	node(bool _op=0,int _x=0,int _y=0,int _z=0){
		op=_op; x=_x; y=_y; z=_z;
	}
};
LL pw[M];
int B=100,ZERO=1e5,ONE=B,SUM=B*10,ANS=2;
vector<node> ans;
void GETBIT(int ind,int tmp,int BEG,bool *t){
	ans.pb(node(1,ind,ONE,ind));//target+1
	DF(i,30,0){
		ans.pb(node(1,tmp,B+i,tmp+1));//add
		ans.pb(node(0,tmp+1,ind,tmp+1));//compare
		ans.pb(node(0,ZERO,tmp+1,BEG+i));//restore
		F(j,1,i) ans.pb(node(1,tmp+1,tmp+1,tmp+1));//pow
		ans.pb(node(1,tmp+1,tmp,tmp));//add
	}
}
bool ta[M],tb[M]; 
int main(){
	ans.pb(node(1,0,1,SUM));
	ans.pb(node(0,ZERO,SUM,ONE)); pw[0]=1;
	F(i,1,60) pw[i]=pw[i-1]*2,ans.pb(node(1,B+i-1,B+i-1,B+i));
	GETBIT(0,5*B,2*B,ta);
	GETBIT(1,6*B,3*B,tb);
	DF(i,60,0){
		ans.pb(node(1,ANS,ANS,ANS));
		int tmp=7*B+i;
		F(j,0,min(30,i)){
			int k=i-j;
			if (j<=30 && k<=30){
				ans.pb(node(1,2*B+j,3*B+k,tmp+1));
				ans.pb(node(0,ONE,tmp+1,tmp+1));
				ans.pb(node(1,tmp+1,ANS,ANS));
			}
		}
	}
	cout<<SZ(ans)+1<<"\n";
	F(i,0,SZ(ans)){
		cout<<(ans[i].op ? "+ " : "< ")<<ans[i].x<<" "<<ans[i].y<<" "<<ans[i].z<<"\n";
	}
	return 0;
}


Measured memory_bytes: 3728
#include<bits/stdc++.h>
using namespace std;
const int maxn=200020;
vector<int> G[maxn];
int n;
int u,v;
int white,black;
int pre[maxn],book[maxn],dep[maxn];
bool vis[maxn];
void dfs2(int x,int f) {
	for(int i=0;i<G[x].size();i++) {
		int v=G[x][i];
		if(vis[v])
			continue;
		if(book[v]==0||book[v]==f) {
			if(f==1&&book[v]==0)
				black++;
			else if(f==2&&book[v]==0)
				white++;
			book[v]=f;
			vis[v]=1;
			dfs2(v,f);
		}
	}
}
void dfs(int r) {
	vis[r]=1;
	for(int i=0;i<G[r].size();i++) {
		int v=G[r][i];
		if(vis[v])
			continue;
		dep[v]=dep[r]+1;
		pre[v]=r;
		dfs(v);
	}
}
int main() {
	memset(pre,-1,sizeof pre);
	memset(book,0,sizeof book);
	memset(vis,0,sizeof vis);
	scanf("%d",&n);
	for(int i=1;i<=n-1;i++) {
		scanf("%d%d",&u,&v);
		G[u].push_back(v);
		G[v].push_back(u);
	}
	dep[1]=0;
	dfs(1);
	memset(vis,0,sizeof vis);
	book[1]=1;
	book[n]=2;
	vis[1]=vis[n]=1;
	for(int i=pre[n];i!=1;i=pre[i]) {
//		cout<<i<<endl;
		if(dep[i]>dep[n]/2) {
			white++;
			book[i]=2;
		}
		else {
			black++;
			book[i]=1;
		}
	}
	dfs2(1,1),dfs2(n,2);
//	cout<<black<<" "<<white<<endl; 
	if(black>white) {
		puts("Fennec");
		return 0;
	}
	else {
		puts("Snuke");
		return 0;
	}
	return 0;
}

Measured memory_bytes: 14848
#include <bits/stdc++.h>
#define pii pair<int, int>
#define F first
#define S second
#define int long long
using namespace std;
const int MX = 1e5 + 100;
const int oo = 1ll << 30;
main () {
	int n, k; cin >> n >> k;
	if(k == 1) cout << 0;
	else       cout << n - k;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n)for(int i=0;i<(int)(n);i++)
#define PI 3.141592653589793
//vector < vector<int>>a(0, vector<int>(0));二次元配列宣言


int main()
{
	int a, b,c;
	cin >> a >> b>>c;
	if (a + b + c >= 22)
		cout << "bust" << endl;
	else
		cout << "win" << endl;
}

Measured memory_bytes: 3560
/*
ID: zhaowei10
TASK:
LANG: C++
*/
#include <algorithm>
#include <array>
#include <climits>
#include <cmath>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

#define pb push_back
#define MOD 1000000007
#define FOR(i, j, k, l) for (s32 i = j; i < k; i += l)
#define RFOR(i, j, k, l) for (s32 i = j; i >= k; i -= l)
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define ALL(x) x.begin(), x.end()
#define MEAN(a, b) min(a, b) + (abs(b - a) >> 1)
#define FASTIO()    \
  cin.tie(nullptr); \
  ios::sync_with_stdio(false);

typedef int64_t s64;
typedef uint64_t u64;
typedef int32_t s32;
typedef uint32_t u32;
typedef float f32;
typedef double f64;
typedef pair<s32, s32> II;
typedef pair<s64, s64> LL;
typedef vector<s32> VI;
typedef vector<II> VII;
typedef vector<char> VC;
typedef vector<VII> VVII;
typedef priority_queue<s32> PQI;
typedef priority_queue<s32, VI, greater<s32>> PQIA;
typedef priority_queue<s64> PQL;
typedef priority_queue<II> PQII;
typedef priority_queue<II, VII, greater<II>> PQIIA;
typedef priority_queue<LL> PQLL;
typedef unordered_set<s32> USI;
typedef unordered_set<s64> USL;
typedef set<II> SII;
typedef multiset<s32> MSI;

template <typename T, typename U>
inline void amin(T &x, U y) {
  if (y < x) x = y;
}
template <typename T, typename U>
inline void amax(T &x, U y) {
  if (x < y) x = y;
}

template <typename T>
inline s32 ndigits(T x) {
  s32 r = 0;
  while (x) {
    x /= 10;
    ++r;
  }
  return r;
}

inline bool prime(s32 x) {
  if (x <= 3) return x > 1;
  if (!(x & 1) || !(x % 3)) return false;

  for (s32 i = 5; i * i <= x; i += 6) {
    if (!(x % i) || !(x % (i + 2))) return false;
  }
  return true;
}

int main() {
  FASTIO();

  s32 x;
  cin >> x;

  for (s32 i = x;; ++i) {
    if (prime(i)) {
      cout << i;
      return 0;
    }
  }
}

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

int main(){
  int n,ans;
  cin >> n;
  string N = to_string(n);
  vector<int> num(N.length(),0);
  int tmp = 1;
  for(int i = 0;i < N.length();i++){
	if(i % 2 == 0){
    num.at(i) += 9 * tmp;
    }
    tmp *= 10;
  }
  
  for(int j = 0;j < N.length()-1;j++){
	ans += num.at(j);
  }
  if(N.length()%2 != 0){
  tmp /= 10;
  ans += n - tmp + 1;
  }

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

Measured memory_bytes: 256
import java.util.*;import java.io.*;import java.math.*;
public class Main
{
    public static void process()throws IOException
    {
        long x=Math.abs(nl());
        long k=nl();
        long d=nl();
        long dis=Math.min(x/d,k);
        x-=(dis*d);
        k=(k-dis)%2;
        if(k==1)
            x=Math.abs(x-d);
        pn(Math.abs(x));
        
    }
    static AnotherReader sc;
    static PrintWriter out;
    public static void main(String[]args)throws IOException
    {
        boolean oj = true;
        if(oj){sc=new AnotherReader();out=new PrintWriter(System.out);}
        else{sc=new AnotherReader(100);out=new PrintWriter("output.txt");}
        int t=1;
        // t=ni();
        while(t-->0) {process();}
        out.flush();out.close();  
    }

    static void pn(Object o){out.println(o);}
    static void p(Object o){out.print(o);}
    static void pni(Object o){out.println(o);out.flush();}
    static int ni()throws IOException{return sc.nextInt();}
    static long nl()throws IOException{return sc.nextLong();}
    static double nd()throws IOException{return sc.nextDouble();}
    static String nln()throws IOException{return sc.nextLine();}
    static int[] nai(int N)throws IOException{int[]A=new int[N];for(int i=0;i!=N;i++){A[i]=ni();}return A;}
    static long[] nal(int N)throws IOException{long[]A=new long[N];for(int i=0;i!=N;i++){A[i]=nl();}return A;}
    static long gcd(long a, long b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int gcd(int a, int b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int bit(long n)throws IOException{return (n==0)?0:(1+bit(n&(n-1)));}

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

    static class AnotherReader{BufferedReader br; StringTokenizer st;
    AnotherReader()throws FileNotFoundException{
    br=new BufferedReader(new InputStreamReader(System.in));}
    AnotherReader(int a)throws FileNotFoundException{
    br = new BufferedReader(new FileReader("input.txt"));}
    String next()throws IOException{
    while (st == null || !st.hasMoreElements()) {try{
    st = new StringTokenizer(br.readLine());}
    catch (IOException  e){ e.printStackTrace(); }}
    return st.nextToken(); } int nextInt() throws IOException{
    return Integer.parseInt(next());}
    long nextLong() throws IOException
    {return Long.parseLong(next());}
    double nextDouble()throws IOException { return Double.parseDouble(next()); }
    String nextLine() throws IOException{ String str = ""; try{
    str = br.readLine();} catch (IOException e){
    e.printStackTrace();} return str;}}
   
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
}

Measured memory_bytes: 32964
// AOJ DSL_5_B The Maximum Number of Overlaps
// 2018.5.5 bal4u

#include <stdio.h>

#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
int in()
{
	int n = 0, c = gc();
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

int s[1002][1002];

/* imos法で解く
   いもす法では，矩形の左上 に +1 を，右上 に −1 を，
   左下 に −1 を，右下 に +1 を加算して、累積和を取る．
   記録には O(N) が，累積和の計算には O(WH) がかかり，
   全体の計算量は O(N+WH)．
*/
int main()
{
	int N, i, ans;
	int x, y, xmin, ymin, xmax, ymax;

	xmin = ymin = 1000,	xmax = ymax = 0;

	N = in();
	for (i = 0; i < N; i++) {

		// 左上(x1,y1)、右下(x2, y2)。原点は左上
		int x1 = in(), y1 = in(), x2 = in(), y2 = in();
		s[y1][x1]++, s[y2][x1]--;
		s[y1][x2]--, s[y2][x2]++;

		if (x1 < xmin) xmin = x1;
		if (x2 > xmax) xmax = x2;
		if (y1 < ymin) ymin = y1;
		if (y2 > ymax) ymax = y2;
	}

	// x軸方向の累積和
	for (y = ymin; y <= ymax; y++) for (x = xmin+1; x <= xmax; x++)
		s[y][x] += s[y][x-1];

	// y軸方向の累積和
	for (y = ymin+1; y <= ymax; y++) for (x = xmin; x <= xmax; x++)
		s[y][x] += s[y-1][x];
	
	ans = 0;
	for (y = ymin; y <= ymax; y++) for (x = xmin; x <= xmax; x++)
		if (s[y][x] > ans) ans = s[y][x];

	printf("%d\n", ans);
	return 0;
}



Measured memory_bytes: 5688
///
// File:  alds1_1_a.cpp
// Author: ymiyamoto
//
// Created on Wed Oct  4 01:04:46 2017
//

#include <cstdint>
#include <iostream>
#include <vector>
using namespace std;

static vector<uint32_t> array;

void insersion_sort()
{
  for (uint32_t i = 0; i < array.size(); i++) {
    for (uint32_t j = i; j > 0; j--) {
      if (array[j - 1] > array[j]) {
        swap(array[j - 1], array[j]);
      }
    }

    for (uint32_t k = 0; k < array.size(); k++) {
      if (k != 0) {
        cout << " ";
      }
      cout << array[k];
    }
    cout << endl;
  }
}

int32_t main()
{
  uint32_t N;
  cin >> N;

  for (uint32_t i = 0; i < N; i++) {
    uint32_t val;
    cin >> val;
    array.push_back(val);
  }

  insersion_sort();

  return 0;
}

Measured memory_bytes: 3136
n = int(input())
l0 = 2
l1 = 1
cnt = 2
l2 = l0 + l1
while cnt < n:
    l2, l1, l0 = l2 + l1, l2, l1
    cnt += 1
if n == 1:
    print(1)
else:
    print(l2)

Measured memory_bytes: 38384
import sys
import itertools
input = sys.stdin.readline

n = int(input())
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))

l = list(range(1, n+1))

i = 0
s = 0
t = 0
#print(p)
for v in itertools.permutations(l):
    #print(v)
    if v == p:
        s = i
    if v == q:
        t = i
    
    i += 1

print(abs(t - s))


Measured memory_bytes: 67764
import math

a,b,h,m = (int(x) for x in input().split())

hun = 6*m
zi = 30*h + m/2

diff = abs(hun-zi)
if diff > 180:
    diff = 360-diff
    
#print(diff)

x = a*a+b*b - 2*a*b*math.cos(math.radians(diff))
print(math.sqrt(x))



Measured memory_bytes: 9440
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define inf 500000000
#define IOS ios_base::sync_with_stdio(0)
#define meM(y,a) memset(y,a,sizeof y)
#define sC(a) scanf("%d",&a)
#define alL(a) a.begin(),a.end()
#define prinT(a,sz)  cout<<a[0];for(int i=1;i<sz;i++)cout<<" "<<a[i];cout<<endl
#define ranD srand(chrono::steady_clock::now().time_since_epoch().count());
typedef pair<int,int>pi;
typedef pair<ll,ll>pll;
//int fx[]={0,0,1,-1};
//int fy[]={1,-1,0,0};
//int gx[]={0,0,1,1,1,-1,-1,-1};
//int gy[]={1,-1,0,1,-1,0,1,-1};
bool check(int n,int p){return (1<<p)&n;}
char ara[100][100],b[100][100];
int n,m;
bool found(int x,int y)
{
    for(int i=0;i<m;i++)
    {
        for(int j=0;j<m;j++)
        {
            if(b[i][j]!=ara[i+x][j+y])return 0;
        }
    }
    return 1;
}
int main()
{
    IOS;
    cin>>n>>m;
    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)cin>>ara[i][j];
    for(int i=0;i<m;i++)
        for(int j=0;j<m;j++)
        cin>>b[i][j];
    bool flag=0;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            if(found(i,j))
            {
                flag=1;
//                cout<<"found at "<<i<<" "<<j<<endl;
            }
        }
        if(flag)break;
    }
    if(flag)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}








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

typedef long long int Long;

int gcd(Long a, Long b) {
  return b == 0 ? a : gcd(b, a%b);
}

int lcm(Long t, Long ab) {
  return ab / t;
}

int main() {
  Long a, b, t;
  while (cin >> a >> b) {
    t = gcd(a, b);
    cout << t << " " << lcm(t, a*b) << endl;
  }
  return 0;
}

Measured memory_bytes: 2924
/***************************************************************************
                                AUTHOR: SPARSH SINHA
            **************************************************************************/


#include <bits/stdc++.h>
using namespace std;
#define si(N) scanf("%d",&N);
#define sll(N) scanf("%lld",&N);
#define ss(s) scanf("%s",s);
#define ll long long int
#define pi pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define eb emplace_back
#define rep(i,a,b) for(int i = a; i<=b;i++)
#define fori(i,n) for(int i = 0 ; i < n; i++)
#define umapii unordered_map<int,int>
#define umapll unordered_map<ll,ll>
#define mapll map<ll,ll>
#define mapii map<int,int>
#define debug(x)       cerr<< #x <<" : "<<x<<endl;
#define debuga(A,N)    cerr<< #A <<" : [";for(int i = 0; i<N;i++) cerr<<A[i]<<" "; cerr<<"]\n";
#define debuga2(A,N,M) cerr<< #A << " : \n"; for(int i=0;i<N;i++){cerr<<"[";for(int j=0;j<M;++j) cerr<<A[i][j]<<" ";cerr<<"]\n";}
#define debugp(p)      cerr<< #p <<" : "<<"("<<(p).first<<","<<(p).second<<")\n";
#define debugv(v)      cerr<< #v <<" : "<<"[";for(int i = 0; i< (v).size(); i++) cerr<<v[i]<<" "; cerr<<"]\n";
#define debugv2(v)     cerr<< #v << " : \n"; for(int i=0;i<v.size();i++){cerr<<"[";for(int j=0;j<(v[0].size());++j) cerr<<v[i][j]<<" ";cerr<<"]\n";}
#define debugs(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin(); itr!=m.end();itr++) cerr<<*itr<<" "; cerr<<"]\n";
#define debugm(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin();itr!=m.end(); itr++) cerr<<"("<<itr->first<<","<<itr->second<<") ";cerr<<"]\n";
const int INF = 1e9 + 7;

int N;
int query(vector<ll> e, vector<ll> o , int i){
     //return the sum from i upto next N/2 terms

     int to_sum_upto = N/2; 
     // cout<<"to calcualate sum upto "<<to_sum_upto;
     int to_start_from ;
     ll s ;
     if( i%2 == 0){
          to_start_from = i/2;
          s =  e[to_start_from + to_sum_upto - 1] - e[to_start_from - 1];
     }
     else{
          to_start_from = (i + 1)/2;
          s =  o[to_start_from + to_sum_upto - 1] - o[to_start_from - 1];
     }
     // cout<<" starting from " << to_start_from <<endl;
     // cout<<"returning "<< s <<endl;
     return s;
}
int main()
{
     ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0);
        cin>>N;
        vector<ll> A(N + 1 , 0 );
        vector<ll> mountain(N + 1, 0);
        rep(i , 1 , N) cin>>A[i];
        ll s = 0;
        rep(i, 1, N)  s = s + ((i & 1)?A[i]: -A[i]);
        mountain[1] = s;
        rep(i , 2 , N) { mountain[i] =  A[i - 1] - (mountain[i - 1]/2); mountain[i] = (mountain[i] << 1);}
        rep(i , 1 , N) cout<<mountain[i]<<" ";
        cout<<"\n";
}

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

int main() {
	int n;
	cin >> n;
	vector<string> ss(n);
	set<string> st;
	rep(i, n) { 
		cin >> ss[i];
		if (i) {
			if (ss[i][0] != ss[i - 1].back()) {
				puts("No");
				return 0;
			}
		}
		if (st.count(ss[i])) {
			puts("No");
			return 0;
		}
		st.insert(ss[i]);
	}
	puts("Yes");
        return 0;
}


Measured memory_bytes: 256
n = int(input())
taro = 0
hanako = 0
for i in range(n):
    vs = list(input().split())
    if vs[0] == vs[1]:
        taro+=1
        hanako+=1
        continue
    short = min(len(vs[0]), len(vs[1]))
    if vs[0][:short] == vs[1][:short]:
        if len(vs[0]) == short:
            hanako += 3
        else:
            taro += 3
        continue
    for j in range(short):
        if ord(vs[0][j]) < ord(vs[1][j]):
            hanako += 3
            break
        elif ord(vs[0][j]) > ord(vs[1][j]):
            taro += 3
            break
print(str(taro) + " " + str(hanako))


Measured memory_bytes: 5596
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<string>
#include<algorithm>
using namespace std;
const int MaxN = 1e5;

int main()
{
	int n,ans;
	while(~scanf("%d",&n))
	{
		ans = n/3;
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<string>
#include<iterator>
#include<cmath>
using namespace std;

int main()
{
   int N, i, count=0, a;
   cin>>N;
   for(i=1;i<=N;i+=1)
   {
       cin>>a;
       if(i%2!=0 && a%2!=0)
       {
           count+=1;
       }
   }
   cout<<count<<endl;
}


Measured memory_bytes: 3632
#pragma GCC optimize("O3")

#include<bits/stdc++.h>
#define sp " "
#define endl "\n"
#define MAX 10e9
#define MAXN 100001 
#define inf_int 2e9
#define inf_ll 2e18
#define e 1e-9
#define vi vector<int>
#define vl vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpl vector<pair<ll,ll>>
#define vpc vector<pair<char,char>>
#define adj_list vector<vl> 
#define umap unordered_map<ll, ll>
#define pll pair<ll,pair<ll, ll>>
#define clr(x) memset(x,0,sizeof(x))
#define set(x,k) memset(x,k,sizeof(x))
#define cy cout << "YES" << endl
#define  cn cout << "NO" << endl
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
typedef long long int ll;

ll spf[MAXN]; 
void sieve() 
{ 
    spf[1] = 1; 
    for (auto i=2; i<MAXN; i++) 
  		spf[i] = i; 
  	for (auto i=4; i<MAXN; i+=2) 
        spf[i] = 2; 
    for (auto i=3; i*i<MAXN; i++) 
    {
        if (spf[i] == i) 
        { 
            for (auto j=i*i; j<MAXN; j+=i) 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
	return;
} 

vl getFactorization(ll x) 
{ 
    vl ret; 
    while (x != 1) 
    { 
        ret.push_back(spf[x]); 
        x = x / spf[x]; 
    } 
    return ret; 
} 


void check()
{
	ll n,d, ans = 0;
	cin >> n >> d;
	vl a(n), b(n);
	for(int i=0;i<n;i++) cin >> a[i] >> b[i];
	for(int i=0;i<n;i++) {
		if(sqrt((a[i]*a[i])+(b[i]*b[i]))<=d)
			ans++;
	}
	cout << ans << endl;
    return ;
}

int32_t main()
{
    fastio;
    ll t = 1;
    // cin >> t;
    while(t--)
        check();
    return 0;
}

Measured memory_bytes: 6376
#include<iostream>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define int long long
#define pi 3.141592653589793238462643383279502
#define M 1000000007
#define F first
#define S second
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
bool isPowerOfTwo(int n)
{
   if(n==0)
   return false;

   return (ceil(log2(n)) == floor(log2(n)));
}
int power(int x, unsigned int y)
{
    if (y == 0)
        return 1;
    else if (y % 2 == 0)
        return power(x, y / 2) * power(x, y / 2);
    else
        return x * power(x, y / 2) * power(x, y / 2);
}
int findXor(int arr[], int n)
{

    // Calculate xor of all the elements
    int xoR = 0;
    for (int i = 0; i < n; i++) {
        xoR = xoR ^ arr[i];
    }

    // Return twice of xor value
    return xoR * 2;
}

signed main()
{
   int n,a,b;
   cin>>n>>a>>b;
   int x=n/(a+b);
   int ans=x*a;
   int y=n%(a+b);
   if(y>=a)
    ans+=a;
   else
    ans+=y;
   cout<<ans<<endl;
}





Measured memory_bytes: 256
n, l = map(int, input().split())
a = list(map(int, input().split()))
b = [a[i]+a[i+1] for i in range(n-1)]
start = -1
for ind, length in enumerate(b):
    if length >= l:
        start = ind+1
        break
if start<0:
    print("Impossible")
else:
    print("Possible")
    for i in range(1,start):
        print(i)
    for i in range(start, n)[::-1]:
        print(i)


Measured memory_bytes: 14304
import sys
sys.setrecursionlimit(10**7)
N = int(input())
G = [[] for _ in range(N+1)]
for _ in range(N-1):
    a, b, c = map(int, input().split())
    G[a].append((b, c))
    G[b].append((a, c))
Q, K = map(int, input().split())


d = [-1]*(N+1)


def dfs(v, c):
    d[v] = c
    for nv, cost in G[v]:
        if d[nv] == -1:
            dfs(nv, cost+c)

dfs(K, 0)

for _ in range(Q):
    x, y = map(int, input().split())
    print(d[x]+d[y])


Measured memory_bytes: 133556
#include<bits/stdc++.h> 
using namespace std;
int main()
{	
  	int n;
  	cin >> n;
  	if(n % 10 == 9 || n/10 == 9)
      cout << "Yes" << endl;
 	else 
      cout << "No" << endl;
 	return 0; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define N 100010
int a[N];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    sort(a+1,a+1+n);
    int m=a[1],m2=1000000010;
    while(1)
    {
        for(int i=1;i<=n;i++)
        {
            if(a[i]%m!=0)
                m=a[i]%m;
        }
        if(m==m2)
            break;

        m2=min(m,m2);
    }
    cout<<m<<endl;
    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
using namespace std;
using lli = long long int;

int main(){
  int n;
  std::cin >> n;
  vector<lli> a(n);
  for (int i = 0; i < n; i++) std::cin >> a[i];
  if(a[0] < 0)for (int i = 0; i < n; i++) a[i] = -a[i];  
  lli ans = 0, sum = 0;
  for (int i = 0; i < n; i++) {
    if(i%2){//minus
      if(sum + a[i] >= 0){
        ans += sum + a[i] + 1; 
        sum = -1;
      }else{
        sum += a[i];
      }
    }else{//plus
      if(sum + a[i] <= 0){
        ans += -(sum + a[i]) + 1;
        sum = 1;
      }else{
        sum += a[i];
      }
    }
  }
  lli ans2 = 0;
  sum = 0;
  for (int i = 0; i < n; i++) {
    if(i%2){//plus
      if(sum + a[i] <= 0){
        ans2 += -(sum + a[i]) + 1;
        sum = 1;
      }else{
        sum += a[i];
      }
    }else{//minus
      if(sum + a[i] >= 0){
        ans2 += sum + a[i] + 1; 
        sum = -1;
      }else{
        sum += a[i];
      }
    }
  }
  ans = min(ans2, ans);
  std::cout << ans << std::endl;
  return 0;
}



Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>

#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)

using lint = long int;
using llint = long long int;
using namespace std;

int main() {
    fastIO;
    int n;
    cin >> n;
    for (int i = 1; i <= 9; i++) {
        for (int j = 1; j <= 9; j++) {
            if (i * j == n) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 3648
/**
 * Created by hiramekun at 20:47 on 2019-11-24.
 */
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for(auto& i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template<class T>
istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template<class T>
ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

void solve() {
    ll n, k;
    cin >> n >> k;
    vl a(n);
    cin >> a;
    vl d(n + 1);

    rep(i, n) {
        d[i + 1] = d[i] + a[i];
        d[i + 1] %= k;
    }
    ump<ll, ll> mp;
    ll ans = 0;
    queue<ll> que;
    rep(r, n + 1) {
        ll t = (d[r] - r) % k;
        if (t < 0) t += k;
        ans += mp[t];
        mp[t]++;
        que.push(t);
        if (que.size() >= k) {
            mp[que.front()]--;
            que.pop();
        }
    }
    cout << ans << '\n';
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 13256
n=int(input())
v=list(map(int, input().split()))
even=[0]*(10**6 + 1)
odd=[0]*(10**6 + 1)



for i in range(n):
    if i%2==0:
        even[v[i]]+=1
    else:
        odd[v[i]]+=1

a=max(even)
M=even.index(a)
even[M]=0
a_second=max(even)
even[M]=a

b=max(odd)
N=odd.index(b)
odd[N]=0
b_second=max(odd)
odd[N]=b


if M!=N:
    ans=sum(even)-a + sum(odd)-b
    print(ans)
else:
    ans=min(sum(even)-a + sum(odd)-b_second, sum(even)-a_second + sum(odd)-b)
    print(ans)

Measured memory_bytes: 68448
//Utkarsh-raj

#include<bits/stdc++.h>

#define ll long long int
#define vc vector
#define mod 100000000007
#define mp make_pair
#define pb push_back
#define nl cout<<endl;
#define ff first
#define ss second

using namespace std;

void dfs(int root, vector<int> &vis, vector<int> &dis, vector<int> v[]){
    vis[root] = 1;
    dis[root] = 0;

    for(int child : v[root]){
        if(!vis[child]){
            dfs(child, vis, dis, v);
            dis[root] = max(dis[root], dis[child] + 1);
        }
        else{
            dis[root] = max(dis[root], dis[child] + 1);
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ifstream myFile("task.in");
    if(!myFile.fail())
    {
        assert(freopen("task.in", "r", stdin));
    }

    int n, m;
    cin>>n>>m;

    vector<int> v[n+1];
    for(int i=0; i<m; i++){
        int x, y;
        cin>>x>>y;
        v[x].push_back(y);
    }

    vector<int> vis(n+1, 0);
    vector<int> dis(n+1, 0);

    for(int i=1; i<=n; i++){
        if(!vis[i]){
            dfs(i, vis, dis, v);
        }
    }

    int ans = 0;
    for(int i=1; i<=n; i++){
        ans = max(ans, dis[i]);
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 12860
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Runtime.InteropServices;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const long Mod = 1000000007;
    const char White = '.';
    const char Black = '#';

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var spl = input.ReadLine().Split(' ');
        var h = int.Parse(spl[0]);
        var w = int.Parse(spl[1]);
        var n = int.Parse(input.ReadLine());
        var ary = ToIntArray(input.ReadLine(), n);

        var tbl = new int[h][];
        for(int i=0; i<h; i++) {
            tbl[i] = new int[w];
        }

        int idx = 0;
        for(int i=0; i<h; i++) {
            for(int j=0; j<w; j++) {
                var jj = i % 2 == 0 ? j : w - j - 1;

                while (ary[idx] == 0) idx++;
                tbl[i][jj] = idx + 1;
                ary[idx]--;
            }
        }

        var sb = new StringBuilder();
        for(int i=0; i<h; i++) {
            for(int j=0; j<w; j++) {
                if(j > 0) sb.Append(' ');
                sb.Append(tbl[i][j]);
            }
            sb.AppendLine();
        }

        return sb;
    }


    static int[] ToIntArray(string strs, int n) {
        var ret = new int[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = int.Parse(spl[i]);
        return ret;
    }
}


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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
using ll = long long;


int main() {
    int d, t, s; cin >> d >> t >> s;
    if((d + s - 1) / s <= t) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 3632
N,K,Q=map(int,input().split())
A=[]
B=[]
for i in range(Q):
  A.append(int(input()))
c=0
for j in range(N):
  B.append(int(0))
for z in range(Q):
  x=A[z]
  B[x-1]=B[x-1]+1
for g in range (N):
  if B[g]>(Q-K):
    print("Yes")
  else:
    print("No")

Measured memory_bytes: 8592
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.util.Arrays;
import java.util.Objects;

public class Main{
    public static void main(String[] args){
        FastScanner sc = new FastScanner();

        int n = sc.nextInt();
        int[] a = new int[n];
        long sum = 0;
        for(int i=0;i<n;i++){
            a[i] = sc.nextInt();
            sum += a[i];
        }
        Arrays.sort(a);
        System.out.println(a[0]+" "+a[n-1]+" "+sum);

    }

    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(String s) {
            try {
                br = new BufferedReader(new FileReader(s));
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
        }

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String nextToken() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(nextToken());
        }

        long nextLong() {
            return Long.parseLong(nextToken());
        }

        double nextDouble() {
            return Double.parseDouble(nextToken());
        }
    }
}



Measured memory_bytes: 29032
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(long long int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){

    vector<vector<long long int>> grid(3,vector<long long int>(3));
    REP(i,3){
        REP(j,3){
            cin>>grid[i][j];
        }
    }
    vector<vector<bool>> grid_hantei(3,vector<bool>(3,false));
    long long int n;
    cin >> n;
    long long int tmp;
    REP(i,n){
        cin >> tmp;
        REP(j,3){
            REP(k,3){
                if(grid[j][k]==tmp){
                    grid_hantei[j][k] = true;
                }
            }
        }
    }
    REP(i,3){
        if(grid_hantei[i][0]&&grid_hantei[i][1]&&grid_hantei[i][2]){
            cout << "Yes" << endl;
            return 0;
        }
        if(grid_hantei[0][i]&&grid_hantei[1][i]&&grid_hantei[2][i]){
            cout << "Yes" << endl;
            return 0;
        }

    }
    if(grid_hantei[0][0]&&grid_hantei[1][1]&&grid_hantei[2][2]){
            cout << "Yes" << endl;
            return 0;
        }
    if(grid_hantei[2][0]&&grid_hantei[1][1]&&grid_hantei[0][2]){
            cout << "Yes" << endl;
            return 0;
        }
    
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
 
using namespace std;
 
int main(){
    int H, W, A, B;
    cin >> H >> W >> A >> B;
    for(int i=0;i<H;++i){
        for(int j=0;j<W;++j){
            if(i < B){
                if(j < A){
                    cout << 1;
                }
                else{
                    cout << 0;
                }
            }
            else{
                if(j < A){
                    cout << 0;
                }
                else{
                    cout << 1;
                }
            }
        }
        cout << endl;
    }
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using boost::multiprecision::cpp_int;
using namespace std;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

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

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


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

  int a;
  cin >> a;
  cout << a + a*a + a*a*a << endl;
}


Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
#include <set>
#include <queue>
#include <list>
using namespace std;
typedef long long ll;

void solve() {
	int n; cin >> n;
	vector<ll> v(n);
	for (ll &i : v)cin >> i;
	ll sum = accumulate(v.begin(), v.end(), 0ll);
	map<ll, int> m;
	for (ll i : v)m[i]++;
	int q; cin >> q;
	while (q--) {
		ll a, b; cin >> a >> b;
		sum += m[a] * (b - a);
		m[b] += m[a];
		m[a] = 0;
		cout << sum << endl;
	}
}

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

	// int t; cin >> t;
	// while (t--)
	solve();

}

Measured memory_bytes: 10012
#
# abc096 c
#

import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """5
WEEWW"""
        output = """1"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """12
WEWEWEEEWWWE"""
        output = """4"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """8
WWWWWEEE"""
        output = """3"""
        self.assertIO(input, output)


def resolve():
    N = int(input())
    S = list(input())

#    ans = float("inf")
#    for i in range(N):
#        if i == 0:
#            ans = min(ans, S[1:].count("E"))
#        elif i == N-1:
#            ans = min(ans, S[0:N-1].count("W"))
#        else:
#            ans = min(ans, S[0:i].count("W") + S[i+1:].count("E"))
#    print(ans)

    W = [0] * N
    E = [0] * N
    L = 0
    R = 0

    for i in range(N):
        if S[i] == "W":
            L += 1
        if S[N-1-i] == "E":
            R += 1
        W[i] = L
        E[N-1-i] = R

    ans = float("inf")
    for i in range(N):
        ans = min(ans, E[i]+W[i]-1)
    print(ans)


if __name__ == "__main__":
    # unittest.main()
    resolve()


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

#define mp make_pair
#define pb push_back
#define el cout<<endl;
#define flog(n) 31-__builtin_clz((n))
#define clog(n) 32-__builtin_clz((n)-1)
#define fori(i,a,b) for(int i=(a);i<=(b);i++)
#define forib(i,a,b) for(int i=(a);i>=(b);i--)
#define rep(n) fori(asdasdasd_RaNdOm_VaRiAbLe_NaMe_asdasdasd,1,(n))

using ui=unsigned int;
using ll=long long; using pi=pair<int,int>;
#define vec vector
using vb=vec<bool>; using vc=vec<char>; using vs=vec<string>; using vi=vec<int>; using vl=vec<ll>; using vpi=vec<pi>;
using sb=set<bool>; using sc=set<char>; using ss=set<string>; using si=set<int>; using sl=set<ll>; using spi=set<pi>;

void solve() {
    int n; cin>>n;
    switch(n%10){
        case 3:
            cout<<"bon ";
            break;
        case 0:
        case 1:
        case 6:
        case 8:
            cout<<"pon ";
            break;
        case 2:
        case 4:
        case 5:
        case 7:
        case 9:
            cout<<"hon ";
            break;
    }
}

int main() {
    if(false){
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    }
    int t=1;
    //cin>>t;
    rep(t) solve();
    return 0;
}


Measured memory_bytes: 3620
#include <iostream>
using namespace std;
using ll = long long;
int main()
{
    ll x;
    cin >> x;
    ll ans = (x / 11 * 2);
    if (x % 11 > 0)
        ++ans;
    if (x % 11 > 6)
        ++ans;
    cout << ans << endl;
}

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

using namespace std;

#define DIM 200009
#define INF 1e18+9
#define MODULO 1000000007

long long i,j,k,l,n,m,flag;

long long a[22][22],dp[22][3000000];

long long get(long long k,long long mask){
    if(dp[k][mask]!=-1)return dp[k][mask];
    if(__builtin_popcountll(mask)==0)return 1;
    dp[k][mask]=0;
    for(int i=1;i<=n;i++){
        if(mask&(1<<(i-1)) && a[k][i]==1){
            dp[k][mask]=(dp[k][mask]+get(k-1,mask-(1<<(i-1))))%MODULO;
        }
    }

    /*cout<<k<<' ';
    for(int i=0;i<n;i++)cout<<((mask&(1<<i))!=0?1:0);
    cout<<' '<<dp[k][mask]<<endl;
*/
    return dp[k][mask];
}

int main()
{
    memset(dp,-1,sizeof(dp));
    cin>>n;
    for(i=1;i<=n;i++){
        flag=0;
        for(j=1;j<=n;j++){
            cin>>a[i][j];
            flag|=a[i][j];
        }
        if(!flag)return cout<<0<<endl,0;
    }

    cout<<get(n,(1<<n)-1)<<endl;

    return 0;
}


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

const ll INF = pow(10, 9) + 7;

int main() {
  ll n;
  cin >> n;
  if((n%10)%2==1){
    cout << 0 << endl;
    return 0;
  }
  ll ans =0;
  n /=10;
  ans += n;
  while(n!=0){
    n /= 5;
    ans += n;
  }
  cout << ans << endl;
}

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

#define all(v) v.begin(), v.end()
#define V vector
#define P pair
typedef long long ll;
const int INT_INF = 1e9;
const ll INF = 1LL << 30;

int main() {
    string s; cin >> s;
    int n = s.size();
    if(s[n - 1] == '2' || s[n - 1] == '4' || s[n - 1] == '5' || s[n - 1] == '7' || s[n - 1] == '9'){
        cout << "hon" << endl;
    }else if(s[n - 1] == '0' || s[n - 1] == '1' || s[n - 1] == '6' || s[n - 1] == '8'){
        cout << "pon" << endl;
    }else if(s[n - 1] == '3'){
        cout <<"bon" << endl;
    }
}


Measured memory_bytes: 3592
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        double L = sc.nextDouble();

        double k=Math.pow(L / 3, 3);

        System.out.println(k);
    }

}


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

int main(){
	int n;
	cin >> n;
	int is[n];
	for(int i = 0; i < n; i++){
		cin >> is[i];
	}
	int c = 0, ans = 0;
	for(int i = 0; i < n; i++){
		c = 0;
		while(i < n && is[i]==i+1){
			c++;
			i++;
		}
		if(c%2)
			ans++;
		ans += c/2;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
using namespace std;
long long MOD = 1e9 + 7;

long long modPow(long long x, long long a) {
    if (a == 1) return x;
    if (a % 2) return (x * modPow(x, a - 1)) % MOD;
    long long t = modPow(x, a / 2);
    return (t * t) % MOD;
}

int main(){
    long long n, ans = 0;
    cin >> n;
    vector<long long> a(n), cnt(61);
    for(int i = 0; i < n; i++){
        cin >> a[i];
        ans += ((a[i] % MOD) * ((n - 1) % MOD)) % MOD;
        ans %= MOD;
        for(long long j = 0; j <= 60; j++){
            if(a[i] & ((long long)1<<j)){
                cnt[j]++;
            }
        }
    }
    for(long long i = 0; i <= 60; i++){
        // cout << i << ":" << cnt[i] << endl;
        ans -= (modPow(2, i+1) * ((cnt[i] * (cnt[i] - 1) / 2) % MOD)) % MOD;
        if(ans < 0) ans += MOD;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int i,j,n,ans;
int a[60],b[60];
map <pair<int ,int>,int >m;
int main(){
	cin>>n;
	for(i=1;i<=n;i++){
		cin>>a[i]>>b[i];
	}
	for(i=1;i<=n;i++)
		for(j=1;j<=n;j++)
			if(i!=j)
			m[make_pair(a[i]-a[j],b[i]-b[j])]++,ans=max(ans,m[make_pair(a[i]-a[j],b[i]-b[j])]);
	cout<<n-ans;
	return 0;
}


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

int main() {
    string s;
    cin >> s;
    int n = s.length();
    if (s[0] == '0' || s[n - 1] == '1') {
        cout << -1 << endl; exit(0);
    }
    for (int i = 1; i < n - 1; i++) {
        if (s[i - 1] ^ s[n - i - 1]) { cout << -1 << endl; exit(0); }
    }
    for (int i = 2, cur = 1; i <= n; i++) {
        cout << cur << " " << i << endl;
        if (s[i - 2] == '1') cur = i;
    }
    return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vll = vector<vl>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const ll INF = 2e15;
template<class T> void print(const T& t){ cout << t << endl; }
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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
  ll x, k, d;
  cin >> x >> k >> d;
  x = abs(x);
  if((ld)x/(ld)d>=(ld)k){
    print(x - k * d);
  }
  else{
    ll a = x % d;
    ll b = d - a;
    ll c = (x - a) / d;
    ll e = (k - c) % 2;
    if(e==0){
      print(a);
    }
    else{
      print(b);
    }
  }
}

Measured memory_bytes: 3604
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct Point{
  int next;
  struct Point *front,*back;
};

struct Point *nil;

struct Point* Search(int);
void PrintList();
void input();
void deletePoint (struct Point *st);
void delete (int next);
void insert (int next);
void First();
void Last();

int main(){
  int i,n,key;
  char hi[20];

  scanf("%d",&n);
  input();

  for(i=0;i<n;i++){
    scanf("%s",hi);
    if(hi[0]=='i'){
      scanf("%d", &key);
      insert(key);
    }
    if(hi[0]=='d'){
      if(6<strlen(hi)){
	if(hi[6]=='F')
	  First();
	else if(hi[6]=='L')
	  Last();
      }else{
	scanf("%d", &key);
	delete(key);
      }
    }
  }

 
 
  PrintList();

  return 0;
}
  

struct Point* Search(int next){
  struct Point *a=nil->back;
  while(a!=nil && a->next != next){
    a=a->back;
  }
  return a;
}

void PrintList()
{
  int cou=0;
  struct Point *a=nil->back;

  while(1){
    if(a==nil)break;
    if(cou>0)
      printf(" ");
    printf("%d",a->next);
    a=a->back;
    cou++;
  }
  printf("\n");
}

void input()
{
  nil=(struct Point *)malloc(sizeof(struct Point));
  nil->back=nil;
  nil->front=nil;
}

void deletePoint (struct Point *st){/*削除*/
  if(st==nil)
    return;
  st->front->back= st->back;
  st->back->front= st->front;
  free(st);
}

void delete (int next){
  deletePoint(Search(next));
}

void insert (int next){
  struct Point *b=(struct Point *)malloc(sizeof(struct Point));
  b->next=next;
  
  b->back=nil->back;
  nil->back->front=b;
  nil->back=b;
  b->front=nil;
}

void First(){/*リストの先頭の要素を削除する*/
  deletePoint (nil->back);
}

void Last(){/*リストの末尾の要素を削除する*/
  deletePoint(nil->front);
}
  



Measured memory_bytes: 33020