akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.TreeSet;
 
 
 
public class Main {
  public static void main(String[] args) {
    InputReader sc = new InputReader(System.in);
 
    int n = sc.nextInt();
    int[] table = new int[n+3];
    table[0] = 0;
    table[1] = 0;
    table[2] = 0;
    table[3] = 1;
    for(int i = 4; i <= n; i++){
      int count = 1;
      for(int j = 3; j <= i; j++){
        count = (count + table[i-j]) % 1000000007;
      }
      table[i] = count;
    }
    System.out.println(table[n]);
 
 
  }
 
 //ここからテンプレ
  static class InputReader {
      private InputStream stream;
      private byte[] buf = new byte[1024];
      private int curChar;
      private int numChars;
      private SpaceCharFilter filter;
 
      public InputReader(InputStream stream) {
          this.stream = stream;
      }
 
      public int next() {
          if (numChars == -1)
              throw new InputMismatchException();
          if (curChar >= numChars) {
              curChar = 0;
              try {
                  numChars = stream.read(buf);
              } catch (IOException e) {
                  throw new InputMismatchException();
              }
              if (numChars <= 0)
                  return -1;
          }
          return buf[curChar++];
      }
 
      public String nextStr() {
        int c = next();
        while(isSpaceChar(c)){c = next();}
        StringBuffer str = new StringBuffer();
        do{
          str.append((char)c);
          c = next();
        }while(!isSpaceChar(c));
        return str.toString();
      }
 
      public char nextChar() {
        int c = next();
        while(isSpaceChar(c)){c = next();}
        char ret;
        do{
          ret = (char)c;
          c = next();
        }while(!isSpaceChar(c));
        return ret;
      }
 
      public int nextInt() {
          int c = next();
          while (isSpaceChar(c))
              c = next();
          int sgn = 1;
          if (c == '-') {
              sgn = -1;
              c = next();
          }
          int res = 0;
          do {
              if (c < '0' || c > '9')
                  throw new InputMismatchException();
              res *= 10;
              res += c - '0';
              c = next();
          } while (!isSpaceChar(c));
          return res * sgn;
      }
 
      public boolean isSpaceChar(int c) {
          if (filter != null)
              return filter.isSpaceChar(c);
          return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
      }
 
      public interface SpaceCharFilter {
          public boolean isSpaceChar(int ch);
      }
  }
}

Measured memory_bytes: 25712
#include<bits/stdc++.h>
using namespace std;
                       ///****   Hasebul Hassan Chowdhury ***////
#define ms(a,v)        memset(a,v,sizeof a)
#define lll            long long
#define FOR(i,a,b)     for(int i=a;i<=b;i++)
#define fast           ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Read           freopen("input.txt", "r", stdin)
#define Write          freopen("output.txt", "w", stdout)
#define INF            1e18


void solve()
{
   int n;
   lll x;
   cin>>n;
   lll arr[100005]={0};
   lll sum=0;
   FOR(i,1,n)
   {
       cin>>x;
       arr[x]++;
       sum+=x;
   }
   int Q;
   cin>>Q;
   FOR(i,1,Q)
   {
       int u,v;
       cin>>u>>v;
       sum-=arr[u]*u;
       sum+=arr[u]*v;
       cout<<sum<<endl;
       arr[v]+=arr[u];
       arr[u]=0;
   }
}


int main()
{
    fast
    #ifndef ONLINE_JUDGE
    //Read;
    //Write;
    #endif
    //int t; cin>>t; while(t--) solve();
    solve();

}


Measured memory_bytes: 4396
#include <stdio.h>

int main(int argc, char const *argv[]) {
  int N,i,count=0;
  char s[101];
  scanf("%d",&N);
  scanf("%s",s);
  for (i = 0; i < N; i++) {
    if (s[i] == 'R') {
      count++;
    } else {
      count--;
    }
  }
  if (count > 0) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int a[21],b[21];
int main(){
	int i,n,ans=0;
	cin>>n;
	for(i=1;i<=n;i++){
		cin>>a[i];
	}
	for(i=1;i<=n;i++){
		cin>>b[i];
	}
	for(i=1;i<=n;i++){
		if(a[i]>b[i]) ans+=a[i]-b[i];
	}
	cout<<ans;
	return 0;
}

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

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

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

    // start
    int x;
    cin >> x;
    if (x == 1)
        cout << "Hello World" << endl;
    else
    {
        int a, b;
        cin >> a >> b;
        cout << a + b << endl;
    }
    // end

    return 0;
}


Measured memory_bytes: 256
A = input()
LR = [[]]
re = 'R'
for i in str(A):
    if i != re:
        LR.append([])
    LR[-1].append(i)
    re = i
