akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int  ,int > pii;
typedef pair<ll  ,ll > pll;

const ll maxn =2e6;
const ll mod = 1e9+7;
const ld PI = 4 * atan((ld) 1);

#define pb(x) push_back(x);
#define endl '\n'
#define dokme(x) cout << x ;  return(0);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_init freopen("input.txt", "r+", stdin); freopen("output.txt", "w+", stdout);
#define ms(x , y) memset(x , y , sizeof x);
ll pw(ll a, ll b) {
    return (!b ? 1 : (b & 1 ? a * pw(a * a % mod, b / 2) % mod : pw(a * a % mod, b / 2) % mod));
}

int n ;
string s;
int sum , ans = 0;

int main(){
    migmig
    cin >> n >> s;
    for (int i = 2 ; i < n ; i ++){
        ans+=(int)(s[i] == 'C' and s[i - 1] == 'B' and s[i - 2] == 'A');
    }
    cout << ans;

    return(0);
}


//When we hit our lowest point, we are open to the greatest change.
//If I try, I fail. If I don't try, I'm NEVER GOING TO GET IT.
//Sometimes, life is like this dark tunnel. You can't always see the light at the end of the tunnel. But if you just keep moving... you will come to a better place.
//It is important to draw wisdom from diffrent places. If you take it from only one place it becomes rigid and stale.


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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_N = (int)(1e1 + 5);
const int MAX_D = (int)(1e1 + 5);

int n, d;
int x[MAX_N][MAX_D];

int ans;

bool check(int i, int j) {
  int base = 0;
  for (int k = 0; k < d; ++k) {
    base += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
  }

  int tmp = (int)(sqrt(base));

  return (tmp * tmp == base);
}

int main(void) {
  // Here your code !
  scanf("%d %d", &n, &d);

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

  ans = 0;

  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      if (check(i, j)) ans += 1;
    }
  }

  printf("%d\n", ans);

  return 0;
}


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

using namespace std;

int main() {
	string Data = "CODEFESTIVAL2016";
	string S;
	cin >> S;

	int count = 0;
	for (int i = 0; i < Data.length(); i++) {
		if (Data[i] != S[i]) {
			//間違ってた時
			count++;
		}
	}

	cout << count << endl;
	
	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int x1,x2,x3,x4,x5;
  cin >> x1 >> x2 >> x3 >> x4 >> x5;
 
    if (x1 == 0){
        cout << 1 <<endl;
    }else if(x2 == 0){
        cout << 2 <<endl;
    }else if(x3 == 0){
        cout << 3 <<endl;
    }else if(x4 == 0){
        cout << 4 <<endl;
    }else if(x5 == 0){
        cout << 5 <<endl;
    }

    
  
}

Measured memory_bytes: 3592
import java.util.*;

public class Main {
    public static void main(String args[]) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int prev = 0;
        while(n-- > 0) {
        	int num = sc.nextInt();
        	if(prev == 0 || num >= prev)
        		prev = num;
        	else {
        		if(prev - num > 1) {
        			 System.out.println("No");
        			return;
        		}
        	}	

        }
        System.out.println("Yes");
    }
}


Measured memory_bytes: 46108
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Console;
using static System.Math;

namespace CP
{
    class Atria
    {
        static void Main(string[] args)
        {
            long[] s = ReadLine().Split(' ').Select(long.Parse).ToArray();
            long n = s[0];
            long a = s[1];
            long b = s[2];

            long tmp = b - a;
            if(n == 0 || (n == 1 && a != b) || a>b)
            {
                WriteLine(0);
                return;
            }
            else if (n == 1 && a == b)
            {
                WriteLine(1);
                return;
            }

            WriteLine(
                (((n*b)-tmp) - ((n * a) + tmp))+1
                );

        }
    }
}


Measured memory_bytes: 11348
//AnkitCode99 here....
//every ups and downs matter!

#include<bits/stdc++.h>
#define endl "\n"
#define Ryuga ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr)
typedef long long int ll;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back

using namespace std;

const ll sz=1e5+5;
const ll szz=1e6+6;
const ll mod=1e9+7;

int main()
{
	Ryuga;

	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("op.txt","w",stdout);
	#endif

	clock_t startTime=clock();

	ll n,m,x;
	cin>>n>>m>>x;
	vector<vector<ll>> ar(n,vector<ll>(m));
	vector<ll> c(n);
	rep(i,0,n)
	{
		cin>>c[i];
		for(ll j=0;j<m;j++)
		{
			cin>>ar[i][j];
		}
	}

	ll ans=12345678;
	for(ll bit=0;bit<(1<<n);bit++)
	{
		vector<ll> lev(m);
		ll cost=0;
		for(ll i=0;i<n;i++)
		{
			if(bit&(1<<i))
			{
				cost+=c[i];
				for(ll j=0;j<m;j++)
				{
					lev[j]+=ar[i][j];
				}
			}
		}

		bool flag=true;
		rep(i,0,m)
		{
			if(lev[i]<x)
			{
				flag=false;
				break;
			}
		}
		if(flag)
		{
			ans=min(ans,cost);
		}
	}

	if(ans==12345678)
	{
		cout<<"-1\n";
	}
	else
	{
		cout<<ans<<endl;
	}

	cerr << endl <<setprecision(20)<< double( clock() - startTime ) / (double)CLOCKS_PER_SEC<< " seconds." << endl;

}//Goodbye...

Measured memory_bytes: 3792
#include <bits/stdc++.h>
#define ROOP(i, N) for(int i=0; i++; i<N)
#define RVROOP(i, N) for(int i=N; i--; i>=0)
#define ALL(v) v.begin(), v.end()
const int INF = 1e9;
const int MAX = 510000;
const int MOD = 1000000007;
using namespace std;
typedef long long ll;

/*DP使ったほうがよくない？？WOWWOW*/

