akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

int main() {
    int n;
    cin >> n;
    ll sum = 0;
    int mx;
    for (int i = 1; sum < n; ++i) {
        sum += i;
        mx = i;
    }
    int diff = sum - n;
    vint ans;
    for (int i = 1; i <= mx; ++i) {
        if (i != diff) ans.push_back(i);
    }

    rep(i, ans.size()) cout << ans[i] << endl;
    return 0;
}

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

int main() {
  int I,J;
  cin >> I >> J;  
  vector<char> vec(I*J);
  for(int i=0; i<I*J; i++){
    cin >> vec.at(i);
  }
  for(int i=0; i<J+2; i++) cout << "#";
  cout << endl;
  for(int i=0; i<I; i++){
    cout << "#";
    for (int j=0; j<J; j++) cout << vec.at(j+J*i);
    cout << "#" << endl;
  }
  for(int i=0; i<J+2; i++) cout << "#";
  cout << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize(2)
#pragma G++ optimize(2)
#include<bits/stdc++.h>
#define si(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define sd(a) scanf("%lf",&a)
#define ss(a) scanf("%s",a)
#define ms(a) memset(a,0,sizeof(a))
#define repi(i,a,b) for(register int i=a,bbb=b;i<=bbb;++i)
#define repd(i,a,b) for(register int i=a,bbb=b;i>=bbb;--i)
#define reps(s) for(register int i=head[s],v=e[i].to;i;i=e[i].nxt,v=e[i].to)
#define ce(i,r) i==r?'\n':' '
#define pb push_back 
#define all(x) x.begin(),x.end()
#define gmn(a,b) a=min(a,b)
#define gmx(a,b) a=max(a,b)
#define fi first
#define se second
#define pr(x) cout<<#x<<": "<<x<<endl
using namespace std;
std::mt19937 rnd(time(0));//std::mt19937_64 rnd(time(0));
typedef long long ll;
typedef double db;
inline int qi(){
    int f=0,fu=1; char c=getchar();
    while(c<'0'||c>'9'){ if(c=='-')fu=-1; c=getchar(); }
    while(c>='0'&&c<='9'){ f=(f<<3)+(f<<1)+c-48; c=getchar(); }
    return f*fu;
}
inline ll ql(){
	ll f=0;int fu=1; char c=getchar();
    while(c<'0'||c>'9'){ if(c=='-')fu=-1; c=getchar(); }
    while(c>='0'&&c<='9'){ f=(f<<3)+(f<<1)+c-48; c=getchar(); }
    return f*fu;
}
inline ll ceil_div(ll a,ll b){ return (a+b-1)/b; }
//start!
const int MAX_N=2e5+5;
const int mod=998244353;
struct node{ int l,r; }il[MAX_N];
int dp[MAX_N],sum[MAX_N]; 
int main()
{
	int n=qi(),k=qi();
	repi(i,1,k) il[i].l=qi(),il[i].r=qi();
	dp[1]=sum[1]=1;
	repi(i,2,n){
		repi(j,1,k)if(i>il[j].l) dp[i]=(dp[i]+(sum[i-il[j].l]-sum[max(0,i-il[j].r-1)]+mod)%mod)%mod;
		sum[i]=(sum[i-1]+dp[i])%mod;
	}
	printf("%d\n",dp[n]);
	return 0;
}

Measured memory_bytes: 5312
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int W = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		//bがaより左
		if(b - (a + W) > 0){
			System.out.println(b - (a + W));
		}else if(a - (b + W) > 0){
			System.out.println(a - (b + W));
		}else{
			System.out.println(0);
		}
		

	}

}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
const long long mod = 1000000007LL;

int main() {
  ll n;
  cin >> n;
  vll a(n);
  rep(i,n) cin >> a[i];
  ll sum = 0LL;
  rep(i,n) sum += a[i];
  ll ans = 0LL;
  rep(i,n) {
    sum -= a[i];
    ll num = sum%mod;
    ans += (num*a[i]);
    ans %= mod;
  }
  if(ans<0) ans += mod;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4852
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<set>
#include<queue>
#include<map>
#include<bitset>
#include<vector>

using namespace std;

#define N 200010
#define ll long long
#define RG register
#define pb push_back

inline int read(){
    RG int x=0,o=1; RG char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=((x<<3)+(x<<1))+ch-'0',ch=getchar();
    return x*o;
}

#define pr pair<char,char>
#define mkp make_pair
#define fi first
#define sc second

int n,Q; char s[N]; vector<pr> V;

inline bool Checkl(int t){
	for(RG pr i:V){
		if(i.fi==s[t]){
			if(i.sc=='L') --t; else ++t;
		}   if(t>n) return 0; if(!t) return 1;
	}   return 0;
}
inline bool Checkr(int t){
	for(RG pr i:V){
		if(i.fi==s[t]){
			if(i.sc=='L') --t; else ++t;
		}   if(t>n) return 1; if(!t) return 0;
	}   return 0;
}

char yyb[100];
int main(){
	n=read(),Q=read(),scanf("%s",s+1);
	for(RG int i=1;i<=Q;++i){
		char a,b;
		scanf("%s",yyb+1),a=yyb[1];
		scanf("%s",yyb+1),b=yyb[1];
		V.pb(mkp(a,b));
	}

	int l=1,r=n,tmp=0,ans=0;
	while(l<=r){
		int mid=l+r>>1;
		if(Checkl(mid)) l=mid+1,tmp=mid;
		else r=mid-1;
	}   ans=tmp,l=tmp+1,r=n,tmp=n+1;
	while(l<=r){
		int mid=l+r>>1;
		if(Checkr(mid)) r=mid-1,tmp=mid;
		else l=mid+1;
	}   ans+=n-tmp+1;
	printf("%d\n",n-ans);
}


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

int main()
{
  int n,ans=0;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++)
    cin>>a[i];
  int sma=INT_MAX;
  for(int i=0;i<n;i++)
  {
    if(a[i]<sma)
    {
      ans++;
      sma=a[i];
    }
  }
  cout<<ans;
  return 0;
}
    
    

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
#include<tuple>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
int main() {
	int a, b;
	cin >> a >> b;
	int ans = max(max(a + b, a - b), a*b);
	cout << ans << endl;
	return 0;
}

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

