akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define w(x) int x;cin>>x;while(x--)
#define ll long long
#define pb push_back
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define vi vector<int>
#define fr(a,b) for(int i=a;i<=b;i++)
#define inf 1e18
#define mod 1000000007
int main()
{   
/*#ifndef ONLINE_JUDGE
	freopen("input.txt", "r",stdin);
	freopen("output.txt", "w",stdout);
#endif*/
	fast;
    ll n;
    cin>>n;
    ll dp[n+1];
    dp[0]=1;
    for(int i=1;i<=n;i++)
    {
    	ll sum=0;
    	for(int j=0;j<=i;j++)
    	{
    		if((i-j)>=3)
    			sum=(sum%mod+dp[j]%mod)%mod;
    	}
    	dp[i]=sum;
    }
    cout<<dp[n]<<"\n";
	return 0;
}

Measured memory_bytes: 3632
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.util.Arrays;

class Main{

    static final int MAX = 10000+1;
    static int cost,n, s, x = MAX;
    static int[] A, B, C = new int[MAX];
    static boolean[] V = new boolean[1000];

    static void sort(){
        Arrays.sort(B, 0, n);
        for(int i = 0; i < n; i++)
            C[B[i]] = i;

        for(int i = 0; i < n; i++) {
            if(V[i]) continue;
            int j = i, s = 0, min = MAX, k = 0;
            while(!V[j]) {
                k++;
                min = Math.min(min,A[j]);
                s += A[j];
                V[j] = true;
                j = C[A[j]];
            }
            cost += Math.min(s + (k - 2) * min, min + s + (k + 1) * x);
        }
    }

    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        n = sc.nextInt();

        A = new int[n];
        B = new int[n];



        for (int i = 0; i < n; i++) {
            int next = sc.nextInt();
            A[i] = next;
            B[i] = A[i];
            V[i] = false;
            x = Math.min(x,next);
        }
        sort();
        System.out.println(cost);
    }



    static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

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

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

        int nextInt() { return Integer.parseInt(next()); }
        long nextLong() { return Long.parseLong(next()); }
        double nextDouble() { return Double.parseDouble(next()); }

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

}



Measured memory_bytes: 25064
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdint.h>
#include<tgmath.h>
#include<stdbool.h>
#include<sys/queue.h>
#include<time.h>
#define ll long long
#define min(a, b) ((a) > (b) ? (b) : (a))
#define max(a, b) ((a) > (b) ? (a) : (b))

int cmp1(const void *a, const void *b){
    if(*(ll*)a > *(ll*)b)return 1;
    else return -1;
}
int cmp2(const void *a, const void *b){
    if(*(ll*)a > *(ll*)b)return -1;
    else return 1;
}

ll n, a[200200], f[200200], k, sum = 0;

ll nyaa(ll x){
	ll tmp = 0;
	for(int i=0; i<n; i++){
		tmp += min(a[i], x / f[i]);
		if(tmp > sum)break;
	}
	return sum - tmp;
}

bool isOK(ll index, ll key) {
    if (nyaa(index) <= key) return true;
    else return false;
}
ll binary_search(ll key) {
    ll ng = 0ll;
    ll ok = (1ll<<60);
    while (llabs(ok - ng) > 1) {
        ll mid = (ok + ng) / 2;
        if (isOK(mid, key)) ok = mid;
        else ng = mid;
    }
    return ok;
}

int main(){
	scanf("%lld%lld", &n, &k);
	for(int i=0; i<n; i++){
		scanf("%lld", &a[i]);
		sum += a[i];
	}
	for(int i=0; i<n; i++){
		scanf("%lld", &f[i]);
	}
	if(sum <= k){
		puts("0");
		return 0;
	}
	qsort(a, n, sizeof(ll), cmp2);
	qsort(f, n, sizeof(ll), cmp1);
	printf("%lld\n", binary_search(k));
}

Measured memory_bytes: 4860
n = gets.chomp.to_i
ans = 0

@ary357 = ['3','5','7']

def retarys(int, ary)
  retary = []
  for i in 1..int 
    retary << ary
  end
  retary
end

2.step(8){|i|
  ans += @ary357.product(*retarys(i,@ary357)).count {|aa| (aa.uniq.size == 3) && (aa.inject(:+).to_i <= n)}
}
puts ans

Measured memory_bytes: 5116
#include <bits/stdc++.h>
using namespace std;
#define rep(i, x, n) for(long i = x; i < n; i++)
#define erep(i, x, n) for(long i = x; i <= n; i++)
#define all(a) a.begin(), a.end()
#define show(ans)  cout << ans << endl;
const long MOD = 1000000007;

bool vis[31];
long tmpscore = 0;
long cost[4][31];
long d[31][31];
long c[501][501];
long ans = 1e10;
long N, C;
// void dfs(long i, long x){
//     vis[x] = true;
//     tmpscore += cost[i][x];
//     if(i == 3){
//         ans = min(ans, tmpscore);
//         vis[x] = false;
//         tmpscore -= cost[i][x];
//         return;
//     }
//     erep(k, 1, C){
//         if(vis[k] == false){
//             dfs(i+1, k);
//         }
//     }
//     vis[x] = false;
//     tmpscore -= cost[i][x];
// }

int main() {
cin >> N >> C;
erep(i, 1, C){
    erep(j, 1, C){
        cin >> d[i][j];
    }
}
erep(i, 1, N){
    erep(j, 1, N){
        cin >> c[i][j];
    }
}
erep(k, 1, C){
    erep(i, 1, N){
        erep(j, 1, N){
            if((i+j)%3 == 2){
                cost[1][k] += d[c[i][j]][k];
            }
            if((i+j)%3 == 0){
                cost[2][k] += d[c[i][j]][k];
            }
            if((i+j)%3 == 1){
                cost[3][k] += d[c[i][j]][k];
            }
        }
    }
}
erep (i , 1, C ) erep (j , 1, C ) if ( i != j ) erep (k , 1, C ) if ( i != k && j != k ){
    ans = min(ans, cost[1][i]+cost[2][j]+cost[3][k]);
}
// erep(i, 1, C) dfs(1, i);
show(ans);
  return 0;
 
}



