akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cmath>
#include<numeric>
#include<functional>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
#include<queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
#define ll long long
#define INF 2147483647
using namespace std;
using Graph=vector<vector<int>>;

int main(){
  int n,m; cin>>n>>m;
  int x[m],y[m];
  rep(i,m){
    cin>>x[i]>>y[i];
    x[i]--; y[i]--;
  }
  int ball[n],possible[n]={};
  rep(i,n){
    ball[i]=1;
  }
  possible[0]=1;
  rep(i,m){
    ball[x[i]]--;
    ball[y[i]]++;
    if(possible[x[i]]==1){
      possible[y[i]]=1;
      if(ball[x[i]]==0){
        possible[x[i]]=0;
      }
    }
  }
  int ans=0;
  rep(i,n){
    if(possible[i]==1){
      ans++;
    }
  }
  cout<<ans;
}


Measured memory_bytes: 1792
import qualified Data.ByteString.Char8 as BS
import Data.Char
import Data.List
import Data.Maybe

readString = map BS.unpack . BS.words

getString = readString <$> BS.getLine

seek :: Char -> String -> String
seek 'z' s
  | 'z' `elem` s = "None"
  | otherwise = "z"
seek c s
  | c `elem` s = seek (chr (ord c + 1)) s
  | otherwise = [c]

main = do
  [s] <- getString
  let s' = sort (nub s)
  putStrLn $ seek 'a' s'


Measured memory_bytes: 1148
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int maxn = 2e5 + 555;
const int MOD = 1e9 + 7;
ll p[maxn];
ll pp[maxn];
void solve(ll x) {
    ll p2 = 0;
    vector<int> s;
    int sb;
    for (int i = 0; i <= 11; i++) {
        if (pp[i] >= x) {
            sb = i;
            break;
        }
    }
    for (int i = sb - 1; i >= 0; i--) {
        if (!i) {
            s.push_back(x - 1);
        } else {
            int ok = 1;
            for (int j = 1; j <= 26; j++) {
                if (j * p[i] <= x - pp[i - 1] - 1) {
                    ok = j;
                }
            }
            s.push_back(ok - 1);
            x -= ok * p[i];
        }
    }
    for (auto i : s) {
        cout << (char)(i + 'a');
    }
    cout << endl;
}
int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.precision(10);
    cout << fixed;
    p[0] = 1;
    p[1] = 26;
    for (int i = 2; i <= 11; i++) {
        p[i] = p[i - 1] * 26;
    }
    for (int i = 1; i <= 11; i++) {
        pp[i] = p[i] + pp[i - 1];
    }
    ll j;
    cin >> j;
    solve(j);
    return 0;
}

Measured memory_bytes: 3652
#include<iostream>
#include<string>
#include<stack>

using namespace std;

int main(void)
{
    bool flag = true;
    string str;
    stack<char> list;

    cin>>str;
   
    int diff = 1;
    for(int i = 1;i < str.size()-1 && str.size() > 2;i++)
    {
	if(str[i-1] == str[i+1]) {
	    diff++;
	    continue;
	}
	else {
	    flag = !flag;
	    str.erase(str.begin()+i);
	    i -= diff;
	    diff = 1;
	}
    }

    if(flag)
	cout<<"Second"<<endl;
    else
	cout<<"First"<<endl;

    return 0;
}


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


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

B = prime_factorize(y)

import collections
C = collections.Counter(B)

ans = 1

for i in C:
    if C[i] >= x:
        ans *= i ** (C[i]//x)
print(ans)

Measured memory_bytes: 39152
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iterator>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>

using namespace std;

#define dump(n) cerr<<"# "<<#n<<"="<<(n)<<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)

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

void solve(){
    string t; getline(cin,t);
    list<char> s(t.begin(),t.end());

    auto it=s.begin();
    int n; cin>>n; cin.get();
    while(n--){
        string cmd; getline(cin,cmd);
        if(cmd=="forward char")
            if(it!=s.end())
                ++it;
        if(cmd=="forward word"){
            while(it!=s.end() && *it==' ')
                ++it;
            while(it!=s.end() && *it!=' ')
                ++it;
        }
        if(cmd=="backward char")
            if(it!=s.begin())
                --it;
        if(cmd=="backward word"){
            while(it!=s.begin() && *--it==' ')
                ;
            while(it!=s.begin()){
                --it;
                if(*it==' '){
                    ++it;
                    break;
                }
            }
        }
        if(cmd.substr(0,6)=="insert"){
            int i=cmd.find('"')+1,j=cmd.find('"',i);
            s.insert(it,cmd.begin()+i,cmd.begin()+j);
        }
        if(cmd=="delete char")
            if(it!=s.end())
                it=s.erase(it);
        if(cmd=="delete word"){
            auto it2=it;
            while(it2!=s.end() && *it2==' ')
                ++it2;
            if(it2==s.end())
                continue;
            while(it2!=s.end() && *it2!=' ')
                ++it2;
            it=s.erase(it,it2);
        }
    }
    for(auto i=s.begin();;++i){
        if(i==it)
            cout<<'^';
        if(i==s.end())
            break;
        cout<<*i;
    }
    cout<<endl;
}

int main()
{
    int t; cin>>t; cin.get();
    while(t--)
        solve();

    return 0;
}

Measured memory_bytes: 1248
def t(s):
    a = [''.join(sorted(i)) for i in s]
    b = {}
    r = 0
    for i in a:
        if i in b.keys():
            r += b[i]
            b[i] += 1
        else:
            b[i] = 1
    return int(r)


if __name__ == '__main__':
    n = int(input())
    print(t([input() for i in range(n)]))


Measured memory_bytes: 26640
import javax.print.DocFlavor;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.function.BiConsumer;

public class Main {

    //グローバル変数を定義

    public static void main(String[] args) throws IOException {
        new Main().run();
    }

    void run() {
        Scanner sc = new Scanner(System.in);
        String input = sc.next();
        String k = sc.next();

        if(k.equals("1")) {
            System.out.println(input.charAt(0));
            return;
        }

        for(int i=0; i<Long.parseLong(k); i++){
            if(input.charAt(i) == '1'){
                continue;
            } else {
                System.out.println(input.charAt(i));
                return;
            }
        }
        System.out.println("1");
    }
}


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

using namespace std;

typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<vi> vvi;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, x;
    cin>>n;
    map<int, int> idex;
    vi numbers;
    for (int i = 0; i < n; ++i) {
        cin>>x;
        idex[x] = i;
        numbers.push_back(x);
    }
    sort(numbers.begin(), numbers.end());
    int cntp = 0, cnti = 0;
    for (int i = 0; i < n; ++i) {
        x = numbers[i];
        int d = abs(idex[x]-i);
        if(d%2) { cntp += (!(idex[x]%2)); cnti += (idex[x]%2); }
    }
    cout<<max(cntp,cnti)<<endl;
    return 0;
}


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

