akhauriyash/Code-Regression huggingface dataset:
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<stdlib.h>
#include<queue>
#include<map>
#include<vector>
#include<cmath>
#include<fstream>
#include <set>
//freopen(".in","r",stdin);
//freopen(".out","w",stdout);
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
const int  MAXN =5e5+10;
const int mod = 1e9 + 7;
const long long INF = 0x7f7f7f7f7f7f7f7f;
const int inf= 0x3f3f3f3f;
#define eps 1e-8
#define PI 3.1415926535898
#define lowbit(x) (x&(-x))
using namespace std ;
//getline(cin,s);
//set<ll>::iterator it;
//map<int,int>::iterator it;
typedef long long ll;
int n,q;
int c[MAXN],ans[MAXN],rt,pos[MAXN],sum,a[MAXN];
struct node{
	int l,r,index;
	/*bool operator <(const node& o)const
    {
        if(pos[l]==pos[o.l]) return r<o.r;
        return pos[l]<pos[o.l];
    }*/
}need[MAXN];
int cmp(node f,node s)
{
	if(pos[f.l]==pos[s.l])
	   return f.r<s.r;
	else return f.l<s.l;
}
void add(int x)
{
	a[c[x]]++;
	if(a[c[x]]==1) sum++;
}
void del(int x)
{
	a[c[x]]--;
	if(a[c[x]]==0) sum--;
}
int main()
{
	scanf("%d %d",&n,&q);
	rt=sqrt(1.0*n);
	for(int i=1;i<=n;i++)
	{
	    scanf("%d",&c[i]);
	    pos[i]=i/rt; 
	} 
	for(int i=1;i<=q;i++)
	{
		scanf("%d %d",&need[i].l,&need[i].r);
		need[i].index=i;
	}
	sort(need+1,need+1+q,cmp);
	int l=1,r=0;
	for(int i=1;i<=q;i++)
	{
		while(l<need[i].l)
		{
			del(l);
			l++;
		}
		while(l>need[i].l)
		{
			l--;
			add(l);
		}
		while(r<need[i].r)
		{
			r++;
			add(r);
		}
		while(r>need[i].r)
		{
			del(r);
			r--;
		}
		ans[need[i].index]=sum;
	}
	for(int i=1;i<=q;i++) printf("%d\n",ans[i]);
	return 0;
}


Measured memory_bytes: 17436
#include<stdio.h>
#include<iostream>
#include<string>
#include<algorithm>
#include <vector>
#include<math.h>
#include<iomanip>


using namespace std;

int main(){
	int X[312]={};
	for(int i=0;i<=300;i++)
		X[i]=1;
	/*
	for(int i=0;i<301;i++){
		X[i+4]+=X[i];if(i>=8)X[i+4]--;
		X[i+9]+=X[i];if(i>=18)X[i+9]--;

	}
	*/
	for(int i=2;i<=17;i++)
	{
		int p=i*i;X[p]++;
		for(int j=1;j+p<301;j++)
		{
			X[j+p]+=X[j];//if(j>=2*p)X[j+p]--;
		}
	}
	/*
	X[0]=1;
	for(int i=1;i<301;i++)
		X[i]+=X[i-1];

		*/

	int d;
	while(1){
		cin>>d;
		if(d==0)break;
		cout<<X[d]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
s=input()
n=len(s)
a=int(n/2)
s1a=s[0:a]
s2a=s[n-a:n]
s2=s[::-1]
s1b=s1a[::-1]
s2b=s2a[::-1]
if s==s2 and s1a==s1b and s2a==s2b:
	print("Yes")
else:
	print("No")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=200010;
const ll mod=1e9+7;

int main(){
  int k,x;
  cin >> k >> x;
  if(k*500>=x){ cout << "Yes" << endl; return 0;}

  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		Scanner s = new Scanner(System.in);
		
		String ss = s.nextLine();
		String t = s.nextLine();
		
		int minS = Integer.MAX_VALUE;
		int tmpS = 0;
		
		for(int i = 0; i + t.length() <= ss.length(); i++) {
			
			String tmp = ss.substring(i, i + t.length());
			tmpS = 0;
			
			for(int j = 0; j < tmp.length(); j++) {
				
				if(tmp.charAt(j) != t.charAt(j))
					tmpS++;
				
			}
			
			if(tmpS < minS)
				minS = tmpS;
			
		}
		
		System.out.println(minS);
		

	}

}


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

int main(){
    int N;cin>>N;
    double ans = 0;
    const int btc = 380000;
    for(int i = 0; i < N; i++)
    {
        double money;
        string type;
        cin>>money>>type;
        if(type=="JPY"){
            ans += money;
        }else{
            ans += money * btc;
        }
    }
    cout<<ans<<endl;
}

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

int main() {
 int a,b,c,d,e,k;
 cin >> a >> b >> c >> d >> e >> k ;
  if(e-a <= k){
  cout << "Yay!" << endl;
  }
  else{
  cout << ":(" << endl;
  }

}


Measured memory_bytes: 256
N, K  = gets.split.map(&:to_i)
as = gets.split.map(&:to_i)
index = as.index(1)
diff_0 = index
diff_1 = N-1 - index
mod_right = diff_0 % (K-1)
mod_left = diff_1 % (K-1)
sum =  (diff_0/(K-1).to_f).ceil + (diff_1/(K-1).to_f).ceil
if mod_left+mod_right <= K-1 && mod_right >= 1 && mod_left >= 1
  sum -= 1
end
puts sum

Measured memory_bytes: 8076
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int) n; i++)
using ll = long long;
using vi = vector<int>;
const int MOD = 1e9+7;