count = 0
AA = []
while count < len(LR):
    AA.append([])
    for _ in range(len(LR[count])):
        AA[-1].append(0)
    AA[-1][-1] = (len(LR[count]) // 2) + (len(LR[count]) % 2) + (len(LR[count + 1]) // 2)
    count += 1    
    AA.append([])
    for _ in range(len(LR[count])):
        AA[-1].append(0)
    AA[-1][0] = (len(LR[count]) // 2) + (len(LR[count]) % 2) + (len(LR[count - 1]) // 2)
    count += 1
ans = []
for _ in range(len(AA)):
    ans += AA[_]
for _ in range(len(ans)):
    print(ans[_])


Measured memory_bytes: 28388
n,m,q = map(int, input().split())

abcd = [list(map(int, input().split())) for i in range(q)]

heap = [[i] for i in range(1, m+1)]

for i in range(n-1):
    nxt = []
    for l in heap:
        for j in range(l[-1], m+1):
            k = l[:]
            k.append(j)
            nxt.append(k)
    heap = nxt

ans = 0
for l in heap:
    tmp = 0
    for a,b,c,d in abcd:
        if l[b-1]-l[a-1] == c:
            tmp += d
    if tmp > ans:
        ans = tmp
print(ans)

Measured memory_bytes: 105368
import sys
from heapq import heappush, heappop
def input(): return sys.stdin.readline().strip()

def main():
    H, W = map(int, input().split())
    ch, cw = map(int, input().split())
    ch -= 1
    cw -= 1
    dh, dw = map(int, input().split())
    dh -= 1
    dw -= 1
    S = [input() for _ in range(H)]

    repn = [[] for _ in range(H * W)]  # (cost, to)
    for h in range(H):
        for w in range(W):
            if S[h][w] != '.': continue
            if w > 0 and S[h][w - 1] == '.':
                repn[h * W + w].append((0, h * W + w - 1))
            if w < W - 1 and S[h][w + 1] == '.':
                repn[h * W + w].append((0, h * W + w + 1))
            if h > 0 and S[h - 1][w] == '.':
                repn[h * W + w].append((0, (h - 1) * W + w))
            if h < H - 1 and S[h + 1][w] == '.':
                repn[h * W + w].append((0, (h + 1) * W + w))

            for ph in range(5):
                for pw in range(5):
                    if abs(ph - 2) + abs(pw - 2) <= 1: continue
                    nh = h + ph - 2
                    nw = w + pw - 2
                    if 0 <= nh < H and 0 <= nw < W and S[nh][nw] == '.':
                        repn[h * W + w].append((1, nh * W + nw))

    q = [(0, ch * W + cw)]
    visited = [10**18] * (H * W)
    visited[ch * W + cw] = 0
    while q:
        cost, u = heappop(q)
        if visited[u] < cost: continue
        for dcost, nu in repn[u]:
            if visited[nu] > cost + dcost:
                visited[nu] = cost + dcost
                heappush(q, (cost + dcost, nu))

    ans = visited[dh * W + dw]
    if ans == 10**18:
        print(-1)
    else:
        print(ans)





if __name__ == "__main__":
    main()


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

int main()
{
    int n;
    cin >> n;
    int i = 1;
    int s = 0;
    while(s <= n){
        s += i;
        i++;
    }
    int j = s - n;
    for(int k = 1; k <= i - 1; k++) if(k != j) cout << k << endl;
}

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

using namespace std;

class WalkAndTeleport
{
public:
	long long n, a, b;
	vector<long long>x;
	WalkAndTeleport();
	~WalkAndTeleport();
	void exec();
};

WalkAndTeleport::WalkAndTeleport(){
	cin >> n >> a >> b;
	x.resize(n);
	for (int i = 0; i < n; ++i)
	{
		cin >> x[i];
	}

}

WalkAndTeleport::~WalkAndTeleport(){}

void WalkAndTeleport::exec(){
	long long ans = 0;
	for (int i = 1; i < n; ++i)
	{
		ans += min(a*(x[i] - x[i-1]), b);
	}
	cout << ans << endl;
}

int main(){
	WalkAndTeleport wat = WalkAndTeleport();
	wat.exec();
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define pb push_back
#define fr first
using namespace std;
typedef long long ll;
const int N = 1e5+1;

int read(){
	int x=0;char ch=getchar();
	while(ch<'0'||ch>'9')ch=getchar();
	while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
	return x;
}

int n,x[N],y[N],t[N];


int main(){
	n=read();
	for(int i=1;i<=n;++i)t[i]=read(),x[i]=read(),y[i]=read();
	for(int i=1;i<=n;++i){
		int d=abs(x[i]-x[i-1])+abs(y[i]-y[i-1]);
		if(d>t[i]-t[i-1]||(t[i]-t[i-1]-d)&1)return 0*printf("No\n");
	}
	printf("Yes\n");
}

Measured memory_bytes: 1408
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
lint p[200100];
int main()
{
	int k,n;lint now=0,out=0;
	cin>>n>>k;rep(i,n) cin>>p[i];
	rep(i,k) now+=p[i];out=now;
	rep(i,n-k){
		now+=p[i+k];now-=p[i];out=max(out,now);
	}
	printf("%.12f\n",0.5*(out+k));
}


Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;

#define ll long long int
#define str string
#define ALL(a)  (a).begin(),(a).end()
#define P pair<ll,ll>

using Graph = vector<vector<int>>;

const int dy[] = { 0, 0, 1, -1 }, dx[] = { 1, -1, 0, 0 };
ll INFL = 1ll << 60, INF = 1 << 30, mod = 1e9 + 7, Min = INFL, Max = -1;
ll a, b, c, n, sum, A[500010], B[500000], rui[500000], dp[5000];
str S; bool check = true;	vector<ll> v;



int main() {
	//Code Line
cin >> a >> b;

if(a < b)for(int i = 0;i < b;i++){
cout << a;
}
else for(int i = 0;i < a;i++){
cout << b;
}

	return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(pi c, pi d){
	return c.S < d.S;
}

int main() {
	ll n;
	//cin >> n;
	scanf("%lld", &n);
	ll o[n], c[n+1]={0};
	REP(i, 0, n){
		//cin >> o[i];
		scanf("%lld", &o[i]);
		++c[o[i]];
	}
	ll pos = 0, val;
	REP(i, 0, n+1){
		val = c[i];
		pos += val* (val - 1)/2;
		c[i] = (val - 1)*(val - (val-2))/2;
	}
	for(auto i: o){
		cout <<  pos - c[i] << endl;
	}
		

}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using Graph = vector<vector<int>>;
const int INT_INF = 1001001001;

int keta(int x){ //各桁の和
    int s = 0;
    while(x > 0){
        s += x%10;
        x /= 10;
    }
    return s;
}

int main(){
    int n;
    cin >> n;
    if(n%keta(n) == 0) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int t = sc.nextInt();
		if (x <= t) {
			System.out.println(0);
		} else {
			System.out.println(x-t);
		}

	}
}

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


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

    SORT(L);
    int res = 0;
    rep(i, N-1) FOR(j, i+1, N) {
        if(i == j) continue;
        int temp = L[i]+L[j];
        int m = max(L[i]-L[j], L[j]-L[i]);
        int mat = lower_bound(ALL(L), temp)-L.begin();
        int mit = upper_bound(ALL(L), m)-L.begin();
        //cout << mit << " " << mat << endl;
        int t = mat-mit;
        if(mit<=i) {
            if(mat<j) {
                t--;
            } else t-=2;
        } else {
            if(mat >= j) t--;
        }

        res += t;
    
    }
    

    cout << res/3 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cassert>
#include <functional>
#include <string>
using namespace std;

int main(){
  int N, A; cin >> N >> A;
  cout << N * N - A << endl;
}


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

int main() {
    string s;
    cin >> s;
    int ans = 0;
    for (int i = 0; i < 3; i++) {
        if (s[i] == '1') {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let x: i32 = read(&mut stdin_lock, &mut buf, b'\n');
    let a: i32 = read(&mut stdin_lock, &mut buf, b'\n');
    let b: i32 = read(&mut stdin_lock, &mut buf, b'\n');
    let ans = (x - a) % b;
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;
using ll = __int128;
#define REP(i, n) for (ll i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()

struct CRT {
	using P = pair<ll, ll>;
	P calc(vector<ll> &r, vector<ll> &m) {
		assert(r.size() == m.size());
		ll R = 0, M = 1;
		REP(i, r.size()) {
			P p = calc(R, M, r[i], m[i]);
			if (p.second == -1) {
				return P(0, -1);
			}
			R = p.first;
			M = p.second;
		}
		return P(R, M);
	}
	ll extgcd(ll a, ll b, ll &p, ll &q) {
		if (b == 0) {
			p = 1;
			q = 0;
			return a;
		}
		ll d = extgcd(b, a % b, q, p);
		q -= (a / b) * p;
		return d;
	}
	P calc(ll r1, ll m1, ll r2, ll m2) {
		ll p, q;
		ll d = extgcd(m1, m2, p, q);
		if ((r2 - r1) % d != 0) {
			return P(0, -1);
		}
		ll M = m1 / d * m2;
		return P((r1 + ((r2 - r1) / d) * p % M * m1 % M + M) % M, M);
	}
};

int main() {
	int n;
	cin >> n;
	vector<int> p(n), q(n);
	REP(i, n) {
		cin >> p[i];
		p[i]--;
	}
	REP(i, n) {
		cin >> q[i];
		q[i]--;
	}

	vector<ll> r(n), m(n);

	REP(i, n) {
		int a = i;
		int cnt = 0;
		while (1) {
			if (cnt > 0 && a == i) break;
			cnt++;
			a = q[a];
		}
		m[i] = cnt;
	}
	REP(i, n) {
		map<int, int> mp;
		int a = p[i];
		int k = 0;
		while (1) {
			if (mp.count(a)) {
				if (mp.count(i) == 0) {
					cout << -1 << endl;
					return 0;
				}
				r[i] = mp[i];
				break;
			}
			mp[a] = k;
			a = q[a];
			k++;
		}
	}

	CRT crt;
	auto ans = crt.calc(r, m);
	if (ans.second == -1) {
		cout << -1 << endl;
	} else {
		cout << (long long )ans.first << endl;
	}
}


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

typedef long long int ll;
typedef vector<long long>lve;
typedef vector<pair<ll,ll> > lvp;
typedef vector<vector<int> > ivve;

#define sp         ' '
#define endl       '\n'
#define F          first
#define S          second
#define pb         push_back
#define mp         make_pair 
#define GCD(x,y)   __gcd(x,y)
#define lb         lower_bound
#define up         upper_bound
#define setp       setprecision
#define bs         binary_search
#define all(x)     x.begin(),x.end()
#define LCM(x,y)   ((x*y)/__gcd(x,y))
#define spc(x)     cout<<fixed<<setp(x)

const   long long  inf = 1e18;
const   long long  cs =  200005;
const   long long  mod = 1000000007;
const   double     PI =  2 * acos(0.0);
void solve()
{
    ll t,n,m,a,b,c,d,e,i,j,k,x,y,z,cnt=0,cnt1=0;
    bool flag = false;
    
    cin >> a >> b >> c >> d;
    cnt = (a == c) ? 0 : 1;
    cout << cnt << endl;
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);    cout.tie(NULL);

    // freopen ("input.txt","r",stdin);
    // freopen ("output.txt","w",stdout);

    // int32_t tc;
    // cin>>tc;
    // while(tc--)
    solve();

    return 0;
}

Measured memory_bytes: 3624
#include "iostream"
#include "string"

int Dice[6];

class DiceMove
{
private:
public:
	DiceMove(){}
	void Move(char dir) {
		int temp;
		if (dir == 'N') {
			temp = Dice[0];
			Dice[0] = Dice[1];
			Dice[1] = Dice[5];
			Dice[5] = Dice[4];
			Dice[4] = temp;
		}
		if (dir == 'S') {
			temp = Dice[0];
			Dice[0] = Dice[4];
			Dice[4] = Dice[5];
			Dice[5] = Dice[1];
			Dice[1] = temp;
		}
		if (dir == 'E') {
			temp = Dice[0];
			Dice[0] = Dice[3];
			Dice[3] = Dice[5];
			Dice[5] = Dice[2];
			Dice[2] = temp;
		}
		if (dir == 'W') {
			temp = Dice[0];
			Dice[0] = Dice[2];
			Dice[2] = Dice[5];
			Dice[5] = Dice[3];
			Dice[3] = temp;
		}
	}
};

int main()
{
	char dir;
	DiceMove move;
	std::string direction;
	for (int i = 0; i < 6; i++)
		std::cin >> Dice[i];
	std::cin >> direction;
	for (int i = 0; i < direction.length(); i++) {
		dir = direction[i];
		if (direction[i] == 'N') move.Move(dir);
		if (direction[i] == 'S') move.Move(dir);
		if (direction[i] == 'E') move.Move(dir);
		if (direction[i] == 'W') move.Move(dir);
	}
	std::cout << Dice[0] << std::endl;
	return 0;
}

Measured memory_bytes: 3188
//“Make it work, make it right, make it fast.” – Kent Beck
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
#define endl '\n'
#define deb(x) cout << #x << " = " << x << endl;

#define N 511111
#define A 5111111
#define BLOCK 715

int cnt[A], a[N], ans[N], answer = 0;

struct Node{
  int l, r, i;
}q[N];

bool cmp(Node x, Node y) {
  if(x.l/BLOCK != y.l/BLOCK) {
    return x.l/BLOCK < y.l/BLOCK;
  }
  return x.r < y.r;
}

void add(int p) {
  cnt[a[p]]++;
  if(cnt[a[p]] == 1)
    answer++;
 }

void remove(int p) {
  cnt[a[p]]--;
  if(cnt[a[p]] == 0)
    answer--;
}

void solve() {
  int n, m;
  cin >> n >> m;
  for(int i = 0; i < n; i++) cin >> a[i];
  for(int i = 0; i < m; i++) {
    cin >> q[i].l >> q[i].r;
    q[i].i = i;
    q[i].l--, q[i].r--;
  }

  sort(q, q+m, cmp);

  int currL = 0, currR = 0;
  for(int i = 0; i < m; i++) {
    int L = q[i].l, R = q[i].r;
    while(currL < L) {
      remove(currL);
      currL++;
    }  
    while(currL > L) {
      add(currL-1);
      currL--;
    }    
    while(currR <= R) {
      add(currR);
      currR++;
    }    
    while(currR > R+1) {
      remove(currR-1);
      currR--;
    }
    ans[q[i].i] = answer;
  }
  for(int i = 0; i < m; i++) {
    cout << ans[i] << endl;
  }

}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cout << fixed << setprecision(10);
  int t = 1;
  // cin >> t;
  for(int tt = 1; tt <= t; tt++) {
    //cout << "Case #" << tt << ": ";
    solve();
  }
  return 0;
}  

Measured memory_bytes: 15472
N = int(input())
H = list(map(int, input().split()))
count = 0
counts = []

for i in range(N-1):
    if H[i] >= H[i+1]:
        count += 1
    else:
        counts.append(count)
        count = 0
counts.append(count)

result = max(counts)
print(result)

Measured memory_bytes: 14252
#include <stdio.h>

using namespace std;

int main(){
	int a,b;
	while(true){
		scanf("%d %d",&a,&b);
		if(a == 0 && b == 0) break;
		if(a > b) printf("%d %d\n",b,a);
		else{
			printf("%d %d\n",a,b);
		}
	}
}


Measured memory_bytes: 2588
n = int(input())
A = [int(x) for x  in input().split()]
flag = 0
ans =1
for i in range(n):
    if(A[i] ==0):
        flag = 1
if flag == 1:
    print(0)
else:
    for i in range(n):
        ans *= A[i]
        if(ans > 1000000000000000000):
            print(-1)
            flag = 1
            break
if flag == 0:
    print(ans)
            

Measured memory_bytes: 21656
#include <bits/stdc++.h> 
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)
 
using ll  = long long;
using ull = unsigned long long;
using P = std::pair<int, int>;
 
int main(int argc, char *argv[])
{
    std::string S;
    std::cin >> S;

    int red  = 0;
    int blue = 0;
    for (int i = 0; i < S.size(); i++) {
        if (S[i] == '0') {
            red++;
        } else {
            blue++;
        }
    }

    std::cout << std::min(red, blue) * 2 << std::endl;
    return 0;
}


Measured memory_bytes: 512
S = input()
T = input()

cnt = 10 ** 9
for i in range(len(S) - len(T) + 1):
    tmp = 0
    for j in range(len(T)):
        if i + j < len(S) and S[i + j] == T[j]:
            continue
        else:
            tmp += 1
    cnt = min(cnt, tmp)

print(cnt)

Measured memory_bytes: 9032
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string N;
  cin >> N;
  
  if(N[0] == '7' || N[1] == '7' || N[2] == '7'){
    cout  << "Yes" << endl;
  }
  else
    cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#include<iostream>
#include<map>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
#define ll long long
#define fori(i,a,b) for(ll i=a;i<=b;i++)
#define ford(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define mk make_pair
#define fs first
#define sc second
#define MAXN 1000000007

ll dp[100005][20];

int main()
{
    string s;
    cin>>s;
    ll n = s.size(),i;
    reverse(s.begin(),s.end());
    vector<ll> y(n,0);
    for( i = 0 ; i < n ; ++i)
    {
        if(i==0)
        {
            y[i]=1;
        }
        else
        {
            y[i]=(y[i-1]*10)%13;
        }
    }

    for( i = 0;i < n ;i++)
    {
        if(s[i]!='?')
        {
            y[i]=((s[i]-'0')*y[i])%13;
        }
        //cout << i << " " << y[i] << endl;
    }

    //dp solution proceeds
    // dp[i][j] represents no of arrangements of digits from 0 to i
    //such that (num%13) = j

    fori(i,0,n-1)
    {
        if(i==0)
        {
            if(s[0]!='?')
            {
                fori(j,0,12)
                {
                    if(j==s[0]-'0')
                    dp[i][j]=1;
                    else dp[i][j]=0;
                }
            }
            else
            {
                fori(j,0,12)
                {
                    if(j<10)
                    dp[i][j]=1;
                    else dp[i][j]=0;
                }
            }
        }
        else if(s[i]=='?')
        {
            fori(j,0,12)
            {
                fori(k,0,12)
                {
                    fori(d,0,9)
                    {
                        if((k+y[i]*d)%13==j)
                            dp[i][j]=(dp[i][j]+dp[i-1][k])%MAXN;
                    }
                }
            }    
        }
        else
        {
           fori(j,0,12)
            {
                fori(k,0,12)
                {
                    if ((k+y[i])%13 == j)
                        dp[i][j] =(dp[i][j] + dp[i-1][k])%MAXN;
                }
            }  
        }
    }
    // fori(i,0,n-1)
    // {
    //     cout << dp[i][5] << " ";
    // }
    cout<<dp[n-1][5];
    return 0;
}

Measured memory_bytes: 16896
import java.util.*;

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

        Scanner sc = new Scanner(System.in);
        String tapsInput = sc.next();
        char[] taps = tapsInput.toCharArray();
        int length = taps.length;

        for (int i = 0; i < length; i++) {
            if (i % 2 == 0 && taps[i] == 'L') { // even
                System.out.println("No");
                return;
            } else if (i % 2 == 1 && taps[i] == 'R') { // odd
                System.out.println("No");
                return;
            }
        }
        System.out.println("Yes");
    }
}

Measured memory_bytes: 21844
def gcd(a, b):
  while b:
    a, b = b, a%b
  return a

def lcm(a, b):
  return a*b//gcd(a, b)

def run():
  N = int(input())
  A_li = list(map(int, input().split()))
  A_lcm = 1
  for A in A_li:
    A_lcm = lcm(A_lcm, A)
  ans = 0
  for A in A_li:
    ans += A_lcm//A
  print(ans%(10**9+7))

if __name__ == '__main__':
  run()

Measured memory_bytes: 4084
#include<stdio.h>
int main()
{
	int n,m,i,j;
	char a[101][101];
	while(scanf("%d %d\n",&n,&m)!=EOF)
	{
		for(i=0;i<n;i++)
		{
		for(j=0;j<m;j++)
		{
			scanf("%c",&a[i][j]);
		
		}
		getchar();
}
for(i=0;i<m+2;i++)
{
printf("#");}
printf("\n");
for(i=0;i<n;i++)
{

printf("#");
		for(j=0;j<m;j++)
		{
			printf("%c",a[i][j]);
		}
		printf("#");
		printf("\n");
		
		
 }
 for(i=0;i<m+2;i++)
{
printf("#");}
printf("\n");
  }}

Measured memory_bytes: 128
# 2020/05/03
# AtCoder Beginner Contest 166 - C

# Input
n, m = map(int,input().split())
h = list(map(int,input().split()))

goodh = [0] * (n+1)
for i in range(m):
    wk_ab = list(map(int,input().split()))

    if h[wk_ab[0]-1] < h[wk_ab[1]-1]:
        goodh[wk_ab[0]] = 1
    elif h[wk_ab[0]-1] > h[wk_ab[1]-1]:
        goodh[wk_ab[1]] = 1
    else:
        goodh[wk_ab[0]] = 1
        goodh[wk_ab[1]] = 1

ans = 0
for i in range(1, n+1):
    if goodh[i] == 0:
        ans = ans + 1

# Output
print(ans)


Measured memory_bytes: 20168
#include <bits/stdc++.h>
#define PI 3.14159265359
using namespace std;

int main() {
	char c;
	cin >> c;

	int f = 0;
	if (c == 'a') f = 1;
	if (c == 'e') f = 1;
	if (c == 'i') f = 1;
	if (c == 'o') f = 1;
	if (c == 'u') f = 1;

	if (f) {
		cout << "vowel" << endl;
	}
	else {
		cout << "consonant" << endl;
	}
}

Measured memory_bytes: 256
# 入力 a1-3, b1-3
a = []
b = []
for i in range(3):
    a0, b0 = [int(i) for i in input().split()]
    if a0 != b0:
        a.append(a0)
        b.append(b0)
    else:
        print("NO")

# 制約条件
if 1 <= all(a + b) <= 4:
    if a[0] + b[0] != a[1] + b[1] and a[1] + b[1] != a[2] + b[2] and a[2] + b[2] != a[0] + b[0]:
        one = (a + b).count(1)
        two = (a + b).count(2)
        three = (a + b).count(3)
        four = (a + b).count(4)
        if 1 <= one <=2 and 1 <= two <=2 and 1 <= three <=2 and 1 <= four <=2:
            print("YES")
        else:
            print("NO")
    else:
        print("NO")
else:
    print("NO")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------
#define INF INT_MAX/2
#define def INF
template<class V, int NV> struct SegTree { //[l,r)
    V comp(V& l, V& r) { return min(l,r); };
    vector<V> val; SegTree() { val = vector<V>(NV * 2, def); }
    V get(int x,int y,int l=0,int r=NV,int k=1){if(r<=x||y<=l)return def;if(x<=l&&r<=y)return val[k];
    auto a=get(x,y,l,(l+r)/2,k*2);auto b=get(x,y,(l+r)/2,r,k*2+1);return comp(a,b);}
    void update(int i, V v) { i+=NV;val[i]=v;while(i>1)i>>=1,val[i]=comp(val[i*2],val[i*2+1]); }
    void add(int i, V v) { update(i, val[i + NV] + v); }
    int operator[](int x) { return get(x, x + 1); }};
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/



int N, B[201010], Q, C[201010];
vector<int> V[201010];
SegTree<int, 1 << 18> dp;
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N;
    rep(i, 0, N) cin >> B[i];
    cin >> Q;
    rep(i, 0, Q) {
        int L, R; cin >> L >> R; L--;
        V[L].push_back(R);
    }

    int base = 0;
    rep(i, 0, N) if (B[i] == 0) {
        base++;
        B[i] = -1;
    }

    rep(i, 0, 201010) dp.update(i, INF);
    dp.update(0, 0);

    rep(L, 0, N) {
        fore(R, V[L]) {
            int x = dp.get(L, R + 1);
            dp.update(R, x);
        }

        dp.update(L + 1, min(dp[L + 1], dp[L] + B[L]));
    }

    cout << base + dp[N] << endl;
}