int main() {
  string t;
  cin >> t;
  char g;
  int ans = 100; 
  for(char g='a'; g<='z'; g++) {
    string s = t;
    int cnt = 0;
    bool ok = false;
    rep(i,s.size()) {
      if(s.at(i)==g) break;
      else if(i==s.size()-1) ok = true;
    }
    while (!ok) {
      rep(i,s.size()) {
        if(s.at(i)!=g) break;
        else if(i==s.size()-1) {
          ans = min(ans,cnt);
          ok = true;
        }
      }
      cnt++;
      string u;
      rep(i,s.size()-1) {
        if(s.at(i)==g||s.at(i+1)==g) u += g;
        else u += 'A';
      }
      s = u;
    }
  }
  cout << ans << endl;
}


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

#define F first
#define S second
#define MP make_pair
#define PB push_back

using namespace std;

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

const int MAXN = 1e5 + 500;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const int LOG = 18;
const double EPS = 1e-9;
const double PI = 3.1415926535;

int dp[MAXN], h[MAXN];

int main() {
    int N, K;
    memset(dp, INF, sizeof(dp));

    cin >> N >> K;
    for(int i = 0; i < N; i++)
        cin >> h[i];

    dp[0] = 0;
    for(int i = 1; i <= K; i++)
        dp[i] = abs(h[i] - h[0]);

    for(int i = K + 1; i < N; i++)
        for(int j = 1; j <= K; j++)
            dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]));

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

    return 0;
}


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

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    
    put(min(b / a, c));
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    int a[3][3];
    for (int i = 0; i < 3; i++) for (int j = 0; j < 3; j++) std::cin >> a[i][j];
    int n;
    std::cin >> n;
    std::vector<int> b(101);
    while (n--) {
        int in;
        std::cin >> in;
        b[in] = 1;
    }

    auto get = [&](int i, int j) { return b[a[i][j]]; };
    bool r = get(0, 0) && get(0, 1) && get(0, 2)
        ||  get(1, 0) && get(1, 1) && get(1, 2)
        || get(2, 0) && get(2, 1) && get(2, 2)
        || get(0, 0) && get(1, 0) && get(2, 0)
        || get(0, 1) && get(1, 1) && get(2, 1)
        || get(0, 2) && get(1, 2) && get(2, 2)
        || get(0, 0) && get(1, 1) && get(2, 2)
        || get(0, 2) && get(1, 1) && get(2, 0);

    std::cout << (r ? "Yes" : "No") << std::endl;

    return 0;
}


Measured memory_bytes: 256
a = [0] * 5
b = [0] * 5
c = [0] * 5
for i in range(5):
    a[i] = int(input())
for i in range(5):
    b[i] = (a[i] + 9) // 10
    c[i] =(a[i]-1) % 10
print(sum(b) * 10 - 10 + min(c)+1)


Measured memory_bytes: 3060
#include<iostream>
#include<cstring>
using namespace std;
int main(){
  int n; cin>>n;
  for(int i=0;i<n;++i){
    char str1[1001],str2[1001]; cin>>str1>>str2;
    int len1=strlen(str1),len2=strlen(str2);
    int dp[1001][1001]={},max=0;
    for(int i=0;i<len1;++i){
      for(int j=0;j<len2;++j){
	if(str1[i]==str2[j]) dp[i+1][j+1]=dp[i][j]+1;
	else{
	  if(dp[i][j+1]<dp[i+1][j]) dp[i+1][j+1]=dp[i+1][j];
	  else dp[i+1][j+1]=dp[i][j+1];
	}
	if(max<dp[i+1][j+1]) max=dp[i+1][j+1];
      }
    }
    cout<<max<<endl;
  }
  return 0;
}



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

int main() {
  
    int N; cin >> N;
    int copyN = N;
    int sum=0;
    while(copyN>0){
    	sum += copyN%10;
        copyN /= 10;
    }
  
    if( N%sum==0 ){ cout << "Yes" << endl; }
    else{ cout << "No" << endl; }
  

}

Measured memory_bytes: 256
# input
N = int(input())
A = []
B = []
C = []
for _ in range(N):
    a, b, c = map(int, input().split())
    A.append(a)
    B.append(b)
    C.append(c)

dp = [{'a': None, 'b': None, 'c': None} for _ in range(N+1)]
dp[0]['a'] = 0
dp[0]['b'] = 0
dp[0]['c'] = 0

for i in range(1, N+1):
    dp[i]['a'] = max(dp[i-1]['b'] + A[i-1], dp[i-1]['c'] + A[i-1])
    dp[i]['b'] = max(dp[i-1]['c'] + B[i-1], dp[i-1]['a'] + B[i-1])
    dp[i]['c'] = max(dp[i-1]['a'] + C[i-1], dp[i-1]['b'] + C[i-1])

