akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <numeric>
#include <iomanip>
#define fi first
#define se second
#define fcout(n) cout<<fixed<<setprecision((n))
#define cinl(str) getline(cin,(str))
using namespace std;
bool value(int y,int x,int R,int C){return 0<=y&&y<R&&0<=x&&x<C;}
typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
double pie=acos(-1);
int INF=1000000007;
int dx[4] = { 0,-1,0,1 };
int dy[4] = { -1,0,1,0 };


int main() {
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if(a+b<c+d) cout<<"Right"<<endl;
	else if(a+b>c+d) cout<<"Left"<<endl;
	else cout<<"Balanced"<<endl;
	
}

Measured memory_bytes: 256
function main(input) {
    const args = input.split(' ');
    const a = parseInt(args[0], 10);
    const b = parseInt(args[1], 10);

    if ((a * b) % 2 === 0) {
        console.log('Even');
    } else {
        console.log('Odd');
    }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29532
using System;
using System.IO;

class Program
{
    static void Main(string[] args) {
        var scan = new Scanner();
        var writer = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
        Console.SetOut(writer);
        Console.WriteLine(Solve(scan));
        Console.Out.Flush();
    }
    static object Solve(Scanner scan) {
        int N = scan.NextInt();
        var P = new int[N];
        for (int i = 0; i < N; i++) {
            P[i] = scan.NextInt();
        }
        var min = P[0];
        var result = 1;
        for (int i = 1; i < N; i++) {
            if (P[i] >= min) continue;
            min = P[i];
            result++;
        }
        return result;
    }
}

class Scanner
{
    string[] s;
    int i;
    public Scanner() {
        s = new string[0];
        i = 0;
    }
    public string Next() {
        if (i < s.Length) return s[i++];
        string str = Console.ReadLine();
        while (str == "") str = Console.ReadLine();
        s = str.Split(' ', StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return Next();
        i = 0;
        return s[i++];
    }
    public int NextInt() => int.Parse(Next());
}

Measured memory_bytes: 42008
mod = 10 ** 9 + 7
N = int(input())
S1 = input()
S2 = input()

domino = []     # 0 : 横, 1 : 縦
flag = False
for i in range(N):
    if S1[i] == S2[i]:
        domino.append(1)
        flag = False
    else:
        if flag:
            flag = False
        else:
            domino.append(0)
            flag = True

if domino[0] == 0:
    ans = 6
else:
    ans = 3

for i in range(1, len(domino)):
    if domino[i] == 0:
        if domino[i-1] == 0:
            ans *= 3
        else:
            ans *= 2
    else:
        if domino[i-1] == 0:
            ans *= 1
        else:
            ans *= 2
print(ans%mod)

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

//template
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
template<typename T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
//end



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

Measured memory_bytes: 3592
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define fo(i,j,n) for (int i=(j); i < (n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() {
    string n; cin >> n;
    
    bool f = false;
    rep(i, 2){
        if(n[i]==n[i+1] && n[i+1]==n[i+2] && n[i+2]==n[i]) f = true;
    }

    if(f) cout << "Yes" << ln;
    else cout << "No" << ln;
}

    

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

int main()
{
    int N,K,r=0;
    cin>>N>>K;
    int a=N;
    while(1){
        a=a/K;
        r++;
        if(a<K&&a!=0){
            cout<<r+1<<endl;
            exit(0);
        }else if(a==0){
            cout<<r<<endl;
            exit(0);
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
 
using namespace std;
 
#define int long long
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(i, a) for (auto &i: (a))
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()

void solve();

signed main () {
    cout.precision(10);
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
    #endif
    int t = 1; 
    // cin >> t;    
    int tt = t;
    while (t--) { 
        solve();
    }
    return 0;
}
bool is_prime (int a) {
	for (int i = 2; i * i <= a; ++i) 
		if (a % i == 0)
			return false;
	return true;
}
void solve() { 
	int x;
	cin >> x;
	for (int i = x; ; i++) {
		if (is_prime(i)) {
			cout << i;
			return;
		}
	}
}


Measured memory_bytes: 256
n,m = map(int,input().split())
a = [int(input()) for _ in range(m)]

p = 10**9 +7
ans = [0]*(n+1)
ans[0] = 1
ans[1] = 1

broken = [0]*(n+1)
for i in a:
    broken[i]= -1

for i in range(1,n):
    if broken[i] == -1:
        ans[i] = 0
        ans[i+1] = ans[i-1]%p
    else:
        ans[i+1] = (ans[i-1] + ans[i])%p

print(ans[-1])

Measured memory_bytes: 14364
#include "bits/stdc++.h"
using ll = long long;
using namespace std;

int get(vector <int> &v, int d) {
   int ans = 0;
   for(auto &e: v) {
      ans += (e - d) * (e - d);
   }
   return ans;
}

void solve() {
   int n;
   cin >> n;
   vector <int> v(n);
   for(int i = 0; i < n; i++) {
      cin >> v[i];
   }
   int sum = accumulate(v.begin(), v.end(), 0);
   double avg = sum / n;
   int nearest = (int) avg;

   int ans = INT_MAX;
   for(int i = nearest - 1; i <= nearest + 1; i++) {
      ans = min(ans, get(v, i));
   }
   cout << ans << endl;
}

int main() {
   cin.tie(0);
   cin.sync_with_stdio(0);
   int testcase = 1;
   // cin >> testcase;
 
   for(int i = 0; i < testcase; i++) {
      solve();
   } 
   return 0;
}


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

using namespace std;

const int MAXN = 200010;

char c[MAXN];

int main(){
  int N;
  while(scanf("%d%s", &N, c) > 0){
    int num_Rs = 0;
    for(int i = 0; c[i]; i++){
      num_Rs += (c[i] == 'R');
    }

    int i = 0, j = strlen(c)-1, ans = 0;

    while(i < num_Rs){
      if(c[i] == 'R'){
	i++;
	continue;
      }

      while(c[j] != 'R') j--;
      swap(c[i], c[j]);
      ans++;
      i++;
    }

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


Measured memory_bytes: 4016
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>

#pragma GCC optimize("Ofast")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "inposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0

using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const double PI = acos(-1);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {

	int n, a;
	scanf("%d", &n);
	ll ans = 0;
	rep(i, n){
		scanf("%d", &a);
		while (a % 2 == 0) {
			a /= 2;
			++ans;
		}
	}
	printf("%lld\n", ans);

	Please AC;
}


Measured memory_bytes: 256
#include <iostream>
#include<unordered_map>
#include<bits/stdc++.h>
using namespace std;
long long int power(long long int x, long long int y, long long int p)  
{  
    long long int res = 1;      
  
    x = x % p; 
   
    if (x == 0) return 0; 
  
    while (y > 0)  
    {  
        
        if (y & 1)  
            res = (res*x) % p;  
  
          
        y = y>>1;  
        x = (x*x) % p;  
    }  
    return res;  
}  
int main() {
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int t;
	t=1;
	while(t--)
	{
        
           string s;
           cin>>s;
           
           int i=s.size();
           char t=s[i-1];
           if(t=='s')
           {
               s.push_back('e');
            s.push_back('s');

           }
           else
           {
               s.push_back('s');

           }
           
           cout<<s<<endl;
	   
	}
	   
	   
	return 0;
}

Measured memory_bytes: 3648
#https://atcoder.jp/contests/abc072/tasks/arc082_a
N = int(input())
ai = list(map(int, input().split()))
num = [0]*(10**5+1)
for a in ai:
   num[a+1] +=1
   num[a] +=1
   if a>0:
    num[a-1] +=1  
print(max(num))

Measured memory_bytes: 13964
#include<stdio.h>

int main(){

    int N,a=1,b=0,c=0;


    scanf("%d",&N);

    while(a<10){


        b = N/a;
       
        if(b <= 9 && N%a ==0){
            c=1;
            break;
        }

        a++;
    }


    if(c==1) {
        printf("Yes");
    }

    else {
        printf("No");
    }
    
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=999999999999;
const ld pi=3.14159265358979;

int main(){
    ld a,b,h,m;
    cin>>a>>b>>h>>m;
    ld ans=a*a+b*b-2*a*b*cos(2*pi*(h/12-11*m/720));
    ans=sqrt(ans);
    cout<<setprecision(13)<<ans<<endl;
}

Measured memory_bytes: 4136
n, m = map(int, input().split())
money = 0
li = []

for i in range(n):
    li.append(list(map(int, input().split())))
li.sort()

for j in range(n):
    shop = li.pop(0)
    if m < shop[1]:
        money += m * shop[0]
        break
    money += shop[0] * shop[1]
    m -= shop[1]

print(money)


Measured memory_bytes: 27760
#include <iostream>
using namespace std;
int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);

	int x, y, z;
	cin >> x;
	cin >> y;
	cin >> z;
	if(x * y * z == 5 * 5 * 7) {
      cout << "YES" << "\n";
    } else {
      cout << "NO" << "\n";
    }
}

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

#if defined(DEBUG)

#include <unistd.h>
#include <sys/fcntl.h>
#define DLOG(...)        cerr << dbgFormat(__VA_ARGS__) << endl
#define DCALL(func, ...) func(__VA_ARGS__)

template <class... Args>
string dbgFormat(const char* fmt, Args... args) {
  size_t len = snprintf(nullptr, 0, fmt, args...);
  char buf[len + 1];
  snprintf(buf, len + 1, fmt, args...);
  return string(buf);
}

#else  // defined(DEBUG)

#define DLOG(...)
#define DCALL(func, ...)

#endif // defined(DEBUG)
// ----------------------------------------------------------------------

// ----------------------------------------------------------------------
int fstDiff(string s) {
  int i = 1;
  while (i < (int) s.size()) {
    if (s.at(i-1) != s.at(i)) return i;
    i++;
  }
  return -1;
}

ll func(string s) {
  ll rv = 0;
  int i = 1;
  int cnt = 1;
  while (i < (int) s.size()) {
    if (s.at(i-1) == s.at(i)) {
      cnt ++;
    }else {
      rv += cnt / 2;
      cnt = 1;
    }
    i++;
  }
  rv += cnt / 2;
  return rv;
}

int main(int argc, char *argv[]) {
#if defined(DEBUG)
  // GDB on Cygwin ignores redirection at run command.
  if (argc == 2) dup2(open(argv[1], 0), 0);
#else
  // For performance.  We should not use C-style stdio functions
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
#endif
  cout << setprecision(20);

  string S;
  ll K;
  cin >> S >> K;
  ll ssize = S.size();

  int i = fstDiff(S);
  if (i == -1) {
    cout << ssize * K / 2 << endl;
    return 0;
  }
  string S1 = S.substr(0, i);
  string S2 = S.substr(i, ssize - i);
  string SS = S2 + S1;
  ll n1 = func(S1);
  ll n2 = func(S2);
  ll nn = func(SS);
  ll ans = n1 + n2 + nn * (K-1);
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MOD 1000000007
int main(){
	fast;
	ll n,x,ans=0,diff=0;
	cin>>n>>x;
	ll arr[n];
	for(ll i=0;i<n;i++)
		cin>>arr[i];
	for(ll i=1;i<n;i++)
		if(arr[i]+arr[i-1]>x)
		{
			diff=arr[i-1]+arr[i]-x;
			ans+=diff;
			if(arr[i]-diff>=0)
			arr[i]-=diff;
			else
			{
			diff-=arr[i];
			arr[i]=0;
			if(arr[i-1]-diff>=0)
			arr[i-1]-=diff;
			else
			arr[i-1]=0;
			}
		}
	cout<<ans;
	return 0;
}



Measured memory_bytes: 4408
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define mod 1000000007
#define nn 65536*16
int bx[nn],by[nn],bbx[nn],bby[nn];
int cntx[nn],cnty[nn];
int n,m,k;
struct asfdgt{
	int tree[nn];
	void add(int x,int y){
		for(;x<nn;x+=x&-x) tree[x]=(tree[x]+y)%mod;
	}
	int ask(int x){
		int y=0;for(;x;x-=x&-x) y=(y+tree[x])%mod;return y;
	}
	int ask(int l,int r){
		return ask(r)-ask(l-1);
	}
}bitx,bity;

vector<int> vx,vy;

#undef nn 
#define nn 102
int dp[nn][nn],black[nn][nn];
int ax[]={1,-1,0,0},ay[]={0,0,-1,1};
void bfs(int x,int y){
	memset(dp,0x3f,sizeof dp);
	queue<int> qx,qy;dp[x][y]=0;qx.push(x);qy.push(y);
	while(qx.size()){
		x=qx.front();qx.pop();
		y=qy.front();qy.pop();
		
		for(int i=0;i<4;i++) {
			int xx=x+ax[i],yy=y+ay[i];
			if(xx>=1 and yy>=1 and xx<=n and yy<=m and dp[xx][yy]>dp[x][y]+1 and !black[xx][yy])
				dp[xx][yy]=dp[x][y]+1,qx.push(xx),qy.push(yy);
		}
	}
}

int find(int x,vector<int>&v){
	return lower_bound(v.begin(),v.end(),x)-v.begin()+1;
}
int adx[1000008],ady[1000008],fun[nn][nn];
signed main(){
	scanf("%d%d%d",&n,&m,&k);
	for(int i=1;i<=n;i++) bitx.add(i,m),adx[i]=1;
	for(int i=1;i<=m;i++) bity.add(i,n),ady[i]=1;
	
	for(int i=1;i<=k;i++) scanf("%d%d",&bx[i],&by[i]),bx[i]++,by[i]++,bitx.add(bx[i],-1),bity.add(by[i],-1),bbx[bx[i]]=bby[by[i]]=1;
//	memset(bbx,1,sizeof bbx);memset(bby,1,sizeof bby);
	int ans=0;
	for(int i=1;i<=n;i++){
		int j=i+1;while(j<=n){
			if(!bbx[i] and !bbx[j]){
				adx[i]+=adx[j];
				ans+=bitx.ask(1,j-1)*bitx.ask(j,n)%mod;ans%=mod;
				j++;
			}
			else break;
		}
		vx.push_back(i);
		i=j-1;
	}
	
	for(int i=1;i<=m;i++){
		int j=i+1;while(j<=m){
			if(!bby[i] and !bby[j]){
				ady[i]+=ady[j];
				ans+=bity.ask(1,j-1)*bity.ask(j,m)%mod;ans%=mod;
				j++;
			}
			else break;
		}
		vy.push_back(i);
		i=j-1;
	}
	
	
	ans*=2;//cout<<ans;
	for(int i=1;i<=k;i++) black[find(bx[i],vx)][find(by[i],vy)]=1;
	n=vx.size(),m=vy.size();
	for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) fun[i][j]=adx[vx[i-1]]*ady[vy[j-1]]%mod;
	for(int i=1;i<=vx.size();i++) for(int j=1;j<=vy.size();j++)if(!black[i][j]){
		bfs(i,j);
		for(int x=1;x<=vx.size();x++) for(int y=1;y<=vy.size();y++) if(!black[x][y]) ans=(ans+dp[x][y]*fun[i][j]%mod*fun[x][y])%mod;
	//	cout<<i<<" "<<j<<":"<<ans<<"\n";
	}
	
	
	printf("%lld\n",(ans%mod*(mod+1)/2%mod+mod)%mod);
	return 0;
} 

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

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

    const ll INF = 1LL << 60;

    ll N;
    cin >> N;
    vector<ll> h(N);
    vector<ll> dp(N);
    rep(i, N) cin >> h[i];
    rep(i, N) dp[i] = INF;

    dp[0] = 0;
    for(int i=1; i<N; i++) {
        if (i > 1) {
            ll first =  dp[i-1] + abs(h[i] - h[i-1]);
            ll second = dp[i-2] + abs(h[i] - h[i-2]);
            dp[i] = min(first, second);
        } else {
            dp[i] = dp[i-1] + abs(h[i] - h[i-1]);
        }
    }

    cout << dp[N-1] << '\n';
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    string ans = "Yes";
    if((a==b&&b==c&&c==a)||(a!=b&&b!=c&&c!=a)){
        ans = "No";
    }
    cout << ans << "\n";
    return 0;
}


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

#define int long long 
using namespace std;
signed main(){
 int a,b;
 while(cin >> a >> b){
  int g = __gcd(a,b);
  int l = a*b/g;
  cout << g << " " << l << endl;
 } 
 return 0;
}


Measured memory_bytes: 3080
#include <stdio.h>
#include <math.h>
#include <algorithm>

using namespace std;

struct Info{
	int id;
	double time_record;
};

int main(){

	Info group1[8],group2[8],group3[8],rest[6];

	for(int i = 0; i < 8; i++){
		scanf("%d %lf",&group1[i].id,&group1[i].time_record);
	}
	for(int i = 0; i < 8; i++){
		scanf("%d %lf",&group2[i].id,&group2[i].time_record);
	}
	for(int i = 0; i < 8; i++){
		scanf("%d %lf",&group3[i].id,&group3[i].time_record);
	}

	for(int i=1; i <= 7; i++){
		for(int k=7; k >= i; k--){
			if(group1[k].time_record < group1[k-1].time_record)swap(group1[k],group1[k-1]);
			if(group2[k].time_record < group2[k-1].time_record)swap(group2[k],group2[k-1]);
			if(group3[k].time_record < group3[k-1].time_record)swap(group3[k],group3[k-1]);
		}
	}

	rest[0] = group1[2];
	rest[1] = group1[3];
	rest[2] = group2[2];
	rest[3] = group2[3];
	rest[4] = group3[2];
	rest[5] = group3[3];

	for(int i=1; i <= 5; i++){
		for(int k=5; k >= i; k--){
			if(rest[k].time_record < rest[k-1].time_record)swap(rest[k],rest[k-1]);
		}
	}

	printf("%d %.2lf\n",group1[0].id,group1[0].time_record);
	printf("%d %.2lf\n",group1[1].id,group1[1].time_record);
	printf("%d %.2lf\n",group2[0].id,group2[0].time_record);
	printf("%d %.2lf\n",group2[1].id,group2[1].time_record);
	printf("%d %.2lf\n",group3[0].id,group3[0].time_record);
	printf("%d %.2lf\n",group3[1].id,group3[1].time_record);
	printf("%d %.2lf\n",rest[0].id,rest[0].time_record);
	printf("%d %.2lf\n",rest[1].id,rest[1].time_record);


	return 0;
}

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

#define mod 1000000007

using namespace std;
typedef long long ll; 
 
int main(void){
	
	ll X, A, B;
	
	cin >> X >> A >> B;
	
	if(X + A < B)
		cout << "dangerous";
	else if(A < B)
		cout << "safe";
	else
		cout << "delicious";
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N; cin >> N;
  bool b = true;
  for(int i = 0; i < N; i++){
    int v; cin >> v;
    if(v % 2 == 0 && !(v % 3 == 0 || v % 5 == 0)){
      b = false;
    }
  }
  cout << (b ? "APPROVED" : "DENIED") << endl;
}


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

using namespace std;
using ll = int64_t;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using mii = map<int, int>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using tpi = tuple<int, int, int>;

using vqi = vector<queue<int>>;
using vpi = vector<pii>;
using bs = bitset<60>;
using vbi = vector<bs>;

ll gcd(ll a, ll b) {
    if (a < b) {
        swap(a, b);
    }

    /* ユークリッドの互除法 */
    ll r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

constexpr int64_t __pow_mod(int64_t n, int64_t p, int64_t mod) noexcept {
    if (p == 0) {
        return 1;
    }
    if (p % 2 == 0) {
        int64_t t = __pow_mod(n, p / 2, mod);
        return (t * t) % mod;
    }
    return (n * (__pow_mod(n, p - 1, mod) % mod)) % mod;
}

constexpr int64_t pow_mod(int64_t n, int64_t p, int64_t mod) noexcept {
    int64_t res = __pow_mod(n, p, mod);
    if (res == 0) {
        res = mod;
    }
    return res;
}

constexpr int64_t nCr_mod(int64_t n, int64_t r, int64_t mod) noexcept {
    int64_t count = 1;
    auto a = r;
    for (auto i = n; i > n - r; i--) {
        count *= i;
        if (count % mod != 0) {
            count %= mod;
        }
        int64_t inv = pow_mod(a, mod - 2, mod);
        count *= inv;
        if (count % mod != 0) {
            count %= mod;
        }
        a--;
    }
    return count;
}

int main() {
    list<char> ans;
    string S;
    cin >> S;
    int Q;
    cin >> Q;

    for (char i : S) {
        ans.push_back(i);
    }

    bool rev = false;
    for (int i = 0; i < Q; i++) {
        int mode;
        cin >> mode;

        if (mode == 1) {
            rev = !rev;
        } else {
            int f;
            char c;
            cin >> f >> c;
            bool front = (f == 1);
            if (rev) {
                front = !front;
            }

            if (front) {
                ans.push_front(c);
            } else {
                ans.push_back(c);
            }
        }
    }

    if (rev) {
        for (auto&& iter = ans.rbegin(); iter != ans.rend(); iter++) {
            cout << *iter;
        }
        cout << endl;
        return 0;
    } else {
        for (auto item :ans) {
            cout << item;
        }
        cout << endl;
        return 0;
    }
    return 0;
}


Measured memory_bytes: 9984
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n, m, c, b, a, tmp, ans;
  vector<int> v;
  ans = 0;
  cin >> n >> m >> c;
  for (int j = 0; j < m; j++)
  {
    cin >> b;
    v.push_back(b);
  }
  for (int i = 0; i < n; i++)
  {
    tmp = 0;
    for (int j = 0; j < m; j++)
    {
      cin >> a;
      tmp += a*v[j];
    }
    if (tmp + c > 0) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, l;
  cin >> n >> l;
  string s[n];
  for (int i=0; i < n; i++) cin >> s[i];
  sort(s, s + n); //l[0:N]を大きい順にソート
  string ans = "";
  for (int i=0; i < n; i++) {
      ans += s[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 3672
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

int A[100001];
int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);


	int N = getint();
	rep(i, N) A[getint()]++;

	int ki = 0;
	int gu = 0;
	rep(i, 100000) {
		if (A[i] & 1) ki++;
		else if (A[i]) gu++;
	}

	if (gu & 1) ki -= 1;

	printf("%d", ki + gu);

	Would you please return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
#include<deque>
#include<cassert>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
const int mod = 1000000007;
const int INF = 1001001001;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int main() {
  int n, k;
  cin >> n >> k;
  combination comb(200100);
  mint ans = 0;
  k = min(k, n);
  for(int i = 0; i <= k; ++i) {
    ans += comb(n - i - 1 + i, i) * comb(n, i);
  }

  cout << ans << endl;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
int main() {
    
    //入力
    int A,B;
    cin>>A>>B;
    
    int x=0;
    //処理
    if(B%A==0){
        x=A+B;
    }
    else{
        x=B-A;
    }
    
    //出力
    cout<<x<<endl;
}


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

int main(){
  string S;
  int A[4];
  cin >> S;
  for(int i=0; i<4; i++){
    A[i] = S[i] - '0';
  }
  if(A[0]+A[1]+A[2]+A[3]==7) cout << A[0] << '+' << A[1] << '+' << A[2] << '+' << A[3] << '=' << '7' << endl;
  else if(A[0]+A[1]+A[2]-A[3]==7) cout << A[0] << '+' << A[1] << '+' << A[2] << '-' << A[3] << '=' << '7' << endl;
  else if(A[0]+A[1]-A[2]+A[3]==7) cout << A[0] << '+' << A[1] << '-' << A[2] << '+' << A[3] << '=' << '7' << endl;
  else if(A[0]+A[1]-A[2]-A[3]==7) cout << A[0] << '+' << A[1] << '-' << A[2] << '-' << A[3] << '=' << '7' << endl;
  else if(A[0]-A[1]+A[2]+A[3]==7) cout << A[0] << '-' << A[1] << '+' << A[2] << '+' << A[3] << '=' << '7' << endl;
  else if(A[0]-A[1]+A[2]-A[3]==7) cout << A[0] << '-' << A[1] << '+' << A[2] << '-' << A[3] << '=' << '7' << endl;
  else if(A[0]-A[1]-A[2]-A[3]==7) cout << A[0] << '-' << A[1] << '-' << A[2] << '-' << A[3] << '=' << '7' << endl;
  else if(A[0]-A[1]-A[2]+A[3]==7) cout << A[0] << '-' << A[1] << '-' << A[2] << '+' << A[3] << '=' << '7' << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, l, r) for (int i = l; i <= (int)(r); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define MOD (int) (1e9+7)
#define INF (int) 2e9
#define LLINF (ll) 2e18

int main(){
    int s, w;
    cin >>  s>> w;
    if(s<=w){
        cout << "unsafe" << endl;
    }else{
        cout << "safe" << endl;
    }
    // printf("%d\n", N);
    return 0;
}

Measured memory_bytes: 3632
from collections import deque

def bfs(maze,sy,sx):
    visited=[[-1 for _ in range(W+2)] for _ in range(H+2)]
    queue=deque([[sy,sx]])
    visited[sy][sx]=0
    dist=0
    
    while queue:
        y,x=queue.popleft()
        for j,k in ([1,0],[-1,0],[0,1],[0,-1]):
            new_y,new_x=y+j,x+k
            if maze[new_y][new_x]=="." and visited[new_y][new_x]==-1:
                visited[new_y][new_x]=visited[y][x]+1
                queue.append([new_y,new_x])
                dist=max(dist, visited[new_y][new_x])
    return(dist)
    
H,W=map(int,input().split())
maze=["#"*(W+2)]
maze+=["#" + input() + "#" for i in range(H)]
maze+=["#"*(W+2)]

Ans=0
for i in range(1,H+1):
    for j in range(1,W+1):
        if maze[i][j]==".":
            Ans=max(Ans, bfs(maze,i,j))
print(Ans)

Measured memory_bytes: 3316
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;

public class Main {

	static BufferedReader reader;
	final static boolean MODE_DEBUG = false;
	//static field here
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		reader = new BufferedReader(new InputStreamReader(System.in));
		//code here
		int[] NM = readLineInt();
		int N = NM[0];
		int M = NM[1];
		int[][] BC = new int[M][2];
		int[] A = readLineInt();
		for(int i=0;i<M;i++) {
			BC[i] = readLineInt();
		}
		Arrays.sort(A);
		Arrays.sort(BC,new Comparator<int[]>(){

			@Override
			public int compare(int[] o1,int[] o2){ // TODO 自動生成されたメソッド・スタブ
			return o2[1]-o1[1]; }
			
		});
		int needle = 0;
		for(int bc=0;bc<BC.length;bc++) {
			for(int j=0;j<BC[bc][0]&&needle<N&&A[needle]<BC[bc][1];j++) {
				A[needle]=BC[bc][1];
				needle++;
			}
		}
		long sum = 0;
		for(int i=0;i<N;i++) {
			sum+=A[i];
		}
		print(sum);
	}
	
	//functions here
	//note that all methods should be STATIC


	private static <T> int arraySearch(T needle, T[] heystack) {
		for(int i=0;i<heystack.length;i++) {
			if(needle.equals(heystack[i])) {
				return i;
			}
		}
		return -1;
	}
	private static int[] sort(int[] base) {
		int[] copy = array_copy(base);
		Arrays.sort(copy);
		return copy;
	}
	private static int[] array_copy(int[] base) {
		int[] copy = new int[base.length];
		for(int i=0;i<base.length;i++) {
			copy[i] = base[i];
		}
		return copy;
	}
	private static int[] asArray(ArrayList<Integer> ints) {
		int[] intlist = new int[ints.size()];
		for(int i=0;i<intlist.length;i++) {
			intlist[i] = ints.get(i);
		}
		return intlist;
	}
	private static String[] readLine(){
		try{
			return reader.readLine().split(" ");
		}catch(Exception e){
			e.printStackTrace();
			return new String[]{e.getMessage()};
		}
	}
	private static int[] readLineInt(){
		try{
			String[] s = readLine();
			int[] ints = new int[s.length];
			for(int i=0;i<ints.length;i++) {
				ints[i] = Integer.parseInt(s[i]);
			}
			return ints;
		}catch(Exception e){
			e.printStackTrace();
			return null;
		}
	}
	private static byte[] readLineByte(){
		try{
			String[] s = readLine();
			byte[] bytes = new byte[s.length];
			for(int i=0;i<bytes.length;i++) {
				bytes[i] = Byte.parseByte(s[i]);
			}
			return bytes;
		}catch(Exception e){
			e.printStackTrace();
			return null;
		}
	}
	private static char[] readLineChar(){
		try{
			String[] s = readLine();
			char[] chars = new char[s.length];
			for(int i=0;i<chars.length;i++) {
				chars[i] = (char)Integer.parseInt(s[i]);
			}
			return chars;
		}catch(Exception e){
			e.printStackTrace();
			return null;
		}
	}
	private static void print(Object o){
		System.out.println(o);
	}
	private static void print(){
		System.out.println();
	}
	private static void printd(Object o){
		if(MODE_DEBUG)System.err.println(o);
	}
	private static void printd(){
		if(MODE_DEBUG)System.err.println();
	}
}


Measured memory_bytes: 64276
#include <bits/stdc++.h>
using namespace std;
#define LOCAL
#pragma region Macros
typedef long long ll;
#define ALL(x) (x).begin(),(x).end()
const long long MOD=1e9+7;
// const long long MOD=998244353;
const int INF=1e9;
const long long IINF=1e18;
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
const char dir[4]={'D','R','U','L'};

template<typename T>
istream &operator>>(istream &is,vector<T> &v){
    for (T &x:v) is >> x;
    return is;
}
template<typename T>
ostream &operator<<(ostream &os,const vector<T> &v){
    for (int i=0;i<v.size();++i){
        os << v[i] << (i+1==v.size()?"": " ");
    }
    return os;
}
template<typename T,typename U>
ostream &operator<<(ostream &os,const pair<T,U> &p){
    cout << '(' << p.first << ',' << p.second << ')';
    return os;
}
template<typename T,typename U>
ostream &operator<<(ostream &os,const map<T,U> &m){
    os << '{';
    for (auto itr=m.begin();itr!=m.end();++itr){
        os << '(' << itr->first << ',' << itr->second << ')';
        if (++itr!=m.end()) os << ',';
        --itr;
    }
    os << '}';
    return os;
}
template<typename T>
ostream &operator<<(ostream &os,const set<T> &s){
    os << '{';
    for (auto itr=s.begin();itr!=s.end();++itr){
        os << *itr;
        if (++itr!=s.end()) os << ',';
        --itr;
    }
    os << '}';
    return os;
}

void debug_out(){cerr << '\n';}
template<class Head,class... Tail>
void debug_out(Head&& head,Tail&&... tail){
    cerr << head;
    if (sizeof...(Tail)>0) cerr << ", ";
    debug_out(move(tail)...);
}
#ifdef LOCAL
#define debug(...) cerr << " ";\
cerr << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << '\n';\
cerr << " ";\
debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

template<typename T> T gcd(T x,T y){return y!=0?gcd(y,x%y):x;}
template<typename T> T lcm(T x,T y){return x/gcd(x,y)*y;}

template<class T1,class T2> inline bool chmin(T1 &a,T2 b){
    if (a>b){a=b; return true;} return false;
}
template<class T1,class T2> inline bool chmax(T1 &a,T2 b){
    if (a<b){a=b; return true;} return false;
}
#pragma endregion

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    vector<ll> A(N); cin >> A;
    ll now=1000,h=0;
    for (int i=0;i<N;++i){
        if (A[i]>A[i+1]){
            now+=h*A[i],h=0;
        } else if (A[i]<A[i+1]){
            h+=now/A[i],now%=A[i];
        }
        if (i==N-1){
            now+=h*A[i],h=0;
        }
    }
    cout << now << '\n';
}

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

#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false

int main()
{
    int n;
    while (cin >> n, n)
    {
        vector<long long int> data;
        data.push_back(0);
        rep(i, n)
        {
            long long int temp;
            cin >> temp;
            data.push_back(data[i] + temp);
        }
        long long int ans = INT_MAX*-1;
        rep(i, n + 1)
        {
            REP(j, i + 1, n + 1)
            {
                ans = max(ans, data[j] - data[i]);
            }
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3128
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

    FastScanner in;
    PrintWriter out;

    public static void main(String[] args) {
        new Main().run();
    }

    void solve() {
        int str = in.nextInt();
        int[] input = new int[4];
        int j = 10;
        for (int i = 0; i < 4; i++) {
            input[i] = str % j;
            str = str / j;
        }
        if ((input[0] == input[1] && input[0] == input[2]) || (input[3] == input[1] && input[3] == input[2])) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
   }


    void run() {
        in = new FastScanner();
        out = new PrintWriter(System.out);
        solve();
        out.close();
    }

    public class FastScanner {
        BufferedReader br;
        StringTokenizer st;

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

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

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

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

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

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

}

Measured memory_bytes: 23124
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define all(x) x.begin(),x.end()
#define fi first
#define se second
#define ld long double
using namespace std;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, k;
    cin >> k >> n;
    vector<bool> a(k);
    for (int i = 0; i<n; i++) {
        int d;
        cin >> d;
        for (int j = 0; j<d; j++) {
            int t;
            cin >> t;
            a[t-1] = 1;
        }
    }
    int ans = 0;
    for (bool i : a) {
        ans += !i;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
typedef long long int llint;
using namespace std;

signed main() {
	llint n,a,b;
	cin >> n>>a>>b;
	if ((b - a) % 2 == 0) {
		cout << (b - a) / 2 << endl;
	}
	else if ((b - a) % 2 == 1) {
		cout << min((1-a-b+2*n)/2,min((b+a-1)/2,min(b - 1, n - a))) << endl;
	}
}

Measured memory_bytes: 256
stack = []

def dfs(visited):
    while 0 < len(stack):
        v = stack.pop()
        for i, u in enumerate(edges[v]):
            if u is True:
                if visited[i]:
                    continue
                visited[i] = True
                stack.append(i)
                dfs(visited)


N, M = tuple(map(int, input().split()))
edges = [[False for _ in range(N)] for _ in range(N)]
A, B = [], []
for i in range(M):
    a, b = tuple(map(int, input().split()))
    a -= 1
    b -= 1
    edges[a][b] = True
    edges[b][a] = True
    A.append(a)
    B.append(b)

ans = 0
for a, b in zip(A, B):
    edges[a][b] = False
    edges[b][a] = False
    visited = [False] * N
    cnt = 0
    for v in range(N):
        if visited[v]:
            continue
        cnt += 1
        visited[v] = True
        stack.append(v)
        dfs(visited)
    if 1 < cnt:
        ans += 1
    edges[a][b] = True
    edges[b][a] = True
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <sys/types.h>
#include <unistd.h>

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

const pid_t pid = getpid();
// Problem Specific Parameter:

ll a[16][16];
ll score[1 << 16];
ll dp[1 << 16];
const ll inf = 1LL << 50;

int main(void){
	int n;
	cin >> n;
	rep(i,n)rep(j,n) cin >> a[i][j];

	rep(mask,1 <<n){
		ll cur = 0LL;
		rep(j,n)rep(i,j){
			if((mask & (1 << i)) == 0) continue;
			if((mask & (1 << j)) == 0) continue;
			cur += a[i][j];
		}
		score[mask]=cur;
	}

	rep(mask,1,1 << n){
		dp[mask] = -inf;
		for(int smask = mask;; smask = (smask - 1) & mask){
			chmax(dp[mask],dp[mask^smask] + score[smask]);
			if(smask == 0) break;
		}
	}

	cout << dp[(1 << n) - 1] << endl;


	return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = pow(10, 9) + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divCeil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) {cout << (A) << endl; exit(0);}

int main()
{
  ll H, W;
  cin >> H >> W;

  ll B = 0;
  vector<vector<char>> S(H + 2, vector<char>(W + 2, '#'));
  for (ll i = 1; i < H + 1; i++)
  {
    for (ll j = 1; j < W + 1; j++)
    {
      cin >> S.at(i).at(j);
      if (S.at(i).at(j) == '#')
        B++;
    }
  }

  vector<vector<ll>> mv = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
  vector<vector<ll>> L(H + 2, vector<ll>(W + 2, -1));
  queue<pair<ll, ll>> Q;
  Q.push(make_pair(1, 1));
  L.at(1).at(1) = 0;
  while (!Q.empty())
  {
    ll Y = Q.front().first;
    ll X = Q.front().second;
    //cerr << X << " " << Y << endl;
    if (Y == H && X == W)
      break;
    Q.pop();
    for (ll i = 0; i < 4; i++)
    {
      ll y = Y + mv.at(i).at(0);
      ll x = X + mv.at(i).at(1);
      if (S.at(y).at(x) != '#' && L.at(y).at(x) == -1)
      {
        Q.push(make_pair(y, x));
        L.at(y).at(x) = L.at(Y).at(X) + 1;
      }
    }
  }

  ll ans = (Q.empty()) ? -1 : H * W - L.at(H).at(W) - 1 - B;
  cout << ans << endl;

  /*
  for (ll i = 1; i < H + 1; i++)
  {
    for (ll j = 1; j < W + 1; j++)
    {
      cerr << L.at(i).at(j) << " ";
    }
    cerr << endl;
  }
  */
}

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

stack<int> s;
int n;

int main(){
	while(cin>>n){
		if(n==0) {
			cout<<("%d\n",s.top())<<endl;
			s.pop();
		}
		else{
			s.push(n);
		}
	}
	return 0;
}

Measured memory_bytes: 3092
package main

import (
  "fmt"
)

func main() {
  var k int
  array := [...]int{1, 1, 1, 2, 1, 2, 1, 5,
                 2, 2, 1, 5, 1, 2, 1, 14,
                 1, 5, 1, 5, 2, 2, 1, 15,
                 2, 2, 5, 4, 1, 4, 1, 51}
  fmt.Scan(&k)
  
  fmt.Println(array[k-1])
}

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

int main()
{
    int n;
    cin>>n;
    vector<int> vec(n);
    for(int i=0;i<n;i++)
        cin>>vec[i];
    vector<int>dp(n);
    long long int ans=vec[0],res=0;dp[1]=abs(vec[1]-vec[0]);
    for(int i=2;i<n;i++)
    {

        dp[i]=min(dp[i-1]+abs(vec[i]-vec[i-1]),dp[i-2]+abs(vec[i]-vec[i-2]));
        //res=res+dp[i];
    }
    cout<<dp[n-1]<<endl;
    return 0;
}


Measured memory_bytes: 1024
n=int(input())
a=[list(map(int,input().split())) for i in range(2)]
b=[[0 for i in range(n)] for j in range(2)]

for j in range(2):
    for i in range(n):
        if i==0:
            b[j][i]+=a[j][i]
        else:
            b[j][i]+=a[j][i]+b[j][i-1]

s=[0 for i in range(n)]
for i in range(n):
    if i==0:
        s[i]=b[0][i]+b[1][n-1]
    else:
        s[i]=b[0][i]+b[1][n-1]-b[1][i-1]

s.sort(reverse=True)
print(s[0])


Measured memory_bytes: 9180
n = int(input())
a = list(map(int, input().split()))

a = sorted(a)
max_a = a[-1]
max_a_harf = (max_a+1) // 2

ans = 0
for i in range(n):
    if abs(max_a_harf - a[i]) < abs(max_a_harf - ans):
        ans = a[i]

print(max_a, ans)

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

using namespace std;

using ll = long long;
using ld = long double;

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    // cout << setprecision(8) << setiosflags(ios::fixed);

    ll n;
    cin >> n;

    ll sum = 0;
    for (ll k = 1; k * k <= n; ++k) {
        if (n % k != 0) continue;

        ll m = k - 1;
        if (0 < m && (n / m) == (n % m)) sum += m;

        if (k == n / k) continue;
        m = (n / k) - 1;
        if (0 < m && (n / m) == (n % m)) sum += m;
    }

    cout << sum << endl;

    return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;

#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
#define pi  3.14159265359
#define mod 1000000007

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll h,w,m;
    cin>>h>>w>>m;
    ll row[h+2]={0};
    ll col[w+2]={0};
    vector<pair<ll,ll>>val;
    ll maxr=LONG_MIN,maxc=LONG_MIN;
    for(ll i=0;i<m;i++)
    {
        ll x,y;
        cin>>x>>y;
        val.push_back(make_pair(x,y));
        row[x]++;
        maxr=max(maxr,row[x]);
        col[y]++;
        maxc=max(maxc,col[y]);
    }
    ll rowMn=count(row,row+h+1,maxr);
    ll colMn=count(col,col+w+1,maxc);
    ll point=rowMn*colMn;
    for(auto i=val.begin();i!=val.end();i++)
    {
         if(row[i->first]==maxr&&col[i->second]==maxc){

                  point--;

         }
    }
    ll mi=1;
    if(point){
        mi=0;
    }

    cout<<maxr+maxc-mi<<endl;





}



Measured memory_bytes: 16280
/*g++ main.cpp -o main.out*/
/*./main.out*/

#include<bits/stdc++.h>
using namespace std;

#define LL long long
#define LD long double
#define Mod 1000000007
#define L_Mod 17100000013

const double eps = 1e-9;
const int INF = 0x3f3f3f3f;
const double PI = 3.1415926535;

#define NO_TLE std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define ree(a,n) memset(a,n,sizeof(a));

#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define red(i,l,u) for(int (i)=(int)(l);(i)>=(int)(u);--(i))

int main()
{
    string s;
    cin>>s;
    string t=s;
    reverse(t.begin(),t.end());
    int sum=0;
    rer(i,0,s.size()-1)
    {
        if(s[i]!=t[i])sum++;
    }
    cout<<(int)ceil(sum*1.0/2.0)<<endl;
    return 0;
}


Measured memory_bytes: 256