akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <complex>
#include <cstdlib>
#include <ctime>
#include <time.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <numeric>
#include <limits>
#include <type_traits>
#include <locale>

using namespace std;
#define SAY_YES cout << "YES" << endl;
#define SAY_Yes cout << "Yes" << endl;
#define SAY_NO cout << "NO" << endl;
#define SAY_No cout << "No" << endl;
#define IFYES(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "YES" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "NO" << endl;  \
    }
#define IFYes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "Yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "No" << endl;  \
    }
#define IFyes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "no" << endl;  \
    }
#define DEBUG_OUTPUT_ARRAY(XXX, ONE)                            \
    for (int i = 0; i < (ONE); i++)                             \
    {                                                           \
        cout << "DEBUG: i = " << i << " -> " << XXX[i] << endl; \
    }
#define DEBUG_OUTPUT_ARRAY2(XXX, ONE, TWO)                             \
    for (int i = 0; i < (ONE); i++)                                    \
    {                                                                  \
        cout << "<<< i = " << i << " >>>" << endl;                     \
        for (int j = 0; j < (TWO); j++)                                \
        {                                                              \
            cout << "DEBUG: j = " << j << " -> " << XXX[i][j] << endl; \
        }                                                              \
    }
#define DEBUG_OUTPUT_ARRAY2_BOX(XXX, ONE, TWO) \
    for (int i = 0; i < (ONE); i++)            \
    {                                          \
        cout << i << "  ";                     \
        for (int j = 0; j < (TWO); j++)        \
        {                                      \
            cout << XXX[i][j] << " ";          \
        }                                      \
        cout << endl;                          \
    }

typedef pair<long long int, long long int> pll;


const long long int mod = 1000000007;
const long long int INF = 1e18;
const long double PI=3.14159265358979323; 

long long int N,M,K,sum=0,res=0,A,B,C;
string S,T;
int main(){
    cout << fixed << setprecision(18);
    cin>>A>>B>>C>>K;
    res+=min(A,K);
    K=max(K-(A+B),0LL);
    res-=K;
    cout<<res<<endl;
}


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