Measured memory_bytes: 2176
#include <iostream>
#include <string>
#include <algorithm>
#include <bitset>
#include <vector>
using namespace std;

typedef bitset<16> bs16;

bs16 input(){
	string s;
	getline(cin, s);
	s.erase(remove(s.begin(), s.end(), ' '), s.end());
	return bs16(s);
}

int main(){
	int n, c;
	vector<int> init(65536, -1000000000);

	while(cin >> n >> c, n){
		cin.ignore();

		vector<bs16> a(n), b(c);
		for(int i = 0; i < n; ++i){
			a[i] = input();
		}
		for(int i = 0; i < c; ++i){
			b[i] = input();
		}

		vector<int> dp1 = init, dp2;
		dp1[0] = 0;

		for(int i = 0; i < n; ++i){
			dp2 = init;
			for(int S = 0; S < 65536; ++S){
				if(dp1[S] < 0) continue;
				int T = S | a[i].to_ulong();
				dp2[T] = max(dp2[T], dp1[S]);
			}
			
			dp1 = dp2;
			for(int S = 0; S < 65536; ++S){
				if(dp2[S] < 0) continue;
				bs16 p(S);
				for(int j = 0; j < c; ++j){
					int x = (p & b[j]).count();
					int T = S & ~b[j].to_ulong();
					dp1[T] = max(dp1[T], dp2[S] + x);
				}
			}
		}

		cout << *max_element(dp1.begin(), dp1.end()) << '\n';
	}
}

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

using ll = long long;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll k, n;
  cin >> k >> n;
  
  vector<ll> a(n);
  for (int i = 0; i < n; i++) cin >> a.at(i);
  
  ll keep = 0;
  for (int i = 1; i < n; i++) keep = max(keep, a.at(i) - a.at(i - 1));
  keep = max(keep, k - a.back() + a.front());
  
  cout << k - keep << '\n';
}

Measured memory_bytes: 1792
def main():
    N = int(input())
    P = list(map(int, input().split()))
    minp = N+1; cnt = 0
    for p in P:
        minp = min(minp, p)
        if minp < p:
            cnt += 1
    print(N-cnt)

if __name__ == "__main__":
    main()


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

int selectionSort(int A[], int N){
    int sw = 0;
    int minj = 0;
    for(int i = 0; i < N - 1; i++){
        minj = i;
        for(int j = i; j < N; j++){
            if(A[minj] > A[j]) minj = j;
        }
        swap(A[i], A[minj]);
        if(i != minj) sw++;
    }
    return sw;
}

int main(){
    int A[100], N, sw;
    cin >> N;
    for(int i = 0; i < N; i++) cin >> A[i];
    
    sw = selectionSort(A, N);
    
    //出力
    for(int i = 0; i < N; i++){
        if(i) cout << " ";
        cout << A[i];
    }
    cout << endl;
    cout << sw << endl;
    
    return 0;
}


Measured memory_bytes: 3112
#include <iostream>

using namespace std;


int m,n,mm=1e9,nn=1e9;
int k;
int a[100005];
int b[100005];
int ans=1e9;

void inp()
{
    cin >> n >> m >> k;
    for (int i = 1; i <= n; i++) cin >> a[i],mm = min(mm,a[i]);
    for (int i = 1; i <= m; i++) cin >> b[i],nn = min(nn,b[i]);
}



