akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
const int N=300,inf=0x3f3f3f3f;
int a[N+10][N+10];
int main(){
	int n; scanf("%d",&n);
	for(int i=1;i<=n;++i) for(int j=1;j<=n;++j) scanf("%d",&a[i][j]);
	bool ffind=1;
	for(int k=1;k<=n;++k) for(int i=1;i<=n;++i) for(int j=1;j<=n;++j)
		if(a[i][k]+a[k][j]<a[i][j]) ffind=0;
	if(!ffind){
		printf("-1"); return 0;
	}
	for(int k=1;k<=n;++k) for(int i=1;i<=n;++i) for(int j=1;j<=n;++j)
		if(i!=j&&j!=k&&i!=k&&a[i][j]==a[i][k]+a[k][j]) a[i][j]=inf;
	long long ans=0;
	for(int i=1;i<=n;++i) for(int j=1;j<=n;++j) if(a[i][j]!=inf) ans+=a[i][j];
	printf("%lld",ans/2); return 0;
}

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

int main(){
	int N,M,C;
	cin>>N>>M>>C;
	vector<int>B(M);
	rep(i,M){
		cin>>B.at(i);
	}
	vector<vector<int>>A(N,vector<int>(M,0));
	int ans=0;
	rep(i,N){
		int solves=0;
		rep(j,M){
			cin>>A.at(i).at(j);
			//cout<<A.at(i).at(j);
			solves+=A.at(i).at(j)*B.at(j);
		}
		if(solves+C>0){
			ans++;
		}
		//cout<<endl;
	}
	cout<<ans<<endl;
return 0;}

/*compile
g++ code.cpp
./a.out
run*/

Measured memory_bytes: 256
# coding: utf-8
# Your code here!
k = int(input())
l = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(l[k-1])

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ios ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define endl '\n'
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
bool sortbysec(const pair<int,int>&a,const pair<int,int>&b)
{
    return (a.second<b.second);
}
int main()
{
    ios;
    int x,n;
    cin>>x>>n;
    if(n==0)
    {
        cout<<x<<endl;
        return 0;
    }
    set<int>s;
    int a[n],b[n]={0},c[n]={0};
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        s.insert(a[i]);
        b[i]=abs(x-a[i]);
        c[b[i]]++;
    }

    sort(b,b+n);
    int k=0;
    for(int i=0;i<n;i++)
    {
        if(c[b[i]]==1&&b[i])
        {
            k=b[i];
            break;
        }
    }
    if(c[0]==0)
       cout<<x<<endl;
    else
    {
        for(int i=1;i<=x;i++)
        {
            if(s.find(x-i)==s.end())
            {
                 cout<<x-i<<endl;
                 break;
            }

                else if(s.find(x+i)==s.end())
               {
                   cout<<x+i<<endl;
                   break;
               }


        }
    }
}




























Measured memory_bytes: 3668
import java.io.*;
import java.util.*;

public class Main {
	public static void main(String[] args) {
		MyScanner sc = new MyScanner();
		out = new PrintWriter(new BufferedOutputStream(System.out));
		int K_MAX = 200001;
		int[] array = new int[K_MAX];
		Arrays.fill(array, K_MAX);
		
		int n = sc.nextInt(), k = sc.nextInt();
		int kinds = 0;
		for (int i = 0; i < n; i++) {
			int a = sc.nextInt();
			if (array[a] == K_MAX) {
				array[a] = 1;
				kinds++;
			}else {
				array[a]++;
			}
		}
		int sub = kinds - k;
		int ans = 0;
		if (sub>0) {
			Arrays.sort(array);
			for (int i = 0; i < sub; i++) {
				ans += array[i];
			}
		}
		out.println(ans);
		out.close();
	}

	//-----------http://codeforces.com/blog/entry/7018---------------------------------
	public static PrintWriter out;

	public static class MyScanner {
		BufferedReader br;
		StringTokenizer st;

		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}

	}
	//--------------------------------------------------------

}



Measured memory_bytes: 46816
#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
#include <iterator>
#include <set>
#include <cmath>
#include <queue>
#include <vector>
#include <algorithm>
using namespace std;