int main() {
    int n,l;
    cin >> n >> l;
    vector<string> s(n);
    for(int i = 0; i < n; i++) {
        cin >> s.at(i);
    }
    sort(s.begin(), s.end());
    for(int i = 0; i < n; i++) {
        cout << s.at(i);
    }
    cout << endl;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
int n, k;
vector<int> l;

// 荷物は連続して流れてくる
int check(int p) {
  int j = 0;
  for (int i=0; i<k; i++){
    int sum = 0;
    while(sum + l.at(j) <= p) {
      sum += l.at(j);
      j++;
      if (j == n) return j;
    }
  }
  return j;
}

int main() {
  cin >> n >> k;
  for (int i=0; i<n; i++) {
    int in; cin >> in;
    l.push_back(in);
  }
  int left = 0;
  int right = 10000 * 100000;

  while (right-left > 1) {
    int mid = (left+right)/2;
    if (check(mid) >= n) {
      right = mid;
    } else {
      left = mid;
    }
  }

  cout << right << endl;
}




Measured memory_bytes: 3524
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
using llong = long long;

llong n, k;
llong a[105];
llong dp[2][100005];

bool dfs(llong f, llong k) {
    if (k < a[0]) return false;
    if (dp[f][k] != -1) return dp[f][k];

    bool rec = false;
    for (int i = 0; i < n; i++) {
        if (k >= a[i]) {
            rec |= !dfs(f ^ 1, k - a[i]);
        }
    }


    return dp[f][k] = rec;
}

int main() {
    for (int i = 0; i < 100005; i++) {
        dp[0][i] = -1;
        dp[1][i] = -1;
    }
    
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    if (dfs(0, k)) {
        cout << "First" << endl;
    }
    else {
        cout << "Second" << endl;
    }

    return 0;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
#include <boost/range/adaptor/reversed.hpp>
#include <boost/range/algorithm/sort.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using boost::irange;
using boost::sort;
using boost::adaptors::reversed;

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    for (int i = 0; i < n; i++) cin >> p[i];
    sort(p);
    int ans = 0;
    for (int i = 0; i < k; i++) ans += p[i];
    cout << ans << endl;
}


Measured memory_bytes: 3632
N = int(input())
xl = []
for i in range(N):
    x, l = map(int, input().split())
    xl.append((x, l))
xl.sort()

kept = []
cur = 0
for i in range(1, N):
    x_cur, l_cur = xl[cur]
    x_next, l_next = xl[i]
    if x_cur + l_cur <= x_next - l_next:
        kept.append(cur)
        cur = i
    elif x_cur + l_cur > x_next + l_next:
        cur = i
kept.append(cur)

print(len(kept))


Measured memory_bytes: 59224
module piyoMod
      implicit none
      integer(16) :: n,m,q,ans=0
      integer(16),allocatable :: abcd(:,:)
      
      contains
      recursive subroutine solve( cnt,array )
        implicit none
        integer(16),intent(in) :: cnt,array(:)
        integer(16) :: a(size(array)), i,buffer
        
        a = array
        if( cnt==1 )then
          do i = 1,m
            a(1) = i
            call solve( cnt+1,a )
          end do
        else if( cnt==n+1 )then
          
          !calc ans
          buffer = 0
          do i = 1,q
            if( a(abcd(i,2))-a(abcd(i,1))==abcd(i,3) )then
              buffer = buffer + abcd(i,4)
            end if
          end do
          ans = max( ans,buffer )
          
        else
          do i = a(cnt-1),m
            a(cnt) = i
            call solve( cnt+1,a )
          end do
        end if
      end subroutine
        
      
      end module
      
      PROGRAM ManyRequirments
      use piyoMod
      IMPLICIT NONE
      integer(16) :: i,dummy(10)
      
      read*,n,m,q
      allocate( abcd(q,4) )
      do i = 1,q
        read*,abcd(i,:)
      end do
      
      call solve(1_16,dummy(1:n))
      print*,ans
      
      
      
      
      END PROGRAM

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

namespace CompetitiveProgCsLib
{
	class MainProg
	{
		static string R => Console.ReadLine();
		static int RI => int.Parse(R);
		static double RD => double.Parse(R);
		static int[] RIs => R.Split(' ').Select(int.Parse).ToArray();
		static double[] RDs => R.Split(' ').Select(double.Parse).ToArray();
		static void Out(object obj) => Console.WriteLine(obj);
		static void Outb(bool b) => Out(b ? "Yes" : "No");
		static void OutB(bool b) => Out(b ? "YES": "NO");

		static void Main(string[] args)
		{
			var N = RI;
			var x = RIs;
			var li = new List<int>(x);
			li.Sort();
			li.Reverse();
			int n = 0;
			int k = 0;
			//for(int i = 0;i < N;i++)
			{
				var m = li[0];
				var mid = m / 2.0;
				var mm = double.MaxValue;
				int n1 = 0;
				int k1 = 0;
				for(int j = 0 + 1;j < N;j++)
				{
					if(Math.Abs(mid - li[j]) < mm)
					{
						mm = Math.Abs(mid - li[j]);
						n1 = m;
						k1 = li[j];
					}
				}
				n = n1;
				k = k1;
			}
			Out(n + " " + k);
		}
		
	}
}


Measured memory_bytes: 21088
#include <iostream>

int main()
{
  int64_t K;
  std::cin>>K;
  
  if(K%2==0||K%5==0)
  {
    std::cout<<"-1"<<std::endl;
    return 0;
  }
  
  int64_t i=1;
  int64_t a=1;
  int64_t b=0;
  
  for(;;)
  {
    b+=7*a;
    b%=K;
    if(b==0)
    {
      std::cout<<i<<std::endl;
      return 0;
    }
    
    a*=10;
    a%=K;
    i++;
  }
}

Measured memory_bytes: 3556
N = int(input())
A = list(map(int,input().split()))
print(' '.join([str(a) for a in A]))

for i in range(1,N):
    key = A[i]
    j = i-1
    # j=0で先頭まで来たらもう比較しない
    while j>=0 and A[j] > key:
        # より小さい項と比較する
        A[j+1] = A[j]
        
        j -= 1
    # keyの位置は確定したので代入(while抜ける前にj-=1されているのでA[j+1])
    A[j+1] = key
    print(' '.join([str(a) for a in A]))


Measured memory_bytes: 5608
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;
typedef pair<int, int> P;

signed main(){
    int n, d;
    string s;
    cin >> n >> s >> d;
    string t = s;
    rep(i, 0, s.size()){
        if(d <= 0) break;        
        if(s[i] == '0' && d > 0){
            t[i] = '1';
            d--;
        }
    }
    repb(i, s.size() - 1, 0){
        if(d <= 0) break;        
        if(s[i] == '1'){
            t[i] = '0';
            d--;
        }
    }
    cout << t << endl;
}

Measured memory_bytes: 3208
import java.util.Scanner;

public class Main {

	static char[][] chars = { 
		{'.',',','!','?',' '},
		{'a','b','c'},
		{'d','e','f'},
		{'g','h','i'},
		{'j','k','l'},
		{'m','n','o'},
		{'p','q','r','s'},
		{'t','u','v'},
		{'w','x','y','z'}
	};
	public static void main(String[] args) {
		Scanner cin  = new Scanner(System.in);
		int n = cin.nextInt();
		for(int kaisuu = 0; kaisuu < n; kaisuu++){
			String str = cin.next();
			char[] s = str.toCharArray();
			str = "";
			int i = 0;
			while(i<s.length){
				if(s[i]=='0')i++;
				else{
					char c = s[i++];
					int j = 0;
					while(s[i]==c){i++;j++;}
					str += (chars[c-'0'-1][j%chars[c-'0'-1].length]);
					i++;
				}
			}
			System.out.println(str);
		}
	}
	static char henkan(int num, int count){
		if(num==0){
			return 0;
		}
		count = count%chars[num-1].length;
		
		return chars[num-1][count];
	}
}

Measured memory_bytes: 12000
S=input()
mini=1000

for i in range(0,len(S)-2):
  i1=int(S[i])
  i2=int(S[i+1])
  i3=int(S[i+2])
  x=i1*100+i2*10+i3
  if abs(x-753)<mini:
    mini=abs(x-753)

print(mini)

Measured memory_bytes: 9192
N = int(input())
nm_of_odd = 0
for n in range(1, N+1, 2):
  nm_of_divisor = 0
  for d in range(1, n+1, 2):
    if n % d == 0:
      nm_of_divisor += 1
  if nm_of_divisor == 8:
    nm_of_odd += 1
print(nm_of_odd)

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)

typedef long long ll;
#define int ll
const ll mod=1e9+7;

int32_t main()
{
    SPEED;
    int h,w;
    cin>>h>>w;
    char a[h+1][w+1];
    for (int i = 1; i <= h; ++i)
    {
        for (int j = 1; j <= w; ++j)
        {
            cin>>a[i][j];
        }
    }
    int dp[h+1][w+1];
    memset(dp,0,sizeof(dp));
    int p=1;
    while(a[p][1]=='.')
    {
        dp[p][1]=1;
        p++;
    }
    p=1;
    while(a[1][p]=='.')
    { 
        dp[1][p]=1;
        p++;
    }
    for (int i = 1; i <= h; ++i)
    {
        for (int j = 1; j <= w; ++j)
        {
            if(i!=1 || j!=1)
            {
                if(a[i][j]=='.')
                    dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
            }
            //cout<<dp[i][j]<<" ";
        }
        //cout<<endl;
    }
    cout<<dp[h][w]<<endl;
}



Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
typedef long long ll;
const ll inf = 1e9;
int main(){
    int n; cin >> n;
    vector<ll> a(n);
    rep(i,n)a[i] = i+1;
    do{
        rep(i,n)cout << a[i] << ((i < n-1)?" ":"\n");
    }while(next_permutation(all(a)));
    
    return 0;
}


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