int main()
{
    inp();
    for (int i = 1; i <= k; i++)
    {
        int x,y,c;
        cin >> x >>y >> c;
        ans = min(ans,a[x] + b[y] - c);
    }
    cout << min(ans,mm+nn);
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()
struct revran {
  const i64 b, e;
  struct iter {
    i64 i;
    constexpr iter(const i64 i) noexcept: i(i) {}
    void operator++() noexcept { --i; }
    constexpr i64 operator*() const noexcept { return i; }
    constexpr bool operator!=(const iter x) const noexcept { return i != x.i; }
  };
  constexpr revran(const i64 e) noexcept: b(0), e(e) {}
  constexpr revran(const i64 b, const i64 e) noexcept: b(b), e(e) {}
  constexpr iter begin() const noexcept { return iter(e - 1); }
  constexpr iter end() const noexcept { return iter(b - 1); }
};

struct ran {
  const i64 b, e;
  struct iter {
    i64 i;
    constexpr iter(const i64 i) noexcept: i(i) {}
    void operator++() noexcept { ++i; }
    constexpr i64 operator*() const noexcept { return i; }
    constexpr bool operator!=(const iter x) const noexcept { return i != x.i; }
  };
  constexpr ran(const i64 e) noexcept: b(0), e(e) {}
  constexpr ran(const i64 b, const i64 e) noexcept: b(b), e(e) {}
  constexpr iter begin() const noexcept { return iter(b); }
  constexpr iter end() const noexcept { return iter(e); }
  constexpr revran rev() const noexcept { return revran(b, e); }
};

constexpr ran rn0(const i64 e) noexcept { return ran(e); }
constexpr ran rn0(const i64 b, const i64 e) noexcept { return ran(b, e); }
constexpr ran rn1(const i64 e) noexcept { return ran(1, e + 1); }
constexpr ran rn1(const i64 b, const i64 e) noexcept { return ran(b, e + 1); }

int main() {
  i64 n, m;
  cin >> n >> m;
  vector<i64> im(n + 1 ,0);
  for(int i = 0;i < m;i++) {
    i64 l, r;
    cin >> l >> r;
    im[l]++;
    im[r + 1]--;
  }
  i64 ans = 0;
  for(int i = 1;i <= n;i++) {
    im[i] += im[i - 1];
    if(im[i] == m) {
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define Endl endl
using namespace std;
vector <int> verr[100005];
int ok[100005];
int f[100005];
int dp(int x)
{
//    cout<<x<<": ";
    if(ok[x]!=0)
        return f[x];
    ok[x]=1;
    for(int i=0;i<verr[x].size();i++)
    {
        f[x]=max(f[x],dp(verr[x][i])+1);
    }
//    if(verr[x].size()==0)
//        f[x]=1;
    return f[x];
}
main()
{
    int xx,yy;
    int n,m;
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        cin>>xx>>yy;
        verr[xx].emplace_back(yy);
    }
    int maxx=0;
    for(int i=1;i<=n;i++)
    {
        if(ok[i]==0)
        {
//            cout<<"qwertyuio";
//            cout<<ok[i]<<endl;
            maxx=max(maxx,dp(i));
//            cout<<endl;
        }
    }
     cout<<maxx;
}


Measured memory_bytes: 8576
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
using namespace std;

int main(void){
    long long x,y;
    cin >> x >> y;
    long long count=0;
    while(1){
        if(x>y)break;
        x+=x;
        count++;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                int n = int.Parse(Console.ReadLine());
                if (n == 0) break;

                int[] numArr = new int[n];
                for (int i = 0; i < n; i++)
                {
                    numArr[i] = int.Parse(Console.ReadLine());
                }

                Console.WriteLine(Solve(numArr));
            }
        }

        static int Solve(int[] arr)
        {
            int result = 0;

            for (int i = arr.Count() - 1; i >= 1; i--)
            {
                for (int j = 0; j <= i - 1; j++)
                {
                    if (arr[j] > arr[j + 1])
                    {
                        int x = arr[j];
                        arr[j] = arr[j + 1];
                        arr[j + 1] = x;

                        result++;
                    }
                }
            }

            return result;
        }
    }
}

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

main() {
  int N; cin >> N;
  int A[N]; rep(i, N) cin >> A[i];

  sort(A, A + N);
  int t = 0;
  ll sum = 0;
  rep(i, N - 1) {
    sum += A[i];
    if (2 * sum < A[i + 1]) t = i + 1;
  }
  cout << N - t << endl;
}

Measured memory_bytes: 640
#include<stdio.h>
int main(void){
	
	int N,M,T,a[100],sp,s,k,l,hasi,owa,d,e,f,time;
	
	a[0]=0;
	sp=0;
	owa=0;
	f=0;
	
	scanf("%d %d %d\n",&N,&M,&T);
	
	for(s=1;s<=N;s++){
		scanf("%d",&a[s]);
	}
	
	for(k=1;k<=N;k++){
		
		sp=sp+2*M;
		hasi=a[k]-M;
		e=T-a[k];
		
		if(hasi<owa){
			d=owa-hasi;
			sp=sp-d;
		}
		
		if(e<M){
			
			if(f==0){
				sp=sp+T-owa;
				f=1;
			}
			sp=sp-(a[k]+M-owa);
		}
		owa=a[k]+M;
	}
	
	time=T-sp;
	
	printf("%d\n",time);
	
	
	return 0;
}


Measured memory_bytes: 2116
INF = 1 << 28
def min(a,b); a < b ? a : b; end

H,W,K = gets.split.map(&:to_i)
S = Array.new(H + 1){ Array.new(W + 1, 0) }

H.times do |y|
  l = gets.chomp
  W.times do |x|
    v = (l[x] == '1' ? 1 : 0)
    S[y + 1][x + 1] = S[y + 1][x] + S[y][x + 1] - S[y][x] + v
  end
end

class << S
  def rect_sum(y1,x1,y2,x2)
    S[y2][x2] - S[y2][x1] - S[y1][x2] + S[y1][x1]
  end
  
  def min_xcut(ycut, cap)
    x1 = 0
    xcut = 0

    while x1 < W
      r = ycut.each_cons(2).inject(W) do |x2, (y1, y2)|
        x2 -= 1 while rect_sum(y1,x1,y2,x2) > cap
        x2
      end
      
      return INF if x1 == r
      return xcut if r == W
      
      xcut += 1
      x1 = r
    end
  end
end

ans = INF
(1 << (H - 1)).times do |w|
  ycut_bit = (1 | (w << 1) | (1 << H))
  ycut = (0 .. H).select{|i| ycut_bit[i] > 0 }
  ans = min(ans, ycut.size - 2 + S.min_xcut(ycut, K))
end
puts ans

Measured memory_bytes: 1916
#include<stdio.h>
#include<string>
#include<math.h>
#include<stdlib.h>
#include<set>
#include<bitset>
#include<map>
#include<vector>
#include<string.h>
#include<algorithm>
#include<iostream>
#include<queue>
#include<deque>
#include<stack>
#include<cmath>
#include<ctime>
#include<complex>
#include<list>
#include<limits.h>
using namespace std;

int n,m,A,B;

int main(){
	scanf("%d%d%d%d",&n,&m,&A,&B);
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(j<=A&&i<=B) printf("1");
			if(j<=A&&i>B)  printf("0");
			if(j>A&&i>B)   printf("1");
			if(j>A&&i<=B)  printf("0");
		}
		puts("");
	}
	return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int n,a[10][10];
    cin>>n;
    memset(a,0,sizeof(a));
    for(int i=1;i<=n;i++){
        a[to_string(i)[0]-'0'][i%10]++;
    }
    int ans=0;
    for(int i=0;i<10;i++){
        for(int j=0;j<10;j++){
            ans+=a[i][j]*a[j][i];
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define ll long long
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef pair <int, int> ii;
typedef vector <int> vi;

const ll siz = 1e5 + 10;
const ll SIZ = 1e6 + 10;
const ll mod = 1e9 + 7;
const ll maxx = 2e9;
const ll MAXX = 1e18;



int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
//    freopen ("IN_4.INP", "r", stdin);
//    freopen ("OUT_4.OUT", "w", stdout);
    int a;
    cin >> a;
    cout << a + a * a + a * a * a;
    return 0;
}


Measured memory_bytes: 3624
x=int(input())
if x==1:
    print(1)
    import sys
    sys.exit()
ans=0
for b in range(2,x):
    bp=b**2
    while(True):
        if bp*b <= x:
            bp=bp*b
            continue
        elif bp <= x <bp*b:
            ans=max(ans,bp)
            break
        else:
            break
print(ans)

Measured memory_bytes: 38384
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
#include <list>
#include <cstring>
using namespace std;
#define pi pair<int,int>
#define pl pair<long long,long long>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
typedef long long ll;
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}
void Exit(){
    cout << -1 << endl;
    exit(0);
}