typedef long long LL;
const int maxn = 2020000;
const LL INF = 100000000000000LL;
const LL mod = 1e9 + 9;
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define For(i,a,b) for(int i=a;i<=b;++i)
int a[maxn];
int main()
{
    int n;
    LL ans = 0;
    LL temp = 0;
    cin >> n;
    for(int i = 1; i <= n; i++) scanf("%d", &a[i]);
    for(int l = 1, r = 0; l <= n; l++)
    {
        ans += (LL)(r - l + 1);
        for(int j = r + 1; j <= n; j++)
        {
            if((temp^a[j]) == temp + a[j])
            {
                temp ^= a[j];
                ans++;
                r++;
            }
            else break;
        }
        temp ^= a[l];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
N = int(input())
# 0スタート0エンドなので付け加えておく
a_li = [0] + list(map(int, input().split())) + [0]
total = 0
for i in range(1, len(a_li)):
    total += abs(a_li[i] - a_li[i - 1])
for i in range(1, len(a_li) - 1):
    # a[i-1], a[i], a[i+1]のうちa[i]が消えたら…
    print(total - abs(a_li[i] - a_li[i - 1]) - abs(a_li[i + 1] - a_li[i]) + abs(a_li[i + 1] - a_li[i - 1]))


Measured memory_bytes: 86568
import collections

n = int(input())
li = list(map(int,input().split()))
x = li[::2]
y = li[1::2]
c = collections.Counter(li)
c0 = collections.Counter(x)
c1 = collections.Counter(y)

if c.most_common()[0][1] == len(li): #1種類だけのリストだったら
    print(n//2)

elif c0.most_common()[0][0] != c1.most_common()[0][0]: #c0に最多ものとc1に最多のものが違うなら
    print(n - c0.most_common()[0][1] - c1.most_common()[0][1])

else:
    if len(c0.keys())==1: #c0が一種類だったら
        print(n//2 - c1.most_common()[1][1]) #c1は2番目に多いものに帰る
    elif len(c1.keys())==1: #c1が一種類だったら
        print(n//2 - c0.most_common()[1][1]) #c0は2番目に多いものに帰る
    elif c0.most_common()[0][1] + c1.most_common()[1][1] < c0.most_common()[1][1] + c1.most_common()[0][1]:
        print(n - c0.most_common()[1][1] - c1.most_common()[0][1])
    else:
        print(n - c0.most_common()[0][1] - c1.most_common()[1][1])

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

int main(){
  ll A,B,C,X,Y;
  cin >> A >> B >> C >> X >> Y;
  
  ll total_num = X + Y;
  ll total_yen = 0;
  C = C*2;
  if(A+B < C){
    total_yen += (A+B)*min(X,Y);
  }else{
    total_yen += C*min(X,Y);
  }
  
  total_num -= min(X,Y)*2;
  if(X > Y){
    if(A < C){
      total_yen += A*total_num;
    }else{
      total_yen += C*total_num;
    }
  }else{
    if(B < C){
      total_yen += B*total_num;
    }else{
      total_yen += C*total_num;
    }
  }
  
  cout << total_yen << endl;
  
}

Measured memory_bytes: 256
/**
 *   @FileName	b.cpp
 *   @Author	kanpurin
 *   @Created	2020.06.21 21:02:04
**/

#include "bits/stdc++.h" 
using namespace std; 
typedef long long ll;

int main() {
    int n,k;cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    ll sum = 0;
    for (int i = 0; i < k; i++) {
        sum += a[i];
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3628
#include<iostream>
using namespace std;
static const int N = 100;

int main()
{
	int A[N], n, time, flag;
	cin >> n;
	
	for (int i = 0; i < n; i++)
		cin >> A[i];

	time = 0;
	flag = 1;
	while (flag)
	{
		flag = 0;
		for (int j = n - 1; j > 0; j--)
		{
			if (A[j] < A[j - 1])
			{
				int temp;
				temp = A[j];
				A[j] = A[j - 1];
				A[j - 1] = temp;
				flag = 1;

				time++;
			}
		}
	}
	for (int i = 0; i < n - 1; i++)
		cout << A[i] << " ";
	cout << A[n - 1] << endl;
	cout << time <<endl;

	return 0;
}


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

	public class Main {

		public static void main(String[] args) {

			Scanner sc = new Scanner(System.in);
			
			int h = sc.nextInt();
			int w = sc.nextInt();
			String[] A = new String[h]; 
			char[][] a = new char[h][w];
			List<Integer> tate = new ArrayList<Integer>();
			List<Integer> yoko = new ArrayList<Integer>();
			
			for(int i=0;i<h;i++) {
				A[i] = sc.next();
			}
			
			for(int i=0;i<h;i++) {
				for(int j=0;j<w;j++) {
					a[i][j]=A[i].charAt(j);
				}
			}
			
			boolean flg;
			
			for(int i=0;i<h;i++) {
				flg = true;
				for(int j=0;j<w;j++) {
					if(a[i][j]=='#') {
						flg = false;
						break;
					}
				}
				if(flg) {
					tate.add(i);
				}
				
			}
			
			for(int j=0;j<w;j++) {
				flg = true;
				for(int i=0;i<h;i++) {
					if(a[i][j]=='#') {
						flg = false;
						break;
					}
				}
				if(flg) {
					yoko.add(j);
				}
				
			}
			
			for(int i=0;i<h;i++) {
				if(tate.contains(i)) {
					continue;
				}
				for(int j=0;j<w;j++) {
					if(yoko.contains(j)) {
						continue;
					}
					System.out.print(a[i][j]);
				}
				System.out.println("");
			}
			
		}
	}

Measured memory_bytes: 25692
import java.io.*;
import java.util.*;
import java.math.*;
public class Main{
        public static void main(String[] arg) throws IOException {
                BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
                String is; 
                String[] ia; 

                while((is = in.readLine()) != null){
                        int n = Integer.parseInt(is);
                        ia = in.readLine().split(" ");
                        ArrayList<Integer> al = new ArrayList<Integer>();
                        for(int i = 0;i < n; ++i){
                                al.add(Integer.parseInt(ia[i]));
                        }   
                        Collections.sort(al);
                        int p = 0;
                        int t = 0;
                        for(int i = 0;i < n; ++i){
                                p += al.get(i);
                                t += p;
                        }   
                        System.out.println(t);
                }   
        }   
}

Measured memory_bytes: 11000
using System;
using System.Linq;

namespace ABC142C
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var As = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();

            Console.WriteLine(string.Join(" ", As.Select((x, i) => new { X = x, I = i+1 }).OrderBy(x => x.X).Select(x => x.I.ToString())));
        }
    }
}


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

int main() {
  ll n; cin>>n;
  ll k; cin>>k;
  vector<ll> a(n);
  rep(i, n) cin>>a.at(i);
  sort(a.begin(), a.end());
  
  if(n<=k) cout << 0;
  
  else {
    ll s=0;
    for(int i=0; i<n-k; i++) {
      s+=a.at(i);
    }
    cout << s << endl;
  }
}

Measured memory_bytes: 1792
// practice with Dukkha
#include <algorithm>
#include <iostream>

using namespace std;

long long count(long long n) {
	return n < 5 ? 0 : count(n / 5) + n / 5;
}

int main() {
	long long n; cin >> n;
	cout << (n % 2 == 0 ? count(n / 2) : 0) << '\n';
	return 0;
}


Measured memory_bytes: 3600
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
    int n, k, i, j, h, res;
    int[] m, l;
    int[][] p;

    for(;;){
      n = sc.nextInt(); if(n == 0)break;
      m = new int[n];
      p = new int[n][n];
      for(i = 0;i < n;i++){
        m[i] = sc.nextInt();
        for(j = 0;j < m[i];j++)p[i][j] = sc.nextInt();
      }
      k = sc.nextInt();
      l = new int[k];
      for(i = 0;i < k;i++)l[i] = sc.nextInt();
      res = -1;
      for(i = 0;i < n;i++){
        if(m[i] < k)continue;
        for(j = 0;j < k;j++){
          for(h = 0;h < m[i];h++)if(p[i][h] == l[j])break;
          if(h == m[i])break;
        }
        if(j == k && res > -1){
          res = -1; break;
        }else if(j == k)res = i + 1;
      }
      out.println(res);
    }


    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}

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

typedef long long ll;

const int MAX_N = 100010;
int par[MAX_N];
int rnk[MAX_N];

void init(int n) {
    rep(i,n) {
        par[i] = i;
        rnk[i] = 0;
    }
}

int find(int x) {
    if (par[x] == x) {
        return x;
    } else {
        return par[x] = find(par[x]);
    }
}

void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return;
    if (rnk[x] < rnk[y]) {
        par[x] = y;
    } else {
        par[y] = x;
        if (rnk[x] == rnk[y]) rnk[x]++;
    }
}

bool same(int x, int y) {
    return find(x) == find(y);
}

void solve() {
    int N, M;
    cin >> N >> M;
    init(N);
    vector<int> p(N);
    rep(i, N) cin >> p[i];
    int x, y;
    rep(i, M) {
        cin >> x >> y;
        unite(x - 1, y - 1);
    }
    int ans = 0;
    rep(i, N) if (same(i, p[i] - 1)) ans++;
    cout << ans << endl;
    return;
}

int main() {
    solve();
}


Measured memory_bytes: 1408
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

string toStr(int a)
{
    ostringstream oss;
    oss << setfill('0') << setw(4) << a;
    return oss.str();
}

int main()
{
    for(;;){
        int n;
        cin >> n;
        if(n == 0)
            return 0;

        int ret = 0;
        while(n != 0 && n != 6174){
            string s = toStr(n);
            string t = s;
            sort(s.rbegin(), s.rend());
            sort(t.begin(), t.end());

            n = atoi(s.c_str()) - atoi(t.c_str());
            ++ ret;
        }

        if(n == 0)
            cout << "NA" << endl;
        else
            cout << ret << endl;
    }
}

Measured memory_bytes: 1256
#include<stdio.h>
int main(void)
{
	int n,a,i,d,x[101][3]={0},g=0;
	scanf("%d%d",&n,&d);
	for(i=0;i<d;i++){
		scanf("%d",&a);
		x[a][0]=1;
	}
	scanf("%d",&d);
	for(i=0;i<d;i++){
		scanf("%d",&a);
		x[a][1]=1;
	}
	scanf("%d",&d);
	for(i=0;i<d;i++){
		scanf("%d",&a);
		x[a][2]=1;
	}
	for(i=1;i<=100;i++){
		if(x[i][0]==0&&x[i][2]==1||x[i][1]==1&&x[i][2]==1){
			g++;
		}
	}
	printf("%d\n",g);
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long
using namespace std;
 
int main() {
  ll a,b,c,d,e;
  cin>>a>>b>>c>>d>>e;
  ll pasta=min(a,min(b,c));
  ll drink=min(d,e);
  cout<<pasta+drink-50<<endl;
}



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

class Dice {
    public:
    int a,b,c,d,e,f;
    string direct;
    int dice[6];
    
    
    Dice(int aa,int bb,int cc,int dd,int ee,int ff) {
        
        dice[0] = aa;
        dice[1] = bb;
        dice[2] = cc;
        dice[3] = dd;
        dice[4] = ee;
        dice[5] = ff;
        
    }
    
    void move_n() {
        
        a = dice[1];
        b = dice[5];
        //c = dice[1];
        //d = dice[1];
        e = dice[0];
        f = dice[4];
        
        dice[0] = a;
        dice[1] = b;
        //dice[2] = c;
        //dice[3] = d;
        dice[4] = e;
        dice[5] = f;
        
    }
    
    void move_e() {
        
        a = dice[3];
        //b = dice[5];
        c = dice[0];
        d = dice[5];
        //e = dice[0];
        f = dice[2];
        
        dice[0] = a;
        //dice[1] = b;
        dice[2] = c;
        dice[3] = d;
        //dice[4] = e;
        dice[5] = f;
        
    }
    
    void move_w() {
        
        a = dice[2];
        //b = dice[5];
        c = dice[5];
        d = dice[0];
        //e = dice[0];
        f = dice[3];
        
        dice[0] = a;
        //dice[1] = b;
        dice[2] = c;
        dice[3] = d;
        //dice[4] = e;
        dice[5] = f;
        
    }
    
    void move_s() {
        
        a = dice[4];
        b = dice[0];
        //c = dice[1];
        //d = dice[1];
        e = dice[5];
        f = dice[1];
        
        dice[0] = a;
        dice[1] = b;
        //dice[2] = c;
        //dice[3] = d;
        dice[4] = e;
        dice[5] = f;
        
    }
    
    int ans() {
        
        int ans = dice[0];
        
        return ans;
        
    }
    
    
};

int main() {
    
    int a,b,c,d,e,f;
    char direct[100];
    
    cin >> a >> b >> c >> d >> e >> f;
    
    Dice d1(a,b,c,d,e,f);
    
    cin >> direct;
    
    for (int i = 0; i < strlen(direct); i ++) {
        
        if (direct[i] == 'N') {
            
            d1.move_n();
            
        } else if (direct[i] == 'E') {
            
            d1.move_e();
            
        } else if (direct[i] == 'W') {
            
            d1.move_w();
            
        } else {
            
            d1.move_s();
            
        }
        
    }
    
    cout << d1.ans() << endl;
    
    return 0;
    
};


Measured memory_bytes: 3096
N=int(input())
list = []
for i in range(N):
  a, b = input().split()
  list1 = [a, b]
  list.append(list1)
 
sum = 0.0
bin = 0.00000000
for i in range(len(list)):
  if list[i][1] == "JPY":
    sum += float(list[i][0])
  else:
    bin += float(list[i][0])
all = sum + (bin * 380000.0)
print(all)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
      
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); i++)
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())

