akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>

using namespace std;

int dfs(vector<vector<int>> & g, vector<bool> & b, int idx)
{
  	b[idx] = false;
	int cnt = 1;
	for (int i = 0, len = g[idx].size(); i < len; i++)
		if (b[g[idx][i]]) cnt += dfs(g, b, g[idx][i]);
	return cnt;
}

int main(void)
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  
  int n, m;
  cin >> n >> m;
  
  vector<vector<int>> g;
  g.resize(n);
  
  for (int i = 0, j, k; i < m; i++)
  {
	cin >> j >> k;
	g[j-1].push_back(k-1);
	g[k-1].push_back(j-1);
  }
  
  vector<bool> b;
  b.resize(n);
  for (int i = 0; i < n; i++) b[i] = true; 

  int max = 0, cnt;
  for (int i = 0; i < n; i++)
	if (b[i])
	{
		cnt = dfs(g, b, i);
		max = max < cnt ? cnt : max;
	}

  cout << max;
  
  return 0;
}


Measured memory_bytes: 26264
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;

const int MAX_V = 100;
const ll INF = (1LL << 32);

int v, e;
long long D[MAX_V][MAX_V];

void warshallFloyd(void) {
    for (int k = 0; k < v; k++) {
        for (int i = 0; i < v; i++) {
            if (D[i][k] == INF) continue;
            for (int j = 0; j < v; j++) {
                if (D[k][j] == INF) continue;
                D[i][j] = min(D[i][j], D[i][k]+D[k][j]);
            }
        }
    }
}