vector<vector<int> > g;
vector<int> dp,ckd;

auto func(int crr){
    if (ckd.at(crr) == 2) return dp.at(crr);
    ckd.at(crr) = 1;
    for (auto nxt : g[crr]){
        if (ckd[nxt] == 1) Exit();
        dp[crr] = max(dp[crr],func(nxt) + 1);
    }
    ckd[crr] = 2;
    return dp[crr];
}

auto encode(int i,int j){
    if (i < j) swap(i,j);
    return i*(i-1)/2 + j + 1;
}

int main(){
    int n; cin >> n;
    auto N = n*(n-1)/2;
    g.resize(N+1);
    for (int i = 0; i < n; i++){
        auto prev = 0;
        for (int j = 0; j < n-1; j++){
            int x; cin >> x; x--;
            auto crr = encode(i,x);
            g[prev].emplace_back(crr);
            prev = crr;
        }
    }
    dp.resize(N+1,0);
    ckd.resize(N+1,0);
    auto ret = func(0);
    cout << ret << endl;
}


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

const int MAXN=2e5+10;
struct {
	long long l,r,w,lazy;
}tree[MAXN<<2];
int n;
long long a[MAXN],b[MAXN];

void build(int l,int r,int tr){
	tree[tr].l=l;tree[tr].r=r;
	if(tree[tr].l==tree[tr].r) return;
	int mid=l+r>>1;
	build(l,mid,tr<<1);
	build(mid+1,r,tr<<1|1);
	return;
}

void down(int tr){
	tree[tr<<1].lazy=max(tree[tr<<1].lazy,tree[tr].lazy);
	tree[tr<<1].w=max(tree[tr<<1].w,tree[tr].lazy);
	tree[tr<<1|1].lazy=max(tree[tr<<1|1].lazy,tree[tr].lazy);
	tree[tr<<1|1].w=max(tree[tr<<1|1].w,tree[tr].lazy);
	tree[tr].lazy=0;
}

void change(int tr,int poi,long long num){
	if(tree[tr].l==poi&&tree[tr].r==poi){
		tree[tr].w=max(num,tree[tr].w);
		return;
	}
	if(tree[tr].lazy) down(tr);
	int mid=tree[tr].l+tree[tr].r>>1;
	if(poi<=mid)	change(tr<<1,poi,num);
	else			change(tr<<1|1,poi,num);
	tree[tr].w=max(tree[tr<<1].w,tree[tr<<1|1].w);
	return;
}

long long ask(int l,int r,int tr){
	if(l<=tree[tr].l&&tree[tr].r<=r) return tree[tr].w;
	if(tree[tr].lazy) down(tr);
	int mid=tree[tr].l+tree[tr].r>>1;
	long long ans=0;
	if(l<=mid) ans=ask(l,r,tr<<1);
	if(r> mid) ans=max(ask(l,r,tr<<1|1),ans);
	return ans;
}

int main(){
	cin>>n;
	build(1,n,1);
	for(int i=1;i<=n;++i) cin>>a[i];
	for(int i=1;i<=n;++i) cin>>b[i];
	for(int i=1;i<=n;++i){
		change(1,a[i],ask(1,a[i],1)+b[i]);
	}
	cout<<ask(1,n,1)<<"\n";
	return 0;
} 

Measured memory_bytes: 20736
# coding: utf-8
import array, bisect, collections, copy, heapq, itertools, math, random, re, string, sys, time
sys.setrecursionlimit(10 ** 7)
INF = 10 ** 20
MOD = 10 ** 9 + 7


def II(): return int(input())
def ILI(): return list(map(int, input().split()))
def IAI(LINE): return [ILI() for __ in range(LINE)]
def IDI(): return {key: value for key, value in ILI()}


def read():
    N = II()
    s = [II() for __ in range(N)]
    return (N, s)


def solve(N, s):
    n_sum = sum(s)
    s_sorted = sorted(s)
    if n_sum % 10 != 0:
        ans = n_sum
    else:
        for n in s_sorted:
            if (n_sum - n) % 10 != 0:
                ans = n_sum - n
                break
        else:
            ans = 0

    return ans


def main():
    params = read()
    print(solve(*params))


if __name__ == "__main__":
    main()


Measured memory_bytes: 5352
//Author - Rahil Malhotra
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define int long long
#define double long double

int32_t main()
{
    IOS;
    int n;
    cin>>n;
    map<int,int>mp;
    for(int i=0;i<n;i++)
    {
        int a;
        cin>>a;
        mp[a]++;
    }
    int ans=0;
    for(auto i:mp)
    {
        if(i.first>i.second)
            ans+=i.second;
        else
            ans+=i.second-i.first;
    }
    cout<<ans;
}

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

int main()
{
	int beru1, beru2, beru3;
	int max;

	cin >> beru1 >> beru2 >> beru3;

	max = beru1;
	if (max < beru2) {
		max = beru2;
	}
	if (max < beru3) {
		max = beru3;
	}

	cout << ((beru1 + beru2 + beru3) - max) << endl;

	return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ll long long
#define db double
#define el "\n"
#define ld long double
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n;i>=0;i--)
#define rep_a(i,a,n) for(int i=a;i<n;i++)
#define tr(ds, it) for(auto it=ds.begin(); it!=ds.end(); it++)
#define rtr(ds, it) for(auto it=ds.rbegin(); it!=ds.rend(); it--)
#define all(ds) ds.begin(), ds.end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
typedef priority_queue <int> pq;
typedef vector< long long > vi;
typedef pair<long long, long long> ii;
#define o_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define graph vector<vi>

