akhauriyash/Code-Regression huggingface dataset:
// When you are hungry for something and you're determined and you're focused 
// and you're committed to something it's hard to surrender, isn't it?

#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define ll long long 
#define int ll
#define mod 1000000007
#define mod1 1000000006
#define modi 998244353
#define setbit(x) __builtin_popcount(x)
#define ff first
#define ss second
#define pb push_back
#define fff(i,n) for(int i=0;i<n;i++)
vector<ll> vi[300005];
int color[100005];
ll pa[500005];
ll si[500005];
#define pb push_back
bool visi[1000005]={false};
bool is[100005];
ll fac[10000001];
ll prime[400005];
ll bit[100005];
const long double eps = 1.0e-14;      // allowable error
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL);
 
 
void fact(){
    fac[0]=1;
    for(int i=1;i<=10000000;i++){
        fac[i]=(fac[i-1]*i)%mod;
    }
    return ;
}
void sieve(){
    prime[0]=0;
    prime[1]=0;
    for(int i=2;i<400005;i++){
        prime[i]=1;
    }
    for(int i=2;i*i<400005;i++){
        if(prime[i]==1){
            for(int j=i*i;j<400005;j+=i){
                prime[j]=0;
            }
        }
    }
    
}
 
ll power(ll n , ll p ){
    if(p==0)
        return 1;
    
    ll res = power((n*n)%mod,p/2);
    if(p%2==1)
        res = (n*res)%mod;
    
    return res;
}
 
 
void upd(ll i,ll val,ll n) {
    for(;i<=n;i+=i&(-i))
        bit[i]+=val;
}
 
ll qry(ll i) {
    ll sum=0;
    for(;i>0;i-=i&(-i))
        sum+=bit[i];
    return sum;
}
 
 
ll fin(ll u) {
    if(pa[u]==u)
        return u;
    return fin(pa[u]);
}
 
void uni(ll u,ll v) {
    ll p1=fin(u);
    ll p2=fin(v);
    if(p1==p2)
        return;
    if(si[p1]<si[p2])
        swap(p1,p2);
    si[p1]+=si[p2];
    pa[p2]=p1;
    return;
}
 
int32_t main() {
    fio
    
    int a,b,c;
    cin >> a >> b >> c;
    
    if((a==b and b!=c) or (a==c  and a!=b) or (b==c and a!=b))
    cout  << "Yes" ;
    else
    cout << "No";
        
    return 0;
    
}

Measured memory_bytes: 8832
import math


def resolve():
    import sys
    input = sys.stdin.readline
    # row = [int(x) for x in input().rstrip().split(" ")]
    kn = [int(x) for x in input().rstrip().split(" ")]
    k = kn[0]
    a = [int(x) for x in input().rstrip().split(" ")]

    max_dist = max([a[i+1] - a[i] for i in range(len(a)-1)])
    max_dist = max_dist if max_dist > a[0] + k - a[len(a)-1] else a[0] + k - a[len(a)-1]

    print(k - max_dist)


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 33852
#include <stdio.h>

int main(){
   int m,n,i,j,c=0;
   scanf("%d",&n);
   int t[n];
   for (i = 0; i < n; i++) {
     scanf("%d",&t[i]);
   }
   scanf("%d",&m);
   int p[m],x[m];
   for (i = 0; i < m; i++) {
     scanf("%d %d",&p[i],&x[i]);
     for (j = 0; j < n; j++) {
       if (p[i] != j+1) {
         c += t[j];
       }else{
         c += x[i];
       }
     }
     printf("%d\n",c);
     c=0;
   }

  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define f first
#define s second
#define mp make_pair
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	cout<<(n*(n+1)/2)<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>
#include<set>
 
using namespace std;
 
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define F(i,j,k) fill(i[0],i[0]+j*j,k)
#define P(p) cout<<(p)<<endl;
#define INF 1<<25
 
typedef long long ll;

int dy[8]={1,1,1,0,0,-1,-1,-1};
int dx[8]={-1,0,1,-1,1,-1,0,1};
struct S{
	int a,b,c;
};
bool asc(const S& left,const S& right){
	return left.c > right.c;
}
bool G[8][8];
bool visited[8];
int ans;
int N,M;
void dfs(int now){
	bool c=true;
	rep(i,N){
		if(visited[i]==false)
			c=false;
	}
	if(c){
		ans++;
	}
	rep(i,N){
		if(G[now][i]==true&&visited[i]==false){
			visited[i]=true;
			dfs(i);
			visited[i]=false;
		}
	}
}
int main(){
	cin>>N>>M;
	rep(i,M){
		int a,b;
		cin>>a>>b;
		a--;b--;
		G[a][b]=true;
		G[b][a]=true;
	}
	rep(i,N)visited[i]=false;
	visited[0]=true;
	dfs(0);
	cout<<ans<<endl;
	
	return 0;
}



Measured memory_bytes: 256
//Author: Fuadul Hasan(fuadul202@gmail.com)
//BSMRSTU,Gopalganj

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

#define ll long long
const int N   = 2e5 + 5;

int main(){

	int n,m;
	cin>>n>>m;
	int x = m - n+1;
	int y = m+n;
	for(int i=x;i<y;i++)
		cout<<i<<" ";
	cout<<endl;


	return 0;
}



Measured memory_bytes: 256
from collections import Counter
n = int(input())
k = n//2
a = list(map(int, input().split()))
p = []
q = []
for i in range(k):
    p.append(a[2*i])
    q.append(a[2*i+1])
s = Counter(p).most_common()
t = Counter(q).most_common()
u, v = len(s), len(t)
ans = 0
if s[0][0] == t[0][0]:
    if u == 1 and v == 1:
        ans = k
    elif u == 1:
        ans = k - t[1][1]
    elif v == 1:
        ans = k - s[1][1]
    else:
        comp = max(s[1][1], t[1][1])
        ans = n - s[0][1] - comp
else:
    ans = n - s[0][1] - t[0][1]
print(ans)



Measured memory_bytes: 21084
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	for sc.Scan() {
		c := map[byte]int{'N': 0, 'S': 0, 'W': 0, 'E': 0}
		bs := sc.Bytes()
		for _, b := range bs {
			num, ok := c[b]
			if ok {
				c[b] = num + 1
			}
		}
		n, _ := c['N']
		s, _ := c['S']
		w, _ := c['W']
		e, _ := c['E']

		if n == 0 && s == 0 && w == 0 && e == 0 {
			// ?
			fmt.Println("No")
		} else {
			if ((n == 0) && (s == 0) || (n > 0) && (s > 0)) &&
				((w == 0) && (e == 0) || (w > 0) && (e > 0)) {
				fmt.Println("Yes")
			} else {
				fmt.Println("No")
			}
		}
	}
}