int main(void) {
    cin >> v >> e;
    for (int i = 0; i < v; i++) {
        for (int j = 0; j < v; j++) {
            if (i != j) {
                D[i][j] = INF;
            } else {
                D[i][j] = 0;
            }
        }
    }

    int s, t, d;
    for (int i = 0; i < e; i++) {
        cin >> s >> t >> d;
        D[s][t] = d;
    }

    warshallFloyd();

    bool neg = false;
    for (int i = 0; i < v; i++) {
        if (D[i][i] < 0) neg = true;
    }

    if (neg) {
        cout << "NEGATIVE CYCLE" << endl;
    } else {
        for (int i = 0; i < v; i++) {
            for (int j = 0; j < v; j++) {
                if (j) cout << " ";
                if (D[i][j] == INF) cout << "INF";
                else cout << D[i][j];
            }
            cout << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 1232
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second
#define mp make_pair
 
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1ll << 60;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N, A, B, C;
string S[int(1e5+5)];
char ans[int(1e5+5)];

int main(){
  cin >> N >> A >> B >> C;
  for (int i = 0; i < N; i++) cin >> S[i];


  for (int i = 0; i < N; i++){
    if (S[i] == "AB" && A == 0 && B == 0){
      No(); return 0;
    }
    if (S[i] == "BC" && B == 0 && C == 0){
      No(); return 0;
    }
    if (S[i] == "AC" && C == 0 && A == 0){
      No(); return 0;
    }

    if (S[i] == "AB"){
      if (A > 1 || B > 1){
        if (A > B) ans[i] = 'B', A--, B++;
        else ans[i] = 'A', A++, B--;
        continue;
      }
      if (A == 0 || B == 0){
        if (A == 0) ans[i] = 'A', A++, B--;
        else ans[i] = 'B', A--, B++;
        continue;
      }
      if (S[i + 1] == "AB" || S[i + 1] == "BC") ans[i] = 'B', A--, B++;
      else ans[i] = 'A', A++, B--;
    }

    if (S[i] == "BC"){
      if (B > 1 || C > 1){
        if (B > C) ans[i] = 'C', C++, B--;
        else ans[i] = 'B', B++, C--;
        continue;
      }
      if (B == 0 || C == 0){
        if (B == 0) ans[i] = 'B', B++, C--;
        else ans[i] = 'C', C++, B--;
        continue;
      }
      if (S[i + 1] == "BC" || S[i + 1] == "AC") ans[i] = 'C', C++, B--;
      else ans[i] = 'B', B++, C--;
    }

    if (S[i] == "AC"){
      if (A > 1 || C > 1){
        if (A > C) ans[i] = 'C', C++, A--;
        else ans[i] = 'A', A++, C--;
        continue; 
      }
      if (A == 0 || C == 0){
        if (A == 0) ans[i] = 'A', A++, C--;
        else ans[i] = 'C', C++, A--;
        continue;
      }
      if (S[i + 1] == "AC" || S[i + 1] == "AB") ans[i] = 'A', A++, C--;
      else ans[i] = 'C', C++, A--;
    }
  }
  
  Yes();
  for (int i = 0; i < N; i++) cout << ans[i] << endl;
  
  return 0;
}


Measured memory_bytes: 6868
#include <bits/stdc++.h>
#define all(v) (v).begin(),(v).end()
using namespace std;
using LL = long long;
const int INF = 1e9;

int main(void)
{
    int X;
    cin >> X;

    int a, b;
    a = X / 100;
    b = X % 100;
    if (5*a >= b) {
        cout << 1 << endl;
    } else {
        cout << 0 << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define dbug(x) cout<<#x<<"="<<x<<endl
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while ('0'>ch||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do {(t*=10)+=ch-'0';ch=getchar();} while ('0'<=ch&&ch<='9'); t*=f;
}
typedef long long ll;
const double INF=(1e20);
const int maxn=(1e5)+10;
int n; char s[10];
int id[300],a[maxn];
int x[maxn],y[maxn];
double xmx,xmn,ymx,ymn;
int fx[4][2]={{1,0},{-1,0},{0,1},{0,-1}};
double solve(double mid) {
	xmx=ymx=-INF; xmn=ymn=INF;
	double A,B;
	for (int i=1;i<=n;i++) {
		A=x[i],B=y[i];
		if (a[i]==0) A+=mid;
		else if (a[i]==1) A-=mid;
		else if (a[i]==2) B+=mid;
		else B-=mid;
		xmx=max(xmx,A);
		xmn=min(xmn,A);
		ymx=max(ymx,B);
		ymn=min(ymn,B);
	//	printf("%.2lf %.2lf\n",A,B);
	}
	return (xmx-xmn)*(ymx-ymn);
}
int main() {
	//freopen("1.txt","r",stdin);
	read(n);
	id['R']=0; id['L']=1;
	id['U']=2; id['D']=3;
	for (int i=1;i<=n;i++) {
		read(x[i]),read(y[i]);
		scanf("%s",s+1);
		a[i]=id[s[1]];
	}
	long double l=0,r=(1e10),m1,m2,len;
	for (int i=1;i<=1000;i++) {
		len=(r-l)/3;
		m1=l+len; m2=l+len+len;
		if (solve(m1)<solve(m2)) r=m2;
		else l=m1;
	}
	printf("%.11lf\n",solve(l));
	return 0;
}

Measured memory_bytes: 1408
#coding:utf-8
N = int(input())
trees = [list(input().split()) for i in range(N)]

class BinaryTree:
    def __init__(self,key,p=None,l=None,r=None):
        self.key = key
        self.p = p
        self.l = l
        self.r = r

def Insert(root,z):
    y = None
    x = root
    while x != None:
        y = x
        if z.key < x.key:
            x = x.l
        else:
            x = x.r
    z.p = y

    if y == None:
        root = z
    elif z.key < y.key:
        y.l = z
    else:
        y.r = z
    return root

def preOrder(x):
    if x == None:
        return
    global preList
    preList.append(x.key)
    
    preOrder(x.l)
    preOrder(x.r)

def inOrder(x):
    if x == None:
        return
    inOrder(x.l)

    global inList
    inList.append(x.key)
    
    inOrder(x.r)

def Find(x,target):
    while x != None:
        y = x
        if target < x.key:
            x = x.l
        elif target > x.key:
            x = x.r
        else:
            print("yes")
            return
    print("no")

root = None
for data in trees:
    if data[0] == "insert":
        z = BinaryTree(int(data[1]))
        root = Insert(root,z)
    if data[0] == "find":
        Find(root, int(data[1]))
      
    if data[0] == "print":
        inList = []
        preList = []
        inOrder(root)
        a = " " + " ".join([str(num) for num in inList])
        print(a)

        preOrder(root)
        a = " " + " ".join([str(num) for num in preList])
        print(a)




Measured memory_bytes: 237452
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define req(i,n) for(long long i=n-1; i>=0; i--)
#define range(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define onBoard(y,x) (y>=0 && y<h && x>=0 && x<w)
#define pri_que priority_queue
#define vint vector<int>
#define vvint vector<vector<int>>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vs vector<string>
#define vvc vector<vector<char>>
#define vc vector<char>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define show(x) cout<<#x<<"="<<x<<endl;
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a/gcd(a,b)*b;}
const long long dx[8]={1,0,-1,0,1,-1,-1,1};
const long long dy[8]={0,1,0,-1,1,1,-1,-1};
const long long INF = 1e15;
const long long MOD = 1e9+7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    int n,k; cin >> n>>k;
    vint a(n);
    rep(i,n) cin>>a[i];

    int res=INF;

    for(int i=0; i+k<n+1; i++){
        int r=a[i],l=a[i+k-1];
        chmin(res,min(abs(r)+abs(r-l),abs(l)+abs(r-l)));
    }   
    cout<<res<<endl;
}

Measured memory_bytes: 4000
#!/usr/bin/env python3

import sys
sys.setrecursionlimit(300000)


def solve(N: int, K: int, p: "List[int]"):
    q = [(1 + v) / 2 for v in p]
    ret = 0
    s = sum(q[:K])
    l = 0
    for i in range(0, N - K):
        tmp = s - l
        ret = max(ret, tmp)
        l += q[i]
        s += q[i + K]
    ret = max(ret, s - l)
    print(ret)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    p = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, p)

if __name__ == '__main__':
    main()


Measured memory_bytes: 32524
const stdin = require('fs').readFileSync('/dev/stdin', 'utf8').trim()

const [n, d] = stdin
  .split('\n')[0]
  .split(' ')
  .map(Number)

const [, ...x] = stdin.split('\n').map(e => e.split(' ').map(Number))

const ans = () => {
  let count = 0
  for (let i = 0; i < n; i++) {
    for (let j = i + 1; j < n; j++) {
      const p1 = x[i]
      const p2 = x[j]

      const dist = calc(p1, p2)

      if (Number.isInteger(dist)) {
        count++
      }
    }
  }

  console.log(count)
}

const calc = (p1, p2) => {
  let sum = 0
  for (let i = 0; i < d; i++) {
    const yz = p1[i] - p2[i]
    sum += yz ** 2
  }

  return Math.sqrt(sum)
}

ans()


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

namespace Grading
{
    class Program
    {
        static void Main(string[] args)
        {
            String str;
            while ((str = Console.ReadLine()) != "-1 -1 -1")
            {
                var input = str.Split(' ');
                int between = int.Parse(input[0]);
                int last = int.Parse(input[1]);
                int again = int.Parse(input[2]);
                if (last < 0 || between < 0)
                {
                    Console.WriteLine("F");
                    continue;
                }
                if (between + last >= 80) Console.WriteLine("A");
                else if (between + last >= 65) Console.WriteLine("B");
                else if ((between + last >= 50) || (between + last >= 30 && again >= 50)) Console.WriteLine("C");
                else if (between + last >= 30) Console.WriteLine("D");
                else Console.WriteLine("F");
            }
        }
    }
}


Measured memory_bytes: 8896
#include <stdio.h>

int main() {
  int r, g, b;
  scanf("%d %d %d", &r, &g, &b);
  if ((100 * r + 10 * g + b) % 4 == 0) {
    printf("YES\n");
  } else {
    printf("NO\n");
  }

  return 0;
}


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

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

#define IOS ios::sync_with_stdio(false), cin.tie(nullptr)
#define FOR(i, a, b) for (int i = (a); i < (int)(b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greater<int>()
#define MAX(a) *max_element(all(a))

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vc = vector<char>;
using vs = vector<string>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vvi;

const int INF = 1001001001;
const int MOD = 1000000007;
const long long INFL = (1LL << 60);
const double EPS = 1e-9;

ll a[100010][3], dp[100010][3];

int main() {
  IOS;
  constexpr char endl = '\n';
  int N;
  cin >> N;
  rep(i, N) rep(j, 3) cin >> a[i][j];

  rep(i, N) rep(j, 3) rep(k, 3) {
    if (j == k) continue;
    chmax(dp[i + 1][k], dp[i][j] + a[i][k]);
  }

  cout << max({dp[N][0], dp[N][1], dp[N][2]}) << endl;
}

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

using namespace std;

#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n)　for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erace(unique(all(v)),v.end())
#define pvec(v)　rep(i,v.size()){cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sezeof(m))
#define mod 1e9 +7;

const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll,ll> P;
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

ll lcm(ll x,ll y)
{
    x /= gcd(x,y);
    y /= gcd(x,y);
    return (x*y);
}

int main()
{
    string s;
    ll f,e;
    cin >> s;
    rep(i,SIZE(s)){
        if(s[i] == 'A'){
            f=i;
            break;
        }
    }
    repr(i,SIZE(s)){
        if(s[i] == 'Z'){
            e=i;
            break;
        }
    }
    //cout << f << endl << e << endl;
    cout << e-f+1 << endl;
    return 0;
}

Measured memory_bytes: 640
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] c = sc.next().toCharArray();
		sc.close();

		int cnt = 0;
		int max = 0;
		for (int i = 0; i < 3; i++) {
			if (c[i] == 'R') {
				cnt++;
			} else {
				max = Math.max(max, cnt);
				cnt = 0;
			}
		}
		max = Math.max(max, cnt);

		System.out.println(max);
	}
}


