akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
using namespace std;

int a,l;
int vis[1000000];
int mi[10],ma[10];

int main(){
  while(cin >> a >> l,l){
    int lim = 1;
    for(int i=0;i<l;i++)lim *= 10;

    for(int i=0;i<lim;i++)vis[i] = -1;
    vis[a] = 0;

    for(int cnt=1;;cnt++){
      for(int i=0;i<l;i++){
	mi[i] = ma[i] = a%10;
	a /= 10;
      }
      sort(mi,mi+l);
      sort(ma,ma+l,greater<int>());

      for(int i=0;i<l;i++)ma[i] -= mi[i];
      for(int i=0;i<l;i++)a = a*10 + ma[i];

      if(vis[a]>=0){
	cout << vis[a] << " " << a << " " << cnt - vis[a] << endl;
	break;
      }
      vis[a] = cnt;
    }
  }
}

Measured memory_bytes: 5084
s = gets().chomp

s1 = s[0, 2].to_i
s2 = s[2, 2].to_i

s2_is_ok = false
if s2 > 0 && s2 < 13
  s2_is_ok = true
end

s1_is_ok = false
if s1 > 0 && s1 < 13
  s1_is_ok = true
end

if s1_is_ok && s2_is_ok
  puts 'AMBIGUOUS'
elsif s1_is_ok && !s2_is_ok
  puts 'MMYY'
elsif !s1_is_ok && s2_is_ok
  puts 'YYMM'
else
  puts 'NA'
end

Measured memory_bytes: 14372
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define ceiling(a,b) (((a)+(b)-1)/(b))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#define ykh mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#ifdef i_am_noob
#define debug(a) print2(#a,a)
#else
#define debug(a)
#endif
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>

using namespace std;
using namespace __gnu_pbds;

const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod2;

inline int add(int a, int b){return (a+b>=MOD?a+b-MOD:a+b);}
inline int sub(int a, int b){return (a+MOD-b>=MOD?a-b:a+MOD-b);}
int Pow(int a, int b){
	if(!b) return 1;
	int tmp=Pow(a*a%MOD,b>>1);
	return (b&1?tmp*a%MOD:tmp);
}
inline int inverse(int n){return Pow(n,MOD-2);}

const int maxn=10000005;
//i_am_noob
int n,a[maxn]={0},ans=0;

signed main(){
    ios_base::sync_with_stdio(0),cin.tie(0);
    cin >> n;
    rep2(i,1,n+1) for(int j=i; j<maxn; j+=i) a[j]++;
    rep2(i,1,n+1) ans+=i*a[i];
    print1(ans);
    return 0;
}


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

const int N = 100005;

int n, a[N];

int main() {
    scanf("%d", &n);
    for (int i = 0; i < 2 * n; ++i)
        scanf("%d", a + i);
    sort(a, a + 2 * n);
    int result = 0;
    for (int i = 0; i < 2 * n; i += 2)
        result += a[i];
    printf("%d\n", result);
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n= Integer.parseInt(sc.nextLine());
		int taroPoint=0;
		int hanakoPoint=0;
		
		for(int i=0;i<n;i++){
			String[] word = sc.nextLine().split(" ");
			if(word[0].equals(word[1])){
				taroPoint+=1;
				hanakoPoint+=1;
			}else{
				int wordlength = word[0].length();
				if(wordlength>word[1].length()){
					wordlength=word[1].length();
				}
				for(int j=0;j<wordlength;j++){
					if(word[0].charAt(j)>word[1].charAt(j)){
						taroPoint+=3;
						break;
					}else if(word[0].charAt(j)<word[1].charAt(j)){
						hanakoPoint+=3;
						break;
					}
					if(j==wordlength-1){
						if(word[0].length()>word[1].length()){
							taroPoint+=3;
						}else{
							hanakoPoint+=3;
						}
					}
				}
			}
		}
		System.out.println(taroPoint+" "+hanakoPoint);
	}
}

Measured memory_bytes: 30912
#include<bits/stdc++.h>
using namespace std;
inline void upmax(short &x,const short &y){if(y>x) x=y;}
const int N=105;short f[N][N][N][N],sum1[N][N],sum2[N][N];
int n,m,tx,ty;
void gao(){
    int limu=tx-1,limd=n-tx,liml=ty-1,limr=m-ty;
    for(int u=0;u<=limu;u++)for(int d=0;d<=limd;d++)for(int l=0;l<=liml;l++)for(int r=0;r<=limr;r++)
    {int L=max(ty-l,r+1),R=min(ty+r,m-l);
		if(L<=R){upmax(f[u+1][d][l][r],f[u][d][l][r]+(tx-u-1>=d+1?sum1[tx-u-1][R]-sum1[tx-u-1][L-1]:0));
			upmax(f[u][d+1][l][r],f[u][d][l][r]+(tx+d+1<=n-u?sum1[tx+d+1][R]-sum1[tx+d+1][L-1]:0));}
        L=max(tx-u,d+1),R=min(tx+d,n-u);
        if(L<=R){upmax(f[u][d][l+1][r],f[u][d][l][r]+(ty-l-1>=r+1?sum2[R][ty-l-1]-sum2[L-1][ty-l-1]:0));
            upmax(f[u][d][l][r+1],f[u][d][l][r]+(ty+r+1<=m-l?sum2[R][ty+r+1]-sum2[L-1][ty+r+1]:0));}
    }printf("%d\n",f[limu][limd][liml][limr]);
}

int main(){
    static char s[105];scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++){scanf("%s",s+1);for(int j=1;j<=m;j++)
    {if(s[j]=='E') tx=i,ty=j;sum1[i][j]=sum1[i][j-1]+(s[j]=='o');sum2[i][j]=sum2[i-1][j]+(s[j]=='o');}}
    gao();return 0;
}

Measured memory_bytes: 207232
S = input()