Measured memory_bytes: 640
# ABC134-B

import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n,d=LI()
  return -(-n//(2*d+1))

# main()
print(main())


Measured memory_bytes: 6092
from statistics import mean, median,variance,stdev
import sys
import math
import fractions

def j(q):
    if q==1: print("YES")
    else:print("NO")
    exit(0)


def ct(x,y):
    if (x>y):print("")
    elif (x<y): print("")
    else: print("")

def ip():
    return int(input())

#n = ip()                              #入力整数1つ
#d,x= (int(i) for i in input().split())      #入力整数横2つ
#k,a,b = (int(i) for i in input().split())    #入力整数横3つ
#n,m,x,y= (int(i) for i in input().split())  #入力整数横4つ
#a = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列

#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
x =ip()
a = []
for i in range(x):
    a.append(input())
y = ip()
b = []
for i in range(y):
    b.append(input())

c = list(set(a))
d = list(set(b))
m = [0]
for i in range(len(c)):
    m.append(a.count(c[i])-b.count(c[i]))
print(max(m))


Measured memory_bytes: 5144
N, M = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(M)]

MAX = N + 2
array = [0] * (MAX)

for l, r in X:
    array[l] += 1
    array[r + 1] -= 1

for i in range(MAX - 1):
    array[i + 1] += array[i]

print(sum(v == M for v in array))


Measured memory_bytes: 93636
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <utility>
typedef long long ll;
const int INF = 1e9+1;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
using namespace std;

int main() {
	int n;
	int cnt = 0;
	int ans = 0;
	cin >> n;
	int a[2][100];
	for (int i = 0; i < n; i++) {
		cin >> a[0][i];
	}
	for (int i = 0; i < n; i++) {
		cin >> a[1][i];
	}
	
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (j >= i)cnt += a[1][j];
			else { cnt += a[0][j]; }
		}
		cnt += a[0][i];
		if (cnt > ans)ans = cnt;
		cnt = 0;
	}
	cout << ans << endl;

}

Measured memory_bytes: 3632
/**
 * @param input string[][]
 */
function Main(input) {
  const M = +input[0][1];
  const psets = input.slice(1);

  const accepted = new Set();
  const penas = {};
  var totalPenas = 0;

  var q;
  for (var i = 0; i < M; i++) {
    q = psets[i][0];

    if (accepted.has(q)) continue;

    if (psets[i][1][0] === 'A') {
      accepted.add(q);
      if (penas[q]) {
        totalPenas += penas[q];
      }
    } else {
      penas[q] = (penas[q] || 0) + 1;
    }
  }

  const answer = '' + accepted.size + ' ' + totalPenas;

  console.log(answer);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim()
  .split('\n')
  .map((v) => v.split(' '))
);