Measured memory_bytes: 12544
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func digitSum(n int) int {
	ret := 0
	for n > 0 {
		ret += n % 10
		n /= 10
	}
	return ret
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	if n%digitSum(n) == 0 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 640
#include<stdio.h>

int selectionSort(int a[], int n)
{
	int i, j, min, temp;
	int swap = 0;
	
	for(i = 0; i < n; i++)
	{
		min = i;
		for(j = i; j < n; j++)
		{
			if(a[j] < a[min])
			{
				min = j;
			}
		}
		temp = a[i];
		a[i] = a[min];
		a[min] = temp;
		if(i != min)
		{
			swap++;
		}
	}
	
	return swap;
}

int main(void)
{
	int n, i;
	int swap = 0;
	
	scanf("%d", &n);
	
	int a[n];
	
	for(i = 0; i < n; i++)
	{
		scanf("%d", &a[i]);
	}
	
	swap = selectionSort(a, n);
	
	for(i = 0; i < n; i++)
	{
		if(i != n - 1)
		{
			printf("%d ", a[i]);
		}
		else
		{
			printf("%d\n", a[i]);
		}
	}
	
	printf("%d\n", swap);
	
	return 0;
}



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


int main() {
  vector<vector<int>>A(3,vector<int>(3));
  int N;
  vector<int>b(N);
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
       cin >> A.at(i).at(j);
    }
  }
  cin >> N;
  for(int i=0;i<N;i++) cin >> b.at(i);
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      for(int k=0;k<N;k++){
        if(A.at(i).at(j) == b.at(k)) A.at(i).at(j) = 0;
      }
    }
  }
  bool a = false;
  for(int i=0;i<3;i++){
    if(A.at(i).at(0) == A.at(i).at(1) && A.at(i).at(1) == A.at(i).at(2))a = true;
    if(A.at(0).at(i) == A.at(1).at(i) && A.at(1).at(i) == A.at(2).at(i))a = true;
  }
  if(A.at(0).at(0) == A.at(1).at(1) && A.at(1).at(1) == A.at(2).at(2))a = true;
  if(A.at(0).at(2) == A.at(1).at(1) && A.at(1).at(1) == A.at(2).at(0))a = true;
    
  if(a) cout << "Yes" << endl;
  else cout << "No" << endl;
       
  return 0;  
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define mp make_pair
#define pii pair<int,int>
#define pdd pair<double,double>
#define pll pair<ll,ll>
#define mst(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const double eps = 1e-9;
const int maxn = 2e5+9;
const double pi=3.14159265358979323846264;
const int inf = 1e9;
const ll mod = 1e9+7;
int op[maxn],pq[maxn];
int main()
{
    ios::sync_with_stdio(false);
    int n;
    ll k;
    cin>>n>>k;
    for(int i=1;i<=n;++i) cin>>op[i];
    int num=0,pos=op[1];
    map<int,int> io;
    io.clear();
    pq[num++]=1;io[1]=0;
    while(!io.count(pos)){
        io[pos]=num;
        pq[num++]=pos;
        pos=op[pos];
    }
    int tmp=io[pos];
    if(k<=tmp) cout<<pq[k];
    else{
        int kl=num-tmp;
        cout<<pq[tmp+(k-tmp)%kl];
    }
    return 0;
}


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

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int H, W, h, w;
int a[550][550];
signed main() {
    cin >> H >> W >> h >> w;
    bool tflag = false;
    if (W % w != 0) {
        tflag = true;
        swap(H, W);
        swap(h, w);
    } else if (H % h == 0) {
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    for (int i = 0; i <= H; i++)a[i][1] = -i;
    for (int i = 0; H - h * i > 0; i++)a[H - h * i][1] = i + 1;
    for (int i = H; i > 0; i--)a[i][1] -= a[i - 1][1];
    for (int i = 1; i <= H; i++) {
        for (int j = 2; j <= W; j++)a[i][j] = a[i][j - 1];
    }
    if (tflag)swap(H, W);
    for (int i = 1; i <= H; i++) {
        for (int j = 1; j <= W; j++) {
            if (tflag) cout << a[j][i] << " ";
            else cout << a[i][j] << " ";
        }
        cout << endl;
    }
}

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

#define rp(i,n) for(int i=0;i<n;i++)
#define rep(i,m,n) for(int i=m;i<=n;i++)
#define lrp(i,n) for(long long i=0;i<n;i++)
#define lrep(i,m,n) for(long long i=m;i<=n;i++)
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define pb push_back
#define elif else if
#define vcin(a); rp(i,a.size()){cin>>a[i];}
#define vcout(a); rp(i,a.size()){cout<<a[i]<<endl;}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef long long ll;
typedef string S;
typedef pair<int,int> P;

bool isOK(int index, int key,vi a) {
    if (a[index] >= key) return true;
    else return false;
}

int binary_search(int key,vi a) {
    int left = -1;
    int right = (int)a.size();
    while (right - left > 1) {
        int mid = left + (right - left) / 2;
        
        if (isOK(mid, key,a)) right = mid;
        else left = mid;
    }
    return right;
}

int modpow(int a,int b,int p){
    if(b==0){
        return 1;
    }elif(b%2==0){
        return modpow((a*a)%p,b/2,p);
    }else{
        return (a*modpow(a,b-1,p))%p;
    }
}

int main(){
    ll n,m;
    cin >> n >> m;
    if(n==1){
        cout << m << endl;
        return 0;
    }
    vl ans;
    ll i=1;
    while(i<=m/i){
        if(m%i){
            i++;
        }else{
            ll j=m/i;
            if(j>=n){
                ans.pb(i);
            }
            if(i>=n){
                ans.pb(j);
            }
            i++;
        }
    }
    sort(ans);
    cout << ans.at(ans.size()-1) << endl;
}


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

using ll = long long;

#define pb push_back
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (int)(a.size())
#define clr(a, b) memset(a, b, sizeof(a))
#define REP(i, a, b) for(int i=(int)(a); i<(int)(b); ++i)
#define REPD(i, a, b) for(int i=(int)(a)-1; i>=(int)(b); --i)

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 85;
int n, a[N];

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    REP(i, 0, n) cin >> a[i];

    ll res = 1000;
    REP(i, 0, n-1) {
    	if(a[i] < a[i+1]) {
    		ll s = res/a[i];
    		res += 1ll * s * (a[i+1] - a[i]);
    	}
    }
    cout << res << "\n";
    return 0;
}