print(max(dp[-1].values()))


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

using namespace std;

int A, B, C;

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%d %d %d", &A, &B, &C);
if (A % 2 == 0 || B % 2 == 0 || C % 2 == 0)
{
    printf ("0\n");
    return 0;
}
if (A > B) swap (A, B);
if (A > C) swap (A, C);
if (B > C) swap (B, C);
printf ("%lld\n", 1LL * A * B);

return 0;
}


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

#define rep(n, i) for(int i = 0; i < n; i++)
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))

void solve(void){
    int H, W;
    scanf("%d %d\n", &H, &W);
    char map[H][W];
    rep(H, i) rep(W, j) scanf("%c\n", &map[i][j]);

    rep (H, i){
        rep(W, j){
            if (map[i][j] == '#') printf("#");
            else {
                int ans = 0;
                if (i > 0) if (map[i-1][j] == '#') ans++;
                if (i < H-1) if (map[i+1][j] == '#') ans++;
                if (j > 0) if (map[i][j-1] == '#') ans++;
                if (j < W-1) if (map[i][j+1] == '#') ans++;
                if (i > 0 && j > 0) if (map[i-1][j-1] == '#') ans++;
                if (i > 0 && j < W-1) if (map[i-1][j+1] == '#') ans++;
                if (i < H-1 && j > 0) if (map[i+1][j-1] == '#') ans++;
                if (i < H-1 && j < W-1) if (map[i+1][j+1] == '#') ans++;
                printf("%d", ans);
            }
        }
        printf("\n");
    }
}

int main(void){
  solve();
  return 0;
}


Measured memory_bytes: 128
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] s = sc.next().toCharArray();
		char[] t = sc.next().toCharArray();
		int N = s.length;
		int M = t.length;

		int[][] nextIndex = new int[26][N+1];
		for(int i=0; i<26; i++)
			Arrays.fill(nextIndex[i], -1);
		
		for(int i=N-1; i>=0; i--) {
			for(int j=0; j<26; j++) {
				nextIndex[j][i] = s[i]=='a'+j ? i : nextIndex[j][i+1];
			}
		}
		
		long ans = 0;
		int cur = 0;
		for(int i=0; i<M; i++) {
			if(nextIndex[t[i]-'a'][cur] < 0 ) {
				if(nextIndex[t[i]-'a'][0] < 0) {
					System.out.println(-1);
					sc.close();
					return;
				} else {
					ans += nextIndex[t[i]-'a'][0]+1 +N - cur;
					cur = nextIndex[t[i]-'a'][0]+1;
				}
			} else {
				ans += nextIndex[t[i]-'a'][cur]+1 - cur;
				cur = nextIndex[t[i]-'a'][cur]+1;
			}
		}
		
		System.out.println(ans);
		
		sc.close();
	}
}


Measured memory_bytes: 39280
import java.util.Scanner;

public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int[][] n = new int[3][3];
		for(int i = 0;i < n.length; i ++){
			for(int j = 0; j < n[0].length; j ++){
				n[i][j] = sc.nextInt();
			}
		}
		int x = sc.nextInt();
		int[] num = new int[x];
		for(int i = 0; i < num.length; i++){
			num[i] = sc.nextInt();
		}
		for(int data: num){
			for(int i = 0; i < n.length; i++){
				for(int j = 0; j < n[0].length; j++){
					if(n[i][j] == data){
						n[i][j] = -1;
					}
				}
			}
		}
		for(int i = 0; i < n.length; i++){
			if(n[i][0] + n[i][1] + n[i][2] == -3){
				System.out.println("Yes");
				break;
			}
			if(n[0][i] + n[1][i] + n[2][i] == -3){
				System.out.println("Yes");
				break;
			}
			if(n[0][0] + n[1][1] + n[2][2] == -3){
				System.out.println("Yes");
				break;
			}
			if(n[2][0] + n[1][1] + n[0][2] == -3){
				System.out.println("Yes");
				break;
			}
			if(i == 2){
				System.out.println("No");
			}
		}
	}
}


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

#define int long long

#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define FORR(i,m,n) for(int i=m;i>=n;i--)
#define pb(x) push_back(x) 
#define SORT(x) sort((x).begin(),(x).end())
#define INF 999999999999

using namespace std;