Measured memory_bytes: 35504
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>
#include <tuple>
#include <cmath>
using namespace std;
typedef long long ll;
//typedef pair<ll, ll> P;

#define rep(i, m) for(ll i=0;i<(m);i++)
#define rep1(i, m) for(ll i=1;i<=(m);i++)
#define FOR(i, a, b) for(ll i=(a);i<(b);i++)
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int p[100010];
int main() {
   int N; cin >> N;
   int q = 0;
   int cnt = 0;
   rep1(i, N) {
      cin >> p[i];
      if (p[i] == i) {
         q++;
      } else if (q > 0) {
         cnt += (q+1)/2;
         q=0;
      }
   }
   cnt += (q+1)/2;
   cout << cnt << endl;
}

Measured memory_bytes: 640
def ninebank(val):
    left = val
    ret = 0
    div = 9 ** 5
    while div > 0:
        ret += left // div
        left = left % div
        div = div // 9
    return ret


def sixbank(val):
    left = val
    ret = 0
    div = 6 ** 10
    while div > 0:
        ret += left // div
        left = left % div
        div = div // 6
    return ret


n = int(input())
ret = 10 ** 10
for i in range(n+1):
    x = ninebank(i)
    y = sixbank(n - i)
    ret = min(ret, x + y)
print(ret)


Measured memory_bytes: 3064
import numpy as np

if __name__ == "__main__":
	n,t = map(int,raw_input().split())
	li = map(int,raw_input().split())

	minv = li[0]
	dm = 0
	ans = 1
	for i in range(1, len(li)):
		minv = min(minv, li[i])
		if(dm == li[i] - minv):
			ans += 1
		elif(dm < li[i]-minv):
			dm = li[i] - minv
			ans = 1

	print ans

Measured memory_bytes: 19240
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=n;i<N;i++)
#define p(S) cout<<(S)<<endl
#define ck(a,b) (0<=(a)&&(a)<(b))

using namespace std;

int main(){
	int n;
	while(cin>>n,n){
		int A[1001];
		int ans=1000100;
		REP(i,0,n) cin>>A[i];
		sort(A,A+n);
		REP(i,1,n)	ans=min(ans,abs(A[i]-A[i-1]));
		p(ans);
	}
	return 0;
}

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