Measured memory_bytes: 3632
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int32_t, int32_t>;

// std::cout << std::setprecision(20) << 1.1 << endl;

/*
int32_t CountD(const string &T) {
  const int32_t L = static_cast<int32_t>(T.length());
  int32_t max_count = 0;
  int32_t c_count = 0;
  for (int32_t i = 0; i < L; ++i) {
    if (T.c_str()[i] == 'P') {
    } else {
      ++c_count;
    }
    if (c_count > max_count) {
      max_count = c_count;
    }
  }
  return max_count;
}

int32_t CountPD(const string &T) {
  const int32_t L = static_cast<int32_t>(T.length());
  int32_t count = 0;
  int32_t i = 0;
  while (i < L - 1) {
    if (T.c_str()[i] == 'P' && T.c_str()[i + 1] == 'D') {
      ++count;
      i += 2;
    } else {
      ++i;
    }
  }
  return count;
}

pair<int32_t, string> Dfs(const int32_t index, const string T, const vector<int32_t> &positions) {
  if (index == static_cast<int32_t>(positions.size())) {
    return pair<int32_t, string>(CountD(T) + CountPD(T), T);
  } else {
    const int32_t position = positions[index];
    if (position == 0) {
      return Dfs(index + 1, string("D") + T.substr(position + 1, T.length()), positions);
    } else if (T.c_str()[position - 1] == 'P') {
      return Dfs(index + 1, T.substr(0, position) + string("D") + T.substr(position + 1, T.length()), positions);
    } else if (T.c_str()[position - 1] == 'D' && position < T.length()-1 && T.c_str()[position + 1] == 'D') {
      return Dfs(index + 1, T.substr(0, position) + string("D") + T.substr(position + 1, T.length()), positions);
    } else if (T.c_str()[position - 1] == 'D' && position < T.length()-1 && T.c_str()[position + 1] == 'P') {
      return Dfs(index + 1, T.substr(0, position) + string("D") + T.substr(position + 1, T.length()), positions);
    } else {
      const pair<int32_t, string> a =
          Dfs(index + 1, T.substr(0, position) + string("D") + T.substr(position + 1, T.length()), positions);
      const pair<int32_t, string> b =
          Dfs(index + 1, T.substr(0, position) + string("P") + T.substr(position + 1, T.length()), positions);
      if (a.first > b.first) {
        return a;
      } else {
        return b;
      }
    }
  }
}*/

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

  string T;
  cin >> T;
  const int32_t L = static_cast<int32_t>(T.length());
  vector<int32_t> positions;
  string result = "";
  for (int32_t i = 0; i < L; ++i) {
    if (T.c_str()[i] == '?') {
      positions.push_back(i);
      result += "D";
    } else {
      result += T.substr(i, 1);
    }
  }
  // const pair<int32_t, string> result = Dfs(0, T, positions);
  // cout << result.second << endl;
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 4816
import java.util.*;