int32_t main(){
	int a, b, c;
	cin >> a >> b >> c;
	
	if(a%2 || b%2 || c%2){
		cout << 0 << endl;
		return 0;
	}
	
	if(a==b && b==c){
		cout << -1 << endl;
		return 0;
	}
	
	for(int i=1; i<INF; i++){
		int x, y, z;
		x=a/2;
		y=b/2;
		z=c/2;
		
		a=y+z;
		b=x+z;
		c=x+y;

		if(a%2 || b%2 || c%2){
			cout << i << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
using namespace std;
using ll=long long;
using ld=long double;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};

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

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n;
    cin >> n;
    vector<string> s(n);
    vl t(n);
    rep(i,n){
      cin >> s[i] >> t[i];
    }
    string st;
    cin >> st;
    ll ans=0;
    bool b=false;
    rep(i,n){
      if(b){
        ans+=t[i];
      }
      if(st==s[i]){
        b=true;
      }
    }
    cout << ans << endl;
}

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

using namespace std;

int a[100010];
vector <int>b[100010];

int main()
{
	bool check1=true;
	int n;
	cin>>n;
	int maxx=0;
	for (int i=1;i<=n;i++) 
	{
		cin>>a[i];
		if (maxx-a[i]>1) check1=false;
		maxx=max(maxx,a[i]);
	}
	if (check1)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Measured memory_bytes: 2944
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    h = I()
    num = 1
    ans = 0
    while h>1:
        h//=2
        ans += num
        num*=2
    ans += num
    print(ans)
main()


Measured memory_bytes: 74552
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

int N;

int main(void)
{
	int nowt = 0;
	int nowx = 0;
	int nowy = 0;
	cin >> N;
	for (int i = 0; i < N; ++i) {
		int t, x, y;
		cin >> t >> x >> y;
		int dis = abs(x - nowx) + abs(y - nowy);
		int tim = abs(t - nowt);
		if (dis % 2 == tim % 2 && tim >= dis) {}
		else {
			cout << "No\n";
			return 0;
		}
		nowt = t;
		nowx = x;
		nowy = y;
	}
	cout << "Yes\n";
	return 0;
}


Measured memory_bytes: 256
def main(n):
    w, h = map(int, input().split())
    xy = [list(map(lambda x:int(x)-1, input().split())) for i in range(n)]
    s, t = map(int, input().split())
    field = [[0] * w for i in range(h)]
    for x, y in xy:
        field[y][x] = 1
    ans = 0
    for y in range(h - t + 1):
        for x in range(w - s + 1):
            b = 0
            for yi in range(t):
                for xi in range(s):
                    b += field[y + yi][x + xi]
            ans = max(ans, b)
    print(ans)
while 1:
    n = int(input())
    if n == 0:
        break
    main(n)


Measured memory_bytes: 5672
#include<iostream>
#define k 10001
#define number 2000000
using namespace std;
 
void countingsort();
 
int n,A[number],B[number],C[k];
 
int main(){
   
  cin >>n;
  for(int i=0 ; i < n ; i++)cin >>A[i];
 
  countingsort();
 
  for(int i=0 ; i < n ; i++){
    if(i == n-1){
      cout <<B[i]<<endl;
    }else{
      cout <<B[i]<<" ";
    }
  }
   
  return 0;
}
 
void countingsort(){
   
  for(int i=0 ; i < k ; i++)C[i]=0;
   
  for(int i=0 ; i < n ; i++)C[A[i]]++;
   
  for(int i=1 ; i < k ; i++)C[i]=C[i]+C[i-1];
   
  for(int i=n-1 ; i >= 0 ; i--){
    B[C[A[i]]-1]=A[i];
    C[A[i]]--;
  }
   
}

Measured memory_bytes: 18748
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;

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

    Graph to(n), cost(n);
    rep(i, n-1) {
        int a, b, w;
        cin >> a >> b >> w;
        a--;  b--;
        to[a].push_back(b);
        to[b].push_back(a);
        cost[a].push_back(w);
        cost[b].push_back(w);
    }

    vector<int> ans(n, -1);
    queue<int> Q;
    ans[0] = 0;
    Q.push(0);
    while(!Q.empty()) {

        int v = Q.front();
        Q.pop();

        rep(i, to[v].size()) {

            int u = to[v][i];
            int w = cost[v][i];

            if(ans[u] != -1) {
                continue;
            }

            ans[u] = (ans[v] + w)%2;
            Q.push(u);
        }
    }

    rep(i, n) {
        cout << ans[i] << "\n";
    }
    
    return 0;
}

Measured memory_bytes: 11904
open System
open System.Collections.Generic

[<AutoOpen>]
module Cin =
    let read f = stdin.ReadLine() |> f
    let reada f = stdin.ReadLine().Split() |> Array.map f

    let readInts() =
        read string
        |> Seq.toArray
        |> Array.map (fun x -> Convert.ToInt32(x.ToString()))

module Util =
    let strRev (s: string): string =
        s
        |> Seq.rev
        |> Seq.map string
        |> String.concat ""

    let inline roundup (x: ^a) (y: ^a): ^a =
        let one = LanguagePrimitives.GenericOne
        (x + y - one) / y

[<EntryPoint>]
let main _ =
    let [|a;b|] = reada int

    match a,b with
    | _ when a + b = 15 -> "+"
    | _ when a * b = 15 -> "*"
    | _ -> "x"
    |> printfn "%s"
    0 // return an integer exit code


Measured memory_bytes: 14044
S = list(input().rstrip())
r = []
for i in range(len(S)):
    if S[i] == '0':
        r.append('0')
    elif S[i] == '1':
        r.append('1')
    elif S[i] == 'B':
        if 0 < len(r):
            del r[-1]


print(''.join(r))



Measured memory_bytes: 3060
n = int(input())
c = list(input())

w = 0
r = c.count('R')
ans = max(w, r)
for i in range(n):
    if c[i] == 'W':
        w += 1
    else:
        r -= 1
    ans = min(ans, max(w, r))
print(ans)


Measured memory_bytes: 77592
import java.util.*;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int t = 0;

			for (int i = 0; i < 2; i++)
				t += Math.min(sc.nextInt(), sc.nextInt());

			System.out.println(t);
		}
	}
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using str = string;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
const double PI = 3.141592653589793238;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = m; i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greator<>()
#define d20 std::setprecision(20)
#define veci vector<int>
#define vecll vector<long long int>
#define vecb vector<bool>
#define vecd vector<double>
template <typename T>
T lcm(T a, T b)
{
	return a / __gcd(a, b) * b;
}
void comb(vector<vector<long long int>> &v)
{
	for (size_t i = 0; i < v.size(); i++)
	{
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (size_t k = 1; k < v.size(); k++)
	{
		for (size_t j = 1; j < k; j++)
		{
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
		}
	}
}
ll repeat_squaring(ll n, ll p, ll m)
{
	if (p == 0)
		return 1;
	if (p % 2 == 0)
	{
		ll t = repeat_squaring(n, p / 2, m);
		return t * t % m;
	}
	return n * repeat_squaring(n, p - 1, m);
}

int main()
{
	int a, p;
	cin >> a >> p;
	cout << (a * 3 + p) / 2 << endl;
	return 0;
}

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


using namespace std;



int main() {
    //fstream cin("A.in");
    //ofstream cout("A.out");
    int n;
    long long a, b, c, d;
    ios::sync_with_stdio(false);
    cin >> n >> a >> b >> c >> d;
    for(long long i = 0; i < n; i++) {
        if( - i * d + c * (n - i - 1) <= b - a && b - a <=  - i * c + d * (n - i - 1)) {
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
    //cin.close();
    //cout.close();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll n;
    cin >> n;

    if(n == 3) {
        cout << 2 << " " << 5 << " " << 63 << endl;
        re0;
    }

    if(n == 20000) {
        exrep(i, 1, 30000) {
            if(i%2 == 0 || i%3 == 0) {
                cout << i << " ";
            }
        }
        cout << endl;
        re0;
    }

    cout << 2 << " " << 4 << " ";

    ll cnt = 2;
    if(n%2 == 1) {
        cout << 30000 << " ";
        cnt++;
    }
    
    for(ll i = 3; i < 15000; i += 3) {
        cout << i << " " << 30000 - i << " ";
        cnt += 2;
        if(cnt == n) {
            cout << endl;
            re0;
        }
    }
    for(ll i = 8; i <= 30000; i += 2) {
        if(i%3 != 0) {
            cout << i << " ";
            cnt++;
        }
        if(cnt == n) {
            cout << endl;
            re0;
        }
    }
    
    re0;
}

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

using namespace std;

bool graph[8][8];

int dfs(int v, int n, bool visited[8])
{
    bool allv = true;

    for (int i=0; i<n; i++) {
        if (visited[i] == false) allv = false;
    }
    if (allv == true) return 1;

    int ret = 0;

    for (int i=0; i<n; i++) {
        if (graph[v][i] == false) continue;
        if (visited[i] == true) continue;

        visited[i] = true;
        ret += dfs(i, n, visited);
        visited[i] = false;
    }

    return ret;
}
int main()
{
    int n, m, a[28], b[28];
    cin >> n >> m;
    for (int i=0; i<m; i++) {
        int a, b;
        cin >> a >> b;
        graph[a-1][b-1] = graph[b-1][a-1] = true;
    }

    bool visited[8];
    for (int i=0; i<n; i++) {
        visited[i] = false;
    }

    visited[0] = true;
    cout << dfs(0, n, visited) << endl;

    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

init = sum(A)
remain = 0
for i in range(N):
    if(B[i] <= A[i]):
        A[i] -= B[i]
    else:
        B[i] -= A[i]
        A[i] = 0
        if(B[i] <= A[i+1]):
            A[i+1] -= B[i]
        else:
            A[i+1] = 0

print(init - sum(A))


Measured memory_bytes: 18476
xy[3][501][501];
n,m,a,b,c,i;
D(a,b){
	if(!xy[c][a][b]++)
		for(i=1;i<=n;i++)
			m-=!xy[(c+2)%3][b][i]&&!xy[(c+1)%3][i][a];
}
main(h){
	for(;scanf("%d%d",&n,&h)*n;){
		memset(xy,0,sizeof(xy));
		m=n*n*n;
		for(;h--;){
			scanf("%s%d%d",&c,&a,&b);
			c%=3;
			c<2?D(a,b):D(b,a);
		}
		printf("%d\n",m);
	}
	{int n;for(n=1000000;n--;)getchar();}//delay(0.52s)
	exit(0);
}

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

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        int n = sc.NextInt();
        int[] a = sc.IntArray();

        int[] count = new int[1000001];
        for (int i = 0; i < n; i++)
        {
            count[a[i]]++;
        }

        int answer = 0;
        for (int i = 1; i < 1000000; i++)
        {
            int sum = count[i - 1] + count[i] + count[i + 1];
            answer = Math.Max(answer, sum);
        }

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 18144
#include <stdio.h>

int main(){
	int r,g,b,num;

	scanf("%d", &r);
	scanf("%d", &g);
	scanf("%d", &b);

	num = r * 100 + g * 10 + b;

	if(num % 4 == 0){
		printf("YES\n");
	}else{
		printf("NO\n");
	}

	return 0;

}

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

ll dp[100005];

int main(){
    int n,w;
    scanf(" %d %d",&n,&w);
    for(int i = 0; i <= w;++i)
        dp[i] = -10000000000000000ll;
    ll ans = 0;
    dp[0] = 0;
    while(n--){
        int we;ll va;
        scanf(" %d %lld",&we,&va);
        for(int i = w; i > -1;--i){
            if(i - we > -1)
                dp[i] = max(dp[i],dp[i-we]+va);
            ans = max(ans,dp[i]);
        }
    }
    printf("%lld\n",ans);
    return 0;
}


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

#ifdef _DEBUG
#define debug(x) cerr << "line: " << __LINE__ << ", func: " << __func__ << " ->  " << #x << " = " << x << endl
#else
#define debug(x)
#endif

#define all(s) begin(s), end(s)
#define rall(s) rbegin(s), rend(s)
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = ((a)-1); i >= (b); i--)
#define pb push_back
#define sz(a) int((a).size())
#define fi first
#define se second

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_ll = pair<ll, ll>;
using d_ll = pair<double, ll>;
using ll_d = pair<ll, double>;
using d_d = pair<double, double>;
template <class T> using vec = vector<T>;

static constexpr ll LL_INF = 1LL << 60;
static constexpr int I_INF = 1 << 28;
static constexpr double PI = static_cast<double>(3.14159265358979323846264338327950288);
static constexpr double EPS = numeric_limits<double>::epsilon();

static map<type_index, const char* const> scanType = {
    {typeid(int), "%d"}, {typeid(ll), "%lld"}, {typeid(double), "%lf"}, {typeid(char), "%c"}};

template <class T> static void scan(vector<T>& v);
[[maybe_unused]] static void scan(vector<string>& v, bool isWord = true);
template <class T> static inline bool chmax(T& a, T b);
template <class T> static inline bool chmin(T& a, T b);
template <class A, size_t N, class T> static void Fill(A (&arr)[N], const T& val);

int main(int argc, char* argv[]) {
  ll n;
  cin >> n;
  vec<ll> p(n), idx(n);
  scan(p);
  rep(i, 0, n) idx[p[i] - 1] = i;
  multiset<int> s;
  s.insert(-1), s.insert(-1), s.insert(n), s.insert(n);

  ll ans = 0;
  rrep(i, n, 0) {
    s.insert(idx[i]);
    auto it = s.find(idx[i]);
    auto pr1 = prev(it, 1), pr2 = prev(it, 2);
    auto ne1 = next(it, 1), ne2 = next(it, 2);

    ans += ((*pr1) - (*pr2)) * ((*ne1) - idx[i]) * (i + 1);
    ans += ((*ne2) - (*ne1)) * (idx[i] - (*pr1)) * (i + 1);
  }

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

template <class T> static void scan(vector<T>& v) {
  auto tFormat = scanType[typeid(T)];
  for (T& n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string>& v, bool isWord) {
  if (isWord) {
    for (auto& n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

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

template <class A, size_t N, class T> void Fill(A (&arr)[N], const T& val) {
  std::fill((T*)arr, (T*)(arr + N), val);
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
#define int long long
typedef long long ll;
const int INF = 1001001001001001001ll;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

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

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

signed main() {
  int X;
  cin >> X;
  int ans = X / 500 * 1000;
  X %= 500;
  ans += X / 5 * 5;
  cout << ans << endl;
}

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

#pragma GCC optimize ("O3")

signed main(){

  int N, M, Q; cin >> N >> M >> Q;
  vector<int16_t> L(M), R(M), p(Q), q(Q);
  for(int i = 0; i < M; i++){
    cin >> L[i] >> R[i];
  }

  vector<int> ans(Q);
  for(int i = 0; i < Q; i++){
    cin >> p[i] >> q[i];
  }

  const int Q1 = Q / 6 * 6;
  for(int i = 0; i < Q1; i+=6){
    for(int j = 0; j < M; j++){
      ans[i + 0] += (p[i + 0] <= L[j]) & (R[j] <= q[i + 0]);
      ans[i + 1] += (p[i + 1] <= L[j]) & (R[j] <= q[i + 1]);
      ans[i + 2] += (p[i + 2] <= L[j]) & (R[j] <= q[i + 2]);
      ans[i + 3] += (p[i + 3] <= L[j]) & (R[j] <= q[i + 3]);
      ans[i + 4] += (p[i + 4] <= L[j]) & (R[j] <= q[i + 4]);
      ans[i + 5] += (p[i + 5] <= L[j]) & (R[j] <= q[i + 5]);
    }
  }
  for(int i = Q1; i < Q; i++){
    for(int j = 0; j < M; j++){
      ans[i] += (p[i] <= L[j]) & (R[j] <= q[i]);
    }
  }

  for(int i = 0; i < Q; i++){
    printf("%d\n", ans[i]);
  }

  return 0;
}


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

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

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

  vector<vector<int>> G(N);
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  int ans = 0;
  for (int i = 0; i < N; i++) {
    bool can = true;
    for (int nv : G.at(i)) {
      if (H.at(i) <= H.at(nv)) {
        can = false;
      }
    }
    if (can) ans++;
  }

  cout << ans << endl;
}


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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SIZE(a) int((a).size())

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

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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


void Main()
{
    int n,m,q;cin>>n>>m>>q;

    VPII train(m);

    REP(i,m){
        int l,r;cin>>l>>r;
        l--;
        r--;
        train[i] = MP(l,r);
    }

    SORT_ASC(train);

    VVI result(n);
    REP(i,n){
        result[i].resize(n);
    }

    int now = 0;
    REP(i,n){
        while(now < m && train[now].first < i){
            now++;
        }

        FOR(j,now,m){
            result[i][train[j].second]++;
        }
    }

    REP(i,n){
        FOR(j,1,n){
            result[i][j] += result[i][j-1];
        }
    }

    REP(i,q){
        int a,b;cin>>a>>b;
        cout<<result[a-1][b-1]<<endl;
    }

	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

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

#define endl '\n'
#define db(x) cerr << #x << " == " << x << endl
#define dbs(x) cerr << x << endl
#define st first
#define nd second
#define pb push_back
#define mp make_pair
#define inf 0x3f3f3f3f
#define linf 0x3f3f3f3f3f3f3f3f

typedef long long ll;
typedef pair <int, int> pii;
typedef vector<int> vi;
const int N = 1e4+5;
const ll mod = 1e9+7;
const char z='0';
string k;
ll d;
ll f[104][N], g[104][N];

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

  cin >> k >> d;
  reverse(k.begin(), k.end());
  int n=k.size();
  for(int res=0; res<d; res++){
    for(int p=0; p<10; p++){
      f[res][0]+=((res+p)%d)==0;
      if(p<=k[0]-z) g[res][0]+=((res+p)%d) == 0;
    }
  }

  for(int i=1; i<n; i++){
    for(int res=0; res<d; res++){
      for(int p=0; p<10; p++){
        f[res][i]+=f[(res+p)%d][i-1]%mod;
        if(p<k[i]-z) g[res][i]+=f[(res+p)%d][i-1]%mod;
        if(p==k[i]-z) g[res][i]+=g[(res+p)%d][i-1]%mod;
        f[res][i]%=mod;
        g[res][i]%=mod;
      }
    }
  }

  cout << (g[0][n-1] + mod-1)%mod << endl;
}

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

namespace ABC081A
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            char[] cs = str.ToCharArray();
            int j = 0;
            foreach (var item in cs)
            {
                if (item == '1')
                {
                    ++j;
                }
            }
            Console.WriteLine("{0}",j);
            Console.Read();
        }
    }
}


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

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

  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  int sum = 0;
  for (int i = 0; i < N; i++) {
    int j = 0;
    while (j*A.at(i)+1<=D) {
        sum++;
        j++;
    }
  }

  cout << sum + X << endl;

}

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

void show(vector<int> a){
	for(int i=0 ; i<(int)a.size() ; i++ ){
		cout << a[i];
		if( i == (int)a.size()-1 )
			cout << endl;
		else
			cout << " ";
	}
}

int sigma(vector<int> a){
	int val=0;
	for(int i=0 ; i<(int)a.size() ; i++ )
		val += a[i];
	return val;
}

void f(vector<int> a, int n, int k){
	for(int i=(n-sigma(a)) ; i > 0 ; i-- ){
		if( k == 0 || a[k-1] >= i ){
			a.push_back( i );
			if( sigma(a) == n ){
				show( a );
			}else{
				f( a , n , k+1 );
			}
			a.pop_back();
		}
	}
}

int main(){
	int n;
	vector<int> a;
	
	while( cin >> n , n ){
		f( a , n , 0 );
	}
}

Measured memory_bytes: 0
a = int(input())
b = int(input())
a = a % 360
b = b % 360
if a > b :
    a, b = b, a
if b - a > 180 :
    a += 360
t = abs((a - b) / 2)
ans = min(a, b) + t
ans = ans % 360
print('{:6f}'.format(ans))


Measured memory_bytes: 5628
n, m, l = map(int, input().split())
A = [tuple(map(int, input().split())) for _ in range(n)]
B = [tuple(map(int, input().split())) for _ in range(m)]
B_T = [tuple(r) for r in zip(*B)]
for L in ((sum((a*b for a, b in zip(ai, bj))) for bj in B_T) for ai in A):
    print(*L)

Measured memory_bytes: 8696
#include <bits/stdc++.h>
#define rg register
#define us unsigned
#define ll long long
#define ui <int>
#define pi <int, int>
#define tmpl template <typename typ>
#define oprt operator
#define sp putchar(32)
#define el putchar(10)
#define flin(x) freopen(x, "r", stdin)
#define flout(x) freopen(x, "w", stdout)
#define flio(x) flin(x".in"), flout(x".out")
#define ms(a, b) memset(a, b, sizeof(a))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define itrt iterator
using namespace std;
tmpl inline bool up(typ &x, const typ &y) { return x < y ? x = y, 1 : 0; }
tmpl inline bool dn(typ &x, const typ &y) { return y < x ? x = y, 1 : 0; }
tmpl inline bool inr(const typ &x, const typ &l, const typ &r) { return !(x < l) && !(r < x); }
namespace orh {
inline void useios() { ios_base::sync_with_stdio(false); cin.tie(0); }
inline char rc() { rg char ch; while (!isgraph(ch = getchar())); return ch; }
tmpl typ ri() {
	rg typ x = 0; rg bool neg = false; rg char ch;
	while (!inr(ch = getchar(), '0', '9')) neg |= ch == '-';
	do x = (x << 1) + (x << 3) + (ch ^ 48); while (inr(ch = getchar(), '0', '9'));
	return neg ? -x : x;
}
tmpl typ ru() {
	rg typ x = 0; rg char ch;
	while (!inr(ch = getchar(), '0', '9'));
	do x = (x << 1) + (x << 3) + (ch ^ 48); while (inr(ch = getchar(), '0', '9'));
	return x;
}
tmpl void wi(rg typ x) {
	if (x < 0) { putchar('-'); x = -x; }
	static int sta[42]; rg int top = 0; rg typ t;
	do t = x / 10, sta[top++] = x - (t << 1) - (t << 3), x = t; while (x);
	while (top) putchar(sta[--top] ^ 48);
}
tmpl void wu(rg typ x) {
	static int sta[42]; rg int top = 0; rg typ t;
	do t = x / 10, sta[top++] = x - (t << 1) - (t << 3), x = t; while (x);
	while (top) putchar(sta[--top] ^ 48);
}
}

const int maxn = 2e5 + 5;
const int inf = 1e9;
int n, d, val, tx[maxn];
ll c[maxn], ans;
struct monster {
	int x, h;
} a[maxn];

inline bool cmp(monster p, monster q) { return p.x < q.x; }

inline ll lowbit(int x) { return x & (-x); }
void add(int i, ll x) {
	for (; i <= n; i += lowbit(i))
		c[i] += x;
}
ll sum(int i) {
	ll ret = 0;
	for (; i; i -= lowbit(i))
		ret += c[i];
	return ret;
}

signed main() {
	orh::useios();
	
	cin >> n >> d >> val;
	for (rg int i = 1; i <= n; ++i)
		cin >> a[i].x >> a[i].h;
	sort(a + 1, a + n + 1, cmp);
	for (rg int i = 1; i <= n; ++i) {
		add(i, a[i].h - a[i - 1].h);
		tx[i] = a[i].x;
	}
	
	for (rg int l = 1; l <= n; ++l) {
		int w = sum(l);
		if (w <= 0) continue;
		int pos = a[l].x + d, r;
		if ((ll)pos + d > (ll)inf) r = n;
		else r = (upper_bound(tx + l, tx + n + 1, pos + d) - tx) - 1;
		int tim = (w % val == 0) ? (w / val) : (w / val + 1);
		add(l, -((ll)tim * val)); add(r + 1, (ll)tim * val);
		ans += (ll)tim;
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 4224
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations
    #from itertools import accumulate, product
    from bisect import bisect_left,bisect_right
    from math import floor, ceil
    #from operator import itemgetter
    import numpy as np
    #mod = 1000000007

    N,K = map(int, input().split())
    a = list(map(int, input().split()))
    a = sorted(a)

    def check(num):
        dp = np.zeros((N+1, K), dtype=np.bool)
        dp[0,0] = 1
        for i in range(N):
            # まとめて遷移
            dp[i+1] |= dp[i]
            #i番目のカードはスルー
            if i != num and a[i] < K:
                dp[i+1,a[i]:] |= dp[i,:K-a[i]]
        return any(dp[N, -a[num]:])

    left = -1
    right = N
    while right - left > 1:
        mid = (left+right)//2
        if check(mid):
            right = mid
        else:
            left = mid
    print(right)

    # 間に合わないよ～><
    # def dp(num):
    #     dp = [[0]*(K) for _ in range(n)]
    #     dp[0][0] = 1
    #     b = a[:num]+a[num+1:] #N-1個
    #     for i in range(n-1):
    #         for j in range(K):
    #             if b[i]<=j:
    #                 dp[i+1][j] = dp[i][j-b[i]] or dp[i][j]
    #             else:
    #                 dp[i+1][j]=dp[i][j]
    #     return any(dp[n-1][K-a[num]:])

if __name__ == '__main__':
    main()

Measured memory_bytes: 38688
#pragma GCC optimize(2)
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define sc(z) scanf("%d", &(z))
#define _ff(i, a, b) for (int i = (a); i <= (b); ++i)
#define _f(i, a, b) for (int i = (a); i < (b); ++i)
#define _rr(i, a, b) for (int i = (a); i >= (b); --i)
#define _r(i, a, b) for (int i = (a); i > (b); --i)
const int inf = 0x3f3f3f3f;
const int maxn = 1e6 + 5;

int main() {
    char s[10];
    cin >> s;
    int ans = 0;
    _f(i, 0, strlen(s)) {
        int k = 0;
        if (s[i] == 'R') {
            while (s[i] == 'R') {
                k++;
                i++;
            }
            ans = max(ans, k);
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
	int N, M;
	cin >> N;
	vector<int> T(N);
	for (int i = 0; i < N; i++) cin >> T[i];
	cin >> M;
	vector<int> P(M), X(M);
	for (int i = 0; i < M; i++) cin >> P[i] >> X[i];
	int sum = 0;
	for (int i = 0; i < N; i++) sum += T[i];
	for (int i = 0; i < M; i++) cout << sum - T[P[i] - 1] + X[i] << endl;
}

Measured memory_bytes: 256
N=int(input())
l=["a","b","c","d","e","f","g","h","i","j"]
def hu(t,c,n):
    if n<N:
        for i in range(0,c):
            hu(t+[i],c,n+1)
        hu(t+[c],c+1,n+1)
    else:
        pr(t)
def pr(t):
    for i in t:
        print(l[i],end="")
    print()
hu([0],1,1)

Measured memory_bytes: 5548
def main():
    S = input()
    S_l = len(S)
    T = []

    for i in range(S_l-1):
        if S[i] != S[i+1]:
            T.append(max([i+1, S_l-i-1]))

    if T != []:
        return min(T)
    else:
        return S_l

if __name__ == '__main__':
    print(main())

Measured memory_bytes: 5204
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int ov = 0;
        int s = 0;
        for (int i = 0; i < N; i++) {
            int d = sc.nextInt();
            ov += d * d;
            s += d;
        }
        System.out.println((s * s - ov)/2);
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = LONG_LONG_MAX / 2;

int main() {
    ll N; cin >> N;
    ll m = INF;
    for (int i = 0; i < 5; i++)
    {
        ll x; cin >> x;
        m = min(m, x);
    }
    cout << (N+m-1)/m + 4 << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>

using namespace std;


int main(){
  int a,b,c;
  cin>>a>>b>>c;
  cout<<min(b/a,c)<<endl;

  
}

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

using namespace std;

int main() {
	long long N=50,K; cin >> K;
    cout << N << endl;
	for(int i=0;i<N;++i) {
		if(i) cout << " ";
		cout << (K-i+N-1)/N-i+N-1;
	}
	cout << endl;
	
	return 0;
}

Measured memory_bytes: 256