#define pb emplace_back
#define fi first
#define se second

using namespace std;

using ld = long double;
using ll = long long int;

const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ll MOD = 1e9+7;
     
template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> void UNIQUE(vector<T> &a){ a.erase(unique(a.begin(), a.end()), a.end()); }

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

ll in(){long long int x; assert(scanf("%lld", &x) == 1); return x;}
ld fin(){double x; assert(scanf("%lf", &x) == 1); return x;}
char yuyushiki[1000010]; string stin(){assert(scanf("%s", yuyushiki) == 1); return yuyushiki;}

// head

struct Mod{
  unsigned n;
  Mod() : n(0){}
  Mod( ll x ){
    if( x < 0 ) n = x%MOD+MOD;
    else n = x%MOD;
  }
};
Mod operator + ( Mod a  , Mod b ){ return Mod( a.n + b.n ); }
Mod operator +=( Mod &a , Mod b ){ return a = a + b; }
Mod operator - ( Mod a ){ return Mod( MOD - a.n ); }
Mod operator - ( Mod a  , Mod b ){ return Mod( a.n + MOD - b.n ); }
Mod operator -=( Mod &a , Mod b ){ return a = a - b; }
Mod operator * ( Mod a  , Mod b ){ return Mod( (ll)a.n * b.n ); }
Mod operator *=( Mod &a , Mod b ){ return a = a * b; }
Mod modpow( Mod x , ll k ){
  Mod res = 1;
  while( k ){
    if( k & 1 ) res *= x;
    k /= 2;
    x *= x;
  }
  return res;
}
ll extgcd( ll a , ll b , ll &x , ll &y ){
  ll d = a;
  if( b != 0 ){
    d = extgcd( b , a % b , y , x );
    y -= a / b * x;
  } else {
    x = 1, y = 0;
  }
  return d;
}
Mod inv( Mod a ){ ll x, y; assert( extgcd( a.n , MOD , x , y ) == 1 ); return Mod( x ); }
Mod operator / ( Mod a  , Mod b ){ return Mod( (ll)a.n * inv(b).n ); }
Mod operator /=( Mod &a , Mod b ){ return a = a / b; }