int main(){
  int n,m,ac=0,wa=0;
  cin >> n >> m;
  vector<bool> ps(n+1,false);
  vector<int>w(n+1);
  rep(i,m){
    int num;
    string s;
    cin >> num >> s;
    if(s=="AC"&&ps[num]==false){        
        ac++;
        wa += w[num];
        ps[num]=true;
    }
    else if(ps[num]==false)
      w[num]++;
  }


  cout << ac << " " << wa << endl;
  return 0;
}


Measured memory_bytes: 640
n = int(input())
h = [int(i) for i in input().split()]

dp = [0 for _ in range(n + 1)]

dp[0] = 0
dp[1] = abs(h[1] - h[0])

for i in range(2, n):
    dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]))

print(dp[n - 1])

Measured memory_bytes: 13928
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
using namespace std;
const double PI = acos(-1.0);
const string alp = "abcdefghijklmnopqrstuvwxyz";
const string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const string HEX = "0123456789ABCDEF";
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define SUM(c) accumulate((c).begin(),(c).end(),0)
#define Yn(b) puts(b?"Yes":"No")
#define YN(b) puts(b?"YES":"NO")

int main(void) {
    int n;
    cin >> n;
    int t;
    t = (n/1)%10+(n/10)%10+(n/100)%10+(n/1000)%10+(n/10000)%10+(n/100000)%10+(n/1000000)%10+(n/10000000)%10+(n/100000000)%10;
    Yn(n%t==0);
    return 0;
}


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

int main() {
  string S;
  cin >> S;
  
  int i = S.size() - 1;
  do {
    string five = S.substr(i - 4, 5);
    string six = S.substr(i - 5, 6);
    string seven = S.substr(i - 6, 7);
    if (five == "dream") {
      i -= 5;
    } else if (seven == "dreamer") {
      i -= 7;
    } else if (five == "erase") {
      i -= 5;
    } else if (six == "eraser") {
      i -= 6;
    } else {
      break;
    }
  } while (6 < i);
  
  if (0 < i) {
    string five = S.substr(0, i + 1);
    if (five == "dream") {
      i -= 5;
    } else if (five == "dreamer") {
      i -= 7;
    } else if (five == "erase") {
      i -= 5;
    } else if (five == "eraser") {
      i -= 6;
    } else {
      i = 0;
    }
  }
  
  if (i == -1) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int X,a,b,c,d,e;
  cin >>X;
  
  a = X / 500;
  b = X % 500;
  c = b / 5;
  d = a * 1000;
  e = c * 5;
 
  cout << d + e << endl;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
food=[] #appendのために宣言が必要
for i in range(n):
    food.append(list(map(int,input().split())))

tmp = set(food[0][1:])
for i in range(1, n):
    tmp = tmp & set(food[i][1:])
print(len(tmp))

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

#define rep(i,l,n) for (i = (l); i < (n); i++)
#define MAX_N 200000 // 2*(10^5)
#define MAX_Si 11 // 1 <= i <= 10

int comp_char(const void *a, const void *b) {
  return (strcmp((const char *)a, (const char *)b));
}

int main(void) {
  int N;
  char S[MAX_N][MAX_Si]; // S[i] (1 <= i <= N)

  int votes[MAX_N];
  int most_votes = 1;
  int i;

  scanf("%d", &N);
  rep(i,0,N) {
    scanf("%s", S[i]);
    votes[i] = 1;
  }

  qsort(S, N, sizeof(S[0]), comp_char);

  rep(i,1,N) {
    if (strcmp(S[i], S[i-1]) != 0) continue;
    votes[i] += votes[i-1];
    if (most_votes >= votes[i]) continue;
    most_votes = votes[i];
  }

  // printf("most votes: %d\n", most_votes);
  rep(i,0,N) {
    if (votes[i] != most_votes) continue;
    // printf("%s %d\n", S[i], votes[i]);
    printf("%s\n", S[i]);
  }

  return (0);
}

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

const int N = 100010;
const int moder = 1e9 + 7;

int fac[N];

int main(){
	fac[0] = 1;
	for (int i = 1; i < N; ++ i){
		fac[i] = 1ll * i * fac[i - 1] % moder;
	}
	int n, m;
	scanf("%d%d", &n, &m);
	if (n < m){
		std::swap(n, m);
	}
	if (n == m){
		return printf("%lld\n", 2ll * fac[n] * fac[m] % moder), 0;
	}
	if (n == m + 1){
		return printf("%lld\n", 1ll * fac[n] * fac[m] % moder), 0;
	}
	return printf("0\n"), 0;
}

Measured memory_bytes: 640
import sys
stdin = sys.stdin
read_int = lambda : list(map(int,stdin.readline().split()))

N,M = read_int()

A = read_int()
# for index arrangement
A.sort(reverse=True)
A.insert(0,-1)

W = [0,2,5,5,4,5,6,3,7,6]

dp = [-1 for j in range(N+1)]
def solve():
    dp[0] = 0
    for i in range(M):
        for j in range(N+1):
            if j - W[A[i + 1]] >= 0 and dp[j - W[A[i + 1]]] >= 0:
                dp[j] = max(dp[j], dp[j - W[A[i + 1]]]*10 + A[i + 1])
                
if __name__ == "__main__":
    solve()
    print(dp[N])


Measured memory_bytes: 16496
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using PL = pair<ll,ll>;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define IFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define RPT(i,a,b) for(int i=(a);i<((a)+(b));++i)
#define IRPT(i,a,b) for(int i=((a)+(b)-1);i>=(a);--i)
constexpr int INF = (1 << 29);
constexpr ll INF_ = (1LL << 58);
constexpr ld EPS = (1e-10);
constexpr ld PI_ = 3.141592653589793238;//46264338327950288
constexpr ld E_ = 2.71828182845904523;//5360287471352
constexpr ll MOD = 1000000007;
//// functions (integer)_________________________________
ll modpow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a % m;
		a = a * a%m; n >>= 1;
	}
	return res;
}
long long modinv(long long a, long long p, long long mod){
  return modpow(a,p-2,mod);
}
////-----------------------------------------------------