public class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int n = sc.nextInt();
	Set<String> list = new HashSet<>();
    for(int i = 0 ; i < n ; i++){
      list.add(sc.next());
    }
	System.out.println(list.size());
	}
}

Measured memory_bytes: 76996
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
/* clang-format on */

int main() {
  int N, K;
  while (cin >> N >> K) {
    vector<int> h(N);
    for (int i = 0; i < N; i++) cin >> h[i];
    sort(h.begin(), h.end());
    int res = 1e9 + 100;
    for (int i = 0; i + K - 1 < N; i++) {
      res = min(res, h[i + K - 1] - h[i]);
    }
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 768
//------------------------------------------
// C++ templete 
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;

#define endl "\n"

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

//REPEAT
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//container util
//------------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define PRINT(V) for (auto v : (V)) cout << v << " "
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())

//constant
//------------------------------------------
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//math
//------------------------------------------
int QP(int a,int b){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int QP(int a,int b,int MOD){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int GCD(int a,int b){return b?GCD(b,a%b):a;}

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

//grobal variable
//------------------------------------------
int N,M;
VI Vec;

int main() 
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int A, B; cin >> A >> B;
    
    int positive = 1;
    if (A <= 0 && B >= 0) cout << "Zero" << endl;
    else
    {
        for(int i=A; i<=B; i++)
        {
            if (i < 0) positive *= -1; 
        }
 
    if (positive > 0) cout << "Positive" << endl;
    else cout << "Negative" << endl;


    }
     
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long
#define lowbit(x) (x & (-x))
#define INF 0x7FFFFFFF//or 0x3f3f3f3f ?
using namespace std;

template<class T> inline
void read(T& x) {
    int f = 1; x = 0;
    char ch = getchar();
    while (ch < '0' || ch > '9')   {if (ch == '-') f = -1; ch = getchar();}
    while (ch >= '0' && ch <= '9') {x = x * 10 + ch - '0'; ch = getchar();}
    x *= f;
}

/*============ Header Template ============*/

const int N = 300000 + 5;

LL n, k, num;
LL a[N], c[N], s[N], t[N];
map<LL, LL> mp;

void upd(int x) {
    for (int i = x; i <= num; i += lowbit(i)) t[i]++;
}

LL getsum(int x) {
    LL ans = 0;
    for (int i = x; i; i -= lowbit(i)) ans += t[i];
    return ans;
}

int main() {
    read(n), read(k);
    for (int i = 1; i <= n; i++) read(a[i]);
    for (int i = 1; i <= n; i++) s[i] = s[i - 1] + a[i];
    for (int i = 0; i <= n; i++) s[i] -= k * i;
    for (int i = 0; i <= n; i++) c[i + 1] = s[i];
    sort(c + 1, c + n + 1 + 1);
    num = unique(c + 1, c + n + 1 + 1) - (c + 1);
    for (int i = 1; i <= num; i++) mp[c[i]] = i;
    for (int i = 0; i <= n; i++) s[i] = mp[s[i]];
    LL ans = 0;
    for (int i = 0; i <= n; i++) {
        ans += getsum(s[i]);
        upd(s[i]);
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 20864
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
template<class T>void chmax(T& a, T b) { if (a < b)a = b; }
template<class T>void chmin(T& a, T b) { if (a > b)a = b; }
constexpr int INF = 1000000000000000000;
constexpr int mod = 1000000007;
int dx[] = { 0,1,0,-1 }, dy[] = { 1,0,-1,0 };
int kaijo[2000010];
struct edge { int to, cost; };
int gcd(int a, int b) {
    if (b == 0)return a;
    return gcd(b, a % b);
}
int lcm(int a, int b) {
    return a / gcd(a, b) * b;
}
bool prime(int a) {
    if (a == 1)return false;
    for (int i = 2; i * i <= a; i++) {
        if (a % i == 0)return false;
    }
    return true;
}
void init_fact() {
    kaijo[0] = 1;
    for (int i = 1; i <= 2000000; i++) {
        kaijo[i] = kaijo[i - 1] * i;
        kaijo[i] %= mod;
    }
}
int modpow(int a, int b) {
    if (b == 0)return 1;
    if (b % 2)return modpow(a, b - 1) * a % mod;
    int memo = modpow(a, b / 2);
    return memo * memo % mod;
}
int comb(int a, int b) {
    if (!kaijo[0])init_fact();
    return kaijo[a] * modpow(kaijo[a - b], mod - 2) % mod * modpow(kaijo[b], mod - 2) % mod;
}
int inv(int x) {
    x = modpow(x, mod - 2);
    return x;
}
bool kosa(double ax, double ay, double bx, double by, double cx, double cy, double dx, double dy) {
    double ta = (cx - dx) * (ay - cy) + (cy - dy) * (cx - ax);
    double tb = (cx - dx) * (by - cy) + (cy - dy) * (cx - bx);
    double tc = (ax - bx) * (cy - ay) + (ay - by) * (ax - cx);
    double td = (ax - bx) * (dy - ay) + (ay - by) * (ax - dx);
    return tc * td < 0 && ta * tb < 0;
}
int n, K, a[310], dp[310][310][310];
signed main() {
    cin >> n >> K;
    for (int i = 1; i <= n; i++)cin >> a[i];
    rep(i, n + 1) {
        rep(j, K + 1) {
            rep(k, n + 1) {
                dp[i][j][k] = INF;
            }
        }
    }
    dp[0][0][0] = 0;
    rep(i, n) {
        rep(j, K + 1) {
            rep(k, i + 1) {
                chmin(dp[i + 1][j][i + 1], dp[i][j][k] + max(0ll, a[i + 1] - a[k]));
                if (j < K)chmin(dp[i + 1][j + 1][k], dp[i][j][k]);
            }
        }
    }
    int ans = INF;
    rep(i, K + 1) {
        rep(j, n + 1) {
            chmin(ans, dp[n][i][j]);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 229632
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    A, B, C, K = [int(x) for x in input().split()]

    ans = A - B
    if K % 2 == 0:
        print(ans)
    else:
        print(-ans)


if __name__ == '__main__':
    main()



Measured memory_bytes: 2940
#include <iostream>
#include <cstdio>
#define MAX 10000
#define NIL -1
using namespace std;

struct Node{
	int p;
	int l;
	int r;
};

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



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

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

int getS(int u){
	if(T[u].p==NIL) return NIL;
	if(T[T[u].p].l!=u&&T[T[u].p].l!=NIL)
	return T[T[u].p].l;
	if(T[T[u].p].r!=u&&T[T[u].p].r!=NIL)
	return T[T[u].p].r;
	return NIL;
}

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

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

Measured memory_bytes: 3212
def makelist(n, m):
    return [[0 for _ in range(m)] for _ in range(n)]

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


ans = 0
for e in A:
    a = e
    while a % 2 == 0:
        a //= 2
        ans += 1
print(ans)


Measured memory_bytes: 41584
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
const long long mod = 1e9+7;
//////////////////////////////////

int main() {
  int x; cin >> x;
  for(int k=1; ; k++) {
    if ((k * x)%360 == 0) {
      cout << k << endl;
      return 0;
    }
  }

  return 0;
}

// EOF

Measured memory_bytes: 3512