int main(){

  int n = in();
  int m = in();
  vector<string> s(n);
  REP(i, n){
    s[i] = stin();
  }
  vector<vector<Mod>> dp(n + 1, vector<Mod>(m + 1, 0));
  dp[0][0] = 1;
  REP(i, n){
    REP(j, m){
      if(s[i][j] == '#'){
        dp[i][j] = 0;
        continue;
      }
      dp[i+1][j] += dp[i][j];
      dp[i][j+1] += dp[i][j];
    }
  }

  cout << dp[n-1][m-1].n << endl;
  
  return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> vec(n);
  for(int i=0; i<n; i++) cin >> vec[i];
  bool flag = true;
  for(int i : vec) {
    if(i%2 == 0) {
      if(i%3 != 0 && i%5 != 0) flag = false;
    }
  }
  if(flag) cout << "APPROVED" << endl;
  else cout << "DENIED" << endl;
}

Measured memory_bytes: 256
//is there any case of -1 or any special corner cases ?
#include<bits/stdc++.h>
using namespace std;
#define int long long int 
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define vi vector<int>
#define pi pair<int,int>
#define all(v) v.begin(),v.end()
#define zeros(arr) memset(arr,0,sizeof(arr));
#define precise(num)  cout<<fixed; cout << std::setprecision(num)
#define nl cout<<"\n";
#define test int t;cin>>t;wahile(t--) 
const int maxx  = 3*1e5 , limit = 1e17 , MOD=1e9+7;
string binary(int n){bitset<32>b(n) ;string p =b.to_string();return p;}
int decimal(string s){int res = 0; for(int i = 0; i < s.size() ; i++ ){if(s[i] == '1')res = res + pow(2,s.size() - i -1);}    return res;}
bool isPrime(int n){if (n <= 1) return false; if (n <= 3) return true;if (n % 2 == 0 || n % 3 == 0) return false;
for (int i = 5; i * i <= n; i = i + 6) if (n % i == 0 || n % (i + 2) == 0) return false; return true; }
int pow (int x, int n,int mod) {if (n == 0) return 1; int res = pow (x, n / 2,mod);res = (res * res) % mod;if (n % 2) res = (res * x ) % mod;return res;}
#define boost  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int32_t main(){
    boost;
    string s;
    cin>>s;
    if(s[0] =='7'||s[1] =='7'||s[2] =='7'){
        cout<<"Yes\n";
    }else
    cout<<"No\n";
}

Measured memory_bytes: 3672
/*
    Author : zzugzx
    Lang : C++
    Blog : blog.csdn.net/qq_43756519
*/
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define endl '\n'
#define SZ(x) (int)x.size()
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int mod = 1e9+7;
//const int mod = 998244353;
const double eps = 1e-10;
const double pi = acos(-1.0);
const int maxn = 1e6+10;
const ll inf = 0x3f3f3f3f;
const int dir[][2]={{0, 1}, {1, 0}, {0, -1}, {-1, 0}, {1, 1}, {1, -1}, {-1, 1}, {-1, -1}};


