akhauriyash/Code-Regression huggingface dataset:
#include<iostream> 
#include<cmath>
#include<malloc.h>
using namespace std;
int main()
{
	long long health,k=0,n;
	cin>>health>>n;
	int *move;
	move  = (int *)malloc(100001*sizeof(int));
	for(long long i=0;i<n;i++)
		cin>>move[i];
	for(long long i=0;i<n;i++)
		k += move[i];
	if(k>=health)
		cout<<"Yes";
	else
		cout<<"No";
	
	return 0;
	
}

Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{
  int N, K;
  int A;

  scanf("%d", &N);
  scanf("%d", &K);
  if (K==1)
  {
    A=0;
  }else
  {
    A = N - K;
  }
  

  printf("%d", A);
  
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define pb push_back
const int maxn = 10000;
const int INF32 = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7 = 1'000'000'007;
const int MOD9 = 1'000'000'009;
const int mod = MOD7;

void ERROR(int num) { cout << "ERROR" << num << endl; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};


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

    int K;
    string S;
    cin >> K;
    cin >> S;

    if(S.length() <= K){
    	cout << S << endl;
    }else{
    	rep(i,K){
    		cout << S[i];
    	}
    	cout << "..." << endl;
    }

}

Measured memory_bytes: 3656
def LI():
    return list(map(int, input().split()))


N, H = LI()
amax = 0
blist = []
for _ in range(N):
    a, b = LI()
    amax = max(amax, a)
    blist.append(b)
blist.sort()
ans = 0
for i in range(N-1, -1, -1):
    if blist[i] <= amax:
        break
    ans += 1
    H -= blist[i]
    if H <= 0:
        break
if H > 0:
    if H % amax == 0:
        ans += H//amax
    else:
        ans += H//amax+1

print(ans)


Measured memory_bytes: 13048
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const int INF = (1 << 30) - 1;
// const ll LL_INF = (1LL << 62) - 1;
const ll MOD = 1e9 + 7;

ll N, K;

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

  ll ans = 0;
  for (ll i = K; i <= N + 1; i++) {
    ll u = i * (N - i + 1 + N) / 2;
    ll l = i * (i - 1) / 2;
    ans += u - l + 1;
    ans %= MOD;
  }

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

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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } 
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define ll long long 
#define INF 999999999
#define rep(i,n) for(int i=0;i<n;i++)
using Graph = vector<vector<int>>;
queue<int> quex,quey;
const int MOD = 1000000007;




int main(){
    string s;
    cin >> s;
    int a;
    if(s=="SUN") a=0;
    if(s=="MON") a=1;
    if(s=="TUE") a=2;
    if(s=="WED") a=3;
    if(s=="THU") a=4;
    if(s=="FRI") a=5;
    if(s=="SAT") a=6;

    cout << 7-a << endl;




}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    ll A, B, K;
    cin >> A >> B >> K;

    cout << A - min(A, K) << " " << max(0LL, B - max(0LL, K - A)) << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    private static Integer N;
    private static List<List<List<Integer>>> map = new ArrayList<>();

    public static boolean judge(Integer bit) {

        for (int i = 0; i < N; ++i) {
            // i人目が「不親切」だったら、証言は無意味
            if ((bit & (1 << i)) == 0) continue;

            List<List<Integer>> xys = map.get(i);
            // それぞれ確認
            for (List<Integer> xy : xys) {
                Integer x = xy.get(0);
                Integer y = xy.get(1);

                if (y == 1 && ((bit & (1 << x)) == 0)) return false;
                if (y == 0 && ((bit & (1 << x)) != 0)) return false;
            }
        }
        return true;
    }

    public static void main(String[] args) {
        //コード
        Scanner scanner = new Scanner(System.in);
        N = Integer.parseInt(scanner.next());

        // ここで初期化
        for (int i = 0; i < N; i++) {
            int A = Integer.parseInt(scanner.next());
            List<List<Integer>> xys = new ArrayList<>();

            for (int j = 0; j < A; ++j) {
                List<Integer> xy = new ArrayList<>();
                xy.add(Integer.parseInt(scanner.next()) - 1);
                xy.add(Integer.parseInt(scanner.next()));
                xys.add(xy);
            }
            map.add(xys);
        }

        int res = 0;
        for (int bit = 0; bit < (1 << N); ++bit) {
            if (judge(bit)) {
                int count = 0;
                for (int i = 0; i < N; ++i) {
                    if ((bit & (1 << i)) != 0) ++count;
                }
                res = Math.max(res, count);
            }
        }

        System.out.println(res);
    }
}

Measured memory_bytes: 26580
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <tuple>

using namespace std;
typedef pair<int, int> pii;
static const int INF = 1000000000;

int main(){
	ios_base::sync_with_stdio(false);
	int n, w, h;
	cin >> n >> w >> h;
	vector<pii> ranges;
	for(int i = 0; i < n; ++i){
		int x, y;
		string f;
		cin >> x >> y >> f;
		const int hw2 = h + w + h + w;
		const int lu = y + x;
		const int ru = h + x + (h - y);
		const int rd = h + w + (h - y) + (w - x);
		const int ld = h + w + h + (w - x) + y;
		int lo = 0, hi = 0;
		if(f[0] == 'N'){
			lo = lu; hi = ru;
		}else if(f[0] == 'E'){
			lo = ru; hi = rd;
		}else if(f[0] == 'S'){
			lo = rd; hi = ld;
		}else if(f[0] == 'W'){
			lo = ld; hi = lu + hw2;
		}
		if(lo >= hw2){
			lo -= hw2;
			hi -= hw2;
		}
		ranges.emplace_back(lo, hi);
		ranges.emplace_back(lo + hw2, hi + hw2);
	}
	sort(ranges.begin(), ranges.end());
	int answer = INF;
	for(int i = 0; i < n; ++i){
		const int hw2 = (h + w) * 2;
		vector<pii> r(ranges.begin() + i, ranges.begin() + i + n);
		sort(r.begin(), r.end(), [](const pii &a, const pii &b){
			return (a.second == b.second) ? (a.first < b.first) : (a.second < b.second);
		});
		int count = 1, last = r[0].second;
		for(int j = 0; j < n; ++j){
			if(r[j].first <= last){ continue; }
			if(r[j].second >= r[0].second + hw2){ continue; }
			++count;
			last = r[j].second;
		}
		answer = min(answer, count);
	}
	cout << answer << endl;
	return 0;
}