ans = [S[0]]
for i in range(1,4):
    can = []
    for a in ans:
        can.append(a+'+'+S[i])
        can.append(a+'-'+S[i])
        ans = can

for j in ans:
    if eval(j) == 7:
        print(j+"=7")
        exit()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  ll sum = 0;
  rep(i, n){
    cin >> a[i];
    sum = sum ^ a[i];
  }
  
  rep(i, n){
    ll ans = sum ^ a[i];
    cout << ans << endl;
  }
  
  return 0;
}

Measured memory_bytes: 4748
N, M = map(int,input().split())

h_list = list(map(int, input().split()))
c_dic = { n:[] for n in range(N) }
#print(c_dic)

#print(h_list)

mycnt = 0 
for m in range(M):
    S, E = map(int,input().split())
    #print(S,E)
    c_dic[S-1] += [E-1]
    c_dic[E-1] += [S-1]
#print(c_dic)

for d in c_dic:
    myflag = 0
    if len(c_dic[d]) == 0:
        mycnt += 1
    else:
        for c in c_dic[d]:
            if h_list[d] <= h_list[c]:
                myflag = 1
                break
        if myflag == 0:
            mycnt += 1
print(mycnt)

Measured memory_bytes: 37788
using I = short;

#include<vector>
class BinaryIndexedTree {
 public:
  BinaryIndexedTree(int s) : node_(s + 1, 0) {}
  I sum(int index) const {
    I result = 0;
    for(int i = index + 1; i > 0; i -= i & -i) result += node_[i];
    return result;
  }
  I sum(int left, int right) const {
    return sum(right) - sum(left - 1);
  }
  void add(int index, I value) {
    for(int i = index + 1; i < node_.size(); i += i & -i) node_[i] += value;
  }
 private:
  std::vector<I> node_;
};

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

enum {UL, LR};
struct Event {
  I i, type, l;
  bool operator<(const auto& e) const {return make_tuple(l, type, i) > make_tuple(e.l, e.type, e.i);};
};

int main() {
  int H, W, L, P;
  cin >> H >> W >> L >> P;

  vector<vector<bool>> naught(H, vector<bool>(W));
  for(auto i = 0; i < P; ++i) {
    int A, B;
    cin >> A >> B;
    naught[A-1][B-1] = true;
  }

  vector<vector<I>> ul, lr, ult, lrt;
  ul = lr = ult = lrt = vector<vector<I>>(H, vector<I>(W, 1));
  for(auto i = 0; i < H; ++i) {
    for(auto j = W-2; 0 <= j; --j) {
      if(naught[i][j]) ul[i][j] = 0;
      else             ul[i][j] += ul[i][j+1];
    }
    for(auto j = 1; j < W; ++j) {
      if(naught[i][j]) lr[i][j] = 0;
      else             lr[i][j] += lr[i][j-1];
    }
  }
  for(auto j = 0; j < W; ++j) {
    for(auto i = H-2; 0 <= i; --i) {
      if(naught[i][j]) ult[i][j] = 0;
      else             ult[i][j] += ult[i+1][j];
    }
    for(auto i = 1; i < H; ++i) {
      if(naught[i][j]) lrt[i][j] = 0;
      else             lrt[i][j] += lrt[i-1][j];
    }
  }
  for(auto i = 0; i < H; ++i) for(auto j = 0; j < W; ++j) {
    lr[i][j] = min(lr[i][j], lrt[i][j]);
    ul[i][j] = min(ul[i][j], ult[i][j]);
  }

  long long ans = 0;

  for(auto i = -W+1; i < H; ++i) {
    int N = min(H-i, W);
    BinaryIndexedTree BIT_UL(N), BIT_LR(N);
    vector<Event> event;
    for(I k = 0; k < N; ++k) {
      if(i+k < 0) continue;
      if(!ul[i+k][k]) continue;
      event.push_back({k, UL, ul[i+k][k]});
      event.push_back({k, LR, lr[i+k][k]});
    }
    sort(begin(event), end(event));
    for(auto q: event) {
      if(q.type == UL) {
        BIT_UL.add(q.i, 1);
        auto i = q.i+L-1;
        auto j = q.i+q.l-1;
        if(i > N-1) continue;
        if(j < i) continue;
        ans += BIT_LR.sum(i, min(j, N-1));
      } else {
        BIT_LR.add(q.i, 1);
        auto i = q.i-q.l+1;
        auto j = q.i-L+1;
        if(j < 0) continue;
        if(i > j) continue;
        ans += BIT_UL.sum(max(i, 0), j);
      }
    }
  }

  cout << ans << endl;
}

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

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

	int n,a,b;

	cin >> n >> a >> b;

	cout << min(n*a,b) << '\n';
	 
    return 0;
}

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

int main() {
  int w;
  int h;
  int x;
  int y;
  int r;
  cin >> w;
  cin >> h;
  cin >> x;
  cin >> y;
  cin >> r;
  if (0 <= x - r) {
    if (0 <= y - r) {
      if (w >= x + r) {
        if  (h >= y + r) {
          cout << "Yes" << endl;
        } else {
          cout << "No" << endl;
        }
      } else {
         cout << "No" << endl;
      } 
    } else {
      cout << "No" << endl;
    } 
  } else {
    cout << "No" << endl;
  }
}


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

const double pi = 3.14159265359;

int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif
    double n;
    cin >> n;
    cout << setprecision(6) << fixed << 2.0 * pi * n << "\n";
}