int a[maxn];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
//  freopen("in.txt", "r", stdin);
//  freopen("out.txt", "w", stdout);
    ll n;
    cin >> n;
    ll ans = 0;
    for (ll i = 1; i <= n; i++)
        ans += i * (i + 1) / 2;
    for (ll i = 1; i < n; i++) {
        ll u, v;
        cin >> u >> v;
        if(u > v) swap(u, v);
        ans -= u * (n - v + 1);
    }
    cout << ans ;
    return 0;
}


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

const double PI = 3.14159265358979323846;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

//const ll mod = 1e10;
typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

#include <iostream>
#include <vector>

using namespace std;


int main() {
    ll n, m;;
    cin >> n >> m;
    vector<ll> popular(n);
    rep(i, n)cin >> popular[i];
    ll sum = accumulate(popular.begin(), popular.end(), 0ll);
    sort(popular.rbegin(), popular.rend());
    int ans = 0;
    for(ll p : popular) {
        if (sum > p * 4 * m) continue;
        ans++;
    }
    if(ans >= m) {
        cout << "Yes" <<endl;
    }else {
        cout << "No"<<endl;
    }
}


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

#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define ACC(c) (accumulate(ALL(c), 0LL))
#define PRINT(x) cout << (x) << "\n"

using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;

inline int std_in(int& a) {return scanf("%d", &a);}
auto pint_compare = [](pint x, pint y) -> bool{return (x.first < y.first);};
const int MOD = 1000000007;

signed main(){
    int a, b, c;
    cin >> a >> b >> c;
    cout << c << " " << a << " " << b << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string S,T;
  cin>>S>>T;
  int x=0;
  for(int i=0;i<S.size();i++)
  {
    if(S.at(i)==T.at(i))
    {
    }else
    {
      x=x+1;
    }
  }
  cout<<x<<endl;
}

Measured memory_bytes: 3916
def test():
    N, K = map(int, input().split())
    h = list(map(int, input().split()))
    dp = [float('inf')]*N
    dp[0] = 0
    
    for i in range(1,N):
        dp[i] = min(dp[j] + abs(h[i] - h[j]) for j in range(max(i-K, 0), i))
    
    print(dp[N-1])
    
if __name__ == '__main__':
    test()

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

using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define _dec(i,j,N) for(int i = (N-1);i >= (j);i--)
#define ALL(x) x.begin(),x.end()
#define PB push_back
#define LL long long

template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {
    _for(i,0,v.size()) os << v[i] << " ";
    return os;
}

template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){
    for(typename set<T>::iterator it = v.begin();it != v.end();it++)
    os << *it <<" ";
    return os;
}

struct P{
    string s;
    int p;
    int id;
    P(string s,int p,int id):s(s),p(p),id(id){;}
    bool operator<(const P& o){
        return s < o.s || (s == o.s && p > o.p);
    }

};

LL N;

vector<P> vp;
int main()
{
    cin >> N;
    _for(i,0,N){
        string s;
        int score;
        cin >> s >> score;
        vp.push_back(P(s,score,i+1));
    }

    sort(ALL(vp));
    _for(i,0,vp.size()){

        cout << vp[i].id << endl;
    }


    return 0;
}


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

int main(){
  string number;
  int c = 0 ;
  cin >> number;
  for(char n : number){
    c += (n - '0');
  }
  if(c % 9 == 0){
    cout << "Yes" << endl;
  }
  if(c % 9 != 0 ){
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 3724
#include <stdio.h>

void insertionsort(int* A, int n){
  int i, j;
  for(i = 1; i < n; i++){
    int k;
    for(k = 0; k < n; k++){
      printf("%d", A[k]);
      if(k == n-1) printf("\n");
      else printf(" ");
    }
    j = i-1;
    while(j >= 0){
      if(A[j] > A[j+1]){
        int tmp = A[j+1];
        A[j+1] = A[j];
        A[j] = tmp;
        j--;
      }else{
        break;
      }
    }
  }
}

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

  insertionsort(A, n);

  for(i = 0; i < n-1; i++) printf("%d ", A[i]);
  printf("%d\n", A[n-1]);
  return 0;
}

Measured memory_bytes: 604
#include<iostream>
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

typedef long long int ll;

ll N;
ll A[200005];
ll K;

bool flag[200005];
ll hs;
ll t=0;


void search(int n){
    if(flag[n]!=0){
        hs=n;
        return;
    }
    if(t==K){
        cout<<n+1<<endl;
        hs=-1;
        return;
    }
    flag[n]=true;
    t++;
    search(A[n]);
}

int main(){
    cin>>N>>K;
    for(int i=0;i<N;++i){
        cin>>A[i];
        A[i]--;
    }
    search(0);
    if(hs==-1)return 0;
    ll k=0;
    ll p=hs;
    while(true){
        p=A[p];
        k++;
        if(p==hs)break;
    }
    ll q=(K-(t-k))%k;
    ll ans=hs;
    for(int i=0;i<q;++i)ans=A[ans];
    cout<<ans+1<<endl;
}

Measured memory_bytes: 5340
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());

        // 主処理
        int result = 0;
        for (int i = 0; i < n - 1; i++) {
            for (int j = i + 1; j < n; j++) {
                result++;
            }
        }
        for (int i = 0; i < m - 1; i++) {
            for (int j = i + 1; j < m; j++) {
                result++;
            }
        }

        // 出力
        System.out.println(result);
        sc.close();
    }
}


Measured memory_bytes: 21844
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    set<string>st;
    rep(i,n){
        string s;
        cin >> s;
        st.insert(s);
    }
    cout << st.size() << endl;
}


Measured memory_bytes: 19124
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define cvector vector<char>
#define svector vector<string>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define rep(i,n) for(ll i=0; i<n; ++i)
#define print(a) cout << (a) << endl

