akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Text;

struct coord
{
    public int row;
    public int col;
}

class Program
{
    public static int Main()
    {
        do
        {
            new Program().solve();
        } while (false);
        return 0;
    }
    public void solve()
    {
        string[] str = Console.ReadLine().Split(' ');
        int N = int.Parse(str[0]);
        int M = int.Parse(str[1]);

        string[] A = new string[N];
        string[] B = new string[M];

        for (int i = 0; i < N; ++i)
        {
            A[i] = Console.ReadLine();
        }
        for (int i = 0; i < M; ++i)
        {
            B[i] = Console.ReadLine();
        }

        System.Collections.Generic.Queue<coord> queue = new Queue<coord>();
        for (int row = 0; row < N - M + 1; ++row)
        {
            int offset = 0;
            while (offset < N - M + 1)
            {
                int col = A[row].IndexOf(B[0], offset);
                if (col != -1)
                {
                    coord v;
                    v.row = row;
                    v.col = col;
                    queue.Enqueue(v);
                    offset = col + 1;
                }
                else
                {
                    break;
                }
            }
        }

        bool exist = false;
        while (queue.Count > 0)
        {
            bool match = true;
            coord v = queue.Dequeue();
            for (int i = 0; i < M; ++i)
            {
                if (A[v.row + i].IndexOf(B[i], v.col) != v.col)
                {
                    match = false;
                    break;
                }
            }
            if (match)
            {
                exist = true;
                break;
            }
        }

        if (exist)
        {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 13524
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;

int main(){
    int n;scanf("%d",&n);double x[n],y[n];
    double d1=0,d2=0,d3=0,dl=0;
    for(int i=0;i<n;i++) scanf("%lf",&x[i]);
    for(int i=0;i<n;i++) scanf("%lf",&y[i]);
    for(int i=0;i<n;i++) d1+=abs(x[i]-y[i]);
    for(int i=0;i<n;i++) d2+=(x[i]-y[i])*(x[i]-y[i]);
    for(int i=0;i<n;i++) d3+=(x[i]-y[i])*(x[i]-y[i])*abs(x[i]-y[i]);
    for(int i=0;i<n;i++) dl=max(dl,abs(x[i]-y[i]));
    printf("%lf\n%lf\n%lf\n%lf\n",d1,sqrt(d2),pow(d3,1.0/3.0),dl);
}


Measured memory_bytes: 3388
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int n,ans,a,b;
int main()
{
    scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d",&a,&b);
		ans+=abs(a-b)+1;
	}
	printf("%d",ans);
    return 0;
}

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

//1 <= N <= 10^10なので
//1回のfor文すら回せない
//N = A * B なので√Nまで探索すればok
int findDigit(ll x, ll y)
{
    ll s, t;
    s = log10(x) + 1;
    t = log10(y) + 1;
    return max(s, t);
}

int main()
{
    cin >> N;
    ll s = sqrt(N);

    ll res = N;
    for (int i = 1; i <= s; i++)
    {
        if (N % i == 0)
        {
            int F = findDigit(i, N / i);
            if (F < res)
                res = F;
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 3900
#include  <iostream>
#include  <algorithm>
#include  <cmath>

using namespace std;

int main()
{
	int n, d;
	int p[10][10];

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

	int cnt = 0;
	for (int i = 0; i < n - 1; i++) {
		for (int j = i + 1; j < n; j++) {
			double a = 0;
			for (int k = 0; k < d; k++) {
				a += (p[i][k] - p[j][k]) * (p[i][k] - p[j][k]);
			}
			double b = sqrt(a);
			if (b - floor(b) == 0)  cnt++;
		}
	}

	cout << cnt << endl;
}

Measured memory_bytes: 256
import static java.util.Arrays.deepToString;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}
	void tr(Object... os) {
		System.err.println(deepToString(os));
	}

	Scanner sc = new Scanner(System.in);
	public void run() {
		for (;sc.hasNext();) {
			int n = sc.nextInt();
			if (n == 0) break;
			sc.nextLine();
			List<S> list = new ArrayList<S>();
			for (int kkk = 0; kkk < n; kkk++) {
				String[] ss = sc.nextLine().split(" ");
				int id = Integer.parseInt(ss[0]);
				int[] as = new int[ss.length - 1];
				for (int i = 1; i < ss.length; i++) {
					as[i-1] = Integer.parseInt(ss[i]);
				}
				S s = new S();
				s.id = id;
				s.score = getScore(as);
				list.add(s);
			}
			Collections.sort(list);
			for (S s : list) {
				System.out.println(s.id + " " + s.score);
			}
		}
	}
	
	int getScore(int[] as) {
		int[] fs = new int[10];
		int i = 0;
		for (int f = 0; f < 10; ) {
			int cur = 0;
			cur += as[i];
			if (cur == 10) { // strike
				cur += as[i + 1] + as[i + 2];
				i += 1;
			} else { 
				cur += as[i + 1];
				if (cur == 10) { // spear
					cur += as[i + 2];
				}
				i += 2;
			}
			fs[f++] = cur;
		}
		int sum = 0;
		for (int x : fs) sum += x;
		return sum;
	}
	
	static class S implements Comparable<S> {
		int id;
		int score;
		@Override
		public int compareTo(S o) {
			if (score != o.score) return -(score - o.score);
			return id - o.id;
		}
	}
}

Measured memory_bytes: 21528
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    string s;
    cin >> n >> k;
    cin >> s;
    vector<vector<char>> abc={{'A','a'},{'B','b'},{'C','c'}};
    for (int i = 0; i < 3;i++){
        if(s[k-1]==abc[i][0])
            s[k - 1] = abc[i][1];
    }
    cout << s << endl;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n,k;
  cin>>n>>k;
  
  vector<int> A(n);
  rep(i,n) cin>>A[i];
  sort(ALL(A));
  
  int sum=0;
  rep(i,k) sum+=A[i];
  
  cout<<sum<<endl;
  
  return 0;
}

Measured memory_bytes: 3720
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

int num[100010];
bool red[100010];

int main(){
  int N,M;
  cin>>N>>M;
  vector<int> X(M),Y(M);
  rep(i,M) cin>>X[i]>>Y[i];

  for(int i=0;i<N;i++) num[i]=1;
  red[0]=true;
  for(int i=0;i<M;i++){
    X[i]--;
    Y[i]--;

    num[Y[i]]++;
    num[X[i]]--;
    if(red[X[i]]) red[Y[i]]=true;
    if(num[X[i]]==0) red[X[i]]=false;
  }

  int ans=0;
  for(int i=0;i<N;i++){
    if(red[i]) ans++;
  }

  cout<<ans<<endl;


  return 0;
}

Measured memory_bytes: 1536
#include "bits/stdc++.h"
#include <math.h>
#include <time.h>
using namespace std;
const long long mod = 1000000007;
#define dump(x)                             \
    if (dbg) {                              \
        cout << #x << " = " << (x) << endl; \
    }
bool dbg = false;
long long gcd(long long a, long long b){
   if (a % b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a % b));
   }
}
long long lcm(long long a, long long b){
   return (a / gcd(a, b))* b;
}
//---------------------------------------------------------------------------------------------------
/*ここからいじる*/
//---------------------------------------------------------------------------------------------------