Measured memory_bytes: 3784
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main()
{
	int N;
	ll K;
	cin >> N >> K;

	auto maxBit = 42;
	vector<vector<ll>> sumBit(2, vector<ll>(maxBit));
	for (auto i = 0; i < N; ++i)
	{
		ll A;
		cin >> A;
		for (auto j = 0; j < maxBit; ++j)
		{
			auto bit = 1ll << j;
			if ((A & bit) != 0)
			{
				sumBit[1][j] += bit;
			}
			else
			{
				sumBit[0][j] += bit;
			}
		}
	}

	vector<ll> sum;
	sum.push_back(0);
	for (auto i = 0; i < maxBit; ++i)
	{
		sum.push_back(sum[i] + max(sumBit[0][i], sumBit[1][i]));
	}

	auto current = 0ll;
	for (auto i = 0; i < maxBit; ++i)
	{
		if ((K & (1ll << i)) != 0)
		{
			current += sumBit[0][i];
		}
		else
		{
			current += sumBit[1][i];
		}
	}

	auto ans = current;
	for (auto i = 0; i < maxBit; ++i)
	{
		if ((K & (1ll << i)) != 0)
		{
			current -= sumBit[0][i];
			auto temp = current + sum[i] + sumBit[1][i];
			ans = max(ans, temp);
		}
		else
		{
			current -= sumBit[1][i];
		}
	}
	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long INF=1000000000;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < n;i++)
#define REP(i, n) for (int i = 0; i <= n;i++)
ll dp[105][100005];