int main() {
    ll N;
    cin >> N;
    
    const ll M = (1LL << N);
    vector<ll> A(M);
    for (ll i = 0; i < M; i++) {
        cin >> A[i];
    }

    //dp[i] := iの部分集合であるjについてA[j]が大きい順に上位二つを保持(A[j]ではなくjを保持)
    vector<pair<ll, ll>> dp(M, { 0, 0 });
    for (ll i = 1; i < M; i++) {
        vector<ll> candidate;

        //自分自身を含む
        candidate.push_back(i);

        //あとはiからビットを一つ降ろしたものについて調べれば十分
        for (ll j = 0; j < N; j++) {
            if (i & (1LL << j)) {
                candidate.push_back(dp[i ^ (1LL << j)].first);
                candidate.push_back(dp[i ^ (1LL << j)].second);
            }
        }

        //重複削除
        sort(candidate.begin(), candidate.end());
        candidate.erase(unique(candidate.begin(), candidate.end()), candidate.end());

        //A[k]の値でソート
        sort(candidate.begin(), candidate.end(), [&](ll lhs, ll rhs) {
            return A[lhs] > A[rhs];
        });

        //上位二つを保持
        dp[i].first = candidate[0];
        dp[i].second = candidate[1];
    }

    //各iについて上位二つとなるインデックスが確保されているのでA[index]の和を取れば良い
    ll ans = 0;
    for (ll i = 1; i < M; i++) {
        ans = max(ans, A[dp[i].first] + A[dp[i].second]);
        printf("%lld\n", ans);
    }
}

Measured memory_bytes: 9216
#include<bits/stdc++.h>
using namespace std;
string s;
inline int hui(int be,int la)
{
	string s1,s2;
	for(int i=be;i<=la;i++)if(s[i]!=s[la-i])return 0;
	return 1;
}
int main()
{
	cin>>s;
	if(hui(0,s.length()-1)&&hui(0,(s.length()-1)/2-1)&&hui((s.length()+3)/2-1,s.length()-1))cout<<"Yes";
	else cout<<"No";
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
#include <cmath>
#include <complex>
#include <map>
using namespace std;

#define rep(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-5
#define F first
#define S second

static const double PI=6*asin(0.5);
typedef pair<double,double> P;
typedef complex<double> CP;
typedef long long ll;

double x;
ll q;
int main(){
	while(cin>>q,q!=-1){
		x=q/2.0;
		while(abs(x*x*x-q)>=EPS*q){
			x-=(x*x*x-q)/3.0/x/x;
		}
		printf("%.6f\n",x);
		
	}
		
	return 0;
}

Measured memory_bytes: 1192
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
using System.Text.RegularExpressions;

namespace Yuzuki
{
    class Yukari
    {
        static int a, b, h, m;
        static string s;

        public static void Main(string[] args)
        {
            input();

            double theta1 = 2*PI * (h * 60 + m) / 720;
            double theta2 = 2*PI * m / 60;
            double theta = Abs(theta1 - theta2);
            double ans = Sqrt(Abs(a * a + b * b - 2 * a * b * Cos(theta)));
            Console.WriteLine(ans);
        }

        public static void input()
        {
            string[] buf = Console.ReadLine().Split();
            a = int.Parse(buf[0]);
            b = int.Parse(buf[1]);
            h = int.Parse(buf[2]);
            m = int.Parse(buf[3]);
        }

    }
}

Measured memory_bytes: 27916
#include<bits/stdc++.h>
using namespace std;
int main(){
	int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
	int h,w;
	cin>>h>>w;
	vector<string>a(h);
	vector<pair<int,int>>newblack,nextblack;
	for(int i=0;i<h;i++){
		cin>>a[i];
		for(int j=0;j<w;j++)
			if(a[i][j]=='#')
				nextblack.emplace_back(i,j);
	}
	bool update;
	for(int ans=0;;ans++){
		update=false;
		newblack=nextblack;
		nextblack.clear();
		for(auto e:newblack){
			for(int i=0;i<4;i++){
				int nx=e.first+dx[i],ny=e.second+dy[i];
				if(0<=nx&&nx<h&&0<=ny&&ny<w&&a[nx][ny]=='.'){
					update=true;
					a[nx][ny]='#';
					nextblack.emplace_back(nx,ny);
				}
			}
		}
		if(update==false){
			cout<<ans<<endl;
			return 0;
		}
	}
}


Measured memory_bytes: 16892
import sys
a,b,c,k=map(int,input().split())
ans=0
if a<=k:
    ans=a
    k=k-a
else:
    print(k)
    sys.exit()
if k!=0:
    k=k-b
else:
    print(a)
    sys.exit()
if k>0:
    ans=ans-k
    print(ans)
else:
    print(a)

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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//Write From this Line

int main()
{
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	rep(i,n) cin >> a[i];
	rep(ki, k){
		vector<int> b(n+1);
		rep(i,n){
			int l = max(0,i-a[i]);
			int r = min(i+a[i]+1, n);
			b[l]++; b[r]--;
		}
		rep(i,n) b[i+1] += b[i];
		b.pop_back();
		if (a==b) break;
		a = b;
	}
	rep(i,n) cout << a[i] << endl;
}


Measured memory_bytes: 4840
#include<stdio.h>

int main(){
  int f[45];
  int n,i;
  f[0]=1;
  f[1]=1;
  scanf("%d",&n);

  for(i=0;i<n-1;i++){
    f[i+2]=f[i]+f[i+1];
  }

  printf("%d\n",f[n]);
  return 0;
}



Measured memory_bytes: 2112
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <tuple>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
//#define MAX_INDEX 1000000001

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

//逆元を求める関数
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
      fac[i] = fac[i-1] * i % MOD;
      inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
      finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
//組み合わせ
long long COM (int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

void solve() {
	int n; cin >> n;
	int a[100001] = {};
	int ans = 0;
	for (int i = 0; i < n; ++i) {
		int num; cin >> num;
		if (num > n) {
			ans++;
			continue;
		}
		a[num]++;
	}
	for (int i = 1; i <= n; ++i) {
		if (a[i] != i) {
			if (a[i] < i) {
				ans += a[i];
			} else if (a[i] > i) {
				ans += (a[i] - i);
			}
		}
	}
	cout << ans << endl;
    return;
}

int main() {
    solve();
    return 0;
}



Measured memory_bytes: 640
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        
        int[] a = new int [n]; 
        
        for(int i=0;i<n;i++){
            a[i]=scan.nextInt();
        }
        
        int min=2147483647;
        int count=0;
        long sum=0;
        
        for(int i=0;i<n;i++){
            if(a[i]<0){
                count++;
                sum-=a[i];
            }else{
                sum+=a[i];
            }
            if(Math.abs(a[i])<min){
                min=Math.abs(a[i]);
            }
        }
        
        if(count%2==1){
            sum-=2*min;
        }
        
        System.out.println(sum);
        
    }
}


