akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
const int INF = 1e9;
const int MODk = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
const double EPS = 1e-10;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define COUTDOUBLE(v) cout << std::setprecision(10)<<(v)<<endl;
#define CIN(n)  int(n);cin >> (n)
#define LCIN(n) LL(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<LL,LL>
#define I vector<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())
#define ENDL cout<<endl

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    int from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};

std::vector<LL> dijkstra(int s,int N,vector<Edge> E){
    std::vector<LL> ans(N,LINF);
    std::vector<std::vector<Edge>> Edges(N);
    FOREACH(e,E){
        Edges.at(e.from).push_back(e);
    }
    priority_queue<P, std::vector<P>, greater<P>> que;
    ans.at(s)= 0;
    que.push(make_pair(0,s));
    while(!que.empty()){
        P p = que.top();que.pop();
        if(ans.at(p.second) < p.first)continue;
        for(int i = 0;i < Edges.at(p.second).size();i++){
                if(ans.at(p.second) + Edges.at(p.second).at(i).value < ans.at(Edges.at(p.second).at(i).to)){
                ans.at(Edges.at(p.second).at(i).to) = ans.at(p.second) + Edges.at(p.second).at(i).value;
                que.push(make_pair(ans.at(Edges.at(p.second).at(i).to),Edges.at(p.second).at(i).to));
            }
        }
    }
    return ans;
}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int N;cin >> N;
    vector<Edge> Edges;
    for(int a = 0;a < N-1;a++){
        int v,u,w;cin >> v >> u >> w;
        v--,u--;
        Edges.push_back(Edge(v,u,w));
        Edges.push_back(Edge(u,v,w));
    }
    vector<LL> ans = dijkstra(0, N, Edges);
    for(int a = 0;a < N;a++){
        cout<<ans.at(a)%2<<endl;
    }
}


Measured memory_bytes: 12528
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>

#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define bit(n,k) (((ll)n>>(ll)k)&1) /*nのk bit目*/
#define pb push_back
#define eb emplace_back
#define SZ(x) ((ll)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
//const ll MOD=998244353LL;
//const ll MOD=1777777777LL;
//const ll MAX_V=114514LL;
//const ll MAX = 500010LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
vl dx={0,0,1,-1};
vl dy={1,-1,0,0};

//素因数分解O(√n)
map<ll,ll>prime_factor(ll n){
  map<ll,ll>res;
  for(ll i=2;i*i<=n;i++){
    while(n%i==0){
      res[i]++;
      n/=i;
    }
  }
  if(n!=1)res[n]=1;
  return res;
}

const ll MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];
//finvが階乗の逆元

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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



int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  cout << fixed << setprecision(10);
  /*--------------------------------*/
  ll n,m,k;cin>>n>>m>>k;
  vl a(n),b(m);
  rep(i,n)cin>>a[i];
  rep(i,m)cin>>b[i];
  vl suma(n);
  vl sumb(m);
  suma[0]=a[0];
  sumb[0]=b[0];
  ll ans=0;
  rep(i,n-1)suma[i+1]=suma[i]+a[i+1];
  rep(i,m-1)sumb[i+1]=sumb[i]+b[i+1];
  rep(i,m){
    if(sumb[i]<=k)ans=max(ans,i+1);
  }
  rep(i,n){
    ll key=k-suma[i];
    ll l=0,r=m;
    if(key<0)continue;
    if(key<suma[0]){
      ans=max(ans,i+1);
      continue;
    }
    while(r-l>1){
      ll mid=(l+r)/2;
      if(key>=sumb[mid]){
        l=mid;
      }
      else r=mid;
    }
    //cout<<key<<" "<<l<<" "<<r<<endl;
    ans=max(i+1+l+1,ans);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 9540
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	const maxWord = (1 << 30)
	buf := []byte{}
	sc.Buffer(buf, maxWord)
	sc.Split(bufio.ScanWords)
}

func input() string {
	sc.Scan()
	return sc.Text()
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func solve(n, m, k int, a, b []int) int {
	sumA := make([]int, n+1)
	sumB := make([]int, m+1)
	for i := 1; i <= n; i++ {
		sumA[i] = sumA[i-1] + a[i]
	}
	for i := 1; i <= m; i++ {
		sumB[i] = sumB[i-1] + b[i]
	}

	ans := 0
	j := m
	for i := 0; i <= n; i++ {
		if sumA[i] > k {
			break
		}
		for sumB[j] > k-sumA[i] {
			j--
		}
		ans = max(ans, i+j)
	}
	return ans
}

func main() {
	n, _ := strconv.Atoi(input())
	m, _ := strconv.Atoi(input())
	k, _ := strconv.Atoi(input())
	a := make([]int, n+1)
	b := make([]int, m+1)
	for i := 1; i <= n; i++ {
		a[i], _ = strconv.Atoi(input())
	}
	for i := 1; i <= m; i++ {
		b[i], _ = strconv.Atoi(input())
	}
	fmt.Println(solve(n, m, k, a, b))
}


Measured memory_bytes: 11580
let inputs = readLine()!.split(separator: " ").map { Int($0)! }
let H = inputs[0] 
let W = inputs[1]
let K = inputs[2]
var grid: [[Character]] = .init(repeating: .init(repeating: Character("@"), count: W), count: H)

for row in 0..<H {
  grid[row] = Array(readLine()!)
}

var ans = 0
for h in 0..<1<<H {
  for w in 0..<1<<W {
    var black = 0
    for i in 0..<H {
      for j in 0..<W {
        if h & (1<<i) == 0 && w & (1 << j) == 0 && grid[i][j] == "#" {
          black += 1
        }
      }
    }
    ans += black == K ? 1 : 0
  }
}
print(ans)

Measured memory_bytes: 8328
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <ratio>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
//#define for(i,n) for(int i=0;i<n;i++)
#define ll long long
#define MAX 1e9
#define MIN -1e9
#define max(x,y) (x>y)?x:y
#define min(x,y) (x<y)?x:y
#define s(n) scanf("%d",&n)
#define mem memset(a, 0, sizeof(a))
#define minimum(a)	*min_element(a.begin(), a.end())
#define maximum(a)	*max_element(a.begin(), a.end())
typedef vector<int> vi;
typedef vector<string> vs;


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int l,r,d;
    cin>>l>>r>>d;
    int count=0;
    for(int i=l;i<=r;i++)
    {
      if(i%d==0)
      {
          count++;
      }


    }
    cout<<count<<endl;
   
return 0;
}