int main() {
	string s;
	cin>>s;
	int n=s.size(),sum=0,ma=0;
	for(int i=0; i<n; i++) {
		if(s[i]=='A'||s[i]=='T'||s[i]=='G'||s[i]=='C') {
			sum++;
		} else {
			if(sum>ma) {
				ma=sum;
			}
			sum=0;
		}
	}
	if(sum>ma) {
		ma=sum;
	}
	cout<<ma<<endl;
	return 0;
}

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

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

    int ans = s.size();
    for(int i=0;i<s.size()-1;++i){
        if(s[i] == s[i+1])continue;
        ans = min(ans, max(i+1, (int)s.size()-i-1));
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main{
  public static void main(String args[]){
    Scanner sc =new Scanner(System.in);
    char[] a = sc.next().toCharArray();
    char[] b = sc.next().toCharArray();
    int ans = 0;
    for(int i = 0;i < 3;i++){
      if(a[i] == b[i]) ans++;
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 23124
#include <algorithm>
#include <iostream>
#include <utility>
#include <vector>
#include <stack>
#include <map>

using namespace std;

using ll = long long;
vector<int> first_exceeder(vector<int> &a) {
  // exceeder[i]: iより右側で a[i]を最初に超えるaのインデックス
  int N = a.size();
  vector<int> exceeder(N);
  stack<int> stk; //番長順番待ちキュー
  for (int i = 0; i < N; ++i) {
      // iが入学
      while (!stk.empty()) {
        int righttail = stk.top();
        if (a[righttail] < a[i]) {
          exceeder[righttail] = i; //順番待ちキューのセンパイが自分より弱い場合，センパイに自分の名前を告げて引導を渡す
          stk.pop();
          continue;
        }
        break;
      }
      stk.push(i);  // 自分がキューに並ぶ
  }

  // 自分より強い後輩が入ってこなかったメンバーはキューに残ったままなので右端をexceederにする
  while (!stk.empty()) {
    int i = stk.top(); stk.pop();
    exceeder[i] = N;
  }
  return exceeder;
}

int main() {
  int n;
  cin >> n;
  vector<int> la(n), lb(n), lc(n);
  for (int i = 0; i < n; ++i) {
    cin >> la[i];
    lb[i] = -la[i];
    lc[n-1-i] = -la[i];
  }
  ll ans = 0;
  vector<int> lright = first_exceeder(lb);
  vector<int> lleft = first_exceeder(lc);
  for (int i = 0; i < n; ++i) {
    ll left = n-lleft[n-1-i];
    ll right = lright[i];
    ans += (right-i)*(i-left+1)*(ll)la[i];
    // cerr << i << " " << la[i] << " " << left << " " << right << endl;
  }
  cout << ans << endl;
  return 0;
}


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

int lcs(string x, string y) {
    x = ' ' + x;
    y = ' ' + y;
    int m = x.length();
    int n = y.length();
    int memo[m][n];
    rep(i, m) memo[i][0] = 0;
    rep(i, n) memo[0][i] = 0;
    for(int i = 1; i < m; i++) {
        for(int j = 1; j < n; j++) {
            if(x[i] == y[j]) {
                memo[i][j] = memo[i - 1][j - 1] + 1;
            } else {
                memo[i][j] = max(memo[i - 1][j], memo[i][j - 1]);
            }
        }
    }

    return memo[m-1][n-1];
}

int main() {
    // 制約見て！！！デカかったらlong longにすること！
    int q;
    string x, y;
    cin >> q;
    rep(i, q) {
        cin >> x >> y;
        cout << lcs(x, y) << endl;
    }
}


Measured memory_bytes: 7068
use std::io::{stdin, Read};

fn main() {
    let mut nk = String::new();
    let mut arr = String::new();
    stdin().read_line(&mut nk);
    stdin().read_line(&mut arr);
    let nk: Vec<i32> = nk.trim().split_whitespace().map(|it| it.parse().unwrap()).collect();
    let arr: Vec<i32> = arr.trim().split_whitespace().map(|it| it.parse().unwrap()).collect();
    let mut n = nk[0];
    let k = nk[1];
    let mut result = 0;

    while n > 0 {
        n -= k;
        if n > 0 {
            n += 1;
        }
        result += 1;
    }
    println!("{}", result);
//    let mut minimum = (n, n + 1);
//    for (i, &v) in arr.iter().enumerate() {
//        if v < minimum.1 {
//            minimum = (i as i32, v);
//        }
//    }
//    let minimum = minimum.0;
//
//    fn doit (n :i32, k: i32, l: i32, r: i32) -> i32 {
//        if l < 0 && r >= n {
//            return 0;
//        }
//        return if l > 0 {1} else {0} + if r < n {1} else {0} + doit(n, k, l - k + 1, r + k - 1)
//    }
//
//    println!("{}", 1 + doit(n, k, minimum - 2, minimum)
//        .min(doit(n, k, minimum - 1, minimum + 1))
//        .min(doit(n, k, minimum, minimum + 2)));
//    println!("{}",
////             if minimum - k >= 0 || minimum + k >= n {
////                 1 + minimum / (k - 1) + (n - minimum) / (k - 1)
////             } else {
//             n / (k - 1)
////             }
//    );
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, a;
  string b;
  cin >> n, a;
  for (int i = 0; i < n; i++) {
    cin >> b;
    if (b == "Y") {
      cout << "Four" << endl;
      break;
    }
    else if (i == n-1) {
      cout << "Three" << endl;
      break;
    }
  }
}

Measured memory_bytes: 256
fn main() {
    let v = read_vec::<usize>();
    let h = v[0];
    let w = v[1];

    let mut r = vec![];
    let mut ansr = vec![vec![0u32; w]; h];

    for _ in 0..h {
        r.push(read::<String>().chars().collect::<Vec<_>>());
    }

    for i in 0..h {
        let mut count  = 0;
        let mut last_j = 0;

        for j in 0..w {
            if r[i][j] == '.' {
                count += 1;
            } else if r[i][j] == '#' {
                for k in last_j..j {
                    ansr[i][k] += count;
                }
                count = 0;
                last_j = j+1;
            }
        }
        for k in last_j..w {
            ansr[i][k] += count;
        }
    }

    //println!("{:?}", ansr);

    for j in 0..w {
        let mut count = 0;
        let mut last_i = 0;

        for i in 0..h {
            if r[i][j] == '.' {
                count += 1;
            } else if r[i][j] == '#' {
                for k in last_i..i {
                    ansr[k][j] += count;
                }
                count = 0;
                last_i = i+1;
            }
        }
        for k in last_i..h {
            ansr[k][j] += count;
        }
    }

    //println!("{:?}", ansr);
    let mut a = 0;
    for i in  0..h  {
        for j in  0..w {
            a = std::cmp::max(a, ansr[i][j]);
        }
    }
    println!("{}", a-1);
}

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 37116
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>
#include <cstdint>



#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rrep(i, n) for(ll i = (ll)(n-1); i >= 0; i--)
#define repi(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rrepi(i,a,b) for(ll i=(ll)(b);i>=(ll)(a);i--)

#define all(x) (x).begin(),(x).end()

template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

typedef long long ll;

using namespace std;


template <std::uint_fast64_t Modulus> class modint {
  using u64 = std::uint_fast64_t;

public:
  u64 a;

  modint(const u64 x = 0) noexcept : a(x % Modulus) {}
  u64 &value() noexcept { return a; }
  u64 &value() const noexcept { return a; }
  modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  modint &operator/=(modint rhs) noexcept {
    u64 exp = Modulus - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
  modint pow(u64 exp){
    modint res=1,rhs=*this;
    while (exp) {
      if (exp % 2) {
        res *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return res;
  }

  friend ostream& operator<<(ostream& os,modint& rhs){
    os << rhs.value();
    return os;
  }

  friend istream& operator>>(istream &is,modint &rhs){
      is>>rhs.value();
      rhs.value()%=Modulus;
      return is;
  }

};
using mint=modint<(ll)1e9+7>;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;cin>>n;
  string s;cin>>s;
  rep(i,2*n){
    if(i%2==0)continue;
    if(s[i]=='B')s[i]='W';
    else s[i]='B';
  }
  mint res=1;
  ll d=0;
  rep(i,2*n){
    if(s[i]=='B'){
      d++;
    }
    else {
      res*=d;
      d--;
    }
  }
  if(d!=0)res=0;
  rep(i,n)res*=i+1;
  cout<<res<<endl;


  return 0;

}


Measured memory_bytes: 720
#define _GLIBCXX_DEBUG    //空コンテナ操作禁止　Clang環境では#define _LIBCPP_DEBUG 0
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
using namespace std;
using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

int main(){
  ll N;
  cin >> N;
  vector<ll> A(N+1), B(N);
  for( int i=0; i<N+1; i++ ) cin >> A.at(i);
  for( int i=0; i<N; i++ ) cin >> B.at(i);
  
  ll monster = A.at(0), slay = 0, reserve = 0;
  for( int i=0; i<N; i++ ){
    if( monster >= B.at(i) ){
      slay += B.at(i);
      reserve = 0;
    }else{
      slay += monster;
      reserve = B.at(i) - monster;
    }
    if( A.at(i+1) > reserve ){
      slay += reserve;
      monster = A.at(i+1) - reserve;
    }else{
      slay += A.at(i+1);
      monster = 0;
    }
  }
  
  cout << slay << endl;
  return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include<math.h>
#define N 100005
#define K 200005
#define MOD (int)1e9+7
#define ll long long int
using namespace std;
ll max(ll a,ll b)
{
    return a>b? a:b;
}
int main() {
    int n;
    cin>>n;
    vector<ll> a(n);
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    ll dp[n+1][n+1];
    
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            dp[i][j]=0;
        }
    }
    for(int l=n-1;l>=0;l-- )
    {

        for(int r=l;r<n;r++)
        {
            if(l==r)
            {
                dp[l][r]=a[l];
            }
            else
            {
            dp[l][r]=max(a[l]-dp[l+1][r],a[r]-dp[l][r-1]);
            }
        }
    }
    cout<<dp[0][n-1]<<endl;
}

Measured memory_bytes: 70656
#include<iostream>
#include<vector>

long long gcd(long long x, long long y);

int main(){
	int n;
	long long lcm;
	std::vector<long long> aList;		

	std::cin>>n;
	aList.resize(n);

	for(int i=0; i<n; i++)
		std::cin>>aList[i];

	lcm= aList[0];

	for(int i=1; i<n; i++){
		long long tmp= gcd(lcm, aList[i]);
		lcm= lcm/tmp;
		lcm= lcm*aList[i];
	}

	std::cout<<lcm<<std::endl;

	return 0;
}

long long gcd(long long x, long long y){
	if(x==0)
		return y;

	long long x_, y_;

	if(x< y)
		x_= y, y_= x;
	else
		x_=x, y_= y;

	return gcd(x_%y_, y_);
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#define maxn 1000000007
using namespace std;
long long int n;
int main()
{
    while(scanf("%lld",&n)!=EOF)
    {
        long long int flag=1;
        for(int i=1;i<=n;i++)
        {
            flag=(flag*i)%maxn;
        }
        printf("%lld\n",flag);
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
const int N=100010;
bool cmp(int a,int b){return a>b;}
int s[N],n;
bool check()
{
	int ind=1,dnd;
	while(s[ind+1]>=ind+1 && ind<n)ind++;
//	printf("ind = %d\n",ind);
	if(ind==n)return (s[ind]-ind)&1;

	for(dnd=ind;dnd<n && s[dnd+1]==ind;dnd++);

	return ((s[ind]-ind)&1) || ((dnd-ind)&1);
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",s+i);
	std::sort(s+1,s+n+1,cmp);
	printf("%s\n",check()?"First":"Second");
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 1e18;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, a, b) for (int i = b - 1; i >= a; i--)
#define int ll
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

signed main() {
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    int ans = min({a * x + b * y, max(x, y) * c * 2, min(x, y) * c * 2 + (x - min(x, y)) * a + (y - min(x, y)) * b});
    cout << ans << "\n";
}

Measured memory_bytes: 3596
#define _CRT_SECURE_NO_WARNINGS
#define REL

#pragma GCC target ("avx2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <iomanip>
#include <cstdio>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <string>
#include <set>
#include <bitset>
#include <cstdint>
#include <cstring>
#include <cassert>
#include <complex>
#include <stack> 
#include <random>

using namespace std;

typedef int64_t i64;
typedef long long LL;
typedef long long ll;
typedef long double LD;
typedef complex <LD> cld;
typedef unsigned int uint;
typedef complex <double> cd;
typedef unsigned long long ULL;

#define endl "\n"
#define dendl "\n\n"
#define mp make_pair
#define mt make_tuple
#define size(v) (int)v.size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

/////////////////////////////////////////////////////////////////////

template <typename T>
T sqr(T a) {
	return a * a;
}

template <typename T>
int sign(T a) {
	if (a == 0)
		return 0;
	return (a > 0 ? 1 : -1);
}

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

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

template <typename T1, typename T2>
istream& operator >> (istream& in, pair<T1, T2>& p) {
	in >> p.first >> p.second;
	return in;
}

template <typename T1, typename T2>
ostream& operator << (ostream& out, pair<T1, T2>& p) {
	out << p.first << ' ' << p.second;
	return out;
}

mt19937_64 rnd(0);

const int LOG = 30;
const int N = (int)3e5 + 7;
const int MAXN = (int)3e6 + 7;
const int MOD = (int)998244353;
const int INF = (int)1e9 + 7;
const int CONST = 450;
const LL LINF = (i64)1e17;
const LD PI = 3.1415926535897932384626433832795;
const LD EPS = 1;

/////////////////////////////////////////////////////////////////////

void solve() {
	LL a, b, n;
	cin >> a >> b >> n;
	LL y = min(n, b - 1);
	cout << a * y / b;
}

int main() {
	double start = clock();
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	cout << fixed << setprecision(20);
	cerr << fixed << setprecision(20);
#else
	cout << fixed << setprecision(20);
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	rnd.seed(time(0));
#endif

	int t = 1;
	for (int i = 0; i < t; i++) {
		solve();
	}

#ifdef _DEBUG
	cout << endl << "Time is " << (clock() - start) / 1000.0;
#endif
}

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

int main()
{
  int n;
  cin >> n;
  int arr[n];
  for(int i = 0; i < n; i++) cin >> arr[i];
  int cnt = 1;
  int mn = arr[0];
  for ( int i = 1; i < n; i++){
    if (arr[i] <= mn){
      cnt++;
      mn = arr[i];}
  }
  cout << cnt;
  return 0;

}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int main()
{
    string A, B, C;
    cin >> A >> B >> C;
    
    string next;
    next.push_back( A[ 0 ] );
    
    int a{}, b{}, c{};
    while( true )
    {
        if( next == "a" )
        {
            if( A.empty() )
            {
                cout << "A" << endl;
                break;
            }
            next = *A.begin();
            A.erase( A.begin() );
            a++;
        }
        if( next == "b" )
        {
            if( B.empty() )
            {
                cout << "B" << endl;
                break;
            }
            next = *B.begin();
            B.erase( B.begin() );
            b++;
        }
        if( next == "c" )
        {
            if( C.empty() )
            {
                cout << "C" << endl;
                break;
            }
            next = *C.begin();
            C.erase( C.begin() );
            c++;
        }
    }
    return 0;
}


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

int main(void){
	int A, B;
	cin >> A >> B;

	if(A>=13){
		cout << B << endl;
	}
	else if(A>5){
		cout << B/2 << endl;
	}
	else{
		cout << 0 << endl;
	}
}



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

using namespace std;

int main(){
  string s;
  cin >> s;
  if(s[0]==s[1] || s[1]==s[2] || s[2]==s[3]){
    cout << "Bad" << endl;
  }
  else {
    cout << "Good" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
using namespace std;
const int nmax=3005;
const long long mod=1000*1000*1000+7;
long long dp[nmax][nmax],lzy[nmax][nmax],old[nmax][nmax];
int a[nmax],X[nmax],Y[nmax];
long long inv2,I2,ans,p2;
int n,i,j,q,x,y;
long long mu(long long x,long long y)
{
    return (1LL*x*y)%mod;
}
int main()
{
    //freopen("data.in","r",stdin);
    cin>>n>>q;
    for(i=1;i<=n;i++)
        cin>>a[i];
    for(i=1;i<=n;i++)
        for(j=i+1;j<=n;j++)
           dp[i][j]=1;
    for(i=1;i<=n;i++)
        for(j=1;j<=n;j++)
          lzy[i][j]=1;
    inv2=(mod+1)/2;I2=inv2;
    p2=1;
    for(i=1;i<=q;i++)
        cin>>X[i]>>Y[i];
    for(int cnt=q;cnt>=1;cnt--)
    {
        x=X[cnt];y=Y[cnt];
        for(i=1;i<=n;i++)
        {
            old[i][x]=(dp[i][x]*mu(lzy[i][x],p2))%mod;
            old[x][i]=(dp[x][i]*mu(lzy[x][i],p2))%mod;
            old[i][y]=(dp[i][y]*mu(lzy[i][y],p2))%mod;;
            old[y][i]=(dp[y][i]*mu(lzy[y][i],p2))%mod;
        }
        for(i=1;i<=n;i++)
        {
            lzy[i][x]=I2;
            lzy[x][i]=I2;
            lzy[i][y]=I2;
            lzy[y][i]=I2;
        }
        lzy[x][x]=lzy[y][y]=0;
        for(i=1;i<=n;i++)
        {
            dp[i][x]=(old[i][y]+old[i][x])%mod;
            dp[i][y]=(old[i][x]+old[i][y])%mod;
            dp[x][i]=(old[y][i]+old[x][i])%mod;
            dp[y][i]=(old[x][i]+old[y][i])%mod;
        }
        dp[x][y]=(old[x][y]+old[y][x])%mod;
        dp[y][x]=(old[x][y]+old[y][x])%mod;
        dp[x][x]=dp[y][y]=0;
        p2=(p2+p2)%mod;
        I2=(I2*inv2)%mod;
    }
    for(i=1;i<=n;i++)
        for(j=1;j<=n;j++)
          if(a[i]>a[j])
    {
        ans+=((1LL*(dp[i][j]*p2)%mod)*lzy[i][j])%mod;
        ans%=mod;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 212348
import sys
input = sys.stdin.readline
import numpy as np
from scipy.sparse.csgraph import floyd_warshall

n,m,l=map(int,input().split())
ans=[[0]*n for i in range(n)]
for i in range(m):
    a,b,c=[int(j) for j in input().split()]
    ans[a-1][b-1]=c
    ans[b-1][a-1]=c
q=int(input())
st=[]
for i in range(q):
    st.append([int(j)-1 for j in input().split()])

ans=floyd_warshall(ans)

for i in range(n):
    for j in range(n):
        if ans[i][j]<=l:
            ans[i][j]=1
        else:
            ans[i][j]=0

ans=floyd_warshall(ans)

for i,j in st:
    if ans[i][j]==float("inf"):
        print(-1)
    else:
        print(int(ans[i][j])-1)



Measured memory_bytes: 29012
#include<iostream>
#include<vector>
#include<string>
#include<stack>
#include<queue>
using namespace std;

int bubbleSort(vector<int>& nums){
	int n = nums.size();
	int cnt = 0;
	for(int i = 0; i < n; i++){
		int j = n-1;
		while(j > i){
			if(nums[j] < nums[j-1]){
				 swap(nums[j], nums[j-1]);
				 cnt++;
			}
			j--;
		}		
	}
	return cnt;
}

int main(){
	int n;
	cin >> n;
	vector<int> nums(n);
	for(int i = 0; i < n; i++){
		cin >> nums[i];
	}
	int swapCnt = bubbleSort(nums);
	for(int i = 0; i < n; i++){
		if(i) cout << " " << nums[i];
		else cout << nums[i];
	}
	cout << endl;
	cout << swapCnt << endl;
	return 0;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()

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

int main() {
    int K, X;
    cin >> K >> X;
    FOR(i, X-K+1, X+K) {
        cout << i << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
//Bismillah hirrahmanir Rahim
        #include<bits/stdc++.h>
        #define ll long long
        #define pb push_back
        #define dbug printf("I am here\n");
        #define Fast ios_base::sync_with_stdio(false); cin.tie(0);
        const int m = 10e6;
        using namespace std;

        int main(){
         long long int a,b,tst,n,k;
         map<int ,int>mp;
         cin>>n>>k;
         while(k--){
         cin>>tst;
         for(int i=0;i<tst;i++){
                cin>>b;
            mp[b]++;
         }

         }
         int cnt=0;
         for(int i=1;i<=n;i++){
            if(mp[i]==0)cnt++;
         }
         cout<<cnt<<endl;
           return 0;

        }


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
using namespace std;
int main(){

  int p,q,use;
  int so[40000]={0};

  cin>>p>>q;
  use=q;
  int a;
  while(q%p){
    a=q%p;
    q=p;
    p=a;
  }
  use/=p;
  vector <int> sonaka;
  for(int i=2;i<40000;i++) if(!so[i]){
      sonaka.push_back(i);
      for(int j=i*2;j<40000;j+=i) so[j]=1;
    }
  int result=1;
  for(int i=0;sonaka[i]<=use&&i<sonaka.size();i++) if(use%sonaka[i]==0){
      result*=sonaka[i];
      while(use%sonaka[i]==0) use/=sonaka[i];
  }
  cout<<result*use<<endl;
  return 0;
}

Measured memory_bytes: 3320
n=int(input())
a=[int(input())-1 for _ in range(n)]
s=set()
i=0
n=0
while True:
  n += 1
  i = a[i]
  if i==1:
    print(n)
    break
  elif i in s:
    print(-1)
    break
  else:
    s|={i}
    

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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define sumvec(v) accumulate(all(v),0LL)
#define mapmin(v) v.rbegin()->first
#define mapmax(v) v.begin()->first
#define pb push_back
#define pf push_front
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK cerr<<"OK\n"
#define OK1 cerr<<"OK1\n"
#define OK2 cerr<<"OK2\n"
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n
#define endl '\n'

typedef long long ll;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;

typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);
const ll mod=1000000007;
const ll mod2=998244353;

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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

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

void YES(bool b) {cout << ((b)?"YES\n":"NO\n");}
void Yes(bool b) {cout << ((b)?"Yes\n":"No\n");}
void yes(bool b) {cout << ((b)?"yes\n":"no\n");}
void Yay(bool b) {cout << ((b)?"Yay!\n":":(\n");}

ll powmod(ll a,ll b){ll c=1; while(b>0){ if(b&1){ c=a*c%mod; } a=a*a%mod; b>>=1; } return c;}
ll nCrmod(ll n,ll r){ll x=1,y=1; rep(i,r){x=x*(n-i)%mod; y=y*(i+1)%mod;} return x*powmod(y,mod-2)%mod;}
ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	ll n;
	while(cin >> n){
		ll cnt=0;
		rep(i,10)rep(j,10)rep(k,10)rep(l,10){
			if(i+j+k+l==n) cnt++;
		}
		cout << cnt << endl;
	}
	return 0;
}


Measured memory_bytes: 3048
N = int(input())
r = {'AC': 0, 'WA': 0, 'TLE': 0, 'RE': 0}
for i in range(N):
    r[input()] += 1

for k in ['AC', 'WA', 'TLE', 'RE']:
    print(k + ' x ' + str(r[k]))


Measured memory_bytes: 74536
using System;
using System.Collections.Generic;

namespace 課題1
{
    class Program
    {
        static void Main(string[] args)
		{
			string[] strArray = Console.ReadLine().Split(" ");
			int[] intArray = new int[2];
			 
			intArray = Array.ConvertAll(strArray, int.Parse);

			int[,] arrayVal = new int[intArray[1],2 ];

			for(int i=0;i< intArray[1];i++)
			{
				string[] strArrayAtai = Console.ReadLine().Split(" ");
				int[] intArrayAtai = new int[2];

				intArrayAtai = Array.ConvertAll(strArrayAtai, int.Parse);

				arrayVal[i, 0] = intArrayAtai[0];
				arrayVal[i, 1] = intArrayAtai[1]-1;
			}

			int intSum = 0;
			int intCount = 0;

			for (int i = 0; i < arrayVal.Length / 2; i++)
			{
				intSum = intSum + arrayVal[i, 0] + arrayVal[i, 1];
			}

			while (intSum != 0)
			{
				var intList = new List<int>();

				for (int i = 0; i < arrayVal.Length/2; i++)
				{

					if (arrayVal[i, 1] != 0)
					{
						intList.Add(arrayVal[i, 1]);
					}
				}

			
				intList.Sort();


				var intListForDelete = new List<int>();

				for (int i = 0; i < arrayVal.Length / 2; i++)
				{
					if(arrayVal[i, 0]<= intList[0]
						&& intList[0]<= arrayVal[i,1])
					{
						intListForDelete.Add(i);
					}

				}


				foreach(int a in intListForDelete)
				{
					arrayVal[a, 0] = 0;
					arrayVal[a, 1] = 0;
				}

				intSum = 0;

				for (int i = 0; i < arrayVal.Length / 2; i++)
				{
					intSum = intSum + arrayVal[i, 0] + arrayVal[i, 1];
				}


				intCount++;


			}


			//出力する
			Console.WriteLine(intCount);

		}
	}
}


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

int main (){
  int n;
  cin>>n;
  map<int, int> a;
  rep(i,n){
    int x;cin>>x;
    a[x-1]++;
    a[x]++;
    a[x+1]++;
  }
  int sum = 0;
  for(auto s : a){
    sum = max(sum,s.second);
  }
  cout << sum << endl;
}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define f first
#define s second
 
ll dp[100100];
 
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//freopen("input.in", "r", stdin);
        //freopen("output.out", "w", stdout);
	int n, w;
	cin >> n >> w;	
	int a[n], b[n];
	for(int i = 0; i < n; i++){
		cin >> a[i] >> b[i];
	}
	for(int i = 0; i < n; i++){
		for(int j = w - a[i]; j >= 0; j--){
			dp[j + a[i]] = max(dp[j] + b[i], dp[j + a[i]]);
		}
	}
	ll ans = 0;
  	for(int i = 1; i <= w; i++){
    	ans = max(ans, dp[i]);
    }
  	cout << ans << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/

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

namespace Atcoder
{
    class ABC111
    {
        static void Main(string[] args)
        {
            string rawinput = Console.ReadLine();

            int Ans = 0;
            //3桁なので
            for (int i = 0; i < 3; i++)
            {
                char input = rawinput[i];
                if (input == '1')
                {
                    Console.Write(9);
                }
                else if (input == '9')
                {
                    Console.Write(1);
                }
            }
            
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
using namespace std;
int main(){
  int N,count=0;
  bool f=true;
  cin>>N;
  int a[N];
  for(int i=0;i<N;i++){
    cin>>a[i];
  }
  for(int j=0;j<N;j++){
    if(a[j]%2==0){
      a[j]=a[j]/2;
      count++;
      j=-1;
    }
  }
  cout<<count;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, s, e) for (int i = (int)(s); i < (int)(e); i++)
#define _rep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define _REP(i, e, s) for (int i = (int)(e - 1); i >= (int)(s); i--)

#define yes cout << "yes" << endl;
#define Yes cout << "Yes" << endl;
#define YES cout << "YES" << endl;

#define no cout << "no" << endl;
#define No cout << "No" << endl;
#define NO cout << "NO" << endl;

#define ll long long
#define ull unsigned long long
#define vi vector<int>

const double PI = 3.14159265358979323846;

ll gcd(ll a, ll b) {
    if (a < b) return gcd(b, a);
    ll r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

int main() {
    int S, W;
    cin >> S >> W;
    if (S > W) {
        cout << "safe" << endl;
    } else {
        cout << "unsafe" << endl;
    }
}


Measured memory_bytes: 3620