Measured memory_bytes: 49796
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, a, b) for(int i = (a); i <= (b); i++)
#define PER(i, a, b) for(int i = (a); i >= (b); i--)
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define all(S) (S).begin(), (S).end()
#define pf push_front
#define pb push_back
#define mk make_pair
#define S second
#define F first
typedef long long ll;
typedef long double lf;
typedef pair<int, int> ii;
const int MAX = 2e5+5;
int N, M, K, ans;
char m[7][7];

void calc(int l, int c) {
	int cnt = 0;
	rep(i, 0, N) rep(j, 0, M) {
		if(l & (1<<i) || c & (1<<j)) continue;
		cnt += (m[i][j] == '#');
	}
	ans += (cnt == K);
}

int main(int argc, char** argv) {
	scanf("%d%d%d", &N, &M, &K);
	rep(i, 0, N) scanf(" %s", m[i]);
	rep(i, 0, (1<<N)-1) rep(j, 0, (1<<M)-1)
		calc(i, j);
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 3796
/*
Author: Arham_doshi
 ***************************************   UNAUTHORISED COPYING OF CODE PROHIBITED   **********************************
*/
#include <bits/stdc++.h>

#define int         long long
#define double      long double
#define pb          push_back
#define pf          push_front
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define isp2(x)     x && (!(x&(x-1)))
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        998244353 
#define PI          3.141592653589
//#define bs(v,n)     binary_search(all((v)),(n))
#define lb(v,n)     lower_bound(all((v)),(n))
#define ub(v,n)     upper_bound(all((v)),(n))
#define fo(i,l,u)   for(i=l;i<u;i++)
using namespace std;

int gcd(int a, int b) {  if (a == 0)  return b; return gcd(b % a, a); }  
bool mod(double a,double b) {return a/b - floor(a/b);}

int occurs(vi v,int n){
auto it=lb(v,n);auto it1=ub(v,n);int x=it1-it;return x;}
int grid[1005][1005];
string arr[1005];


int logb(int base, int x) {
    return (log(x) / log(base));
}




signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int i,j,n;
    cin>>n;
    double x;
    vector<double> v,v1;
    fo(i,0,n){
        cin>>x;
        v.pb(x);
        v1.pb(1-x);
        //cout<<v[i]<<' '<<v1[i]<<endl;
    }
    
    double dp[n+1][n+1];
   
    dp[0][0]=v1[0];
    dp[0][1]=v[0];
    
    fo(i,1,n){
        dp[i][0]=dp[i-1][0]*v1[i];
        //cout<<dp[i][0]<<" ";
        fo(j,1,i+1){
            dp[i][j]=dp[i-1][j-1]*v[i]+dp[i-1][j]*v1[i];
           // cout<<dp[i][j]<<" ";
        }
        dp[i][i+1]=dp[i-1][j-1]*v[i];
         //cout<<dp[i][j]<<" "<<endl;
    }
    double d=0;
    fo(i,0,n+1){
        if(i>n-i)d+=dp[n-1][i];
    }
    cout<<setprecision(15)<<d;

    return 0;
}