Measured memory_bytes: 3644
#include "bits/stdc++.h"

using namespace std;

const int value = INT_MAX;
int main()
{
    int n;
    cin >> n;
    vector<int> p(n);
    for( int &x : p){
     cin >> x;   
    }
    vector<int> dp(n,value);
    dp[0] = 0;
    for ( int i = 0; i < n-1; i++){
        for ( int j : {i +1 , i+2}){
            dp[j] =  min(dp[j],dp[i] + abs(p[i] - p[j]));
        }
    }
    cout << dp[n-1];
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<string> vs;

const int p = 31;
const int prime = 1e9 + 9;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    cout << fixed << setprecision(15);

    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans = 0;
    for (int i = 1; i < n; i++) {
        int t = 0;
        for (int j = 0; j + i < n; j++) {
            t = (t + 1) * (s[j] == s[j+i]);
            ans = max(ans, min(t, i));
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    int N; cin >> N;
    vector<int> H;
    rep (i, 0, N) {
        int h; cin >> h;
        H.push_back(h);
    }

    vector<int> dp(N+1, INF);
    dp[0] = 0;
    for (int now = 0; now < N; now++) {
        for (int next = now+1; next <= min(N, now+2); next++) {
            dp[next] = min(dp[next], abs(H[now] - H[next])+dp[now]);
        }
    }

    cout << dp[N-1] << endl;
}

Measured memory_bytes: 1272
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

void Main() {
	int n; cin >> n;
	vector<int > v(n);
	rep(i, n)cin >> v[i];
	sort(all(v)); reverse(all(v));
	int ans = 0;
	rep(i, n - 2) {
		repi(j, i + 1, n - 1) {
			repi(k, j + 1, n) {
				if (v[i] + v[j] > v[k] && v[j] + v[k] > v[i] && v[k] + v[i] > v[j]) {
					ans++;
					//cout << v[i] << v[j] << v[k] << endl;
					
				}
			}
		}
	}
	cout << ans;
	//rep(i, n)cout << v[i];
}


int main() {
	Main();

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef vector<ll> vec;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-6;
const ld pi = acos(-1.0);
typedef vector<vector<ll>> mat;
typedef vector<ll> vec;




void solve() {
	ll a, b; cin >> a >> b;
	ll ans = b;
	while (ans%a)ans += b;
	cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(4);
	//init();
	solve();
	stop
		return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORS(i,a,b) for(int i=a+1;i<=b;i++)
#define REP(i,N) FOR(i,0,N)
#define REPS(i,N) FORS(i,0,N)
#define debug(x) cout<<#x<<"="<<x<<endl
#define debugarr(arr,N,M){REP(i,N){REP(j,M){if(arr[i][j]==INF)printf(" INF");\
	else printf(" %3d",arr[i][j]);} cout<<endl;}}
#define pb push_back
#define pob pop_back
#define cint(a) int a;cin>>a
#define cint2(a,b) int a,b;cin>>a>>b
#define cint3(a,b,c) int a,b,c;cin>>a>>b>>c
typedef long long ll;
const int INF=100000000;
//--------------------------------------//
int main(){
	cint(n);
	int a[100];
	int ma=-101,mi=101;
	REP(i,n){
		cin>>a[i];
		ma=max(ma,a[i]);
		mi=min(mi,a[i]);
	}
	int ans=INF;
	FOR(i,mi,ma+1){
		int s=0;
		REP(j,n){
			s+=(a[j]-i)*(a[j]-i);
		}
		ans=min(ans,s);
	}
	cout<<ans<<endl;
	return 0;
}


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

int main() {
  int a,b,c,k;
  cin>>a>>b>>c>>k;
  while(a+1>b){
    b*=2;
    k--;
  }
  //cout<<a<<" "<<b<<" "<<c<<" ";
  while(b+1>c){
    c*=2;
    k--;
  }
  //cout<<a<<" "<<b<<" "<<c<<" ";
  //cout<<k<<endl;
  if(k<0)cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
  return 0;
}

Measured memory_bytes: 3572
//import java.io.File;
import java.util.Scanner;
import java.util.HashMap;
import java.util.Map;

public class Main{
  public static void main(String[] args) {
try{

    //Scanner scan = new Scanner(new File("in.txt"));
    Scanner scan = new Scanner(System.in);

    int input1 = scan.nextInt();

    while(input1 != 0) {
      HashMap<Integer,Panel> panel = new HashMap<>();
      panel.put(0,new Panel(0,0));

      for(int i = 1; i < input1; i++) {
        int input2 = scan.nextInt();
        int input3 = scan.nextInt();

        int dx=0,dy=0;
        switch(input3) {
          case 0:
            dx=-1;
            break;
          case 1:
            dy=1;
            break;
          case 2:
            dx=1;
            break;
          case 3:
            dy=-1;
            break;
        }
        panel.put(i,new Panel(panel.get(input2).x+dx,panel.get(input2).y+dy));
      }

      //ookisakeisan
      int maxX = 0, minX = 0, maxY = 0, minY = 0;
      for(Map.Entry<Integer,Panel> entry : panel.entrySet()) {
        int nowX = entry.getValue().x;
        int nowY = entry.getValue().y;
        if(nowX > maxX) maxX = nowX;
        if(nowX < minX) minX = nowX;
        if(nowY > maxY) maxY = nowY;
        if(nowY < minY) minY = nowY;
      }

      System.out.println((maxX-minX+1)+" "+(maxY-minY+1));

      input1 = scan.nextInt();
    }

}catch(Exception e) {
  e.printStackTrace();
}
  }
}

class Panel{
  int x,y;
  Panel(int _x, int _y) {
    x = _x;
    y = _y;
  }
}

Measured memory_bytes: 42924
#include <bits/stdc++.h>
#define endl "\n"
#define rep(i,n) for(int i=0;i<int(n);i++)
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
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 main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);

    int m,f,r;
    cin>>m>>f>>r;
    while(m!=-1 or f!=-1 or r!=-1){
        string score;
        int total=m+f;
        if(m==-1 or f==-1)score="F";
        else if(total>=80)score="A";
        else if(65<=total and total<80)score="B";
        else if(50<=total and total<65)score="C";
        else if(30<=total and total<50){
            if(50<=r)score="C";
            else score="D";
        }else score="F";
        cout<<score<<endl;
        cin>>m>>f>>r;
    }
    return 0;
}