int main(){
  int N;vector<ll> A; set<ll>P; map<ll,ll> B;
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N;
  RPT(i,0,N){
    ll a; cin >> a;
    A.push_back(a);
  }
  sort(A.begin(),A.end());

  FOR(i,2,1000003){
    bool ynprime = true;
    for(auto &xx : P){
      ll x = xx;
      if(i % x == 0){ ynprime = false; break; }
      if( x*x > i ) break;
    }
    if(ynprime) P.insert(i);
  }

  RPT(i,0,N){
    ll ttl = A[i];
    set<ll>::iterator it = P.find(A[i]);
    if(it!=P.end()){
      ttl = 1;
      if(B[A[i]]<1) B[A[i]] = 1;
    }
    for(auto &xx : P){
      auto x = xx;
      ll cnt = 0;
      if(x > A[i] || ttl == 1) break;
      while(ttl % x == 0){
        ttl /= x;
        cnt++;
      }
      if(cnt){
        if(B[x]<cnt) B[x] = cnt;
      }
    }
    if(ttl != 1) {
      P.insert(A[i]);
      B[A[i]] = 1;
    }
  }

  ll L=1, Ainv = 0;
  for(auto x : P){
    if(B[x] != 0)L = ((L * (modpow(x,B[x],MOD))%MOD)) % MOD;
  }
  RPT(i,0,N){
    Ainv = (Ainv + ((modpow(A[i],MOD-2,MOD)%MOD)%MOD) ) % MOD;
  }
  ll ans = (Ainv * L) % MOD;
  //ll ans = (Ainv % MOD);
  cout << ans << endl; 
  //cout << L << endl << Ainv << endl;for(auto x: P) if(B[x]) cout << x << "^" << B[x] << " ";
  return 0;
}

Measured memory_bytes: 8960
n,m=map(int,input().split())
par=[-1]*n

# this par & rank are initialized lists
def find(x):
    global par
    if par[x]<0:
        return x
    else:
        par[x]=find(par[x])
        return par[x]
        
def unite(x,y):
    x,y=find(x),find(y)
    global par
    if x==y:return False
    else:
        if par[x]>par[y]:x,y=y,x
        par[x]+=par[y]
        par[y]=x
        return True

def size(x):
    return -par[find(x)]
def same(x,y):
    return find(x)==find(y)

for i in range(m):
  a,b=map(int,input().split())
  a-=1
  b-=1
  unite(a,b)

cnt=0
for i in par:
  if i<0:
    cnt+=1
print(cnt-1)

Measured memory_bytes: 10680
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<iostream>
#include<cstring>
#include<vector>
#include<string> 
#include<queue>
#include<set>
#include<algorithm>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
		int ans;
		if(b>=a)ans=a;
		else ans=a-1;
		printf("%d\n",ans);
	return 0;
 } 

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

int main() {
	int N;
	cin >> N;
	string S;
	cin >> S;
	int a=0, b=N-1, c=0, x, y, z;
	bool f = true;
	rep(i, N) {
		if (f) {
			if (S.at(a) == 'W') {
				f = !f;
			}
			a++;
		} else {
			if (S.at(b) == 'R') {
				f = !f;
				c++;
			}
			b--;
		}
	}
	std::cout << c << '\n';
}

Measured memory_bytes: 3748
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int[] dp=new int[n+1];
    int[] a={6,9,36,81,216,729,1296,6561,7776,46656,59049};
    Arrays.fill(dp,Integer.MAX_VALUE-7);
    dp[n]=0;
    for(int i=n;i>=0;i--){
      if(dp[i]!=Integer.MAX_VALUE-7){
        for(int j=0;j<11;j++){
          if(i>=a[j]){
            dp[i-a[j]]=Math.min(dp[i]+1,dp[i-a[j]]);
          }
        }
      }
    }
    int min=Integer.MAX_VALUE;
    for(int i=0;i<6&&i<dp.length;i++){
      min=Math.min(dp[i]+i,min);
    }
    System.out.println(min);
  }
}