void solve(){
}
int main(){
    int n, d;
    cin >> n >> d;
    vector<vector<int> >data(n, vector<int>(d));
    for(int i = 0; i < n; i++){
        for(int j = 0; j < d; j++){
            cin >> data.at(i).at(j);
        }
    }
    int cnt = 0;
    for(int i = 0; i < n - 1; i++){
        for(int j = i + 1; j < n; j++){
            int tmp = 0;
            for(int k = 0; k < d; k++){
                tmp += ((data.at(i).at(k) - data.at(j).at(k)) * (data.at(i).at(k) - data.at(j).at(k)));
            }
            if(floor(sqrt(tmp)) == sqrt(tmp)){
                cnt++;
            }
        }
    }
    cout << cnt << endl;
    solve();
    return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <cstring>

int main(){
  char ring[101], p[101], line[202];
  scanf("%s", ring);
  scanf("%s", p);

  int ring_length, p_length;
  ring_length = strlen(ring);
  p_length = strlen(p);

  for(int i = 0; i < 2; i++){
    strcpy((line+i*(ring_length)),ring);
  }

  if(strstr(line, p) != NULL){
    printf("Yes\n");
  }
  else{
    printf("No\n");
  };

  return 0;
}

Measured memory_bytes: 960
#include<bits/stdc++.h>
#define ll     int
#define pb          push_back
#define    endl        '\n'
#define pii         pair<ll ll,ll ll>
#define all(v) (v).begin(), (v).end()
using namespace std;
const int N = 1e3 + 5;
ll vis[N][N], a[N][N];
const std::vector<ll> v = {-2, -1, 0, 1, 2};
ll n, m;
ll tx, ty, nx, ny, type;
deque<pair<ll, ll>> q;
inline bool check(ll x, ll y)
{
    return x > 0 and  y > 0 and x <= n and y <= m;
}

void solve()
{
    char c;
    cin >> n >> m;
    ll x, y;
    cin >> x >> y >> tx >> ty;
    for(int i = 0; i < n; i++)
        for(int j = 0; j < m; j++)
        {
            cin >> c;
            a[i + 1][j + 1] = (c == '.');
            vis[i + 1][j + 1] = INT_MAX;
        }

    q.push_back({x, y});
    vis[x][y] = 0;
    while(!q.empty())
    {

        tie(x, y) = q.front(); q.pop_front();
        if(x == tx  and y == ty) break;

        for(ll dx : v)for(ll dy : v)
            {
                nx = dx + x, ny = dy + y;
                type = (abs(dx) + abs(dy) != 1);
                if(check(nx, ny) and a[nx][ny] and vis[nx][ny] > vis[x][y] + type)
                {
                    vis[nx][ny] = vis[x][y] + type;
                    if(type)
                        q.push_back({nx,ny});
                    else
                        q.push_front({nx,ny});
                }
            }
    }

    cout << (vis[tx][ty] == INT_MAX ? -1 : vis[tx][ty]);

}
int main()
{


    ios_base::sync_with_stdio(false);
    cin.tie(0);

    ll TESTS = 1;
    // cin >> TESTS;
    while(TESTS--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 11516
#include <bits/stdc++.h>
using namespace std;
int main() {
   int a,b,c;
   int N = 0;
   cin >>a>>b>>c;
  
   if(a == b){N++;}
   if(c == b){N++;}  
   if(a == c){N++;}
  
   if(N == 1) cout << "Yes" << endl;
   else cout << "No" << endl;
  
   return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,nw,a[100005],b[100005];
long long ans[100005];
bool cmp(int x,int y){return a[x]>a[y]||(a[x]==a[y]&&x<y);}
int main()
{
	scanf("%d",&n);
	for(int i=0;i<n;i++)scanf("%d",&a[i]);
	for(int i=0;i<n;i++)b[i]=i;
	sort(b,b+n,cmp);
	b[n]=n;
	int nw=b[0];
	for(int i=0;i<n;i++,nw=min(nw,b[i]))ans[nw]+=1ll*(a[b[i]]-a[b[i+1]])*(i+1);
	for(int i=0;i<n;i++)printf("%lld\n",ans[i]);
	return 0;
}

Measured memory_bytes: 2688
#include<bits/stdc++.h>
#define MAX 1000000
using namespace std;
int visited[MAX+1];
bool check(int x)
{
	vector<int> divisors;
	divisors.push_back(1);
	for(int i=2;i*1LL*i<=x;++i)
		if(x%i==0)
			divisors.push_back(i),divisors.push_back(x/i);
	divisors.push_back(x);
	for(int y:divisors)
		if(visited[y])
			if(x!=y||visited[y]>1)
				return false;
	return true;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	vector<int> v;
	for(int i=0,x;i<n;++i)
		cin>>x,v.push_back(x),visited[x]++;
	int ans = 0;
	for(int i=0;i<n;++i)
		if(check(v[i]))
			ans++;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 8160
#include<stdio.h>
int main(){
    int a,b,c,d,n,f;
    for(;;){
        if(scanf("%d",&n)==EOF){break;}
        f=0;
        for(a=0;a<10;a++){
            for(b=0;b<10;b++){
                for(c=0;c<10;c++){
                    for(d=0;d<10;d++){
                        if(n==a+b+c+d){f++;}
                        }
                        }
                        }
                        }
                        printf("%d\n",f);
                        }
                        return 0;
                        }

Measured memory_bytes: 596
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
string s;
map<string, int> weight;
int p;
int expr();
string parseS(){
  string res = "";
  res += s[p++];
  while(islower(s[p])) res += s[p++];
  return res;
}
int parseN(){
  if(!(p < s.size()) || !isdigit(s[p])) return 1;
  int res = 0;
  while(isdigit(s[p])) res = res * 10 + s[p++] - '0';
  return res;
}
int term(){
  if(s[p] == '('){
    p++;
    int e = expr();
    int num = parseN();
    return e * num;
  }
  string atom = parseS();
  int num = parseN();
  //printf("%s %d\n",atom.c_str(), num);
  if(weight.count(atom)) return weight[atom] * num;
  else return INF;
}
int expr(){
  int res = term();
  while(p < s.size()){
    if(s[p] == ')'){
      p++;
      break;
    }
    res += term();
  }
  return res;
}
int main(){
  weight.clear();
  while(cin>>s && s != "END_OF_FIRST_PART"){
    int value; cin>>value;
    weight[s] = value;
  }
  while(cin>>s && s != "0"){
    p = 0;
    int ans = expr();
    if(ans >= INF) cout<<"UNKNOWN"<<endl;
    else cout<<ans<<endl;
  }
  return 0;
}

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
   int n;
   cin >> n;
   if (360%n==0)
   {
       cout << 360/n;
   }
   else
   {
       for (auto i=1; i<=100000; i++)
       {
           if (i*n%360==0)
           {
               cout << i;break;
           }
       }
   }
   return 0;
}

Measured memory_bytes: 3568
import java.util.List;
import java.util.Scanner;
import java.util.ArrayList;

public class Main {
    static int f(int n) {
        if (n % 2 == 0) {
            return n / 2;
        } else {
            return 3 * n + 1;
        }
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int s = sc.nextInt();
        int[] a = new int[1000005];
        ArrayList<Integer> array = new ArrayList<>();
        for (int i = 0; i < 1000005; i++) {
            if (i == 0)
                a[i] = s;
            else {
                a[i] = f(a[i - 1]);
            }
            if (array.contains(a[i])) {
                System.out.println(i + 1);
                return;
            } else
                array.add(a[i]);
        }
    }

}


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

int main()
{
    int h, w, a, b;
    cin >> h >> w >> a >> b;
    for(int i = 0; i < b; i++){
        for(int j = 0; j < a; j++) cout << 0;
        for(int j = a; j < w; j++) cout << 1;
        cout << endl;
    }
    for(int i = b; i < h; i++){
        for(int j = 0; j < a; j++) cout << 1;
        for(int j = a; j < w; j++) cout << 0;
        cout << endl;
    }
}

Measured memory_bytes: 1280
#include <iostream>
 
inline bool is_right_triangle(const u_int a, const u_int b, const u_int c) {
    return (a*a == b*b + c*c || b*b == c*c + a*a || c*c == a*a + b*b);
}
 
int main(void) {
    u_int n;
    std::cin >> n;
    
    for (u_int i = 0; i < n; ++i) {
        u_int a, b, c;
        std::cin >> a >> b >> c;
        std::cout << (is_right_triangle(a, b, c) ? "YES" : "NO") << std::endl;
    }
 
    return 0;
}

Measured memory_bytes: 1148
import math


def is_prime(x):
    for i in range(2, int(math.sqrt(x))):
        if x % i == 0:
            return False
    return True

def next_prime(x):
    i = x
    while True:
        if is_prime(i):
            return i
        i += 1

x = int(input())
print(next_prime(x))

Measured memory_bytes: 3060
a[9999];main(n,i,j,m,s){
	for(;scanf("%d",&n),n;){
		for(i=0;i<n;i++)scanf("%d",a+i);
		for(m=-100000,i=0;i<n;i++){
			for(s=0,j=i;j<n;j++){
				s+=a[j];
				if(m<s)m=s;
			}
		}
		printf("%d\n",m);
	}
	exit(0);
}

Measured memory_bytes: 612
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define str to_string
#define endl "\n"
#define PI 3.141592653589
using namespace std;
using lint = long long;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

int n;

void bfs(vector<vector<pair<int,int>>> &vec,vector<int> &ans,int color,int start){
    int e,v,c=0;
    vector<int> vc(n,-1);//それぞれの頂点をつっこむ時に使った色
    queue<pair<int,int>> q;
    for(auto p:vec[start]){
        q.push(p);
        ans[p.first]=c%color;
        vc[p.second]=c%color;
        c++;
    }
    while(!q.empty()){
        auto p=q.front();q.pop();
        e=p.first;v=p.second;
        c=vc[v]+1;
        for(auto np:vec[v]){
            if(ans[np.first]!=-1)continue;
            q.push(np);
            ans[np.first]=c%color;
            vc[np.second]=c%color;
            c++;
        }
    }
}

//AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC
int main(){
  int x,y;cin>>x>>y;
  if(x%y==0)cout<<-1<<endl;
  else cout<<x<<endl;
}


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

#define vi vector<int>
#define ii pair<int,int>
#define iii pair<int,pair<int,int>>
#define vii vector<pair<int,int>>
#define vvi vector<vector<int>>

typedef long long ll;
typedef unsigned long long ull;

#define pb push_back
#define mp make_pair
#define fi first
#define se second

using namespace std;

int n, result = 0;
vi v;

int main (void) {
    ios_base::sync_with_stdio(false);

    cin >> n;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        if (x % 2 == 0) {
            while (x % 2 == 0) {
                x /= 2;
                result++;
            }
        }
    }

    cout << result << endl;

    return 0;
}


Measured memory_bytes: 256
import sys
from collections import deque
from functools import lru_cache
import bisect
import copy
import heapq
import itertools
import math
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 10 ** 9 + 7

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


def f(N, E, memo):
    if N == 0:
        return 0
    
    if N == 1:
        return E[-1]

    if N in memo:
        return memo[N]

    res = N * E[-1]
    for k in (2, 3, 5):
        l = (N // k) * k
        r = ((N - 1) // k + 1) * k

        res = min(res, (N - l) * E[-1] + E[k] + f(l // k, E, memo))
        res = min(res, (r - N) * E[-1] + E[k] + f(r // k, E, memo))
    memo[N] = res
    return res
   

def main():
    T = int(input())
    for _ in range(T):
        N, A, B, C, D = read_values()
        E = (0, 0, A, B, 0, C, D)
        memo = dict()
        print(f(N, E, memo))


if __name__ == "__main__":
    main()



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


int main(){
  string s;
  cin>>s;
  string c="hi";
  int n=s.size();
  string ans="Yes";
  for (int i=0;i<n;i+=2){
    string temp=s.substr(i,2);
    if (temp.compare(c)!=0){
      ans="No";
      break;
  }
  if (s.size()%2==1) ans="No";

  }
  cout<<ans;
}


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

int main(){
    
    int a,b;
    
    cin>>a >> b ;
    
    if (a<b) cout << "a < b" << "\n";
    
    else if (a>b) cout << "a > b"  << "\n";
    
    else cout << "a == b" << "\n";
    
    return 0;
}


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

using namespace std;

int main() {
    int n;
    cin >> n;
    double a,an = 0;
    for (int i = 0; i < n; i++) {
        cin >> a;
        an += 1 / a;
    }

    cout << fixed << setprecision(10) << 1 / an << endl;

    return 0;
}


Measured memory_bytes: 256
using System;

class Program
{
    static int Main()
    {
        string[] in1 = Console.ReadLine().Split(' ');
        int n = int.Parse(in1[0]), m = int.Parse(in1[1]), cnt2 = 0;
        int[] cnt = new int[m];
        for(var i=0; i<n; i++)
        {
            string[] in2 = Console.ReadLine().Split(' ');
            int k = int.Parse(in2[0]);
            for(var j=1; j<=k; j++)
            {
                cnt[int.Parse(in2[j])-1]++;
            }
        }
        /*
        for (var i = 0; i < m; i++)
            Console.Write(cnt[i]);
        Console.WriteLine();
        */
        for(var i=0; i<m; i++)
        {
            if (cnt[i] == n)
                cnt2++;
        }
        Console.WriteLine(cnt2.ToString("d"));
        return 0;
    }
}

Measured memory_bytes: 13140
<?php

fscanf(STDIN, "%d", $n);
$P = array_map('intval', explode(' ', trim(fgets(STDIN))));

$eq = [];
$tmp = [];
for ($i = 0; $i < $n; ++$i) {
    if ($i + 1 !== $P[$i]) {
        if (empty($tmp)) continue;
        $eq[] = $tmp;
        $tmp = [];
    } else {
        $tmp[] = $P[$i];
    }
}
if (!empty($tmp)) {
    $eq[] = $tmp;
}

$cnt = 0;
foreach ($eq as $arr) {
    $cnt += ceil(count($arr) / 2);
}
echo (int) $cnt;


Measured memory_bytes: 31604
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <numeric>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define ll long long
#define debug(x) cout << "debug: " << x << endl
#define MOD 1e9 + 7
#define INF 1e9

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

int main(){
    int n; cin >> n; int k; cin >> k;
    vector<int> h(n); rep(i, n) cin >> h[i];
    vector<int> dp_table(n, INF);
    dp_table[0] = 0;
    rep(i,n){
        chmin(dp_table[i], abs(h[i] - h[i - 1]) + dp_table[i - 1]);
        for (int j = 2; j <= k; j++){
            if (i > j -1 ){
                chmin(dp_table[i], abs(h[i] - h[i - j]) + dp_table[i - j]);
        }

        }
    }
    cout << dp_table[n - 1] << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <string>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

int main(){
    string s;
    cin >> s;
    if(s == "AAA" || s == "BBB"){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }


    return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
public static void main(String[] args) {
  Scanner reader =new Scanner (System.in);
  int  a=reader.nextInt();
  int b=reader.nextInt();
  int c=reader.nextInt();
  int k=reader.nextInt();
  int ans=0;
  int kai=k;

  for(int i=0;i<a;i++)
  {
    if(k!=0)
    {
      k--;
      ans++;
    }else break;

  }
  for(int i=0;i<b;i++)
  {
    if(k!=0)
    {
      k--;
    }else break;
  }

    for(int i=0;i<c;i++)
    {
      if(k!=0)
      { ans--;
        k--;
      }else break;
  }
System.out.println(ans);


}

}


Measured memory_bytes: 35784
#include <iostream>
#include <string>

using namespace std;

int main(){
	int k;
	string s, s2;

	cin >> k >> s;

	if((int)(s.length()) <= k){
		cout << s << endl;
	}else{
		s2 = s.substr(0, k);
		cout << s2 + "..." << endl;
	}

	

	return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <deque>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int main() {
	int n;
	cin >> n;

	vector<int>a(n);
	vector<int>b(n);
	rep(i, n) {
		cin >> a[i];
		b[i] = a[i];
	}

	sort(a.begin(), a.end());
	int ans = a[n - 1];
	int ans2 = a[n - 2];

	rep(i, n) {
		if (b[i] == ans)
			cout << ans2 << endl;
		else
			cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define LL long long
using namespace std;
const LL inf=3000000000000000000ll;
const int mo=1000000007;
LL A,B,w[100005]; int f[100005],g[100005],a[100005],b[100005],n,p,q;
int main(){
	scanf("%d%lld%lld",&n,&A,&B);
	for (int i=1;i<=n;++i) scanf("%lld",&w[i]);
	w[0]=-inf; w[n+1]=inf;
	for (int i=1;i<=n;++i){
		if (w[i]-w[i-1]>=A) a[i]=a[i-1]; else a[i]=i;
		if (w[i]-w[i-1]>=B) b[i]=b[i-1]; else b[i]=i;
	}
	f[0]=g[0]=1;
	for (int i=1;i<=n;++i){
		while (p<i&&w[p]+A<=w[i+1]) ++p;
		while (q<i&&w[q]+B<=w[i+1]) ++q;
		f[i]=q>=a[i]?(g[q-1]-(a[i]>1?g[a[i]-2]:0))%mo:0;
		g[i]=p>=b[i]?(f[p-1]-(b[i]>1?f[b[i]-2]:0))%mo:0;
		(f[i]+=f[i-1])%=mo;
		(g[i]+=g[i-1])%=mo;
	}
	printf("%d\n",((1ll*f[n]-f[n-1]+g[n]-g[n-1])%mo+mo)%mo);
	return 0;
}

Measured memory_bytes: 2688
#include<iostream>
#include<algorithm>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<vector>
#include<deque>

using namespace std;

int H, W;
int m[102][102];
int N;
int a[10007];

int init(){
  cin >> H >> W;
  cin >> N;
  for( int i = 0; i < N; i++ ){
	cin >> a[i];
  }
  for( int i = 0; i < 102; i++ ){
	for( int j = 0; j < 102; j++ ){
	  m[i][j] = 10007;
	}
  }
  for( int i = 1; i <=H; i++ ){
	for( int j = 1; j <=W; j++ ){
	  m[i][j] = 0;
	}
  }
  return 0;
}

int main(){
  int DX[4] = {1, 0, -1, 0};
  int DY[4] = {0, 1, 0, -1};
  int k = 0;
  int dx = DX[k], dy = DY[k];
  int px = 1, py = 1;
  init();
  for( int i = 0; i < N; i++ ){
	for( int j = 0; j < a[i]; j++ ){
	  m[py][px] = i+1;
	  if( m[py+dy][px+dx] > 0 ){
		k = (k+1) & 3;
		dx = DX[k];
		dy = DY[k];
	  }
	  px = px + dx;
	  py = py + dy;
	}
  }
  for( int i = 1; i <= H; i++ ){
	for( int j = 1; j <= W; j++ ){
	  cout << " " << m[i][j];
	}
	cout << endl;
  }
  return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
#include<math.h>
signed main(void)
{
  int A,B,H,M;
  if(~scanf("%d %d %d %d",&A,&B,&H,&M))
  {
    double theta=(60*H-11*M)*M_PI/360.0,x=A-B*cos(theta),y=B*sin(theta);
    return printf("%.20f",pow(x*x+y*y,0.5)),0;
  }
}

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

int main(){
  int n,j=0;
  cin>>n;
  for(int i=0;i<n;i++){
    string s;
    cin>>s;
    if(s=="Y"){
      cout << "Four"<<endl;
      break;
    }
    else j++; 
  	if(j==n)
	  cout <<"Three"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    unsigned long N, M;
    cin >> N >> M;
    unsigned long ans = 0;
    if(N>=M/2){
        ans = M/2;
    }else{
        ans = N + (M-2*N)/4;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n;i>=0;i--)
#define MAX 1004
#define B 100
#define dpb push_back
#define fi first
#define se second
typedef pair<int, int> P;
typedef long long ll;
const int inf = 1e9;
const ll INF = 1e18;
//__gcd(a,b), __builtin_popcount(a);

char str[MAX][MAX];
int a[MAX][MAX], dp[MAX][MAX][16];
main(){
	int h, w;
	fill((int*)dp, (int*)(dp+MAX), inf);
	scanf("%d%d", &h, &w);
	rep(i,h)scanf("%s", str[i]);
	rrep(i,h)rrep(j,w){
		if(str[i-1][j-1] == '.')a[i][j] = 0;
		else a[i][j] = str[i-1][j-1]-'0';
	}
	
	dp[1][1][0] = 0;
	int b, c, t[4], cost, ans = inf;
	for(int y = 1;y <= h;y++){
		for(int x = 1;x <= w;x++){
			for(int bit = 0;bit < (1<<4);bit++){
				cost = dp[y][x][bit];
				if(cost == inf)continue;
				rep(i,4)t[i] = bit>>i&1;
				
				b = 6+8*t[2];
				c = a[y][x+1]*(!t[1])+a[y+1][x+1]+a[y][x+2];
				dp[y][x+1][b] = min(dp[y][x+1][b], cost+c);
				
				b = 4+8*t[2];
				c = a[y][x+1]*(!t[1])+a[y-1][x+1]*(!t[0])+a[y+1][x+1];
				dp[y][x+1][b] = min(dp[y][x+1][b], cost+c);
				
				b = 2+8*t[2];
				c = a[y][x+1]*(!t[1])+a[y-1][x+1]*(!t[0])+a[y][x+2];
				dp[y][x+1][b] = min(dp[y][x+1][b], cost+c);
				
				b = 6+t[1];
				c = a[y+1][x]*(!t[2])+a[y+1][x+1]+a[y+2][x];
				dp[y+1][x][b] = min(dp[y+1][x][b], cost+c);
				
				b = 2+t[1];
				c = a[y+1][x]*(!t[2])+a[y+1][x-1]*(!t[3])+a[y+1][x+1];
				dp[y+1][x][b] = min(dp[y+1][x][b], cost+c);
				
				b = 4+t[1];
				c = a[y+1][x]*(!t[2])+a[y+1][x-1]*(!t[3])+a[y+2][x];
				dp[y+1][x][b] = min(dp[y+1][x][b], cost+c);
				
				if(y == h && w == x)ans = min(ans, cost);
			}
		}
	}
	
	printf("%d\n", ans);
	return 0;
}



Measured memory_bytes: 71116
#include <iostream>
#include <bitset>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

int main(){
  ll X,Y;
  cin >> X >> Y;
  if(X==Y){
    cout << 0 << endl;
  }
  else if(X>Y){
    if(Y>0){
      cout << X-Y+2 << endl;
    }
    else if(Y==0){
      cout << X-Y+1 << endl;
    }
    else if(X>0){
      cout << abs(X+Y)+1 << endl;
    }
    else if(X==0){
      cout << -Y+1 << endl;
    }
    else{
      cout << X-Y+2 << endl;
    }
  }
  else{
    if(X>=0){
      cout << Y-X << endl;
    }
    else if(Y>0){
      cout << abs(Y+X)+1 << endl;
    }
    else if(Y==0){
      cout << abs(X) << endl;
    }
    else{
      cout << Y-X << endl;
    }
  }
}

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

#ifdef _DEBUG
#define ASSERT(x) assert(x)
#define DLOG(x) cout << __LINE__ << ": " << x << endl;
#else
#define ASSERT(x)
#define DLOG(x)
#endif
#define DLOG_V(x) DLOG(#x << ": " << x)

using namespace std;

struct Node {
  explicit Node(int value) : value{value} {}
  int value;
  Node* left{nullptr};
  Node* right{nullptr};
};

struct Tree {
  void print(ostream& os) const {
    doInOrder(root, 0, [&os](auto&& i, auto&&) { os << " " << i; });
    os << endl;
    doPreOrder(root, [&os](auto&& i) { os << " " << i; });
    os << endl;
  }
  void print2(ostream& os) const {
    doInOrder(root, 0, [&os](auto&& i, auto&& depth) {
        for (int i = 0; i < depth; ++i) {
          os << ' ';
        }
        os << " " << i << endl;
    });
    os << endl;
  }

  void insert(int val) {
    *findNode(val) = new Node{val};
  }

  bool find(int val) {
    return *findNode(val);
  }

  void delete_(int val) {
    deleteNode(findNode(val));
  }

 private:
  Node** findNode(int val) {
    auto place = &root;
    while (*place && (*place)->value != val) {
      place = val < (*place)->value ? &(*place)->left : &(*place)->right;
    }
    return place;
  }

  void deleteNode(Node** place) {
    auto node = *place;
    auto& left = node->left;
    auto& right = node->right;
    if (left && right) {
      auto t = leftMost(&right);
      node->value = (*t)->value;
      deleteNode(t);
    } else {
      auto child = left ? left : right;
      *place = child;
      delete node;
    }
  }

  Node** leftMost(Node** node) {
    auto& left = (*node)->left;
    if (!left) {
      return node;
    } else {
      return leftMost(&left);
    }
  }

  void doInOrder(Node* node, int depth, const function<void(int, int)>& f) const {
    if (!node) {
      return;
    }
    doInOrder(node->left, depth + 1, f);
    f(node->value, depth);
    doInOrder(node->right, depth + 1, f);
  }

  void doPreOrder(Node* node, const function<void(int)>& f) const {
    if (!node) {
      return;
    }
    f(node->value);
    doPreOrder(node->left, f);
    doPreOrder(node->right, f);
  }

  Node* root{nullptr};
};

int main() {
  int num;
  cin >> num;
  Tree tree;
  ostringstream ss;
  for (int i = 0; i < num; ++i) {
    string cmd;
    cin >> cmd;
    if (cmd == "insert") {
      int val;
      cin >> val;
      tree.insert(val);
    } else if (cmd == "find") {
      int val;
      cin >> val;
      ss << (tree.find(val) ? "yes" : "no") << endl;
    } else if (cmd == "delete") {
      int val;
      cin >> val;
      tree.delete_(val);
    } else if (cmd == "print") {
      tree.print(ss);
    }
  }
  cout << ss.str();
}



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

int main() {
	int n, m;
	cin >> n >> m;
	int *d = new int[n], *c = new int[m];
	int *memo = new int[n+n*m+1];
	for(int i = 0; i < n; i++){
		cin >> d[i];
	}
	for(int i = 0; i < m; i++){
		cin >> c[i];
	}
	for(int i = 0; i < n+n*m+1; i++){
		memo[i] = 0;
	}
	for(int i = 1; i <= n; i++){
		for(int j = i; j <= m; j++){
			if(i == 1){
				if(j == 1){
					memo[i + j * n] = d[n-i] * c[m-j];
					continue;
				}
				int buf = d[n-i] * c[m-j];
				memo[i + j * n] = buf > memo[i + (j-1) * n] ? memo[i + (j-1) * n] : buf;
				continue;
			}
			if(i == j){
				memo[i + j * n] = d[n-i] * c[m-j] + memo[(i-1) + (j-1) * n];
				continue;
			}
			int buf = d[n-i] * c[m-j] + memo[(i-1) + (j-1) * n];
			memo[i + j * n] = buf > memo[i + (j-1) * n] ? memo[i + (j-1) * n] : buf;
		}
	}
	cout << memo[n + m * n] << endl;
}

Measured memory_bytes: 4352
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define pb(a) push_back(a)

typedef long long ll;
using namespace std;

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

//const int dy[] = { 0, 0, 1, -1 };
//const int dx[] = { 1, -1, 0, 0 };
const int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
const int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
ll gcd(ll a, ll b);
ll lcm(ll x, ll y);

//vector<ll> a;

int main()
{
	ll a,p;
	ll tmp;

	cin >> a >> p;
	
	tmp = a * 3 + p;
	cout << tmp/2 << endl;

	return 0;
}


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

int main(){
  char e;
  cin >>e;
  if((e=='a')||(e=='i')||(e=='u')||(e=='e')||(e=='o')){
    cout<<"vowel"<<endl;
    return 0;
  }
  cout<<"consonant"<<endl;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Collections;
using System.Collections.Generic;
public class Program {
    static void Main (string[] args) {
        StreamWriter sw = new StreamWriter(System.Console.OpenStandardOutput()) {};
        System.Console.SetOut(sw);
        
        var n = int.Parse(Console.ReadLine());
        int[] a = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
        int[] t = a.ToArray();
        Array.Sort(t);
        int m = n / 2 - 1;
        for (int i = 0; i < n; ++i) {
            if (a[i] <= t[m]) {
                Console.WriteLine(t[m+1]);
            } else {
                Console.WriteLine(t[m]);
            }
        }
        
        System.Console.Out.Flush();
    }
}


Measured memory_bytes: 40056
//C
#include <bits/stdc++.h>
#define reg register

using namespace std;

typedef long long ll;
const int maxn = 100005;

inline ll read() {
    reg ll s = 0, t = 0; reg char ch = getchar();
    while (!isdigit(ch)) t |= ch == '-', ch = getchar();
    while (isdigit(ch)) s = (s << 1) + (s << 3) + (ch ^ 48), ch = getchar();
    return t ? -s : s;
}

struct man { int id, num; } p[maxn];

inline bool cmp(man x, man y) { return x.num < y.num; }

int main() {
    reg int n = read();
    for (reg int i = 1; i <= n; i++) p[i].num = read(), p[i].id = i;
    sort(p + 1, p + n + 1, cmp);
    for (reg int i = 1; i <= n; i++) cout << p[i].id << " ";
    cout << endl;
    return 0;
}


Measured memory_bytes: 1536
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <algorithm>
#include <string>
#include <queue>
#define PIE 3.14159265358979
#define rep(i,n) for(int i = 0;i < (n);i++)
#define MAX_N 3005
using namespace std;
typedef long long ll;

ll dp[MAX_N][MAX_N];
int N;
ll a[MAX_N];

ll dfs(int i,int j){ //i枚目まで投げた時、j枚おもての確率
    if(dp[i][j]>=0){
        return dp[i][j];
    }
    if(i==j){
        dp[i][j]=0;
        return 0;
    }
    ll ret = max(a[i]-dfs(i+1,j),a[j-1]-dfs(i,j-1));
    dp[i][j]=ret;
    return ret;
}

int main() {
    cin>>N;
    rep(i,N){
        cin>>a[i];
    }
    rep(i,MAX_N){
        rep(j,MAX_N){
            dp[i][j]=-1;
        }
    }
    cout<<dfs(0,N)<<endl;
}



Measured memory_bytes: 70912
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.math.BigInteger;

public class Main {
//  ??¨?????????????????????
  static InputReader in;
  static PrintWriter out;
  
  static class Solution {
    void solve() throws IOException {
      int x = in.nextInt();
      out.println(x*x*x);
    }
  }

  public static void main(String[] args) throws IOException {
//    ??????
    in = new InputReader(System.in);
    out = new PrintWriter(System.out);
    Solution solver = new Solution();
    solver.solve();
    out.close();
}

  static class InputReader {
//    ??\???
    public BufferedReader br;
    public StringTokenizer st;
    
    public InputReader(InputStream stream) {
//      ?????????????????????
      br = new BufferedReader(new InputStreamReader(stream));
    }
   
//    ????????????????????????
    public int nextInt() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return Integer.parseInt(st.nextToken());
    }
    
    public long nextLong() throws IOException {
      return Long.parseLong(next()); 
    }
    
    public String next() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return st.nextToken();
    }
    
    public double nextDouble() throws IOException {
      return Double.parseDouble(next());
    }
    
  }
  
}

Measured memory_bytes: 24504
#include<bits/stdc++.h>
#define ll long long
#define debug(x) cout<<#x<<":"<<x<<endl;
using namespace std;
ll a,b,ans=1e9;
int main(){
	scanf("%lld%lld",&a,&b);
	if(b/2019-(a-1)/2019>0)return !puts("0");
	ll x=a%2019,y=b%2019;
	for(ll i=x;i<=y;i++){
		for(ll j=i+1;j<=y;j++){
			if(ans>i*j%2019){
				ans=i*j%2019;
//				debug(i);debug(j);
			}
		}
	}
	printf("%lld",ans);
//	printf("%lld",(a*(a+1))%2019);
	return 0;
}


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


int D[11] = {0};
int flag = 0;

bool check(int n)
{
	while(n!=0)
	{
		if(D[n%10] == 1)
		{
			return false;
		}
		n = n/10;
	}
	flag = 1;
	return true;
}


int main()
{
	int N, K, x, i;
	cin >> N >> K;
	for(i=0;i<K;i++)
	{
		cin >> x;
		D[x] = 1;
	}
	int n = N;
	while(flag==0)
	{
		if(check(n))
		{
			break;
		}
		n++;
	}
	cout << n;
  	return 0;
}

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

int main() {
  int N, y=0;
  cin >> N;
  
  for (int i=0; i<N; i++) {
    string S;
    cin >> S;
    
    if (S=="Y") {
      y++;
    }
  }
  
  if (y != 0) {
    cout << "Four" << endl;
  }
  else {
    cout << "Three" << endl;
  }
}

Measured memory_bytes: 3600
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
	var a = parseInt(input[0], 10);
	var b = input[1];
 if(b.slice(0, a/2) === b.slice(a/2, a)) console.log('Yes');
 else console.log('No');
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 21064
#include<bits/stdc++.h>
 using namespace std;
 
 int main() 
 {
 	string s;
 	cin>>s;
 	
 	for(int i=0;i<s.size()-1;i++)
 	{
 		if(s[i]==s[i+1])
 		{
 			cout<<i+1<<" "<<i+2<<endl;
 			return 0;
		 }
		 if(i+2<s.size())
		 {
		 	if(s[i]==s[i+2])
		 	{
		 		cout<<i+1<<" "<<i+3<<endl;
		 		return 0;
			 }
		 }
	}
	cout<<-1<<" "<<-1<<endl;
 }

Measured memory_bytes: 3752
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>

using namespace std;

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
 
	long long N;
 
	cin >> N;
 
	long long mod = pow(10, 9) + 7;
 
	long long re_x;
 
	long long base = 1;
 
	for(long long i = 2; i < N; i++) {
		base *= i;
		base %= mod;
	}
 
	long long plus = base;
 
	long long count = 0;
 
	cin >> re_x;
 
	for(long long i = 1; i < N; i++) {
		long long x;
		cin >> x;
 
		long long dis = x - re_x;
 
		re_x = x;
 
		count += (base * dis) % mod;
		count %= mod;
 
		plus *= modpow(i + 1, mod - 2, mod);
      	plus %= mod;
		plus *= i;
      	plus %= mod;
 
		base += plus;
		base %= mod;
	}
 
	count %= mod;
 
	cout << count << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const long long mod = 1e9 + 7;

ll gcd(ll a, ll b) {
	return b ? gcd(b, a % b) : a;
}

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

ll powMod(ll n, ll k, ll m) {
	if (k == 0) {
		return 1;
	} else if (k % 2 == 1) {
		return powMod(n, k - 1, m) * n % m;
	} else {
		ll t = powMod(n, k / 2, m);
		return t * t % m;
	}
}

int main() {
	vector<vector<P>> a(3, vector<P>(3));

	rep(i, 3) {
		rep(j, 3) {
			ll num;
			cin >> num;
			a[i][j]=make_pair(num,0);
		}
	}

	ll n;
	cin >> n;
	
	rep(i, n) {
		ll num;
		cin >> num;
		rep(j, 3) {
			rep(k, 3) {
				if (a[j][k].first == num) {
					a[j][k].second=1;
				}
			}
		}
	}


	rep(i, 3) {
		bool flg = true;
		rep(j, 3) {
			if (a[i][j].second != 1) {
				flg=false;
			}
		}
		if (flg) {
			cout << "Yes" << endl;
			return 0;
		}
	}

	rep(i, 3) {
		bool flg = true;
		rep(j, 3) {
			if (a[j][i].second != 1) {
				flg = false;
			}
		}
		if (flg) {
			cout << "Yes" << endl;
			return 0;
		}
	}

	if (a[0][0].second == 1 && a[1][1].second == 1 && a[2][2].second == 1) {
		cout << "Yes" << endl;
		return 0;
	}
	if (a[0][2].second == 1 && a[1][1].second == 1 && a[2][0].second == 1) {
		cout << "Yes" << endl;
		return 0;
	}

	cout << "No" << endl;
}

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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;	
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

const ll INF = 1LL << 61;

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

const ll mod = 1000000007;

vector<t4> qs;
vector<ll> ids;
ll n, m, q;

ll dfs(int index) {
	if (index == n) {
		ll sum = 0;
		rep(i, q) {
			ll a, b, c, d;
			tie(a, b, c, d) = qs[i];
			if (ids[b] - ids[a] == c) {
				sum += d;
			}
		}
		return sum;
	}
	ll upper = 0;
	for (int i = ids[index - 1]; i <= m; i++) {
		ids[index] = i;
		upper = max(upper, dfs(index + 1));
	}
	return upper;
}

int main() {
	cin >> n >> m >> q;
	ids.resize(n);
	rep(i, q) {
		ll a, b, c, d;
		cin >> a >> b >> c >> d;
		a--; b--;
		qs.emplace_back(a, b, c, d);
	}
	ids[0] = 1;
	auto u = dfs(1);
	cout << u << endl;
	return 0;
}

Measured memory_bytes: 3600
def main():
    mod = 10**9+7
    inv_n = [0]*1001
    nCr = [[1]*(i+1) for i in range(1001)]
    for i in range(1001):
        inv_n[i] = pow(i, mod-2, mod)
    for i in range(2, 1001):
        for j in range(1, i):
            nCr[i][j] = (nCr[i-1][j-1]+nCr[i-1][j]) % mod
    n, a, b, c, d = map(int, input().split())
    dp = [0]*(n+1)
    dp[0] = 1

    for A in range(b, a-1, -1):
        dp2 = [i for i in dp]
        for N in range(n-c*A, -1, -1):
            e = dp[N]
            if e:
                temp = 1
                for C in range(1, c):
                    temp = temp*nCr[n-N-(C-1)*A][A]*inv_n[C] % mod
                for C in range(c, min(d, (n-N)//A)+1):
                    temp = temp*nCr[n-N-(C-1)*A][A]*inv_n[C] % mod
                    dp2[N+C*A] = (dp2[N+C*A]+temp*e) % mod
        dp = dp2
    print(dp[-1])


main()

Measured memory_bytes: 66140
def main():
    n = int(input())
    l_list = list(map(int, input().split()))

    sum_l = sum(l_list)
    max_l = max(l_list)

    if max_l < sum_l - max_l:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()


Measured memory_bytes: 61924
# import sys
# input = sys.stdin.readline

N, *a = [int(x) for x in open(0)]
a.insert(0, None)

first = 1
pres = first
count = 0
nex =  a[pres] # press the button
count += 1
for i in range(N-1): # operations are at most N-1 times.
    if nex == 2: break
    prev = pres
    pres = nex
    nex = a[pres] # press the button
    count += 1
    if nex == prev or nex == pres: break

if nex == 2: print(count)
else: print(-1)

Measured memory_bytes: 7844
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from heapq import heapify, heappop, heappush
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

S = input()

if S[0] == S[1] == S[2]:
    print("No")
else:
    print("Yes")


Measured memory_bytes: 4148