akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cctype>

using namespace std;

string g;

int main(void) {
    getline(cin, g);

    for(int i = 0; i < (int) g.size(); i++) {
        if(g[i] >= 'a' && g[i] <= 'z') {
            g[i] = toupper(g[i]);
        }
    }
    cout << g << endl;
    return 0;
}

Measured memory_bytes: 0
N = int(input())
As = list(map(int, input().split()))
 
As.sort()
 
st = set(As)
m = As[-1]
rlt = 0
Fs = [1]*(m+1)
 
for i in range(N):
  if i > 0 and As[i] == As[i-1]:
    Fs[As[i]] = 0
    continue
  j = 2
  while As[i]*j <= m:
    Fs[As[i]*j] = 0
    j += 1

for a in As:
  rlt += Fs[a]
    
print(rlt)

Measured memory_bytes: 121336
#include <bits/stdc++.h>
#include <vector>
#include <cmath>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP2(i, m, n) for (int i = (m); i < (int)(n); ++i)
#define REPR(i, n) for (int i = (n)-1; i >= 0; --i)
#define REPR2(i, m, n) for (int i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a) sort(ALL(a), greater<int>())
#define REVERSE(a) reverse(ALL(a))
#define bit_search(bit, n) REP(bit, 1<<(n))
#define bit_check(bit, i) (bit>>(i)) & 1
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REP(i, a.size()) cin >> a[i];
#define INPUTP(a) REP(i, a.size()) cin >> a[i].first >> a[i].second;
#define ENDL cout << endl;
using namespace std;
using LL = long long;
using LD = long double;
using PII = pair<int, int>;
using VPII = vector<PII>;
using PLL = pair<LL, LL>;
using VPLL = vector<PLL>;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VC = vector<char>;
using VS = vector<string>;
using VB = vector<bool>;
using VD = vector<double>;
const LL INF = 1e18;
const LL MOD = 1e9 + 7;

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

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, w;
  cin >> n >> w;
  VPLL item(n);
  INPUTP(item);
  VVLL dp(n, VLL(w+1, 0));
  REP2(weight, item[0].first, w+1) dp[0][weight] = item[0].second;
  REP2(i, 1, n) REP(weight, w+1) dp[i][weight] = max(dp[i-1][weight], weight >= item[i].first ? dp[i-1][weight-item[i].first] + item[i].second : 0LL);
  cout << dp[n-1][w] << endl;

  return 0;
}


Measured memory_bytes: 79488
import java.util.*;

public class Main {
    static int N;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        N = sc.nextInt();
        int[] a = new int[N];
        for (int i = 0; i < N; i++) {
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);
        int small = 0;
        int large = N-1;
        long ans = 0;
        int left = a[large];
        int right = a[large];
        large--;
        while (large >= small) {
            int nextSmall = a[small];
            int nextLarge = a[large];
            int nextSmallLeft = Math.abs(left - nextSmall);
            int nextSmallRight = Math.abs(right - nextSmall);
            int nextLargeLeft = Math.abs(left - nextLarge);
            int nextLargeRight = Math.abs(right - nextLarge);
            int s = Math.max(nextSmallLeft, nextSmallRight);
            int l = Math.max(nextLargeLeft, nextLargeRight);
            boolean ll = nextLargeLeft > nextLargeRight;
            boolean sl = nextSmallLeft > nextSmallRight;
            boolean lgt = l > s;
            if(ll && lgt) {
                ans += nextLargeLeft;
                left = a[large--];
            } else if (!ll && lgt) {
                ans += nextLargeRight;
                right = a[large--];
            } else if (sl && !lgt) {
                ans += nextSmallLeft;
                left = a[small++];
            } else if (!sl && !lgt) {
                ans += nextSmallRight;
                right = a[small++];
            }
        }
        System.out.println(ans);
   }
}

Measured memory_bytes: 53712
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int n;
  cin >> n;
  vector<int> d(n);
  for (int i = 0; i < n; ++i) {
    cin >> d[i];
  }
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      ans += d[i] * d[j];
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
#define Vi vector<int>
#define Vl vector<long long>
#define pb(a) push_back(a)
using namespace std;

typedef long long ll;
const int inf=1000000000;
struct edge{
	int myc,to,c,cost;
};
struct pos{
	int to,cost,color;
};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main() {
	int n;
	cin>>n;
	int p;
	int a[4]={};
	int b[4]={};
	rep(i,n){
		rep(j,4)a[j]=b[j];
		rep(j,4)b[j]=inf;
		cin>>p;
		if(p==0){
			rep(j,4)b[0]=min(b[0],a[j]+j);
		}
		if(p==1){
			for(int j=1;j<4;++j)b[0]=min(b[0],a[j]+j);
			b[1]=a[0]+1;
		}
		if(p==2){
			for(int j=2;j<4;++j)b[0]=min(b[0],a[j]+j);
			b[1]=a[1]+2;
			b[2]=a[0]+2;
		}
		if(p==3){
			b[0]=a[3]+3;
			b[1]=a[2]+3;
			b[2]=a[1]+3;
			b[3]=a[0]+3;
		}
	}
	int total=inf;
	rep(i,4)total=min(total,b[i]);
	cout<<total<<endl;

	return 0;
}