Measured memory_bytes: 21844
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.Comparator;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author silviase
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BATCoder solver = new BATCoder();
        solver.solve(1, in, out);
        out.close();
    }

    static class BATCoder {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String s = in.next();
            PriorityQueue<Integer> pq = new PriorityQueue<>(Comparator.reverseOrder());
            int cnt = 0;
            for (int i = 0; i < s.length(); i++) {
                if (s.charAt(i) == 'A' || s.charAt(i) == 'C' || s.charAt(i) == 'G' || s.charAt(i) == 'T') {
                    cnt++;
                } else {
                    pq.add(cnt);
                    cnt = 0;
                }
            }
            pq.add(cnt);
            out.println(pq.poll());
        }

    }
}



Measured memory_bytes: 23124
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            SolveA();
            //SolveB();
            //SolveC();
            //SolveD();
        }
        private const long MOD = 1000000007;

        static void SolveA()
        {
            string s = Console.ReadLine();
            bool[] table = new bool[26];
            for(int i=0;i<s.Length;++i)
            {
                int idx = s[i] - 'a';
                table[idx] = true;
            }
            for(int i=0;i<table.Length;++i)
            {
                if( !table[i])
                {
                    Console.WriteLine((char)(i + 'a'));
                    return;
                }
            }
            Console.WriteLine("None");
        }

        #region よく使う便利関数
        private static bool isPrime(long x)
        {
            if (x == 2) { return true; }
            if (x < 2 || x % 2 == 0) { return false; }
            long i = 3;
            while (i * i <= x)
            {
                if (x % i == 0) { return false; }
                i = i + 2;
            }
            return true;
        }
        private static long lcm(long x, long y)
        {
            return x / gcd(x, y) * y;
        }
        private static long gcd(long x, long y)
        {
            return y > 0 ? gcd(y, x % y) : x;
        }
        private static long pow(long x, long n)
        {
            if (n == 0) { return 1; }
            long res = pow(x * x % MOD, n / 2);
            if (n % 2 == 1)
            {
                res = res * x % MOD;
            }
            return res;
        }
        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        #endregion
    }
}

Measured memory_bytes: 11092
while True:
    h, w = map(int,input().split())

    if h == 0 and w == 0:
        break

    for i in range(h):
        if i == 0 or i == h-1:
            print("#"*w)
        else:
            for j in range(w):
                if j == 0 or j == w-1:
                    print("#",end="")
                else:
                    print(".",end="")
            print()

    print()


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

