akhauriyash/Code-Regression huggingface dataset:
// https://atcoder.jp/contests/abc175/tasks/abc175_d
#include <bits/stdc++.h>
using namespace std;
#define int int64_t
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define CEIL(a, b) ((a - 1) / b + 1)

void solve() {
    int N, K;
    cin >> N >> K;
    vector<int> P(N), C(N);
    for (auto &&x : P) {
        cin >> x;
        x--;
    }
    for (auto &&x : C) {
        cin >> x;
    }

    int ans = -1e12;
    // スタート位置
    REP(i, N) {
        // 循環する要素を求める（Pi != i なので自分自身へループしない）
        vector<int64_t> v;
        for (int j = i;; j = P[j]) {
            v.push_back(C[j]);
            // 開始時点に戻ったら終了
            if (P[j] == i)
                break;
        }
        // 循環する要素の長さ
        int m = v.size();
        // 循環する要素の合計
        auto sum = accumulate(begin(v), end(v), 0LL);
        int64_t cur = 0;
        for (int r = 1; r <= m; ++r) {
            if (r > K)
                break;
            cur += v[r - 1];
            // 先頭からスコアを加算し、残りの長さに対して何回循環するか数える
            ans = max(ans, cur + (K - r) / m * max<int64_t>(sum, 0));
        }
    }
    cout << ans << endl;
}

signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    solve();
}


Measured memory_bytes: 3844
n, k = [int(i) for i in input().split()]
ans = 0
mod = 10 ** 9 + 7
for i in range(k, n + 2):
    ans += (n+1)*(n)//2-(n - i) * (n + 1 - i) // 2 - (i) * (i - 1) // 2+1
    ans %= mod
    #print(i, (n+1)*(n)//2, (n - i) * (n + 1 - i) // 2, (i) * (i - 1) // 2)

print(ans)


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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

// a^b mod M
long myPow(long a,long b,int M) {
    long ret = 1;
    long tmp = a;
    while(b>0) {
        if((b&1)==1) ret = (ret * tmp) % M;
        tmp = (tmp * tmp) % M;
        b = b>>1;
    }
    return ret;
}

 // nCk mod M
int nCk(int n,int k,int M) {
    long ret = 1;
    int mi = min(k, n-k);
    for(int i=1;i<=mi;i++) {
        ret = (ret * myPow(i,M-2,M)) % M;
    }
    for(int i=n-mi+1;i<=n;i++) {
        ret = (ret * i) % M;
    }
    return (int)ret;
};

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}


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

    int ans = 1;
    int v = 2;
    while(n > ans){
        ans += v++;
    }

    if (n != ans){
        cout << "No" << endl;
        return 0;
    }

    cout << "Yes" << endl;

    vector<int> g[10000];
    int k = 1;
    for(int i = 0; i < v; i++){
        for(int j = i + 1; j < v; j++){
            g[i].push_back(k);
            g[j].push_back(k);
            k++;
        }
    }

    cout << v << endl;
    REP(i, v) {
        cout << g[i].size(); 
        REP(j, g[i].size()) cout << " " << g[i][j];
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 2560
import cmath
import sys

INF=10**18
MOD=998244353
MAX=10**5+7

def main():
    N=int(input())
    D=list(map(int, input().split()))
    cnt=[0]*(N+1)

    if (D[0]!=0) or (0 in D[1:]):
        print(0)
        exit()

    for d in D:
        cnt[d]+=1

    ans=1
    for  i in range(1, max(D)+1):
        ans=ans*pow(cnt[i-1], cnt[i], MOD)%MOD
    print(ans)

if __name__=='__main__':
    main()


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

namespace AtCorder
{
	public class Program
	{	
		static void Main(string[] args)
		{
			Scanner cin = new Scanner();
			int x = cin.Int();
			int a = cin.Int();
			if (x < a) {
				Console.WriteLine(0);
			} else {
				Console.WriteLine(10);
			}

			//
		}
		
		
	}

	public class Scanner
	{
		string[] s;
		int i;

		char[] cs = new char[] { ' ' };

		public Scanner()
		{
			s = new string[0];
			i = 0;
		}

		public string Next()
		{
			if (i < s.Length) return s[i++];
			string st = Console.ReadLine();
			while (st == "") st = Console.ReadLine();
			s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
			if (s.Length == 0) return Next();
			i = 0;
			return s[i++];
		}

		public int Int()
		{
			return int.Parse(Next());
		}
		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long Long()
		{
			return long.Parse(Next());
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double Double()
		{
			return double.Parse(Next());
		}


		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}
	}
}


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

int main(){
    string n;
    cin >> n;
    int ok = 0;
    if (n.at(0) == '7'){
        ok = 1;
    }
    if (n.at(1) == '7'){
        ok = 1;
    }
    if (n.at(2) == '7'){
        ok = 1;
    }
    if (ok == 1) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3620
#include <stdio.h>

int main(void) {
	// get inputs
	int top, bottom, height;
	
	scanf("%d", &top);
	scanf("%d", &bottom);
	scanf("%d", &height);
	
	// get area
	int area = (top + bottom) * height / 2;
	
	// output
	printf("%d\n", area);
	
	return 0;
}

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

using namespace std;
using ll = long long;

int main(int argc, const char *argv[])
{
    int n;
    cin >> n;

    ll sum = 0;
    for (int i = 1; i <= n; i++)
    {
        if (i % 15 == 0)
        {
            continue;
        }
        else if (i % 3 == 0)
        {
            continue;
        }
        else if (i % 5 == 0)
        {
            continue;
        }
        sum += i;
    }
    cout << sum << endl;
}

Measured memory_bytes: 3620
/**
 * author: stein
 * created: 2020.08.15 13:24:56
**/
#include <bits/stdc++.h>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  int c = 0, n = 0;
  for (int i = 0; i < 3; i++) {
    if (s[i] == 'R') {
      n++;
    }else n = 0;
    c = max(c, n);
  } 
  cout << c << endl;
  return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define mod 998244353
#define pb push_back
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector< pi > 
const int N=1010;
vi v[N*N];
int st[N*N],tim[N*N];
int main()
{
	//memset(d,1,sizeof d)
	int n,lst,x;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>lst;
		for(int j=2;j<n;j++)
		{
			cin>>x;
			int f=min(i,lst)*N+max(i,lst);
			int s=min(i,x)*N+max(i,x);
			lst=x;
			v[f].pb(s);
			tim[s]+=1;
		}
	}
	vector<int> ans;
	for(int i=1;i<=n;i++)
	{
		for(int j=i+1;j<=n;j++)
		{
			if(!tim[i*N+j])
				ans.pb(i*N+j);
		}
	}
	int res=0,cnt=0;
	while(ans.size())
	{
		res++;
		cnt+=ans.size();
		vi w;
		for(int z:ans)
		{
			for(int y: v[z])
			{
				tim[y]--;
				if(tim[y]==0)
					w.pb(y);
			}
		}
		ans=w;
		//for(int y: ans) cout<<y<<' ';cout<<"\n";
	}

	if(cnt==n*(n-1)/2)
		printf("%d",res);
	else cout<<"-1";
	return 0;
}

Measured memory_bytes: 45696
/// kazuki08
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());



signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
  
  int n;
  cin >> n;
  int p[n+1],q[n+1];
  for(int i=0;i<n;i++){
    cin >> p[i];p[i]--;
  }
  for(int i=0;i<n;i++){
    cin >> q[i];q[i]--;
  }
  vi v;
  for(int i=0;i<n;i++){
    v.pb(i);
  }
  int a = 1, b = 1;
  int cnt = 1;
  do{
    // cout << v << endl;
    bool f1 = true;
    bool f2 = true;
    for(int i=0;i<n;i++){
      if(p[i]!=v[i])f1 = false;
      if(q[i]!=v[i])f2 = false;
    }
    if(f1){
      a = cnt;
    }
    if(f2){
      b = cnt;
    }
    cnt++;
  }while(next_permutation(all(v)));

  int ans = abs(a-b);
  cout << ans << endl;

return 0;
}
///....


Measured memory_bytes: 256
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
  let mut s = String::new();
  std::io::stdin().read_line(&mut s).ok();
  s.trim()
    .split_whitespace()
    .map(|e| e.parse().ok().unwrap())
    .collect()
}

fn main() {
  let str_list: Vec<String> = read_vec();
  let second: &String = &str_list[1];
  println!("A{}C", second.chars().collect::<Vec<char>>()[0]);
}


Measured memory_bytes: 4476
from functools import reduce
def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    c = a % b
    return gcd(b, c)
def gcd_list(numbers):
    return reduce(gcd, numbers)
na = lambda: list(map(int, input().split()))
n, X = na()
x = na()
x.append(X)
x.sort()
l = []
for i in range(len(x)-1):
    l.append(x[i+1]-x[i])
print(gcd_list(l))

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

    long long money = 100;
    long long year = 0;

    while(money < X){
        money = money + (money/100);
        year ++;
    }

    cout << year << endl;

    return 0;
}


Measured memory_bytes: 3620
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N, W = map(int, input().split())
items = [list(map(int, input().split())) for _ in range(N)]
dp = [[0]*(W+1) for _ in range(N)]

# init
first_item = items[0]
for i in range(W+1):
    if i >= first_item[0]:
        dp[0][i] = first_item[1]

# update
for i in range(1, N):
    for w in range(W+1):
        if w-items[i][0] >= 0:
            dp[i][w] = max(dp[i-1][w], dp[i-1][w-items[i][0]]+items[i][1])
        else:
            dp[i][w] = dp[i-1][w]

print(max(dp[N-1]))


Measured memory_bytes: 120172
A, B, M = map(int, input().split())
a = [int(e) for e in input().split()]
b = [int(e) for e in input().split()]

ans = min(a) + min(b)

for _ in range(M):
  x, y, c = map(int, input().split())
  cost = a[x - 1] + b[y - 1] - c
  ans = min(ans, cost)

print(ans)


Measured memory_bytes: 96960
/**
 * 与えられた英文に含まれる、
 * 各アルファベットの数を数えるプログラムを作成して下さい。 なお、小文字と大文字は区別しません。
 */

//スキャナつかうため

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
	// プログラムのエントリポイント
	public static void main(String[] args) {
		// 入力ストリームの生成
		Scanner sc = new Scanner(System.in);
		//入力される二つの文字列を受け取る
		String strs = sc.nextLine();
		String strItti = sc.nextLine();
		//比較対象になる文字列をつくる
		String strMoji = strs + strs;
		// System.out.println(strMoji);
		//strMoji のなかにstrIttiがあればYes,なければNoを表示
		if (strMoji.contains(strItti)) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}
}

Measured memory_bytes: 17280
#include<stdio.h>
#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n,M[N][N];
int color[N],d[N],f[N],time;

void dfs_visit(int u){
  int v;
  color[u]=GRAY;
  d[u]=++time;
  for(v=0;v<n;v++){
    if(M[u][v]==0) continue;
    if(color[v]==WHITE){
      dfs_visit(v);
    }
  }
  color[u]=BLACK;
  f[u]=++time;
}