const ll mod = 1000000007;
ll po(ll x, ll n ){ 
    ll ans=1;
     while(n>0){
         if(n&1) ans=(ans*x)%mod;
         x=(x*x)%mod;
         n/=2;
     }
     return ans;
}



int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
  
    int T=1;
    //cin >> T;
    while(T--){
        ll l;
        cin>>l;
        cout<<setprecision(10)<<fixed<<(l*l*l)/(ld)27<<el;

    }

    return 0;
}

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

int main() {
	char a[20], b[20], c[20];
	cin >> a >> b >> c;
	char A = a[0] -32;
	char B = b[0] -32;
	char C = c[0] -32;
	cout << A << B << C;
	system("pause");
}


Measured memory_bytes: 504
#include <iostream>
#include <algorithm>
#include <stdio.h>

#define MAXN 100000

using namespace std;

typedef long long ll;

ll A[MAXN];

int main()
{
  int n;
  ll l,r;
  ll mindis;

  cin >> n;

  for ( int i = 0; i < n; ++i ) scanf("%ld", &A[i]);
  sort(A,A+n);

  l = A[n-1];
  r = -100;
  mindis = abs(r-(l/2));

  if ( l%2 ) {
    for ( int i = 0; i < n-1; ++i ) {
      ll mid1,mid2;
      ll dis;
      mid1 = (l/2);
      mid2 = (l/2)+1;
      dis = min( abs(A[i]-mid1), abs(A[i]-mid2) );
      if ( dis < mindis ) {
        r = A[i];
        mindis = dis;
      }
    }
  } else {
    for ( int i = 0; i < n-1; ++i ) {
      ll mid = l/2;
      ll dis = abs(A[i]-mid);
      if ( dis < mindis ) {
        r = A[i];
        mindis = dis;
      }
    }
  }

  cout << l << " " << r << endl;
}


Measured memory_bytes: 1152
h,n = list(map(int, input().split()))
st = str(input())
a = [list(map(int, input().split())) for _ in range(n)]

o = "B"
b = []
c = 0
for i in range(len(st)):
    sti = st[i]
    if sti == "A":
        o = "A"
        b.append(c)
    elif sti == "C" and o == "A":
        o = "C"
        c += 1
        b.append(c)
    else:
        o = "B"
        b.append(c)

for a1,b1 in a:
    print(b[b1-1] - b[a1-1])

Measured memory_bytes: 69336
#include <bits/stdc++.h>
//#pragma GCC optimize(2)
//author wjl

using namespace std;
#define LL long long
#define Rint register int
#define U unsigned
#define forn(i,a,b) for(int i = a;i <= b;++i)
#define nfor(i,a,b) for(int i = a;i >= b;--i)
#define pii pair<int ,int>
#define MS0(X) memset(X,0,sizeof(X))
#define MSf(X) memset(X,false,sizeof(X))
#define MS1(X) memset(X,-1,sizeof(X))
#define BR printf("--------------------\n")
#define pb push_back
#define rep(i,a,b) for(Rint i=a;i<=b;++i)
#define DEBUG(x) std::cerr << #x << '=' << x << std::endl
const double PI=atan(1.)*4.;
const int maxn=1e6+5;
const int inf = 0x3f3f3f3f;
const int mod=1e9+7;
const double e=2.71828182845904523536;
int dirx[8]={1,0,-1,0,1,-1,-1,1};
int diry[8]={0,1,0,-1,1,1,-1,-1};
int n,t;
struct node
{
    int a,b;
}st[maxn];

bool cmp(node a,node b)
{
    return a.a<b.a;
}

int dp[3005][6005];
int mx[3005];
int main()
{
    /*ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);*/
    scanf("%d%d",&n,&t);//cin>>n>>t;
    for(int i=1;i<=n;i++)
    {
        scanf("%d%d",&st[i].a,&st[i].b);//cin>>st[i].a>>st[i].b;
    }
    sort(st+1,st+n+1,cmp);//排序很重要
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        for(int j=t+st[i].a-1;j>=st[i].a;--j)
        {
            dp[i][j]=max(dp[i-1][j],dp[i-1][j-st[i].a]+st[i].b);
            ans=max(ans,dp[i][j]);
        }
        for(int j=st[i].a-1;j>=0;--j)
        {
            dp[i][j]=dp[i-1][j];
            ans=max(ans,dp[i][j]);
        }
    }
    printf("%d",ans);//cout<<ans<<endl;
    return 0;
}

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

using namespace std;

#define fio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long
#define double long double
#define endl '\n'

signed main() {
   fio;
   int n , k; cin >> n >> k;
   vector<int> a(n);
   for(int &it : a) {
      cin >> it;
   }
   int low = 1 , high = 1e9;
   while(low < high) {
      int mid = (low + high) >> 1;
      int cuts = 0;
      for(int it : a) {
         if(it <= mid) {
            continue;
         }
         cuts += it / mid;
      }
      if(cuts <= k) {
         high = mid;
      } else {
         low = mid + 1;
      }
   }
   
   cout << low << endl;
   
   return 0;
}




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

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

    map<char, int> alphabet;
    for (int i = 0; i < 26; i++) {
        alphabet.insert(make_pair('a' + i, 0));
    }

    string str;

    // getline(cin, str);
    while (getline(cin, str)) {
        for (int i = 0; i < str.size(); i++) {
            if (isupper(str[i])) {
                str[i] = tolower(str[i]);
            }
            if (str[i] >= 'a' && str[i] <= 'z') {
                alphabet[str[i]] += 1;
            }
        }
    }

    for (auto itr = alphabet.begin(); itr != alphabet.end(); itr++) {
        cout << itr->first << " : " << itr->second << '\n';
    }
    return 0;
}