int main() {
    int n, num = 0, ans;
    string s;
    cin >> n >> s;
    int siro[n+1], kuro[n+1];
    siro[0] = 0; kuro[n] = 0;
    ans = n;
    for(int i = 1; i <= n; ++i) {
        if(s[i-1] == '#') num++;
        siro[i] = num;
    }
    num = 0;
    for(int i = n - 1; i >= 0; --i) {
        if(s[i] == '.') num++;
        kuro[i] = num;
    }
    for(int i = 0; i <= n; ++i) {
        if(siro[i] + kuro[i] < ans) ans = siro[i] + kuro[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 2180
#include <bits/stdc++.h>
#include <numeric>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep1(i,n) for (int i = 1; i <= n; ++i)
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
const long long MOD = 1e9+7;
#define precout(val) cout << std::fixed << std::setprecision(20) << val;
const string alphabet = "abcdefghijklmnopqrstuvwxyz";
const int dy[4] = { 0, 1, 0, -1 };
const int dx[4] = { 1, 0, -1, 0 };

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

  int n; cin >> n;
  int first; cin >> first;
  if(first != 0) {
    cout << 0 << endl;
    return 0;
  }

  int maxd = -1;
  vector<int> cnt(100005, 0);
  cnt[0] = 1;
  rep(i, n-1) {
    int d; cin >> d;
    ++cnt[d];
    chmax(maxd, d);
  }

  if(cnt[0] != 1) {
    cout << 0 << endl;
    return 0;
  }

  ll mod = 998244353;
  ll ans = 1;
  rep1(i, maxd) {
    if(cnt[i] == 0) {
      cout << 0 << endl;
      return 0;
    }

    rep(j, cnt[i]) {
      ans = ans * cnt[i-1] % mod;
    }
  }

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


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
 
int main()
{
    int n,m;
   cin>>n>>m;
char arr[n][n];
char arr1[m][m];
    for(int i=0; i<n; i++)
 cin>>arr[i];
    for(int i=0; i<m; i++)
 cin>>arr1[i];
 
    for(int i=0; i<n; i++)
    {
        for(int j=0; j<n; j++)
        {
            int cnt=0;
            for(int a=0; a<m; a++)
            {
                for(int b=0; b<m; b++)
                {
                    if(arr1[a][b]==arr[i+a][j+b])
                        cnt++;
                }
 
            }
            if(cnt==(m*m))
            {
				cout<<"Yes";
                return 0;
            }
 
        }
    }
    cout<<"No";
 
}

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

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

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

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

using namespace std;

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

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

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

// Problem Specific Parameter:

int main() {
  int N, M; cin >> N >> M;
  vector<pair<long long, long long>> v;
  for(int i = 0; i < N; ++i) {
    long long a, b;
    cin >> a >> b;
    v.push_back(make_pair(a, b));
  }
  sort(v.begin(), v.end());
  long long n=0;
  long long ans=0;
  for(int i = 0; i < N; ++i) {
    if(n+v[i].second <= M) {
      n += v[i].second;
      ans += v[i].first * v[i].second;
    } else {
      ans += v[i].first * (M-n);
      cout << ans << endl;
      return 0;
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
  vector<ll> vec(3);
  for(ll i=0;i<3;i++) {
    cin>>vec[i];
  }
sort(all(vec));
  reverse(all(vec));
  cout<<vec[0]*10+vec[1]+vec[2]<<endl;
}

Measured memory_bytes: 3576
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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

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

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

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

//----------------------------------------------------------------


int main(){
ll a,b;
cin>>a>>b;
if((a+b)%2>0){
    cout<<"IMPOSSIBLE"<<endl;
}else{
    cout<<(a+b)/2<<endl;
}
}









Measured memory_bytes: 256
#include<stdio.h>
#include<limits.h>
#define LEN 100

int Q[LEN];
int G[LEN][LEN];
int head,tail;
int d[LEN];
int n;

void enqueue(int x){
  Q[tail] = x;
  tail = (tail+1) % LEN;
}
int dequeue(){
  int  x = Q[head];
  head = (head+1)%LEN;
  return x;
}

void bfs(int s){
  int i;
  int u,v;
  enqueue(s);

  for(i=0;i<n;i++){
    d[i] = INT_MAX;
  }

  d[s] = 0;

  while(head!=tail){
    u = dequeue();
    for(v=0;v<n;v++){
      if(G[u][v] == 0)continue;
      if(d[v] != INT_MAX)continue;
      d[v] = d[u] + 1;
      enqueue(v);
    }
  }

  for(i=0;i<n;i++){
    printf("%d %d\n",i+1,((d[i] == INT_MAX)? -1 : d[i]));
  }
}

int main(){
  int k,u,v,i,j;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      G[i][j] = 0;
    }
  }

  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    u--;
    for(j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      G[u][v] = 1;
    }
  }

  bfs(0);

  return 0;
}



Measured memory_bytes: 2104
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    Map<String, Integer> mm = new HashMap<>();
    for (int i = 0; i < N; i++) {
      char[] a = sc.next().toCharArray();
      Arrays.sort(a);
      String s = Arrays.toString(a);
      mm.put(s, mm.getOrDefault(s, 0) + 1);
    }
    
    long ans = 0;
    for (int v : mm.values()) {
      if (v >= 2) {
        ans += sum(v-1);
      }
    }
    
    System.out.println(ans);
  }
  
  private static long sum(int v) {
    if (v == 1) {
      return 1;
    }
    return v + sum(v-1);
  }
}


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

using namespace std;

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

  int min_x = 0;
  int max_x = W;
  int min_y = 0;
  int max_y = H;
  for (int i = 0; i < N; ++i) {
    int x, y, a;
    cin >> x >> y >> a;
    if (a == 1) {
      min_x = max(min_x, x);
    } else if (a == 2) {
      max_x = min(max_x, x);
    } else if (a == 3) {
      min_y = max(min_y, y);
    } else {
      max_y = min(max_y, y);
    }
  }
  const int ans = (max_x - min_x < 0 || max_y - min_y < 0)
                      ? 0
                      : (max_x - min_x) * (max_y - min_y);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int dp[N],n,m;
bool visit[N];
vector<int>v[N];
int dfs(int now)
{
	if(visit[now])return dp[now];
	else{
		visit[now]=true;
		for(int i=0;i<v[now].size();i++)
		{
			int to=v[now][i];
			dp[now]=max(dfs(to)+1,dp[now]);
		}
		return dp[now];
	}
}
int main()
{
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		int a,b;
		cin>>a>>b;
		a--,b--;
		v[a].push_back(b);
	}
	int ans=0;
	for(int i=0;i<n;i++)ans=max(ans,dfs(i));
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 8192
#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;

int main() {
	int N;
	cin >> N;
	vector <int>a(N),cost(201);
	for (size_t i = 0; i < N; i++)
	{
		cin >> a.at(i);
	}
	for (int i = -100; i <= 100; i++)
	{
		for (size_t j = 0; j < N; j++)
		{
			cost.at(i + 100) += pow((a.at(j) - i), 2);
		}
	}
	sort(cost.begin(), cost.end());
	cout << cost.at(0);
}

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

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin >> n;
	vector<int> a(n-1); int ans=0;
	for(auto &x:a) cin >> x;
	ans += a[0];
	for(int i=1;i<n-1;i++) if(a[i-1] > a[i]) a[i-1] = a[i];
	for(int i=0;i<n-1;i++) ans += a[i];
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int a,b,c,d,e,f,g,h,i,j;
    cin>>a>>b>>c>>d;
    e = a *c;
    f = a * d;
    g  = b * c;
    h = b * d;
    i = max(e, f);
    j = max(g, h);
    if(i > j)
    {
        cout<<i<<endl;
    }
    else
    {
        cout<<j<<endl;
    }
    return 0;
}