Measured memory_bytes: 3284
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>

int main(){
    int w, a, b;
    std::cin>>w>>a>>b;

    int res;
    if(a + w <= b){
        res = b - (a + w);
    }else if(b + w <= a){
        res = a - (b + w);
    }else{
        res = 0;
    }
    std::cout<<res<<std::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;
const int INF=INT_MAX,MOD=1e9+7;

bool board[25][25];
int dy[4]={-1,0,1,0},dx[4]={0,1,0,-1};
int sy,sx,gy,gx;
int w,h;
int ans=INF;

bool object(int y,int x){
	if(!board[y][x]){
		return 1;
	}
	return 0;
}
bool out(int y,int x){
	if(0<=y&&y<h&&0<=x&&x<w){
		return 1;
	}
	return 0;
}

void dfs(int y,int x,int num){
	// cout<<y<<" "<<x<<" "<<num<<endl;
	if(num>9) return;
	rep(i,4){
		if(out(y+dy[i],x+dx[i])&&object(y+dy[i],x+dx[i])){
			int j=0;
			while(1){
				j++;
				if(!out(y+dy[i]*j,x+dx[i]*j)) break;
				if(gy==y+dy[i]*j&&gx==x+dx[i]*j){
					ans=min(ans,num+1);
					return;
				}
				if(!object(y+dy[i]*j,x+dx[i]*j)){
					board[y+dy[i]*j][x+dx[i]*j]=0;
					j--;
					dfs(y+dy[i]*j,x+dx[i]*j,num+1);
					j++;
					board[y+dy[i]*j][x+dx[i]*j]=1;
					break;
				}
			}
		}
	}
	return;
}

int main(){
	while(cin>>w>>h&&w){
		ans=INF;
		rep(i,25)rep(j,25) board[i][j]=0;
		rep(i,h)rep(j,w){
			int x; cin>>x;
			if(x==2){
				sy=i; sx=j; x=0;
			}
			if(x==3){
				gy=i; gx=j; x=0;
			}
			board[i][j]=x;
		}
		dfs(sy,sx,0);
		if(ans==INF) cout<<-1<<endl;
		else cout<<ans<<endl;
	}
	return 0;
}



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

typedef long long ll;
const ll INF = 1LL<<60, MOD = 1e9 + 7;
const double EPS = 1e-9, PI = 3.141592653589793;
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define all(v) (v).begin(), (v).end()
#define fi first
#define se second
#define m_p make_pair

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll a,b,c;
    cin >> a >> b >> c;
    if(c-(a-b)>0){
        cout << c-(a-b) << endl;
    }else{
        cout << 0 << endl;
    }
    return 0;
}

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

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

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

    vector<ll> A(N);
    for(ll i = 0; i < N; ++i){
        cin >> A[i];
    }

    vector<pll> BC(M);
    for(ll i = 0; i < M; ++i){
        cin >> BC[i].second >> BC[i].first;
    }
    
    sort(begin(A), end(A));

    sort(begin(BC), end(BC), greater<pll>());

    ll x = 0;
    for(ll i = 0; i < M; ++i){
        ll cnt = BC[i].second;
        while(x < N && cnt > 0L){
            if(A[x] < BC[i].first){
                A[x++] = BC[i].first;
                --cnt;
            }else{
                break;
            }
        }

        if(x >= N){
            break;
        }
    }

    cout << accumulate(begin(A), end(A), 0L) << endl;

}

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