int main(){
    ll n,W;
    cin>>n>>W;
    ll v[n],w[n],sum=0;
    rep(i,n){
        cin >> w[i] >> v[i];
        sum += v[i];
    }
    ll dp[sum+1];
    REP(i, sum) dp[i] = INF;
    dp[0]=0;
    rep(i,n){
        for(int j = sum - v[i]; j >= 0;j--){
            dp[j + v[i]] = min(dp[j + v[i]], dp[j] + w[i]);
        }
    }
    ll ans = 0;
    for (int i = sum; i >= 0;i--){
        if(dp[i]<=W){
            ans = max((ll)i, ans);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
int i;
int count=0;


void Linear(int *A,int key){
  
  int k=0;
  A[i]=key;
  while(A[k] != key){
    k++;

  }

  if( k == i) return;

  count++;
  return ;


}

main(){


  int A[100000],t,j,q,n;


  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }

  scanf("%d",&q);
 for(j=0;j<q;j++){

   scanf("%d",&t);
   Linear(A,t);
 }


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

Measured memory_bytes: 640
def dfs(v, k, s):
    if k == K:
        return 1 if s == S else 0
    res = 0
    for i in range(v + 1, N + 1):
        res += dfs(i, k + 1, s + i)
    return res

while True:
    N, K, S = map(int, input().split())
    if not N:
        break
    print(dfs(0, 0, 0))

Measured memory_bytes: 6720
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int[] tmp = parceIntArray(br.readLine().split(" "));
		int n = tmp[0];
		int m = tmp[1];
		tmp = null;
		int[][] matrix = new int[n][m];
		int[][] vector = new int[m][1];
		for(int i = 0;i < n;i++){
			matrix[i] = parceIntArray(br.readLine().split(" "));
		}
		for(int i = 0;i < m;i++){
			vector[i][0] = Integer.parseInt(br.readLine());
		}
		for(int i = 0;i < n;i++){
			int sum = 0;
			for(int j = 0;j < m;j++){
				sum += matrix[i][j] * vector[j][0];
			}
			System.out.println(sum);
		}
	}
	
	static int[] parceIntArray(String[] strArr)throws NumberFormatException{
		int [] arr = new int[strArr.length];
		for(int i = 0;i < arr.length;i++){
			arr[i] = Integer.parseInt(strArr[i]);
		}
		return arr;
	}
}

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

ULL K, N;
string S;
const ULL M = 1000000007;

const ULL Z = 2000000;
ULL F[Z + 1], I[Z + 1], iF[Z + 1];
ULL C(ULL n, ULL r) { return F[n] * iF[r] % M * iF[n - r] % M; }
ULL G[Z + 1];

int main() {
	F[0] = 1; I[1] = 1; iF[0] = 1;
	for (UL i = 1; i <= Z; i++) F[i] = F[i - 1] * i % M;
	for (UL i = 2; i <= Z; i++) I[i] = M - M / i * I[M % i] % M;
	for (UL i = 1; i <= Z; i++) iF[i] = iF[i - 1] * I[i] % M;

	cin >> K >> S;
	N = S.size();

	ULL ans = 0;
	ULL m = 1;
	rep(i, K) m = m * 26 % M;
	for (UL j = N; j <= N + K; j++) {
		ULL tmp = C(j - 1, N - 1);
		tmp = tmp * m % M;
		m = m * 25 % M * I[26] % M;
		ans += tmp;
	}

	ans %= M;
	cout << ans;

	return 0;
}


Measured memory_bytes: 52172
#include <iostream>
#include <string>
#include <math.h>
using namespace std;

int main() {
    int n, min = 1000;
    string s;
    cin >> s;
    for(int i = 0; i < s.size()-2; ++i){
        n = abs(753 - (s[i]-48)*100 - (s[i+1]-48)*10 - (s[i+2]-48));
        if(n < min) min = n;
    }

    cout << min << "\n";
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class A
{
	public static void Main()
	{
		char[] S = GetString().ToCharArray();
		if(S.Length == 3)
			Array.Reverse(S);
						
		Console.WriteLine(S);
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
 
#define fi first
#define se second
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
 
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
int L,R,vis[10000];
vi v;
int main(){
    cin >> L >> R;
    if(R-L+1 >= 2019) return puts("0"),0;
    ll MIN = 1e9; 
    for(int i = L;i < R; ++i){
        for(int j = i+1;j <= R; ++j){
            MIN = min(1ll*i*j%2019,MIN);
        }
    }
    cout << MIN << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int n;
    int a,c,d;
    int tatemono[4][3][10]={{}};
    cin >>n;
    int b,f,r,v;
    for(a=0;a<n;a++){
        cin >>b >>f >>r >>v;
        tatemono[b-1][f-1][r-1]+=v;
    }
    for(a=0;a<4;a++){
        for(c=0;c<3;c++){
            for(d=0;d<10;d++){
        cout << " ";
        cout << tatemono[a][c][d];
            }
            cout << endl;
        }
        if(a<3) cout << "####################" << endl;
    }
    return 0;
}


Measured memory_bytes: 3108
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
d = b[a[0]-1]


for i in range(1,n):
  dishname = a[i]
  d += b[dishname-1]
  if a[i] - a[i-1] == 1:
    d += c[dishname - 2]
  
print(d)
  


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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    int ans=0;
    int n,m;
    cin>>n>>m;
    bool b[10][10];
    m0(b);
    for (int i = 0; i < m; i++)
    {
        int k;
        cin>>k;
        for (int j = 0; j < k; j++)
        {
            int ss;
            cin>>ss;
            b[i][ss-1]=true;
        }
    }
    int p[10];
    for (int i = 0; i < m; i++)
    {
        cin>>p[i];
    }
    

    for (int bit = 0; bit < (1<<n); bit++)
    {
        bool ok = true;
        for (int denkyu = 0; denkyu < m; denkyu++)
        {
            int cnt=0;

            for (int swi = 0; swi < n; swi++)
            {
                if(b[denkyu][swi] && (bit & (1<<swi)) >0) cnt++;
            }
            

            if(cnt%2==p[denkyu]) continue;
            else {
                ok=false;
                break;
            }
        }
        
        if(ok) ans++;
    }
    

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=998244353;
const ll LINF=1LL<<60;
const int INF=1<<30;

//繰り返し二乗法
ll mod_pow(ll x,ll n){
	ll res = 1;
	while(n > 0){
		if(n & 1){
			res = res * x % mod;
		}
		x = x * x % mod;
		n >>= 1;
	}
	return res;
}

int main(){
	ll n;cin>>n;
	vector<ll> d(n);
	for(ll i = 0; i < n; i++) {
		cin>>d[i];
		if (i != 0 && d[i] == 0){
			cout << 0 << endl;
			return 0;
		}
	}
	if (d[0] !=  0){
		cout << 0 << endl;
		return 0;
	}
	vector<ll> cnt(n,0);
	for(ll i = 0; i < n; i++) {
		cnt[d[i]]++;
	}
	ll l;
	for(ll i = 1; i < n; i++) {
		if (cnt[i] == 0){
			l = i;
			for(ll j = i + 1; j < n; j++) {
				if (cnt[j] != 0){
					cout << 0 << endl;
					return 0;
				}
				break;
			}
		}
	}
	ll ans = 1;
	for(ll i = 1; i < min(l,n); i++) {
		ans *= mod_pow(cnt[i - 1] % mod,cnt[i]);
		ans %= mod;
	}
	cout << ans << endl;

	return 0;
}

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

// グローバル変数
ll n;
vector<pair<ll, ll>> a;

// 関数プロトタイプ
void input();
void solve();

int main(void)
{
    input();
    solve();  
}

// 標準入力
void input() {
    cin >> n;
    a.resize(n);
    for (int i = 1; i <= n;i++) {
        ll num = 0;
        cin >> num;
        a.at(i-1) = make_pair(num, i);
    }
}

void solve() {
    sort(a.begin(), a.end());
    for (int i = 0; i < n;i++) {
        cout << a[i].second << " ";
    }
    cout << endl;
}

Measured memory_bytes: 2432
#include<cstdio>
#include<algorithm>
using namespace std;
int main(void)
{
	int i,a[3];
	for(i=0;i<3;i++){
		scanf("%d",&a[i]);
	}
	sort(a,a+3);
	printf("%d\n",a[2]*10+a[1]+a[0]);
	return 0;
}
		

Measured memory_bytes: 1708
#include <stdio.h>
#include <stdlib.h>
 
int main(void)
{
  int i;
  int width, height;
  char **matrix;
 
  scanf("%d %d",&height, &width);
 
  matrix = malloc(sizeof(char *) * height);
  for(i = 0; i < height; i++) {
    matrix[i] = malloc(sizeof(char) * (width+1));
  }
  
  for(i = 0; i < height; i++) {
    scanf("%s", matrix[i]);
  }
 
  for(i = 0; i < height; i++) {
    printf("%s\n%s\n",matrix[i],matrix[i]);
  }
 
  for(i = 0; i < height; i++) {
    free(matrix[i]);
  }
 
  free(matrix);
 
  return 0;
}


Measured memory_bytes: 128
s = input()

#if s == "SSS":
    #print(0)
#elif s == "RSS" or "SRS" or "SSR" or "RSR":
    #print(1)
#elif s == 'RRS' or 'SRR':
    #print(2)
#elif s == "RRR":
    #print(3)

if s.count("R") == 0:
    print(0)
elif s.count("R") == 1 or s == "RSR":
    print(1)
elif s.count("R") == 2:
    print(2)
elif s.count("R") == 3:
    print(3)


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

const int N = 55;
int n, m;
pair<int, int> person[N], check[N];

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> n >> m;
	for(int i = 1; i <= n; i++)
		cin >> person[i].first >> person[i].second;
	for(int i = 1; i <= m; i++)
		cin >> check[i].first >> check[i].second;

	for(int i = 1; i <= n; i++) {
		int ans = -1, best = 1e9;
		for(int j = 1; j <= m; j++) {
			if(best > abs(person[i].first - check[j].first) + abs(person[i].second - check[j].second)) {
				best = abs(person[i].first - check[j].first) + abs(person[i].second - check[j].second);
				ans = j;
			}
		}
		cout << ans << '\n';
	}

	return 0;
}

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

using namespace std;

int main()
{
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);
	cout << a[0] << " " << a[1] << " " << a[2] << endl;

	return 0;
}

Measured memory_bytes: 3112
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<long long,long long> Pll;
#define fout(num) cout << fixed << setprecision(20) << (num) << endl
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ
//vector<vector<ll>> dp(n,vector<ll>(n))
//exist x map o setconst ll MOD = 1e9+7;return fac[n]*(finv[k]*finv[n-k] % MOD) % MOD;

signed main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int n; cin >> n;
    int a=0,b=0,c=0,d=0;
    rep(i,n){
        string s; cin >> s;
        if(s=="AC") a++;
        else if(s=="WA") b++;
        else if(s=="TLE") c++;
        else d++;
    }
    cout << "AC x " << a << endl;
    cout << "WA x " << b << endl;
    cout << "TLE x " << c << endl;
    cout << "RE x " << d << endl;
}



Measured memory_bytes: 3656
from collections import Counter

N = int(input())
D = list(map(int, input().split()))

mod = 998244353
c = Counter(D)
m = max(c.keys())

if D[0] == 0 and c[0] == 1:
  ans = 1
  for i in range(1, m+1):
    ans *= c[i-1]**c[i]
    ans %= mod
  print(ans)
else:
  print(0)

Measured memory_bytes: 24248
using System;
using System.Linq;
class Test{ 
  public static void Main(){    
    var KN =  Console.ReadLine().Split(' ').Select(n => int.Parse(n)).ToList();
    var nums = Console.ReadLine().Split(' ').Select(n => int.Parse(n)).ToList();
    long between = 0;
    for(int i =0; i<KN[1]; i++){
      if(i == KN[1]-1){
        if(KN[0] - nums[i] + nums[0] > between ){
          between = KN[0] - nums[i] + nums[0];
        }
      }else{
        if(nums[i+1]- nums[i] > between){
          between = nums[i+1]- nums[i];
        }
      }
    }   
    Console.WriteLine(KN[0]-between);
  }
}

Measured memory_bytes: 34780
// AOJ 2253: Brave Force Story
// 2017.11.10 bal4u@uu

#include <stdio.h>
#include <string.h>

#define BASE 100

typedef struct { int x, y, k; } Q;
Q q[100000]; int top, end;

char b[200][200];
char mk[200][200];
int mv[6][2] = {{-1,-1},{-1,0},{0,-1},{0,1},{1,0},{1,1}};

int main()  
{  
	int t, n, i, x, y, x2, y2, k, ans;

	while (scanf("%d%d", &t, &n) && t > 0) {
		memset(mk, 0, sizeof(mk)), memset(b, 0, sizeof(b));
		while (n--) {
			scanf("%d%d", &x, &y);
			b[x+BASE][y+BASE] = 1;
		}
		scanf("%d%d", &x, &y);
		x += BASE, y += BASE;
		mk[x][y] = 1;
		q[0].x = x, q[0].y = y, q[0].k = 0; top = 0, end = 1;
		while (top < end) {
			x = q[top].x, y = q[top].y, k = q[top++].k;
			if (k++ >= t) continue;
			for (i = 0; i < 6; i++) {
				x2 = x + mv[i][0];
				y2 = y + mv[i][1];
				if (b[x2][y2] || mk[x2][y2]) continue;
				mk[x2][y2] = 1;
				q[end].x = x2, q[end].y = y2, q[end++].k = k;
			}
		}
		for (ans = 0, x = 0; x < 200; x++) for (y = 0; y < 200; y++)
			if (mk[x][y]) ans++;
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 1868
#include <bits/stdc++.h>
 
using namespace std;
 
int n;
 
main(){
    cin >> n;
    while (n != 0){
        if (n % 10 == 7){
            cout << "Yes";
            exit(0);
        }
        n /= 10;
    }
    cout << "No";
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main(){
   int a,b,c,d;
  cin>>a>>b>>c>>d;
    int a1=a*b;
    int a2=c*d;
   if(a1>a2){
    cout<<a1;
  }
    else{
   cout<<a2;
}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
using pll=pair<long long,long long>;
#define ITR(i,c) for(auto i=begin(c);i!=end(c);++i)
#define FORE(x,c) for(auto &x:c)
#define FOR(i,a,n) for(int i=a,i##_len=(int)n;i<i##_len;++i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i=((int)(n)-1);i>=0;--i)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)   // c++14
#define SZ(c) ((int)c.size())
#define EXIST(c,x) (c.find(x)!=end(c))
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0}, DY[9]={-1,0,1,0,-1,1,1,-1,0};
const int INF=1001001001; const long long INFLL=1001001001001001001ll;
template<class T> ostream& operator << (ostream &os, const vector<T> &v) {
    ITR(i,v) os << *i << (i==end(v)-1 ? "" : " "); return os; }
template<class T> istream& operator >> (istream &is, vector<T> &v) {
    ITR(i,v) is >> * i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
        is >> p.first >> p.second; return is; }
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;}
//------------------------------------------------------------------------------
struct before_main_function {
    before_main_function() {
    #ifdef int
        cerr<<"\x1b[7m"<<"'int' is defined as 'long long' !!!!"<<"\x1b[m"<<endl;
    #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(12)<<fixed;
    }
} before_main_function;
//------------------------------------------------------------------------------

signed main() {
    int x,ans=0;
    cin>>x;
    if(x>11) {
        ans+=(x/11)*2;
        x%=11;
    }
    if(x==0);
    else if(x<=6) ans+=1;
    else if(x<=11) ans+=2;
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;
 
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef int64_t ll; typedef vector<int> VI; typedef pair<int,int> pii;
const ll mod = 1e9+7;

void dbg(){ cerr << "\n"; }  
template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

int main()
{
 
	//cin.tie(0); ios_base::sync_with_stdio(false);
	const int MX=200001;
	int n, ch;
	cin >>n >>ch;
	vector<vector<int8_t>> usd(ch+2, vector<int8_t>(MX+20));
	
	//VI s(n), t(n), c(n);
	
	rep(i, n){
		int s,t,c;
		cin >>s >> t >>c;
		usd[c-1][max(0, 2 * s - 1)] += 1;
		usd[c-1][2*t] -= 1;
	}
	
	rep(i,ch){
		rep2(j, 1, MX) usd[i][j] = usd[i][j] + usd[i][j-1];
	}
	
	int ans = 0;
	rep(i, MX){
		int sm =0;
		rep(j, ch) if(usd[j][i] >0) sm++;
		ans = max(ans, sm);
	}
	
	cout << ans <<"\n";

	return 0;
}

Measured memory_bytes: 8508
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

int v[200010],aib[200010],n;
long long sum[200010];
vector<long long> norm;

int poz_norm(long long x)
{
    return lower_bound(norm.begin(),norm.end(),x)-norm.begin()+1;
}

void aib_update(int i,int s)
{
    for(;i<=n+1;i+=i&(-i)) aib[i]+=s;
}

int aib_query(int i)
{
    int s=0;
    for(;i>=1;i-=i&(-i)) s+=aib[i];
    return s;
}

int main()
{
    //freopen("file.in", "r" ,stdin);
    //freopen("file.out", "w", stdout);
    int k;
    long long sol=0;
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++) scanf("%d",&v[i]);
    for(int i=1;i<=n;i++) sum[i]=sum[i-1]+v[i]-k;
    norm.push_back(0);
    for(int i=1;i<=n;i++) norm.push_back(sum[i]);
    sort(norm.begin(),norm.end());
    aib_update(poz_norm(0),1);
    for(int i=1;i<=n;i++)
    {
        int poz=poz_norm(sum[i]);
        sol+=aib_query(poz);
        aib_update(poz,1);
    }
    printf("%lld",sol);
    return 0;
}


Measured memory_bytes: 5104
#include<iostream>
#include<algorithm>
#include<string>
#include<iomanip>
#include<vector>
#include<cstring>
#include<stack>
#include<cstdlib>
#include<cmath>

using namespace std;

int h[100000 + 1], v[100000 + 1];

int main()
{
	int n, m, t;

	cin >> n >> m;

	for (int i = 1; i <= n; i++) {
		cin >> h[i];
		v[i] = 0;
	}

	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		v[a] = max(v[a], h[b]);
		v[b] = max(v[b], h[a]);
	}
	int cnt = 0;
	for (int i = 1; i <= n; i++) {
		if (h[i] > v[i])
			cnt++;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 4412
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)

ll gcd(ll a, ll b) {
	if (a == 0 || b == 0)return 0;
	if (a%b == 0)return b;
	return gcd(b, a%b);
}

int check(ll A, ll B, ll C, ll D) {
	if (B > D)return 0;
	if (B > A)return 0;
	if (C + 1 - B >= 0)return 1;
	ll g = gcd(B, D);
	if (B - g + (A%g) <= C)return 1;
	else return 0;
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	int T;
	cin >> T;
	for (int i = 0; i < T; i++) {
		ll A, B, C, D;
		cin >> A >> B >> C >> D;
		cout << ((check(A,B,C,D)) ? "Yes" : "No") << endl;
	}
	
	return 0;
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace _558_Common_Divisors
{
	class Program
	{
		static void Main ( string[] args )
		{
			//input
			int inputCount = int.Parse (Console.ReadLine ());
			int[] inputNum = Array.ConvertAll (Console.ReadLine ().Split (' '), int.Parse);

			List<double>[] divisors = new List<double>[inputCount];

			for (int lp = 0; lp < inputCount; lp++)
			{
				divisors[lp] = new List<double> (20);

				double quotient = inputNum[lp];

				//商が割った数を超えるまで
				for (double divisor = 1; divisor <= quotient; divisor++)
				{
					quotient = inputNum[lp] / divisor;

					if (quotient % 1 == 0)
					{
						//割る数と商をそれぞれ約数としてカウントする
						divisors[lp].Add (divisor);
						divisors[lp].Add (quotient);
					}
				}
			}

			//output
			IEnumerable<double> result = divisors[0];

			for (int lp = 1; lp < inputCount; lp++)
			{
				result = result.Intersect (divisors[lp]);
			}

			result = result.OrderBy (item => item);

			foreach (var item in result)
			{
				Console.WriteLine (item);
			}

		}
	}
}



Measured memory_bytes: 8212
#include<iostream>
#include<algorithm>
#include<vector>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
#define pb push_back
#define all(c) c.begin(),c.end()
using namespace std;
typedef pair<int,int> P;
typedef pair<P,int> Pi;

bool comp(const Pi &a,const Pi &b){
  if(a.F.F < b.F.F)return true;
  else if(a.F.F == b.F.F && a.F.S <= b.F.S)return true;
  return false;
}

int main(){
  int n;
  while(true){
    cin >> n;
    if(n==541-4-42-231-12-78-9-26-88-51)break;
    vector<Pi> vec;
    bool used[n]; 
    rep(i,n)used[i] = false;

    rep(i,n){
      Pi p;
      cin >> p.S >> p.F.F >> p.F.S;
      vec.pb(p);
    }
    sort(all(vec),comp);
    int cost = 0;
    bool ok = true;
    rep(i,n){
      cost += vec[i].S;
      for(int j=i-1;j>=0;j--){
	if(vec[j].F.S <= vec[i].F.F && !used[j]){
	  used[j] = true;
	  cost -= vec[j].S;
	}
      }
      //cout << i << "-th : cost = " << cost << endl;
      if(cost > 150){
	cout << "NG" << endl;
	ok = false;
	break;
      }
    }
    if(ok)cout << "OK" << endl;
  }
return 0;
}

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

using namespace std;

int main(){
  double a,b,t; cin >> a >> b >> t;
  double time=0;
  double number=0;
  double i=1;
  while(time+a<=t+0.5){
    time +=a;
    number+=b;
    i++;
  }
  cout << number << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define ll long long
//#define cccgift
//#define getchar()(p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
//char buf[1<<21],*p1=buf,*p2=buf;
template<typename T>
inline void read(T &x)
{
    static char ch;bool f=1;
    for(x=0,ch=getchar();!isdigit(ch);ch=getchar()) if(ch=='-') f=0;
    for(;isdigit(ch);x=(x<<1)+(x<<3)+(ch^48),ch=getchar());x=f?x:-x;
}
template<typename T>
void print(T x)
{
    if (x<0) x=-x,putchar('-');
    if (x>9) print(x/10);
    putchar(x%10+48);
}
template<typename T>
inline void print(T x,char ap) {print(x);if (ap) putchar(ap);}
template<typename T>
inline void chkmax(T &x,const T &y) {x=x<y?y:x;}
template<typename T>
inline void chkmin(T &x,const T &y) {x=x<y?x:y;}
int n;
inline bool check(int x) {
	for(res i=2;i<=sqrt(x);++i) if(!(x%i)) return false;
	return true;
}
int main()
{
	ios::sync_with_stdio(false);
	cin>>n;
	while(1) {
		if(check(n)) return cout<<n<<'\n',0;
		++n;
	}
	cout<<flush;	
	return 0;
}
/* stuff you should look for
    * int overflow, array bounds
    * special cases (n=1?), set tle
    * do something instead of nothing and stay organized
*/ 

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double PI = 3.14159265358979;
const double E = 2.718281828459045;
const double root2 = sqrt(2);
typedef pair<int, int> P;
typedef unsigned int ui;
const ll key = 998244353;
int main() {
	int a[300000] = {}; vector<int> v;
	for (int i = 6; i < 300000; i++) {
		if (i % 7 == 1 || i % 7 == 6) {
			if (a[i] == 0) {
				v.push_back(i);
				for (int j = 2*i; j < 300000; j+=i) {
					a[j] = 1;
				}
			}
		}
	}
	int n; int len = v.size();
	while (cin >> n) {
		if (n == 1)break;
		cout << n << ":";
		for (int i = 0; i < len; i++) {
			if (n%v[i] == 0) {
				cout << " "<<v[i];
			}
		}
		cout << endl;
	}
	return 0;
}



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

#define all(x) (x).begin(),(x).end()
#define init() \
  ios::sync_with_stdio(false); \
  cin.tie(0)

using namespace std;

using ll = long long;
using ull = unsigned long long;

template<typename M, typename N>
constexpr common_type_t<M, N> gcd(M a, N b) {
  return a == 0 ? b
    : b == 0 ? a
    : gcd(b, a % b);
}

template <typename M, typename N>
constexpr common_type_t<M, N> lcm(M a, N b) {
  return a * b / gcd(a, b);
}

int main() {
  init();

  int n;
  cin >> n;
  unordered_set<int> a;
  for(int i =0; i<n; i++){
    int k;
    cin >> k;
    a.emplace(k);
  }
  cout << a.size() << '\n';

  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
using namespace std;
vector<int> b;
int a[110];
int main(){
	int i,j,n;
	cin >> n;
	for(i=0;i<n;i++){
		int x; cin >> x;
		b.push_back(x);
	}
	int k = n - 1;
	while(k>=0){
		for(i=b.size()-1;i>=0;i--){
			if(b[i]==i+1){
				a[k] = i+1; k--;
				vector<int> c;
				for(j=0;j<b.size();j++){
					if(j!=i){
						c.push_back(b[j]);
					}
				}
				b.clear();
				for(j=0;j<c.size();j++){
					b.push_back(c[j]);
				}
				break;
			}
			if(i==0){
				cout << -1 << endl;
				return 0;
			}
		}
	}
	for(i=0;i<n;i++){
		cout << a[i] << endl;
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<climits>
#include<cmath>
#include<math.h>
#include<string>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<queue>
#define rep(i,n) for (int i = 0; i < (n); ++i)
typedef long long ll;
using namespace std;

int main(){
    int N,K;
    cin >> N >> K;
    int p[N];
    int ans = 0;
    rep(i,N) cin >> p[i];
    sort(p,p+N);
    for(int i=0;i<K;i++){
        ans += p[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3184
import sys
sys.setrecursionlimit(300000)

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI0(): return map(lambda s: int(s) - 1, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
def LMI0(): return list(map(lambda s: int(s) - 1, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7
INF = float('inf')


a = I()
print(a + a ** 2 + a ** 3)

Measured memory_bytes: 62016
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int main(){
	char s[10];
	scanf("%s",s);
	if(s[2]==s[3]&&s[4]==s[5]){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 888
#include<iostream>
#include<algorithm> 
using namespace std;
string s;
int n,b[1010];
double a[1010],ans;
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];
	sort(a,a+n);
	double k=a[0];
	for(int i=1;i<n;i++)	
		k=(k+a[i])/2;	
	cout<<k<<endl;
} 

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

typedef long long ll ;
using namespace std;

#define M_PI        3.14159265358979323846

void solve(){
    double a, b, h, m;
    cin >> a >> b >> h >> m;

    double theta = 2.0 * M_PI * (h / 12.0 +  (m / 60.0) / 12.0 - m/60.0);
    double ans = a * a + b * b - 2.0 * a * b * cos(theta);
    printf("%.9f\n", sqrt(ans));
}

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

    solve();

    return 0;
}


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

template<typename ...> static inline int gc(void) { return getchar(); }
static inline void read(long long int &x){
    int k=gc();x=0;
    for(;k<48||k>57;k=gc());
    for(;k>47&&k<58;k=gc())x=x*10+k-48;
}

typedef priority_queue<long long> P;
long long d[100000], m, i, M, N, O, a[300000];
P q, l;

int main(){
    read(N);
    M = N << 1;
    O = N * 3;
    for(; i < O; ++i){
        read(a[i]);
    }
    for(i = 0; i < M; ++i){
        q.push(-a[i]);
        m += a[i];
        if(!(i ^ N - 1)){
            *d = m;
        }
        if(N <= i){
            m += q.top();
            q.pop();
            d[i - N + 1] = m;
        }
    }
    m = 0;
    for(i = N * 3; --i >= N;){
        l.push(a[i]);
        m += a[i];
        if(!(i ^ M)){
            d[i - N] -= m;
        }
        if(i < M){
            m -= l.top();
            l.pop();
            d[i - N] -= m;
        }
    }
    cout << *max_element(d, d + N + 1) << endl;
}


Measured memory_bytes: 5748
#include <stdio.h>

int main() {

  int n,c;
  int a[101] = {0};
  int d,i,j;
  int flag;


  scanf("%d",&n);

  c = 0;

  for(i = 0;i<n;i++) {

    scanf("%d" ,&a[i]);

  }

  flag = 1;

  while(flag) { 
    flag = 0;

    for(j=n-1;j>=1;j--) {
      
      if(a[j] < a[j-1]) {
	d = a[j];
	a[j] = a[j-1];
	a[j-1] = d;
	c++;
	flag = 1;
      } 
    }
    
  }

  for(i=0;i<n;i++) {
    printf("%d",a[i]);
    if(i != n-1) printf(" ");

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

  return 0;

}

Measured memory_bytes: 604
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#solve
def solve():
    l = II()
    print((l / 3) ** 3)
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 39152
#include <bits/stdc++.h>
using namespace std;
struct iofix
{
   ios_base::Init i;
   iofix() {
      cin.sync_with_stdio(0);
      cin.tie(0);
      cout.sync_with_stdio(0);
      cout.tie(0);
      cout.precision(10);
      cout << fixed;
   }
} iofix;

void solve(){
    int c; cin >> c;
    map<string,int>mp;
    while(c--){
      string s; cin >> s;
      mp[s]++;
    }
    cout <<"AC x " <<  mp["AC"] << "\n"; 
    cout <<"WA x " <<  mp["WA"] << "\n"; 
    cout <<"TLE x " <<  mp["TLE"] << "\n"; 
    cout <<"RE x " <<  mp["RE"] ;   
}

int main(){
// #ifndef Judge
//     freopen("in.txt","r",stdin);
//     freopen("out.txt","w",stdout);
// #endif

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);  
    cout.precision(10);
    cout << fixed; 

   	solve();

// #ifndef Time
//     cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
// #endif
   return 0;
}

Measured memory_bytes: 3648
package main

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

//Util
func nextStr() string {
	sc.Scan()
	return sc.Text()
}

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

func maxInt(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func minInt(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

func absInt(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func absFloat64(a float64) float64 {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func maxFloat64(a, b float64) float64 {
	if a > b {
		return a
	} else {
		return b
	}
}

func minFloat64(a, b float64) float64 {
	if a > b {
		return b
	} else {
		return a
	}
}

func str2Int(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func isPrime(x int) bool {
	if x == 1 {
		return false
	}
	if x == 2 {
		return true
	}
	if x%2 == 0 {
		return false
	}

	b := true
	rootx := int(math.Sqrt(float64(x)))
	i := 3
	for i <= rootx {
		if x%i == 0 {
			b = false
			break
		}
		i += 2
	}
	return b
}

//Main
const (
	initialBufSize = 10000
	maxBufSize     = 1000000
	mod            = 1e9 + 7
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		return sc
	}()
)

var A, B int

func main() {
	sc.Split(bufio.ScanWords)
	A, B = nextInt(), nextInt()

	A--
	sock := 1
	ans := 0
	for sock < B {
		sock += A
		ans++
	}

	fmt.Println(ans)
}


Measured memory_bytes: 640
/*input
314159265358979323 846264338327950288 419716939 937510582
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}

//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}

int main(){
	IOS;
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	ll sum1=b/c-(a-1)/c;
	ll sum2=b/d-(a-1)/d;
	ll lcm=c*d/__gcd(c,d);
	ll sum3=b/lcm-(a-1)/lcm;
	// cout<<sum1<<' '<<sum2<<' '<<sum3<<'\n';
	cout<<(b-a+1)-(sum1+sum2-sum3)<<'\n';
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <stack>
#include <climits>
#include <map>
#include <set>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

const ll mod = 1000000007;
const int inf = 1e9;
const long long INF = 1LL << 60;



int main()
{
    int n;cin >> n;
    int a[n];
    for(int i = 0; i < n; i++) cin >> a[i];
    int m; cin >> m;
    int ans = 0;
    for(int i = 0; i < m; i++){
        int key; cin >> key;
        if(binary_search(a,a+n,key)){
            ans++;
        }
    }
    cout << ans << endl;
} 


Measured memory_bytes: 3476
let first = readLine()!.split(separator: " ")
let N = Int(first[0])!
var K = Int(first[1])!
let steps = readLine()!.split(separator: " ").map { Int($0)! }

var chain: [Int] = []
var loopbackIndex = -1
var table: [Int: Int] = [0: 0]
var start = 0
while true {
  chain.append(start)
  let next = steps[start] - 1
  if table[next] != nil {
    loopbackIndex = table[next]!
    break
  }
  table[next] = chain.count
  start = next
}
if K < chain.count {
  print(chain[K] + 1)
} else {
  K -= chain.count
  let index = K % (chain.count - loopbackIndex)
  print(chain[loopbackIndex + index] + 1)
}
  

Measured memory_bytes: 26252
#include <iostream>

using namespace std;

int main() {
    int h, w, n;

    int table[100][100];
    int x = 0, y = 0;

    cin >> h >> w;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        for (int j = 0; j < a; j++) {
            table[y][x] = i+1;

            if (y % 2 == 0)
                x++;
            else
                x--;

            if (x == w) {
                y++;
                x = w - 1;
            }
            if (x == -1) {
                y++;
                x = 0;
            }
        }
    }
    
    for (int j = 0; j < h; j++) {
        for (int i = 0; i < w; i++) {
            cout << table[j][i];
            if (i != w-1)
                cout << ' ';
        }
        cout << endl;
    }
    
    return 0;
}


Measured memory_bytes: 384