Measured memory_bytes: 56672
#include<bits/stdc++.h>
using namespace std;
string to_string(const string& s) {
	return '"' + s + '"';
}
string to_string(const bool b) {
	return (b ? "true" : "false");
}
string to_string(const char* s) {
	return to_string((string)s);
}
string to_string(const char c) {
	string s = "'";
	s += c;
	s += "'";
	return s;
}
template<class T, class U>
string to_string(const pair<T, U>& p) {
	string s = "(";
	s += to_string(p.first);
	s += ", ";
	s += to_string(p.second);
	s += ")";
	return s;
}
template<class T>
string to_string(const T& a) {
	bool first = true;
	string s = "{";
	for (const auto& x : a) {
		if(!first){
			s += ", ";
		}
		first = false;
		s += to_string(x);
	}
	s += "}";
	return s;
}
void debug_out() {cerr << '\n';}
template<class Head, class... Tail>
void debug_out(Head head, Tail... tail) {
	cerr << ' ' << to_string(head);
	debug_out(tail...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "] = ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
using ll = long long;
using ld = long double;
const int mod = 1e9 + 7;
const int inf = 1e9 + 100;
const ll inf64 = 7e18l;
bool check(int x) {
	string p = to_string(x);
	string t = p;
	reverse(p.begin(), p.end());
	return t == p;
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(20);
	int a, b;
	int answer = 0;
	cin >> a >> b;
	for (int i = a; i <= b; ++i) {
		answer += check(i);
	}
	cout << answer << '\n';
 	return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 998244353;

const int N = 1e6 + 10;
int cnt[N], s2[N], s1[N];
int f[N];

void add(int& x, int y) {
  x += y;
  if (x >= MOD) x -= MOD;
}

int main() {
  f[1] = 1;
  for (int i = 2; i < N; ++i) {
    f[i] = (MOD - MOD / i) * (int64)f[MOD % i] % MOD;
  }
  for (int i = 1; i < N; ++i) {
    for (int j = i + i; j < N; j += i) {
      add(f[j], MOD - f[i]);
    }
  }

  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    int k;
    scanf("%d", &k);
    add(s1[k], k);
    add(s2[k], (int64)k * k % MOD);
  }
  for (int i = 1; i < N; ++i) {
    int cur1 = 0, cur2 = 0;
    for (int j = i; j < N; j += i) {
      add(cur1, s1[j]);
      add(cur2, s2[j]);
    }
    cnt[i] = (int64)cur1 * cur1 % MOD;
    add(cnt[i], MOD - cur2);
    cnt[i] = cnt[i] % 2 == 0 ? cnt[i] / 2 : (cnt[i] + MOD) / 2;
  }

  int ret = 0;
  for (int i = 0; i < N; ++i) {
    add(ret, (int64)f[i] * cnt[i] % MOD);
  }
  printf("%d\n", ret);

  return 0;
}


Measured memory_bytes: 15872
N = int(input())
a = list(map(int,input().split()))
c = a.copy()

b = [0] * N
i = N-1
while i >= 0:
    for j in range(1, N//(i+1)):
        c[i] = c[i] - b[(j+1)*(i+1)-1]
    b[i] = c[i]%2
    i -= 1


count = 0
for i in range(N):
    e = sum(b[i::i+1])
    if e%2 != a[i] :
        print(-1)
        count =1
        break


if count == 0 :
    d = []

    print(b.count(1))

    for i in range(N):
        if b[i] ==1 :
            d.append(str(i+1))

    if len(d) != 0:
        print(' '.join(d))


Measured memory_bytes: 19260
#include <iostream>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <cstdlib>
#include <cmath>
#include <cstdio>
#include <string>
#include <cstring>
#include <algorithm>
#define fup(i,a,b) for(int i=a;i<=b;i++)
#define fdw(i,a,b) for(int i=a;i>=b;i--)
#define sync ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define cl(a) memset(a,0,sizeof(a))
using namespace std;
typedef long long ll;
const int N=1e6+10;
int a[N];
bool cmp(int a,int b)
{
    return a>b;
}
int main ()
{
    ll n;
    cin>>n;
    ll sum=1;
    while(n>=sum)
    {
        sum*=2;
    }
    cout<<sum-1<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <functional>
#include <limits>
#include <queue>
#include <iomanip>
#include <deque>
#include <stack>
#include <cstdio>
#include <cmath>
#include <complex.h>
#include <cstdio>
#include <random>
#include <chrono>
#include <numeric>
#include <cassert>
#include <iso646.h>
#include <exception>
#include <stdexcept>

using namespace std;

typedef long long i64;

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

    int r, g;
    cin >> r >> g;

    cout << 2 * g - r;
}

Measured memory_bytes: 256
import collections


def choose2(n):
    return n * (n - 1) // 2


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

count = collections.Counter(A)

total = 0
for cnt in count.values():
    total += choose2(cnt)

for a in A:
    ans = total
    c = count[a]
    ans -= choose2(c)
    ans += choose2(c-1)
    print(ans)


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

int main() {
	int n;
	cin>>n;
	string s[n+1];int a[n+1]={},b[n+1]={};int p=0;int a1=0,b1=0,c1=0;int small,large;
	for(int i=1;i<n+1;i++)
	{
		cin>>s[i];
		int l=s[i].length();
		for(int j=0;j<l-1;j++)
		{
			if(s[i][0]=='B')
			b[i]=1;
			if(s[i][l-1]=='A')
			a[i]=1;
			if(s[i][j]=='A' && s[i][j+1]=='B')
			p++;
		}
		if(a[i]==1)
		a1++;
		if(b[i]==1)
		b1++;
		if(a[i]==1 && b[i]==1)
		c1++;
	}
	if(a1>b1)
	{small=b1;large=a1;}
	else {small=a1;large=b1;}
	if(c1==small)
	{
		if(large==small && small!=0)
		small--;
	}
	p=p+small;
	cout<<p;
	
	
	// your code goes here
	return 0;
}

Measured memory_bytes: 896
def paint(masu,data):
    masu[data[1]][data[0]]+=1                   #インクを垂らした場所
    #print(masu)
    if data[2]==1:                              #インク小の時
        if data[0]!=0:
            masu[data[1]][data[0]-1]+=1
        if data[0]!=9:
            masu[data[1]][data[0]+1]+=1
        if data[1]!=0:
            masu[data[1]-1][data[0]]+=1
        if data[1]!=9:
            masu[data[1]+1][data[0]]+=1
        #print("小の時",masu)
    elif data[2]==2:                            #インク中の時
        if data[0]!=0:
            masu[data[1]][data[0]-1]+=1
        if data[0]!=9:
            masu[data[1]][data[0]+1]+=1
        if data[1]!=0:
            masu[data[1]-1][data[0]]+=1
        if data[1]!=9:
            masu[data[1]+1][data[0]]+=1
        if data[1]!=9 and data[0]!=9:
            masu[data[1]+1][data[0]+1]+=1
        if data[1]!=9 and data[0]!=0:
            masu[data[1]+1][data[0]-1]+=1
        if data[1]!=0 and data[0]!=9:
            masu[data[1]-1][data[0]+1]+=1
        if data[1]!=0 and data[0]!=0:
            masu[data[1]-1][data[0]-1]+=1
        #print("中の時",masu)
    elif data[2]==3:                            #インク大の時
        if data[0]!=0:
            masu[data[1]][data[0]-1]+=1
        if data[0]!=9:
            masu[data[1]][data[0]+1]+=1
        if data[1]!=0:
            masu[data[1]-1][data[0]]+=1
        if data[1]!=9:
            masu[data[1]+1][data[0]]+=1
        if data[1]!=9 and data[0]!=9:
            masu[data[1]+1][data[0]+1]+=1
        if data[1]!=9 and data[0]!=0:
            masu[data[1]+1][data[0]-1]+=1
        if data[1]!=0 and data[0]!=9:
            masu[data[1]-1][data[0]+1]+=1
        if data[1]!=0 and data[0]!=0:
            masu[data[1]-1][data[0]-1]+=1
        if data[1]>=2:
            masu[data[1]-2][data[0]]+=1
        if data[1]<=7:
            masu[data[1]+2][data[0]]+=1
        if data[0]>=2:
            masu[data[1]][data[0]-2]+=1
        if data[0]<=7:
            masu[data[1]][data[0]+2]+=1
        #print("大の時",masu)
    return masu

masu=[
        [0,0,0,0,0,0,0,0,0,0],
        [0,0,0,0,0,0,0,0,0,0],
        [0,0,0,0,0,0,0,0,0,0],
        [0,0,0,0,0,0,0,0,0,0],
        [0,0,0,0,0,0,0,0,0,0],
        [0,0,0,0,0,0,0,0,0,0],
        [0,0,0,0,0,0,0,0,0,0],
        [0,0,0,0,0,0,0,0,0,0],
        [0,0,0,0,0,0,0,0,0,0],
        [0,0,0,0,0,0,0,0,0,0]
    ]



def keisan(masu):
    max=0
    num1=0
    for na in range(10):
        for ma in range(10):
            if masu[na][ma]==0:
                num1+=1
            if masu[na][ma]>max:
                max=masu[na][ma]
    print(num1)
    print(max)

while True:
    try:
        x,y,s=list(map(int, input().split(',')))
        data=[x,y,s]   
        masu2=paint(masu,data)
    except:
        break

    
    #print("masu",masu2)
#print("masu2",masu2)
keisan(masu2)




Measured memory_bytes: 5824
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int ans = Math.max(A+A-1, Math.max(B+B-1, A+B));
		System.out.println(ans);
		
	}

}


Measured memory_bytes: 21588
s = input()
x, y = map(int, input().split())
x += 8500
y += 8500

dpx = [0 for i in range(17000)]
dpy = [0 for i in range(17000)]

dpx[8500] = 1
dpy[8500] = 1

f = s.split("T")

fx = []
fy = []

for i, fi in enumerate(f):
    if i % 2:
        fy.append(len(fi))
    else:
        fx.append(len(fi))

for i, fxi in enumerate(fx):
    nex = [0] * 17000
    for j in range(17000):
        if dpx[j]:
            if fxi + j < 17000:
                nex[fxi + j] = 1
            if i > 0 and j - fxi >= 0:
                nex[j - fxi] = 1
    dpx = nex[:]
        
for fyi in fy:
    nex = [0] * 17000
    for j in range(17000):
        if dpy[j]:
            if fyi + j < 17000:
                nex[fyi + j] = 1
            if j - fyi >= 0:
                nex[j - fyi] = 1
    dpy = nex[:]

if dpx[x] and dpy[y]:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 168404
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <chrono>
#include <queue>
#include <functional>

using namespace std;

typedef long long ll;

int dp[64][100+1];

int main() {
    set<int> banned = { 0b001001, 0b100001, 0b000110 };
    // 0, 1, 2, 3 -> A C G T;
    for (int j = 0; j < 64; ++j) {
        if (banned.count(j) == 0) dp[j][3] = 1;
    }
    //cin.tie(0);
    //ios::sync_with_stdio(false);
    int N;
    cin >> N;

    for (int i = 4; i <= N; ++i) {
        for (int j = 0; j < 64; ++j) {
            if (banned.count(j) == 0) {
                //T, C
                dp[j][i] += dp[0b110000 | j >> 2][i - 1];
                dp[j][i] %= 1000000007;
                dp[j][i] += dp[0b010000 | j >> 2][i - 1];
                dp[j][i] %= 1000000007;

                // G
                if ((j >> 2) != 0b0001) {
                    dp[j][i] += dp[0b100000 | j >> 2][i - 1];
                    dp[j][i] %= 1000000007;
                }
                // A
                if ((j >> 2) != 0b1001 && (j >> 2) != 0b0110 && (j & 0b1111) != 0b1001 && (j & 0b110011) != 0b100001) {
                    dp[j][i] += dp[0b000000 | j >> 2][i - 1];
                    dp[j][i] %= 1000000007;
                }
            }
        }
    }

    int ans = 0;
    for (int j = 0; j < 64; ++j) {
        ans += dp[j][N];
        ans %= 1000000007;
    }

    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

const int maxN = 1e5; int x, y, a, b, c;
lli reds[maxN], greens[maxN], bugs[maxN];

int main()
{
  while (scanf("%d %d %d %d %d", &x, &y, &a, &b, &c) != EOF)
  {
    for (int i = 0; i < a; i++) scanf("%lld", &reds[i]);
    for (int i = 0; i < b; i++) scanf("%lld", &greens[i]);
    for (int i = 0; i < c; i++) scanf("%lld", &bugs[i]);
    sort(reds, reds+a, greater<lli>());
    sort(greens, greens+b, greater<lli>());
    sort(bugs, bugs+c, greater<lli>());
    reverse(reds, reds+x);
    reverse(greens, greens+y);

    lli ans = 0;
    for (int i = 0; i < x; i++) ans += reds[i];
    for (int i = 0; i < y; i++) ans += greens[i];
    for (int r = 0, g = 0, i = 0; i < c; i++)
    {
      lli dr = r < x ? bugs[i] - reds[r] : -1, dg = g < y ? bugs[i] - greens[g] : -1;
      DEBUG printf("%d %d %d - %lld %lld %lld\n", i, r, g, dr, dg, ans);
      if (dr > 0 && dr > dg)
        ans += dr, r++;
      else if (dg > 0)
        ans += dg, g++;
    }

    printf("%lld\n", ans);
  }
  return 0;
}

Measured memory_bytes: 2560
import java.util.*;
 
public class Main {
  public static void main(String... args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    String S = sc.next();    
    System.out.println(S.substring(0,N/2).equals(S.substring(N/2,N)) ? "Yes" : "No");
  }
}

Measured memory_bytes: 21844
import java.io.*;

class Main{
	public static void main(String[] args){
		try{
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			String wk[] = br.readLine().split(" ", 0);
			int n = Integer.parseInt(""+wk[0]);
			int q = Integer.parseInt(""+wk[1]);
			String name[] = new String[n+1];
			int time[] = new int[n+1];
			int i, ttime=0;
			int head=0, tail=n-1;
			for(i=0; i<n; i++){
				wk = br.readLine().split(" ", 0);
				name[i] = wk[0];
				time[i] = Integer.parseInt(""+wk[1]);
			}
			while(n>0){
				if(time[head]<=q){
					ttime += time[head];
					System.out.println(name[head]+" "+ttime);
					for(i=head; i<n-1; i++){
						name[i] = name[i+1];
						time[i] = time[i+1];
					}
					if(head==n-1) head=0;
					if(tail==n-1) tail=0;
					n--;
				} else{
					ttime += q;
					time[head] -= q;
					head++;
					if(head==n) head=0;
					tail++;
					if(tail==n) tail=0;
				}
			}
		} catch(IOException e){
			System.out.println("Exception :" + e);
		}
	}
}

Measured memory_bytes: 60716
s = input()
gap = len(s)-1

def dfs(i,f):
    if i == gap:
        return sum(list(map(int, f.split("+"))))

    # 式 f の末尾に "+" を追加するかしないかして次の数字を追加
    return dfs(i + 1, f + s[i + 1]) + dfs(i + 1, f + "+" + s[i + 1])

print(dfs(0,s[0]))

Measured memory_bytes: 3060
#include<iostream>
#include<utility>
#include<tuple>
#include<set>
#include<list>
#include<vector>
#include<map>
#include<algorithm>
#include<queue>

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FUNCTION__ << endl;
#define int long long

const long long MAXN = 1e6;
const long long MOD = 1e9+7;
const long long INF = __LONG_LONG_MAX__ / 2;

using namespace std;

int hoge[MAXN];

signed main(){
    int R, G;
    cin >> R >> G;
    cout << 2 * G - R;
    return 0;
}

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



int main() {
  int N;
  cin >> N;
  int num_7 = N/7;
  int num_4 = N/4;
  int res = 0;
  string out;
  for (int i=0; i <= num_7; i++){
    for (int j=0; j <= num_4; j++){
      int total = i*7+j*4;
      if (total == N) ++res; 
    }
  }
  if (res == 0){
    out = "No";
    }
  else{
    out = "Yes";
  }
  cout << out << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char c;
  cin >> c;
  if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') {
    cout << "vowel" << endl;
  }
  else {
    cout << "consonant" << endl;
  }
}

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

string replace(string s, int a, int b, string t){
    for(int i = a; i <= b; i++){
        s[i] = t[i - a];
    }
    return s;
}

string reverse(string s, int a, int b){
    int i = a; 
    int j = b;
    while (i < j)
    {
        swap(s[i], s[j]);
        i++;
        j--;
    }
    return s;
}

void print(string s, int a, int b){
    for(int i = a; i <= b; i++){
        cout << s[i];
    }
    cout << endl;
}

int main(){
    string str;
    cin >> str;
    int q;
    cin >> q;
    for(int i = 0; i < q; i++){
        string c;
        cin >> c;
        int a, b;
        cin >> a >> b;
        if(c == "replace"){
            string t;
            cin >> t;
            str = replace(str, a, b, t);
        }
        else if(c == "reverse"){
            str = reverse(str, a, b);
        }
        else if(c == "print"){
            print(str, a, b);
        }
    }
    return 0;
}


Measured memory_bytes: 3216
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

S = input()
L = len(S)

def p():
    for j in range(L - 2):
        if S[j] == S[j + 1]:
            print(j + 1, j + 2)
            return
        if S[j] == S[j + 2]:
            print(j + 1, j + 3)
            return

    if S[-2] == S[-1]:
        print(L - 1, L)
    else:
        print(-1, -1)

p()

Measured memory_bytes: 3828
import java.security.KeyStore.TrustedCertificateEntry

object Main {

  import java.util.Scanner

  def main(args: Array[String]): Unit = {
    val scanner = new Scanner(System.in)
    var count5 = 0
    var count7 = 0
    var s = ""

    for(i <- 0 to 2){
      s = scanner.next()
      if(s equals "5")
        count5 += 1
      else if(s equals "7")
        count7 += 1
    }

    if(count5 == 2 && count7 == 1)
      println("YES")
    else
      println("NO")

  }
}

Measured memory_bytes: 27208
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    ll N;
    cin >> N;
    N -= 1;
    ll i = 26;
    vector<ll> border(12);
    border[0] = 0;
    rep(j,11){
        border[j + 1] = i + border[j];
        i = i * 26;
    }
    rep(j,11){
        if (border[j] <= N && N < border[j + 1]){
            N -= border[j];
            vector<ll> name(j + 1);
            ll a = 1;
            for (int k = 0; k < j; k++){
                a *= 26;
            }
            for (int k = 0; k < j + 1; k++){
                name[k] = N / a;
                N -= a * name[k];
                a /= 26;
            }
            rep(k,j + 1){
                if (name[k] == 0) cout << 'a';
                if (name[k] == 1) cout << 'b';
                if (name[k] == 2) cout << 'c';
                if (name[k] == 3) cout << 'd';
                if (name[k] == 4) cout << 'e';
                if (name[k] == 5) cout << 'f';
                if (name[k] == 6) cout << 'g';
                if (name[k] == 7) cout << 'h';
                if (name[k] == 8) cout << 'i';
                if (name[k] == 9) cout << 'j';
                if (name[k] == 10) cout << 'k';
                if (name[k] == 11) cout << 'l';
                if (name[k] == 12) cout << 'm';
                if (name[k] == 13) cout << 'n';
                if (name[k] == 14) cout << 'o';
                if (name[k] == 15) cout << 'p';
                if (name[k] == 16) cout << 'q';
                if (name[k] == 17) cout << 'r';
                if (name[k] == 18) cout << 's';
                if (name[k] == 19) cout << 't';
                if (name[k] == 20) cout << 'u';
                if (name[k] == 21) cout << 'v';
                if (name[k] == 22) cout << 'w';
                if (name[k] == 23) cout << 'x';
                if (name[k] == 24) cout << 'y';
                if (name[k] == 25) cout << 'z';
            }
            cout << endl;
        }
    }
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
int imos[100002];
int main(void){
    int N, M; cin >> N >> M;    
    for (int i = 0; i < M; i++) {
        int l, r; cin >> l >> r;
        r++;
        imos[l]++;
        imos[r]--;
    }
    int ans = 0;
    for (int i = 1; i < 100001; i++) {
        imos[i] += imos[i-1];
        if (imos[i] == M) {
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#include<iostream>
#include<ctype.h>
using namespace std;
int main()
{
  int x,i,j;
  cin>>x;
  if(x>=500)
    i=x/500;
  if(x>=5)
    j=(x%500)/5;
  x=500*i*2+j*5;
  cout<<x;
}


Measured memory_bytes: 256
#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);

  int n;
  string s;
  cin >> n >> s;
  // dp[i][j] = i文字目までとj文字目までの共通文字列のうち最長のものの長さ
  // i < j;
  vii dp(n,vi(n));
  int ans = 0;
  for(int i = 0; i < n-1; i++) {
    for(int j = i+1; j < n; j++) {
      if(s[i] == s[j]) {
        dp[i][j]++;
        if(i > 0 && j > i+1) dp[i][j] += dp[i-1][j-1];
        chmin(dp[i][j], j-i);
        chmax(ans, dp[i][j]);
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 99968
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <map>
#include <queue>
#define rep(i,n) for (int i=0;i<(n);i++)

using namespace std;

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

	for (int i = 0;i < s.length();i++) {
		s[i] = s[i] + n;
		if (s[i] > 90) {
			s[i] = s[i] - 26;
		}
	}

	cout << s << endl;
	return 0;
}

Measured memory_bytes: 3604
#include <cstdio>
#include <cassert>
#include <algorithm>    
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <bitset>
#define pb push_back
#define mk make_pair
#define eb emplace_back
#define eps 1e-8
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define int long long
using namespace std;

typedef long double ld;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef tuple<int, int, int> tiii;
typedef unsigned long long ull; 
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<long double> vd;
const int inf = 1e9;
const long long INF = 1e18;
const int M = 1e9 + 7;
//__int128


signed main() {
  // freopen("in.txt", "r", stdin);
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  cout.setf(ios::fixed); cout.precision(10);
  long long x;
  cin >> x;
  cout << x * x << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <stdio.h>
#include <set>
#include <vector>
using namespace std;


int main(){
    int x, a;
    cin>>x>>a;

    if(x<a){
        cout<<0<<endl;
    }

    else{
        cout<<10<<endl;
    }
    return 0;

}

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

#define rep(i,n) for(int i=1;i<=n;i++)

int main() {
	int N, M;
	cin >> N >> M;
	rep(i, max({ N,M }))
		cout << min({ N,M });
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define All(a) (a).begin(),(a).end()

int main(){ 
  int a,b,c,x,y;
  ll ans=0;
  cin >> a>> b>>c>>x>>y;
  if(a+b<2*c){
    cout<<a*x+b*y<<endl;
    return 0;
  }else{
    int tmp=min(x,y);
    x-=tmp;y-=tmp;
    ans+=c*tmp*2;
    if(x>0 && a>2*c)ans+=x*c*2;
    else if(y>0 && b>2*c)ans+=y*c*2;
    else  ans+=a*x+b*y;
    cout << ans <<endl;
  }

  return 0;
}

Measured memory_bytes: 3392
#include <bits/stdc++.h>
using namespace std;
int main(){

    long long int X,Y,Z,i;
    cin >> X >> Y >> Z;

    for(i = 0; i < 100000000; i++) {

        if(Z + (Y + Z) * i > X) {
            break;
        }
    }

    cout << i - 1 << endl;

    return 0;
}


Measured memory_bytes: 256
n = int(input())
s = input()
r = s.count("R")
g = s.count("G")
b = s.count("B")
ans = r*g*b
for i in range(1,(n+1)//2):
    j = 0
    while j + 2*i <= n-1:
        if len(set(s[j]+s[j+i]+s[j+2*i])) == 3:
            ans -= 1
        j += 1
print(ans)

Measured memory_bytes: 68088
#include <bits/stdc++.h>
typedef long long lint;
using namespace std;
const int MAXN = 101;
const int INF = 1e9 + 7;
int w[MAXN],v[MAXN];
int N,W;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> N >> W;
	for (int i = 0; i < N; ++i) {
		cin >> w[i] >> v[i];
	}
	int sumv = v[0];
	vector<vector<int> > dp(N,vector<int>(1e5+1,INF));
	dp[0][0] = 0, dp[0][v[0]] = w[0];
	for (int i = 1; i < N; ++i) {
		sumv += v[i];
		for (int j = 0; j <= sumv; ++j) {
			dp[i][j] = dp[i - 1][j];
			if(j >= v[i]) 
				dp[i][j] = min(dp[i][j], dp[i-1][j - v[i]] + w[i]);
		}
	}
	int ans = -1;
	for (int i = 0; i < dp[N-1].size(); ++i) {
		if (dp[N-1][i] > W) continue;
		ans = max(ans, i);
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 42800
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> ii;
typedef pair<int, int> pii;
const int M = 1e5+7;
const ll MAX = 1e15;
const ll MOD = 1e9+7;

ll dp[805][2005];

void solve() {
    int s;
    cin>>s;
    int n = s/3;dp[0][0] = 1;
    for(int i=1; i<=n; i++) {
            dp[i][0] = 1;
        for(int j=1; j<=s; j++) {
            dp[i][j] = (dp[i-1][j] + dp[i][j-1])%MOD;
        }
    }

    ll ans = 0;
    for(int i=1; i<=n; i++) {
        ans += dp[i][s-3*i];
        ans %= MOD;
    }
    cout<<ans;
}

int main() {
    ios::sync_with_stdio(0);
   // freopen("input.txt","r",stdin);
    if(0) {
        int t;
        cin>>t;
        for(int i=1; i<=t; i++) {
            solve();
            cout<<"\n";
        }
    } else solve();
    return 0;
}


Measured memory_bytes: 13976
#include <stdio.h>
#include <algorithm>
#define N 500
using namespace std;

int a[N + 5], p[N + 5], b[N * N + 5] = {0};

void write(int x)
{
	if(x < 10){
		putchar(x + 48);
		return;
	}
	write(x / 10);
	putchar(x % 10 + 48);
}

int cmp(int x, int y)
{
	return a[x] < a[y];
}

int next(int i)
{
	for(i++; b[i]; i++);
	return i;
}

int main()
{		
	int n, i, head = 1, j, x, t;
	
	scanf("%d", &n);
	for(i = 1; i <= n; i++){
		scanf("%d", a + i);
		p[i] = i;
	}
	sort(p + 1, p + n + 1, cmp);
	
	for(i = 1; i <= n; i++){
		x = p[i], t = a[x];
		for(j = 1; j < x; j++){
			if(head >= t){
				puts("No");
				return 0;
			}
			b[head] = x;
			head = next(head);
		}
		if(head == t) head = next(head);
		b[t] = x;
	}
	for(i = 1; i <= n; i++){
		x = p[i], t = a[x];
		for(j = x + 1; j <= n; j++){
			if(head > t) b[head] = x;
			else{
				puts("No");
				return 0;
			}
			head = next(head);
		}
	}
	puts("Yes");
	write(b[1]);
	for(i = 2, t = n * n; i <= t; i++){
		putchar(32), write(b[i]);
	}
	puts("");
			
	return 0;
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
using pll=pair<long long,long long>;
#define ITR(i,c) for(auto i=begin(c);i!=end(c);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##_len=(int)(n);i<i##_len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define REPW(i,n) for(i=0;i<(int)(n);++i)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)   // c++14
#define SZ(c) ((int)c.size())
#define EXIST(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,v) os << *i << (i==end(v)-1 ? "" : " "); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,v) is >> * i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
        is >> p.first >> p.second; return is; }
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
//------------------------------------------------------------------------------
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
    }
} before_main_function;
//------------------------------------------------------------------------------

inline void solve(int n) {
    vector<int> cnt(100010,0);
    REP(i,n) {
        int a,b;
        cin>>a>>b;
        cnt[a]++;
        cnt[b+1]--;
    }
    cnt[0]++;
    REP(i,100010) {
        cnt[i+1]+=cnt[i];
    }
    REPR(i,100010) {
        if(i<=cnt[i]) {
            cout<<i-1<<endl;
            return;
        }
    }
    cout<<0<<endl;
}
signed main() {
    int n;
    cin>>n;
    solve(n);
    return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include<math.h>
#include<iomanip>
using namespace std;

int main(int argc, const char * argv[]) {
    double x1, y1, x2, y2;
    double asw;
    double disx, disy;
    
    cin >> x1 >> y1 >> x2 >> y2;
    
    disx=x2-x1;
    disx=disx*disx;
    disy=y2-y1;
    disy=disy*disy;
    
    asw=sqrt(disx+disy);
    
    cout << fixed;
    cout << setprecision(10) << asw << endl;
    
    return 0;
}


Measured memory_bytes: 3300
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;

namespace AtCorders
{
	public class Program
	{
		static void Main(string[] args)
		{
			var hw = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
			int h = hw[0];
			int w = hw[1];
			var a = new int[h, w];
			for (int i = 0; i < h; i++) {
				var temp = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
				for (int j = 0; j < w; j++) {
					a[i, j] = temp[j];
				}
			}

			int count = 0;
			var sb = new StringBuilder();
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					if (i == h - 1 && j == w - 1) {
						continue;
					}

					if (a[i, j] % 2 == 1) {
						if (j == w - 1) {
							a[i, j] -=1;
							a[i + 1, j] += 1;
							sb.AppendLine($"{i + 1} {j + 1} {i + 2} {j + 1}");
						} else {
							a[i, j] -= 1;
							a[i, j + 1] += 1;
							sb.AppendLine($"{i + 1} {j + 1} {i + 1} {j + 2}");
						}

						++count;
					}
				}
			}

			Console.WriteLine(count);
			Console.Write(sb.ToString());
		}
	}
}

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

#define ll long long
#define pb push_back
#define debug1(x) cerr << #x << " = " << x << '\n';
#define debug2(x, y) cerr << #x << " = " << x << "   " << #y << " = " << y << "\n";
#define _ ios_base::sync_with_stdio(0);cin.tie(NULL);

void solve() {
    int n;
    cin >> n;
    int rem = n%1000;
    if(rem == 0) cout << rem;
    else cout << (1000 - rem);
}

int main() {_
    int t = 1;
    //cin >> t;
    //Please remember to uncomment for taking test cases
    for(int i = 1; i<=t; i++) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <complex>
#include <tuple>

#define FAST ios_base::sync_with_stdio(false); cin.tie(0)
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
// #define repr(i, a, b) for(int i=int(a); i>=int(b); i--)
#define reps(i,n) for(int i=1;i<=int(n);++i)
#define repr(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define reprs(i,x) for(int i=((int)(x));i>0;i--)
#define iceil(x,y) (x+y-1)/y
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define all(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define LF "\n"

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

using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef pair<int, PII> PP;


int main(){
	FAST;
	int a, b, x;
	cin >> a >> b >> x;

	float y = 2*(float)x/(float)(a*b);

	if (a>y) {
		float theta = atan2f((float)b, y) * 180.0 / (float)M_PI;
		cout << std::fixed << std::setprecision(12) << theta << LF;
		return 0;
	}
	else {
		float ydash = (float)b*2.0 - (float)x*2.0/((float)a*(float)a);
		float theta = atan2f(ydash, (float)a) * 180.0 / (float)M_PI;
		cout << std::fixed << std::setprecision(12) << theta << LF;
		return 0;
	}

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

        int[] a = new int[3];

        if (s.indexOf('a') == -1 ||
            s.indexOf('b') == -1 ||
            s.indexOf('c') == -1) {
            System.out.println("No");
        } else {
            System.out.println("Yes");
        }
    }
}


Measured memory_bytes: 23124
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <map>
#include <algorithm>
using namespace std;

int c[505],s[505],f[505];
int main()
{
    int n;
    cin >> n;
    for(int i = 0; i < n -1; i++){
        scanf("%d %d %d",&c[i],&s[i],&f[i]);
    }
    for(int i = 0; i < n - 1; i++){
        int now = 0;
        for(int j = i; j < n - 1; j++){
            if(now<s[j])
                now = s[j];
            while(now%f[j]){
                now++;
            }
            now += c[j];
        }
        cout << now << endl;
    }
    cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int cnt=0,i,N,K,h[100000]={};
	scanf("%d%d",&N,&K);
	for(i=0;i<N;++i){
		scanf("%d",&h[i]);
		if(h[i]>=K){
			++cnt;
		}
	}
	printf("%d\n",cnt);
}
//???

Measured memory_bytes: 512
#include "bits/stdc++.h"
#define pb push_back
#define ss second
#define ff first
#define all(x) x.begin(), x.end()
#define INF 300000000000001
#define ll_max 9000000000000000000
#define PI 3.14159265358979323846L
#define fill(a, n, x) for(int i = 0; i < n; i++) a[i] = x;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define db(args...) {string _ss = #args; replace(_ss.begin(), _ss.end(), ',' , ' '); stringstream ___s(_ss) ; debug(___s, args);}
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef long long int ll;
typedef long double ld;
typedef vector<pair<ll,ll> > vll;
typedef vector<int> vi;
typedef pair<ll,ll> pll;
ll mod = 1000000007;
const ll N = 300001;
const ll M = log2(N);

struct point
{
    ll x, y;
};

struct node
{
    ll t, p, d, i;
};

void debug(stringstream &s) {}
template <typename T, typename... Args>
void debug(stringstream &s, T a, Args... args)
{
    string word;
    s >> word;
    cerr << word << " = " << a << endl;
    debug(s, args...);
}

ll fast_exp(ll x, ll n)
{
    if(n == 0) return 1;
    if(n & 1) return fast_exp(x, n - 1) * x % mod;
    else
    {
        ll ans = fast_exp(x, n / 2);
        return ans * ans % mod;
    }
}

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    fast;
    int _ = 1;
    //cin >> _;
    int test = 0;
    while(_--)
    {
        test++;
        ll n, m, x = 0, y = 0, k, ans = 2;
        cin >> n;
        x = 8;
        for(int i = 400; i < 2100; i += 200)
        {
            if(n >= i)
                ans = x;
            x--;
        }
        cout << ans << "\n";
    }
    return 0;
}


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

int main() {
    int a,b,n,T,cas=0;
    cin>>n;
    long long x=0;
    for(int i=0;i<n;++i) {
        cin>>a;
        x+=(a-1);
    }
    cout<<x;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define rep(i,n) for(lli i=0;i<n;i++)
#define repb(i,n) for(lli i=n-1;i>=0;i--)
#define pb push_back
#define mp make_pair
#define bg() begin()
#define en() end()
#define ft first
#define sc second
#define vect_lli_it vector<lli>::iterator
#define set_lli_it set<lli>::iterator
#define inf 1e18
#define all(X) X.begin(),X.end()
#define iterate(X) for(it=X.begin();it!=X.end();it++)
lli combi(lli n,lli k)
{
    lli ans=1;
    k=k>n-k?n-k:k;
    lli j=1;
    for(;j<=k;j++,n--)
    {
        if(n%j==0)
        {
            ans*=n/j;
        }else
        if(ans%j==0)
        {
            ans=ans/j*n;
        }else
        {
            ans=(ans*n)/j;
        }
    }
    return ans;
}
lli gcd(lli a, lli b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
lli findlcm(vector <lli> arr, lli n)
{
    lli ans = arr[0];
    for (lli i = 1; i < n; i++)
        ans = (((arr[i] * ans)) /
                (gcd(arr[i], ans)));

    return ans;
}
lli power(lli x, lli y, lli p)
{
    lli res = 1;
    x = x % p;
    if (x == 0) return 0;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
lli gcdExtended(lli a, lli b, lli *x, lli *y);
lli modInverse(lli b, lli m)
{
    lli x, y;
    lli g = gcdExtended(b, m, &x, &y);
    if (g != 1)
        return -1;
    return (x%m + m) % m;
}
lli modDivide(lli a, lli b, lli m)
{
    a = a % m;
    lli inv = modInverse(b, m);
    return (inv * a) % m;
}
lli gcdExtended(lli a, lli b, lli *x, lli *y)
{
    if (a == 0)
    {
        *x = 0, *y = 1;
        return b;
    }
    lli x1, y1;
    lli gcd = gcdExtended(b%a, a, &x1, &y1);
    *x = y1 - (b/a) * x1;
    *y = x1;
    return gcd;
}
int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lli n;
    cin>>n;
    vector <lli> arr;
    map<lli,lli> mps;
    lli x;
    lli tot=0;
    rep(i,n){
    	cin>>x;
    	arr.pb(x);
    	mps[x]++;
    	tot+=x;
	}
	lli q;
	cin>>q;
	lli y;
	while(q--){
		cin>>x>>y;
		tot+=(-mps[x]*x+mps[x]*y);
		mps[y]+=mps[x];
		mps[x]=0;
		cout<<tot<<"\n";
	}
    return 0;
}


Measured memory_bytes: 10068