#define rep(i,n) for(ll i = 0; i < n; i++)
#define per(i,n) for(ll i = n-1; i >= 0; i--)
#define REP(i,n) for(ll i = 1; i < n; i++)
#define PER(i,n) for(ll i = n; i >= 1; i--)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
using vP = vector<P>;
using vPP = vector<vP>;
using vPl = vector<Pl>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
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; }



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

  ll n;
  cin >> n;
  ll ans = infll;
  for(ll i = 1; i*i <= n; i++) {
    if(n % i == 0) {
      chmin(ans, i + n/i - 2);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
def lp_norm(x, y, p):
    if p == "INF":
        return max([abs(x_i - y_i) for (x_i, y_i) in zip(x, y)])
    else:
        return (sum([abs(x_i - y_i) ** p for (x_i, y_i) in zip(x, y)])) ** (1/p)


n = int(input())
x = [float(i) for i in input().split()]
y = [float(i) for i in input().split()]

for i in [1, 2, 3, "INF"]:
    print(lp_norm(x, y, i))



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

using namespace std;

int main()
{
    string S; cin >> S;
  
    map<char, string> mp;
    mp['S'] = "Cloudy";
    mp['C'] = "Rainy";
    mp['R'] = "Sunny";
  
    cout << mp[S[0]] << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll gcd(ll a, ll b) {
	return b ? gcd(b, a % b) : a;
}
ll inf = 1000000000;
int main() {
	ll n;
	string s;
	cin >> n;
	cin >> s;
	ll rcount = 0, gcount = 0, bcount = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'R') {
			rcount++;
			continue;
		}
		if (s[i] == 'G') {
			gcount++;
			continue;
		}
		else{
			bcount++;
		}
	}
	ll count = rcount*gcount*bcount;
	ll k;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			k = 2 * j - i;
			if (k >= n)continue;
			if (s[i] != s[k] && s[i] != s[j] && s[j] != s[k])count--;
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using ll = long long;

int main() {
    char s;
    cin >> s;
    if (isupper(s)) cout << 'A' << endl;
    else cout << 'a' << endl;

    return 0;
}

Measured memory_bytes: 3636
import unittest


class TestD(unittest.TestCase):
    def test_1(self):
        self.assertEqual(think(25), 17)

    def test_2(self):
        self.assertEqual(think(1), 1)

    def test_3(self):
        self.assertEqual(think(100), 108)

    def test_4(self):
        self.assertEqual(think(2020), 40812)

    def test_5(self):
        self.assertEqual(think(200000), 400000008)


def solve():
    n = read()
    result = think(n)
    write(result)


def read():
    return read_int(1)[0]


def read_int(n):
    return read_type(int, n, sep=' ')


def read_float(n):
    return read_type(float, n, sep=' ')


def read_type(t, n, sep):
    return list(map(lambda x: t(x), read_line().split(sep)))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(n):
    count = 0
    dp = [[0 for last_digit in range(10)] for first_digit in range(10)]
    for i in range(1, n + 1):
        first_digit = first_digit_of(i)
        last_digit = last_digit_of(i)
        dp[first_digit][last_digit] += 1
    for first_digit in range(10):
        for last_digit in range(10):
            count += dp[first_digit][last_digit] * dp[last_digit][first_digit]
    return count


def write(result):
    print(result)


def first_digit_of(a):
    return int(str(a)[0])


def last_digit_of(a):
    return int(str(a)[-1])


if __name__ == '__main__':
    # unittest.main()
    solve()

Measured memory_bytes: 52456
#include<iostream>
#include<vector>
#include<string>

using namespace std;

typedef long long ll;


int main(){
 ll A,B; cin >> A >> B; A--; 
  ll a,b;
  if( A % 4 == 1){
    a = 1;}
  else if( A % 4 == 3){
    a = 0;}
  else if( A % 4 == 2){
    a = ( A + 1) ^ 0;}
  else if( A % 4 == 0){
    a = (A + 1 ) ^ 1;}
  
  if( B % 4 == 1){
    b = 1;}
  else if( B % 4 == 3){
    b = 0;}
  else if( B % 4 == 2){
    b = ( B + 1) ^ 0;}
  else if( B % 4 == 0){
    b = ( B + 1) ^ 1;}
  
  cout << (a^b) << endl;
  return 0;}
  
    

    
  
  

Measured memory_bytes: 256
//encoding:utf-8
#include <iostream> //c++
#include<time.h> //時間にかんして
#include<stack> //スタックに関して　最新のデータから捨てる
#include<queue> //キューに関して　最古のデータから捨てる

#define ll long long
using namespace std;

int month,day;
int ans=0;

int main(){
  cin>>month>>day;
  for(int i=1;i<=month;i++){
    if(day<=12){
      ans = month-1;
    }
    if(day>=month){
      ans++;
    }
  }
  cout<<ans<<"\n";
  return 0;
}


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

class Main{
  public static void main(String args[]) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String s = br.readLine();
    String res = "Good";
    
	if(s.charAt(0) == s.charAt(1)){
      res = "Bad";
    }
	if(s.charAt(1) == s.charAt(2)){
      res = "Bad";
    }
	if(s.charAt(2) == s.charAt(3)){
      res = "Bad";
    }
    System.out.print(res);
  }
}

Measured memory_bytes: 22484
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>



using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)











ll POW(ll n, ll m, ll p){
    ll res = 1, x = n;
    for(ll i = m; i > 0; i >>= 1){
        if(i & 1){
            res *= x;
            res %= p;
        }
        x *= x;
        x %= p;
    }
    return res;
}


int main(){
    const ll mod = 1000003;
    vector<ll> r(mod);
    r[0] = r[1] = 1;
    for(ll i = 2; i < mod; i++){
        r[i] = r[i - 1] * i;
        r[i] %= mod;
    }
    
    ll q;
    cin >> q;
    REP(i, q){
        ll x, d, n;
        cin >> x >> d >> n;
        if(d == 0){
            cout << POW(x, n, mod) << endl;
            continue;
        }
        ll xx = (x * POW(d, mod - 2, mod)) % mod;
        if(xx == 0 || xx + n - 1 >= mod){
            cout << 0 << endl;
            continue;
        }
        cout << ((r[xx + n - 1] * POW(r[xx - 1], mod - 2, mod)) % mod * POW(d, n, mod)) % mod << endl;
    }
}

Measured memory_bytes: 8704
c500 = int(input())
c100 = int(input())
c50 = int(input())
sumX = int(input())
retCount = 0
chk500X = sumX
for i in range(c500+1):
  for j in range(c100+1):
    for k in range(c50+1):
      if sumX == 500*i + 100 * j + 50 * k:
        retCount += 1
print(retCount)
  

Measured memory_bytes: 3060
from collections import deque
n = int(input())
a = list(input().split())

b = deque([])
r = False
for i in range(n):
    if r:
        b.appendleft(a[i])
    else:
        b.append(a[i])
    r = not r

if r:
    b = reversed(b)
ans = ' '.join(b)
print(ans)

Measured memory_bytes: 26564
#include <stdio.h>
int isprime(int n){
  for(int i = 2 ; i*i<=n ;i++){
    if(n%i==0)return 0;
}
 return 1;
}
int main(){
  int number[10000+2]={0};
  int n ,i , fir ,sec;
  for(i=2 ; i<10000 ;i++){
    number[i] = isprime(i);
  }
  while(scanf("%d" ,&n)){
    if(n==0)break;
    fir = 0 ,sec = 0;
    for(i=n ;i>3 ;i--){
      if(number[i] && number[i-2]){
        fir = i-2;
        sec = i;
        break;
      }
    }
    printf("%d %d\n" ,fir ,sec);
  }
  return 0;
}

Measured memory_bytes: 1764
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
using namespace std;

#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (int i=0; i < (int)(n); i++)  // 0 ~ n-1
#define REPN(i, n) for (int i=1; i <= (int)(n); i++)  // 1 ~ n
#define DESCEND greater<int>()  // sort 降順 大きい順
#define UNIQUE(vec) (vec).erase(unique(ALL((vec))), (vec).end());  // 必ずsortを行なってから
#define MIN(vec) min_element(ALL((vec)))  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする vec2は空にしておく必要あり
typedef long long ll;