void dfs(){
  int u;
  for(u=0;u<n;u++){
    color[u]=WHITE;
    time=0;
  }
  for(u=0;u<n;u++){
    if(color[u]==WHITE){
      dfs_visit(u);
    }
  }
  for(u=0;u<n;u++){
    printf("%d %d %d\n",u+1,d[u],f[u]);
  }
}

int main(){
  int u,v,k,i,j;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      M[i][j]=0;
    }
  }
  for(i=0;i<n;i++){
    scanf("%d %d",&u,&k);
    u--;
    for(j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      M[u][v]=1;
    }
  }
  dfs();
  return 0;
}



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


int main(){
  int n;
  cin>>n;
  int best = 1e9;
  for(int i=1; i<n; i++){
    int j = abs(n-i);
    int sum_ = 0;
    int k = i;
    while(k!=0){
      sum_ += (k%10);
      k /= 10;
    }
    while(j!=0){
      sum_ += (j%10);
      j /= 10;
    }
    if(sum_<best)
    best = sum_;
  }
  cout<<best<<"\n";
  return 0;

}


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

int main(void)
{	
	while (1) {
		char card[201] = "\0";
		cin >> card;
		
		if (card[0] == '-' && card[1] == '\0') break;
		
		int cnum = strlen(card);
		int m;
		cin >> m;
		for (int i = 0; i < m; i++) {
			int h;
			cin >> h;
			
			char temp[201] = "\0";
			strncpy(temp, card, h);
			for (int j = 0; j < cnum - h; j++) {
				card[j] = card[h+j];
			}
			strncpy(&card[cnum-h], temp, h);
		}
		
		cout << card << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define fr(a,b,c) for(int a=b,__=c;a<__;a++)
using namespace std;
typedef long long ll;
ll n,m;
string dp[51][51][51];

string go(int x,int y,int z){
	if(x==1&&y==0&&z==0)return "a";
	if(x==0&&y==1&&z==0)return "b";
	if(x==0&&y==0&&z==1)return "c";
	if(dp[x][y][z]!="")return dp[x][y][z];
	fr(i,0,x+1)fr(j,0,y+1)fr(k,0,z+1){
		if(i+j+k&&(i!=x||j!=y||k!=z)){
			string a=go(i,j,k);
			string b=go(x-i,y-j,z-k);
			if(a<b)a=a+b;
			else a=b+a;
			if(dp[x][y][z]<a)dp[x][y][z]=a;
		}
	}
	return dp[x][y][z]; 
}

int main(){
	int x,y,z;
	cin>>x>>y>>z;
	cout<<go(x,y,z)<<endl;
}

Measured memory_bytes: 1664
using System;
using System.Linq;
using System.Collections.Generic;

public class Program
{
	public static void Main()
	{
		var message = "No";
		var input = _GetReadLine();
		var length = input.Length;
		if(length > 0 && (length % 2) == 1)
		{
			var halfLength = length / 2;
			var left = input.Substring(0 , halfLength);
			var right = input.Substring(halfLength + 1);
			if(left == right) { message = "Yes"; }
		}
		Console.WriteLine(message);
	}

	private static int _GetCombinationNum(int iLeft , int iRight)
	{
		var left = Enumerable.Range(iLeft - iRight + 1 , iRight).Aggregate((iCurrent , iNext) => iCurrent * iNext);
		var right = Enumerable.Range(1 , iRight).Aggregate((iCurrent , iNext) => iCurrent * iNext);
		return left / right;
	}
	
	private static string		_GetReadLine()		  { return Console.ReadLine(); }
	private static int			_GetIntReadLine()	  { return int.Parse(_GetReadLine()); }
	private static List<string> _GetListReadLine()	  { return _GetReadLine().Split(' ').ToList(); }
	private static List<int>	_GetIntListReadLine() { return _GetListReadLine().Select(iText => int.Parse(iText)).ToList(); }
}

Measured memory_bytes: 13140
#pragma region include
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <cstdio>
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define MOD 1000000007
#define INF 1000000000
#define LLINF 4000000000000000000
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#pragma endregion

//#define __DEBUG__
#ifdef  __DEBUG__
#define dump(x) cerr << #x << " = " << (x) << " [" << __LINE__ << ":" << __FUNCTION__ << "] " << endl;
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& v) {
    os << "{";
    REP(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
    os << "}";
    return os;
}
// pair出力
template<typename T, typename U>
ostream& operator << (ostream& os, pair<T, U>& p) {
    return os << "(" << p.first << ", " << p.second << ")";
}
// map出力
template<typename T, typename U>
ostream& operator << (ostream& os, map<T, U>& map_var) {
    os << "{";
    for (auto itr = map_var.begin(); itr != map_var.end(); itr++) {
        os << "(" << itr->first << ", " << itr->second << ")";
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set 出力
template<typename T>
ostream& operator << (ostream& os, set<T>& set_var) {
    os << "{";
    for (auto itr = set_var.begin(); itr != set_var.end(); itr++) {
        os << *itr;
        ++itr;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
#endif

//powMod
ll powMod(ll k, ll n, ll mod) {
    ll x = 1;
    while (n > 0) {
        if (n & 1) {
            x = x * k % mod;
        }
        k = k * k % mod;
        n >>= 1;
    }
    return x;
}

// comb (前計算O(NlogMOD) クエリO(1))
const int MAX_N = 200000;
ll FACT[MAX_N + 1], IFACT[MAX_N + 1];

ll comb(ll n, ll r) {
    if (n < 0 || r < 0 || r > n)return 0;
    if (r > n / 2) r = n - r;
    return FACT[n] * IFACT[n - r] % MOD * IFACT[r] % MOD;
}

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    int H, W, A, B; cin >> H >> W >> A >> B;
    ll ans = 0;
    // 前計算(mainに)
    FACT[0] = IFACT[0] = 1;
    for (int i = 1; i <= MAX_N; i++) {
        FACT[i] = FACT[i - 1] * i % MOD;
        IFACT[i] = powMod(FACT[i], MOD - 2, MOD);
    }
    while (A < H && B < W) {
        ans += comb(B + H - A - 1, B) * comb(A + W - B - 1, A) % MOD;
        ans %= MOD;
        A++; B++;
    }
    cout << ans << endl;
    getchar(); getchar();
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vint;
#define rep(i,n) for (ll i = 0; i < (ll)(n); ++i)
#define rrep(a,b,n) for(ll a = (ll)(b); a < (ll)(n); a++)
#define mrep(i,n) for (ll i = (ll)(n); i > 0; i--)
#define be(v) (v).begin(), (v).end()
#define dcout cout << fixed << setprecision(20) 
ll INF = 1LL << 60;
ll mod = 1e9 + 7;

int main() {
	int n,s; cin >> n;
	vector<int> a(100001);
	rep(i,n) {
		cin >> s;
		a[s]++;
	}
	int ans=-1;
	rep(i,99999) {
		ans=max(ans,(a.at(i)+a.at(i+1)+a.at(i+2)));
	}
	cout << ans << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ub upper_bound
//#define int long long
#define vbe(sdk) sdk.begin(),sdk.end()
#define pb push_back
#define loop(i,a,b) for(int i=a;i<b;++i)
#define rloop(i,a,b) for(int i=a;i>=b;--i)
#define mp make_pair
#define mod 1000000007
#define endl '\n'
#define vvll vector<vector<int> >
#define vll vector<int>
#define mint map<int,int> 
#define sz(x) (int)x.size()
#define sll set<int>
#define pll pair<int,int>
#define F first
#define S second
#define pi 3.14159265358979323846
using namespace std;
int arr1[26],arr2[26][26];
void solve()
{
    int n,k;
    cin>>n>>k;
    int cnt=0;
    while(n>0)
    {
        n/=k;
        cnt++;
    }
    cout<<cnt<<"\n";
}

signed main(){
  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
        //  int t;
        // cin>>t;
        // while(t--){
            solve();
    //    }
    return 0;
}




Measured memory_bytes: 256
a = [1, 3, 5, 7, 8, 10, 12];
b = [4, 6, 9, 11];
c = [2];
z = [];

var readline = require('readline');

var rl = readline.createInterface({
	input: process.stdin,
	output: process.stdout
});

rl.question('', function(x)
{
	first = parseInt(x.substring(0, 1));
	second = parseInt(x.substring(2, 3));

	if(a.indexOf(first) >= 0)
		z = a;
	else if(b.indexOf(first) >= 0)
		z = b;
	else if(c.indexOf(first) >= 0)
		z = c;


	if(z.indexOf(second) >= 0)
		console.log("Yes");
	else
		console.log("No");

	rl.close();
	process.stdin.destroy();
});

Measured memory_bytes: 7628
#include <string>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <utility>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iterator>
#include <sstream>

using namespace std;

bool b[50000];

int main()
{
	memset(b,1,sizeof(b));
	b[0] = b[1] = false;
	for(int i = 2; i < sizeof(b); i++)
		if(b[i]) for(int j = i*2; j < sizeof(b); j += i) b[j] = false;

	int n;
	while(cin>>n,n){
		int ans = 0;
		for (int i = 2; i <= n/2; i++){
			if(b[i] && b[n-i]) ans++;
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 916
#include<iostream>
#include <string>

using namespace std;

int main(){
  int i;
  string a(4,'0');

  for (size_t i = 0; i < 4; i++) {
    cin >> a[i];
  }


if (a[0] == a[1] && a[2] == a[3] && a[1] != a[2]) {
  cout << "Yes" << endl;
}else if (a[0] == a[2] && a[1] == a[3] && a[0] != a[1]) {
  cout << "Yes" << endl;
}else if (a[0] == a[3] && a[1] == a[2] && a[0] != a[1]) {
  cout << "Yes" << endl;
}else{
  cout << "No" << endl;
}

  return 0;
}


Measured memory_bytes: 256
using System;

public class AtCoderB
{
    static void Main()
    {
        long a;
        long b;
        long k;
        {
            var line = Console.ReadLine();
            var words = line.Split(' ');
            a = long.Parse(words[0]);
            b = long.Parse(words[1]);
            k = long.Parse(words[2]);
        }

        if (a >= k)
        {
            a = a - k;
        }
        else if (a < k)
        {
            b = b - (k - a);
            a = 0;
            if (b < 0)
            {
                b = 0;
            }
        }

        Console.WriteLine(a + " " + b);
    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <fstream>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

#define EPS 1e-9
#define INF MOD
#define MOD 1000000007LL
#define fir first
#define iss istringstream
#define sst stringstream
#define ite iterator
#define ll long long
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define pi pair<int,int>
#define pb push_back
#define sec second
#define sh(i) (1LL<<i)
#define sz size()
#define vi vector<int>
#define vc vector
#define vl vector<ll>
#define vs vector<string>

char a='a',b='a',c='a';
string s;
set<string> S;

int main(){
	while(1){
		cout<<"?"<<a<<b<<c<<"a\n";
		string t="";
		t+=a,t+=b,t+=c,t+='a';
		S.insert(t);
		cin>>s;
		if(s[0]!='a'||S.count(s)){
			cout<<"!OUT\n";
			return 0;
		}
		S.insert(s);
		a=s[s.sz-1];
		c++;
		if(c=='{')b++,c='a';
	}
}

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

using namespace std;

int area(int a) {
    int ans = 3 * pow(a, 2);
    return ans;
}

int main() {
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
    int r;
    cin >> r;
    cout << area(r) << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[n];
	int i;
	for(i=0;i<n;i++)
		cin>>a[i];
	sort(a, a+n);
	int res = a[n/2] - a[n/2-1];
	cout<<res<<endl;
}

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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int x,a,b;
  cin >> x>>a>>b;
  cout << ((abs(x-a) < abs(x-b)) ? "A" : "B") << "\n";
}


Measured memory_bytes: 256
// ABC152E
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P>IP;
typedef vector<ll> V;
typedef vector<V> V2;
typedef vector<vector<P> > G;
void g_dir(G &graph, ll a, ll b, ll w = 1){graph[a].push_back(P(b, w));}
void g_undir(G &graph, ll a, ll b, ll w = 1){g_dir(graph, a, b, w);g_dir(graph, b, a, w);}
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)
#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)
template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}
const ll INF = 1145141919;
const ll MOD = 1000000007;
const ll NUM = 101010;

ll m_pow(ll a, ll b){
    ll ret = 1;
    while(b > 0){
        if(b & 1)(ret *= a) %= MOD;
        (a *= a) %= MOD;
        b >>= 1;
    }
    return ret;
}

ll m_div(ll x){
    return m_pow(x, MOD - 2);
}

int main(){

    for(ll N; cin >> N;){
        V A(N);
        rep(i, N)cin >> A[i];
        map<ll, ll>cnt;
        for(auto a : A){
            map<ll, ll>tmp;
            ll x = a;
            for(ll j = 2; j * j <= x; j++){
                while(x % j == 0){
                    x /= j;
                    tmp[j]++;
                }
            }
            if(x > 1)tmp[x]++;
            for(auto p : tmp)chmax(cnt[p.first], p.second);            
        }
        ll m = 1;
        for(auto p : cnt)m = (m * m_pow(p.first, p.second)) % MOD;
        ll sum = 0;
        for(auto a : A){
            ll tmp = (m * m_div(a)) % MOD;
            sum = (sum + tmp) % MOD;
        }
        cout << sum << endl;
    }
    
    return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
#define all(v) ((v).begin()),((v).end())
#define ll long long
#define fastIO cout << fixed << setprecision(12), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
double const EPS = 1e-12, PI = acos(-1);
const int N = 1e6 + 9, M = 5e3 + 9, OO = 1e9 + 7, MOD = 1e9 + 7;
const ll inf = 1e18;

bool la2[N];
int n, m, a;
ll mem[N];

ll dp(int step) {
  if(step == n)
    return 1;
  if(step > n)
    return 0;
  ll& ret = mem[step];
  if(~ret)
    return ret;
  ret = 0;
  if(!la2[step + 1])
    ret = ((ret % MOD) + (dp(step + 1) % MOD)) % MOD;
  if(!la2[step + 2])
    ret = ((ret % MOD) + (dp(step + 2) % MOD)) % MOD;
  return ret;
}

int main() {
  fastIO;
#ifdef LOCAL
  freopen("input.in", "rt", stdin);
#endif
  cin >> n >> m;
  for (int i = 0; i < m; ++i) {
    cin >> a;
    la2[a] = 1;
  }
  memset(mem, -1, sizeof mem);
  cout << dp(0);
  return 0;
}

Measured memory_bytes: 11520
#include<string.h>
#include<stdio.h>
#include<stdlib.h>
int main(){
    char s[3];
    scanf("%s",s);
    int count = 0;
    for(int i=0;i<3;i++){
    if(s[i]=='1')count++;
    }
    printf("%d", count);
return 0;
}

Measured memory_bytes: 128
n = int(input())

count = 0
flag = 0
for i in range(n):
    d1,d2 = map(int,input().split())
    if d1 == d2:
        count += 1
        if count == 3:
            flag = 1
    else:
        count = 0

if flag == 1:
    print("Yes")
else: print("No")

Measured memory_bytes: 9176
#include<bits/stdc++.h>
const long long INF = INT_MAX / 2;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ll long long int
#define ALL(x) x.begin(),x.end()
using namespace std;
ll ans = 0, sum = 0, n, k, counter = 0, w, h;
string s;
vector<ll> v;
vector < pair<ll, ll > > vp;
vector<vector<ll> > vv(50, vector<ll>(50, INF));
vector<string> vs;
vector<char> vc;
vector<ll> vi;

/*--------------------template--------------------*/


int main() {
	cin >> s;
	ll g = 1;
	FOR(i, 1, s.size()) {
		if (s[i] == 'g'&&g != 0) {
			ans++;
			g--;
		}
		else if (s[i] == 'g'&&g == 0) {
			g++;
		}
		else if (s[i] == 'p'&&g != 0) {
			g--;
		}
		else if (s[i] == 'p'&&g == 0) {
			ans--;
			g++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
//freopen("transmitters.in","r",stdin);
//cout<<fixed<<setprecision(6)<<n<<endl;
// transform(s.begin(), s.end(), s.begin(), ::tolower);
//double PI=3.14159265359,c=0;
#define all(v) v.begin(),v.end()
#define endl '\n'
#define ll long long
//#define f(n) for(int i=;i<n;i++)
double PI = acos(-1);
using namespace std;
void fast()
{
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
ll n,arr[1000][3],vist[111][100005];
ll Knapsack(int i,ll r)
{
    if(i>=n)
     return 0;
    if(vist[i][r])
     return vist[i][r];
    ll c1=Knapsack(i+1,r);
    ll c2=0;
    if(r>=arr[i][0])
    {
       c2=Knapsack(i+1,r-arr[i][0])+arr[i][1];
    }
    return vist[i][r]=max(c1,c2);
}
int main()
{
    fast();
    ll w;
    cin>>n>>w;
    for(int i=0;i<n;i++)
      cin>>arr[i][0]>>arr[i][1];
    
    cout<<Knapsack(0,w) <<endl;

    return 0;
}


Measured memory_bytes: 78080
#include <stdio.h>
#include <stdlib.h>

#define ARRAY_MAX 31

int main()
{
	int w, n;
	int amda[ARRAY_MAX];
	int i;
	int a, b, tmp;
	char c;

	scanf( "%d", &w );

	for ( i = 0 ; i <= w ; i++ )
	{
		amda[i] = i;
	}

	scanf( "%d", &n );
	for ( i = 0 ; i < n ; i++ )
	{
		scanf( "%d%c%d", &a, &c, &b );
		//swap operation
		tmp = amda[a];
		amda[a] = amda[b];
		amda[b] = tmp;
	}
	
	for ( i = 1 ; i <= w ; i++ )
	{
		fprintf( stdout, "%d\n", amda[i] );
	}

	return 0;
}

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

int main(){
    string s;
    cin >> s;
    long long int tmp, ans=0;
    for(int i=0;i<(1<<s.size()-1);i++){
        bitset<9> bt(i);
        tmp = s.at(0) - '0';
        for(int j=0;j<s.size()-1;j++){
            if(bt.test(j)){
                ans  += tmp;
                tmp = 0;
            }
            tmp = tmp * 10 + s.at(j + 1) - '0';
        }
        ans += tmp;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    ll n,m; cin>>n>>m;
    vector<vector<pair<ll,ll>>> path(n);
    vector<ll> l(m,0),r(m,0),d(m,0),visited(n,0),data(n,0);
    rep(i,m){
        cin>>l[i]>>r[i]>>d[i];
        l[i]--; r[i]--;
        path[l[i]].push_back(mk(r[i],d[i]));
        path[r[i]].push_back(mk(l[i],-d[i]));
    }
    ll cnt=0;
    rep(i,n){
        if(visited[i]) continue;
        queue<ll> que;
        que.push(i);
        data[i]=0;
        visited[i]=1;
        while(!(que.empty())){
            cnt++;
            ll s=que.front();
            que.pop();
            for(auto to:path[s]){
                if(visited[to.first]) continue;
                data[to.first]=data[s]+to.second;
                visited[to.first]=1;
                que.push(to.first);
            }
        }
    }
    //cout<<cnt<<endl;
    rep(i,m){
        if(data[r[i]]-data[l[i]]!=d[i]){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
}


Measured memory_bytes: 22400
#include <iostream>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
using Real = mp::number<mp::cpp_dec_float<1024>>;

using namespace std;

Bint ans = 0;

Bint fizzbuzz(Bint n)
{
    if (n > 1)
        fizzbuzz(n - 1);

    if (n % 3 == 0 && n % 5 == 0)
    {
    }
    else if (n % 3 == 0)
    {
    }
    else if (n % 5 == 0)
    {
    }
    else
    {
        ans += n;
    }
    return ans;
}

int main()
{
    Bint n;
    cin >> n;
    Bint a;
    a = fizzbuzz(n);
    cout << a;
    return 0;
}

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

using namespace std;
int main() {
	long long N, M, K;
	cin >> N >> M >> K;
	vector<long long>A(N+1);
	vector<long long>B(M+1);
	for (int n = 0;n<N;++n) {
		int m = 0;
		cin >>m;
		A[n + 1] = A[n] + m; 
	}
	for (int n = 0; n < M; ++n) {
		int m = 0;
		cin >> m;
		B[n + 1] = B[n] + m; 
	}
	int ans = 0;
	for (int n = 0;n<=N;++n) {
		int z = K - A[n];
		if (z < 0) {
			break;
		}
		auto itr = upper_bound(B.begin(),B.end(), z);
		int num = itr - B.begin()-1;
		//cout << z << " " << *itr << " " << num << endl;
		ans = max(ans, n + num);
	}
	cout <<ans <<endl;
	return 0;
}


Measured memory_bytes: 6388
#include<cstdio>
#include<algorithm>
int main(){
    int n,m,a[50],b[50],c[50],d[50];
    scanf("%d%d",&n,&m);
    for(int i=0;i<n;i++)scanf("%d%d",&a[i],&b[i]);
    for(int i=0;i<m;i++)scanf("%d%d",&c[i],&d[i]);
    for(int i=0;i<n;i++){
        int k,l=1e9,ans;
        for(int j=0;j<m;j++){
            k=std::abs(a[i]-c[j])+std::abs(b[i]-d[j]);
            if(k<l){
                ans=j+1;
                l=k;
            }
        }
        printf("%d\n",ans);
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <iterator>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <math.h>

#define v vector
#define ll long long 
#define vpll vector<pair<long long,long long> > 
#define F first
#define S second
#define mp make_pair
#define ld long double
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pci pair<char,int>
#define un unsigned
# define M_PI           3.14159265358979323846  /* pi */
#define mod 1000000007
#define MAXN 200001
using namespace std; 
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)


void solve()
{
    ll n,k;
    cin>>n>>k;
    cout<<min(n%k,k-(n%k))<<endl;
}

int main()
{
    int t;
    // cin>>t;
    t = 1;
    while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
n = int(input())
res = []
for i in range(n):
    a,b = input().split()
    res.append ((a,b))        
res_1 = sorted(res,key=lambda x: (x[0], -int(x[1])))
for i in range(len(res_1)):
    print(res.index(res_1[i])+1)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
  if((a==5 && b==5 && c==7)||(a==7 && b==5 && c==5)||(a==5 && b==7 && c==5))
  cout<<"YES"<<endl;
  else
  cout<<"NO"<<endl;
  return 0;
}
    


Measured memory_bytes: 3496
#include <bits/stdc++.h>
using namespace std;
//#define cerr if (false) cerr
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto _x : v) cerr << _x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << ", "; cerr << endl
template <typename A, typename B>
ostream& operator<<(ostream& os, const pair<A, B>& x) {
	return os << "(" << x.first << "," << x.second << ")";
}
typedef long long ll;
typedef long double ld;
int main() {
	int L, n;
	scanf("%d%d", &L, &n);
	vector<int> X(n + 1), Y(n + 1);
	vector<ll> frSum(n + 1), baSum(n + 1);
	for (int i = 1; i <= n; ++i) {
		scanf("%d", &X[i]);
	}
	ll ans = 0;
	for (int t = 0; t < 2; ++t) {
		for (int i = 1; i <= n; ++i) {
			Y[n - i + 1] = L - X[i];
			frSum[i] = frSum[i - 1] + X[i];
		}
		for (int i = 1; i <= n; ++i) {
			baSum[i] = baSum[i - 1] + Y[i];
		}
		for (int i = 1; i <= n; ++i) {
			int fr = i - 1, ba = n - i;
			ll score;
			if (ba > fr) {
				score = frSum[fr] + baSum[ba] - baSum[ba - fr - 1];
			} else {
				score = frSum[fr] + baSum[ba] - frSum[fr - ba];
			}
			score = 2 * score + X[i];
			ans = max(score, ans);
		}
		swap(frSum, baSum);
		swap(X, Y);
	}
	printf("%lld\n", ans);
}


Measured memory_bytes: 8020
def main():
    import math
    a, b, c, d = map(int, input().split())

#a-bの間の数字の個数（"全体の個数"）を数える
    kosuu = b - a + 1
    
#c, d, c&dの最小公倍数と、a, bそれぞれの割り算の商を求めておく
    a_c = a // c
    a_d = a // d 
    b_c = b // c
    b_d = b // d
    
    lcm_cd = int(c// math.gcd(c,d) * d)
    a_cd = int(a // lcm_cd)
    b_cd = int(b // lcm_cd)

#c, d, c&dの最小公倍数がa, bの間に何個あるか（"約数の個数"）を数える（aは「a以上」の条件から検討に入れるべき数字のため、aで割り切れる場合は約数の個数として含める）
    if a % c == 0:
        kosuu_c = b_c - a_c + 1
    else:
        kosuu_c = b_c - a_c
    
    if a % d == 0:
        kosuu_d = b_d - a_d + 1
    else:
        kosuu_d = b_d - a_d

    if a % lcm_cd == 0:
        kosuu_cd = b_cd - a_cd + 1
    else:
        kosuu_cd = b_cd - a_cd

#全体の個数から約数の個数を引く。公倍数の約数の個数分多く引きすぎているため、足し戻す
    print(kosuu - kosuu_c - kosuu_d +kosuu_cd)




if __name__ == "__main__":
    main()


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

using namespace std;


/// Bismilahir Rahmanir Rahim


typedef unsigned int ui;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef short int si;
typedef unsigned short int usi;
typedef pair <int, int> pii;


#define CASE false
#define TEST false
#define BUFFER true
#define TIME false
#define DEBUG true
#define _ << " " <<
#define __ << "\n"
#define ff first
#define ss second


const double pi = acos(-1);
const int inf = 2147483647;
const int _inf = -2147483648;
const int mod = 1e9+7;


void delay(int sec); // DEBUG



void solution(void)
{
    int n, k;

    cin >> n >> k;
    int ara[n], dp[n];

    for(int i = 0; i < n; ++i) {
        cin >> ara[i];
        dp[i] = mod;
    }
    dp[0] = 0;

    for(int i = 0; i < n; ++i) {
        for(int j = i+1; j <= i+k; ++j) {
            if (j < n) {
                dp[j] = min(dp[j], dp[i]+abs(ara[i]-ara[j]));
            }
            else break;
        }
    }


    cout << dp[n-1] __;




    return ;
}

int main(int argc, char *arv[])
{
    #if BUFFER
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    #endif


    unsigned short int t = 1;

    #if CASE
    int cnt = 1;
    #endif

    #if TEST
    cin >> t;
    #endif

    #if TIME
    clock_t start_time, end_time;
    double time_elapsed;
    #endif


    while(t--) {

        #if TIME
        start_time = clock();
        #endif

        #if CASE
        cout << "Case " << cnt++ << ": ";
        #endif

        solution();

        #if TIME
        end_time = clock();

        time_elapsed = (double) (end_time - start_time) / CLOCKS_PER_SEC;

        cout << "\nRuntime: " << fixed << setprecision(7) << time_elapsed << "\n";
        #endif
    }


    return 0;
}

void delay(int sec)
{
    int mili_sec = 1000 * sec;

    clock_t start_time = clock();

    while (clock() < start_time + mili_sec);

    return ;
}

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

using namespace std;

int man(pair<int, int> lhs, pair<int, int> rhs) {
	return abs(lhs.first - rhs.first) + abs(lhs.second - rhs.second);
}

int main() {
	int n, m;
	cin >> n >> m;
	vector < pair<int, int> > a(n), b(m);
	for (int i = 0; i < n; i++) {
		cin >> a[i].first >> a[i].second;
	}
	for (int i = 0; i < m; i++) {
		cin >> b[i].first >> b[i].second;
	}
	for (int i = 0; i < n; i++) {
		int bst = -1;
		for (int j = 0; j < m; j++) {
			if (bst == -1 || man(a[i], b[j]) < man(a[i], b[bst])) bst = j;
		}
		cout << bst + 1 << "\n";
	}
	return 0;
}




Measured memory_bytes: 256
N, M = map(int, input().split())
ac = [0] * N
wa = [0] * N
for i in range(M):
    p, S = input().split()
    p = int(p) - 1
    if S == 'AC':
        ac[p] = 1
    if S == 'WA' and ac[p] == 0:
        wa[p] += 1
print(sum(ac), sum(ac[i] * wa[i] for i in range(N)))


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

int main(){
	int n, a, v, maxa, maxv;
	while (cin >> n) {
		int maxa = 21, maxv = 0;
		for (int i = 0; i < n; i++) {
			cin >> a >> v;
			if (v > maxv) {
				maxv = v;
				maxa = a;
			}
			else if(v == maxv && maxa > a){
				maxa = a;
			}
		}
		cout << maxa << " " << maxv << endl;
	}
	return 0;
}

Measured memory_bytes: 3092
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
#include <functional>
#include <random>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vvvl> vvvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<ll, ll> PL;
typedef vector<PL> vpl;
typedef vector<vector<PL>> vvpl;
typedef vector<vvpl> vvvpl;
const int INF = 1001001001;
const ll LINF = 1e17;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back
#define ALL(X) (X).begin(),(X).end()

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    sort(ALL(vec));
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

inline ll popcnt(ll x){return __builtin_popcountll((unsigned long long)x);};
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
//friend bool operator<(const stc& lhs, const stc& rhs){
//    return std::tie(lhs.l, lhs.r) < std::tie(rhs.l, rhs.r);
//}



int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N; cin >> N;
    string S; cin >> S;
    ll ans = 0;
    ll idx = 0;
    while(idx < N){
        ll now = idx;
        while(idx < N && S[idx] == S[now]){
            idx++;
        }
        ans++;
    }
    cout << ans << endstr;
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
const int MAX_N = 100010;
bool prime[MAX_N];
int Sum[MAX_N];

int main(){
    fill(prime + 2, prime + MAX_N, true);
    for (int i = 2; i < MAX_N; i++){
        if (prime[i]){
            for (int j = 2 * i; j < MAX_N; j += i){
                prime[j] = false;
            }
        }
    }

    for (int i = 3; i < MAX_N; i += 2){
        Sum[i] = Sum[i - 2];
        if (prime[i] && prime[(i + 2) / 2]) Sum[i] += 1;
    }

    int n;
    cin >> n;
    for (int i = 0; i < n; i++){
        int l, r;
        scanf("%d %d", &l, &r);
        printf("%d\n", Sum[r] - Sum[l - 2]);
    }

    return 0;
}

Measured memory_bytes: 1152
/****************************
/////  Shubham Singhal
/////  LNMIIT
*****************************/
#include <bits/stdc++.h>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define eb emplace_back
#define lwr lower_bound
#define upr upper_bound
#define pq priority_queue
#define umap unordered_map
#define rep(i,n) for(i=0; i<n;i++)
#define repp(i,a,n) for(i=a; i<n;i++)
#define precise(x) cout<<fixed<<setprecision(x)
#define all(x) x.begin(),x.end()
#define lcm(a,b) (a*b)/__gcd(a,b)
#define prn(x) cout<<x<<"\n"
#define prn2(x, y) cout<<x<<" "<<y<<"\n"
#define prn3(x, y, z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define prn4(x, y, z, a) cout<<x<<" "<<y<<" "<<z<<" "<<a<<"\n"
#define prnv(x) for(auto i:x) cout<<i<<" "; cout<<"\n"
#define MOD 1000000007
#define MAX 300005
using namespace std;
 
typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd; 
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<pil> vpil;
typedef vector<pli> vpli;
typedef vector<pll> vpll;
const long long INF64 = 1'000'000'000'000'000'000ll;
clock_t time_p=clock();
void time()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
void doc()
{
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
}
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
}

int main()
{
    fast();
    char x;
    cin>>x;
    x++;
    cout<<x;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll res[10000009]={0};
int main(){
	ll n,sum=0;
	cin>>n;
	for(ll i=1;i<=n;i++)
	    for(ll j=i;j<=n;j+=i)res[j]++;

	for(ll i=1;i<=n;i++)sum+=(i*res[i]);

	cout<<sum<<endl;

}


Measured memory_bytes: 81692
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
const ll mod = 1000000007;
int main() {
  int k;
  cin >> k;
  ll x = 0;
  srep(d,1,1000010){
    x*=10;
    x+=7;
    x%=k;
    if(x%k == 0){
      cout<<d<<endl;
      return 0;
    }
  }
  cout<<-1<<endl;
  return 0;
}

Measured memory_bytes: 3632