Measured memory_bytes: 3116
import java.util.Scanner;

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

		int answer = 0;
		if (c >= a - b) {
			answer = c - a + b;
		}
		System.out.println(answer);

	}

}


Measured memory_bytes: 20948
#include<bits/stdc++.h> 
typedef long long ll;
using namespace std;
const ll mod =998244353; 
inline int read(){
	int x=0,f=1;char ch=getchar();
	while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int k,n,c;
int dp[200005][2],bf[200005],st,nxt[200005],en;
char ch[200005];
int bef(int x){
	int BF=x-c-1;
	if(BF<1) return 0;
	if(ch[BF]=='x') BF=bf[BF];
	if(BF<1) return 0;
	return dp[BF][0];
}
int nt(int x){
	int NT=x+c+1;
	if(NT>n) return 0;
	if(ch[NT]=='x') NT=nxt[NT];
	if(NT>n) return 0;
	return dp[NT][1];
}
int dpbf[200005],dpnxt[200005];
int main(){
	int i,j,now;
    //freopen("a.in","r",stdin);
    n=read(),k=read(),c=read();
    scanf("%s",ch+1);
    for(i=1;i<=n;i++) {bf[i]=st;if(ch[i]=='o') st=i;}
    en=n+1;
    for(i=n;i>=1;i--) {nxt[i]=en;if(ch[i]=='o') en=i;}
    for(i=1;i<=n;i++){
    	dp[i][0]=dp[i-1][0];
		if(ch[i]=='o') dp[i][0]=max(dp[i][0],bef(i)+1);
    }
    for(i=n;i>=1;i--){
    	dp[i][1]=dp[i+1][1];
		if(ch[i]=='o') dp[i][1]=max(dp[i][1],nt(i)+1);
    }
    st=0;
    for(i=1;i<=n;i++){
    	dpbf[i]=st;
    	if(dp[i][0]!=dp[i-1][0]) st=i;
    }
    en=n+1;
    for(i=n;i>=1;i--){
    	dpnxt[i]=en;
    	if(dp[i][1]!=dp[i+1][1]) en=i;
    }
    for(i=1;i<=n;i++){
    	if(ch[i]=='o')
			if(dp[dpbf[i]][0]+dp[min(n+1,max(i+1,dpbf[i]+c+1))][1]<k&&dp[dpnxt[i]][1]+dp[max(0,min(i-1,dpnxt[i]-c-1))][0]<k) printf("%d\n",i); 
    }
}

Measured memory_bytes: 6400
package main

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

func main() {
	N := nextInt()
	p := make([]int, N+1)

	for i := 1; i <= N; i++ {
		p[i] = nextInt()
	}

	c := 0

	for i := 1; i <= N; i++ {
		if p[i] != i {
			c++
		}
	}

	if c <= 2 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

var stdin = initStdin()

func initStdin() *bufio.Scanner {
	bufsize := 1 * 1024 * 1024 // 1 MB
	var stdin = bufio.NewScanner(os.Stdin)
	stdin.Buffer(make([]byte, bufsize), bufsize)
	stdin.Split(bufio.ScanWords)
	return stdin
}

func nextString() string {
	stdin.Scan()
	return stdin.Text()
}

func nextBytes() []byte {
	stdin.Scan()
	return stdin.Bytes()
}

func nextInt() int {
	i, _ := strconv.Atoi(nextString())
	return i
}

func nextInt64() int64 {
	i, _ := strconv.ParseInt(nextString(), 10, 64)

	return i
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 100100100100;
const ll MOD = 1000000007;
 
 
ll combination(ll n, ll r){
    if(n < r) return 0;
    if(r == 0||r == n) return 1;
    else if(r == 1) return n;
    return (combination(n - 1, r - 1) + combination(n - 1, r));
}
 
bool checkKaibun(string str){
    string checkStr = str;
    reverse(checkStr.begin(), checkStr.end());
    if(str == checkStr) return true;
    else return false;
}
 
int keta(ll num){
    int digits = 0;
    while(num > 0){
        num /= 10;
        digits++;
    }
    return digits;
}
 
 
ll mpow(ll x, ll n){//繰り返し二乗法 計算量O(logN)
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans * x % MOD;
        x = x * x % MOD;
        n  = n >> 1;
    }
    return ans;
}
 
 
int main(){
    int N;
    cin >> N;
    int a, b, c;
    a = N / 100;
    b = N % 100 / 10;
    c = N % 10;
    if(a == 7 || b == 7 || c == 7)cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <utility>
#include <climits>
#include <iomanip>
using namespace std;
#define MAXSIZE 100005
#define MAXL 100
#define MOD_CONST 1000000007
typedef long long int lli;

int sq(int x);

bool is_sq_num(int x);

int main(){
    size_t n, d;
    cin >> n >> d;
    vector<int> row(d, 0);
    vector<vector<int>> x(n, row);
    for(size_t i = 0; i < n; ++i){
        for(size_t j = 0; j < d; ++j){
            cin >> x[i][j];
        }
    }

    int ans = 0;
    for(size_t i = 0; i < n - 1; ++i){
        for(size_t j = i + 1; j < n; ++j){
            int sum_sq_len = 0;
            for(size_t k = 0; k < d; ++k){
                sum_sq_len += sq(x[i][k] - x[j][k]);
            }
            ans += is_sq_num(sum_sq_len);
        }
    }
    cout << ans << endl;
    return 0;
}

int sq(int x){
    return x * x;
}

bool is_sq_num(int x){
    for(int i = 0; i * i <= x; ++i){
        if(i * i == x){
            return true;
        }
    }
    return false;
}

Measured memory_bytes: 256
require 'prime'
p ={}
Prime.each(100000).each { |prime| p[prime] = true }
x = {}
(0..100000).each { |i| x[i] = (p[i]&&p[(i+1)/2] ? 1 : 0) }
(3..100000).each { |i| x[i] += x[i-1]}

gets.to_i.times do |_|
  l, r = gets.split.map(&:to_i)
  puts x[r]-x[l-1]
end


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

using namespace std;

struct node{
    int id, parent_id, depth;
    vector<int> children;
    node(){ parent_id=-1; depth=0; }
};

vector<node> tree;

void calc_depth(node &nd, int current_depth)
{
    nd.depth=current_depth;
    if(nd.children.size()){
        for(auto it=nd.children.begin(); it!=nd.children.end(); it++){
            calc_depth(tree[*it], current_depth+1);
        }
    }
}

int main()
{
    int n;
    scanf("%d", &n);
    tree=vector<node>(n);
    for(int i=0; i<n; i++){
        int id; scanf("%d", &id);
        auto it=&tree[id];
        it->id=id;
        int k; scanf("%d", &k);
        for(int j=0; j<k; j++){
            int c; scanf("%d", &c);
            it->children.push_back(c);
            tree[c].parent_id=it->id;
        }
    }

    for(auto it=tree.begin(); it!=tree.end(); it++){
        if(it->parent_id==-1){
            calc_depth(*it, 0);
            break;
        }
    }

    for(auto it=tree.begin(); it!=tree.end(); it++){
        printf("node %d: parent = %d, depth = %d, ", it->id, it->parent_id, it->depth);
        if(it->parent_id==-1){
            printf("root");
        } else if(it->children.size()==0){
            printf("leaf");
        } else{
            printf("internal node");
        }

        printf(", [");
        for(auto jt=it->children.begin(); jt!=it->children.end(); jt++){
            if(jt!=it->children.begin()){
                printf(", ");
            }
            printf("%d", *jt);
        }
        printf("]\n");
    }
    return 0;
}

Measured memory_bytes: 7084
<?php
$N = trim(fgets(STDIN));
$a = explode(" ", trim(fgets(STDIN)));

$p = 0;
$sum = 0;
for ($i = 0; $i <= $N - 1; $i++) {
    $sum += abs($a[$i] - $p);
    $p = $a[$i];
}

$sum += abs($a[$N - 1]);

for ($i = 0; $i <= $N - 1; $i++) {
    $l = $a[$i - 1] ?? 0;
    $h = $a[$i + 1] ?? 0;

    if (($l <= $a[$i] && $a[$i] <= $h) || ($h <= $a[$i] && $a[$i] <= $l)) {
        echo($sum . "\n");
    } else {
        echo($sum - min(abs($a[$i] - $l), abs($a[$i] - $h)) * 2 . "\n");
    }
}

Measured memory_bytes: 14068
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

def is_ok(arg):
    return a[i][j]+a[arg][j] >= 0

def meguru_bisect(ng, ok):
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if is_ok(mid):
            ok = mid
        else:
            ng = mid
    return ok

n = INT()
a = [[0]*19 for i in range(19)]
for i in range(n):
    A = int(float(input())*10**9+0.5)
    m2 = m5 = 0
    while A % 2 == 0:
        A //= 2
        m2 += 1
    while A % 5 == 0:
        A //= 5
        m5 += 1
    m2 = min(m2, 18)
    m5 = min(m5, 18)
    a[m2][m5] += 1

ans = 0
for i in range(19):
    for j in range(19):
        for k in range(19):
            for l in range(19):
                if i + k >= 18 and j + l >= 18:
                    if i == k and j == l:
                        ans += a[i][j] * ( a[k][l] - 1 )
                    else:
                        ans += a[i][j] * a[k][l]
ans //= 2
print(ans)

Measured memory_bytes: 10324
_a = gets.to_i
b_array = gets.strip.split.map(&:to_i)
c_array = gets.strip.split.map(&:to_i)

permutations = b_array.sort.permutation.to_a

b_index = nil
c_index = nil
permutations.each_with_index do |p, index|
  b_index = index + 1 if p == b_array
  c_index = index + 1 if p == c_array
end

puts (c_index - b_index).abs


Measured memory_bytes: 6780
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
int main()
{
    ll arr[3][3];
    ll n=3,i,j;
    for(i=0;i<n;i++) for(j=0;j<n;j++) cin>>arr[i][j];
    ll k;
    ll t;
    cin>>t;
    while(t--)
    {
        ll a;
        cin>>a;
        ll flag=0;
        for(i=0;i<n;i++) 
        {
            for(j=0;j<n;j++) 
            {
                if(arr[i][j]==a) 
                {
                    arr[i][j]=0;
                    flag=0;
                    break;
                }
            }
            if(flag) break;
        }
    }
    bool t1=false,t2=false,t3=false,t4=false;
    ll sum=0;
    for(i=0;i<n;i++)
    {
        sum=0;
        for(j=0;j<n;j++) sum+=arr[i][j];
        if(sum==0) 
        {
            t1=true;
            break;
        }
    }
    for(i=0;i<n;i++)
    {
        sum=0;
        for(j=0;j<n;j++) sum+=arr[j][i];
        if(sum==0) 
        {
            t2=true;
            break;
        }
    }
    sum=0;
    for(i=0;i<n;i++) sum+=arr[i][i];
    if(sum==0) t3=true;
    sum=0;
    for(i=0;i<n;i++) sum+=arr[i][(n-1)-i];
    if(sum==0) t4=true;
    if(t1 || t2 || t3 || t4) cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main( int argc, char *argv[] ) {
    int n;
    (void)scanf("%d", &n);

    for (long long a=-200; a<200; a++) {
        long double a5 = pow(a,5);
        for (long long b=-200; b<200; b++) {
            long double b5=pow(b,5);
            if (round(a5)-round(b5)==n) {
                printf("%Ld %Ld\n", a, b);
                return 0;
            }
            //printf("%Ld-%Ld=%d\n", a, b, (int)(a5-b5));
        }
    }
}


Measured memory_bytes: 2516
def main():
    n = int(input())
    m = 100 // 7 + 1
    flag = False
    for i in range(m):
        for j in range(m):
            if n == i * 7 + j * 4:
                flag = True
                if flag:
                    print('Yes')
                    break
        else:
            continue
        break
    if not flag:
        print('No')
if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <math.h>

int main() {

    char s[100001];
    scanf("%s", s);

    int l = strlen(s);
    for (int i = 0; i < l; i += 2) {
        printf("%c", s[i]);
    }

    return 0;

}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
using namespace std;
const int N=1010;
int n,m,k;
int main()
{
	while(~scanf("%d%d%d",&n,&m,&k)){
        bool flag=0;
        for(int i=0;i<=m;i++){
            for(int j=0;j<=n;j++)
                if(k==i*(n-j)+j*(m-i)){
                    flag=1;break;
                }
            if(flag) break;
        }
        if(flag) printf("Yes");
        else printf("No");
        printf("\n");




	}
	return 0;
}



Measured memory_bytes: 128
#include<stdio.h>

#define N 100000

int bserch(int a[], int b, int key){
  int i,left =0, right =b;

  while(left < right){
    i = (left+right)/2;
    if(a[i] == key){
      return 1;
    }
    else if(key < a[i]){
      right = i;
    }
    else{
      left = i +1;
    }
  }
  return 0;
}

int main(){
  int n, q, i, j, count = 0, discount = 0;
  int S[N],T[N];
  
   scanf("%d",&n);
  
  for(i=0; i<=n-1;i++){
    scanf("%d",&S[i]);
  }

  scanf("%d",&q);

  for(i=0;i<=q-1;i++){
    scanf("%d",&T[i]);
  }
  for(i=0;i<=q-1;i++){
    if(bserch(S,n,T[i]) == 1){
      count += 1;
    }
  }

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

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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
ll mod = 1000000007;

void solve(vector<ll> &ans, const vector<vector<ll>> &g,
           const vector<ll> &counter, ll index, ll value) {
    if (ans[index] != -1) {
        return;
    }
    ans[index] = value + counter[index];
    rep(i, g[index].size()) { solve(ans, g, counter, g[index][i], ans[index]); }
}

int main() {
source:
    ll n, q;
    cin >> n >> q;
    ll a[n - 1], b[n - 1];
    rep(i, n - 1) { cin >> a[i] >> b[i]; }
    ll p[q], x[q];
    rep(i, q) { cin >> p[i] >> x[i]; }

    vector<vector<ll>> g(n);
    rep(i, n - 1) {
        g[a[i] - 1].push_back(b[i] - 1);
        g[b[i] - 1].push_back(a[i] - 1);
    }
    vector<ll> counter(n, 0);
    rep(i, q) { counter[p[i] - 1] += x[i]; }
    vector<ll> ans(n, -1);
    solve(ans, g, counter, 0, 0);
    rep(i, n) { cout << ans[i] << " "; }
    cout << endl;
    return 0;
}



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

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long int n,m,k;
    cin>>n>>m>>k;
    long long int arr[n];
    long long int brr[m];
    long long int x;
    long long int count=0;
    for(long long int i=0;i<n;i++)
    {
        cin>>x;
        if(i==0)
        arr[i]=x;
        else
        {
            arr[i]=arr[i-1]+x;
        }
        if(arr[i]<=k)
        count = max(count,i+1);
    }
    for(long long int i=0;i<m;i++)
    {
        cin>>x;
        if(i==0)
        brr[i]=x;
        else
        {
            brr[i]=brr[i-1]+x;
        }
        if(brr[i]<=k)
        count=max(count,i+1);
    }
    for(long long int i=0;i<n;i++)
    {
        if(arr[i]<k)
        {
            long long int index = upper_bound(brr,brr+m,k-arr[i])-brr;
            count = max(count,i+1+index);
        }
    }
    cout<<count<<"\n";
}

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

int main(){
    string s;
    cin >> s;
    long long k;
    cin >> k;
    for(int i=0;i<min(k,(long long)s.size());i++){
        if(s[i]!='1'){
            cout << s[i] << endl;
            return 0;
        }
    }
    cout << '1' << endl;
    return 0;
}

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

using namespace std;

int main()
{
	int t;
	t=1;
	while(t--)
	{
	
	
	int n,x,T;
	
	cin>>n>>x>>T;
	
	
	if(n%x==0)
	cout<<(n/x)*T<<endl;
	
	
	else
	cout<<(   (n/x)+1)*T<<endl;
	
	
	
	}



}


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


using namespace std;


// Powered by caide (code generator, tester, and library code inliner)


class Solution {
public:
  void solve(std::istream& in, std::ostream& out)
  {
    int n;
    in >> n;
    vector<long long> a(n);
    for(auto&& i : a) {
      in >> i;
    }
    long long ans = 0;
    while (true) {
      sort(a.rbegin(), a.rend());
      if(a[0] < n) {
        break;
      }
      vector<long long> score(n);
      for (int i = 0; i < n; i++) {
        long long add = a[i] / n;
        a[i] %= n;
        score[i] += a[i];
        for (int j = 0; j < n; j++) {
          if(i == j) {
            continue;
          }
          score[j] += add;
        }
        ans += add;
      }
      a = score;
    }
    out << ans << "\n";
  }
};

void solve(std::istream& in, std::ostream& out)
{
  out << std::setprecision(12);
  Solution solution;
  solution.solve(in, out);
}


#include <fstream>
#include <iostream>


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


  istream& in = cin;


  ostream& out = cout;

  solve(in, out);
  return 0;
}




Measured memory_bytes: 256
n,x,y = map (int ,input().split())

x = x-1
y = y-1

dict = {int(i+1):0 for i in range(n)}

ans = 0
for i in range(n):
    for j in range(n):
        if i < j:
            ans = min(j-i,abs(x-i)+abs(j-y)+1)
            dict[ans] +=1
            
for i in range(n-1):
     print(dict[i+1])

Measured memory_bytes: 3572
n=int(input())
t=list(map(int,input().split()))
m=int(input())
p=[0]*m
x=[0]*m
ans=0
for j in range(m):
    p[j],x[j]=map(int,input().split())
for i in range(m):
    for k in range(n):
        if k+1==p[i]:
            ans+=x[i]
        else:
            ans+=t[k]
    print(ans)
    ans=0

Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
#include <stdio.h>
#define eps 1.0e-8

using namespace std;

double d;
int n, b;
int p[15], h[15];
double coe[3];

void Lagrange(double x1, double y1, double x2, double y2, double x3, double y3)
{
	double x[] = {x1, x2, x3}, y[] = {y1, y2, y3};
	
	double l[3][3];
	for(int i = 0; i < 3; i++){
		l[i][0] = 1;
		l[i][1] = 0;
		for(int j = 0; j < 3; j++) if(i != j) l[i][1] -= x[j];
		l[i][2] = 1;
		for(int j = 0; j < 3; j++) if(i != j) l[i][2] *= x[j];
		double bunbo = 1;
		for(int j = 0; j < 3; j++) if(i != j) bunbo *= (x[i] - x[j]);
		for(int j = 0; j < 3; j++) l[i][j] /= bunbo;
	}
	for(int i = 0; i < 3; i++){
		coe[i] = 0;
		for(int j = 0; j < 3; j++){
			coe[i] += y[j] * l[j][i];
		}
	}
}
	

int main(void)
{
	cin >> d >> n >> b;
	for(int i = 0; i < n; i++) cin >> p[i] >> h[i];
	
	double ans = 1.0e10;
	double l, r;
	
	for(int i = 0; i < n; i++){
		for(int j = 0; j <= b; j++){
			for(int k = 0; k <= j; k++){
				l = d / (j+1) * k;
				r = d / (j+1) * (k+1);
				if(p[i] <= l || p[i] >= r) continue;
				Lagrange(0, 0, r-l, 0, p[i]-l, h[i]);
				
				bool flag = true;
				for(int z = 0; z < n; z++){
					int no = p[z] / (r-l);
					double x = p[z] - no*(r-l);
					double y = coe[0]*x*x + coe[1]*x + coe[2];
					if(y < h[z] - eps){
						flag = false;
						break;
					}
				}
				if(flag){
					double th = atan(coe[1]);
					double v = sqrt( -0.5 / (coe[0]*cos(th)*cos(th)) );
					ans = min(ans, v);
				}
			}
		}
	}
	
	for(int j = 0; j <= b; j++){
		l = 0.0;
		r = d / (j+1);
		coe[0] = -1.0 / (r-l);
		coe[1] = 1.0;
		coe[2] = 0.0;
		
		bool flag = true;
		for(int z = 0; z < n; z++){
			int no = p[z] / (r-l);
			double x = p[z] - no*(r-l);
			double y = coe[0]*x*x + coe[1]*x + coe[2];
			if(y < h[z] - eps){
				flag = false;
				break;
			}
		}
		if(flag){
			double th = atan(coe[1]);
			double v = sqrt( -0.5 / (coe[0]*cos(th)*cos(th)) );
			ans = min(ans, v);
		}
	}
	
	printf("%.8f\n", ans);
	return 0;
}

Measured memory_bytes: 3640
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;

public class Main {
	
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			
			int N = scan.nextInt();
			String []S = new String[N];
			Set<String>set = new TreeSet<String>();
			for(int i = 0;i<N;i++) {
				S[i] = scan.next();
				set.add(S[i]);
			}
			
			System.out.println(set.size());
			
		}
		
		
	}
		

}


Measured memory_bytes: 78372
#include<iostream>
#include<string>
#include<algorithm>

int main() {
	int n,k;
	std::cin >> n;
	std::string str;
	std::cin >>k>>str;

	if (str[k - 1] == 'A') {
		str[k - 1] = 'a';
	}

	if (str[k - 1] == 'B') {
		str[k - 1] = 'b';
	}

	if (str[k - 1] == 'C') {
		str[k - 1] = 'c';
	}

	std::cout << str << std::endl;
	return 0;
}

Measured memory_bytes: 256
/// Bismillah Hir Rahmanir Rahim

/**
    Practice like Cristiano Ronaldo
        Play Like Leo Messi..
**/

#include <bits/stdc++.h>

using namespace std;

#define PI                    acos(-1.0)
#define Pi                    3.141592653589793
#define ff                    first
#define ss                    second
#define pb                    push_back
#define space                 " "
#define all(x)                (x).begin(), (x).end()
#define clr(ar)               memset(ar, 0, sizeof(ar))
#define eprintf(...)          fprintf(stderr, __VA_ARGS__)

/*
template <class T> T gcd(T a,T b){ if(b == 0) return a; return gcd( b,a % b ); }
template <class T> T lcm(T a, T b ){ return ( a * b ) / gcd( a,b ); }
template<class T> string ToString(const T &x){ stringstream s; s << x; return s.str(); }
template<class T> int ToInteger(const T &x){ stringstream s; s << x; int r; s >> r; return r; }
*/

typedef  long long int            ll;
typedef  map<string,int>          msi;
typedef  map<int,int>	          mii;
typedef  map<char,int>            mci;
typedef  map<int,string>	      mis;
typedef  pair<int,int> 	          ii;
typedef  pair<string, int>        psi;
typedef  vector<int> 	          vi;
typedef  vector<string> 	      vs;
typedef  vector< ii >             vii;

template<class T1> void deb(T1 e1)
{
    cout << e1 << endl;
}
template<class T1,class T2> void deb(T1 e1, T2 e2)
{
    cout << e1 << space << e2 << endl;
}
template<class T1,class T2,class T3> void deb(T1 e1, T2 e2, T3 e3)
{
    cout << e1 << space << e2 << space << e3 << endl;
}

#define sf                    scanf
#define pf                    printf

#define sf1(a)                scanf("%d", &a)
#define sf2(a,b)              scanf("%d %d",&a, &b)
#define sf3(a,b,c)            scanf("%d %d %d", &a, &b, &c)
#define sf4(a,b,c,d)          scanf("%d %d %d %d", &a, &b, &c, &d)

#define sf1ll(a)              scanf("%I64d", &a)
#define sf2ll(a,b)            scanf("%lld %lld", &a, &b)
#define sf3ll(a,b,c)          scanf("%I64d %I64d %I64d", &a, &b, &c)
#define sf4ll(a,b,c,d)        scanf("%I64d %I64d %I64d %I64d", &a, &b, &c, &d)

#define READ                  freopen("in.txt", "r", stdin);
#define WRITE                 freopen("out.txt", "w", stdout);
/// The End.

void check_time()
{
#ifdef the_badcoder
    eprintf("%.5lf\n", (double)clock() / CLOCKS_PER_SEC);
#endif
}

const int res = 1e4 + 50;
const int oo = 0x3f3f3f3f; /// only for "INT".
const ll mod = 1e9 + 7;

template<class T> int ToInteger(const T &x){ stringstream s; s << x; int r; s >> r; return r; }

int main()
{

    string x, y;
    cin >> x >> y;
    string z = x + y;

    ll sum = ToInteger( z );

    ll sq = sqrt( sum );

    if( sq * sq == sum ){
        deb("Yes");
    }
    else {
        deb("No");
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
int main()
{
   long long a,b,n,y;
   cin>>a>>b>>n;
   if(n<b)
   {
       y=(a*n)/b;
   }
   else
   {
       y=(a*(b-1))/b;
   }
   cout<<y<<endl;
    return 0;
}


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

int main() {
    string s,t;
    cin >> s >> t;
    int ans = 0;
    for(int i = 0; i < 3; i++){
        if(s.at(i) == t.at(i))ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
int n;
long long dp[105][300001];
int m;
int a[123456];
int b[123456];
bool used[105][300001];
 
int main() {
	cin >> n >> m;
	for(int i = 1; i <= n; i++) 
	cin >> a[i] >> b[i]; //swap(a[i], b[i]);

	used[0][0] = 1;

	for(int i = 1; i <= n; i++) {
		for(int j = m; j >= 0; j--) {
			if(!used[i -1][j]) continue;

			used[i][j] = 1;
			dp[i][j] = max(dp[i][j], dp[i - 1][j]);

			if(j + a[i] <= m) {
				used[i][j + a[i]] = 1;
				dp[i][j + a[i]] = max(dp[i][j + a[i]], dp[i - 1][j] + b[i]);
			}
		}
		if(i == n) {
			long long ans = 0;
			for(int j = 0; j <= m; j++) 
				ans = max(ans, dp[i][j]);
		   	cout << ans;
		}
	}
}


Measured memory_bytes: 266752
#include <stdio.h>
#include <stdlib.h>
 
int mas[4][4];
int cpy[4][4];
 
void input() {
  int i, j;
  for(i = 0; i < 4; i++)
    for(j = 0; j < 4; j++)
      scanf("%d", &mas[i][j]);
}
 
void output() {
  int i, j;
  for(i = 0; i < 4; i++) {
    for(j = 0; j < 4; j++) printf("%3d", mas[i][j]);
    puts("");
  }
}
 
void copy(int m[4][4], int t[4][4]) {
  int i, j;
 
  for(i = 0; i < 4; i++)
    for(j = 0; j < 4; j++) m[i][j] = t[i][j];
}
 
int calc() {
  int i, sum = 0;
  for(i = 0; i < 16; i++) {
    int v = mas[i/4][i%4];
    if(v) {
      v--;
      sum += abs(i/4-v/4)+abs(i%4-v%4);
    }
  }
  return sum;
}
 
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
 
void swap(int *a, int *b) {
  int tmp = *a;
  *a = *b;
  *b = tmp;
}
 
int is_in(int x, int y) {
  return 0<=x&&x<4&&0<=y&&y<4;
}
 
int dfs(int x, int y, int p, int dep, const int lim) {
  int i, h = calc();
  //output();
  if(h == 0) return dep;
  //printf("%d %d %d\n", h, lim, p);
  if(dep+h > lim) return -1;
 
  for(i = 0; i < 4; i++) {
    int nx = x+dx[i], ny = y+dy[i], res;
    if(~p && i == (p+2)%4) continue;
    if(!is_in(nx, ny)) continue;
    swap(&mas[y][x], &mas[ny][nx]);
    res = dfs(nx, ny, i, dep+1, lim);
    if(~res) return res;
    swap(&mas[y][x], &mas[ny][nx]);
  }
 
  return -1;
}
 
void get_empty(int *x, int *y) {
  int i, j;
  for(i = 0; i < 4; i++) {
    for(j = 0; j < 4; j++) {
      if(!mas[i][j]) {
    *x = j;
    *y = i;
    return;
      }
    }
  }
}
 
int solve() {
  int x, y, lim, ans;
  get_empty(&x, &y);
  for(lim = 0; lim < 50; lim++) {
    copy(cpy, mas);
    if((ans = dfs(x, y, -1, 0, lim)) != -1) return ans;
    copy(mas, cpy);
  }
  return -1;
}
 
int main() {
  input();
  printf("%d\n", solve());
  return 0;
}


Measured memory_bytes: 2108
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;

int main()
{
    int N,A=0,ans=0,count=1,size_count=0;
    cin>>N;
    vector<string>S(N);
    vector<int>a(N);
    for(int i=0;i<N;i++){
        cin>>S.at(i);
    }
    sort(S.begin(),S.end());
    for(int i=0;i<N-1;i++){
        if(S.at(i)==S.at(i+1)){
            count++;
        }else{
            if(ans==count){
                a.push_back(i);
                count=1;
            }else if(ans>count){
                count=1;
            }else{
                ans=count;
                a.clear();
                count=1;
                a.push_back(i);
            }
        }
        if(i==N-2){
             if(ans==count){
                a.push_back(i+1);
                count=1;
            }else if(ans>count){
                count=1;
            }else{
                ans=count;
                a.clear();
                count=1;
                a.push_back(i);
            }
        }
    }
    for(int i=0;i<a.size();i++){
        cout<<S.at(a.at(i))<<endl;
    }
}

Measured memory_bytes: 15104
#include <stdio.h>
#include <stdlib.h>
int main(void){
    int n;
    int p[8+3], q[8+3];
    scanf("%d", &n);
    for(int i=0; i<n; i++)scanf("%d", &p[i]);
    for(int i=0; i<n; i++)scanf("%d", &q[i]);
    
    int num_p=0, num_q=0;
    for(int i=0; i<n; i++){
        // p
        int temp=0;
        for(int j=i+1; j<n; j++){
            if(p[i]>p[j])temp++;
        }
        for(int j=1; j<n-i; j++)temp*=j;
        num_p+=temp;
        
        // q
        temp=0;
        for(int j=i+1; j<n; j++){
            if(q[i]>q[j])temp++;
        }
        for(int j=1; j<n-i; j++)temp*=j;
        num_q+=temp;
    }
    
    printf("%d\n", abs(num_p-num_q));
    
    return 0;
}


Measured memory_bytes: 1728
#include "bits/stdc++.h"

using namespace std;
typedef long long ll;

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

#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1LL << 60;
// ll dp[100010];

int main(){

  int n;cin>>n;
  int h[n+10];rep(i,0,n)cin>>h[i];

  vector<ll>dp(n,INF);
  dp[0]=0;
  // cout<<dp[0]<<",";
  rep(i,1,n){
    chmin(dp[i],dp[i-1]+abs(h[i]-h[i-1]));
    if(i>1)chmin(dp[i],dp[i-2]+abs(h[i]-h[i-2]));
    // cout<<dp[i]<<",";
  }
  // cout<<endl;

  out(dp[n-1]);


  return 0;
}


Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
typedef pair<string,int> P;
typedef pair<P,int> T;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
ll a,b,c,n,m,x,y;
string s;
vector<T> vec;
int main(){
	cin >> n;
	for(int i=0;i<n;i++){
		T a;
		cin >> a.fi.fi >> a.fi.sec;
		a.fi.sec *= -1;
		a.sec = i+1;
		vec.pb(a);
	}
	sort(all(vec));
	for(int i=0;i<n;i++){
		cout << vec[i].sec << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#define inf 1e9
using namespace std;
int solve(int arr[], int n)
{
    int dp[n+1];// minimum cost to reach the ith stone 
    dp[1] = 0 ;
    for(int i=2;i<=n;i++)
    {
        int option1= abs(arr[i] -arr[i-1]) + dp[i-1];
        int option2 = (i==2)? inf :abs(arr[i] - arr[i-2]) + dp[i-2];
        dp[i] = min(option2,option1);
        
    }
    
    
    return dp[n];
    
    
    
}

int main() {
	int n;
	cin>>n;
	int arr[n+1];
	for(int i=1;i<=n;i++)
	cin>>arr[i];
	cout << solve(arr,n);
	return 0;
}

Measured memory_bytes: 4384
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<queue>
using namespace std;
long long a,b,c,ans;
struct node{
	int order;
	int i;
}aa[100001];
int qpow(int x,int y)
{
	int tmp=1;
	while(y){
		if(y&1)tmp*=x;
		y>>=1;
		x*=x;
	}return tmp;
}
int cmp(node x,node y)
{
	return x.order<y.order;
}
bool isprime(long long x)
{
	if(x<=1)return 0;
	for(long long i=2;i<=sqrt(x);i++)
	{
		if(x%i==0)return 0;
	}return 1;
}
long long gcd(long long x,long long y){return y==0?x:gcd(y,x%y);}
void fenjie(long long c){
	long long tmp=c;
	for(long long i=2;i<=sqrt(c);i++)
	{
		if(tmp%i==0){
		//	cout<<i<<endl;
			ans++;
			while(tmp%i==0)tmp/=i;
		}
	}
	if(isprime(tmp))ans++;
}
int main()
{
	cin>>a>>b;
	c=gcd(a,b);
	fenjie(c);
	cout<<ans+1;
	return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
A = [list(map(int, input().split())) for i in range(N)]


def calc(hold):
    participants = {i: 0 for i in range(1, M + 1)}
    for person in A:
        for sport in person:
            if sport not in hold:
                continue
            participants[sport] += 1
            break
    return participants


X = set(list(range(1, M + 1)))
ans = float('inf')
while X:
    ret_p = calc(X)
    max_participants = max(ret_p.values())
    ans = min(ans, max_participants)
    for key, value in ret_p.items():
        if value == max_participants:
            X.remove(key)
            break

print(ans)


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

int main(){
  int n,p;
  int mayor[50],id,num;

  for(;;){
    cin >> n >> p;
    if(n==0 && p==0)break;
    
    for(int i=0;i<n;i++)mayor[i] = 0;
    id = 0; num = p;

    for(;;){
      if(num){
	mayor[id]++;
	num--;
      }else{
	num += mayor[id];
	mayor[id] = 0;
      }

      if(num==0 && mayor[id] == p){
	cout << id << endl;
	break;
      }

      id = (id+1) % n;
    }
  }
}

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

const int N = 20010;

int a[N], b[N];

int main(){
	int n;
	scanf("%d", &n);
	for (int i = 1, x; i <= n; ++ i){
		scanf("%d", &x);
		a[x] = i;
		b[i] = 2 * n * (n + 1 - i);
	}
	for (int i = 1; i <= n; ++ i){
		a[i] -= b[i];
	}
	for (int i = n; i >= 1; -- i){
		a[i] -= a[1] - 1;
	}
	for (int i = 1; i <= n; ++ i){
		printf("%d%c", a[i], " \n"[i == n]);
	}
	for (int i = 1; i <= n; ++ i){
		printf("%d%c", b[i], " \n"[i == n]);
	}
	return 0;
}

Measured memory_bytes: 768
N=int(input())
T,A=map(int,input().split())
H=[int(i) for i in input().split()]
ans=0
que=T-0.006*H[0]
for i in range(1,N):
    temp=T-0.006*H[i]
    if abs(A-que)>abs(A-temp):
        que=temp
        ans=i
print(ans+1)

Measured memory_bytes: 3064