const int MOD = 1000000007;  // 1 000 000 007


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

    // input
    string O, E;
    cin >> O >> E;
    size_t len = E.length();
    // calculation
    REP(i, len) {
        cout << O[i];
        cout << E[i];
    }
    
    if (len != O.length()) {
        cout << O.back();
    }
    cout << "\n";
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define PB_VEC(Itr1,Itr2) (Itr1).insert((Itr1).end(),(Itr2).begin(),(Itr2).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())
#define BOUND(Itr,val) lower_bound((Itr).begin(),(Itr).end(),(val))
typedef long long ll;

int main(){

    int h,w;
    cin>>h>>w;
    
    int ans=0;
    REP(i,h){
        int cnt=0;
        REP(j,w){
            int t;
            cin>>t;
            if(t==1)cnt++;
        }
        ans=max(ans,cnt);
    }
    
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 3108
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <regex>
#include <stack>
#include <queue>
#include <vector>
#define MAX_N 100
#define INF 10000000

using namespace std;


int n;
string s;
int a[200000];

void solve() {
	for (int i = 0; i < s.length()-8; i++) {
		cout << s[i];
	}
	cout << endl;
}

int main() {
	cin >> s;
	solve();
	return 0;
}

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

#define ll long long
#define ar array
#define vi vector<int>
#define INF 1000000000

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	ll n, k;
	cin >> n >> k;
	ll ans = min(n % k, k - n%k);
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
using Int = long long;

template <typename T>
vector<T> dijkstra(Int s,vector<vector<pair<Int, T> > > & G,T INF){
  using P = pair<T, Int>;
  Int n=G.size();
  vector<T> d(n,INF);
  vector<Int> b(n,-1);
  priority_queue<P,vector<P>,greater<P> > q;
  d[s]=0;
  q.emplace(d[s],s);
  while(!q.empty()){
    P p=q.top();q.pop();
    Int v=p.second;
    if(d[v]<p.first) continue;
    for(auto& e:G[v]){
      Int u=e.first;
      T c=e.second;
      if(d[u]>d[v]+c){
	d[u]=d[v]+c;
	b[u]=v;
	q.emplace(d[u],u);
      }
    }
  }
  return d;
}


template<typename T> void chmin(T &a,T b){if(a>b) a=b;}
template<typename T> void chmax(T &a,T b){if(a<b) a=b;}


template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T>
vector<vector<T> > make_v(size_t a,size_t b){
  return vector<vector<T> >(a,make_v<T>(b));
}
template<typename T>
vector<vector<vector<T> > > make_v(size_t a,size_t b,size_t c){
  return vector<vector<vector<T> > > (a,make_v<T>(b,c));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

//INSERT ABOVE HERE
signed main(){
  Int n,m,s,t,U,V;
  cin>>n>>m>>s>>t>>U>>V;
  s--;t--;U--;V--;
  
  const Int INF=1e16;

  using P = pair<Int, Int>;
  vector<vector<P> > G(n);
  for(Int i=0;i<m;i++){
    Int a,b,c;
    cin>>a>>b>>c;
    a--;b--;
    G[a].emplace_back(b,c);
    G[b].emplace_back(a,c);
  }

  auto ds=dijkstra(s,G,INF);
  auto dt=dijkstra(t,G,INF);
  assert(ds[t]==dt[s]);
  Int L=ds[t];

  using TP=tuple<Int, Int, Int>;
  
  vector<vector<TP> > T(n);
  for(Int v=0;v<n;v++){
    for(auto e:G[v]){
      Int u,c;
      tie(u,c)=e;
      if(ds[v]+dt[v]==L&&ds[u]+dt[u]==L&&
	 (ds[u]+c==ds[v]||ds[v]+c==ds[u]))
	T[v].emplace_back(u,c,(ds[u]+c==ds[v])+1);
      else T[v].emplace_back(u,c,0);
    }
  }

  auto dp=make_v<Int>(4,n);
  fill_v(dp,INF);
  
  priority_queue<TP,vector<TP>,greater<TP> > pq;

  dp[0][U]=0;
  pq.emplace(dp[0][U],0,U);
  
  while(!pq.empty()){
    Int d,c,v;
    tie(d,c,v)=pq.top();pq.pop();
    if(dp[c][v]<d) continue;
    //cout<<d<<" "<<c<<" "<<v<<endl;
    for(auto e:T[v]){
      Int u,nc,nd;
      tie(u,nc,nd)=e;
      Int nt=-1;
      if(c==0){
	if(nd){
	  nt=nd;
	  if(dp[nt][u]>d){
	    dp[nt][u]=d;
	    pq.emplace(dp[nt][u],nt,u);
	  }
	}
	nt=c;
	if(dp[nt][u]>d+nc){
	  dp[nt][u]=d+nc;
	  pq.emplace(dp[nt][u],nt,u);
	}
      }
      if(c==1||c==2){
	if(c==nd){
	  nt=c;
	  if(dp[nt][u]>d){
	    dp[nt][u]=d;
	    pq.emplace(dp[nt][u],nt,u);
	  }
	}
	nt=3;
	if(dp[nt][u]>d+nc){
	  dp[nt][u]=d+nc;
	  pq.emplace(dp[nt][u],nt,u);
	}
      }
      if(c==3){
	nt=3;
	if(dp[nt][u]>d+nc){
	  dp[nt][u]=d+nc;
	  pq.emplace(dp[nt][u],nt,u);
	}
      }
    }
  }
  
  cout<<min({dp[0][V],dp[1][V],dp[2][V],dp[3][V]})<<endl;
  return 0;
}



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

using namespace std;

int main() {
	int n;
	cin >> n;
	int a, b = 0;
	for (int i = 0; i < n; i++)
		scanf("%d", &a), b |= a;
	cout << (b % 2 ? "first" : "second") << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P  = pair<ll, ll>;

#define FOR(i,a,b)  for(ll (i)=a;(i)<(b);++(i))
#define RFOR(i,a,b) for(ll (i)=a;(i)>=(b);--(i))
#define REP(i,n)    FOR(i,0,n)
#define RREP(i,n)   RFOR(i,n,0)
#define ALL(v)      (v).begin(),(v).end()
#define BIT(n)      (1LL<<(n))
#define IN(x,l,r)   ((l)<=(x)&&(x)<=(r))
#define LEN(s)      (string(s)).length()
#define NPOS        string::npos
#define SHOW(x)     cout<<#x<<" = "<<x<<endl
#define SORT(v)     sort(ALL(v))
#define SZ(v)       (ll)(v).size()
#define UNIQ(v)     SORT(v);(v).erase(unique(ALL(v)),(v).end())
#define PERM(v)     for(bool p=1;p;p=next_permutation(ALL(v)))
#define PQ(T)       priority_queue<T,vector<T>,greater<T>>

template<class T>string join(const vector<T>& v,string d=" ")
{stringstream s;REP(i,SZ(v))s<<d<<v[i];return s.str().substr(LEN(d));}

template<class T>ostream& operator<<(ostream& o,const vector<T>& v)
{o<<"{";if(SZ(v))o<<join(v,", ");o<<"}";return o;}

template<class T,class U>ostream& operator<<(ostream& o,const pair<T,U>& p)
{o<<"(";o<<p.first<<", "<<p.second;o<<")";return o;}

template<class T>bool contain(const string& s,const T& v)
{return s.find(v)!=NPOS;}

template<class T,class U>string& replace(string& s,const T& f,const U& t)
{for(auto p=s.find(f);p!=NPOS;p=s.find(f,p+LEN(t)))s.replace(p,LEN(f),t);}

const ll INF = 1e15;
const ll MOD = 1e9+7;
const double EPS = 1e-10;

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

int main() {
    string S; cin >> S;
    
    if (LEN(S) >= 4 and S.substr(0, 4) == "YAKI") {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    
    return 0;
}

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

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF             2e9
#define INF_LL          1LL<<60
#define ll              long long
#define Ceil(x, n)      (((((x))+((n)-1))/n))
#define CeilN(x, n)     (((((x))+((n)-1))/n)*n)
#define FloorN(x, n)    ((x)-(x)%(n))
#define ALL(x)          (x).begin(),(x).end()
typedef pair<ll, ll>    P;

int main() {
    int x, y;
    cin >> x >> y;
    if(x < y) {
        int ans = y-x;
        if(x <= 0 || y >= 0) {
            int tmp = 1 + abs(x+y);
            ans = min(y-x, tmp);
        }
        cout << ans << endl;
    } else if(x > y){
        int ans;
        if(y <= 0 && x >= 0) {
            ans = 1 + abs(x+y);
        } else {
            ans = 2 + abs(x-y);
        }
        cout << ans << endl;
    } else {
        cout << "0" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
///AJoy Sarker ,CSE JAHANGIRNAGAR UNIVERSITY 48 Batch
#include<bits/stdc++.h>
using namespace std;
#define SORT(c) sort((c).begin(),(c).end());
#define pb push_back
#define MP make_pair
#define pii pair<int,int>
#define pcc pair<char,char>
#define pic pair<int,char>
#define pci pair<char,int>
#define VS vector<string>
#define VI vector<int>
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define pi 3.141592653589793
#define in scanf
#define out printf
#define ll long long
#define ull unsigned long long
#define w(x) int x;cin>>x;while(x--)
#define fast ios_base::sync_with_stdio(0)
#define FOR(i,a,b) for( int i=(a),_b=(b);i<=_b;i++)
#define DOW(i,b,a) for( int i=(b),_a=(a);i>=_a;i--)
#define sz size()
typedef unsigned long long UL;
template<typename T>inline T  S(T a)
{
    return a*a;
}
template<class T>inline string tostring(T a)
{
    ostringstream os("");
    os << a;
    return os.str();
}
template<typename T>inline ll tolong(T a)
{
    ll res;
    istringstream os(a);
    os>>res;
    return res;
}
template<typename T>inline T gcd(T a, T b)
{
    if (b == 0)return a;
    else return gcd(b, a % b);
}
template<typename T>inline T bigmod(T a, T b, T m)
{
    if (b == 0)return 1;
    else if (b % 2 == 0)return S(bigmod(a, b / 2, m)) % m;
    else return (a % m*bigmod(a, b - 1, m)) % m;
}
const int inf = (int)1e9 + 5;
const ll linf = (ll)1e16 + 5;
const ll mod = (ll)1e9 + 7;
#define N 20000009
bool prime[N];
vector<ll> prm;
void seive ()
{

    memset(prime, true, sizeof(prime));

    for( ll i=2; i*i<=N; i++)
    {
        if (prime[i] == true)
        {
            prm.pb(i);
            for (ll j=i*i; j<=N; j += i)
                prime[j] = false;
        }
    }
}
void pr (int f)
{
    if(f==1)
        cout<<"Yes\n";
    else
        cout<<"No\n";
}
map<int,int>mp;
set<int> s;
int vis[111];
int main()
{
    fast;
     ll n,c=0;
     cin>>n;
     for(ll i=1;i<=n;i++)
     {
         string x=tostring(i);
         if((x.sz)%2) c++;
     }
     cout<<c<<endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 1e5 + 5;
const int INF = 0x3f3f3f3f;
#define DEBUG(x) cout << x << '\n'

int n, m, t, x, y, a[MAXN];
void run(){
    cin >> n;
    ll sum = 0;
    for(int i = 1; i <= n; i++)
        cin >> t, a[t]++, sum += t;
    for(cin >> m; m--;){
        cin >> x >> y;
        sum -= 1ll * x * a[x];
        sum += 1ll * y * a[x];
        a[y] += a[x];
        a[x] = 0;
        DEBUG(sum);
    }
}
int main(){
#ifdef Irene
    freopen("in.txt", "r", stdin);
#endif // Irene
    ios::sync_with_stdio(false);

    run();
}


Measured memory_bytes: 3980
#include <iostream>
#include <string>
using namespace std;
typedef long long ll;

const ll MOD = 1000000007;

int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    ll now = 0;
    ll ans = 1;
    for(int i = 0; i < n * 2; i++){
        if(now % 2){
            if(s[i] == 'W') now++;
            else{
                ans = ans * now % MOD;
                now--;
            }
        }
        else{
            if(s[i] == 'B') now++;
            else{
                ans = ans * now % MOD;
                now--;
            }
        }
    }
    ll f = 1;
    for(ll i = 1; i <= n; i++) f = f * i % MOD;
    if(now == 0) cout << ans * f % MOD << endl;
    else cout << 0 << endl;
}

Measured memory_bytes: 640
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}

import Control.Applicative
import Control.Monad
import Control.Arrow
import Data.List
import Data.Maybe
import Data.Char
import qualified Data.ByteString.Char8 as B
import Text.Printf

readInt = ( readLn :: IO Int )
readInts = map ( read :: String -> Int ) . words <$> getLine

getList = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = getChar >>= putStrLn . which "vowel" "consonant" . ( `elem` "aeiou" )


Measured memory_bytes: 380
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
int main(){
    ll n,sum=0;
    cin>>n;
    for(ll i=1;i<=n;i++){
        if(i%3!=0&&i%5!=0){
            sum+=i;
        }
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 3632
#include<cstdio>
#include<vector>
#include<algorithm>
#include<utility>
#include<numeric>
#include<iostream>
#include<array>
#include<string>
#include<sstream>
#include<stack>
#include<queue>
#include<list>
#include<functional>
#define _USE_MATH_DEFINES

#include<math.h>
#include<map>

#define SENTINEL 1000000001

#define min(a,b) (a)>(b)?(b):(a)
#define max(a,b) (a)>(b)?(a):(b)

using namespace std;

typedef pair<int, int> pii;

int threatened[8][8];
bool qexist[8][8];

bool solve(int rest)
{
	if (rest == 0)
	{
		return true;
	}

	for (int i = 0; i < 8; i++)for (int j = 0; j < 8; j++)
	{
		if (threatened[i][j] == 0)
		{
			qexist[i][j] = true;
			for (int k = 0; k < 8; k++)
			{
				threatened[i][k]++;
				threatened[k][j]++;
				if ((max(0, min(7, i + k))) == i + k && (max(0, min(7, j + k))) == j + k)threatened[i + k][j + k]++;
				if ((max(0, min(7, i - k))) == i - k && (max(0, min(7, j + k))) == j + k)threatened[i - k][j + k]++;
				if ((max(0, min(7, i + k))) == i + k && (max(0, min(7, j - k))) == j - k)threatened[i + k][j - k]++;
				if ((max(0, min(7, i - k))) == i - k && (max(0, min(7, j - k))) == j - k)threatened[i - k][j - k]++;
			}
			if (solve(rest - 1))
			{
				return true;
			}
			else
			{
				qexist[i][j] = false;
				for (int k = 0; k < 8; k++)
				{
					threatened[i][k]--;
					threatened[k][j]--;
					if ((max(0, min(7, i + k))) == i + k && (max(0, min(7, j + k))) == j + k)threatened[i + k][j + k]--;
					if ((max(0, min(7, i - k))) == i - k && (max(0, min(7, j + k))) == j + k)threatened[i - k][j + k]--;
					if ((max(0, min(7, i + k))) == i + k && (max(0, min(7, j - k))) == j - k)threatened[i + k][j - k]--;
					if ((max(0, min(7, i - k))) == i - k && (max(0, min(7, j - k))) == j - k)threatened[i - k][j - k]--;
				}
			}
		}
	}
	return false;
}

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

	for (int j = 0; j < k; j++)
	{
		int r, c;
		cin >> r >> c;
		qexist[r][c] = true;
		for (int i = 0; i < 8; i++)
		{
			threatened[r][i]++;
			threatened[i][c]++;
			if ((max(0, min(7, r + i))) == r + i && (max(0, min(7, c + i))) == c + i)threatened[r + i][c + i]++;
			if ((max(0, min(7, r - i))) == r - i && (max(0, min(7, c + i))) == c + i)threatened[r - i][c + i]++;
			if ((max(0, min(7, r + i))) == r + i && (max(0, min(7, c - i))) == c - i)threatened[r + i][c - i]++;
			if ((max(0, min(7, r - i))) == r - i && (max(0, min(7, c - i))) == c - i)threatened[r - i][c - i]++;
		}
	}

	solve(8 - k);

	for (int i = 0; i < 8; i++)
	{
		for (int j = 0; j < 8; j++)
		{
			printf(qexist[i][j] ? "Q" : ".");
		}
		printf("\n");
	}
	
	return 0;
}


Measured memory_bytes: 3220
#include <stdio.h>

int main(void)
{
    int i;

    int n;
    scanf("%d", &n);

    int R[n];
    for (i=0; i<n; i++)
        scanf("%d", &R[i]);

    int min = R[0], diff = R[1] - R[0];
    for (i=1; i<n-1; i++){
        min = (R[i] < min) ? R[i]: min;
        diff = (diff < R[i+1] - min) ? R[i+1] - min: diff;
    }
    printf("%d\n", diff);
    return 0;
}





Measured memory_bytes: 2568
from collections import deque
k = int(input())
def solve():
  count = 0
  stack_strings = deque([str(i) for i in range(9, -1, -1)])
  for _ in range(10):
    for _ in range(len(stack_strings)):
      lunstring = stack_strings.pop()
      if lunstring[0] != "0":
        count += 1
        if count == k:
          return(int(lunstring))
      right_char = lunstring[-1]
      if right_char == "0":
        [stack_strings.appendleft(lunstring+x) for x in ["0", "1"]]
      elif right_char == "9":
        [stack_strings.appendleft(lunstring+x) for x in ["8", "9"]]
      else:
        [stack_strings.appendleft(lunstring+x) for x in [str(int(right_char)-1), right_char, str(int(right_char)+1)]]
print(solve())

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

int main(){
  int n;
  cin >> n;
  if(n % 10 == 3){
    cout << "bon" << endl;
  }else if(n % 10 == 0 || n % 10 == 1 || n % 10 == 6 || n % 10 == 8){
    cout << "pon" <<endl;
  }else{
    cout << "hon" << endl;
  }
}

Measured memory_bytes: 3624
#include<stdio.h>

int main(){
    int n, flag;
    scanf("%d",&n);
    //処理
    int i,j;//i:4 j:7
    for(i=0;i<=25;i++){
        for(j=0; j<=14; j++){
            if(n==(4*i+7*j)) flag++;
        }
    }
    if(flag) printf("Yes");
    else printf("No");
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
//#include<string.h>
using namespace std;
string str;
int main(){
  int t,i,j;
 // cin>>t;
  //char str[t+2];
  //scanf("%s",str);
  cin>>str;
  t=str.length();
  for(i=0;i<t;i++){
    if(str[i]=='?'){
      str[i]='D';
    }
    cout<<str[i];
  }
  cout<<endl;
}

Measured memory_bytes: 3760
S = list(input())
l = len(S)
l2 = l % 2

if S[0] != S[-1]:
  if l2 == 0:
    winner = "Second"
  else:
    winner = "First"
else:
  if l2 == 0:
    winner = "First"
  else:
    winner = "Second"

print(winner)

Measured memory_bytes: 4084
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(a) (a).begin(), (a).end()

using namespace std;

int nextInt() {int a; cin >> a; return a;}
char nextChar() {char a; cin >> a; return a;}
double nextDouble() {double a; cin >> a; return a;}
string nextString() {string a; cin >> a; return a;}

void inputVector(vector<int> &v, int &n) {rep(i,n){v.push_back(nextInt());}}
void inputVector(vector<double> &v, int &n) {rep(i,n){v.push_back(nextDouble());}}
void inputVector(vector<string> &v, int &n) {rep(i,n){v.push_back(nextString());}}

signed main() {
	int N = nextInt();

	vector<int> a;
	inputVector(a, N);

	int minCost = 10000000000;
	for (int i = -100; i <= 100; i++) {
		int cost = 0;
		rep(j, N) {
			int d = abs(i - a[j]);
			cost += d * d;
		}
		minCost = min(minCost, cost);
	}

	cout << minCost << endl;

    return 0;
}


Measured memory_bytes: 256
import static java.util.Comparator.reverseOrder;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class Main {
	public static void main(String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		List<Integer> hillsHightList = new ArrayList<>();
		try {
			while (br.ready()) {
				hillsHightList.add(Integer.valueOf(br.readLine()));
			}
		} catch (Exception e) {
		}
		Collections.sort(hillsHightList, reverseOrder());

		System.out.println(hillsHightList.get(0));
		System.out.println(hillsHightList.get(1));
		System.out.println(hillsHightList.get(2));
	}
}

Measured memory_bytes: 24208
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N = int(input())
h = list(map(int, input().split()))

dp = [0 for _ in range(N)]
dp[1] = abs(h[1] - h[0])

for i in range(2, N):
    one = abs(h[i]-h[i-1])+dp[i-1]
    two = abs(h[i]-h[i-2])+dp[i-2]
    dp[i] = min(one, two)


print(dp[-1])


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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;


ull N, K;

ull s[1000001] = { 0, };
vector<ull> mlt[1000001];

int main() {
	
	cin >> N;

	for (ull i = 1; i <= N; i++) {
		ull M = int(N / i) + 1;
		for (ull j = 1; j < M; j++) {
			mlt[i * j].push_back(i);
		}
	}

#ifdef DEBUG
	for (auto m : mlt[N]) {
		cout << m ;
	}
	cout << endl;
#endif

	for (ull i = 2; i <= N; i++) {
		s[i] = s[i - 1] + mlt[i - 1].size();
	}

	cout << s[N] << endl;
}

Measured memory_bytes: 191732
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<61;
const ll mod=1e9+7;

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

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

int n,m;
VI v;

void cut(int x){
    VI w(2*n);
    for(int i=0;i<2*n;i++){
        w[(i-x+2*n)%(2*n)]=v[i];
    }
    swap(v,w);
}

void riffle(){
    VI w(2*n);
    for(int i=0;i<2*n;i++){
        w[(i*2)%(2*n)+(i>=n)]=v[i];
    }
    swap(v,w);
}

int main(){
    int i,j;
    cin>>n>>m;
    for(i=0;i<2*n;i++) v.pb(i+1);
    for(i=0;i<m;i++){
        int x;
        cin>>x;
        if(x) cut(x);
        else riffle();
    }
    for(i=0;i<2*n;i++) cout<<v[i]<<endl;
}


Measured memory_bytes: 3152
n,q=map(int,input().split())
s=input()
c=[0]*n
for i in range(1,n):
  if s[i]=="C" and s[i-1]=="A":
    c[i]+=1
from itertools import accumulate as acc
c=list(acc(c))
for i in range(q):
  l,r=map(int,input().split())
  print(c[r-1]-c[l-1])

Measured memory_bytes: 7948
//  AtCoder Beginner Contest 134 
//  ドタバタしてるけど頑張るぞー
#include <stdio.h>
int main(void){
    int i,j;    //ループ用変数
    int n,count;
    int d[200001] = {};
    int emp;
    int max,max2;
    count = 0;
    max = 0;
    max2 = 0;
    int xpoint = 0;
    scanf("%d",&n);
    for (i = 0; i < n; i++){
        scanf("%d",&d[i]);
        if (max < d[i]){
            count = 0;
            max2 = max;
            max = d[i];
            xpoint = i;
        }else if (max2 < d[i]){
            max2 = d[i];
        }
        if (max == d[i]){
            count++;
        }
    }
    //  処理
    if (count != 1){
        for (i = 0; i < n; i++){
            printf("%d\n",max);
        }
    }else{
        for (i = 0; i < xpoint; i++){
            printf("%d\n",max);
        }
        printf("%d\n",max2);
        for (i = xpoint + 1; i < n; i++){
            printf("%d\n",max);
        }
    }

    
   
   


}


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

// BIT木を実装する

const int MAX_N = 3e7;

int bit[MAX_N]; int n;

void init(const int &N){ 
  
  n = 1LL;
  while( n < N){ n *= 2;} //bitは最初から0だから更新する必要なし
}

void add(int i, const int &x){
  while( i <= n ){ bit[i] += x; i += i& (-i);}
}

int sum(int i){ //a1+...+asまでの和
  int s = 0;
  while( i > 0 ){ s += bit[i]; i -= i&(-i);}
  return s;
}

signed main(void){
  
  int N,K; cin >> N >> K;
 
  
  init(10*N);
    
  
  int ans = 0;
  vector<int> a(N+1,0);
  
  for(int i = 1; i <= N; i++){ //bitは1-indexedで扱うことに注意
    cin >> a[i]; a[i] -= K; 
  }
  
  vector<int> b(N+1,0); b[1] = a[1];
  
  //aとbは0-で、cとBITは1-で扱う
  for(int i = 2; i <= N; i++){ 
    b[i] = b[i-1]+a[i];
  }
 //次にbを座標圧縮する

  vector<int> c(N+1); vector<int> copy(N+1);
  
  for(int i = 0; i <= N; i++){ copy[i] = b[i];} 
  
  sort(copy.begin(),copy.end());
  
  for(int i = 0; i <= N; i++){
    //b[i]が実は何番めかを調べて行く
    
    int test = b[i];
    
    int order = lower_bound(copy.begin(),copy.end(),test)-copy.begin();
    
    c[i] = order+1;
    
  }
  for(int i = 0; i <= N; i++){ 
    
   
    ans += sum(c[i]);
    
    add(c[i],1);
    
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 16256
import java.io.BufferedReader;
import java.io.InputStreamReader;

class Main {
	private static final String[][] KEYWORDS = {
			{ "the", "uif", "vjg", "wkh", "xli", "ymj", "znk", "aol", "bpm", "cqn", "dro", "esp", "ftq", "gur", "hvs",
					"iwt", "jxu", "kyv", "lzw", "max", "nby", "ocz", "pda", "qeb", "rfc", "sgd" },
			{ "this", "uijt", "vjku", "wklv", "xlmw", "ymnx", "znoy", "aopz", "bpqa", "cqrb", "drsc", "estd", "ftue",
					"guvf", "hvwg", "iwxh", "jxyi", "kyzj", "lzak", "mabl", "nbcm", "ocdn", "pdeo", "qefp", "rfgq",
					"sghr" },
			{ "that", "uibu", "vjcv", "wkdw", "xlex", "ymfy", "zngz", "aoha", "bpib", "cqjc", "drkd", "esle", "ftmf",
					"gung", "hvoh", "iwpi", "jxqj", "kyrk", "lzsl", "matm", "nbun", "ocvo", "pdwp", "qexq", "rfyr",
					"sgzs" } };

	public static void main(String[] a) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		try {
			READ_LOOP: while ((line = br.readLine()) != null) {
				for (int i = 0; i < KEYWORDS.length; i++) {
					for (int j = 0; j < KEYWORDS[i].length; j++) {
						if (line.indexOf(KEYWORDS[i][j]) != -1) {
							char[] cs = line.toCharArray();

							for (int k = 0; k < cs.length; k++) {
								char ch = cs[k];
								if (ch != ' ' && ch != '.') {
									cs[k] = (char) ((ch - 'a' + 26 - j) % 26 + 'a');
								}
							}

							System.out.println(cs);

							continue READ_LOOP;
						}
					}
				}
			}
		} catch (Exception e) {
		}
	}
}

Measured memory_bytes: 24116
s = input()
buf = [0 for i in range(13)]
s = s[::-1]
n = len(s)
# print(s)

base = 10

if s[0] == "?":
    buf = [1,1,1,1,1,1,1,1,1,1,0,0,0]
else:
    buf[int(s[0])] = 1
# print(buf)
# print("############")
for i in range(1,n):
    base = base%13
    nbuf = [0 for j in range(13)]
    if s[i] == "?":
        ooo = [0 for j in range(13)]
        for j in range(10):
            temp = (base*j)%13
            ooo[temp] += 1
        # print(ooo)
        for j in range(13):
            for k in range(13):
                temp = (j+k)%13
                nbuf[temp]+= buf[k]*ooo[j]
                nbuf[temp] %= (10**9+7)
    else:
        for j in range(13):
            temp = j+int(s[i])*base
            temp %= 13
            nbuf[temp] += buf[j]
            nbuf[temp] %= (10 ** 9 + 7)
    base *= 10
    buf = nbuf
    # print(buf)
    # print("*********************")

# print(buf)
print(buf[5])


Measured memory_bytes: 44780
#include <iostream>

using namespace std;

int main()
{
	char b;

	cin >> b;

	switch (b)
	{
	case 'A':
		b = 'T';
		break;
	case 'C':
		b = 'G';
		break;
	case 'G':
		b = 'C';
		break;
	case 'T':
		b = 'A';
		break;
	}

	cout << b << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int solve(int n)
{
	int sum = 0;

	for (int i = 0; i * i <= n; i++)
	{
		for (int j = i; j * j <= n; j++)
		{
			for (int k = j; k * k <= n; k++)
			{
				for (int l = k; l * l <= n; l++)
				{
					if (i*i + j*j + k*k + l*l == n)
					{
						sum++;
					}
				}
			}
		}
	}

	return sum;
}

int main()
{
	int n;

	while (true)
	{
		cin >> n;

		if (n == 0) { break; }

		cout << solve(n) << endl;
	}

	return 0;
}

Measured memory_bytes: 3088