Measured memory_bytes: 3620
#include <array>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <tuple>
using namespace std;


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

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}

template <class T>
T clampMax(const T& a, const T& b) { return min(a, b); }

template <class T>
T clampMin(const T& a, const T& b) { return max(a, b); }

template <class T>
bool updateMax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }

template <class T>
bool updateMin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }

#define REP(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define PB push


#define MOD 1000000007LL
#define EPS 1e-10

bool Check(const string& s)
{
    for (char c : s)
    {
        if (c != 'A' && c != 'C' && c != 'G' && c != 'T')
        {
            return false;
        }
    }
    return true;
}

int main()
{
    string S;
    cin >> S;
    int ans = 0;
    REP(i, S.length())
    {
        REP(j, S.length())
        {
            if (i + j <= S.length())
            {
                string T;
                REP(k, S.length())
                {
                    if (k >= i && k < S.length() - j)
                    {
                        T += S[k];
                    }
                }

//                cout << T << endl;

                if (Check(T))
                {
//                    cout << "ok" << endl;
                    ans = max(static_cast<int>(T.length()), ans);
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }


int N;
string S;


long long solve() {
    N = S.size();
    vector<int> whsum(N+1, 0);
    vector<int> blsum(N+1, 0);
    for (int i = 0; i < N; ++i) {
        whsum[i+1] = whsum[i] + (S[i] == '.' ? 1 : 0);
        blsum[i+1] = blsum[i] + (S[i] == '#' ? 1 : 0);
    }
    
    long long res = 1LL<<60;
    for (int left = 0; left <= N; ++left) {
        long long tmp = 0;
        // left を全部白に
        tmp += blsum[left] - blsum[0];
        
        // right を全部黒に
        tmp += whsum[N] - whsum[left];
        
        chmin(res, tmp);
    }
    return res;
}


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    while (cin >> N >> S) {
        cout << solve() << endl;
    }
}














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

int main()
{
  long ans = 0;
  int n, k, r, s, p;
  string t;
  
  cin >> n >> k >> r >> s >> p >> t;
  
  string u(n, 'a');
  
  for(int i = 0; i < n; i++){
    if(i >= k){
      if(t.at(i) != t.at(i - k) || u.at(i - k) == 'a'){
        if(t.at(i) == 'r'){
          u.at(i) = 'p';
        }
        else if(t.at(i) == 's'){
          u.at(i) = 'r';
        }
        else if(t.at(i) == 'p'){
          u.at(i) = 's';
        } 
      }
    }
    else{
      if(t.at(i) == 'r'){
        u.at(i) = 'p';
      }
      else if(t.at(i) == 's'){
        u.at(i) = 'r';
      }
      else if(t.at(i) == 'p'){
        u.at(i) = 's';
      }
    }
  }
  
  
  for(int i = 0; i < n; i++){
    if(u.at(i) == 'r'){
      ans += r;
    }
    else if(u.at(i) == 's'){
      ans += s;
    }
    else if(u.at(i) == 'p'){
      ans += p;
    }
  }
  //cout << u << endl;
  cout << ans << endl;
 
  return 0;
}

Measured memory_bytes: 512
#pragma GCC optimize("Ofast,fast-math,unroll-loops")
 
#include <bits/stdc++.h>
 
#define int ll
//#define double long double
#define endl '\n'
#define all(C) (C).begin(), (C).end()
#define rall(C) (C).rbegin(), (C).rend()
#define mp make_pair 
#define pb emplace_back
#define dbg(x) cerr << #x << " : " << x << endl
//#define PI 3.141592653589
 
using namespace std;
        
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair <int, int>;
using pld = pair <ld, ld>;

/*
const ll MAX_MEM = 4e8;
char MEM[MAX_MEM];
ll MEM_POS = 0;
void* operator new(size_t x)
{
    auto ret = MEM + MEM_POS;
    MEM_POS += x;
    assert(MEM_POS < MAX_MEM);
    return ret;
}
void operator delete(void*)
{}
*/
        
template <class T>
istream& operator>> (istream &in, vector <T> &a)
{
    for (auto &i : a)
        in >> i;
    return in;
}
        
template <class T> 
ostream& operator<< (ostream &out, vector <T> a)
{
    for (auto &i : a)
        out << i << ' ';
    return out;
}
        
template <class T, class U>
istream& operator>> (istream &in, pair <T, U> &p)
{
    in >> p.first >> p.second;
    return in;
}
        
template <class T, class U>
ostream& operator<< (ostream &out, pair <T, U> p)
{
    out << p.first << " " << p.second << " ";
    return out;
}
        
inline void Start()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    //freopen("lol.in", "r", stdin);
    //freopen("lol.out", "w", stdout);
}

signed main()
{
    Start();
    int n;
    cin >> n;
    vector <int> p(n);
    cin >> p;
    vector <int> lft(n), rgt(n);
    vector <pii> st;
    st.pb(0ll, -1ll);
    for (int i = 0; i < n; ++i)
    {
        int kek = upper_bound(all(st), mp(p[i], 0ll)) - st.begin() - 1;
        lft[i] = st[kek].second;
        while (st.back().first > p[i])
            st.pop_back();
        st.pb(p[i], i);
    }
    st = {};
    reverse(all(p));
    st.pb(0ll, -1ll);
    for (int i = 0; i < n; ++i)
    {
        int kek = upper_bound(all(st), mp(p[i], 0ll)) - st.begin() - 1;
        rgt[i] = st[kek].second;
        while (st.back().first > p[i])
            st.pop_back();
        st.pb(p[i], i);
    }
    reverse(all(p));
    reverse(all(rgt));
    for (int i = 0; i < n; ++i)
        rgt[i] = n - rgt[i] - 1;
    int ans = 0;
    for (int i = 0; i < n; ++i)
        ans += p[i] * (i - lft[i]) * (rgt[i] - i);
    cout << ans;
    return 0;
}



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

int main(){
    map<string,int> dic;int n;cin>>n;
    for(int i=0;i<n;i++){
        string a;cin>>a;
        dic[a]++;
    }
    int dic_max=0;
    for(auto i:dic) dic_max=max(dic_max,i.second);
    for(auto i:dic){
        if(i.second==dic_max) cout<<i.first<<endl;
    }
}

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

int main()
{
    vector<vector<int>> a(3,vector<int>(3));
    for (int i=0;i<3;i++){
        for (int j=0;j<3;j++){
            cin>>a.at(i).at(j);
        }
    }
    int n;
    cin>>n;

    vector<int> b(n);
    for (int i=0;i<n;++i){
        cin>>b.at(i);
    }
    for (int i=0;i<3;++i){
        for (int j=0;j<3;++j){
            for (int k=0;k<n;++k){
                if(a.at(i).at(j)==b.at(k)){
                    a.at(i).at(j)=0;
                }
            }
        }
    }
    string ans="No";
    for (int i=0;i<3;i++){
        if(a.at(i).at(0)==0&&a.at(i).at(1)==0&&a.at(i).at(2)==0){
            ans="Yes";
            break;
        }
    }
    for (int i=0;i<3;i++){
        if(a.at(0).at(i)==0&&a.at(1).at(i)==0&&a.at(2).at(i)==0){
            ans="Yes";
            break;
        }
    }
    if(a.at(0).at(0)==0&&a.at(1).at(1)==0&&a.at(2).at(2)==0){
        ans="Yes";
    }
    if(a.at(0).at(2)==0&&a.at(1).at(1)==0&&a.at(2).at(0)==0){
        ans="Yes";
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 3576
n, k = map(int, input().split())
S = set()
D = dict()
for _ in range(n):
    a, b = map(int, input().split())
    if a in S:
        D[a] += b
    else:
        S.add(a)
        D[a] = b
L = sorted(S)
cnt = 0
for l in L:
    cnt += D[l]
    if cnt >= k:
        print(l)
        break

Measured memory_bytes: 17924
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

const int N = 101010;
int dp[N];

int main()
{
    int n,d,x;
    cin >>n >>d >>x;
    vector<vector<int>> p(d,vector<int>(n));
    rep(i,d)rep(j,n) cin >>p[i][j];

    rep(i,d-1)
    {
        memset(dp,0,sizeof(dp));
        rep(j,n)rep(k,x+1)
        {
            if(k+p[i][j]<=x) dp[k+p[i][j]] = max(dp[k+p[i][j]], dp[k]+p[i+1][j]);
        }

        int v = x;
        rep(k,x+1) v = max(v,dp[k]+x-k);
        x = v;
    }

    cout << x << endl;
    return 0;
}

Measured memory_bytes: 3540
#include<stdio.h>
main()
{
	int a, b, c;
	scanf("%d%d%d", &a, &b, &c);
	if (a<=b && b<=c)
	{
		printf("%d %d %d\n", a, b, c);
	}
	else if (a<=c && c<=b)
	{
		printf("%d %d %d\n", a, c, b);
	}
	else if (b<=a && a<=c)
	{
		printf("%d %d %d\n", b, a, c);
	}
	else if (b<=c && c<=a)
	{
		printf("%d %d %d\n", b, c, a);
	}
	else if (c<=a && a<=b)
	{
		printf("%d %d %d\n", c, a, b);
	}
	else if (c<=b && b<=a)
	{
		printf("%d %d %d\n", c, b, a);
	}
}


Measured memory_bytes: 2044
#include<iostream>
#include<vector>
#include<cmath>
using namespace std;

int main()
{
    int N; cin >> N;
    vector<int> h(N);
    for(auto &&item : h) cin >> item;
    vector<int> c(N);
    c.at(0) = 0; c.at(1) = abs(h.at(1) - h.at(0));
    for(int i = 2; i < N; i++) c.at(i) = min(c.at(i - 1) + abs(h.at(i) - h.at(i - 1)), c.at(i - 2) + abs(h.at(i) - h.at(i - 2)));
    cout << c.at(N - 1) << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>


// 1000keta dato int gata dato afureru.dousiyou.
// sokka. hairetsu ni hito-keta dutu irete ikeba yoi youna kiga site kita.


int main(void)
{
  int i,cnt;
  char num[1001];
  while(1)
    {
      scanf("%s",num);// num ha address nanode ampersand ha iranai
      if(num[0] == '0')break;
      // minus ha kanngaenai
      cnt = 0;
      for( i = 0;num[i] ;i++)
        cnt += num[i] - '0';// num[i]niha ascii code ga haitteiru. 0no ascii code wo hikuto suuchi ni naru
      printf("%d\n",cnt);
    }
  return 0;
}

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

using namespace std;

#define ll long long
#define ld long double

ll inverse(int* A, int N) {
	ll ans = 0;
	ll a[N + 1000] = {};
	for (int i = 0; i < N; ++i) {
		for (int j = A[i]; j; j -= (j & (-j))) ans -= a[j]; ans += i;
		for (int j = A[i]; j <= N; j += (j & (-j))) a[j]++;
	}
	return ans;
}

signed main() {
	int n, k;
	cin >> n >> k;

	int p[n];
	for (int i = 0; i < n; ++i) {
		int pi; cin >> pi;
		p[i] = pi;
	}

	bool is_sorted = true;
	for (int i = 0; i < n; ++i)
		is_sorted = is_sorted && (p[i] == i + 1);
	if (is_sorted){
		cout << "Yes" << endl;
		exit(0);
	}

	if (n == k){
		bool ok = true;
		for (int i = 0; i < n; ++i){
			if (p[(i + 1) % n] != (p[i] != n ? (p[i] + 1) : 1))
				ok = false;
		}
		if (ok){
			cout << "Yes" << endl;
			exit(0);
		}
		else{
			cout << "No" << endl;
			exit(0);
		}
	}

	ll inv = inverse(p, n);

	if (k % 2 == 1 && inv % 2 == 1) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}

	return 0;
}


Measured memory_bytes: 4272
#include<bits/stdc++.h>
#define nl cout<<"\n";
#define sp cout<< " ";
#define rep(i, a, b) for(int i=a; i< b; i++)


using namespace std;
int main()
{
    long long n, s=0;
    cin>> n;
    rep(i, 1, n+1)
    {
        rep(j, 1, n+1)
        {
            rep(k, 1, n+1)
            s+=__gcd(__gcd(i, j), k);
        }
    }
    cout<< s<< endl;


    return 0;
}


Measured memory_bytes: 3624
using System;
using static System.Console;
using static System.Math;
using System.IO;
using System.Collections.Generic;
namespace I_am_the_green_coder{
    class Inonoa{
        // なんか入力用の関数作ったけどまだテストしてないので使う前に確かめて
        static void Main(){
            long n = ILongs()[0];
            long[][] a = ILongLongs(n);

            List<long> head = new List<long>();
            head.Add(a[0][0]);

            for(int i=1;i<n;i++){
                int left = 0;
                int right = head.Count;
                while(left<right){
                    if(head[(left+right)/2]+1==a[i][0]){
                        right = (left+right)/2;
                        continue;
                    }else if(head[(left+right)/2]+1>a[i][0]){
                        left = (left+right)/2 + 1;
                        continue;
                    }else{
                        right = (left+right)/2;
                        continue;
                    }
                }
                if(left==head.Count && head[head.Count-1]>=a[i][0]){
                    head.Add(a[i][0]);
                }else{
                    head[left] = a[i][0];
                }
            }

            Console.WriteLine(head.Count);
        }

        static readonly long MOD = 1000000007;

        ///<summary>a_1, a_2, a_3, ...みたいなの</summary>
        static long[] ILongs(){
            string[] s = ReadLine().Split();
            long[] re = new long[s.Length];
            for(long i=0;i<s.Length;i++){
                re[i] = long.Parse(s[i]);
            }
            return re;
        }

        ///<summary>xooxoxoxxoxo...みたいなの</summary>
        static char[] IChars(){
            return ReadLine().ToCharArray();
        }

        ///<summary>n m とかをちょっとはやくかくだけ</summary>
        static string[] IStrings(){
            return ReadLine().Split();
        }

        ///<summary>n行の入力を取ったり</summary>
        static long[][] ILongLongs(long n){
            long[][] re = new long[n][];
            for(long i=0;i<n;i++){
                string[] s = ReadLine().Split();
                re[i] = new long[s.Length];
                for(long j=0;j<s.Length;j++){
                    re[i][j] = long.Parse(s[j]);
                }
            }
            return re;
        }

        ///<summary>n行の文字列を取ったり</summary>
        static char[][] ICharsChars(long n){
            char[][] re = new char[n][];
            for(long i=0;i<n;i++){
                re[i] = ReadLine().ToCharArray();
            }
            return re;
        }
    }
}

Measured memory_bytes: 23504
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <deque>
#include <list>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define all(v) (v).begin(),(v).end()


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef vector<int, int> vint;
typedef pair<int,int> pint;
typedef vector<pint>vpint;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B, C, D; cin >> A >> B >> C >> D;
    cout << (A*B>C*D ? A*B : C*D);
    cout << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#define _USE_MATH_DEFINES
#include <math.h>
#include <vector>
#include <string>
#include <ctype.h>

using namespace std;

void solve()
{
	string s, p;
	cin >> s >> p;
	s += s;
	if (s.find(p) != string::npos)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
}

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

Measured memory_bytes: 1188