int main(){
  long double L; cin>>L;
  L=pow(L,3)/27;
  cout << fixed << setprecision(13)<<L<<endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
 {
     int n;
     cin>>n;

   string s;
   cin>>s;
  int  cnt = 1;

    for(int i=1;i<s.size();i++)
        {
            if(s[i] == s[i-1])continue;
            else cnt++;
        }
        cout<<cnt<<endl;
}



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

using namespace std;

int main(){
    int n; cin >> n;
    vector<int> a(n),b(n);

    long long sum=0;
    int mn=INT_MAX;
    for(int i=0;i<n;i++){
        cin >> a[i] >> b[i];
        if(a[i]>b[i]){
            mn=min(mn,b[i]);
        }
        sum+=a[i];
    }
    if(mn<INT_MAX){
        cout << sum-mn << endl;
    }
    else{
        cout << 0 << endl;
    }

    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
  ll l,r;
  cin>>l>>r;
  if(r-l<=3000)
  {
    ll ans=2019;
  for(ll i=l;i<=r;i++)
  {
    for(ll j=i+1;j<=r;j++)
    {
      ans = min(ans,(i*j)%2019);
      if(ans==0)
      {
        cout<<0;
        return 0;
      }
    }
  }
    cout<<ans;
    return 0;
  }
  cout<<0;
  return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f

#include <iostream>
#include <cstdio>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
  
using namespace std;
  
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;
  
static const double EPS = 1e-8;
  
static const int tx[] = {0,1,0,-1};
static const int ty[] = {-1,0,1,0};

int main(){
  int n;
  while(~scanf("%d",&n)){
    deque<pair<char,int> > seq;
    for(int i=0;i<n;i++){
      char parentheses[2];
      int num;

      scanf("%s %d",parentheses,&num);
      seq.push_back(pair<char,int>(parentheses[0],num));
    }

    int max_round = seq.size();
    for(int round=0;round < max_round;round++){
      for(int i=0;i+1<seq.size();i++){
	if(seq[i].first == '(' && seq[i+1].first == ')'){
	  if(seq[i].second < seq[i+1].second){
	    seq[i+1].second -= seq[i].second;
	    seq.erase(seq.begin()+i);
	    break;
	  }
	  else if(seq[i].second > seq[i+1].second){
	    seq[i].second -= seq[i+1].second;
	    seq.erase(seq.begin()+i+1);
	    break;
	  }
	  else if(seq[i].second == seq[i+1].second){
	    seq.erase(seq.begin()+i,seq.begin()+i+2);
	    break;
	  }
	}
      }
    }

    printf("%s\n",seq.size() == 0 ? "YES" : "NO");
  }
}

Measured memory_bytes: 1204
#include <stdio.h>
#include <string.h>
#define N 1000
int main(){
  char T[N],P[N];
  int i,j,l,m,count;
   
  scanf("%s",T);
  scanf("%s",P);
   
  l=strlen(T);
  m=strlen(P);
   
  for(i=0;i<l;i++){
    count=0;
    for(j=0;j<m;j++){
      if(T[i+j]==P[j]) count++;
   
    }
    if(count==m) printf("%d\n",i);
  }
  return 0; 
}  

Measured memory_bytes: 540
#include <bits/stdc++.h>
#define ll long long
#define REP(i, n) for (ll (i) = 0; (i) < (n); (i)++)
#define REPI(i, a, b) for (ll (i) = (a); (i) < (b); (i)++)
#define P pair<ll, ll>
#define VI vector<ll>
#define int long long
using namespace std;

int N;
string S;

void solve() {
  VI r = VI(N);
  VI l = VI(N);
  // init l
  l[0] = 0;
  REP (i, N-1) {
    if (S[i] == 'W') {
      l[i+1] = l[i] + 1;
    } else {
      l[i+1] = l[i];
    }
  }
  // init r
  r[N-1] = 0;
  for (int i = N-1; i > 0; i--) {
    if (S[i] == 'E') {
      r[i-1] = r[i] + 1;
    } else {
      r[i-1] = r[i];
    }
  }
  // min(r[i] + l[i])
  int ans = 10000000;
  REP (i, N) {
    /* cout << l[i] << ' ' << r[i] << endl; */
    if (r[i] + l[i] < ans) {
      ans = r[i] + l[i];
    }
  }
  cout << ans << endl;
}

signed main() {
  cin >> N;
  cin >> S;

  solve();
}


Measured memory_bytes: 5508
//By Koios1143
#include<bits/stdc++.h>
#define LL long long
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define pii pair<int,int>
using namespace std;
const int MaxN = 105,MaxW = 100005;
int n,w,cost[MaxN],value[MaxN];
long long dp[MaxW];
long long max(long long a, long long b){
	return a>b ? a : b;
}
int main(){
	IOS
	while(cin>>n>>w){
		for(int i=0 ; i<n ; i++){
			cin>>cost[i]>>value[i];
		}
		for(int i=0 ; i<n ; i++){
			for(int j=w ; j-cost[i]>=0 ; j--){
				dp[j] = max(dp[j], dp[j-cost[i]]+value[i]);
			}
		}
		cout<<dp[w]<<"\n";
	}
	return 0;
}


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

using namespace std;

int main(){

	string s;

	cin >> s;

	for(int i = 0;i < s.length();i+=2){
		cout << s[i];
	}


    return 0;

}


Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main(){
int n,num;
string mar;
int cards[4][14];
for(int i=0; i<4; i++){
for(int j=1; j<14; j++){
cards[i][j]=0;
}
}
cin >> n;
for(int i=0; i<n; i++){
cin >> mar >> num;
if(mar=="S") cards[0][num]=1;
else if(mar=="H") cards[1][num]=1;
else if(mar=="C") cards[2][num]=1;
else if(mar=="D") cards[3][num]=1;
}
for(int i=0; i<4; i++){
for(int j=1; j<14; j++){
if(cards[i][j]==0){
if(i==0) cout << "S " << j <<endl;
else if(i==1) cout << "H " << j <<endl;
else if(i==2) cout << "C " << j <<endl;
else if(i==3) cout << "D " << j <<endl;
}
}
}
return 0;
}


Measured memory_bytes: 3128
#include<stdio.h>

int main(void)
{
	int r,c,n,i,j=0,sum=0;
	int array[101][101]={0,};

	scanf("%d %d",&r,&c);
	for(j=0;j<r;j++){
		for(i=0;i<c;i++){
			scanf("%d",&array[i][j]);
		}
	}
	for(j=0;j<r;j++){
		for(i=0;i<c;i++){
			array[c][j]+=array[i][j];
			array[i][r]+=array[i][j];
			array[c][r]+=array[i][j];
		}
	}
	for(j=0;j<=r;j++){
		for(i=0;i<=c;i++){
			if(i!=0) printf(" ");
			printf("%d",array[i][j]);
		}
		printf("\n");
	}


	return 0;	
}	

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

using namespace std;

int main() {
  int n;
  string s;
  cin >> n >> s;
  n = s.length();
  int a[n];
  for (int i = 0; i < n; i++) {
    if (s[i] == '(') {
      a[i] = 1;
    } else if (s[i] == ')') {
      a[i] = -1;
    }
  }
  int tmp = 0;
  int lb = 0;
  int rb = 0;
  for (int i = 0; i < n; i++) {
    tmp += a[i];
    if (tmp < 0) {
      tmp = 0;
      lb++;
    }
  }
  rb = tmp;

  for (int i = 0; i < lb; i++) {
    cout << "(";
  }
  cout << s;
  for (int i = 0; i < rb; i++) {
    cout << ")";
  }
  cout << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cctype>
#include<string>
using namespace std;
int main()
{
 string s;
 int a,b;
 cin>>a>>b;
 cin>>s;
 if(s.size()!=a+b+1)
 {
 cout<<"No";
 return 0;
 }
 
 
 for(int i=0;i<s.size();i++)
 {
 if(i!=a)
 {
 
 if(!isdigit(s[i])){
 
 cout<<"No";
 return 0;
 }
}
 else
 
 {
 if(s[i]!='-'){
 
 cout<<"No";
 return 0;
 
 }
 }
}
 cout<<"Yes";
 return 0;

}

Measured memory_bytes: 256
while 1:
    try:
        l=list(map(int,input().split(",")))
        v1=l[10]
        suml=sum(l[:10])
        sumv=sum(l[10:12])
        time=suml/sumv
        point=time*v1
        ans=1
        for i in l[:10]:
            if point<=i:break
            else:
                point-=i
                ans+=1
        print(ans)
    except:break


Measured memory_bytes: 5604
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <numeric>
#include <string>
#include <bitset>
#include <functional>

using ld = long double;
using vld = std::vector<ld>;
using vvld = std::vector<vld>;
using vvvld = std::vector<vvld>;
using ll = long long;
using vll = std::vector<ll>;
using vvll = std::vector<vll>;
using vvvll = std::vector<vvll>;
using pll = std::pair<ll, ll>;
using vpll = std::vector<pll>;
using str = std::string;
using vstr = std::vector<str>;

template<typename T> bool chmin(T a, T &b) { return a < b ? b = a, true : false; }
template<typename T> bool chmax(T a, T &b) { return a > b ? b = a, true : false; }

constexpr ld PI = 3.141592653589793L;
constexpr ld EPS = std::numeric_limits<ld>::epsilon();

ll gcd(ll n, ll m) { return m ? gcd(m, n % m) : n; }
ll lcm(ll n, ll m) { return n / gcd(n, m) * m; }
bool isprime(ll n) {
    if (n < 2) return false;
    for (ll i = 2; i * i <= n; i++)
        if (n % i == 0) return false;
    return true;
}
ll rpow(ll x, ll n) {
    if (n == 0) return 1;
    ll k = 1;
    for (; n > 1; n /= 2) {
        if (n & 1) k *= x;
        x *= x;
    }
    return k * x;
}
ll modpow(ll x, ll n, ll mod) {
    if (n == 0) return 1;
    ll k = 1;
    for (; n > 1; n /= 2) {
        if (n & 1) (k *= x) %= mod;
        (x *= x) %= mod;
    }
    return k * x % mod;
}
ll modcomb(ll n, ll r, ll mod) {
    if (r < 0 || n < r) return 0;
    chmin(n - r, r);
    ll mul = 1, div = 1;
    for (ll i = 0; i < r; i++) {
        (mul *= n - i) %= mod;
        (div *= i + 1) %= mod;
    }
    return mul * modpow(div, mod - 2, mod) % mod;
}

/*------------------------------------------------------------------------*/

void solve();

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

    solve();
}
void solve() {
    ll n, k;
    std::cin >> n >> k;

    vll d(k);
    for (ll i = 0; i < k; i++)
        std::cin >> d[i];

    for (ll i = n;; i++) {
        str s = std::to_string(i);
        bool flg = true;
        for (char c : s) for (ll j : d)
            if (c == j + '0') {
                flg = false; break;
            }
        if (flg) { std::cout << i << '\n'; return; }
    }
}


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

int main(void){
  int a, b, num;
  cin >> a >> b;
  if(b < 10) num = a*10 + b;
  else if(b < 100) num = a*100 + b;
  else num = a*1000 + 100;

  for(int i = 0; i < 1000; i++){
    if(i*i == num){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
s = input()

colors = ['R', 'B', 'G']

cnt = 1
for c in colors:
    cnt *= s.count(c)

for i in range(n):
    w = 1
    while True:
        if i + 2*w >= n: break
        if s[i] != s[i+w] and s[i+w] != s[i+2*w] and s[i+2*w] != s[i]:
            cnt -= 1
        w += 1
print(cnt)

Measured memory_bytes: 67972
#include <math.h>
int i,n,x[1000],y[1000];
double t;
double D(int p){
    int i;
    for(t=0,0,i=0;i<n;i++){
        if(p==4)t=t>abs(x[i]-y[i])?t:abs(x[i]-y[i]);
        else t+=pow(1.0*abs(x[i]-y[i]),p);
    }
    return p==4?t:pow(t,1.0/p);
}
main(){
    scanf("%d",&n);
    for(i=0;i<n;i++)scanf("%d",&x[i]);
    for(i=0;i<n;i++)scanf("%d",&y[i]);
    for(i=1;i<5;i++)printf("%lf\n",D(i));
}

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


int main(){
  ll H;
  cin >> H;
  ll enemy = 1;
  ll ans = 0;
  while (H != 0){
    ans += enemy;
    H = H/2;
    enemy *= 2;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define to edge[i].v
#define mp make_pair
#define rint register int
#define debug(x) cerr<<#x<<"="<<x<<endl
#define fgx cerr<<"-------------"<<endl
#define N 1000
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int mod=1e9+7;
int a[N],b[N],h[N],f[N][N];
inline int qpow(int y,int x=2){int A=1;for(;y;y>>=1,x=(ll)x*x%mod)if(y&1)A=(ll)A*x%mod;return A;}
int main()
{	int n,ans=0; cin>>n;
	for(rint i=1;i<=n;i++) scanf("%d",&h[i]),b[i]=h[i];
	sort(b+1,b+n+1); int l=unique(b+1,b+n+1)-b-1;
	for(rint i=1;i<=n;i++) a[i]=lower_bound(b+1,b+l+1,h[i])-b;
	f[0][0]=1;
	for(rint i=1;i<=n;i++)
	{	f[i][0]=f[i-1][0]*2%mod; 
		for(rint j=a[i]+1;j<=a[i-1];j++) (f[i][0]+=2*f[i-1][j]%mod)%=mod;
		for(rint j=1;j<=a[i];j++)
		{	f[i][j]=(ll)f[i-1][j]*qpow(max(0,b[a[i]]-b[a[i-1]]))%mod;
			if(j>a[i-1])
			(f[i][j]+=((j!=1)+1LL)*f[i-1][0]%mod*qpow(b[a[i]]-b[j])%mod*(qpow(b[j]-b[j-1])-1-(j==1))%mod)%=mod;
		}
	}
	for(rint i=0;i<=a[n];i++) (ans+=f[n][i])%=mod;
	cout<<ans;
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int n;
	cin >> n;
	
	vector<int> h(n);
	int ans = 0;
	for(int i = 0; i < n; ++i) {
		cin >> h[i];
		ans += h[i];
	}
	
	for(int i = 0; i < n - 1; ++i) {
		ans -= min(h[i], h[i + 1]);
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<string.h>
#include<complex>
#include<math.h>
using namespace std;
typedef long long int llint;
#define rep(i,n) for(int i=0;i<n;i++)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;

bool check(int a, int b) {
	return a > b;
}

int main() {
	int x;
	cin >> x;
	int ans = 0;
	while (x > 0) {
		ans += x % 10;
		x /= 10;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		long m = 1000000007;

		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		int kk = sc.nextInt();

		long[][] dp = new long[h + 1][w];
		dp[0][0] = 1;
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				for (int k = 0; k < 1 << (w - 1); k++) {
					boolean ok = true;
					for (int l = 0; l < w - 2; l++) {
						if (((k >> l) & 1) == 1 && ((k >> (l + 1)) & 1) == 1) {
							ok = false;
						}
					}

					if (!ok) continue;

					if (j >= 1 && ((k >> (j - 1)) & 1) == 1) {
						dp[i + 1][j - 1] = (dp[i + 1][j - 1] + dp[i][j]) % m;

					} else if (j < w - 1 && ((k >> j) & 1) == 1) {
						dp[i + 1][j + 1] = (dp[i + 1][j + 1] + dp[i][j]) % m;

					} else {
						dp[i + 1][j] = (dp[i + 1][j] + dp[i][j]) % m;
					}
				}
			}
		}

		System.out.println(dp[h][kk - 1]);
	}
}


Measured memory_bytes: 24148
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
	#ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    int n,k;
    cin>>n>>k;
    string s[n];
    for(int i=0;i<n;++i) cin>>s[i];
    sort(s,s+n);
	for(int i=0;i<n;++i) cout<<s[i];
	return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int a;
  cin >> a;
  cout << a + pow(a, 2) + pow(a, 3) << endl;
  return 0;
}

Measured memory_bytes: 4144
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n;
  cin >> n;
  if(n%2!=0){
    cout << "No" << endl;
    return 0;
  }
  int h_n = n/2;
  char t1[h_n];
  char t2;
  for(int i=0; i<h_n; i++){
    cin >> t1[i];
  }
  for(int i=0; i<h_n; i++){
    cin >> t2;
    if(t1[i]!=t2){
      cout << "No" << endl;
      return 0;
    }
  }
  
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP()(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep (i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(X, x) for (auto &&X : x)
#define all(x) (x).begin(), (x).end()
#ifdef LOCAL
  #include "../../Lib/cout_container.hpp"
  #define debug(x) cerr << #x " => " << x << endl
#else
  #define debug(x) 0
#endif
using lint = long long;
constexpr int    INF  = 1 << 30;
constexpr lint   INFL = 1LL << 62;
constexpr int    MOD  = (int)1e9 + 7;
constexpr double EPS  = 1e-9;
using namespace std;
namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; }

int main(void) {
  int n, d;
  cin >> n >> d;
  vector<vector<int>> x(n, vector<int>(d));
  rep (i, n) {
    rep (j, d) cin >> x[i][j];
  }
  int cnt = 0;
  rep (i, n) {
    rep (j, i + 1, n) {
      lint sum = 0;
      rep (k, d) sum += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
      lint root = sqrt(sum);
      if (root * root == sum) ++cnt;
    }
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
    string a;
    cin>>a;
    int n=0;
    int w=0;
    int s=0;
    int e=0;
    for(int i=0;i<a.size();i++){
        if(a[i]=='N'){
            n++;
        }
        if(a[i]=='W'){
            w++;
        }
        if(a[i]=='S'){
            s++;
        }
        if(a[i]=='E'){
            e++;
        }
    }
    int ns=max(n,s),sn=min(n,s),we=max(w,e),ew=min(e,w);
    if((ns>0&&sn==0)||(we>0&&ew==0)){
        cout<<"No"<<endl;
    }
    else{
        cout<<"Yes"<<endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<stack>
#include<queue>
#include<list>

using namespace std;


int main(){
	int n,q,a,ans=0;
	vector<int> T;
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> a;T.push_back(a);
	}
	sort(T.begin(),T.end());
	cin >> q;
	for(int i=0;i<q;i++){
		cin >> a;
		ans+=binary_search(T.begin(), T.end(), a);
	}
	cout << ans << endl;
}

Measured memory_bytes: 3224
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <iomanip>
#include <map>
#include <queue>
#include <list>


#define REP(i, n ,N) for(ll i = (n); i < (N); i++)
//#define RREP(i, n ,N) for(ll i = (N-1); i >= (n); i--)
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
#define INF 1e9
#define vint vector<int>

using namespace std;
typedef long long  ll;

const long long M = 1e9+7;

vector<ll> fac(300001); //n!(mod M)
vector<ll> ifac(300001); //k!^{M-2} (mod M)
//a,bの範囲的にこれだけ配列を用意していけば十分

ll mpow(ll x, ll n){ //x^n(mod M) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % M;
        x = x*x % M;
        n = n >> 1;
    }
    return ans;
}

ll comb(ll a, ll b){ //aCbをmod計算
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    ll tmp = ifac[a-b]* ifac[b] % M;
    return tmp * fac[a] % M;
}

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

    //大した量ではないので，先にfax[i]とifax[i]を全て計算しておく
    fac[0] = 1;
    ifac[0] = 1;
    for(ll i = 0; i<=200000; i++){
        fac[i+1] = fac[i]*(i+1) % M; // n!(mod M)
        ifac[i+1] = ifac[i]*mpow(i+1, M-2) % M; // k!^{M-2} (mod M) ←累乗にmpowを採用
    }

    ll ans = 0;
    ll tmp = 0;
    ll under = 0;
    ll top = 0;
    for(ll i = 0; i < k; i++){
        under += i;
        top += n - i;
    }
    for(ll i = k; i <= n+1; i++){

        tmp = comb(n+1, i);
//        p(tmp);
//        ans += min((top - under + 1), tmp % M);
        ans += (top - under + 1);
//        max = 0;
        under += i;
        top += n - i;
    }

//    ans = comb(n, k);

    p(ans%M);
}

Measured memory_bytes: 7396
#include<cstdio>
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<string>

using namespace std;

#define rep(i,n) for(int i=0;i<int(n);i++)
#define reps(i,n) for(int i=1;i<=int(n);i++)
#define sint(i) scanf("%d",&i);
#define sintt(i,j) scanf("%d%d",&i,&j);
#define sinttt(i,j,k) scanf("%d%d%d",&i,&j,&k);
#define sintttt(i,j,k,m) scanf("%d%d%d%d",&i,&j,&k,&m);

#define INF 1010000000
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};



int main(){
	while(1){
		int n,m;
		sintt(n,m);
		if(n==0)break;
		int masu[17][17];
		int dp[17][17];
		
		rep(i,17)rep(j,17)masu[i][j]=dp[i][j]=0;
		
		rep(i,m)rep(j,n){
			sint(masu[j+1][i]);
		}
		
		reps(j,n){
			if(masu[j][0]!=1){
				dp[j][0]=1;
			}
		}
		
		rep(i,m-1){
			reps(j,n){
				if(masu[j][i]==2){
					if(masu[j][i+2]!=1){
						dp[j][i+2]+=dp[j][i];
					}
					continue;
				}
				if(masu[j][i]==0){
					if(masu[j-1][i+1]==0){
						dp[j-1][i+1]+=dp[j][i];
					}
					if(masu[j+1][i+1]==0){
						dp[j+1][i+1]+=dp[j][i];
					}
					
					if(masu[j][i+1]!=1){
						dp[j][i+1]+=dp[j][i];
					}
				}
			}
		}
		
		int ans=0;
		for(int i=m-1;i<=m;i++){
			reps(j,n){
				ans+=dp[j][i];
			}
		}
		printf("%d\n",ans);
		/*
		rep(i,m+2){
			rep(j,n+2){
				printf("%d ",dp[j][i]);
			}puts("");
		}*/
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pcc pair<char,char>
#define vi vector <int>
#define vl vector <ll>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d",x)
#define plld(x) printf("%lld",x)
#define pds(x) printf("%d ",x)
#define pllds(x) printf("%lld ",x)
#define pdn(x) printf("%d\n",x)
#define plldn(x) printf("%lld\n",x)
#define INF 2e9
#define INFLL 4e18
using namespace std;
ll powmod(ll base,ll exponent,ll mod){ // with mod < 1e9
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%mod;
		base=(base*base)%mod;
		exponent/=2;
	}
	return ans;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b,a%b);
}
const int upperlimit = 2e5+1;
const int mod = 1e9+7;
ll arr[upperlimit];
ll gaussian[65];
int lg(ll n){
	ll x=1;int ans=-1;
	while(x<=n){
		x*=2;
		ans++;
	}
	return ans;
}
int main() {
	ll ans=0,temp=0;
	int n;
	sd(n);
	for(int i = 1; i <= n; i++){
		slld(arr[i]);
		ans^=arr[i];
	}
	for(int i = 1; i <= n; i++) arr[i]-=(ans&arr[i]);
	for(int i = 1; i <= n; i++){
		for(int j = 63; j >= 0; j--) if((arr[i]^gaussian[j])<arr[i]) arr[i]^=gaussian[j];
		if(arr[i]) gaussian[lg(arr[i])]=arr[i];
	}
	for(int j = 63; j >= 0; j--) if((temp^gaussian[j])>temp) temp^=gaussian[j];
	temp*=2;
	ans+=temp;
	plld(ans);
	return 0;
}

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

#define rep(i, n) for(int i = 0; i < (n); i++)
using ULL = unsigned long long;



void solve() {
	int n; cin >> n;
	int np = 1 << n;
	vector<int> s(np); rep(i, np) cin >> s[i];
	sort(s.begin(), s.end());
	reverse(s.begin(), s.end());
	vector<int> d(np);

	d[0] = s[0]; s[0] = 0;

	for(int i = 0; i < n; i++) {
		int iii = 0;
		int ns = (1 << i);
		sort(d.begin(), d.begin() + ns);
		reverse(d.begin(), d.begin() + ns);
		for (int ii = 0; ii < ns; ii++) {
			while (true) {
				if (iii >= np) { cout << "No" << endl; return; }
				if (s[iii] == 0)iii++;
				else if (s[iii] >= d[ii])iii++;
				else {
					d[ii + ns] = s[iii];
					s[iii] = 0;
					iii++; break;
				}
			}
		}
	}
	cout << "Yes" << endl;
}

int main() {

	solve();

	return 0;
}


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

#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define endl '\n'
#define fcin ios::sync_with_stdio(false); cin.tie(nullptr);
#define INF 0x3f3f3f3f
#define all(x) x.begin(), x.end()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

template <typename A, typename B>
string to_string(pair<A, B> p){
    return "(" + to_string(p.fi) + ", " + to_string(p.se) + ")";
}

template <typename T>
string to_string(T v){
    string s = "{";
    bool first = true;
    for(const auto & x : v){
        if(!first) s += ", ";
        first = false;
        s += to_string(x);
    }
    return s + "}";
}

void debug_out(){ cerr << endl;}
template <typename First, typename... Next>
void debug_out(First F, Next... N){
    cerr << " " << to_string(F);
    debug_out(N...);
}

#ifdef LOCAL
    #define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
    #define debug(...) 1
#endif

int main(){
    fcin;
    string s, t;
    cin >> s >> t;
    cout << t + s << endl;
    return 0;
}



Measured memory_bytes: 256
import sys
si = sys.stdin.readline


def main():
    l = [int(e) for e in si().split()]
    lower = l[0]
    upper = l[1]
    q = l[2]
    start = lower//q
    end = upper//q
    cnt = end-start+1
    if q*start < lower:
        cnt -= 1
    print(cnt)


if __name__ == '__main__':
    main()


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

#define fi first
#define se second
#define all(x) x.begin(), x.end()
using namespace std;
using ull = unsigned long long;
using ll = long long;

struct __INIT {
    __INIT() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
    }
} __init;

int main() {
    int H, W;
    cin >> H >> W;
    vector<vector<char>> G(H, vector<char>(W));
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++) cin >> G[i][j];
    }
    bool flag = true;
    for(int i = 0; i < H - 1; i++){
        for(int j = 0; j < W - 1; j++){
            if(G[i][j + 1] == '#' and G[i + 1][j] == '#' and G[i + 1][j + 1] == '#'){
                flag = false;
            }
            if(G[i][j] == '#' and G[i][j + 1] == '#' and G[i + 1][j] == '#'){
                flag = false;
            }
        }
    }
    if(flag) puts("Possible");
    else puts("Impossible");
}

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

int main() {
    int n, m, cnt = 0, sum = 0;
    scanf("%d %d", &n, &m);
    int a[n];
    for(int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
        sum += a[i];
    }
    for(int i = 0; i < n; i++) {
        if(a[i] >= sum * 1.0 / (4 * m)) {
            cnt++;
            if(cnt == m) {
                printf("Yes\n");
                return 0;
            }
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <fstream>
#define debug(x) cout << #x << " = " << x << 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 > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;


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

  int n;
  cin>>n;
  int a[n];
  rep(i,n) cin>>a[i];
  int t = 1;
  int odd = 1;
  rep(i,n) {
    t *= 3;
    if(a[i] % 2 == 0) {
      odd *= 2;
    }
  }
  cout << t - odd << endl;

  return 0;
}


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

int n, k, c, j;
string s;
int l[200000], r[200000];

int main()
{
    cin >> n >> k >> c >> s;

    j = 0;

    for (int i = 0; i < n; i++) {
        if (s[i] == 'o') {
            l[j] = i;
            j++;
            i += c;
        }
    }

    j = 0;

    for (int i = n - 1; i >= 0; i--) {
        if (s[i] == 'o') {
            r[k - 1 - j] = i;
            j++;
            i -= c;
        }

        if (k - 1 - j < 0)
            break;
    }

    for (int i = 0; i < k; i++)
        if(l[i] == r[i])
            cout << l[i] + 1 << endl;
}

Measured memory_bytes: 3332
#include <iostream>
#include <iomanip>
typedef long long ll;
using namespace std;
const  ll INF = 1e9;
const  ll MOD = 1e9 + 7;
#define repi(i,n,init) for(ll i=init;i<(n);i++)

int main()
{
    int a,b,c;
    cin >> a >> b >> c;
    cout << (b - a == c - b?"YES":"NO") <<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#define MOD_BY 1000000007

int add(int a, int b) {
	return a + b - MOD_BY * (a + b >= MOD_BY);
}

char S[114514];

int memo[114514][4];

int asumikana(int pos, int status) {
	int answer = 0;
	if (S[pos] == 0) return status == 3;
	if (memo[pos][status]) return ~memo[pos][status];

	if (S[pos] == 'A' || S[pos] == '?') {
		answer = add(answer, asumikana(pos + 1, status));
		if (status == 0) answer = add(answer, asumikana(pos + 1, status + 1));
	}
	if (S[pos] == 'B' || S[pos] == '?') {
		answer = add(answer, asumikana(pos + 1, status));
		if (status == 1) answer = add(answer, asumikana(pos + 1, status + 1));
	}
	if (S[pos] == 'C' || S[pos] == '?') {
		answer = add(answer, asumikana(pos + 1, status));
		if (status == 2) answer = add(answer, asumikana(pos + 1, status + 1));
	}

	return ~(memo[pos][status] = ~answer);
}

int main(void) {
	if (scanf("%114513s", S) != 1) return 1;
	printf("%d\n", asumikana(0, 0));
	return 0;
}


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

using namespace std;

int main(){
    int q;
    scanf("%d", &q);
    while(q--)
    {
        string X, Y;
        cin>>X>>Y;
        int table[X.length() + 1][Y.length() + 1];
        for(int i=0; i<Y.length() + 1; i++) table[0][i] = 0;
        for(int i=1; i<X.length() + 1; i++)
        {
            table[i][0] = 0;
            for(int j=1; j<Y.length() + 1; j++)
            {
                if(X[i-1] == Y[j-1]) table[i][j] = table[i-1][j-1] + 1;
                else table[i][j] = max(table[i-1][j], table[i][j-1]);
            }
        }
        printf("%d\n", table[X.length()][Y.length()]);
    }
}  


Measured memory_bytes: 7088
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

X = ir()
answer = 1
for y in range(2, X):
    temp = y * y
    if temp > X:
        continue
    while temp * y <= X:
        temp *= y
    if temp > answer:
        answer = temp

print(answer)


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

int main(){

    int N;
    cin >> N;

    int count = 0;
    int product = 2;
    while(true){
        if(N < product)  break;

        product *= 2;
        ++count;
    }

    cout << product/2 << endl;

    return 0;
}


Measured memory_bytes: 3528
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))
 
using namespace std;
 
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
 
const ll INF=1e9+7;

int main(){
    ll n;
    cin >> n;
    ll d=n/15;
    cout << 800*n-d*200 << endl;
    return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(v) v.begin(),v.end()
using namespace std;
using ll=long long;
#ifdef ONLINE_JUDGE
#define D(...)
#else
#define D(...)cerr<<__LINE__<<":"<<"["<<#__VA_ARGS__<<"]->",P(__VA_ARGS__)
#endif
void P(){cerr<<endl;} 
template<typename H,typename...T>void P(H h,T...t){cerr<<h<<" ";P(t...);}
int main()
{
    ios::sync_with_stdio(false);cin.tie(0);
    int n,T;cin>>n>>T;
    int ans=INT_MAX;
    for(int i=0,x,y;i<n;++i){
        cin>>x>>y;
        if(y<=T){
            ans=min(ans,x);
        }
    }
    if(ans==INT_MAX)cout<<"TLE";
    else cout<<ans;
}

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

  
int main() {
  int N;
  cin >> N;
  
  set<int> d;
  for(int i=0; i<N; i++){
    int k;
    cin >> k;
    d.insert(k);
  }
  
  
  cout << d.size()  << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <vector>
#include <limits.h>
#include <math.h>

#define repeat(i,n) for (int i = 0; (i) < (n); ++ (i))

using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> vint;
const ll INF = LONG_LONG_MAX;

typedef ll Weight;
struct Edge {
    int src, dst;
    Weight weight;
    Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) { }
};
bool operator < (const Edge &e, const Edge &f) {
    return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

typedef vector<Weight> Array;
typedef vector<Array> Matrix;

bool BellmanFord(const Graph &g, int s, vector<Weight> &dist,
                 vector<int> &prev) {
    int n = (int)g.size();
    dist.assign(n, INF);
    dist[s] = 0;
    prev.assign(n, -2);
    //bool negative_cycle = false;
    repeat(k, 2*n+1){
        bool tchanged = false;
        repeat(i, n)
            for (__typeof(g[i].begin()) e = g[i].begin(); e != g[i].end();
                 e++) {
                Weight d = dist[e->src] + e->weight;
                if (dist[e->src] != INF && dist[e->dst] > d) {
                    dist[e->dst] = d;
                    prev[e->dst] = e->src;
                    /*
                    if (k == n) {
                        dist[e->dst] = -INF;
                        negative_cycle = true;
                    }
                     */
                    if(e->dst == n-1)
                        tchanged = true;
                }
            }
        if(tchanged && k > n) return false;
    }
    return true;
}

int main() {
    // insert code here...    return 0;
    //////
    // input from txt
    /*
     std::ifstream in("input.txt");
     std::cin.rdbuf(in.rdbuf());
     std::ofstream out("output.txt");
     std::cout.rdbuf(out.rdbuf());
     ////
     */
    int N,M;
    cin >> N >> M;
    Graph g(N);
    repeat(i, M){
        int a,b;
        Weight c;
        cin >> a >> b >> c;
        a--;
        b--;
        g[a].push_back(Edge(a,b,-c));
    }
    vector<Weight> d;
    vint p;
    if(BellmanFord(g, 0, d, p)){
        cout << -d[N-1] << endl;
    }else{
        cout << "inf" << endl;
    }
    
    return 0;
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int w,h,c[50][50],ans;
vector<int> out;
bool dfs(int x,int y);
int main(){
  while(1){
    ans = 0;
    for(int i=0;i<50;i++){
      for(int l=0;l<50;l++){
        c[i][l] = 0;
      }
    }
    cin >> w >> h;
    if(w == 0 && h == 0){
      break;
    }
    for(int i=0;i<h;i++){
      for(int l=0;l<w;l++){
         cin >> c[l][i];
      }
    }
    for(int i=0;i<h;i++){
      for(int l=0;l<w;l++){
        if(c[l][i] == 1){
          dfs(l,i);
          ans++;
        }
      }
    }
    out.push_back(ans);
  }
  for(int i=0;i<out.size();i++){
    cout << out[i] << endl;
  }
}
bool dfs(int x,int y){
  if(x<0 || x>=w || y<0 || y>=h || c[x][y] == 0) return false;
  c[x][y] = 0;
  for(int dx=-1;dx<=1;dx++){
    for(int dy=-1;dy<=1;dy++){
      if(dfs(x+dx,y+dy)){
        return true;
      }
    }
  }
  return false;
}



Measured memory_bytes: 3172
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {

	public static void main(String[] args) throws Exception{

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String s = br.readLine();
		List<Integer> l = new ArrayList<>();
		for(int i=0;i<s.length();i++)
		{
			if(s.charAt(i) == '0')
				l.add(0);
			else if(s.charAt(i) == '1')
				l.add(1);
			else
			{
				if(!l.isEmpty())
					l.remove(l.size()-1);
			}
		}
		StringBuilder sb = new StringBuilder();
		for(int i: l)
			sb.append(i);
		System.out.println(sb);
	}

}


Measured memory_bytes: 32404
n,m = map(int,input().split())
h = list(map(int,input().split()))
good = [0]*n
for i in range(m):
    a,b = map(int,input().split())
    if h[a-1] >= h[b-1]:
        good[b-1] += 1
    if h[b-1] >= h[a-1]:
        good[a-1] += 1
ans = 0
for i in range(n):
    if good[i] == 0:
        ans += 1
print(ans)

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

int main(){
  int64_t N, K, a, b;
  cin >> N >> K;
  
  int64_t quote = N/K;
  a = N - K*quote;
  b = K * (quote + 1) - N;
  if(a >= b){
    cout << b;
  }
  else {
    cout << a;
  }
}



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


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		while(true){
			String[] tmpArray = br.readLine().split(" ");
			int n = Integer.parseInt(tmpArray[0]);
			int k = Integer.parseInt(tmpArray[1]);
			
			if(n == 0 && k == 0){
				break;
			}
			boolean[] exist = new boolean[n+1];
			
			for(int i = 0; i < k ; i++){
				exist[Integer.parseInt(br.readLine())] = true;
			}
			
			ArrayList<Section> list = new ArrayList<Section>();
			boolean inSection = false;
			Section sec = null;
			for(int  i = 1; i <= n; i++){
				if(exist[i] == true && inSection == false){
					sec = new Section(i, i);
					inSection = true;
				}
				
				if(inSection == true && (i == n || exist[i+1] == false)){
					sec.end = i;
					list.add(sec);
					inSection = false;
//					System.out.println("start "+ sec.start + " end "+sec.end);
					
				}
			}
			//????´???????????????????
			if(exist[0] == false){
				Iterator<Section> it = list.iterator();
				int lenMax = 0;
				while(it.hasNext()){
					Section tmp = it.next();
					if(tmp.numOfNumbers() > lenMax){
						lenMax = tmp.numOfNumbers();
					}
				}
				
				System.out.println(lenMax);
			}
			
			else {
				Iterator<Section> it = list.iterator();
				Section first = it.next();
				Section second = null;
				
				int lenMax = first.numOfNumbers();
				while(it.hasNext()){
					second = it.next();
					int tmpLen = second.numOfNumbers();
					if(second.start - first.end == 2){
						tmpLen += first.numOfNumbers() + 1;
					}
					
					if(lenMax < tmpLen){
						lenMax = tmpLen;
					}
					
					first = second;
				}
				
				System.out.println(lenMax);
			}
		}
	}

}

class Section {
	int start;
	int end;
	
	public Section(int s, int e){
		this.start = s;
		this.end = e;
	}
	
	public int numOfNumbers(){
		return end - start + 1;
	}
}

Measured memory_bytes: 34772
#include <bits/stdc++.h>
#include <variant>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;

struct Data {
  int num;
  Data() : num(0) {;}
  Data(int n) : num(n) {;}
};

inline Data Merge(Data left, Data right) {
  return Data(left.num > right.num ? left.num : right.num);
}

struct SegmentTree {
  int n; vector<Data> data;
  SegmentTree(int N) : n(1 << N), data(n * 2) {}
  void update (int pos, Data value) {
    data[pos] = value;
    while (pos < 2*n-1) {
      int l = pos, r = pos^1;
      if (l > r) swap(l, r);
      pos = pos / 2 + n;
      data[pos] = Merge(data[l], data[r]);
    }
  }
  Data sub(int fr, int to, int node, int la, int ra) {
    if (ra<=fr || to<=la) return Data();
    if (fr<=la && ra<=to) return data[node];
    Data vl = sub(fr, to, (node-n)*2+0, la, (la+ra)/2);
    Data vr = sub(fr, to, (node-n)*2+1, (la+ra)/2, ra);
    return Merge(vl, vr);
  }
  Data query(int fr, int to) { return sub(fr, to, 2*n-2, 0, n); }
};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n,k;
  cin>>n>>k;
  SegmentTree st(19);
  REP(i,n) {
    int a;
    cin>>a;
    int mn = max(0, a-k);
    int mx = min(300000, a+k);
    int val = st.query(mn, mx+1).num;
    st.update(a, val+1);
  }
  cout<<st.query(0, 300001).num<<endl;
  return 0;
}


Measured memory_bytes: 7440
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define PI acos(-1)
typedef  long long ll;
ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}
using namespace std;

int main(){
   int k,a,b;
   cin>>k>>a>>b;

   for(int i=a;i<=b;i++){
      if(i%k==0){
         cout<<"OK";
         return 0;

      }
      
   }
   cout<<"NG";

return 0;
}


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

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

  if (n[0] == n[2]) {
    std::cout << "Yes" << std::endl;
  } else {
    std::cout << "No" << std::endl;
  }

  return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
	static Scanner s=new Scanner(System.in);
	static int gInt(){
		return Integer.parseInt(s.next());
	}
	public static void main(String[]A){
		int n=gInt(),l=gInt();
		int[]a=new int[n];
		int start=-1;
		a[0]=gInt();
		for(int i=1;i<n;++i) {
			a[i]=gInt();
			if(start<0&&a[i]+a[i-1]>=l)
				start=i;
		}
		if(start<0) {
			System.out.println("Impossible");
			return;
		}
		System.out.println("Possible");
		for(int i=1;i<start;++i)
			System.out.println(i);
		for(int i=n-1;i>=start;--i)
			System.out.println(i);
	}
}


Measured memory_bytes: 49612
#include <iostream>
#include <cstring>
using namespace std;
int main(void) {
  int n;
  int page[51], first, last;
  bool flag[2] = {1, 1}, flag2;
  while(cin >> n, n) {
    memset(page, 0, sizeof(page));
    for(int i = 0 ; i < n ; i++) {
      cin >> page[i];
    }
    
    for(int i = 0 ; i < n ; i++) {

      if(page[i-1] + 1 != page[i] && page[i] + 1 != page[i+1]) {
	if(i != n-1) cout << page[i] << ' ';
	else cout << page[i];
      }

      if(page[i] + 1 == page[i+1]) {
	first = page[i];
	if(flag[0]) cout << first << '-';
	flag[0] = false;
	flag[1] = true;
      }
      
      if(page[i] + 1 != page[i+1]) {
	last = page[i];
	if(flag[1] && i != n-1) cout << last << ' ';
	else if(flag[1] && i == n-1) cout << last;
	flag[1] = false;
	flag[0] = true;
      }
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int n,i,j,a[100010],s,x;
int main()
{
    cin>>n;
    for(i=1;i<=n;i++)
        a[i]=999999999;
    for(i=1;i<n;i++)
    {
        cin>>x;
        a[i]=min(a[i],x);
        a[i+1]=min(a[i+1],x);
        s+=a[i];
    }
    cout<<s+a[n];
    return 0;
}



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

signed main()
{
    int a[200002], res=0;
    int n;
    cin>>n;
    for (int i=1; i<=n; i++) {cin>>a[i];}
    sort(a+1,a+n+1);
    for (int i=1; i<n; i++)
    {
        if (a[i]==a[i+1]) {cout<<"NO"; return 0;}
    }
    cout<<"YES";
}


Measured memory_bytes: 1792