Measured memory_bytes: 140928
#include<iostream>
using namespace std;
int main(){
  int t;
  cin>>t;
  while(t--){
    int n,e=-1,E=-1,be=1e9,BE=1e9;
    int f=0;
    cin>>n;
    int an=n;
    for(int i=0;i<2;i++){
      char a,b='N';
      for(int j=0;j<n;j++){
	cin>>a;
	if(a=='Y'||b=='Y'){
	  an++;
	  if(i==1)f=2,E=j,BE=min(BE,j);
	  else e=j,be=min(be,j);
	}
	cin>>b;
      }
	if(b=='Y'){
	  an++;
	  if(i==1)f=2,E=n,BE=min(BE,n);
	  else e=n,be=min(be,n);
	}
      b='N';
    }
    if(e>=E&&f>0)f--;
    if(be<=BE&&f>0)f--;
    cout<<an+f<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>
using namespace std;
int main(void){
int x,y;

while(1){
scanf("%d %d",&x,&y);
if(x==0&&y==0)break;


if(x>=y){
printf("%d %d\n",y,x);
}else{
printf("%d %d\n",x,y);
}
}
    
}



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

using namespace std;

int main()
{
  int N, C, K;
  cin >> N >> C >> K;
  vector<int> T(N);
  for (int i = 0; i < N; i++)
    cin >> T[i];
  sort(T.begin(), T.end());
  int ans = 1, ride = 1, ti = T[0] + K;
  for (int i = 1; i < N; i++)
    if (ride == C || ti < T[i])
    {
      ans++;
      ride = 1;
      ti = T[i] + K;
    }
    else
    {
      ride++;
    }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) < (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MODU 1000000007LL
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#define PI 3.141592653589


#define izryt bool
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}
pll Dir[8] = { //移動
	{ 0 ,1 },{ -1 ,0 },{ 1 ,0 },{ 0 ,-1 },
	{ 1 ,1 },{ 1 ,-1 },{ -1 ,1 },{ -1 ,-1 }
};

//[a, b)
#define Getsum(ar, a,b) (ar[b] - ar[a])
#define INF 10000000000000000LL
#define chmax(a,b) a = max(a,b)
#define chmin(a,b) a = min(a,b)

struct Edge {
	int from, to;
	ll w;
};

typedef vector<vector<Edge>> Graph;

void connect(Graph& g, int f, int t, int w = 1) {
	g[f].push_back({ f,t, w });
	g[t].push_back({ t,f, w });
}
signed main(void) {

	int n;
	cin >> n;
	
	Graph g(n + 1);
	int bas = n + (1-n%2);
	rep(i, 1, n + 1) {
		rep(j, i  + 1, n + 1) {
			if(j != bas - i)
				connect(g, i, j);
		}
	}

	vector<pii> ans;
	rep(i, 1, n + 1) {
		for (auto itr : g[i]) {
			if (itr.from < itr.to && itr.from != 0) {
				ans.push_back({itr.from, itr.to});
			}
		}
	}

	cout << ans.size() << endl;
	for (auto itr : ans) {
		cout << itr.first << " " << itr.second << endl;
	}
	return 0;
}

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

using namespace std;

#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define f first
#define s second

typedef long long ll;

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fll;

const int MAX = 2e5+10;

namespace seg {
	ll seg[4*MAX];
	int n;

	void build(int n2) { n = n2; }

	ll query(int a, int b, int p=1, int l=0, int r=n-1) {
		if (b < l or r < a) return 0;
		if (a <= l and r <= b) return seg[p];
		int m = (l+r)/2;
		return max(query(a, b, 2*p, l, m), query(a, b, 2*p+1, m+1, r));
	}
	ll upd(int a, int b, ll x, int p=1, int l=0, int r=n-1) {
		if (b < l or r < a) return seg[p];
		if (a <= l and r <= b) return seg[p] = x;
		int m = (l+r)/2;
		return seg[p] = max(upd(a, b, x, 2*p, l, m), upd(a, b, x, 2*p+1, m+1, r));
	}
};

int main(){ _

	int n; cin >> n;
	seg::build(n+1);
	vector<int> h(n), a(n);

	for(int& i : h) cin >> i;
	for(int& i : a) cin >> i;

	ll ans = 0;
	for(int i=0; i<n; i++) {
		ll now = a[i] + seg::query(0, h[i]-1);
		ans = max(ans, now);
		seg::upd(h[i],h[i],now);
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 8924
n,k=map(int,input().split())
max=(n*(n-1))//2-(n-1)
if k>max:
  print(-1)
else:
  ans=[]
  for i in range(2,n+1):
    ans.append([1,i])
  lim=max-k
  cnt=0
  for i in range(2,n+1):
    for j in range(i+1,n+1):
      if cnt>=lim:
        continue
      ans.append([i,j])
      cnt+=1
  print(len(ans))
  for i,j in ans:
    print(i,j)

Measured memory_bytes: 4120
#include <cstdio>
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
using namespace std;

int main()
{
	int w;
	cin >> w;
	cout << w * 32 << endl;
}


Measured memory_bytes: 3104
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

var sc *bufio.Scanner

const bufferSize = 1024

func nextString() string {
	if !sc.Scan() {
		panic(nil)
	}
	return sc.Text()
}

var production bool

func debugf(format string, v ...interface{}) {
	if !production {
		fmt.Printf(format, v...)
	}
}

func answer(reader io.Reader, writer io.Writer) {
	sc = bufio.NewScanner(reader)
	buf := make([]byte, bufferSize)
	sc.Buffer(buf, 1e+7)
	sc.Split(bufio.ScanWords)
	s := nextString()
	if s == "AAA" || s == "BBB" {
		_, _ = fmt.Fprint(writer, "No")
	} else {
		_, _ = fmt.Fprint(writer, "Yes")
	}

}

func main() {
	production = true
	answer(os.Stdin, os.Stdout)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  //cout << n << endl;
  vector<int> w_i(n+1);
  for(int i=0;i<n;i++){
    cin >> w_i[i];
    //cout << w_i[i];
  }
  int a,b;
  int c=9901;
  for(int i=0;i<n;i++){
    a=0;b=0;
    for(int j=0;j<i+1;j++){
      a += w_i[j];
    }
    //cout << a << endl;
    for(int k=i+1;k<n;k++){
      b += w_i[k];
    
    }
    //cout << b << endl;
    if(abs(a-b)<c){
      c = abs(a-b);
    }
  }
  cout << c << endl;
 
}

Measured memory_bytes: 3596
#!/usr/bin/env python3
import sys
from itertools import chain

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(S: str, T: str):
    return YES if T[: len(S)] == S else NO


def main():
    tokens = chain(*(line.split() for line in sys.stdin))
    S = next(tokens)  # type: str
    T = next(tokens)  # type: str
    answer = solve(S, T)
    print(answer)


if __name__ == "__main__":
    main()


Measured memory_bytes: 8828
#include <bits/stdc++.h>
 
typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(ll i=0;i<(n);i++)
 
using namespace std;
 
 
int main(){
    int n;
    ll a, b;
    cin >> n >> a >> b;

    ll t;
    ll cnt = 0;
    rep(i, n){
        cin >> t;
        if(a <= t && t < b){

        }
        else cnt++;
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << '\n';
#define fi first
#define se second
typedef int64_t Int;
Int mod = 1e9+7;
Int INF = 1e9+7;

const int MAX = 5100000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main() {
    Int x, y;
    cin >> x >> y;
    if ((x + y) % 3 != 0 || max(x, y) / min(x, y) > 2) {
        dump(0);
        return 0;
    }
    COMinit();
    //cout << (x + y) / 3 <<  " " << y - (x + y) / 3 << endl;
    dump(COM((x + y) / 3, y - (x + y) / 3) % mod);
    return 0;
}

Measured memory_bytes: 119808
#include <stdio.h>

int main(){
    int N,i,j,min,max,maxsub;
    scanf("%d",&N);
    int A[N];
    for(i = 0;i < N;i++){
        scanf("%d",&A[i]);
        //printf("%d \n",A[i]);
    }

    min = A[0];
    max = A[0];

    for(i = 0;i < N;i++){
        if(A[i] > max){
            max = A[i];
        }else if(A[i] < min){
            min = A[i];
        }
    }
    //printf("max:%d,min:%d\n",max,min);
    maxsub = max - min;
    printf("%d\n",maxsub);
    return 0;
}

Measured memory_bytes: 128
#ifndef _WIN32
#include<iostream>
#endif // !_WIN32

#include<string>
#include<cmath>
#include<iomanip>
#include<vector>
#include<algorithm>
using namespace std;
string r = "yuiophjklnm";

#define ITR(x,v) for(auto &x:v)
int f(char c) {
	ITR(cc, r)if (c == cc)return 1;
	return 0;

}
int main() {
	string s;
	while (cin >> s, s != "#") {
		vector<int> v;
		ITR(c, s)v.push_back(f(c));

		int prv = v.front();
		int res = 0;
		ITR(x, v) {
			res += (prv != x);
			prv = x;
		}
		cout << res << endl;
	}

	return 0;
}

Measured memory_bytes: 3184
def is_all_even(seq):
    for i in seq:
        if i % 2 != 0:
            return False
    return True


N = int(input())
A = [int(s) for s in input().split()]

ans = 0
while is_all_even(A):
    A = [a // 2 for a in A]
    ans += 1
print(ans)


Measured memory_bytes: 2940
// ※※※ 解答不能 ※※※
// LHiC氏.
// https://atcoder.jp/contests/keyence2019/submissions/4005363
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define a first
#define b second
const int MAXN = 210000;
LL d;
int n;
LL a[MAXN];

int main(){
    scanf("%d %lld", &n, &d);
    rep(i, n) scanf("%lld", &a[i]);
    vector<pair<LL, int>> vv;
    repx(i, 1, n){
        LL x = a[i] + d * i;
        while(!vv.empty() && vv.back().a >= x) vv.pop_back();
        vv.emplace_back(x, i);
    }
    int now = 1;
    LL bst = a[0];
    LL ans = 0;
    rep(i, vv.size()){
        int nw = vv[i].b;
        ans += vv[i].a + bst;
        repx(j, now, nw){
            ans += a[j] + min(vv[i].a - j * d, bst + j * d);
            bst = min(bst, a[j] - j * d);
        }
        bst = min(bst, a[nw] - nw * d);
        now = nw + 1;
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 7024
#グーで勝つR　チョキで勝つS　パーで勝つP
n,k = map(int, input().split())
r,s,p = map(int, input().split())
t = input()
point = {"r":p, "s":r, "p":s}
do = {"r":"p", "s":"r", "p":"s"}
d = []

score = 0
for i in range(n):
    if i < k:
        score += point[t[i]]
        d.append(do[t[i]])
    else:
        if d[-k] == do[t[i]]:
            d.append("")
        else:
            score += point[t[i]]
            d.append(do[t[i]])
print(score)

Measured memory_bytes: 4212
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll INF = 1LL<<60;
const ll MOD = 1e9 + 7;


int main() {
    ll X,N;
    cin >> X >> N;
    map<ll,ll> mp;
    for (ll i = 0;i<N;i++) {
        ll p;
        cin >> p;
        mp[p]++;
    }
    ll m = 100000;
    ll ans;
    for (ll i = -10;i<=110;i++) {
        if (mp[i] == 1) continue;
        ll d = abs(i-X); //差
        if (m > d) {  //より小さい差(差が同じときは更新しない)
            m = d;
            ans = i;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3636
# -*- coding utf-8 -*-
N = int(input())
AN = list(map(int, input().split()))

s = 0
sign = 1
m = 1e10
for i in range(N):
    abs_val = abs(AN[i])

    s += abs_val
    sign = sign * (1 if abs_val == AN[i] else -1)
    m = min(m, abs_val)

if sign < 0: 
    print(s - 2 * m)
else:
    print(s)

Measured memory_bytes: 14332
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>
#include <utility>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

int main(){
    ll N,K;
    cin >> N >> K;
    vector<ll> A(N);
    set<ll> ss;
    map<ll,ll> mpa;

    for(ll i = 0;i < N;i++){
        cin >> A.at(i);
        ss.insert(A.at(i));
    }

    for(auto x:ss){
        mpa[x] = 0;
    }

    for(int i = 0;i < N;i++){
        mpa[A.at(i)]++;
    }

    ll ss_size = ss.size();
    vector<ll> B(ss_size);

    ll j = 0;
    for(auto i:ss){
        B.at(j) = mpa[i];
        j++;
    }
    
    sort(B.begin(),B.end());

    ll goukei = 0;

    for(ll i = 0;i < ss_size - K;i++)
        goukei += B.at(i);

    cout << goukei << endl;


    

}

Measured memory_bytes: 28260
from itertools import combinations

n, d = map(int, input().split())

xs = [list(map(int, input().split())) for _ in range(n)]

ans = 0
for x1, x2 in combinations(xs, 2):
    s = sum(((y - z) ** 2 for y, z in zip(x1, x2)))
    if (int(s ** 0.5)) == s ** 0.5:
        ans += 1
print(ans)



Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define N 500
//#define int long long
#define INF 1e9
#define rep(i, l, r) for(register int i = l; i <= r; ++ i)
using namespace std;
inline int read()
{
	register char cc = getchar();register int cn(0), flus(1);
	while(cc > '9' || cc < '0') {if(cc == '-') flus = -flus; cc = getchar();}
	while(cc >= '0' && cc <= '9') {cn = cn * 10 + cc - '0'; cc = getchar();}
	return cn * flus; 
}
int e[N][N];
int tmp[N][N];
int a, b;
inline void floyd()
{
	rep(k,1,a * b)
	{
		rep(i,1,a * b)
		{
			rep(j,1,a * b)
			{
				e[i][j]=min(e[i][j],e[i][k]+e[k][j]);
			}
		}
	}
}
signed main()
{
	a = read();
	b = read();
	rep(i, 1, a * b) 
	{
		rep(j, 1, a * b) 
		{
			if(i != j) e[i][j] = 1e9;
		}
	}
	rep(i, 1, a)
	{
		char s[N];
		scanf("%s",s + 1);
		rep(j, 1, b)
		{
			if(s[j] == '.') tmp[i][j] = 1;
		}
	}
	rep(i, 1, a)
	{
		rep(j, 1, b)
		{
			int k = i - 1;
			if(tmp[i][j])
			{
				//printf("i = %d j = %d\n",i,j);
				//printf("tmp[i][j - 1] = %d\n",tmp[i][j - 1]);
				if(tmp[i][j - 1])
				{
					e[k * b + j - 1][k * b + j] = 1;
					e[k * b + j][k * b + j - 1] = 1;
					//printf("added(%d,%d)\n",i * b + j - 1,i * b + j);
				}
				if(tmp[i][j + 1])
				{
					e[k * b + j + 1][k * b + j] = 1;
					e[k * b + j][k * b + j + 1] = 1;
				}  
				if(tmp[i + 1][j]) 
				{
					e[(k + 1) * b + j][k * b + j] = 1;
					e[k * b + j][(k + 1) * b + j] = 1;
				}
				if(tmp[i - 1][j])
				{
					e[(k - 1) * b + j][k * b + j] = 1;
					e[k * b + j][(k - 1) * b + j] = 1;
				}
			}
		}
	}
	floyd();
	int _max = 0;
	/*rep(i, 1, a * b)
	{
		rep(j, 1, b * a)
		{
			printf("%d ",e[i][j]);
		}
		puts("");
	}*/
	rep(i, 1, a * b)
	{
		rep(j, 1, b * a)
		{
			if(e[i][j] > _max && e[i][j] < 1e9) _max = e[i][j];
		}
	}
	printf("%d\n",_max);
	return 0;	
}


Measured memory_bytes: 1024
import Control.Monad.State
import Control.Arrow
import Data.Maybe
import Data.List

getInts = map read . words <$> getLine :: IO [Int]

data Point = Point {_x::Int, _y::Int}
data Travel = Travel {_time::Int, _p::Point}

toTravel (s:x:y:_) = Travel s (Point x y)

reachable (Travel t (Point x y)) ret@(Travel t2 (Point x2 y2)) = 
    if distance <= time && (t2 - t) `mod` 2 == distance `mod` 2 then Just ret else Nothing
    where
        time = t2 - t
        distance = abs(x2 - x) + abs(y2 - y)

main = do
    time <- readLn
    inp <- replicateM time getLine
    let travels = map (words >>> map read >>> toTravel) inp
    let res = foldl' doTravel (Just $ Travel 0 (Point 0 0)) travels
    putStrLn $ if isJust res then "Yes" else "No"
    where
        doTravel x y = join $ (flip reachable y) <$> x


Measured memory_bytes: 73084
N, M = map(int, input().split())
A = list(map(int, input().split()))
CB = []
for _ in range(M):
    b, c = map(int, input().split())
    CB.append((c, b))

# ascend
A.sort()

# descend
CB.sort(reverse=True)

# fill convert ary
conv = []
for cb in CB:
    c, b = cb
    conv.extend([c] * b)
    if len(conv) >= N:
        break

cl = len(conv)

sum = 0
for i in range(N):
    if i >= cl:
        sum += A[i]
    else:
        sum += max(A[i], conv[i])

print(sum)


Measured memory_bytes: 22984
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

vector<pair<string,int> >  v;
vector<pair<int,int> > c;
int id[110];

int N;
int main (){
    cin >> N;
    for(int i=0; i<N; i++) {
        string s;
        int p;
        cin >> s >> p;
        v.push_back(make_pair(s,-p));
        c.push_back(make_pair(p,i+1));
    }
    sort(v.begin(),v.end());
    for(int i=0; i<N; i++) {
        for(int j=0; j<N; j++) {
            if( v[i].second * -1 == c[j].first ) {
                cout << c[j].second << endl;
            } else continue;
        }
    }

    return 0;
}


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

int main()
{
    int n, l;
    cin >> n >> l;
    vector <string> s(n);
    for (int i = 0; i < n; i++)
    {
        cin >> s[i];
    }
    int k=0, x=1, p;
    for(int i=0; i < n-1 ; i++)
    {
        for(int j=x; j < n ; j++)
        {
            if(s[i][k] > s[j][k])
            {
                swap(s[i], s[j]);
            }
            else if(s[i][k] == s[j][k])
            {
                while(1)
                {
                    k++;
                    if(s[i][k] > s[j][k])
                    {
                        swap(s[i], s[j]);
                        k=0;
                        break;
                    }
                    else if(s[i][k] < s[j][k])
                    {
                        k=0;
                        break;
                    }
                }
            }
        }
        x++;
    }
    for(int i=0; i < n; i++)
    {
        cout << s[i];
    }
    cout << endl;
}

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)

using namespace std;

#define P1 1
#define P2 0

bool dfs(int L,int R,vector<int> &f,bool phase,int rem1,int rem2) { // [L,R)
  //cout << "[" << L << "," << R << ") , phase = " << (phase?"P1":"P2") << ", rem1 = " << rem1 << ", rem2 = " << rem2 << endl;
  if( phase == P1 ) {
    bool ret = false;
    if( L - 1 > 0 && f[L-1] == phase ) {
      if( rem1 - 1 == 0 ) ret = true;
      else ret |= dfs(L-1,R,f,!phase,rem1-1,rem2);
    }
    if( R < 14 && f[R] == phase ) {
      if( rem1 - 1 == 0 ) ret = true;
      else ret |= dfs(L,R+1,f,!phase,rem1-1,rem2);
    }
    if( !( L - 1 > 0 && f[L-1] == phase ) && !( R < 14 && f[R] == phase ) ) {
      ret |= dfs(L,R,f,!phase,rem1,rem2);
    }
    return ret;
  } else {
    bool ret = true;
    if( L - 1 > 0 && f[L-1] == phase ) {
      if( rem2 - 1 == 0 ) ret = false;
      else ret &= dfs(L-1,R,f,!phase,rem1,rem2-1);
    }
    if( R < 14 && f[R] == phase ) {
      if( rem2 - 1 == 0 ) ret = false;
      else ret &= dfs(L,R+1,f,!phase,rem1,rem2-1);
    }
    if( !( L - 1 > 0 && f[L-1] == phase ) && !( R < 14 && f[R] == phase ) ) {
      ret &= dfs(L,R,f,!phase,rem1,rem2);
    }
    return ret;
  }

}

int main() {
  int n;
  cin >> n;
  rep(_,n) {
    vector<int> f(14,P2);
    rep(i,6) {
      int a;
      cin >> a;
      f[a] = P1;
    }
    puts(dfs(7,8,f,P1,6,6)?"yes":"no");
  }
  return 0;
}

Measured memory_bytes: 3080
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Main {
	public static void main(String[] args) throws Exception{
	       BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	       char[] line = br.readLine().toCharArray();
	       int[] num = new int[26];
	       for(char c : line){
	    	   if(num[c-'a']+1==1){
	    		   num[c-'a']+=1;
	    	   }else{
	    		   System.out.println("no");
	    		   return;
	    	   }
	       }
	       System.out.println("yes");
	}
}


Measured memory_bytes: 21204
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }


string str;
int x, y;

vector<int> val[2];

bool dp[3][100000];
bool iscan(int num, vector<int> vec) {
    memset(dp, 0, sizeof(dp));
    dp[0][50000] = true;
    for (int i = 0; i < vec.size(); ++i) {
        for (int j = 0; j < 100000; ++j) {
            if (!dp[i%2][j]) continue;
            if (j - vec[i] >= 0) dp[(i+1)%2][j - vec[i]] |= dp[i%2][j];
            if (j + vec[i] < 100000) dp[(i+1)%2][j + vec[i]] |= dp[i%2][j];
        }
        for (int j = 0; j < 100000; ++j) {
            dp[i%2][j] = false;
        }
    }
    return dp[vec.size() % 2][num + 50000];
}


int main() {
  while (cin >> str >> x >> y) {
      for (int i = 0; i < 2; ++i) val[i].clear();
      int parity = 0;
      int tmp = 0;
      bool isfirst = true;
      int first = 0;
      str += 'T';
      for (auto c : str) {
          if (c == 'F') {
              ++tmp;
          }
          else {
              if (!isfirst) {
		if (tmp) {
		  val[parity].push_back(tmp);
		}
              }
              else {
                  isfirst = false;
                  first = tmp;
              }
              parity = 1 - parity;
              tmp = 0;
          }
      }

      bool ok1 = iscan(x - first, val[0]);
      bool ok2 = iscan(y, val[1]);
      
      /*
       COUT(first);
       COUT(val[0]);
       COUT(val[1]);
      COUT(ok1);
      COUT(ok2);
      */
       
      if (ok1 && ok2) puts("Yes");
      else puts("No");
  }
}


















Measured memory_bytes: 640
#include<stdio.h>

int main()
{
    long long N;
    scanf("%lld",&N);
    
    long long h,n,x1,x2;
    int flag=0;
    for(h=1;h<=3500;h++)
    {
        for(n=1;n<=3500;n++)
        {
            x1=N*h*n;
            x2=4*h*n-n*N-h*N;
            if(x1>0&&x2>0&&x1%x2==0)
            {
                printf("%lld %lld %lld\n",h,n,x1/x2);
                flag=1;
                break;
            }
        }
        if(flag==1) 
			break;
    }
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	long long n, i, j, k, MOD = 998244353, ans, x, m;
	cin >> n;
	vector<long long> d(n, 0), f(n + 1), a(n + 1);
	for (i = 1; i <= n; i++) {
		cin >> a[i];
		d[a[i]]++;
	}
	f[0] = 1;
	for (i = 1; i <= n; i++) f[i] = (f[i - 1] * i) % MOD;

	if ((d[0] != 1) || (a[1] != 0)) ans = 0;
	else {
		for (m = n - 1; (m >= 0) && (d[m] == 0); m--);
		ans = 1;
		for (i = 1; i <= m; i++) {
			if (d[i] == 0) {
				ans = 0; break;
			}
			for (j = 1; j <= d[i]; j++) ans = (ans * d[i - 1]) % MOD;
		}
	}
	cout << ans << "\n";

	return 0;
}


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

const string YES = "YES";
const string NO = "NO";

void solve(long long N, std::vector<long long> A){
    sort(A.begin(),A.end());
    auto it = unique(A.begin(),A.end());
    if(it == A.end()) cout<<YES<<endl;else cout<<NO<<endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 1792