Measured memory_bytes: 3240
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let o: Vec<char> = input::<String>().chars().collect();
    let e: Vec<char> = input::<String>().chars().collect();

    let mut v = vec!['0'; o.len() + e.len()];
    for i in 0..e.len() {
        v[2 * i] = o[i];
        v[2 * i + 1] = e[i];
    }
    if o.len() > e.len() {
        v[o.len() + e.len() - 1] = o[o.len() - 1];
    }

    println!("{}", v.iter().cloned().collect::<String>());
}


Measured memory_bytes: 4352
from heapq import *
import sys
from collections import *
from itertools import *
from decimal import *
import copy
from bisect import *
import math
sys.setrecursionlimit(4100000)
def gcd(a,b):
    if(a%b==0):return(b)
    return (gcd(b,a%b))
input=lambda :sys.stdin.readline().rstrip()
K=int(input())
A,B=map(int,input().split())
for i in range(A,B+1):
    if i%K==0:
        print("OK")
        exit()
print("NG")


Measured memory_bytes: 10076
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;

void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int h,w,k;
    cin >> h >> w >> k;
    int n = h + w;
    vector<vector<char>> a(h,vector<char>(w));
    rep(i,h){
        rep(j,w) {
            cin >> a[i][j];
        }
    }

    ll ans = 0;
    for(int bit =0;bit<(1<<n);bit++){
        ll cnt = 0;
        vector<int> s;
        for(int i=0;i<n;i++){
            if(bit&(1<<i)){
                s.push_back(i);
            }
        }
        vector<vector<char>> c(h,vector<char>(w));
        rep(i,h){
            rep(j,w) c[i][j] = a[i][j];
        }
        for(auto v:s){
            if(v<h){
                rep(i,w){
                    c[v][i] = '.';
                }
            }
            else{
                rep(i,h){
                    c[i][v-h] = '.';
                }
            }
        }
        rep(i,h){
            rep(j,w){
                if(c[i][j]=='#') cnt++;
            }
        }
        if(cnt == k) ans++;
    }
    cout << ans;

    return 0;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 1101010101010101010
#define MOD 1000000007
#define int long long
using P = pair<int,int>;

signed main(){
  int n;
  cin >> n;
  vint A(n);
  int m;
  cin >> m;
  rep(i,2*m){
    int a;
    cin >> a;
    a--;
    A[a]++;
  }
  bool flag = true;
  rep(i,n){
    if(A[i] % 2 == 1) flag = false; 
  }
  if(flag) cout << "YES" << endl;
  else cout << "NO" << endl;
}

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

int main() {
  int n,m;
  cin >> n >> m;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  
  int sum=0;
  rep(i,n) sum+=a[i];
  int ans=0;
  rep(i,n) {
    if(sum<=a[i]*4*m) {
      ans++;
    }
    else {
    }
  }
  if(m<=ans) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


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


 
int main() {


    int n;
    cin>>n;

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

    vector<int> p(n);
    for(int i=0;i<n;i++){
        cin>>p.at(i);
    }

    int prob1_cnt=0,prob2_cnt=0,prob3_cnt=0;
    for(int i=0;i<n;i++){
        if(p.at(i)<=a)
            prob1_cnt++;
        else if(p.at(i)>a && p.at(i)<=b)
            prob2_cnt++;
        else
            prob3_cnt++;
    }

    cout<<min(min(prob1_cnt,prob2_cnt),prob3_cnt)<<endl;

 	return 0;
}


Measured memory_bytes: 3568
//raja1999
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 <<endl;prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx


using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false);
int main(){
	std::ios::sync_with_stdio(false);
	int n;
	cin>>n;
	if(n/100==n%10)
	cout<<"Yes"<<endl;
	else
	cout<<"No"<<endl;	
} 


Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define P pair<int, int>
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
const int MAX_N = 101;


int N, A, B, C, X, Y[MAX_N];

int rand(int x){
  return (A * x + B) % C;
}

int calc(){
  int ans = 0, cnt = 0, x = X;
  REP(i, 10001){
    if(Y[cnt] == x){
      ++cnt;
      if(cnt >= N) return i;
    }
    x = rand(x);
  }
  return -1;
}

int main() {
  while(cin >>N >>A >>B >>C >>X && N){
    REP(i, N) cin >>Y[i];
    cout <<calc() <<endl;
  }
  return 0;
}

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

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vd = vector<double>;
using vc = vector<char>;
using vs = vector<string>;
using vll = vector<ll>;
using vpii = vector<pii>;
using mpii = map<int, int>;
using mpci = map<char, int>;
using mpsi = map<string, int>;
using si = set<int>;
using sll = set<ll>;

#define rep(i, n) for(int(i)=0;(i)<(n);(i)++)
const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    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;
    }
}

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

// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

bool custom1 (pii a, pii b) {
  return (a.first < b.first);
}

bool custom2 (pii a, pii b) {
  return (a.second < b.second);
}