ll n,a,b,c,d;
vector<P> operators(3);
map<ll,ll> mp;

ll dfs(ll x) {
  if(mp.find(x)!=mp.end()) return mp[x];
  ll ret=(4e18/d<x)?4e18:d*x;
  for(auto& op:operators) {
    ll div=op.first,cost=op.second;
    ret=min(ret,dfs(x/div)+cost+d*(x%div));
    if(x%div!=0) ret=min(ret,dfs(x/div+1)+cost+d*(div-x%div));
  }
  mp[x]=ret;
  return ret;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll t;cin>>t;
  rep(tt,t) {
    cin>>n>>a>>b>>c>>d;
    mp.clear();
    operators[0]=P(2,a);
    operators[1]=P(3,b);
    operators[2]=P(5,c);
    mp[0]=0,mp[1]=d;
    print(dfs(n));
  }
  return 0;
}

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

#define FASTIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using ll = long long;

const int MOD = 1e9+7;

int main() {
    FASTIO
    
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll x = a*c, y = a*d, z = b*c, w = b*d;
    cout << max(x,max(y,max(z,w))) << "\n";
    
    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int N; cin >> N;
    vector<int> a(N); for (int i = 0; i < N; i++) cin >> a[i];

    int ans = 0;
    for (int i = 0; i < N; i++) {
        while (a[i]%2 == 0) {
            ans++;
            a[i] /= 2;
        }
    }

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

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_set>
#include <bitset>
#include <time.h>
#include <limits.h>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define szz(x) (int)x.size()
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
typedef tuple<int, int, int> t3;

int N, p[5050], A, B;
ll dp[5050][5050];

void upd(ll &a, ll b) { if(a > b) a = b; }

int main() {
	scanf("%d%d%d", &N, &A, &B);
	for(int i=1;i<=N;i++) scanf("%d", p+i);
	rep(i, 5050) rep(j, 5050) dp[i][j] = 1e18;
	dp[0][0] = 0;
	for(int i=0;i<N;i++) for(int j=0;j<=N;j++) {
		int x = p[i+1];
		if(j < x) upd(dp[i+1][j], dp[i][j] + A);
		else upd(dp[i+1][j], dp[i][j] + B);
		if(j < x) {
			upd(dp[i+1][x], dp[i][j]);
		}
	}
	printf("%lld\n", *min_element(dp[N], dp[N] + N+1));
	return 0;
}

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

using namespace std;

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;
  vector<vector<int>> F(N, vector<int>(10));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 10; j++) {
      cin >> F[i][j];
    }
  }
  vector<vector<int>> P(N, vector<int>(11));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j <= 10; j++) {
      cin >> P[i][j];
    }
  }
  int ans = -1e9 - 10;
  for (int bits = 1; bits < (1 << 10); bits++) {
    int a = 0;
    for (int i = 0; i < N; i++) {
      int cnt = 0;
      for (int j = 0; j < 10; j++) {
        if (F[i][j] && (bits & (1 << j))) cnt++;
      }
      a += P[i][cnt];
    }
    chmax(ans, a);
  }
  cout << ans << endl;

  return 0;
}
/* vim:set fdm=marker: */


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define Would
#define you
#define please

vector<int> eda[200001];
int siwake[200001] = {};
vector<int> fukumu[200001];
int p[200001];

void sagasu(int A, int B) {
	if (!siwake[A]) {
		siwake[A] = B;
		fukumu[B].push_back(p[A]);
		for (auto itr : eda[A]) sagasu(itr, B);
	}
}

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

	cin >> N >> M;
	rep1(i, N) cin >> p[i];
	rep(i, M) {
		int x, y;
		cin >> x >> y;
		eda[x].push_back(y);
		eda[y].push_back(x);
	}

	rep1(i, N) sagasu(i, i);
	rep1(i, N) sort(fukumu[i].begin(), fukumu[i].end());
	
	int kotae = 0;
	rep1(i, N) {
		if (fukumu[siwake[i]].size()) {
			int L = 0;
			int R = fukumu[siwake[i]].size() - 1;
			while (L != R) {
				int half = (L + R) / 2;
				if (fukumu[siwake[i]][half] < i) L = half + 1;
				else R = half;
			}
			if (fukumu[siwake[i]][L] == i) kotae++;
		}
	}

	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 16636
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<queue>
#include<stack>
#include<list>
#include<unordered_map>
#include<unordered_set>
#include<cctype>
#include<iomanip>
#include<limits>
#include<bitset>

using namespace std;
typedef long long int ll; typedef pair<int, int> P; typedef unsigned long long int ull;
const ll mod = 1000000007;
const int inf = 1e9 + 7;
const ll linf = 1LL << 60;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define REP(i,m,n) for(int i=(m);i<(int)n;i++)
#define all(a) (a).begin(),(a).end()
#define allg(a) (a).begin(),(a).end(),greater<>()
#define SUM(a) accumulate((a).begin(),(a).end(),0)
#define d10 std::setprecision(10)
#define d20 std::setprecision(20)
#define vec vector<int>
#define vecb vector<bool>
#define vecd vector<double>
using str = string;
const double PI = 3.14159265359;
ll gcd(ll a, ll b) { ll t; while (b != 0) { t = a % b; a = b; b = t; }return a; }
int gcd(int a, int b) { int t; while (b != 0) { t = a % b; a = b; b = t; }return a; }
ll recfact(ll start, ll n) {
	ll i;
	if (n <= 16) {
		ll r = start;
		for (i = start + 1; i < start + n; i++) r = r * i % mod;
		return r % mod;
	}
	i = n / 2;
	return recfact(start, i) % mod * recfact(start + i, n - i) % mod;
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}
ll fct(ll n) { return recfact(1, n); }
ll ncm(ll n, ll m) {
	if (n < m)return 0;
	ll x = (fct(n) % mod / (fct(m) * fct(n - m)) % mod) % mod;
	return x;
}
std::string sreverse(string str, int firstItr, int secondItr) {
	if (firstItr < 0 || secondItr>int(str.size() - 1))return str;
	while (firstItr < secondItr) {
		swap(str[firstItr], str[secondItr]);
		firstItr++; secondItr--;
	}
	return str;
}
std::string RunLengthEncoding(std::string str) {
	int itr = 0; std::string res;
	while (itr < int(str.size())) {
		char tmp = str[itr++];
		int length = 1;
		while (itr <int(str.size()) && str[itr] == tmp) { ++itr; ++length; }
		res.push_back(tmp);
		res += to_string(length);
	}
	return res;
}
std::string split(std::string str, size_t first_itr, size_t second_itr) {
	std::string tmp;
	for (size_t i = first_itr; i < second_itr + 1; i++) {
		tmp.push_back(str.at(i));
	}
	return tmp;
}
ll max(ll a, ll b) {
	return a > b ? a : b;
}
ll min(ll a, ll b) {
	return a < b ? a : b;
}