int machi (int x){
    int count =0;
    while(x%10 != 0){ 
        x +=1;
        count ++;
    }
    return count;
}

int main() {
    int A,B,C,D,E;
    cin >>A>>B>>C>>D>>E;
    vector<int>data{machi(A),machi(B),machi(C),machi(D),machi(E)};
    sort(data.begin(),data.end());
    reverse(data.begin(),data.end());
    int ans = A+B+C+D+E+machi(A)+machi(B)+machi(C)+machi(D)+machi(E)-data.at(0);
    cout << ans <<endl;
    }



Measured memory_bytes: 256
from collections import deque
def bfs(field,visited,sy,sx,gy,gx):
    queue = deque([[sy,sx]])
    visited[sy][sx] = 0
    while queue:
        y,x = queue.popleft()
        if [y,x] == [gy,gx]:
            return visited[y][x]
 
        for j,k in ([1,0],[-1,0],[0,1],[0,-1]):
            new_y, new_x = y+j, x+k
            if new_y < 0 or new_y > gy or new_x < 0 or new_x > gx:
              continue
            if field[new_y][new_x] == "." and visited[new_y][new_x] == -1:
                visited[new_y][new_x] = visited[y][x] + 1
                queue.append([new_y, new_x])
                
if __name__ == "__main__":
 
    h,w=map(int,input().split())
    sy=1
    sx=1
    field=[list(input()) for i in range(h)]
    visited = [[-1]*w for i in range(h)]
    sy, sx, gy, gx = sy-1, sx-1, h-1, w-1
    ans=bfs(field,visited,sy,sx,gy,gx)
    #print(ans)
    cnt=0
    for i in range(h):
      for j in range(w):
        if field[i][j]==".":
          cnt+=1
    if ans == None:
      print(-1)
    else:
      print(cnt - ans -1)

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(long long i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
const int INF=1e18;
const int MOD=1e9+7;

signed main(){
    int n;cin>>n;
    int s[n];
    REP(i,n)cin>>s[i];
    map<pair<int,int>,int>f;
    map<int,bool>used;
    //f(k,c=a-b)の形にする
    //f(1,1....n-2)を求めよう
    //漸化式でf(k,c)を出そう
    REPS(c,n-2){
        if(n-1-c==c)continue;
        used.clear();
        f[{1,c}]=s[n-1-c]+s[c];
        used[n-1-c]=used[c]=true;
        for(int k=2;(k+1)*c<n-1;k++){
            if(n-1-k*c==k*c)break;
            if(used[n-1-k*c] or used[k*c])break;
            f[{k,c}]=f[{k-1,c}]+s[n-1-k*c]+s[k*c];
            used[n-1-k*c]=used[k*c]=true;
        }
    }
    int ans=0;
    for(auto v:f)chmax(ans,v.second);
    cout<<ans<<endl;
}

Measured memory_bytes: 66176
#include <iostream>
#include <cstdio>
#include <cstring>
#include <climits>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <sstream>
#include <numeric>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

///////////////////////////////////////////////////////////////
// namespace
///////////////////////////////////////////////////////////////
using namespace std;
namespace mp = boost::multiprecision;

///////////////////////////////////////////////////////////////
// types
///////////////////////////////////////////////////////////////
using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using mpi = mp::cpp_int;
using mpf = mp::number<mp::cpp_dec_float<1024>>;

///////////////////////////////////////////////////////////////
// mod https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a
///////////////////////////////////////////////////////////////
// ll MOD = 1000000007;
//
// ll mod(long long val) {
//     long long res = val % MOD;
//     if (res < 0) res += MOD;
//     return res;
// }
//
// ll modinv(ll a) {
//     ll b = MOD, u = 1, v = 0;
//     while (b) {
//         ll t = a / b;
//         a -= t * b; swap(a, b);
//         u -= t * v; swap(u, v);
//     }
//     u %= MOD;
//     if (u < 0) u += MOD;
//     return u;
// }
//
// const int MAX = -1;
// ll fac[MAX], finv[MAX], inv[MAX];
// void com_init() {  // initialize nCk table with O(N)
//     fac[0] = fac[1] = 1;
//     finv[0] = finv[1] = 1;
//     inv[1] = 1;
//     for (int i = 2; i < MAX; i++){
//         fac[i] = fac[i - 1] * i % MOD;
//         inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
//         finv[i] = finv[i - 1] * inv[i] % MOD;
//     }
// }
// ll com(int n, int k){  // nCk
//     if (n < k) return 0;
//     if (n < 0 || k < 0) return 0;
//     return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
// }


int main() {
    string y; cin >> y;
    mpf x(y);
    int c = 0;
    mpf m(100.0);
    while (m < x) {
        ++c;
        m *= mpf(1.01);
        mpi tmp(m);
        m = mpf(tmp);
        // cout << m << endl;
    }
    cout << c << endl;
    return 0;
}


Measured memory_bytes: 4000
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007
 

int main() {
	ll n;
	cin>>n;
	string s;
	cin>>s;
	for(ll i=0;i<s.size();i++){
		ll now=s[i]-'A'+n;
		if(now>=26){
			now-=26;
		}
		cout << char(now+'A');
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define lli long long int
using namespace std;
#define S second
#define F first
#define pb push_back 
#define M1 1000000007
#define M2 998244353
#define plli pair<lli,lli>
#define setit set<lli>::iterator seti
#define mapit map<lli,lli> ::iterator mapi
#define MP make_pair
#define MT make_tuple
// map      iterator->first  iterator.first
// map      mp[key]=value
// set      *s.begin()
// vector   v[j]=value
// pair     p.first p.second
// vector of pairs v[j].first v[j].second
// tuple    get<index>(tuple_name)
// vector of tuples get<index>(v[j])  sort(v.begin(),v.end())
//priority queue .top() .pop() .push()
// __gcd(x,y)
#define fr(j,a,b) for(j=a;j<b;j++)


int power(int x, unsigned int y, int p)  
{    int res = 1;    
     x = x % p;
     if (x == 0) return 0;
     while (y > 0)  
     {  if (y & 1)  
        res = (res*x) % p;  
        y = y>>1;
        x = (x*x) % p;  
     }  
    return res;  
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    lli t,i,m,j,n,x,k,f,g,q,r,w,l;
    cin>>k;
    x=0;
    for(i=1;i<=k;i++){
        for(j=1;j<=k;j++){
            for(l=1;l<=k;l++){
                x=x+__gcd(__gcd(l,j),i);
            }
        }
    }
    cout<<x;
}

Measured memory_bytes: 3600
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = 1; i < (int)(n); i++) 
#define dunk(n) cout << n << endl
#define all(a) (a).begin(),(a).end()
typedef pair<int,int> P;
typedef long long ll;

int main() {
    ll a,b,c,k;
    cin >> a >> b >> c >> k;
    ll ans = 0;
    if(k <= a) ans = k;
    else if(k <= a + b) ans = a;
    else ans = 2*a + b - k;
    dunk(ans);
    return 0;
}

Measured memory_bytes: 3608
#define _USE_NATH_DEFINES
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
using namespace std;

int main() {
	int a, b, c;
	cin >> c >> a >> b;
	if (b-a >= c +1){
		cout << "dangerous" << endl;
	}
	else if (b-a <= 0)
	{
		cout << "delicious" << endl;
	}
	else if (b - a <= c)
	{
		cout << "safe" << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
const int inf=0x3f3f3f3f;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int n;
	cin>>n;
	string s;
	cin>>s;
	int len=s.size();
	if(n>=len)
		cout<<s<<endl;
	else
	{
		for(int i=0;i<=n-1;i++)
			cout<<s[i];
		cout<<"..."<<endl;
	}
	return 0;
}




Measured memory_bytes: 3648
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int ans = 0;
    if(N%2 == 0){
      ans = N/2-1;
    }else{
      ans = N/2;
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 22484
#include <iostream>

using namespace std;

int main(void) {
	int A, B, C, K;

	cin >> A >> B >> C >> K;

	int i = 0;

	int sum = 0;

	sum = A;
	if (K - A <= 0) {
		cout << K << endl;
		return 0;
	}
	K = K - A;



	K = K - B;
	if (K <= 0) {
		cout << sum << endl;
		return 0;
	}
	else {
		cout << sum - K << endl;
		return 0;
	}
	return 0;
}



Measured memory_bytes: 3116
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define MOD 1000000007
#define MOD2 998244353
#define pb emplace_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define sz(x) (ll)x.size()
#define F first
#define S second
#define FOR(i,a,b) for(ll i=a;i<=b;++i)
#define ROF(i,a,b) for(ll i=a;i>=b;--i)
#define trace(x) cerr<<#x<<": "<<x<<'\n';
typedef long long ll;
using namespace std;
using namespace __gnu_pbds;
#define T int
#define ordered_set tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>
auto clk=clock();
 
ll mexp(ll a, ll b, ll m){
    ll ans=1;
    a%=m;
    while(b){
        if(b&1) ans=ans*a%m;
        b>>=1;
        a=a*a%m;
    }
    return ans;
}

int a[101];

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

int main(){
    IOS
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());

    string s;
    cin >> s;
    int n = s.length();
    if(s[0] == s[n-1]){
        if(n % 2 == 1){
            cout << "Second";
        }
        else{
            cout  << "First";
        }
    }
    else{
        if(n % 2 == 1){
            cout << "First";
        }
        else{
            cout << "Second";
        }
    }

    cerr<<endl<<endl<<"Time: "<<fixed<<setprecision(12)<<(long double)(clock()-clk)/CLOCKS_PER_SEC<<" ms"<<endl<<endl;
 
    return 0;
}

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

int h, w, k;
char field[50][50];

int dp[4][50][50][1024][4];
int ans = 0;
int sum[4] = {0, 1, 3, 6};

bool judge(int x, int y)
{
  if(0 <= x && x < h && 0 <= y && y < w && field[x][y] != '#')
    return true;
  return false;
}

void solve(int times)
{
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      for(int l = 0; l < 1024; l++){
	for(int m = 0; m <= times; m++){

	  if(dp[times][i][j][l][m] > -1){
	    //toright
	    if(judge(i, j + 1)){
	      int nextl 
		= (field[i][j + 1] == '.' ? 0 : 1 << (sum[times] + m))
		| ((l & (1 << 0)) << 1)
		| ((l & (1 << 1)) << 2)
		| ((l & (1 << 2)) << 2)
		| ((l & (1 << 3)) << 3)
		| ((l & (1 << 4)) << 3)
		| ((l & (1 << 5)) << 3);
	      
	      dp[times][i][j + 1][nextl][m] = max(dp[times][i][j + 1][nextl][m], dp[times][i][j][l][m] + ((field[i][j + 1] == '.'|| times > 0 && (l & (1 << (sum[times] + m - (times - 1) - 1)))) ? 0 : field[i][j + 1] - '0'));
	    }
	    
	    //tounder
	    if(judge(i + 1, j)){
	      int nextl
		= (field[i + 1][j] == '.' ? 0 : 1 << (sum[times] + m))
		| ((l & (1 << 0)) << 2)
		| ((l & (1 << 1)) << 3)
		| ((l & (1 << 2)) << 3)
		| ((l & (1 << 3)) << 4)
		| ((l & (1 << 4)) << 4)
		| ((l & (1 << 5)) << 4);
	      
	      dp[times][i + 1][j][nextl][m] = max(dp[times][i + 1][j][nextl][m], dp[times][i][j][l][m] + ((field[i + 1][j] == '.' || times > 0 && (l & (1 << (sum[times] + m - (times - 1) - 2)))) ? 0 : field[i + 1][j] - '0'));
	    }
	    
	    if(times < k){
	      //toleft
	      if(judge(i, j - 1)){
		int nextl = l | (field[i][j - 1] == '.' ? 0 : (1 << (sum[times] + m + times + 1)));
		dp[times + 1][i][j - 1][nextl][m] = max(dp[times + 1][i][j - 1][nextl][m], dp[times][i][j][l][m] + ((field[i][j - 1] == '.' || (l & (1 << (sum[times] + m + times + 1)))) ? 0 : field[i][j - 1] - '0'));
	      }
	      
	      //toup
	      if(judge(i - 1, j)){
		int nextl = l | (field[i - 1][j] == '.' ? 0 : (1 << (sum[times] + m + times + 2)));
		dp[times + 1][i - 1][j][nextl][m + 1] = max(dp[times + 1][i - 1][j][nextl][m + 1], dp[times][i][j][l][m] + ((field[i - 1][j] == '.' || (l & (1 << (sum[times] + m + times + 2)))) ? 0 : field[i - 1][j] - '0'));
	      }
	    }

	  }
	}
      }
    }
  }

  for(int i = 0; i < 1024; i++){
    for(int j = 0; j <= times; j++){
      ans = max(ans, dp[times][h - 1][w - 1][i][j]);
    }
  }
}

int main()
{
  cin >> h >> w >> k;
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      cin >> field[i][j];
    }
  }

  memset(dp, -1, sizeof dp);
  dp[0][0][0][0][0] = 0;

  for(int i = 0; i <= k; i++){
    solve(i);
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 161172
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

int main() {
    int N;    

    cin >> N;

    if (N%1000 == 0){
        cout << 0 << endl;
    }
    else{
        cout << 1000-(N%1000) << endl;
    }

}


Measured memory_bytes: 3632
def main():
    n,d=map(int,input().split())
    count = 0
    d = d**2
    for _ in range(n):
        x,y = map(int,input().split())
        if d >= x**2 + y**2:
            count += 1
    print(count)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9184
#include<bits/stdc++.h>
using namespace std;
#define N 100005
char A[N],B[N];
int n,ans;
int main() {
	scanf("%s%s",A+1,B+1);
	n=strlen(A+1);
	for(int i=1; i<=n; i++)ans+=A[i]==B[i];
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int H,W;
	char A[8];

	int i,j,count=0;

	scanf("%d %d", &H, &W);

	for(i=0;i<H;i++){
		scanf("%s",A);
		for(j=0;j<W;j++){
			if(A[j]=='#'){count++;}
		}

	}

	if(count == H+W-1){
		printf("Possible");
	}
	else{
		printf("Impossible");
	}

	return 0;
}

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

long long int max(long long int a,long long int b){
	if(a>b)return a;
	else return b;
}

int main(void) {
	int n,W;
	scanf("%d%d",&n,&W);
	long long int w[n+1],v[n+1];
	for(int i=0;i<n;i++){
		scanf("%lld%lld",&w[i],&v[i]);
	}
	long long int dp[101][100001];
	for(int i=0;i<n;i++){
		for(int j=0;j<=W;j++){
			if((j-w[i])>=0){//n個目の新たな荷物を導入する部分
				dp[i+1][j] = max(dp[i][j-w[i]]+v[i],dp[i+1][j]);
			}
			dp[i+1][j] = max(dp[i][j],dp[i+1][j]);
		}
	}
	printf("%lld\n",dp[n][W]);
}


Measured memory_bytes: 79808
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}