int main() {
  string s, t;
  int a, b;
  cin >> s >> t >> a >> b;
  string u;
  cin >> u;
  if(s == u) {
    cout << a-1 << " " << b << endl;
  }
  else if(t == u) {
    cout << a << " " << b-1 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import java.util.*;


import java.io.*;



public class Main 
{   
	
	//static int dp[][];
	public static void main(String[] args) throws IOException 
	{ 
		 
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		PrintWriter pw=new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
		StringTokenizer s=new StringTokenizer(br.readLine());
		
		int n=Integer.parseInt(s.nextToken());
		int k=Integer.parseInt(s.nextToken());
		
		int dp[][]=new int[n+1][k+1];
		
		int ar[]=new int[n+1];
		s=new StringTokenizer(br.readLine());
		
		for(int i=1;i<=n;i++) {
			ar[i]=Integer.parseInt(s.nextToken());
			
		}
		
			for(int j=0;j<=k;++j) dp[1][j] = (j > ar[1])?0:1;
		for(int i=2;i<=n;i++) {
			
			for(int j=0;j<=k;j++) {
				if(j==0)
					dp[i][j]=dp[i-1][j];
				else {
					dp[i][j]=(dp[i][j-1]+dp[i-1][j])%1000000007;
					if(j-1-ar[i] >= 0) dp[i][j] = (dp[i][j] - dp[i-1][j-1-ar[i]] + 1000000007)%1000000007;
			}}
		}
		

//		for(int i=0;i<=n;i++) {
//			for(int j=0;j<=k;j++)
//				pw.print(dp[i][j]+" ");
//			pw.println();
//		}
		
		pw.print(dp[n][k]);
		
		
				pw.close();
	
	}
	
	
}

Measured memory_bytes: 83412
// Problem : C - Green Bin
// Contest : AtCoder - AtCoder Beginner Contest 137
// URL : https://atcoder.jp/contests/abc137/tasks/abc137_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,b,a) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
 
#define bug(x) cout<<#x<<"="<<x<<endl; 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const ld pii=3.14159265359; 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 200001; //check the limits, dummy
 vl hsh={2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199};
int main() 
{
	ios_base::sync_with_stdio(0); cin.tie(0);    
	// cout<<sz(hsh);
	int N;
	cin>>N;
	map<ll,int> m;
	ll ans=0;
	F0R(x,N)
	{
		string str;
		cin>>str;
		ll val=1;
		F0R(x,sz(str))
			val=val*(hsh[str[x]-'a']);
		ans+=m[val];
		m[val]++;
	}
	cout<<ans<<nl;
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 9800
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
using namespace std;


int main()
{
	int a, b;
	cin >> a >> b;
	if (a == 1) {
		a = 14;
	}
	if (b == 1) {
		b = 14;
	}
	if (a > b) {
		cout << "Alice" << endl;
	}
	else if (a < b) {
		cout << "Bob" << endl;
	}
	else {
		cout << "Draw" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;



int main() {
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) {
        cin >> a[i];
    }

    int q;
    cin >> q;


    vi AA(2001);
    rep(i, 1<<n) {
        bitset<20> bits(i);
        int now = 0;
        rep(j, n) {
            if(bits[j]) {
                now += a[j];
            }
        }
        if(now > 2000) continue;
        AA[now]++;
    }

    rep(i, q) {
        int m;
        cin >> m;
        cout << (AA[m] ? "yes":"no") << endl;
    }
}


Measured memory_bytes: 3112
import java.util.*;

public class Main {
    static long MOD = 109+7;

    static public void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        char[] chars = sc.nextLine().toCharArray();
        int n = chars.length;

        int ans = Integer.MAX_VALUE;
        for(int i = 0; i < 26; i++) {
            char ch = (char) ('a' + i);

            int pos = -1;
            int maxLength = 0;
            for(int j = 0; j < n; j++) {
                if(chars[j] == ch) {
                    maxLength = Math.max(maxLength, j - pos - 1);
                    pos = j;
                }
            }
            maxLength = Math.max(maxLength, n - 1 - pos);
//            System.out.println(ch + ": " + maxLength);
            ans = Math.min(ans, maxLength);
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
int main() {
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;
  int x = tx - sx, y = ty - sy;
  for (int i = 0; i < x; i++) cout << "R";
  for (int i = 0; i < y; i++) cout << "U";
  for (int i = 0; i < x; i++) cout << "L";
  for (int i = 0; i < y + 1; i++) cout << "D";
  for (int i = 0; i < x + 1; i++) cout << "R";
  for (int i = 0; i < y + 1; i++) cout << "U";
  cout << "L" << "U";
  for (int i = 0; i < x + 1; i++) cout << "L";
  for (int i = 0; i < y + 1; i++) cout << "D";
  cout << "R" << endl;
}

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

#define for_(i,a,b) for(int i=a;i<b;++i)

typedef pair< int, int > pii;
int N, W, H;

int main() {
	cin >> N >> W >> H;
	vector< pii > xp, yp;
	
	for_(i,0,N) {
		int x, y, w; cin >> x >> y >> w;
		xp.push_back(pii(max(x-w,0), min(x+w,W)));
		yp.push_back(pii(max(y-w,0), min(y+w,H)));
	}
	
	sort(xp.begin(), xp.end());
	sort(yp.begin(), yp.end());
	
	int xe = 0, ye = 0;
	for_(i,0,N) {
		if (xe >= xp[i].first) xe = max(xe, xp[i].second);
		if (ye >= yp[i].first) ye = max(ye, yp[i].second);
	}
	
	bool fx = (xe == W), fy = (ye == H);
	cout << (fx || fy ? "Yes" : "No") << endl;
}

Measured memory_bytes: 2904
#include<bits/stdc++.h>
using namespace std;
int main(int argc,char* argv[]){
    int s,h,m;
    cin>>s;
    h=s/3600;
    m=(s%3600)/60;
    s=(s%3600)%60;
    cout<<h<<":"<<m<<":"<<s<<endl;
}


Measured memory_bytes: 3088
#include <stdio.h>

int main(void) {
  char op = '?';
  int a = 0;
  int b = 0;
  int result = 0;

  scanf("%d %c %d", &a, &op, &b);

  while (op != '?') {
    if (op == '+') {
      result = a + b;
    } else if(op == '-') {
      result = a - b;
    } else if(op == '*') {
      result = a * b;
    } else if(op == '/') {
      result = a / b;
    }

    printf("%d\n", result);
    
    scanf("%d %c %d", &a, &op, &b);
  }

  return 0;
}

Measured memory_bytes: 600
console.log((args=>{
  const [[N,M],...tmp] = args.trim().split('\n').map(r=>r.split(' ').map(v=>v|0));
  const G = Array.from({length:N},_=>[]);
  for ( let i = 0; i < M; i++ ) {
    const [a,b] = tmp[i];
    G[a-1].push(b-1);
    G[b-1].push(a-1);
  }
  const stack = [[0,1]];
  const ALL = (1<<N)-1;
  let count = 0;
  while ( stack.length ) {
    const [i,a] = stack.pop();
    for ( const j of G[i] ) {
      const c = a|1<<j;
      if ( c === ALL ) count++;
      else if ( c !== a ) stack.push([j,c]);
    }
  }
  return `${count}`;
})(require('fs').readFileSync('/dev/stdin', 'utf8')));


Measured memory_bytes: 34336
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
	int n,k;
  	cin>>n>>k;
  	vint h(n+1);
  	REP(i,1,n+1){
		cin>>h[i];
    }
  	vint dp(n+1);
  	REP(i,2,n+1){
      	dp[i]=dp[i-1]+abs(h[i-1]-h[i]);
      	REP(j,2,k+1){
          	if(i-j>=1){
              	dp[i]=min(dp[i],dp[i-j]+abs(h[i-j]-h[i]));
            }
        }
    }
  	cout<<dp[n]<<'\n';
    return(0);
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
long long k,_min,_max,x_y,x,y,fibx,fiby,a;double mid;
#define MOD 1000000007
int dp[3];
int main(){
	cin>>k;
	a=sqrt(k)/16;
	x_y=(long long)((2*sqrtl(k-a-0.01))-1);
	_max=(long long)((x_y+2)*(x_y+2)/4);
	_min=(long long)((x_y+1)*(x_y+1)/4)+1;
	mid=1.0*(_max+_min)/2;
	if(k<=mid){y=(k-_min)*2;}
	else{y=(_max-k)*2+1;}
	x=x_y-y;
	if(x<3){
		fibx=x+1;
	}
    else{
		dp[0]=1;
		dp[1]=2;
		dp[2]=3;

		for(long long i=3;i<=x;i+=3)
		{
			dp[0]=(dp[1]+dp[2])%MOD;
			dp[1]=(dp[2]+dp[0])%MOD;
			dp[2]=(dp[0]+dp[1])%MOD;
		}

		fibx=dp[x%3];
    }
	if(y<3)
	{
		fiby=y+1;
	}
    else{
		dp[0]=1;
		dp[1]=2;
		dp[2]=3;

		for(long long i=3;i<=y;i+=3)
		{
			dp[0]=(dp[1]+dp[2])%MOD;
			dp[1]=(dp[2]+dp[0])%MOD;
			dp[2]=(dp[0]+dp[1])%MOD;
		}

		fiby=dp[y%3];
	}

	cout<<((long long)(fibx * fiby)%MOD)<<endl;
}

Measured memory_bytes: 3092
#include<stdio.h>
#define NUMBER 1000
int main(void)
{
    int i, tmp,num,a[NUMBER];
    scanf("%d",&num);
    for(i=0;i<num;i++)
    scanf("%d ",&a[i]);
    
    for(i=0;i<num/2;i++){
                tmp=a[i];
                a[i]=a[num-i-1];
                a[num-i-1]=tmp;
            
    }
    printf("%d",a[0]);
    for(i=1;i<num;i++)
    printf(" %d",a[i]);
printf("\n");
    return 0;
}


Measured memory_bytes: 2104
from collections import deque

H, W=map(int, input().split())
ch, cw=map(int, input().split())
dh, dw=map(int, input().split())
ch-=1 #0インデックスにする
cw-=1
dh-=1
dw-=1

grid=["0"]*H
for i in range(H):
    s=input()
    grid[i]=s

Inf=10**12
cost=[[Inf] * W for i in range(H)] #各マスへの移動コスト

walk=[(0, 1), (0, -1), (-1, 0), (1, 0)]
warp=[]

for i in range(-2, 3):
    for j in range(-2, 3):
        if i==0 and j==0:
            continue
        if (i, j) not in walk:
            warp.append((i, j))

q=deque()
cost[ch][cw]=0
q.append((ch, cw, 0))

while q:
    x, y, c=q.popleft()
    for dx, dy in walk: #移動A
        nx = x+dx
        ny = y+dy
        if 0<= nx < H and 0<= ny < W and grid[nx][ny]=="." and cost[nx][ny]>c:
            cost[nx][ny]=c
            q.appendleft((nx, ny, c)) #移動Aはコスト０,キューの先頭に追加
    
    for dx, dy in warp:#移動B
        nx = x+dx
        ny = y+dy
        if 0<= nx < H and 0<= ny < W and grid[nx][ny]=="." and cost[nx][ny]>c+1:
            cost[nx][ny]=c+1
            q.append((nx, ny, c+1)) #移動Bはコスト1,キューの最後尾に追加


if cost[dh][dw]==Inf:
    print(-1)
else:
    ans=cost[dh][dw]
    print(ans)

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

int main(){
    // 制約見て！！！デカかったらlong longにすること！
    int N;
    cin >> N;
    int o=0;
    int tmp;
    rep(i,N){
        cin >> tmp;
        if(tmp %2 == 1){
            o++;
        }
    }
    if(o%2==0){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
}

Measured memory_bytes: 3492
#include<bits/stdc++.h>
using namespace std;
const int N=1000;
int n,d1,d2,a[N][N];
void wk(int x)
{
	int k=0;
	while(x%4==0)x/=4,k++;k=1<<k;
	for(int i=0;i<n*2;i++)
	{
		for(int j=0;j<n*2;j++)
		if(x&1)
		{
			if((i/k+j/k)%2)a[i][j]=1;
		}
		else
		{
			if(i/k%2)a[i][j]=1;
		}
	}
}
int main()
{
	scanf("%d%d%d",&n,&d1,&d2);
	wk(d1),wk(d2);int now=0;
	for(int i=0;i<2*n;i++){
		for(int j=0;j<2*n;j++)
		{
			if(a[i][j])continue;
			now++;printf("%d %d\n",i,j);if(now==n*n)return 0;
		}
	}
}


Measured memory_bytes: 3200
import fractions
A,B,C,D = map(int,input().split())
 

lcm = C*D//fractions.gcd(C, D)

a_cnt = (A -1) - (((A - 1) // C) + ((A - 1) // D) - ((A - 1) // (lcm)))
b_cnt = B - ((B // C) + (B // D) - (B // (lcm)))

print(b_cnt - a_cnt)

Measured memory_bytes: 5048