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

#define dump(...) cout<<"# "<<#__VA_ARGS__<<'='<<(__VA_ARGS__)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	print_tuple<Cdr...>(os,t);
	os<<(sizeof...(Cdr)?",":"")<<get<sizeof...(Cdr)>(t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

int grundy(const vvi& g,int p,int u)
{
	int x=0;
	for(int v:g[u])
		if(v!=p)
			x^=grundy(g,u,v)+1;
	return x;
}

bool solve(const vvi& g)
{
	return grundy(g,-1,0);
}

int main()
{
	for(int n;cin>>n&&n;){
		vvi g(n);
		rep(i,n-1){
			int u,v; cin>>u>>v; u--,v--;
			g[u].push_back(v);
			g[v].push_back(u);
		}
		cout<<(solve(g)?"Alice":"Bob")<<endl;
	}
}


Measured memory_bytes: 11904
package main

import (
	"fmt"
)

func main() {
	var n, m, x int
	fmt.Scan(&n, &m, &x)

	listA := make([]int, m)
	for i := 0; i < m; i++ {
		fmt.Scan(&listA[i])
	}

	costP := 0
	costM := 0
	for i := 0; i < m; i++ {
		if listA[i] > x {
			costP++
		} else {
			costM++
		}
	}
	if costP < costM {
		fmt.Println(costP)
	} else {
		fmt.Println(costM)
	}

}


Measured memory_bytes: 512
#include <algorithm>
#include <iostream>
#include <vector>
#include <string> 
#include <set>
typedef long long ll;
using namespace std;

int arr[107];
const ll inf = 1000000001;

int main() {
    int x, n; cin >> x >> n;
    
    set<int>s;
    for (int i = 0; i < n; ++i) {
        int a; cin >> a;
        s.insert(a);
    }

    ll dif = inf;
    ll ans = inf;
    for (int i = -2000; i <= 2000; ++i) {
        if (s.count(i))
            continue;
        int di = abs(x - i);
        if (di < dif) {
            dif = abs(x - i);
            ans = i;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3560
S = str(input())
T = str(input())
S_dict = {}
T_dict = {}
S_dict[S[0]] = 1
T_dict[T[0]] = 1
for i in range(1, len(S)):
    s, t = S[i], T[i]
    if s in S_dict.keys():
        if t in T_dict.keys():
            if S_dict[s] == T_dict[t]:
                S_dict[s] += 1
                T_dict[t] += 1
            else:
                print('No')
                quit()
        else:
            print('No')
            quit()
    else:
        if t in T_dict.keys():
            print('No')
            quit()
        else:
            S_dict[s] = 1
            T_dict[t] = 1

if len(S_dict) == len(T_dict):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define INF 5000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main()
{
  ll N;
  cin >> N;
  vector<ll> A(N);
  for (ll i = 0; i < N; ++i) {
    cin >> A.at(i);
  }
  vector<vector<ll>> pos(N, vector<ll>(2, 0));
  for (ll i = 0; i < N; ++i) {
    if (i - A.at(i) >= 0) {
      pos.at(i - A.at(i)).at(1) += 1;
    }
    if (i + A.at(i) < N) {
      pos.at(i + A.at(i)).at(0) += 1;
    }
  }
  ll ans = 0;
  for (ll i = 0; i < N; ++i) {
    ans += pos.at(i).at(0) * pos.at(i).at(1);
  }
  cout << ans << "\n";
}


Measured memory_bytes: 15668
import collections
def solve(A):
    counter = collections.Counter()
    ans = 1
    for i, a in enumerate(A):
        c = counter[a] if a in counter else 0
        ans += i - c
        counter.update([a])
    return ans
#
# assert(solve("a") == 1)
# assert(solve("aa") == 1)
# assert(solve("ab") == 2)
# print(solve("aatt"))

if __name__ == "__main__":
    A = input()
    print(solve(A))


Measured memory_bytes: 3752
#include <bits/stdc++.h>
#define rep(i, a) for (ll i = 0; i < (a); ++i)
#define pb push_back
#define all(v) v.begin(),v.end()
#define sort_1(v) sort(v.begin(),v.end())
#define sort_2(v) sort(v.begin(),v.end(),greater<ll>())
typedef long long ll;
typedef long double la;
using namespace std;
 
int main(){
  int n,m;
  cin >> n >> m;
  vector<int> s(m);
  vector<char> c(m);

  rep(i,m) cin >> s[i] >> c[i];

  rep(i,1000){
    bool flag = true;
    string str = to_string(i);
    if(str.length() < n) continue;
    rep(j,m){
      if(str[s[j]-1] != c[j]) flag = false;
    }
    if(flag){
      cout << i << endl;
      return 0;
    }
  }
  cout << "-1" << endl;
}

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

int main () {
  int a, b, c;
  cin >> a >> b >> c;
  if (c <= a + b + 1) {
    cout << b + c << endl;
  }
  else {
    cout << a + 2*b + 1 << endl;
  }
}

    


Measured memory_bytes: 256
using System;

namespace Beginner101
{
    class Program
    {
        static void Main(string[] args)
        {
            var hoge = Console.ReadLine();
            var ans = 0;
            for(int i=0; i < hoge.Length; i++) {
                if (hoge[i] == '+') { ans++; }
                else ans--;
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 11092
n = int(input())
s = str(input())

a = ""
ans = 0
for i in range(n):
  a += s[i]
  while(len(a) > 0):
    if a in s[i+1:]:
      ans = max(ans,len(a))
      break
    else:
      a = a[1:]
print(ans)

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

int main() {
    int D, N;
    cin >> D >> N;

    int i     = 0;
    int count = 0;
    while (count<N) {
        i++;
        int now     = i;
        int waru100 = 0;
        while (now % 100 == 0) {
            now /= 100;
            waru100++;
        }
        if (waru100 == D) count++;
    }
    cout << i << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include<bits/stdc++.h>
#include <utility>

#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,a,b) for(int i = (a); (b) <= i; i--)
#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = n; n <= i; i--)
#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))
#define elif else if
#define MOD 1000000007
#define INF (1<<29)

using namespace std;
using ll = long long;
map <int ,int> mpa,mpb;
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> pque;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int N,M,X,Y;
  cin >> N >> M >> X >> Y;
  int x[N],y[M];
  for(int i=0;i<N;i++){
    cin >> x[i];
  }
  for(int i=0;i<M;i++){
    cin >> y[i];
  }
  bool flag =false;
  sort(x,x+N);
  sort(y,y+M);
  for(int Z=X+1;Z<=Y;Z++){
    if(x[N-1]<Z && Z<=y[0]){
      flag =true;
    }
  }
  if(flag){
    cout << "No War"<< endl;
  }else{
    cout << "War" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<cmath>
using namespace std;

const double PI = 3.14159265358979;

int main(){
    double a, b, x;
    cin >> a >> b >> x;
    double s = x / a;
    double ans;
    if (s > a * b / 2){
        double t = 2 * s / a - b;
        double theta = atan(a/(b-t));
        ans = 90 - theta * 180 / PI;
    }
    else{
        double t = 2*s/b;
        double theta = atan(t/b);
        ans = 90 - theta * 180 / PI;
    }
    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}

Measured memory_bytes: 3464
import math
import collections
import itertools
import copy

def YesNo(Bool):
    if(Bool):
        print("YES")
    else:
        print("NO")
    return

def resolve():

    N=int(input())
    p=list(map(int,input().split()))
    ans=False

    tmp=copy.deepcopy(p)
    isOK=True
    for k in range(N-1):
        if(tmp[k]>=tmp[k+1]):
            isOK=False
    if(isOK):
        ans=True

    for i in range(N):
        for j in range(i+1,N):
            tmp=[]
            tmp=copy.deepcopy(p)
            tmp[i],tmp[j]=tmp[j],tmp[i]
            isOK=True
            for k in range(N-1):
                if(tmp[k]>=tmp[k+1]):
                    isOK=False
            if(isOK):
                ans=True
    YesNo(ans)

resolve()


Measured memory_bytes: 9544
n = int(input())
a = list(map(int, input().split()))
q = int(input())
xy = [map(int, input().split()) for _ in range(q)]
b, c = [list(i) for i in zip(*xy)]

ans = 0

sum_all = 0
for cnt in range(n):
    sum_all += a[cnt]

a = sorted(a)
list_a_num = [0]*(10**5 + 1)
for cnt in range(n):
    list_a_num[a[cnt]] += 1

for cnt in range(q):
    sum_all += (c[cnt] - b[cnt]) * list_a_num[b[cnt]]
    list_a_num[c[cnt]] += list_a_num[b[cnt]]
    list_a_num[b[cnt]] = 0
    print(sum_all)


Measured memory_bytes: 67052
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
char a[20],b[20];
inline bool check()
{
	int n=strlen(a);
	for(int i=0;i<n;++i)
	if(a[i]!=b[i])return 0;
	return 1;
}
int main()
{
	scanf("%s",a);
	scanf("%s",b);
	if(strlen(a)+1==strlen(b) && check())puts("Yes");
	else puts("No");
}

Measured memory_bytes: 3768
#include <stdio.h>
#include <string.h>
//#include<iostream.h>
int main(){
long	long int n,t,i,len,j,l;
	
	scanf("%lld",&t);

		scanf("%lld",&n);
		l=t+n;
		if(l%2==0)
		printf("%lld\n",l/2);
		else
		printf("IMPOSSIBLE\n");
	
	}

Measured memory_bytes: 128
inf = float("inf")
H, W = map(int, input().split())
ans = min(W, H)
if H % 3 == 0 or W % 3 == 0:
    print(0)
    exit()
for i in range(1, W):
    s = [H * i, H // 2 * (W - i), (H + 1) // 2 * (W - i)]
    ans = min(ans, abs(max(s) - min(s)))
for j in range(1, H):
    s = [W * j, W // 2 * (H - j), (W + 1) // 2 * (H - j)]
    ans = min(ans, abs(max(s) - min(s)))
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a;i<(int)b;++i)
int main(){
    string s;cin>>s;
    rep(i,s.size())if((i+1)%2==1)cout<<s[i];
    cout<<endl;
    return 0;
}

Measured memory_bytes: 512
#include<cstdio>
#include<bits/stdc++.h>
typedef long long int ll;
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR_IN(i, a, b) for(int i = (a); i < (b); i++)
#define BETWEEN(x, a, b) ((x) >= (a) && (x) <= (b))
#define BIT(b, i) (((b) >> (i)) & 1)
#define LOG_F 1
#define LOG(...) if(LOG_F) fprintf(stderr, __VA_ARGS__)

using namespace std;

ll pow(int x, int n){
  return n == 0 ? 1 : x * pow(x, n - 1);
}


/*
x a b

x limit
a syoumikigen - a
b tabeta
 */
int x,a,b;
int main(){
  cin>>x>>a>>b;
  if(b <= a){
    cout<<"delicious\n";
  } else if(b-a <= x){
    cout << "safe\n";
  } else
    cout<<"dangerous\n";

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<sstream>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
#define mod 1000000007
#define all(v) v.begin(),v.end()
#define loop(i,a,b) for(i=(int)a;i<(int)b;i++)
#define revloop(i,a,b) for(i=(int)a;i>=(int)b;i--)
#define stloop(it,v) for(it=v.begin();it!=v.end();++it)
#define ii pair<int,int>
#define MP make_pair
#define pb push_back
#define f first
#define s second
#define ll long long int
#define PI acos(-1.0)
#define rs resize
ll comb[55][55];
void co(ll n)
{
 for(ll i=0;i<=n;i++)
  for(ll j=0;j<=i;j++)
  {
   if(j==0 || j==i)
    comb[i][j]=1;
   else
    comb[i][j]=comb[i-1][j-1]+comb[i-1][j];
  }
}
bool cmp(double a,double b)
{
  return a>b;
}
int main()
{  std::ios::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
   ll n,b,i,a;
   cin>>n>>a>>b;
   double v[n],avg=0.0;
   loop(i,0,n)
    cin>>v[i];
   sort(v,v+n,cmp);
   loop(i,0,a)
    avg+=v[i];
   avg=avg/a;
   co(n);
   ll num=0,pos=0,cnt=0;
   loop(i,0,n)
    if(v[i]==v[a-1])
    {
     num++;
     if(i<a)
      pos++;
    }
   if(pos==a)
   {
    for(i=a;i<=b;i++)
     cnt+=comb[num][i];
   }
   else
    cnt+=comb[num][pos];
   cout<<setprecision(10)<<fixed<<avg<<endl<<cnt;
   return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<deque>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<iterator>
#include<complex>
#include<stack>
#include "stdio.h"
using namespace std;

#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)

using ll = long long;
using Pii = pair<int, int>;

const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const long long mod_const = 1e9+7;

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

using MIte = multimap<long, long, greater<long> >::iterator;



//1730
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	// long long?
	long long N, M;
	cin >> N >> M;

	vector<int> vK(N, 0);
	vector<int> vLike(M, 1);
	rep(i, N) {
		cin >> vK[i];
		vector<int> vLiketmp(M, 0);
		rep(j, vK[i]) {
			int tmp = 0;
			cin >> tmp;
			tmp--;
			vLiketmp[tmp] = 1;
		}
		rep(k, M) {
			vLike[k] = (vLiketmp[k] == 0) ? 0 : vLike[k];
		}
	}

	int cnt = 0;
	rep(i, M) {
		cnt = (vLike[i] == 1) ? cnt + 1 : cnt;
	}

	cout << cnt << endl;
	return 0;

}

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

int main()
{
	int X;
	int maxv = 1;
	cin >> X;

	for ( int i = 2; i <= X; i++ ) {
		int g = i * i;
		while ( g <= X ) {
			maxv = max(maxv , g);
			g *= i;
		}
	}

	cout << maxv << endl;

	return (0);
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <iomanip>

#include <map>
#include <set>
#include <queue>
#include <stack>

#define ALL(a) (a).begin(),(a).end()
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define vint vector<int>
#define vdbl vector<double>
#define vstr vector<string>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

	int N;
	cin >> N;

	ll A[N];
	rep(i,N) cin >> A[i];

	ll asum = 0;
	ll isum = 0;
	rep(i,N){
		 asum += A[i];
		 isum += i+1;
	}

	if(asum % isum != 0){
		cout << "NO" << endl;
		return 0;
	}

	// 1,2,3, ...,N-1,N,1　の間隔は1,1, ...,1,-(N-1)
	// 最終的な間隔もその足し合わせ合わせでできているかをチェックする
	//　間隔はすべてを-1した0,0,0, ..., -Nの足し合わせをチェックするのが簡単
	ll k = asum / isum;

	ll b[N];
	rep(i,N-1) b[i] = A[i+1] - A[i] - k;
	b[N-1] = A[0] - A[N-1] - k;

	rep(i,N){
		if(b[i] > 0){
			cout << "NO" << endl;
			return 0;
		}

		if(b[i] % N != 0){
			cout << "NO" << endl;
			return 0;
		}
	}
	
	cout << "YES" << endl;
}

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

using namespace std;

int main()
{
  int64_t n, x;
  cin >> n >> x;
  vector<int64_t> v;
  for (auto i = 0; i < n; i++) {
    int64_t a;
    cin >> a;
    v.push_back(a);
  }
  sort(begin(v), end(v));
  int64_t child = 0;
  for (auto i = 0; i < n; i++) {
    if (v[i] == x) {
      child++;
      x = 0;
      break;
    }
    if (v[i] < x) {
      child++;
      x -= v[i];
    } else {
      child++;
      break;
    }
  }
  if (child != 0 && x != 0) child--;
  cout << child << endl;
  return 0;
}


Measured memory_bytes: 888
#include <algorithm>
#include <iostream>
#include <queue>
#include <string>
#include <map>
#include <vector>
#include <ctype.h>
using namespace std;

#define REP(i, n) for(int i = 0; i < n; i++)
typedef vector<int> vi;
typedef vector<vector<int>> vvi;

int i, j, k;

int main(){

    int K, N; 
    string S;

    cin >> N >> K;
    cin >> S;

    S[K-1] = tolower(S[K-1]);

    cout << S;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 2002
using namespace std;
typedef long long ll;
const int mod=1e9+7;
int n,k;
ll dp[N][N],jie[N*N],ni[N*N];
inline ll rd(){
    ll x=0;char c=getchar();bool f=0;
    while(!isdigit(c)){if(c=='-')f=1;c=getchar();}
    while(isdigit(c)){x=(x<<1)+(x<<3)+(c^48);c=getchar();}
    return f?-x:x;
}
inline ll power(ll x,ll y){
    ll ans=1;
    while(y){
        if(y&1)ans=ans*x%mod;
        x=x*x%mod;
        y>>=1;
    }
    return ans;
}
inline ll C(int n,int m){return jie[n]*ni[m]%mod*ni[n-m]%mod;}
int main(){
    n=rd();k=rd();
    if(k==1){puts("1");return 0;}
    int x=n*k;
    jie[0]=1;
    for(int i=1;i<=x;++i)jie[i]=jie[i-1]*i%mod;
    ni[x]=power(jie[x],mod-2);
    for(int i=x-1;i>=0;--i)ni[i]=ni[i+1]*(i+1)%mod;
    dp[0][0]=1;
    for(int i=1;i<=n;++i){
        dp[i][0]=1;
        for(int j=1;j<=i;++j){
            dp[i][j]=(dp[i-1][j]+dp[i][j-1]*(n-j+1)%mod*C(n*k-(j-1)*(k-1)-i-1,k-2))%mod;
        }
    }
    cout<<dp[n][n];
    return 0;
}

Measured memory_bytes: 94208
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdlib>
#define rep(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
using namespace std;
int V, E, st, gl;//頂点数、辺数、始点、終点
#define E_M 401 
#define V_M 41
char INF[2000];
struct edge{
	int from, to;
	char label[2000];
};
edge es[E_M];
char d[V_M][2000];

//aにbをコピー
void cp(char *a, char *b){
	int p = 0;
	while (b[p] != '\0'){
		a[p] = b[p];
		 p++;
		 if (p >= 800)break;
	}
	a[p] = '\0';
}
//aにx->y連結をコピー
void connect_str(char a[], char x[], char y[]){
	int p=0, q=0;
	while (x[p] != '\0'){
		a[p] = x[p], p++;
		if (p >= 1800)break;
	}
	while (y[q] != '\0'){
		a[p] = y[q], q++, p++;
		if (p >=1800)break;
	}
	a[p] = '\0';
}


bool shortest(int s,int g){
	rep(i, 0, V)cp(d[i], INF);
	d[g][0] = '\0';
	rep(i, 0, 2*V*6+1){
		rep(j, 0, E){
			edge e = es[j];
			//cout << d[e.to] << endl;
			if (strcmp(d[e.to], INF) >= 0)continue;
			char target[2000] = { 0 };
			connect_str(target, e.label, d[e.to]);
			if ((strcmp(d[e.from], target) >0)){
			//	cout << d[e.to] << endl;
				cp(d[e.from], target);
				if (i == 2*6*V+1)return(true);
			}
		}
	}
	return(false);
}

int main(void){

	rep(i, 0, 400)INF[i] = 'z';
	INF[400] = '\0';
	while (true){
		cin >> V >> E >> st >> gl;
		if (V == 0)return(0);
		rep(i, 0, E)
			cin >> es[i].from >> es[i].to >> es[i].label;
		
		if (shortest(st, gl) || strcmp(d[st], INF) >= 0 || strlen(d[st])>6*(V-1))cout << "NO" << endl;
		else cout << d[st] << endl;
	}
}
	

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

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

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        
        String s = br.readLine();
        List<String> days = Arrays.asList("SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT");
        
        out.println(7 - days.indexOf(s));
        
        out.close();
        
    }
}

Measured memory_bytes: 32776
k = int(input())
l = ['1','2','3','4','5','6','7','8','9']
lf = l.copy()
sum = 9
while sum < k:
    lff = []
    for i in lf:
        if i[-1] == '0':
            lff.append(i+'0')
            lff.append(i+'1')
        elif i[-1] == '9':
            lff.append(i+'8')
            lff.append(i+'9')
        else:
            lff.append(i+str(int(i[-1])-1))
            lff.append(i+str(int(i[-1])))
            lff.append(i+str(int(i[-1])+1))
    lf = lff
    l += lff
    sum += len(lff)
print(int(l[k-1]))

Measured memory_bytes: 18296
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CSharp_AtCoder
{

    class Program
    {


        static void Main(string[] args)
        {
            int[] NM = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            int N = NM[0];
            int M = NM[1];

            Dictionary<int, int>[] prefs = new Dictionary<int, int>[N];
            int[] city_to_pref = new int[M];
            string[] id = new string[M];
            for (int i = 0; i < N; i++) prefs[i] = new Dictionary<int, int>();
            for(int city_num = 0; city_num < M; city_num++)
            {
                int[] PY = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
                int pref_num = PY[0] - 1;
                int year = PY[1];

                city_to_pref[city_num] = pref_num; 
                prefs[pref_num][city_num] = year;

            }

            for (int pref_num = 0; pref_num < N; pref_num++)
            {
                // yearで昇順                
                int cnt = 1;
                foreach(var city_to_year in prefs[pref_num].OrderBy(x => x.Value))
                {
                    int city_num = city_to_year.Key;
                    int city_year = city_to_year.Value;

                    //city_numのidを求める
                    //pref_num(6) + cnt(6)
                    string left = (pref_num + 1).ToString();
                    int left_l = left.Length;
                    for (int i = 0; i < 6 - left_l; i++) left = "0" + left;
                    string right = cnt.ToString();
                    int right_l = right.Length;
                    for (int i = 0; i < 6 - right_l; i++) right = "0" + right;

                    id[city_num] = left + right;

                    cnt++;
                }
            }


            Console.WriteLine(string.Join("\n", id));

        }
    }
}


Measured memory_bytes: 49272
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
 
int main()
{int N;
cin>>N;
int W[N];
for(int k=0;k<N;k++)
  cin>>W[k];
int i=0,j=N-1;
int temp=0;
int s1=W[i],s2=W[j];
while(i!=j&&i<N&&j>0)
{if(temp==1)
  s1+=W[i];
if(temp==2)
  s2+=W[j];
if(s1<s2)
  {i=i+1;
   temp=1;
  }
else
  {j=j-1;
   temp=2;
  }
}

cout<<abs(s2-s1);
}

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

using namespace std;

const int M=26;

int arr[404];
int n;
int c[26];
int s[404][26];
int las[26];

long long calc()
{
	for(int i=0;i<M;i++) las[i]=0;
	long long ans=0;
	for(int i=0;i<n;i++)
	{
		las[arr[i]-1]=i+1;
		ans+=s[i][arr[i]-1];
		for(int j=0;j<M;j++)
			ans-=c[j]*(i+1-las[j]);
		//cout << ans << endl;
	}
	return ans;
}

long long calcs(vector<int> v,int st)
{
	vector<int> lass;
	for(int i=0;i<M;i++)
		lass.push_back(las[i]);
	long long res=0;
	for(int i=0;i<v.size();i++)
	{
		lass[v[i]]=st+i;
		res+=s[st+i-1][v[i]];
		for(int j=0;j<M;j++)
			res-=c[j]*(st+i-lass[j]);
	}
	return res;
}

int main()
{
	//auto start = std::chrono::system_clock::now();
	mt19937 rng(12342);
	cin >> n;
	for(int i=0;i<M;i++) cin >> c[i];
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<M;j++) cin >> s[i][j];
	}
	for(int i=0;i<n;i+=3)
	{
		vector<int> v={0,0,0};
		long long best=calcs(v,1+i);
		arr[i]=1; arr[i+1]=1; arr[i+2]=1;
		for(int x=0;x<26;x++)
		{
			for(int y=0;y<26;y++)
			{
				for(int z=0;z<26;z++)
				{
					v[0]=x;
					v[1]=y;
					v[2]=z;
					long curs=calcs(v,1+i);
					if(curs>best)
					{
						best=curs;
						arr[i]=v[0]+1; arr[i+1]=v[1]+1; arr[i+2]=v[2]+1;
					}
				}
			}
		}
		for(int j=0;j<v.size();j++)
		{
			las[arr[i+j]-1]=i+j+1;
		}
	}
	//std::chrono::duration<double> elp=std::chrono::system_clock::now()-start;
	int t=1000;
	long long curs=calc();
	while(t--)
	{
		int x=uniform_int_distribution<int>(0, n-1)(rng);
		int y=uniform_int_distribution<int>(0, M-1)(rng);
		int oldx=arr[x];
		arr[x]=y+1;
		if(calc()<curs)
		{
			arr[x]=oldx;
		}
	}
	for(int i=0;i<n;i++)
		cout << arr[i] << endl;
}

Measured memory_bytes: 3680
#include <stdio.h>
#include <stdlib.h>

#define TRUE 1
#define FALSE 0

int reachable(int t_b, int x_b, int y_b,
	int t_a, int x_a, int y_a) {
	int dt = t_a - t_b, dx = abs(x_a - x_b), dy = abs(y_a - y_b);
	if (dt % 2 != (dx % 2 + dy % 2) % 2 ) {
		return FALSE;
	}
	if (dx + dy > dt) {
		return FALSE;
	}
	return TRUE;
}

int main(void) {
	int x_before = 0, y_before = 0, t_before = 0, n, sw,
		x_after, y_after, t_after;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d %d %d", &t_after, &x_after, &y_after);
		sw = reachable(t_before, x_before, y_before,
			t_after, x_after, y_after);
		if (sw) {
			t_before = t_after;
			x_before = x_after;
			y_before = y_after;
		}
		else if (!sw) {
			break;
		}
	}
	if (sw) {
		printf("Yes\n");
	}
	else if (!sw) {
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
n = int(input())
a = list(map(int, input().split()))

d1 = [abs(a[0])]
d2 = [abs(a[1])]
for i in range(1, n):
    d1.append(abs(a[i] - a[i - 1]))
d1.append(abs(a[-1]))
s = sum(d1)
for i in range(2, n):
    d2.append(abs(a[i] - a[i - 2]))
d2.append(abs(a[-2]))

for i in range(n):
    print(s - d1[i] - d1[i + 1] + d2[i])

Measured memory_bytes: 58732
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <set>
#include <string>
#include <cstring>
#include <cmath>
#include <map>
#include <stack>
#define N 1005
using namespace std;
typedef long long ll;
char s[105];
int main()
{
    int a[10];
    int n,sum=0;
    memset(a,0,sizeof(a));
    scanf("%d",&n);
    /*getchar();
    gets(s);
    int len=strlen(s);*/
    for(int i=1; i<=n*2-1; i++)
    {
        scanf("%c",&s[i]);
        if(s[i]=='P')
            a[1]=1;
        if(s[i]=='W')
            a[2]=1;
        if(s[i]=='G')
            a[3]=1;
        if(s[i]=='Y')
            a[4]=1;

    }
    for(int i=1;i<=4;i++)
        if(a[i]==1)
        sum++;

    if(sum==3)
        printf("Three\n");
        else
        printf("Four\n");

}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const ll INFLL = 1001001001001001001;  // > 10^18
const int MOD = (int)1e9 + 7;
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;

int main () {
    
    string s; cin >>s;

    string t = "";
    for (int i = 0; i < s.length(); i++) {
        if (i % 2 == 0) {
            t = t + s[i];
        } 
    }
    
    cout << t << endl;
    return 0;
}



Measured memory_bytes: 640
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        boolean b = true;
        String s = sc.next();
        for (int i=0;i<s.length();i++){
            if ((i%2==0&&s.charAt(i)=='L')||(i%2==1&&s.charAt(i)=='R'))b=false;
        }
        if (b)System.out.println("Yes");
        else System.out.println("No");
    }
}


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

bool isPalindromicNumber(int num);
int getOneOfPlaces(int num);
int getTenOfPlaces(int num);
int getThousandsOfPlaces(int num);
int getTenThousandsOfPlaces(int num);

int main(void){
    int A, B, counter, currentNumber;
    cin >> A >> B;

    currentNumber = A;
    counter = 0;
    while(currentNumber <= B){
        if(isPalindromicNumber(currentNumber)){
            counter++;
        }
        currentNumber++;
    }
    cout << counter << endl;
}

bool isPalindromicNumber(int num){
    if((getOneOfPlaces(num)==getTenThousandsOfPlaces(num)) && getTenOfPlaces(num)==getThousandsOfPlaces(num)){
            return true;
    }
    else{
        return false;
    }
}

int getOneOfPlaces(int num){
    return num%10;
}

int getTenOfPlaces(int num){
    return (num%100 - num%10) / 10;
}

int getThousandsOfPlaces(int num){
    return (num%10000 - num%1000) / 1000;
}

int getTenThousandsOfPlaces(int num){
    return (num - num%10000) / 10000;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.math.*;
 
 
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main{ 
 
 
    static long mod=1000000007;
    static int dx[]={1,-1,0,0};
    static int dy[]={0,0,1,-1};
    // static int dx[]={1,-1,0,0,1,1,-1,-1};
    // static int dy[]={0,0,1,-1,1,-1,1,-1};
    // PriorityQueue<Integer> que = new PriorityQueue<Integer>(); 
    //HashMap<Integer,Integer> map = new HashMap<Integer,Integer>();
 
    public  static void main(String[] args)   throws Exception, IOException{
     
        
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);
     
        int n=sc.nextInt();
        // long n=sc.nextLong();
        // char c[][] = new char[h][w];
        // long a[] = new long [n];
        // for (int i=0; i<n; i++ ) {a[i]=sc.nextInt();}
        long ans=0;
        int d[] = new int[n];

        for (int i=0 ; i < n; i++) {
            d[i] = sc.nextInt();
        }
        sort(d);
        // db(d);
        for (int i=0 ; i < n; i++) {
            int x=d[i],c=0;
            // db(x,i);
            while(i<n && d[i]==x){
                c++;
                i++;
            }
            if(x<c){ans+=c-x;}
            else if(c<x)ans += c ;
            i--;
        }
        
        out.println(ans);
        out.flush();
    }

     
    static void db(Object... os){
     
        System.err.println(Arrays.deepToString(os));
     
    }
     
    static boolean validpos(int x,int y,int r, int c){
        
        return x<r && 0<=x && y<c && 0<=y;
        
    }
     
    static boolean bit(long x,int k){
        // weather k-th bit (from right) be one or zero
        return  ( 0 < ( (x>>k) & 1 )  )  ? true:false;
    }    
}

class XY {
    int x,y,d;
    XY(int x, int y, int d) {
        this.x=x;
        this.y=y;
        this.d=d;
    } 
}
 
class P implements Comparable<P>{
    int x,y;
    P(int x, int y) {
        this.x=x;
        this.y=y;
    } 
      
    public int compareTo(P p){
        return -x + p.x;//des
    } 
}
 
class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}

Measured memory_bytes: 40088
import java.util.Map.Entry;
import java.util.*;
import java.math.*;
import org.w3c.dom.css.Counter;
  
public class Main{
    public static void main(final String[] args){
 
        final Scanner sc = new Scanner(System.in);

       for(int i = 1;i<=5;i++){
        if(sc.nextInt()==0){
            System.out.println(i);
        };
    
       }
        /*  int N =sc.nextInt();
        int K =sc.nextInt();
        Map<Integer,Integer> numMap = new HashMap<>();
        Map<Integer,Integer> newMap = new HashMap<>();
        Map<Integer,Integer> hogeMap = new HashMap<>();
        if(N>41){

        }
        for(int i =1;i<=N;i++){
            numMap.put(i, sc.nextInt());
            newMap.put(i,0);
            hogeMap.put(i,0);
        }
        for(int i= 0;i<K;i++){
            //newMap =  numMap;

            for(int i2= 1; i2<=N;i2++){

                    for(int i4 =0 ;i4 <=numMap.get(i2)&&i4+i2<=N;i4++){
                        newMap.replace(i2+i4, newMap.get(i2+i4)+1);
                        if(i4<i2&&i4 != 0){
                            newMap.replace(i2-i4, newMap.get(i2-i4)+1);
                        }
                    }
   /*                  for(int i4 =1 ;i4<i2&&i4<=numMap.get(i2);i4++){
                        newMap.replace(i2-i4, newMap.get(i2-i4)+1);
                    } */
                }
} 

Measured memory_bytes: 35712
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <time.h>
#define ll long long
#define double long double
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl;
#define COYE cout<<"YES"<<endl;
#define COYe cout<<"Yes"<<endl;
#define COye cout<<"yes"<<endl;
#define CONO cout<<"NO"<<endl;
#define CONo cout<<"No"<<endl;
#define COno cout<<"no"<<endl;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define ALL(V) ((V).begin(),(V).end())
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
const int vx[4]={0,1,0,-1},vy[4]={1,0,-1,0};
using namespace std;

int main(){
  ll N,K,ans=INF;
  cin>>N>>K;
  
  ll A[N],DIV[N],t=0;
  REP(i,N) cin>>A[i];
  
  for(int bit=0; bit<(1<<N); ++bit){
    vector<int> S;
    for(int i=0; i<N; ++i){
      DIV[i]=0;
      if(bit&(1<<i)){
        S.push_back(A[i]);
        DIV[i]=1;
        if(S.size()==1) t=i;
      }
    }
    
    if(S.size()==K){
      ll cnt=0,mx=A[0];
      
      for(int i=1; i<N; ++i){
        if(DIV[i]==1){
          if(mx>=A[i]){
            cnt+=mx-A[i]+1;
            mx+=1;
          }
          else mx=A[i];
        }
        chmax(mx,A[i]);
      }
      chmin(ans,cnt);
    }
  }
  
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

enum HinaArareColor {
    PINK,
    WHITE,
    GREEN,
    YELLOW,
    NUM_OF_HINA_ARARE_COLORS
};
    
 
int main() {
    int numOfArares = 0;
    std::cin >> numOfArares;
    char* hinaArareBag = new char[numOfArares];
    
    bool hinaArareColors[NUM_OF_HINA_ARARE_COLORS] = {false, false, false, false};
    int numOfColors = 0;
    for (int i = 0; i < numOfArares; i++) {
        std::cin >> hinaArareBag[i];
        switch (hinaArareBag[i]) {
            case 'P':
                hinaArareColors[PINK] = true;
                break;
            case 'W':
                hinaArareColors[WHITE] = true;
                break;
            case 'G':
                hinaArareColors[GREEN] = true;
                break;
            case 'Y':
                hinaArareColors[YELLOW] = true;
                break;
        }
        numOfColors = 0;
        for (int indexOfColor = 0; indexOfColor < NUM_OF_HINA_ARARE_COLORS; indexOfColor++) {
            if (hinaArareColors[indexOfColor]) {
                numOfColors++;
            }
        }
        if (numOfColors == NUM_OF_HINA_ARARE_COLORS) {
            break;
        }
    }
    if (numOfColors == 3) {
        std::cout << "Three" << std::endl;
    } else if (numOfColors == 4) {
        std::cout << "Four" << std::endl;
    }
    
    delete[] hinaArareBag;
}

Measured memory_bytes: 3004
def main():
    import sys
    input = sys.stdin.readline
    n,m = map(int,input().split())
    l = list(map(int,input().split()))
    dp = [0]+ [100000000000]*(n-1)

    for i in range(1,n):
        
        for j in range(1,m+1):
            if i-j >= 0:
                dp[i] = min(dp[i],dp[i-j]+abs(l[i]-l[i-j]))
        
    print(dp[n-1])

if __name__ == "__main__":
    main()    

Measured memory_bytes: 52444
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


signed main() {
    int N, A, B;
    cin >> N >> A >> B;
    vi X(N);
    rep(i, N) cin >> X[i];

    int prev = X[0];
    int res = 0;
    FOR(i, 1, N) {
        if((X[i]-prev)*A > B) res += B;
        else res += (X[i]-prev)*A;
        prev = X[i];
    }

    cout << res << endl;
    
    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
int main()
{
	int n,a[5000];
	while(1){
		int max=-100001;
		scanf("%d",&n);
		if(n==0)
			break;
		for(int i=0;i<n;i++)
			scanf("%d",&a[i]);
		for(int i=0;i<n;i++){
			int sum=0;
			for(int j=i;j<n;j++){
				sum+=a[j];
				if(max<sum)
					max=sum;
			}
		}
		printf("%d\n",max);
	}
	return 0;
}

Measured memory_bytes: 1044
#include <bits/stdc++.h>
using namespace std;
//make_tuple emplace_back next_permutation push_back make_pair second first setprecision

#if MYDEBUG
#include "lib/cp_debug.h"
#else
#define DBG(...) ;
#endif

using LL = long long;
constexpr LL LINF=334ll<<53;
constexpr int INF=15<<26;
constexpr LL  MOD=1E9+7;


struct Problem{
    int n,m;
    vector<vector<LL>> gmat;
    Problem(LL n):n(n),gmat(n,vector<LL>(n,LINF)){};

    void solve(){
        cin >> m;
        for(int i=0; i<m; ++i){
            int a,b;LL c;
            cin >> a >>b >> c;
            --a;--b;
            gmat[a][b]=-c;
        }
        for(int i=0; i<n; ++i){
            gmat[i][i]=0;
        }
        for(int k=0; k<n; ++k){
            for(int i=0; i<n; ++i){
                for(int j=0; j<n; ++j){
                    gmat[i][j]=min(gmat[i][j],gmat[i][k]+gmat[k][j]);
                }
            }
        }
        for(int i=0; i<n; ++i){
            if(gmat[i][i]<0 and gmat[0][i]<1e17 and gmat[i][n-1]<1e17){
                cout << "inf"<<"\n"; exit(0);
            }
        }
        cout << -gmat[0][n-1] <<"\n";
    }
};

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    long long n=0;
    cin >> n;
    Problem p(n);
    p.solve();
    return 0;
}



Measured memory_bytes: 8064
from math import factorial as f

n, m = map(int, input().split())

if n == m:
    print((f(n) ** 2 * 2) % (10 ** 9 + 7))
elif abs(n - m) == 1:
    print((f(n) * f(m)) % (10 ** 9 + 7)) 
else:
    print(0)

Measured memory_bytes: 10952
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip>
using namespace std;
#define int long long

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

    int n; cin >> n;
    int a,b;

    for(int i = 1;i <= sqrt(n);i ++){
        if(n % i == 0){
            a = i;
            b = n / i;
        }
    }

    int ans = 0;
    while(b > 0){
        b /= 10;
        ans ++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3704
import java.util.*;
    
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 D = sc.nextInt();
    int ans = Math.max(0,Math.min(B,D) - Math.max(A,C));
    System.out.println(ans);
  }
}


Measured memory_bytes: 21204
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int a,b,c;
  cin>>a>>b>>c;
  int dp[n+1][3];
  dp[1][0]=a;
  dp[1][1]=b;
  dp[1][2]=c;
  for(int i=2;i<=n;i++)
  {
    int a1,b1,c1;
    cin>>a1>>b1>>c1;
    dp[i][0]=a1+max(dp[i-1][1],dp[i-1][2]);
      dp[i][1]=b1+max(dp[i-1][0],dp[i-1][2]);
      dp[i][2]=c1+max(dp[i-1][1],dp[i-1][0]);
  }
  cout<<max(dp[n][0],max(dp[n][1],dp[n][2]));
  return 0;
}


Measured memory_bytes: 1408
k = int(input())
a = [7 % k]
if 7 % k == 0:
    print(1)
    exit()
for i in range(1,k):
    tmp = (a[-1] * 10 +7) % k
    if tmp == 0:
        print(i+1)
        exit()
    else:
        a.append(tmp)
print('-1')

Measured memory_bytes: 140664
N,A,B=map(int,input().split())
S=input()
a=0
b=0
for i in range(N):
    if S[i]=="c":
        print("No")
    elif S[i]=="a":
        if (a+b)<(A+B):
            print("Yes")
            a+=1
        else:
            print("No")
    elif S[i]=="b":
        if (a+b)<(A+B) and b+1<=B:
            print("Yes")
            b+=1
        else:
            print("No")

Measured memory_bytes: 4016
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		final int D = sc.nextInt();
		final int N = sc.nextInt();
		
		int[] ondo = new int[D];
		int[] hade = new int[N];
		
		boolean[][] ok = new boolean[D][N];
		int[][] dp = new int[D][N];
		
		for(int i = 0; i < D; i++){
			ondo[i] = sc.nextInt();
		}
		
		for(int i = 0; i < N; i++){
			final int A = sc.nextInt();
			final int B = sc.nextInt();
			final int C = sc.nextInt();
			
			hade[i] = C;
			
			for(int j = 0; j < D; j++){
				if(ondo[j] >= A && ondo[j] <= B){
					ok[j][i] = true;
				}
			}
		}
		
		int max = 0;
		for(int i = 0; i < D - 1; i++){
			for(int j = 0; j < N; j++){
				if(!ok[i][j]){
					continue;
				}
				
				for(int k = 0; k < N; k++){
					if(!ok[i+1][k]){
						continue;
					}
					
					dp[i+1][k] = Math.max(dp[i+1][k], dp[i][j] + Math.abs(hade[j] - hade[k]));
					max = Math.max(dp[i+1][k], max);
				}
			}
		}
		
		System.out.println(max);
	}

}

Measured memory_bytes: 22432
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
xyh = [None]*n
for i in range(n):
    x,y,h = map(int, input().split())
    xyh[i] = (x,y,h)
ans = []
bx,by,bh = max(xyh, key=lambda p: p[2])
for i in range(101):
    for j in range(101):
        H = bh + abs(bx-i) + abs(by-j)
        bad = False
        for x,y,h in xyh:
            if max(0, H - abs(x-i) - abs(y-j))!=h:
                bad = True
                break
        if bad:
            pass
        else:
            ans = (i,j,H)
            break
    if not bad:
        break
print(" ".join(map(str, ans)))

Measured memory_bytes: 73404
#include <bits/stdc++.h>
 
using namespace std;
 
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fileio freopen("in.in", "r", stdin),freopen("out.out", "w", stdout);
#define ll int
#define FF first
#define SS second
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define pss printf
#define MOD 1000000007
#define INF 1e18
#define eps 0.00001
#define endl '\n'
#define debug(n1) cout<<n1<<endl
ll n,a[2000005];
multiset<ll>f[2000005];
int main()
{
	SPEED;
	cin>>n;
	for(int i=0;i<(1<<n);i++)
		cin>>a[i],f[i].insert(a[i]);
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<(1<<n);j++)
		{
			if((j&(1<<i)))
			{
				for(auto h:f[(j^(1<<i))])
					f[j].insert(h);
				while(f[j].size()>2)
					f[j].erase(f[j].begin());
			}
		}
	}
	ll an=0;
	for(int i=1;i<(1<<n);i++)
	{
		auto j=f[i].begin();
		ll x,y;
		x=*j;
		j++;
		y=*j;
		an=max(an,x+y);
		cout<<an<<endl;
	}
	return 0;
}

Measured memory_bytes: 123904
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n;
  cin >> n;
  vector<vector<long int>> d(10, vector<long int>(10));
  for(int i = 1; i <= n; i++){
    int x = i;
    while(x >= 10) x/=10;
    d[x][i%10]++;
  }
  long int ans=0;
  for(int i = 0; i < 10; i++){
    for(int j = 0; j < 10; j++){
      ans+=d[i][j]*d[j][i];
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll h,w;
ll direction2[4][2]={{1,0},{0,1},{0,-1},{-1,0}};
bool valid(int a,int b)
{
    if(a>=1&&a<=h&&b>=1&&b<=w)return true;
    else return false;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,x;
    cin>>n;x=n;
    ll i=0;
    while(n>0){
        i+=(n%10);n/=10;
    }
    (x%i==0)?cout<<"Yes":cout<<"No";
}


Measured memory_bytes: 3508
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> P3;
typedef pair<P ,P> PP;
constexpr ll MOD = ll(1e9) + 7;
constexpr int IINF = INT_MAX;
constexpr ll LLINF = LLONG_MAX;
constexpr int MAX_N = int(2e5) + 5;
constexpr double EPS = 1e-9;
constexpr int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i > 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()

ll factrial[MAX_N], inverse[MAX_N];  //階乗と逆元を保持

ll mod_power(ll x, ll n) {  //繰り返し二乗法
    ll res = 1;
    while (n > 0) {
        if (n & 1) {
            res = res * x % MOD;
        }
        x = x * x % MOD;
        n >>= 1;
    }
    return res;
}

void init(ll n) {
    factrial[0] = 1;
    inverse[0] = 1;
    for (ll i = 1; i <= n; i++) {
        factrial[i] = (factrial[i - 1] * i) % MOD;  //階乗を求める
        inverse[i] = mod_power(factrial[i], MOD - 2) % MOD;  //オイラーの定理で逆元を求める
    }
}

ll nCk(ll n, ll k) {
    if(n < 0 || k < 0 || n < k) return 0;
    return factrial[n] * inverse[k] % MOD * inverse[n - k] % MOD;
}

ll n, k;

int main() {
    cin >> n >> k;
    init(n);
    for(ll i=1;i<=k;i++){
        cout <<  nCk(n-k+1, i)*nCk(k-1,i-1) % MOD << endl;
    }
    return 0;
}

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

using namespace std;

const int MAX_S = 2010;
const long long P = 1000000007;
int S;
long long dp[MAX_S];

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	cin >> S;
	
	dp[0] = 1LL;
	dp[1] = dp[2] = 0LL;
	for (int i = 3; i <= S; i++)
		for (int k = 3; k <= i; k++)
			dp[i] = (dp[i] + dp[i - k]) % P;
	
	cout << dp[S] << "\n";
	
	return 0;
}


Measured memory_bytes: 3620
import sys, bisect, math, itertools, heapq, collections
from operator import itemgetter
# a.sort(key=itemgetter(i)) # i番目要素でsort
from functools import lru_cache
# @lru_cache(maxsize=None)
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = float('inf')
mod = 10**9 + 7
eps = 10**-7


def inp():
    '''
    一つの整数
    '''
    return int(input())


def inpl():
    '''
    一行に複数の整数
    '''
    return list(map(int, input().split()))


s = input()
print("".join(["x" for _ in range(len(s) - 1)]))


Measured memory_bytes: 68568