void main()
{
  int n; readV(n);
  writeln(n*(n+1)/2);
}


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

#define watch(x) cerr << (#x) << ": " << (x) << endl
#define int long long

const int N = 100007;
int n, m, a[N];
int pre[N], ans;

int32_t main() {

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

    cin >> n >> m;
    for(int i = 0; i < n; ++i) {
        cin >> a[i];
    }

    sort(a, a+n);

    for(int i = 0; i < n; ++i) {
        pre[i+1] = pre[i] + a[i];
    }

    int l = 0, r = 2*N;
    while(r-l > 1) {
        int mid = l + (r-l)/2;

        int cur = 0;
        for(int i = 0; i < n; ++i) {
            cur += a+n - lower_bound(a, a+n, mid-a[i]);
        }
        if(cur >= m) {
            l = mid;
        } else {
            r = mid;
        }
    }

    int tot = 0;
    for(int i = 0; i < n; ++i) {
        int st = lower_bound(a, a+n, r-a[i]) - a;
        tot += n-st;
        int sm = pre[n] - pre[st];
        ans += sm + a[i]*(n-st);
    }

    ans += (m-tot)*l;

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


Measured memory_bytes: 1792
#include <stdio.h>

#define MAX 10000
#define NIL -1

typedef struct { int parent, left, right;} Node;

Node T[MAX];
int n, D[MAX], H[MAX];

void setDepth(int u,int d) {
  if(u == NIL) return;
  D[u] = d;
  setDepth(T[u].left, d+1);
  setDepth(T[u].right,d+1);
}

int setHeight(int u) {
  int h1 = 0, h2 = 0;
  if(T[u].left != NIL)
    h1 = setHeight(T[u].left)  + 1;
  if(T[u].right != NIL)
    h2 = setHeight(T[u].right) + 1;
  return H[u] = (h1 > h2 ? h1 : h2);
}

// 接点 u の兄弟を返す
int getSibling(int u) {
  if(T[u].parent == NIL) return NIL;
  if(T[T[u].parent].left != u && T[T[u].parent].left != NIL )
    return T[T[u].parent].left;
  if(T[T[u].parent].right != u && T[T[u].parent].right != NIL )
    return T[T[u].parent].right;
  return NIL;
}

void print(int u) {
  int deg = 0;
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].parent);
  printf("sibling = %d, ",getSibling(u));
  if(T[u].left  != NIL) deg++;
  if(T[u].right != NIL) deg++;
  printf("degree = %d, ",deg);
  printf("depth = %d, ",D[u]);
  printf("height = %d, ",H[u]);
  
  if(T[u].parent == NIL) {
    printf("root\n");
  } else if(T[u].left == NIL && T[u].right == NIL) {
    printf("leaf\n");
  } else {
    printf("internal node\n");
  }
}