int main() {
	double n, d; cin >> n >> d;
	d = 2 * d + 1;
	cout << ceil(n / d) << endl;	

	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>

int main(void)
{
  int a[100];
  int i, j, k, l, N, temp;
  int num = 0;

  scanf("%d", &N);

  for(i = 0; i < N; i++)
   scanf("%d", &a[i]);


  for(j = 0; j < N; j++) {
  for(i = N-1; i > j; i--) {
    if(a[i] < a[i-1]) {
      temp = a[i];
      a[i] = a[i-1];
      a[i-1] = temp;
      num++;
    }
  }
  }

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

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

Measured memory_bytes: 1804
#include<bits/stdc++.h>
#define ll long long int
const ll mod=1e9+7;
const int maxn=2e5+50;
using namespace std;
int main()
//int found; found=chaine.find(cara); if (found!=std::string::npos) how to verify if a caracter exists in a chaine
// toupper(caractere) ==> return the majuscule of a caractere
//floor(x) Returns the largest integer smaller than x
//ceil(x) returns  Returns the smallest integer greater
{
    int n,w;
    cin>>n>>w;
    int weight[n+1];
    ll value[n+1];
    for(int i=0;i<n;i++)
    {
    	cin>>weight[i+1]>>value[i+1];
	}
	ll mat[n+1][w+1];
	for(int av=0;av<=w;av++)
	{
		 if(av<weight[1])
		 {
		 	mat[1][av]=0;
		 }
		 else
		 {
		 	mat[1][av]=value[1];
		 }
	}
	
	for(int i=2;i<=n;i++) 
	{
	  for(int av=0;av<=w;av++)
      {
		  if(weight[i]>av)
		  {
		  	mat[i][av]=mat[i-1][av];
		  	
		  }
		  else
		  {
		  	mat[i][av]=max(mat[i-1][av-weight[i]]+value[i],mat[i-1][av]);
		  }
	  }   
    }
 
    cout<<mat[n][w];
}



Measured memory_bytes: 78336
#include <bits/stdc++.h> 
#define F(i,a,b) for(int i=a;i<=(b);++i)
#define dF(i,a,b) for(int i=a;i>=(b);--i)
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define pb push_back
#define maxnkp make_pair
#define fi first
#define se second
#define eps 1e-10
using namespace std;
typedef long long ll;
const int mods = 1e9+7;
const int maxn = 1e3+10;
const int N = 1e6+10;
const int E = 1e6+10;  
ll n,m,k;
ll a,b;
string s; 

int main(){
	cin>>s;
	if(s[2]==s[3]&&s[4]==s[5]){
		printf("Yes\n");
	}	
	else printf("No\n");
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int a[10]={111,222,333,444,555,666,777,888,999};
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<9;i++)	
		if(n<=a[i])
		{
			cout<<a[i];
			break;
		}
	return 0;	
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9+7,MAX = 1e9;

bool needcar(vector<int> w,int mid,int k)
{
	int res = 0;
	int sum =0;
	for(int i = 0;i <w.size();++i )
	{
		if(w[i]>mid)return false;
		if(sum+w[i]>mid)
		{
			res++;
			sum = w[i];
		}
		else
		{
			sum += w[i];
		}
	}
	//とらっくたりない
	if(res+1>k)return false;
	return true;
}

int main()
{
	int n,k;
	cin >> n>>k;
	vector<int> w(n);
	for(int i = 0;i<n;i++)
	{
		cin >> w[i];
	}
	int l = 0,r = MAX+1;
	while (1)
	{
		int mid = (l+r)/2;
		bool bin = needcar(w,mid,k);
		if(bin)
		{
			r = mid;
		}
		else
		{
			l = mid;
		}

		if(r-l==1)break;
	}
	cout<<r<<endl;
	return 0;
}


Measured memory_bytes: 3676
#include<stdio.h>
int main(){
    int H,W;
    for(;;){
        scanf("%d%d",&H,&W);
        if(H == 0 && W == 0){
            break;
        }
        
        for(int i = 0;i < H;i++){
            for(int j = 0;j < W;j++){
                if(i % 2 == 0 && j % 2 == 0){
                    printf("#");
                }
                else if(i % 2 == 0 && j % 2 == 1){
                    printf(".");
                }
                else if(i % 2 == 1 && j % 2 == 0){
                    printf(".");
                }
                else if(i % 2 == 1 && j % 2 == 1){
                    printf("#");
                }
            }
            printf("\n");
        }
        printf("\n");
        
    }
    return 0;
}


Measured memory_bytes: 2572
n, k = map(int, input().split())

MOD = 10**9 + 7

s = [0 for _ in range(n+2)]
v = 0
for i in range(n+2):
    v += i
    s[i] = v

ans = 0
for i in range(k, n+2):
    t = (s[n+1] - s[n+1-i]) - s[i] + 1
    ans += t
    ans %= MOD
print(ans)

Measured memory_bytes: 82468
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int a[1000050];
long long s=999999999;
int cnt;
int main()
{
    int n,m;
    cin>>n>>m;
    for(int i=0;i<n;i++)
        cin>>a[i];
    for(int i=0;i<n;i++)
    {
        if(a[i]<s)s=a[i];
    }
    for(int i=0;i<n;i++)
        if(a[i]==s)cnt++;
    int ans=(n-cnt+m-2)/(m-1);
    cout<<ans;
      
system("pause");
return 0;
}

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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll dpL[200005];
ll dpR[200005];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, K, C;
    cin >> N >> K >> C;
    string S;
    cin >> S;
    memset(dpL, 0, sizeof(dpL));
    memset(dpR, 0, sizeof(dpR));
    {
        ll max = 0;
        REP(i, N) {
            dpL[i] = max;
            if (S[i] == 'o') {
                ll m = 1;
                if (i - (C + 1) >= 0)
                    m += dpL[i - (C + 1)];
                dpL[i] = std::max(dpL[i], m);
            }
            max = std::max(max, dpL[i]);
        }
    }
    vector<ll> v;
    {
        ll max = 0;
        for (ll i = N - 1; i >= 0; --i) {
            ll left = i > 0 ? dpL[i - 1] : 0;
            ll right = dpR[i + 1];
            if (left + right < K)
                v.push_back(i + 1);

            dpR[i] = max;
            if (S[i] == 'o') {
                ll m = 1;
                if (i + C + 1 <= N)
                    m += dpR[i + C + 1];
                dpR[i] = std::max(dpR[i], m);
            }
            max = std::max(dpR[i], max);
        }
    }
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    REP(i, v.size()) {
        cout << v[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 6536
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
const int INF=1e9;
struct data{
    int to,cost;
    data(int a,int b):to(a),cost(b){}
    bool operator>(const data &d)const{
        return cost>d.cost;
    }
};
vector<vector<data> >edge;
vector<int>D;
void dijkstra(int s){
    priority_queue<data,vector<data>,greater<data> >Q;
    Q.push(data(s,0));
    while(Q.size()){
        data latte=Q.top();Q.pop();
        int At=latte.to,cost=latte.cost;
        if(D[At]<cost)continue;
        D[At]=cost;
        for(int i=0;i<edge[At].size();i++){
            data e=edge[At][i];
            if(D[e.to]<D[At]+e.cost)continue;
            Q.push(data(e.to,D[At]+e.cost));
        }
    }
    return;
}
int main(){
    int n,m,k;
    cin>>n>>m>>k;
    edge.resize(n);
    D.resize(n,INF);
    for(int i=0;i<m;i++){
        int a,b,c;
        cin>>a>>b>>c;
        a--;b--;
        edge[a].push_back(data(b,c));
        edge[b].push_back(data(a,c));
    }
    for(int i=0;i<k;i++){
        int s;
        cin>>s;
        s--;
        dijkstra(s);
    }
    int Max=0;

    for(int i=0;i<n;i++){
        for(int j=0;j<edge[i].size();j++){
            data e=edge[i][j];
            int latte=(D[i]+D[e.to]+e.cost+1)/2;
            Max=max(max(D[i],D[e.to]),max(Max,latte));

        }
    }
    cout<<Max<<endl;

}

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

using namespace std;
typedef long long ll;

const ll INF = 1e18;

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> p(n + 1), c(n + 1);
    for (int i = 1; i <= n; i++) cin >> p[i];
    for (int i = 1; i <= n; i++) cin >> c[i];
    ll res = *max_element(c.begin() + 1, c.end());
    for (int i = 1; i <= n; i++) {
        ll j = i, sum = 0, len = 0;
        do {
            sum += c[j], j = p[j], len++;
        } while (j != i);
        ll r = k >= 2 * len ? 2 * len + k % len : k;
        ll base = ((k - r) / len) * max(sum, 0ll), add = -INF;
        sum = 0;
        for (int t = 1; t <= r; t++) {
            sum += c[j], j = p[j];
            add = max(add, sum);
        }
        res = max(res, base + add);
    }
    cout << res << "\n";
}


Measured memory_bytes: 3672
#include <cmath>
#include<vector>
#define rep(i, n) for (int i=0;i<n;i++)
#include <map> 
#include<algorithm>
#include <numeric>
#include<iostream>
#include<deque>
#include<queue>
#include<string>
#include <iomanip>
using namespace std;
typedef long long ll;

int main(void){
    int n, m;
    cin>>n>>m;
    priority_queue<ll>a;
    rep(i, n){
        ll s;
        cin>>s;
        a.push(s);
    }
    rep(i, m){
        ll top=a.top();
        top=top/2;
        a.pop();
        a.push(top);
    }
    ll ans=0;
    rep(i, n){
        ans+=a.top();
        a.pop();
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1400
n,s=int(input()),input()
s+=s[:2]
# 羊:0 狼:1
for i in range(2):
    for j in range(2):
        a=[0]*(n+2)
        a[0]=i
        a[1]=j
        for k in range(1,n+1):
            if a[k]==0:
                if s[k]=="o":
                    a[k+1]=a[k-1]
                else:
                    a[k+1]=not a[k-1]
            else:
                if s[k]=="o":
                    a[k+1]=not a[k-1]
                else:
                    a[k+1]=a[k-1]
        if a[0]==a[n] and a[1]==a[n+1]:
            print(*["W" if k else "S" for k in a[:n]],sep="")
            exit()
print(-1)

Measured memory_bytes: 7632