Measured memory_bytes: 3116
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;
string s;
char a[5];
int main()
{
	int n;
	scanf("%d",&n);
	cin>>s;
	// cout<<s;
	// system("pause");
	int tot,sum=0;
	for (a[1]='0';a[1]<='9';a[1]++)
	{
		for (a[2]='0';a[2]<='9';a[2]++)
		{
			for (a[3]='0';a[3]<='9';a[3]++)
			{
				// printf(":: %c %c %c\n",a[1],a[2],a[3]);
				// system("pause");
				tot=0;
				for (int i=0;i<n&&tot<3;i++)
				{
					// printf("%d %c %c\n",i,s[i],a[tot+1]);
					if (s[i]==a[tot+1]) tot++;
				}
				if (tot==3) sum++;
			}
		}
	}
	printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 256
def main():
    n = int(input())
    sum_money = 0
    for i in range(n):
        money = input().split()
        if money[1] == "JPY":
            sum_money += int(money[0])
        else:
            sum_money += float(money[0]) * 380000


    print(sum_money)


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define    clr(v,d)      memset( v, d ,sizeof(v))
typedef  long long     ll ;
typedef  unsigned long long ull;
const double eps= (1e-9);
using namespace std;
int dcmp(long double a,long double b){   return fabsl(a-b)<=eps ? 0: (a>b)? 1:-1  ;}
int getBit(ll num, int idx) {return ((num >> idx) & 1ll) == 1;}
int setBit1(ll num, ll idx) {return num | (1ll<<idx);}
ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}
ll flipBit(ll num, int idx) {return num ^ (1ll<<idx);}
void GO(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);}
int countNumBit1(int mask) {int ret=0; while (mask) 	{mask &= (mask-1);++ret;	}return ret;}
string st;
int vis[30];
int main(){
    ll a,b;
    cin>>a>>b;
    for(int i=0;i<=10000;i++){
        int n1= (8*i)/100;
        int n2= (10*i)/100;
        if(n1==a&&n2==b){
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<"-1\n";
}














































Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s,t;
    cin>>s>>t;
    vector<vector<int>> dp(s.size()+1,vector<int>(t.size()+1));
    for(int i=1;i<=s.size();i++)
    {
        for(int j=1;j<=t.size();j++)
        {
            if(s[i-1]==t[j-1])
                dp[i][j]=max(dp[i][j],1 + dp[i-1][j-1]);
            else
            {
                dp[i][j]=max(dp[i][j],max(dp[i-1][j],dp[i][j-1]));
            }
        }
    }
    int i=s.size(),j=t.size();
    string ans="";
    while(j>0 && i>0)
    {
        // cout<<i<<" "<<j<<" "<<dp[i][j]<<endl;
        if(dp[i][j]==dp[i-1][j])
        {
            i--;
        }
        else if(dp[i][j]==dp[i][j-1])
        {
            j--;
        }
        else
        {
            ans=s[i-1] + ans;
            i--;
            j--;
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

int main(){
  int N,M;
  cin>>N>>M;
  int road[2*M];
  int city[N]={0};
  for(int i=0;i<M;i++){
    cin >> road[2*i] >> road[2*i+1];
    city[road[2*i]-1]++;
    city[road[2*i+1]-1]++;
  }
  for(int i=0;i<N;i++){
    cout<<city[i]<<endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 100000000000000 //10^14 100兆
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

int main(){
  ll S, W;
  cin >> S >> W;
  if(W >= S){
    cout << "unsafe" << endl;
  }
  else{
    cout << "safe" << endl;
  }
}

Measured memory_bytes: 3636
#include<stdio.h>
int main(){
  int n,k,s,d[100],mx,max,min,i,j,ans,b;
  while(scanf("%d %d",&n,&k),n||k){
    s=1;
    for(i=ans=mx=0;i<n;i++){
      scanf("%d",&d[i]);
      s*=d[i];
      if(i<k-1)continue;
      if(mx<s)mx=s;
      s/=d[i-k+1];
    }//printf("%d\n",mx);
    for(i=b=0;i+k-1<n;i++){//printf("b%d ",b);
      min=20;
      s=1;
      for(j=0;j<k;j++){
	if(min>d[i+j])min=d[i+j];
	s*=d[i+j];
      }
      for(max=0;i+j<n;j++){
	if(max<d[i+j])max=d[i+j];
      }//printf("%d ",max);
      if(max<b)max=b;
      s=s/min*max;//printf("s%d\n",s);
      if(ans<s-mx)ans=s-mx;
      if(b<d[i])b=d[i];
    }
    printf("%d\n",ans);
  }
  return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
ll W;
ll mem[100005][101];
ll kp(ll val[],ll wt[],ll n,ll i,ll w)
{
    if(i==n)return 0;
    if(mem[w][i]!=-1)return mem[w][i];
    if(w+wt[i+1]>W)
    {
        mem[w][i]=kp(val,wt,n,i+1,w);
        return mem[w][i];
    }
    else
    {
        mem[w][i]=max(val[i+1]+kp(val,wt,n,i+1,w+wt[i+1]),kp(val,wt,n,i+1,w));
        return mem[w][i];
    }
}

int main()
{
    ll n,i;
    cin>>n>>W;
    ll val[n+3],wt[n+3];
    for(i=1; i<=n; i++)
    {
        cin>>wt[i]>>val[i];
    }
    memset(mem,-1,sizeof(mem));
    cout<<kp(val,wt,n,0,0);



    return 0;
}


Measured memory_bytes: 79104
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
#include <complex>

using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef unsigned long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL) INF;

const double EPS = 1e-6;
const int MAX = 300 + 47;

int a, b, c, d;



int main()
{
    int q;
    scanf("%d", &q);
    FOR(_, 0, q)
    {
        scanf("%d%d%d%d", &a, &b, &c, &d);
        --c, --d;
        int res = (a + b) / (min(a, b) + 1);
        int l = 0, r = a + 1;
        while(r - l > 1)
        {
            int m = (l + r) / 2;
            if ((a - m + 1) * 1LL * res >= b - (m-1) / res)
                l = m;
            else r = m;
        }
        string ans = "";
        FOR(i, c, d+1)
            if (i < l + (l-1)/res)
            {
                if (i % (res + 1) == res)
                    ans += 'B';
                else
                    ans += 'A';
            }
            else
            {
                if ((a + b - i - 1) % (res + 1) == res)
                    ans += 'A';
                else
                    ans += 'B';
            }
        printf("%s\n", ans.c_str());
    }
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = null;
		try {
			scanner = new Scanner(System.in);
			execute(scanner);
		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private static void execute(Scanner scanner) {
		String s = scanner.nextLine();
		System.out.println(s.substring(0, s.length() - "FESTIVAL".length()));
	}
}


Measured memory_bytes: 21844
#include <stdio.h>

int main(int argc, char *argv[]){
  int w,h,x,y;
  double s,v;
  
  scanf("%d %d %d %d", &w, &h, &x, &y);

  s = ((double)w) * ((double)h) / 2.0;
  if(((w % 2) == 0) && ((h % 2) == 0)){
    if(((w / 2) == x) && ((h/2) == y)) printf("%f 1",s);
    else printf("%f 0",s);
  }
  else printf("%f 0",s);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#include<cmath>
#include<string>
#define pb push_back
#define ll long long
#define ull unsigned long long
#define deb(x) cerr<<#x<<" "<<x<<"\n"
#define debi cerr<<"hey sparky\n"
#define x first
#define y second
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define eps (double)1e-9
#define all(x) x.begin(),x.end()
#define int long long
using namespace std;
using namespace __gnu_pbds; 
typedef tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> pdbs;
 
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
//void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
// look for  all edge cases
//search for a pattern
 
int r , c , k;

int m[3002][3002];

int dp[3002][3002][4];

int calc(int row , int col , int  picked){
	
	
	if(dp[row][col][picked] != -1){
		return dp[row][col][picked];
	}
	
	int val = 0;
	
	if(row < r){
		int dummy = calc(row + 1 , col , 0);
		int cnt = picked;
		//debug(picked);
		//int now = 0;
		//int sum = 0;
		if(cnt < 3)
			val = max(val , calc(row + 1, col ,0 ) + m[row][col]);
		
		val = max(dummy , val);
	}
	if(col < c){
		val = max(val , calc(row , col+1 , picked));
		//int now = 0;
		//int sum = 0;
		int cnt = picked;
		if(cnt  < 3)
			val = max(val , calc(row , col+1 , picked +1 ) + m[row][col]);
	}
	
	if(row == r && col == c){
		//int now = 0;
		int sum = 0;
		//int cnt = picked;
		if(picked < 3)
			sum += m[row][col];
		val = max(val , sum);
	}
	
	
	//debug(row , col , val);
	dp[row][col][picked] = val;
	
	return val;
}


signed main() {
	
	cin >> r >> c >> k;
	for(int i =0 ;  i < k ; i++){
		int temp1 , temp2 , val;
		cin >> temp1 >> temp2 >> val;
		m[temp1][temp2] = val;
	}
	
	
	for(int i =0 ; i < 3001 ; i++){
		for(int j = 0; j < 3001; j++){
			for(int p =0 ; p < 4 ;p++){
				dp[i][j][p] = -1;
			}
		}
	}
	
	int ans = calc(1  , 1 , 0);
	
	cout<<ans; 
   
   return 0;
}


Measured memory_bytes: 355832
#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define pb push_back
#define reset(a,b) memset(a,b,sizeof a);
#define ALL(x) x.begin(),x.end()
#define debug(x) cout<<#x<<" = "<<(x)<<endl
#define sz(x) (int)(x.size())
#define lt(x) (int)(x.length())
#define MOD 1000000007 
#define mx 100003

int n;
map<int, int> jaw, banyak;

bool is_prime(int now){
	if(now == 1)
		return false;
	for(int i = 2; i * i <= now; i++){
		if(now % i == 0)
			return false;
	}
	return true;
}
vector<int> prima;

int berapa(int x){
	// debug(x);
	int cnt = 1;
	for(int i : prima){
		// debug(i);
		int hit = 0;
		while(x % i == 0){
			x /= i;
			hit += 1;
		}
		if(hit > 1)
			return 0;
		if(hit == 1)
			cnt *= -1;
	}
	return cnt;
}

long long POW(long long a, int b){
	long long ret = 1;
	while(b > 0){
		if(b & 1)
			ret = ret * a % MOD;
		b >>= 1;
		a = a * a % MOD;
	}
	return ret;
}

int main(){
	int k;
	set<int> faktor;
	cin >> n >> k;
	for(int i = 1; i * i <= n; i++){
		if(n % i == 0){
			faktor.insert(i);
			faktor.insert(n / i);
		}
	}
	for(int i : faktor){
		if(is_prime(i))
			prima.pb(i);
	}
	if(n & 1){
		for(int i : faktor){
			banyak[i] = POW(k, (i / 2) + 1);
		}
		for(auto it = faktor.rbegin(); it != faktor.rend(); it++){
			int i = *it;
			// debug(i);
			for(int x : faktor){
				if(i % x > 0)
					continue;
				// debug(x);
				int coef = berapa(i / x);
				jaw[i] += banyak[x] * coef;
				jaw[i] %= MOD;
				if(jaw[i] < 0)
					jaw[i] += MOD;
				// debug(x);
			}
		}
		// cin >> k;
		long long ans = 0;
		// for(auto i : jaw){
			// ans = ans + POW(k, (i.f + 1) / 2) * i.s % MOD;
		// }
		// cout << ans << endl;
		for(auto i : jaw){
			ans = (ans + 1LL * i.f * i.s) % MOD;
		}
		cout << ans << endl;
	}
	else{
		for(int i : faktor){
			banyak[i] = POW(k, __gcd(i, n / 2));
		}
		for(int i : faktor){
			// int i = *it;
			// debug(i);
			for(int x : faktor){
				if(i % x > 0)
					continue;
				// debug(x);
				int coef = berapa(i / x);
				jaw[i] += banyak[x] * coef;
				jaw[i] %= MOD;
				if(jaw[i] < 0)
					jaw[i] += MOD;
				// debug(x);
			}
		}
		// cin >> k;
		long long ans = 0;
		for(auto i : jaw){
			ans = (ans + 1LL * i.f * i.s % MOD) % MOD;
			// cout << i.f << ' ' << i.s << endl;
			// debug(ans);
		}
		cout << ans << endl;
		// for(auto i : jaw)
	}
}
// 1 1 1 ->  1
// 1 2 1 -> 2 1 1 -> 1 1 2 -> 3
// 2 1 2 -> 1 2 2 -> 2 2 1 -> 3
// 2 2 2 -> 1




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



int main()
{
	//freopen("D:\\patin.txt","r",stdin);
	int n;
	scanf("%d",&n);
	int sum = 0;
	int tmp;
	for(int i = 0;i < n;++i){
		scanf("%d",&tmp);
		sum += tmp-1;
	}	
	printf("%d\n",sum);
	return 0;	
} 

Measured memory_bytes: 504
s = input()
if (len(s) == 2 and s == "hi") or (len(s) == 4 and s == "hihi") or (len(s) == 6 and s == "hihihi") or (len(s) == 8 and s == "hihihihi") or (len(s) == 10 and s == "hihihihihi"):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
using ll = long long;


int main(void){
  ll n;
  cin >> n;
  ll ans = 1e18;
  for(ll i = 1; i*i <= n; i ++){
    if(n % i != 0) continue;
    ans = min(ans, i + n/i - 2);
  }
  cout << ans << endl;
}

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

using namespace std;

#define fo(i,n) for(int i=0; i<n; i++)
#define Fo(i,k,n) for(int i=k; i<n; i++)
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define clr(x) memset(x, 0, sizeof(x))
#define tr(it, a) for(auto it=a.begin(); it!=a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef vector<vl> vvl;

string s,t;
vector<char> ans;
int ls,lt;

vector<vector<pair<int, pair<int, int>>>> dp;

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

    cin>>s>>t;
    ls = s.length();
    lt = t.length();
    dp.resize(ls+1, vector<pair<int, pair<int, int>>>(lt+1, make_pair(0, make_pair(0, 0))));
    Fo(i,1,ls+1){
        Fo(j,1,lt+1){
            if(s[i-1]==t[j-1]){
                // if(((1+dp[i-1][j-1].first) > dp[i-1][j].first) && ((1+dp[i-1][j-1].first) > dp[i][j-1].first)){
                //     cout<<i<<" "<<j<<" "<<dp[i-1][j-1].first<<" "<<dp[i][j-1].first<<" "<<dp[i-1][j].first<<endl;
                // }
                dp[i][j] = max({make_pair(1+dp[i-1][j-1].first, make_pair(i-1, j-1)), make_pair(dp[i-1][j].first, make_pair(i-1, j)), make_pair(dp[i][j-1].first, make_pair(i, j-1))});
                // cout<<dp[i][j].first<<" "<<dp[i][j].second.first<<" "<<dp[i][j].second.second<<endl;
            }else{
                dp[i][j] = max(make_pair(dp[i-1][j].first, make_pair(i-1, j)), make_pair(dp[i][j-1].first, make_pair(i, j-1)));
            }
        }
    }
    // cout<<dp[0][0].first<<" "<<dp[1][1].first<<endl;
    auto nans = make_pair(0, make_pair(0,0));
    Fo(i,1,ls+1){
        Fo(j,1,lt+1){
            if(dp[i][j].first > nans.first){
                nans = dp[i][j];
            }
        }
    }
    // cout<<nans.first<<" "<<nans.second.first<<" "<<nans.second.second<<endl;
    auto curr = nans.second, previous = nans.second;
    if(nans.first!=0){
        ans.push_back(s[curr.first]);
    }
    while(curr != make_pair(0, 0)){
        int l = curr.first, r = curr.second;
        if(l+1 == previous.first && r+1 == previous.second){
            ans.push_back(s[l]);
        }
        previous = curr;
        curr = dp[l][r].second;
    }
    if(curr.first+1 == previous.first && curr.second+1 == previous.second){
        ans.push_back(s[curr.first]);
    }
    for(auto it=ans.rbegin(); it!=ans.rend(); it++){
        cout<<*it;
    }
    cout<<endl;
    
    return 0;
}

Measured memory_bytes: 105984
#include<stdio.h>
#include<stdlib.h>
int main(void){
	int n;
	int *a;
	scanf("%d", &n);
	a = (int *)malloc(sizeof(int) * (n+1));
	for (int p = 0; p < n; p++){
		scanf("%d", &a[p]);
	}
	int j=1;
	int k=0;
	for(int i=0; i<n; i++){
		if(a[i]==j){
			j++;
		}
		else{
			k++;
		}
	}
	if(k==n){
		printf("-1\n");
	}
	else{
		printf("%d\n", k);
	}
	free(a);
	return 0;
}


Measured memory_bytes: 896
import java.util.Scanner;

public class Main {


	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

		// input
		final int HEIGHT = scan.nextInt();
		final int WIDTH = scan.nextInt();
		char[][] pic = new char[HEIGHT][WIDTH];
		for(int i = 0; i < HEIGHT; i++){
			pic[i] = scan.next().toCharArray();
		}

		// answer
		for(int i = 0; i < HEIGHT; i++){
			for(int j = 0; j < WIDTH; j++){
				System.out.print(pic[i][j]);
			}
			System.out.println("");
			for(int j = 0; j < WIDTH; j++){
				System.out.print(pic[i][j]);
			}
			System.out.println("");
		}

	}
}


Measured memory_bytes: 27584
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int n;
  string s;
  cin >> n >> s;
  map<char, ll> mp;
  rep(i, 0, n) mp[s[i]]++;

  ll ans = mp['R'] * mp['G'] * mp['B'];
  rep(i, 0, n) {
    rep(x, 0, n) {
      int j = i - x, k = i + x;
      if (j < 0 || k >= n)
        break;
      if (s[i] != s[j] && s[j] != s[k] && s[i] != s[k])
        ans--;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3660
#include<stdio.h>
#include<string.h>
char s[20],t[20],u[20];
int main()
{
	int a,b;scanf("%s%s%d%d%s",s,t,&a,&b,u);
	if(!strcmp(s,u))printf("%d %d\n",a-1,b);
	else printf("%d %d\n",a,b-1);
}

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

int main(){

int N;
  cin >> N;
vector<int> vec(N);
int sum = 0;  
  for(int i = 0;i < N;i++){
  cin >> vec.at(i);
  }
  
  sort(vec.begin(), vec.end());
  
  if(N % 2 == 0){
  for(int i = 0;i < N;i++){
  if(i % 2 == 0) sum -= vec.at(i);
    else sum += vec.at(i);
    }
  }
  
  else {  
  for(int i = 0;i < N;i++){
  if(i % 2 == 0) sum += vec.at(i);
    else sum -= vec.at(i);
     }
  }
  
  cout << sum << endl;
  
  return 0;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll; typedef long double ld;
const int INF32 = 1e9+10;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, M; cin >> N >> M;
  int X[100010];
  for (int i = 0; i < M; i++) {
    cin >> X[i];
  }
  sort(X, X+M);
  int D[100010];
  for (int i = 0; i < M-1; i++) {
    D[i] = X[i+1]-X[i];
  }
  sort(D, D+M-1);
  if (M > N)
    cout << accumulate(D, D+M-N, 0L) << endl;
  else
    cout << 0 << endl;
}


Measured memory_bytes: 1024
import java.io.PrintWriter;
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		
		int N = sc.nextInt();
		int[] ans = new int[N];
		for(int i=0; i<N; i++)
			if((N-i-1)%2==0)
				ans[(N-i-1)/2] = sc.nextInt();
			else
				ans[(N+i)/2] = sc.nextInt();
		
		for(int i=0; i<N; i++)
			pw.print(ans[i] + (i==N-1 ? "\n" : " "));
		
		sc.close();
		pw.close();
	}
}


Measured memory_bytes: 94448
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!$BDs=P;~$K%3%a%s%H%"%&%H(B!!
#ifdef DEBUG_
#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

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

    template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int mod = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);
    LL K; cin >> K;
    LL loop = K / 50;
    VL ans(50);
    REP(i,50) ans[i] = 49+loop;
    LL rem = K % 50;
    if(rem != 0){

        REP(i,50-rem){
            ans[i] -= rem;
        }
        FOR(i,50-rem,50){
            ans[i] += 50 - (rem-1);
        }

    }
    cout << 50 << endl;
    REP(i,50){
        cout << ans[i] << " ";
    }
    cout << endl;


}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef pair<pii,pii> P;
typedef tuple<ll,ll,ll> tl;
typedef pair<double,double> pdd;
typedef vector<vector<ll>> mat;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll mod5=1000000009;
ll inf=1LL<<62;
double pi=3.141592653589793238462643383279L;
double eps=1e-14;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
#define mrep(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#define umh unordered_map<ll,ll,custom_hash>
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll c=gcd(a,b);
    return a*b/c;
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
    now%=md;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
ll popcount(ll n){
    ll ret=0;
    ll u=n;
    while(u>0){
        ret+=u%2;
        u/=2;
        
    }
    return ret;
}

int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    int n,m;cin>>n>>m;
    ll dp[m+1][n+1][n+1];
    memset(dp,0,sizeof dp);
    dp[0][n-1][1]=1;
    rep(i,0,m){
        rep(j,0,n+1){
            rep(k,1,n+1){
                (dp[i+1][j][k]+=dp[i][j][k]*k)%=mod;
                if(j>0&&k<n){
                    (dp[i+1][j-1][k+1]+=dp[i][j][k]*j)%=mod;
                }
                if(j>0)(dp[i+1][j-1][k]+=dp[i][j][k]*j)%=mod;
                (dp[i+1][j][k-1]+=dp[i][j][k]*k)%=mod;
            }
        }
    }
    
        /*rep(j,0,n+1){
            rep(k,0,n+1)cout<<dp[2][j][k]<<" ";
            cout<<endl;
        }*/
    
    cout<<dp[m][0][0]<<endl;
}



Measured memory_bytes: 213248
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <deque>
#include <string>
#include <fstream>
#define ni(n) scanf("%d", &n)
#define nl(n) scanf("%I64d", &n)
#define nai(a,n) for (int i = 0; i < (n); i++) ni((a)[i])
#define nal(a,n) for (int i = 0; i < (n); i++) nl((a)[i])
#define case(t) printf("Case #%d: ", (t))
#define pii pair<int, int>
#define vii vector<pii>
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define f first
#define s second
typedef long long ll;
const double pi = acos(-1);
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const int MAXN = 1e5 + 5;
const double eps = 1e-9;
using namespace std;
ll a[MAXN];

int main()
{
    int k;
    ni(k);
    nal(a, k);
    if (a[k - 1] != 2)
    {
        printf("-1\n");
        return 0;
    }
    ll lo = 1, hi = 1e18;
    ll ma = 0ll, mi = 1e19;
    while (lo <= hi)
    {
        ll mid = (lo + hi) >> 1;
        ll tmp = mid;
        for (int i = 0; i < k; i++)
        {
            tmp = (tmp / a[i]) * a[i];
            if (!tmp) break;
        }
        if (tmp > 2) hi = mid - 1;
        else
        {
            if (tmp == 2) mi = min(mi, mid), hi = mid - 1;
            else lo = mid + 1;
        }
    }
    if (mi == 0ll)
    {
        printf("-1\n");
        return 0;
    }
    lo = 1ll;
    hi = 1e18;
    while (lo <= hi)
    {
        ll mid = (lo + hi) >> 1;
        ll tmp = mid;
        for (int i = 0; i < k; i++)
        {
            tmp = (tmp / a[i]) * a[i];
            if (!tmp) break;
        }
        if (tmp > 2) hi = mid - 1;
        else
        {
            if (tmp == 2) ma = max(ma, mid), lo = mid + 1;
            else lo = mid + 1;
        }
    }
    if (ma == 0ll)
    {
        printf("-1\n");
        return 0;
    }
    cout << mi << " " << ma << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>

int* assignNum(int* num, int n);	// 配列をに数値を代入する処理

int main()
{
	int n;

	std::cin >> n;

	int* num = new int[n];

	num = assignNum(num, n);

	// 出力処理が何度もあり気に入らない。もう少しきれいにしたい
	for (int i = 0;i < n - 1;i++)
	{
		std::cout << num[(n - 1) - i] << ' ';
	}
	std::cout << num[0] << '\n';

	delete[] num;

	return 0;
}

int* assignNum(int* num, int n)
{
	for (int i = 0;i < n;i++)
	{
		std::cin >> num[i];
	}

	return num;
}



Measured memory_bytes: 3072
#include <iostream>

using namespace std;

int main(){
    int ab, bc, ca, area;
    scanf("%d %d %d", &ab, &bc, &ca);
    if(ab > bc && ab > ca){
        area = bc * ca / 2;
    }else if(bc > ab && bc > ca){
        area = ab * ca / 2;
    }else{
        area = ab * bc / 2;
    }
    printf("%d\n", area);
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cmath>
#include <cstddef>
#include <iostream>
#include <queue>
#include <stack>
#include <string>
#include <vector>

int main() {
  int A, B;
  std::cin >> A >> B;

  int p = 10*B;
  for (int i=0; i<10; ++i){
    auto pp = p + i;
    if (floor(pp*0.08) == A){
      std::cout << pp << std::endl;
      return 0;
    }
  }

  std::cout << -1 << std::endl;

  return 0;
}


Measured memory_bytes: 256
NN = input().split()
N = int(NN[0])
X = int(NN[1])
LL = input().split()
list1 = [0]
for i in range(N):
  
  a = list1[i] + int(LL[i])
  list1.append(a)
count = 0
for i in list1:
  if int(i) <= X:
    count +=1
print(count)

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

using namespace std;

int main(void)
{
	int H,W; cin>>H>>W;
	char c[H][W];
	for(int i = 0; i < H; i++){
		for(int j = 0; j < W; j++){
			cin>>c[i][j];
		}
	}
	
	//cout<<"\n"<<endl;
	
	for(int i = 0; i < 2*H; i++){
		for(int j = 0; j <W; j++){
			cout<<c[i/2][j];
		}
		cout<<endl;
	}
	return 0;
}



Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main()
{
  int n;
  cin>>n;
  int ans=1;
  int flag=0;
  int bef;
  cin>>bef;
  for(int i=1;i<n;i++)
  {
    int a;
    cin>>a;
    if(flag==0)
    {
      if(a>bef)flag=1;
      if(a<bef)flag=2;
    }
    else if(flag==1)
    {
      if(a<bef)
      {
        ans++;
        flag=0;
      }
    }
    else
    {
      if(a>bef)
      {
        ans++;
        flag=0;
      }
    }
    bef=a;
  }
  cout<<ans<<endl;
}
      
    

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1000;
char s[maxn+5];
inline int read()
{
    int x=0,f=1;char ch=getchar();
    for (;ch<'0'||ch>'9';ch=getchar()) if (ch=='-') f=-1;
    for (;ch>='0'&&ch<='9';ch=getchar()) x=(x<<1)+(x<<3)+ch-'0';
    return x*f;
}
int main()
{
    scanf("%s",s);
    int len=strlen(s);
    for (int i=0;i<len;i++) printf("x");
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.TreeMap;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		TreeMap<Integer, Integer> treeMap = new TreeMap<Integer, Integer>();
		int max = 0;
		while(scan.hasNext()) {
			Integer num = scan.nextInt();
			int count = 0;
			if(treeMap.containsKey(num)) {
				count = treeMap.get(num);
				if(max < count + 1) {
					max = count + 1;
				}
			}
			treeMap.put(num, count + 1);
		}
		for(Integer key : treeMap.keySet()) {
			if(treeMap.get(key) == max) {
				System.out.println(key);
			}
		}
		scan.close();
	}
}


Measured memory_bytes: 26280
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


class DisjointSetUnion:
    def __init__(self, n):
        self.n = n
        self.par = [-1] * n
        self.rank = [0] * n

    def root(self, x):
        if self.par[x] == -1:
            return x
        else:
            self.par[x] = self.root(self.par[x])
            return self.par[x]

    def same(self, x, y):
        return self.root(x) == self.root(y)

    def unite(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return
        if self.rank[x] < self.rank[y]:
            x, y = y, x
        if self.rank[x] == self.rank[y]:
            self.rank[x] += 1
        self.par[y] = x
        return


if __name__ == '__main__':
    n, q = map(int, readline().split())
    dsu = DisjointSetUnion(n)

    for i in range(q):
        t, u, v = map(int, readline().split())

        if t:
            print(int(dsu.same(u, v)))
        else:
            dsu.unite(u, v)


Measured memory_bytes: 13440
#include <bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define pii pair<int, int>
#define sz size()
#define pb push_back

using namespace std;

int a, b;

int main() {
    cin >> a >> b;
    if (a <= b * 2) {
        cout << 0;
    } else {
        cout << a - b * 2;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
#define int long long
#define str string
#define rep(i,j) for(int i=0;i<(int)(j);i++)
typedef long long ll;
typedef long double ld;
const ll inf = 4523372036854775807;
short gh[2][4] = { {0,0,-1,1},{-1,1,0,0} };
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to, cost;
};
struct S {//辺の情報を入れる変数
	int from, to, cost;
};
struct H {
	int x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(ld a, ld b, ld c, ld d) {
	return sqrt(pow(a - c, 2) + pow(b - d, 2));
}//rad＝座標上の2点間の距離
int ari(int a, int b, int c) {
	return (a + b)*c / 2;
}//等差数列の和
bool suf(ld a, ld b, ld c, ld d) {
	if (b <= c || d <= a) return 0;
	return 1;
}//[a,b),[c,d)
//---------------------------------------------------
//+++++++++++++++++++++++++++++++++++++++++++++++++++1
int n, m, a[200000], t;
bool b[200000];
signed main() {
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	cin >> m;
	sort(a, a + n);
	for (int i = 0; i < m; i++) {
		cin >> t;
		int k = lower_bound(a, a + n, t) - a;
		while (b[k])
			k++;
		if (k == n || a[k] != t) { cout << "NO\n"; return 0; }
		b[k] = 1;
	}
	cout << "YES\n";
	getchar(); getchar();
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<pi, pi> pp;
typedef pair<ll, ll> pl;
const double EPS = 1e-9;
const ll MOD = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;

ll a, b;

int main() {
    cin >> b >> a;
    ll ans = linf;
    for (ll q = 1; q <= 10*b; q++) {
        ll p = q*b/a;
        ll x = q*b-p*a;
        if (x >= b) continue;
        if (p+x > q) {
            ans = min(ans, q*b);
        }
    }
    if (ans == linf) cout << -1 << endl;
    else cout << ans << endl;
}



Measured memory_bytes: 3112
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>

#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))
#define FOR(i,n) for (int i = 1; (i) <= (n); ++ (i))
#define dump(x)  cout << #x << " = " << (x) << endl;
#define pb push_back
#define int long long

const int INF = 1e18;
const int MOD = 1e9+7;
//const lint LINF = 1e18;
const double eps = 0.000000001;//もとの値の10^(-16)まで

using namespace std;

//typedef pair<int, int> P;
//priority_queue< P, vector<P>, greater<P> > q;//ダイクストラの時、greaterで小さい順
//cout << fixed << setprecision(10) << ans << endl;
//int gcd(int a,int b){return b?gcd(b,a%b):a;}
int a[300000];
signed main(){
    int n;
    cin >> n;
    REP(i,n){
        cin >> a[i];
    }
    sort(a,a+n);
    reverse(a,a+n);
    int ans = 0;
    REP(i,n){
        if(i==0) continue;
        ans += a[i/2];
    }
    cout << ans << endl;



    return 0;
}

Measured memory_bytes: 5176
import collections
s = input()
s2 = collections.deque([int(i) for i in s])
mins = []
x = collections.deque(maxlen = 3)
x.append(s2.popleft())
x.append(s2.popleft())
x.append(s2.popleft())
while s2:
        y = 100*x[0]+ 10*x[1] + x[2]
        mins.append(abs(y - 753))
        x.append(s2.popleft())
y = 100*x[0]+ 10*x[1] + x[2]
mins.append(abs(y - 753))
print(min(mins))
        

Measured memory_bytes: 3444
{-# LANGUAGE CPP       #-}
{-# LANGUAGE MagicHash #-}

import           Control.Monad
import qualified Data.ByteString.Char8 as B
import qualified Data.List             as L
import qualified Data.Vector.Unboxed   as U
import           GHC.Exts

#define MOD 998244353

main :: IO ()
main = do
    [n,a,b,k] <- map read.words <$> getLine
    print $ solve n a b k

solve :: Int -> Int -> Int -> Int -> Int
solve n a b k = L.foldl' (+%) 0 $ do
    numA <- [0..min (div k a) n]
    (numB, 0) <- return $ quotRem (k - a * numA) b
    guard $ numB <= n
    return $! comb n numA *% comb n numB

comb :: Int -> Int -> Int
comb n k = U.unsafeIndex factCache n
    *% U.unsafeIndex recipFactCache k
    *% U.unsafeIndex recipFactCache (n - k)

lim :: Int
lim = 300000

factCache :: U.Vector Int
factCache = U.scanl' (*%) 1 $ U.generate lim (+1)

recipFactCache :: U.Vector Int
recipFactCache = U.scanr' (*%) (1 /% U.last factCache) $ U.generate lim (+1)

infixl 7 *%, /%
infixl 6 +%, -%

type IntMod = Int

intMod :: Int -> IntMod
intMod x = mod x MOD

(+%) :: IntMod -> IntMod -> IntMod
(I# x#) +% (I# y#) = I# ((x# +# y#) `remInt#` MOD#)
{-# INLINE (+%) #-}

(-%) :: IntMod -> IntMod -> IntMod
(I# x#) -% (I# y#) = I# ((x# -# y# +# MOD#) `remInt#` MOD#)
{-# INLINE (-%) #-}

(*%) :: IntMod -> IntMod -> IntMod
(I# x#) *% (I# y#) = I# ((x# *# y#) `remInt#` MOD#)
{-# INLINE (*%) #-}

(/%) :: IntMod -> IntMod -> IntMod
(I# x#) /% (I# y#) = go# y# MOD# 1# 0#
  where
    go# a# b# u# v#
        | isTrue# (b# ># 0#) = case a# `quotInt#` b# of
            q# -> go# b# (a# -# (q# *# b#)) v# (u# -# (q# *# v#))
        | otherwise = I# ((x# *# (u# +# MOD#)) `remInt#` MOD#)
{-# INLINE (/%) #-}


Measured memory_bytes: 8956
#include<cstdio>
#include<cmath>
#include<cstring>
using namespace std;
const int N=100000+10;
int n,m,R[N],D[N],l,r,d;
bool flag;
int find(int now){
    if(R[now]==-1) return now;
    int root=find(R[now]);
    D[now]+=D[R[now]];//更新距离
    R[now]=root;
    return root;
}
int main() {
    while(~scanf("%d%d",&n,&m)){
        flag=0;
        memset(R,-1,sizeof(R));
        memset(D,0,sizeof(D));
        for(int i=0;i<m;i++){
            scanf("%d%d%d",&l,&r,&d);
            if(flag) continue;
            int a=find(l),b=find(r);
            if(a==b){
                if(abs(D[r]-D[l])!=d) flag=1;
            }
            else {
                R[a]=b;
                D[a]=D[r]-D[l]+d;//直接更新点L的根相对于点R的根相对距离
            }
        }
        printf("%s\n",flag?"No":"Yes");

    }
    return 0;
}


Measured memory_bytes: 896
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int sx = sc.nextInt();
		int sy = sc.nextInt();
		int tx = sc.nextInt();
		int ty = sc.nextInt();

		StringBuilder str = new StringBuilder();
			for (int i = 0; i < tx-sx; i++) {
				str.append("R");
			}
			for (int i = 0; i < ty-sy; i++) {
				str.append("U");
			}
			for (int i = 0; i < tx-sx; i++) {
				str.append("L");
			}
			for (int i = 0; i < ty-sy; i++) {
				str.append("D");
			}

			str.append("DR");
			for (int i = 0; i < tx-sx; i++) {
				str.append("R");
			}
			for (int i = 0; i < ty-sy; i++) {
				str.append("U");
			}
			str.append("ULUL");

			for (int i = 0; i < tx-sx; i++) {
				str.append("L");
			}
			for (int i = 0; i < ty-sy; i++) {
				str.append("D");
			}
			str.append("DR");

		System.out.println(str.toString());
	}
}


Measured memory_bytes: 21844
type ABC(stream:System.IO.TextReader) =
  member this.Scan1 f = stream.ReadLine() |> f
  member this.Scan2 f = stream.ReadLine().Split() |> Array.map f |> (fun a -> (a.[0], a.[1]))
  member this.Scan3 f = stream.ReadLine().Split() |> Array.map f |> (fun a -> (a.[0], a.[1], a.[2]))
  member this.Scan4 f = stream.ReadLine().Split() |> Array.map f |> (fun a -> (a.[0], a.[1], a.[2], a.[3]))
  member this.ScanVecH f = stream.ReadLine().Split() |> Array.map f
  member this.ScanVecV n f = [ for i in 1..n -> stream.ReadLine() |> f ]
  member this.ScanMatrix n f  = [ for i in 1..n do yield stream.ReadLine().Split() |> Array.map f ]
  member this.ScanCharMatrix n = [| for i in 1..n -> stream.ReadLine().ToCharArray() |]
  member this.Close () = stream.Close()

let util = ABC(stdin)

let format n = (string n).PadLeft(6, '0')
 
let N, M = util.Scan2 int
let xs = util.ScanMatrix M int

xs
|> List.mapi (fun i -> fun x -> i, x.[0], x.[1])
|> List.groupBy (fun (_,a,_) -> a) 
|> List.collect (fun (_,block) ->
    block
    |> List.sortBy (fun (_,_,a) -> a) // 県内でソートして
    |> List.mapi (fun i -> fun (x,a,_) -> x, (format a) + (format (i+1)) ) // 名前に変換
   ) // bind/collect して平坦化
|> List.sortBy fst // 出力順序を調整して
|> List.map snd
|> String.concat "\n" // 文字列は先に作っておいて pirntfn 呼び出し回数を削減
|> printfn "%s"

util.Close()

Measured memory_bytes: 69880
#include <iostream>
using namespace std;
int main(){
  int n;
  cin>>n;
  int a;
  int p = 1, count = 0;
  for(int i=0; i<n; i++){
    cin>>a;
    if(a==p){
      p++;
    }
    else{
      count++;
    }
  }
  if(count==n){
    cout<<-1<<endl;
  }
  else{
    cout<<count<<endl;
  }
  return 0;
}


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

dic = {}

for i in range(1, n+1):
    dic[i] = a[i-1]

out = sorted(dic.items(), key=lambda x:x[1])

for i in range(n-1):
    print(out[i][0], end=' ')
print(out[n-1][0])

Measured memory_bytes: 26268
#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() {
  int n, d;
  cin >> n >> d;

  int count = 1;
  int currentEndPoint = 2 * d + 1;
  while (currentEndPoint < n) {
    currentEndPoint += (2 * d + 1);
    count++;
  }
  cout << count << endl;

  return 0;
}


Measured memory_bytes: 256