int main(void) {
  int i, v, l, r, root = 0;
  scanf("%d",&n);
  for(i=0;i<n;i++) T[i].parent = NIL;
  for(i=0;i<n;i++) {
    scanf("%d %d %d",&v,&l,&r);
    T[v].left  = l;
    T[v].right = r;
    if(l != NIL) T[l].parent = v;
    if(r != NIL) T[r].parent = v;
  }
  
  for(i=0; i<n; i++)
  if(T[i].parent == NIL) root = i;
  
  setDepth(root,0);
  setHeight(root);
  
  for(i=0;i<n;i++) print(i);
  
  return 0;
}


Measured memory_bytes: 2108
#include<bits/stdc++.h>
#define ft(i,l,r) for(register int i=l;i<=r;i++)
#define fd(i,r,l) for(register int i=r;i>=l;i--)
using namespace std;
string a,b;
int ans;
int main()
{
	getline(cin,a);
	getline(cin,b);
	ft(i,0,a.size()-1)
	  if(a[i]!=b[i]) ans++;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3888
N = input().split()
while True :
    if N[1] == "?" :
        break
    a = int(N[0])
    b = int(N[2])
    if N[1] == "+" :
        print(a+b)
    if N[1] == "-":
        print(a-b)
    if N[1] == "*" :
        print(a*b)
    if N[1] == "/" :
        print(a//b)
    N = input().split()



Measured memory_bytes: 5596
#include<iostream>
#include<vector>
using namespace std;
#define ll long long

int main(){
  ll M, ans;
  cin >> M;
  
  vector<ll> X;
  //                     1   2  3   4    5   6   7     8  9
  vector<ll> cost = {0, 70, 77, 4, 91,  98,  5, 112, 119, 2};
  vector<ll> num  = {0, 64, 64, 4, 64,  64,  4,  64,  64, 2};
  for(ll i=0; i<M; ++i) {
    ll d, c;
    cin >> d >> c;
    if(d==0){ ans+=c; continue; }

    while(c>=num[d]){
      ans += (c/num[d])*cost[d];
      c = c/num[d] + c%num[d];
    }
    
    for(ll i=0; i<c; ++i) X.emplace_back(d);
  }

  ll v = X[0];
  for(ll i=1; i<X.size(); ++i){
    ans += 1 + (v+X[i])/10;
    v = (v+X[i])/10 + (v+X[i])%10;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 35044
#include<cstdio>
#include<algorithm>
#include<iostream>
using namespace std;
int n,ans;
string s;
int main(){
	cin>>n>>s;
	++ans;
	for(register int i=1;i<s.length();i++)if(s[i]!=s[i-1])++ans;
	cout<<ans;
}

Measured memory_bytes: 512
N,M,V,P=[int(a) for a in input().split()]
A=[int(a) for a in input().split()]
effect=N-V
A.sort(reverse=True)
#print(A)
ans=P
target_score=A[P-1]
target_vote=0
to_kill=0
#print(target_score)
for i in range(P,N):
    if A[i-1]>A[i]:
        #print(i,target_vote)
        target_vote+=(A[i-1]-A[i])*(i-P+1)
        to_kill=i-P+1
        #print(i,target_vote)
    real_effect=min(effect,to_kill)
    #print(i,target_vote,real_effect)
    if target_vote==0 or (((target_vote-1)//real_effect)+1<=M and target_score-A[i]<=M):
        ans+=1
    #print(ans)
print(ans)



Measured memory_bytes: 14480
using System;
using System.Linq;
using System.Collections.Generic;

public class Hello
{
    static void Main()
    {
        string[] s_data1 = Console.ReadLine().Split(' ');
        int possession_count = int.Parse(s_data1[0]);
        int usage_count = int.Parse(s_data1[1]);

        string[] s_data2 = Console.ReadLine().Split(' ');
        int[] tree_length = new int[possession_count];

        for (int i = 0; i < tree_length.Length; i++) tree_length[i] = int.Parse(s_data2[i]);
        var sum_tree_length = tree_length.Select(x => x).OrderByDescending(x => x).Take(usage_count).Sum();

        Console.WriteLine(sum_tree_length);
    }
}

Measured memory_bytes: 13396
import sys


N, T = map(int, input().split())
CT = [list(map(int, input().split())) for _ in range(N)]
target_list = [[c, t] for c, t in CT if t <= T]

if len(target_list) == 0:
    print('TLE')
else:
    target_list = sorted(target_list, key=lambda t: t[0])
    print(target_list[0][0])


Measured memory_bytes: 3060
def mine(i, j):
    if masu[i][j] == ".":
        masu[i][j] = 0
    if masu[i][j] != "#":
        masu[i][j] += 1
    return masu[i][j]


h, w = map(int, input().split())
masu = [[0]*(w+2) for _ in range(h+2)]

for i in range(1, h+1):
    masu[i] = [0]+list(input())+[0]
for i in range(h+2):
    for j in range(w+2):
        if masu[i][j] == ".":
            masu[i][j] = 0
        if masu[i][j] == "#":
            masu[i-1][j-1] = mine(i-1, j-1)
            masu[i-1][j] = mine(i-1, j)
            masu[i-1][j+1] = mine(i-1, j+1)
            masu[i][j-1] = mine(i, j-1)
            masu[i][j+1] = mine(i, j+1)
            masu[i+1][j-1] = mine(i+1, j-1)
            masu[i+1][j] = mine(i+1, j)
            masu[i+1][j+1] = mine(i+1, j+1)

for i in range(1, h+1):
    print("".join(map(str, masu[i][1:-1])))

Measured memory_bytes: 3192
#include<stdio.h>
int main(){
	int x,y;
	scanf("%d%d",&x,&y);
	if(x==1||x==3||x==5||x==7||x==8||x==10||x==12)x=1;
	else if(x==4||x==6||x==9||x==11)x=2;
	else x=3;
	if(y==1||y==3||y==5||y==7||y==8||y==10||y==12)y=1;
	else if(y==4||y==6||y==9||y==11)y=2;
	else y=3;
	if(x==y)printf("Yes\n");
	else printf("No\n");
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

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

	vector<int> a(n, 0);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	int ans = 0;
	int target = 1;
	bool ok = false;
	for (auto x: a) {
		if (x == target) {
			target++;
			ok = true;
		} else {
			ans++;
		}
	}

	if (!ok) {
		ans = -1;
	}

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


Measured memory_bytes: 1024
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

s = ns()
if 1 <= int(s[:2]) <= 12:
    if 1 <= int(s[2:]) <= 12:
        print("AMBIGUOUS")
    else:
        print("MMYY")

else:
    if 1 <= int(s[2:]) <= 12:
        print("YYMM")
    else:
        print("NA")

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main(){
	int k;
	string s;
	cin>>k>>s;
	if(s.length()>k){
		for(int i=0;i<k;i++){
			cout<<s[i];
		}
		cout<<"..."<<endl;
	}else{
		cout<<s<<endl;
	}

	return 0;
}

Measured memory_bytes: 3572
#include<stdio.h>
#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n, M[N][N];
int color[N], d[N], f[N], tt;

void dfs_visit(int u) {
	int v;
	color[u] = GRAY;
	d[u] = ++tt;
	for ( v = 0; v < n; v++ ) {
		if ( M[u][v] == 0 ) continue;
		if ( color[v] == WHITE ) {
			dfs_visit(v);
		}
	}
	color[u] = BLACK;
	f[u] = ++tt;
}

void dfs() {
	int u;
	for ( u = 0; u < n; u++ ) color[u] = WHITE;
	tt = 0;

	for ( u = 0; u < n; u++ ) {
		if ( color[u] == WHITE ) dfs_visit(u);
	}
	for ( u = 0; u < n; u++ ) {
		printf("%d %d %d\n", u + 1, d[u], f[u]);
	}
}

int main() {
	int u, v, k, i, j;

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

	for ( i = 0; i < n; i++ ) {
		scanf("%d %d", &u, &k);
		u--;
		for ( j = 0; j < k; j++ ) {
			scanf("%d", &v);
			v--;
			M[u][v] = 1;
		}
	}

	dfs();

	return 0;
}

Measured memory_bytes: 636
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+10;
typedef long long ll;

char s[N];
ll l,r;
int sum[N][26],c,nxt[N],k,n;

ll cal(ll m) {
	if(m<=n) return sum[m][c];
	ll l1=n,l2=k,s1=sum[n][c],s2=sum[k][c];
	while(l1+l2<=m) {
		ll tmp=l1;l1+=l2;l2=tmp;
		tmp=s1;s1+=s2;s2=tmp;
	}
	return s1+cal(m-l1);
}

int main() {
	scanf("%s",s+1),n=strlen(s+1)/2;
	for(int i=1;i<=n;i++) {
		for(int j=0;j<26;j++) sum[i][j]=sum[i-1][j];
		++sum[i][s[i]-'a'];
	}
	for(int i=2,j=0;i<=n;i++) {
		while(j&&s[j+1]!=s[i]) j=nxt[j];
		if(s[j+1]==s[i]) ++j;
		nxt[i]=j;
	}
	k=n-nxt[n];cin>>l>>r;
	for(c=0;c<26;c++) cout<<cal(r)-cal(l-1)<<' ';
	return 0;
}


Measured memory_bytes: 12288
// Words are flowing out like endless rain into a paper cup
// They slither while they pass they slip away across the universe
// Pools of sorrow, waves of joy are drifting through my open mind
// Possessing and caressing me

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

using LL = long long;

namespace _buff {

const size_t BUFF = 1 << 19;
char ibuf[BUFF], *ib = ibuf, *ie = ibuf;
char getc() {
    if (ib == ie) {
        ib = ibuf;
        ie = ibuf + fread(ibuf, 1, BUFF, stdin);
    }
    return ib == ie ? -1 : *ib++;
}

}

LL read() {
    using namespace _buff;
    LL ret = 0;
    bool pos = true;
    char c = getc();
    for (; (c < '0' || c > '9') && c != '-'; c = getc()) {
        assert(~c);
    }
    if (c == '-') {
        pos = false;
        c = getc();
    }
    for (; c >= '0' && c <= '9'; c = getc()) {
        ret = (ret << 3) + (ret << 1) + (c ^ 48);
    }
    return pos ? ret : -ret;
}

template <typename T>
void chkmin(T &dp, const T &val) {
    if (val < dp) dp = val;
}

template <typename T>
void chkmax(T &dp, const T &val) {
    if (val > dp) dp = val;
}

const size_t N = 2e5 + 5;
using P = pair<int, int>;
#define fi first
#define se second

P& operator += (P &p, const P &q) {
    chkmin(p.fi, q.fi);
    chkmax(p.se, q.se);
    return p;
}

P operator + (const P &p, const P &q) {
    P ret = p;
    return ret += q;
}

P tree[N << 2];
int pw2;

void prep(int n) {
    for (pw2 = 1; pw2 < n; pw2 <<= 1) {}
}

void push(int p, int val) {
    for (tree[p += pw2] = {val, val}; p > 1; p >>= 1) {
        tree[p >> 1] = tree[p] + tree[p ^ 1];
    }
}

P query(int l, int r) {
    P ret = {INT_MAX, -1};
    for (l += pw2, r += pw2 + 1; l < r; l >>= 1, r >>= 1) {
        if (l & 1) ret += tree[l++];
        if (r & 1) ret += tree[--r];
    }
    return ret;
}

int p[N], lst[N];

int main() {
    int n = read(), k = read(), ans = 1;
    prep(n);
    for (int i = 0; i < n; ++i) {
        push(i, p[i] = read());
        lst[i] = i && p[i - 1] < p[i] ? lst[i - 1] : i;
    }
    bool flag = lst[k - 1] > 0;
    for (int i = 0; i + k < n; ++i) {
        P pr = query(i, i + k);
        bool special = lst[i + k] <= i + 1;
        ans += (pr.fi != p[i] || pr.se != p[i + k]) && (!special || flag);
        flag &= !special;
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 8448
#include <stdio.h>
int main(){
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if(a>b&&a>c){
		printf("%d %d %d\n",b>c?c:b,b>c?b:c,a);
	}
	else if(b>c){
		printf("%d %d %d\n",a<c?a:c,a<c?c:a,b);
	}
	else{
		printf("%d %d %d\n",a>b?b:a,a>b?a:b,c);
	}
	return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD 1000000007
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll a,b,c,d,s1,s2;
    s1=s2=0;
    cin>>a>>b>>c>>d;
    s1=a+b;
    s2=c+d;
    if(s1>s2)
    {
        cout<<"Left\n";
    }
    else if(s2>s1)
    {
        cout<<"Right\n";
    }
    else
    {
        cout<<"Balanced\n";
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define all(vec) vec.begin(), vec.end()
#define END return 0
typedef int64_t ll;
const int mod7 = 1e9 + 7;
const int mod9 = 1e9 + 9;
const int inf = 1 << 30;
const ll INF = 1LL << 60;
template<typename T> T gcd(T a, T b) {return b ? gcd(b, a % b) : abs(a);}
template<typename T> T lcm(T a, T b) {return a / gcd(a, b) * b;}
template<typename T> bool chmax(T &a, T b) {if (a < b) {a = b; return true;} return false;}
template<typename T> bool chmin(T &a, T b) {if (a > b) {a = b; return true;} return false;}
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) {fill((T*)array, (T*)(array+N), val);}

int p[10][10];

int main() {
    Fill(p, 0);
    int n;
    cin >> n;
    for(int i = 1; i <= n; i++) {
        int j = 1e6;
        while(i < j) j /= 10;
        int fk = i / j, lk = i % 10;
        p[fk][lk]++;
    }
    int ans = 0;
    rep(i, 10)
        rep(j, 10) {
            ans += p[i][j] * p[j][i];
        }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <map>
#include <set>
#include <ctime>
#include <queue>
#include <stack>
#include <cmath>
#include <vector>
#include <bitset>
#include <cstdio>
#include <cctype>
#include <string>
#include <cstring>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std ;
#define rep(i, a, b) for (int (i) = (a); (i) <= (b); (i)++)
#define per(i, a, b) for (int (i) = (a); (i) >= (b); (i)--)
#define clr(a) memset(a, 0, sizeof(a))
#define ass(a, sum) memset(a, sum, sizeof(a))
#define lowbit(x) (x & -x)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define enter cout << endl
#define siz(x) ((int)x.size())
typedef long long ll ;
typedef unsigned long long ull ;
typedef vector <int> vi ;
typedef pair <int, int> pii ;
typedef map <int, int> mii ;
typedef map <string, int> msi ;
const int N = 100010 ;
const int INF = 0x3f3f3f3f ;
const int iinf = 1 << 30 ;
const ll linf = 2e18 ;
const int MOD = 1000000007 ;
void print(int x) { cout << x << endl ; exit(0) ; }
void PRINT(string x) { cout << x << endl ; exit(0) ; }
void douout(double x){ printf("%lf\n", x + 0.0000000001) ; }

int n;
ll l,x[300000];
ll a[300000];


ll calc() {
	ll Max = 0, cnt = 0 ;
	for (int i = 0, c = n; c >= 0; i++, c -= 2) cnt += a[i] * c ;
	for (int i = n, c = n - 1; c >= 0; i--, c -= 2) cnt += a[i] * c ;
	Max = cnt ;
	rep(i, 0, n - 1) {
		cnt -= x[i] ;
		int d = (n - i) / 2 + i ;
		cnt += x[d] - x[i] ;
		int e = n - (n - i) / 2 ;
		cnt -= l - x[e] ;
		Max = max(Max, cnt) ;
	}
	return Max ;
}

signed main() {
	scanf("%lld%d", &l ,&n) ;
	rep(i, 0, n - 1) {
		scanf("%lld", &x[i]) ;
		a[i] = x[i] ;
		if (i) a[i] -= x[i - 1] ;
	}
	ll ans = 0 ;
	a[n] = l - x[n - 1] ;
	ans = calc() ;
	reverse(x, x + n) ;
	rep(i, 0, n - 1) {
		x[i] = l - x[i] ;
		a[i] = x[i] ;
		if (i) a[i] -= x[i - 1] ;
	}
	a[n] = l - x[n - 1] ;
	ans = max(ans, calc()) ;
	printf("%lld\n", ans) ;
}

/*
写代码时请注意：
	1.ll？数组大小，边界？数据范围？
	2.精度？
	3.特判？
	4.至少做一些
思考提醒：
	1.最大值最小->二分？
	2.可以贪心么？不行dp可以么
	3.可以优化么
	4.维护区间用什么数据结构？
	5.统计方案是用dp？模了么？
*/


Measured memory_bytes: 3840
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline ostream& operator << (ostream& out, const vector<T>& v) {
    if (v.empty())return out;
    constexpr bool is_vector_v = is_vector<T>::value;
    if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
    else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
    return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }

int main(){
    int n;
    cin >> n;
    vector<ll> l(n),r(n);
    vector<P> p(n);
    REP(i,n){
        cin >> l[i] >> r[i];
        p[i].first = -l[i];
        p[i].second = r[i];
    }
    auto ml = max_element(all(l))-l.begin(),mr = min_element(all(r))-r.begin();
    int maxd=0;
    REP(i,n){
        if(i!=ml&&i!=mr){
            chmax(maxd,r[i]-l[i]+1);
        }
    }
    ll res = maxd+max<ll>(0,r[mr]-l[ml]+1);
    sort(all(p));
    vector<int> t1(n - 1), t2(n - 1);
    int maxl=0, minr=1e9+1;

    REP(i, n - 1) {
       chmax(maxl, -p[i].first);
       chmin(minr, p[i].second);
       t1[i] = max(0, minr - maxl + 1);
    }

    maxl = 0, minr = 1e9 + 1;
    RFOR(i, n, 1) {
       chmax(maxl, -p[i].first);
       chmin(minr, p[i].second);
       t2[i - 1] = max(0, minr - maxl + 1);
    }
    REP(i, n - 1) {
        chmax(res, t1[i] + t2[i]);
    }
    put(res);
    return 0;
}


Measured memory_bytes: 4224
#include<stdio.h>
int main(){
	int a,b,i;
	scanf("%d",&a);
	while(1){
	if(a==0){
		break;
	}
	for(i=0;i<9;i++){
		scanf("%d",&b);
		a=a-b;
	}
	printf("%d\n",a);
	scanf("%d",&a);
	}
	return 0;
}

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

int main() {
  int N; cin >> N;
  int sum;
  vector<int> order(N);
  vector<int> seaq(N);
  
  for (int i = 0; i < N; i++) {
    cin >> sum;
    seaq.at(sum - 1) = i + 1;
  }
  
  for (int i = 0; i < N; i++) {
    cout << seaq.at(i) << " " << endl;
  }
}
  

          
        
  


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

int main() {
  int H,W;
  cin >> H >> W;
  int h,w;
  cin >> h >> w;
  
  int x = H * w + W * h - h * w;
  cout << H * W - x << endl;
}
  


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

int main() {
	int n;
	cin >> n;
	vector<int> t(n+1), x(n+1), y(n+1);
	t[0] = 0;
	x[0] = 0;
	y[0] = 0;
	for (int i = 1; i < t.size(); i++) {
		cin >> t[i] >> x[i] >> y[i];
	}
	bool f = true;
	for (int i=1;i<n+1;i++){
		if (abs(x[i]-x[i-1]) + abs(y[i]-y[i-1]) > t[i] - t[i-1] || (t[i]-t[i-1]-abs(x[i]-x[i-1])-abs(y[i]-y[i-1]))%2 == 1) {
			f = false;
			break;
		}
	}
	if(f) cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
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; }
using namespace std;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;
const double PI = 3.1415926535897932;
const int MOD = 1e9 + 7;

//cin.tie(0);ios::sync_with_stdio(false);
int main() {
  int n, d;
  cin >> n >> d;

  ll ans = 0;
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    double dis = sqrt(pow(x, 2) + pow(y, 2));
    if (dis <= d) ans++;
  }

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


Measured memory_bytes: 3676
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cassert>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repd(i, n) for (int i = n; i >= 1; i--)
#define mod 1000000007
#define MOD 998244353
#define inf 1e20
typedef long long int ll;
typedef pair<ll, ll> p;


int main() {
	string s;
	cin >> s;
	int a[26];
	rep(i, 26) {
		a[i] = 0;
	}
	rep(i, s.size()) {
		a[s[i] - 'a']++;
	}
	rep(i, 26) {
		if (a[i] > 1) {
			cout<<"no";
			return 0;
		}
	}
	cout << "yes";
	return 0;
}

//Ctrl+Aを使わない

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
typedef long long ll;
using namespace std;

pair<int,int> dp[2][200001];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	while(cin>>n,n){
		int a[201];
		fill(a,a+201,0);
		for(int i=0;i<n;i++){
			cin>>a[i];
		}
		for(int i=0;i<=200000;i++)dp[0][i]=make_pair(-1,0);
		dp[0][0]=make_pair(0,0);
		for(int i=0;i<n;i++){
			for(int j=0;j<=200000;j++)dp[(i+1)&1][j]=make_pair(-1,0);
			for(int j=0;j<=200000;j++){
				if(dp[i&1][j].fi==-1)continue;
				int tmp=a[i]%1000;
				if(tmp<=500 && tmp>=1){
					if(dp[(i+1)&1][j+500-tmp]<make_pair(dp[i&1][j].fi+1,dp[i&1][j].se-a[i])){
						dp[(i+1)&1][j+500-tmp]=make_pair(dp[i&1][j].fi+1,dp[i&1][j].se-a[i]);
					}
				}else{
					int pay=(tmp+500)%1000;
					dp[(i+1)&1][j]=max(dp[(i+1)&1][j],dp[i&1][j]);
					if(pay<=j){
						if(dp[(i+1)&1][j-pay]<make_pair(dp[i&1][j].fi+1,dp[i&1][j].se-a[i])){
							dp[(i+1)&1][j-pay]=make_pair(dp[i&1][j].fi+1,dp[i&1][j].se-a[i]);
						}
					}
					int pay2=(1000-tmp)%1000;
					if(dp[(i+1)&1][j+pay2]<make_pair(dp[i&1][j].fi,dp[i&1][j].se-a[i])){
						dp[(i+1)&1][j+pay2]=make_pair(dp[i&1][j].fi,dp[i&1][j].se-a[i]);
					}
				}
			}
		}
		pair<int,int> ans=make_pair(0,0);
		for(int i=0;i<=200000;i++){
			if(dp[n&1][i]>ans){
				ans=make_pair(dp[n&1][i].fi,dp[n&1][i].se);
			}
		}
		cout<<ans.fi<<" "<<-ans.se<<endl;
	}
	return 0;
}


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

using namespace std;
using ll=long long;
int main()
{
    int n;cin >>n;
    bool flg=false;
    while(n>0){
        if(n%10==7)flg=true;
        n/=10;
    }
    if(flg)puts("Yes");
    else puts("No");
    return 0;
}


Measured memory_bytes: 3636
def task():
	a=input().split()
	r=int(a[0])
	d=int(a[1])
	x=int(a[2])
	for i in range (10):
		print((r*x)-d)
		x=(r*x-d)
		
t=1
while(t>0):
		task()
		t-=1


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(vec) vec.begin(), vec.end()
#define rALL(vec) vec.rbegin(), vec.rend()
using namespace std;
using ll = long long;

int main() {
    string S;
    cin >> S;
    string keyence = "keyence";
    rep(i, S.size() - 1) {
        for (int j = i; j < S.size(); ++j) {
            string left = S.substr(0, i);
            string right = S.substr(j);
            if (keyence == left + right) {
                cout << "YES" << endl;
                return 0;
            }
        }
    }
    cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 3584
#include <iostream>
#include <ctype.h>

using namespace std;

int is_contain_C(string s) {
  int temp_flg = -1;

  for(int i = 2; i < s.size() - 1; i++) {
    if (s[i] == 'C') {
      if (temp_flg != -1) {
	return -1;
      } else {
	temp_flg = i;
      }
    }
  }

  return temp_flg;
}

int main(int argc, char** argv){
  string s;

  cin >> s;
  if (s[0] != 'A') {
    cout << "WA" << endl;
    return 0;
  }
    
  int offset_a = 0;
  int offset_c = is_contain_C(s);
    
  if(offset_c == -1) {
    cout << "WA" << endl;
    return 0;
  }

  for(int i = 0; i < s.size(); i++) {
    if(i == offset_a) continue;
    if(i == offset_c) continue;

    if(!islower(s[i])) {
      cout << "WA" << endl;
      return 0;
    }
  }

  cout << "AC" << endl;


  return 0;
}


Measured memory_bytes: 256