akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace Tasks
{
    public class E
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var N = Scanner.Scan<string>();
            var K = Scanner.Scan<int>();
            var digits = N.Length;
            var dp = new long[digits + 1, 2, K + 1];
            dp[0, 0, 0] = 1;
            for (var digit = 0; digit < digits; digit++)
            {
                var value = N[digit] - '0';
                for (var j = 0; j < 2; j++)
                {
                    for (var k = 0; k <= K; k++)
                    {
                        var max = k == K ? 0 : j == 1 ? 9 : value;
                        for (var n = 0; n <= max; n++)
                        {
                            var next = j == 1 || n < value ? 1 : 0;
                            var count = Math.Min(K, n > 0 ? k + 1 : k);
                            dp[digit + 1, next, count] += dp[digit, j, k];
                        }
                    }
                }
            }
            var answer = dp[digits, 0, K] + dp[digits, 1, K];
            Console.WriteLine(answer);
        }

        public static class Scanner
        {
            private static Queue<string> queue = new Queue<string>();
            public static T Next<T>()
            {
                if (!queue.Any()) foreach (var item in Console.ReadLine().Trim().Split(" ")) queue.Enqueue(item);
                return (T)Convert.ChangeType(queue.Dequeue(), typeof(T));
            }
            public static T Scan<T>() => Next<T>();
            public static (T1, T2) Scan<T1, T2>() => (Next<T1>(), Next<T2>());
            public static (T1, T2, T3) Scan<T1, T2, T3>() => (Next<T1>(), Next<T2>(), Next<T3>());
            public static (T1, T2, T3, T4) Scan<T1, T2, T3, T4>() => (Next<T1>(), Next<T2>(), Next<T3>(), Next<T4>());
            public static (T1, T2, T3, T4, T5) Scan<T1, T2, T3, T4, T5>() => (Next<T1>(), Next<T2>(), Next<T3>(), Next<T4>(), Next<T5>());
            public static IEnumerable<T> ScanEnumerable<T>() => Console.ReadLine().Trim().Split(" ").Select(x => (T)Convert.ChangeType(x, typeof(T)));
        }
    }
}


Measured memory_bytes: 28356
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;
import java.util.Random;

public class Main {
    private static FastScanner sc = new FastScanner();
    private static boolean DEBUG_FLG = false;

    public static void main(String[] args) {
    	int N = sc.nextInt();
    	int L = sc.nextInt();
    	int sum = 0;
    	int min = Integer.MAX_VALUE;
    	for(int i=0; i<N; i++) {
    		int x = L + i;
    		if(Math.abs(x) < Math.abs(min)) {
    			min = x;
    		}
    		sum += x;
    	}
    	System.out.println(sum - min);
    }

    static void debug(long... args) {
    	if(!DEBUG_FLG) return;
    	boolean flg = false;
    	for(long s : args) {
    		if(flg) System.out.print(" ");
    		flg = true;
    		System.out.print(s);
    	}
    	System.out.println();
    }

    static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if(ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch(IOException e) {
                    e.printStackTrace();
                }
                if(buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
        public boolean hasNext() { skipUnprintable(); return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public int nextInt(){
            return Integer.parseInt(next());
        }
        public double nextDouble(){
            return Double.parseDouble(next());
        }
    }

    static void shuffleArray(long[] arr){
        int n = arr.length;
        Random rnd = new Random();
        for(int i=0; i<n; ++i){
            long tmp = arr[i];
            int randomPos = i + rnd.nextInt(n-i);
            arr[i] = arr[randomPos];
            arr[randomPos] = tmp;
        }
    }
}


Measured memory_bytes: 20692
#include<iostream>
#include<string>
#include<vector>
#include <algorithm>
#include<deque>
#include<queue>
#include<set>
#include <functional>

//マクロ
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define REPS(i,n) for(int i=1; i<=(int)(n); ++i)
#define RREP(i,n) for(int i=(int)(n)-1; i>=0; --i)
#define RREPS(i,n) for(int i=(int)(n); i>0; --i)
#define FOR(i,s,e) for(int i=(int)(s); i<(int)(e); ++i)
#define RFOR(i,s,e) for(int i=(int)(e)-1; i>=(int)(s); --i)

#define All(a) (a).begin(),(a).end()

//定数
#define INF 1e9
#define MOD (int)(1e9+7)

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

//とりあえず書いておく変数
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

//今回の変数
vector<int> l;

//使用する関数
template<class T>bool chmax(T &a, const T &b) {
	if (a < b) { a = b; return 1; }
	return 0;
}
template<class T>bool chmin(T &a, const T &b) {
	if (a > b) { a = b; return 1; }
	return 0;
}
bool isOK(int index, int key) {
	if (l[index] <= key) return true;
	else return false;
}

int binary_search(int key, int lf) {
	int left = lf;
	int right = (int)l.size();

	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key)) right = mid;
		else left = mid;
	}

	return right;
}


int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll ans = 0;
	int n;
	cin >> n;
	REP(i, n) {
		int li;
		cin >> li;
		l.push_back(li);
	}
	sort(All(l), std::greater<int>());
	REP(i, n - 2) {
		FOR(j, i + 1, n - 1) {
			int l1 = l[i];
			int l2 = l[j];
			int idx = binary_search(l1-l2,j);
			ans += n - (j + 1) - (n - idx);
			//cout << ans << " " << idx << endl;
		}
	}


	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
using ll = long long;
using ull = unsigned long long;

int main(void)
{
    IOS
    int n;
    cin >> n;
    vector<int> v(n);

    REP(i,n) cin >> v[i];

    int ans = 0;
    FOR(i,1,n-1) {
        vector<int> v2({v[i-1],v[i],v[i+1]});
        sort(ALL(v2));
        if (v[i] == v2[1]) ans++;
    }

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

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

int main() {
	int n, i = 0;
	cin >> n;
	vector<int> A(n);
	for (int& i : A) cin >> i;
	for (int j = 0; j < n - 1; ++j) {
		if (A.back() >= A[j]) {
			swap(A[i], A[j]);
			++i;
		}
	}
	swap(A.back(), A[i]);
	for (int j = 0; j < n - 1; ++j) {
		if (i == j) cout << '[' << A[i] << ']';
		else cout << A[j];
		cout << ' ';
	}
	cout << A.back() << endl;
}


Measured memory_bytes: 3076
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
const int maxn=105;
char a[maxn][maxn];
int b[maxn][maxn];
int m,n;
int main()
{
	//freopen("1.txt","r",stdin);
	scanf("%d%d",&n,&m);
	memset(b,0,sizeof(b));
	getchar();
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			a[i][j]=getchar();
			b[i][j]+='0';
			if(a[i][j]=='#')
			{
				b[i][j]='#';
				if(b[i+1][j]!='#')b[i+1][j]++;
				if(b[i-1][j]!='#')b[i-1][j]++;
				if(b[i+1][j+1]!='#')b[i+1][j+1]++;
				if(b[i+1][j-1]!='#')b[i+1][j-1]++;
				if(b[i-1][j+1]!='#')b[i-1][j+1]++;
				if(b[i-1][j-1]!='#')b[i-1][j-1]++;
				if(b[i][j+1]!='#')b[i][j+1]++;
				if(b[i][j-1]!='#')b[i][j-1]++;
			}
		}
		getchar();
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		putchar(b[i][j]);
		putchar('\n');
	}
	return 0;
} 

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;
using namespace std;



int main(int argc, char* argv[])
{
    int n;
    scanf("%d", &n);

    ll a0=0,b0=0;
    int i;
    for(i=0; i<n; i++) {
        ll a,b;
        scanf("%lld %lld", &a, &b);
        if(i==0) {
            a0=a; b0=b;
        }
        else {
            ll tmp0=(a0+a-1)/a;
            ll tmp1=(b0+b-1)/b;
            ll tmp=MAX(tmp0,tmp1);
            a0=a*tmp; b0=b*tmp;
        }
    }
    printf("%lld\n", a0+b0);
    

    return 0;
}


Measured memory_bytes: 128
/*
    問題をよく読もう！
    論理的に考えよう！
    サンプルを確認しよう!
    絶対に諦めるな！
    工夫をしろ！
    配列は少し多めにとっておく

    Twitterは終わるまでログアウト！
    （間違えて解法をツイートしてはいけないから）

*/
//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include<cstring>
//namespace
using namespace std;
//繰り返し
#define REP(i, m, n) for(int i=(int)m; i<(int)n; ++i)
#define rep(i, n) REP(i, 0, n)
//イテレータ
#define all_range(C) begin(C), end(C)
//簡略化
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
typedef pair<string,int> pst;

const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
//最大最小
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) {if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) {if(a<b) a=b;}

//関数

//最大公約数を求める
ll my_gcd(ll x, ll y) {
  ll r;

  while(y!=0) {
    r = x%y;
    x = y;
    y = r;
  }

  return x;
}

//最小公約数を求める
ll my_lcm(ll x, ll y) {

  return (x*y)/my_gcd(x,y);
}

//xのy乗を求める ※参考：10^18乗まで
ll my_pow(ll x, ll y) {
  ll sum = 1;

  while(y>0) {
    sum *= x;
    --y;
  }

  return sum;
}

/*考えを書くスペース

*/

/*おーじさんのやつ
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll>
#define m_p make_pair

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k,x2,y2;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
P p[ohara];
ll p_cou;
bool vi[ohara];
*/
//main.cpp----------------------------
#define MAX 100000

int n, m;
int a[101][101], b[101];
int c;

int main() {
  cin >> n >> m >> c;
  rep(i, m) cin >> b[i];
  rep(i, n) {
    rep(j, m) cin >> a[i][j];
  }
  int cnt = 0;
  int sum;
  rep(i, n) {
    sum = 0;
    rep(j, m) {
      sum += a[i][j]*b[j];
    }
    sum += c;
    if(sum>0) cnt += 1;
  }

  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
  string s; cin>>s;
  int n = s.size();
  rep(i,n){
    if(i%2){
      if(s[i]=='R') return cout<<"No"<<endl,0;
    }else{
      if(s[i]=='L') return cout<<"No"<<endl,0;
    }
  }
  cout << "Yes" <<endl;


  return 0;
}


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

typedef pair<double,double> pd;
vector<pd>vec;
vector<long>used;

bool op(pd p1,pd p2){
    if(p1.first*p2.second-p2.first*p1.second>0)return 1;
    return 0;
}
bool com(pd p1,pd p2){
    return p1.first==p2.first?p1.second>p2.second:p1.first<p2.first;
}

pd minu(pd p1, pd p2){
    return make_pair(p1.first-p2.first, p1.second-p2.second);
}

int main(){
    int n;
    while(cin>>n,n){
        vec.clear();
        used.clear();
        for(int i=0;i<n;i++){
            double x,y;char c;
            cin>>x>>c>>y;
            vec.push_back(make_pair(x, y));
        }
        sort(vec.begin(),vec.end(),com);
        pd last=minu(vec[1],vec[0]), cur;
        used.push_back(0);
        used.push_back(1);
        for(int i=0;i<vec.size();i++){
            cur=vec[i];
            if(find(used.begin(),used.end(),i)!=used.end())
                continue;
            while(op(last,minu(cur,vec[used[used.size()-1]]))){
                used.pop_back();
                last=minu(vec[used[used.size()-1]],vec[used[used.size()-2]]);
            }
            last=minu(cur,vec[used[used.size()-1]]);
            used.push_back(i);
        }
        for(long i=vec.size()-1;i>=0;i--){
            cur=vec[i];
            if(find(used.begin(),used.end(),i)!=used.end()&&i!=0)
                continue;
            while(op(last,minu(cur,vec[used[used.size()-1]]))){
                used.pop_back();
                last=minu(vec[used[used.size()-1]],vec[used[used.size()-2]]);
            }
            if(i!=0){
                last=minu(cur,vec[used[used.size()-1]]);
                used.push_back(i);
            }
        }
        cout<<vec.size()-used.size()<<endl;
    }
}

Measured memory_bytes: 1264
#include <bits/stdc++.h>
using namespace std;
int main()
{
  const double pi=3.1415926535;
  int a,b,x;
  double theta;
  cin>>a>>b>>x;
  if(a*a*b/2.0>x)
  {
    theta=pi/2.0-atan(2*x/((double)a*b*b));
  }
  else
  {
    theta=atan(2*(a*a*b-x)/((double)a*a*a));
  }
  cout<<fixed<<setprecision(10)<<theta*360/(2*pi)<<endl;
}

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

const ll mod = 1e9 + 7 ;
int main(){
 ll n ;
 cin >> n ;
 vector<ll> A(n) ;
 rep(i,n) cin >> A.at(i) ;
 ll sum = 0 ;
 ll ans = 0 ;
 rep(i,n){
     sum += A.at(i) ;
 } 
rep(i,n){
    sum -= A.at(i) ;
    ll tem = sum % mod ;
    ans += (A.at(i)*tem)%mod ;
    ans %= mod ;
}
cout << ans << endl; 
} 

Measured memory_bytes: 4828
import java.util.Scanner;
class Main{
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        if (a < 10 && b < 10){
            System.out.println(a * b);
        }else{
            System.out.println(-1);
        }
    }
}

Measured memory_bytes: 22740
import sys
input = sys.stdin.buffer.readline

N, Q = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N - 1)]
PX = [list(map(int, input().split())) for _ in range(Q)]

graph = [[] for _ in range(N + 1)]
for a, b in AB:
  graph[a].append(b)
  graph[b].append(a)
  
cost = [0] * (N + 1)
for p, x in PX:
  cost[p] += x
  
check = [0] * (N + 1)
stack = [1]
check[1] = 1

while stack:
  s = stack.pop()
  for g in graph[s]:
    if check[g] == 0:
      check[g] = 1
      cost[g] += cost[s]
      stack.append(g)
      
print(*cost[1:])

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

const int N = 205, inf = 1e9;



int n, m, c, d[10][10];
long long ans;
vector< pair< int, int > >g[10];


inline void dj(int x){
    d[x][x] = 0;
    set< pair< int, int > >q;
    q.insert(make_pair(0, x));
    while(!q.empty()){
        int v = q.begin()->second;
        q.erase(q.begin());
        for(auto to : g[v]){
            if(d[x][to.first] > d[x][v] + to.second){
                q.erase(make_pair(d[x][to.first], to.first));
                d[x][to.first] = d[x][v] + to.second;
                q.insert(make_pair(d[x][to.first], to.first));
            }
        }
    }
}

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> n >> m;
    for(int i = 0; i <= 9; i++){
        for(int j = 0; j <= 9; j++){
            cin >> c;
            d[i][j] = inf;
            g[i].push_back(make_pair(j, c));
        }
    }
    for(int i = 0; i <= 9; i++){
        dj(i);
    }
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            cin >> c;
            if(c != -1){
                ans += d[c][1];
            }
        }
    }
    cout << ans;
}


Measured memory_bytes: 384
k = int(input())
a, b = [int(x) for x in input().split()]
result = False
check = [x*k for x in range(0, 1000)]
for i in check:
    if (i >= a and i <= b):
        result = True
    else:
        continue

if result:
    print('OK')
else:
    print('NG')

Measured memory_bytes: 9216
n, a, b = map(int, input().split())
current = 1

cnt = 0

while current <= n:
    
    number = str(current)
    length = len(number)
    
    allsum = 0
    
    for i in range(length):
        allsum += int(number[i])
        
    if a <= allsum and allsum <= b:
        cnt += current
    
    current += 1

print(cnt)

Measured memory_bytes: 9012
#include <bits/stdc++.h>
#define speed_demon; ios_base::sync_with_stdio(0);
#define ll long long
using namespace std;
int main(){
	speed_demon;
	ll n,m,l=1;
	cin>>n>>m;
	while(n-m>0){
		l++;
		n-=m;
	}
	cout<<l;
}



Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue> //C++
#include <string> //C++
#include <iostream> //C++
#include <vector> //C++
#include <algorithm> //C++
using namespace std; //C++
#define rep(i, a, n) for (i = (a); i < (n); i++)



int main() 
{
	long long int x;
	cin >> x;

	long long int Ans = 0;
	long long int i;
  
  if (x == 1) {
		cout << "0" << endl;
		return 0;
	}

	rep(i, 1, x) Ans += i;

	cout << Ans << endl;
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define mp make_pair
#define INF 1e9

void init()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
}

int main()
{
    init();
    int n;
    cin>>n;
    int a;
    int ans=0;
    rep(i,n){
        cin>>a;
        if(a%2==1&&(i+1)%2==1)ans++;
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 3644
package main

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

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() int {
	n, err := strconv.Atoi(nextString())
	if err != nil {
		fmt.Printf("strconv.Atoi failed: %v\n", err)
	}
	return n
}

func stringifyArray(arr []int) string {
	return strings.TrimRight(fmt.Sprintf("%+v", arr)[1:], "]")
}

func main() {
	scanner.Split(bufio.ScanWords)

	nArrays := nextInt()
	nQueries := nextInt()

	arrays := make([][]int, nArrays)
	for i := 0; i < nArrays; i++ {
		arrays[i] = []int{}
	}

	for i := 0; i < nQueries; i++ {
		query := nextInt()
		iQuery := nextInt()

		if query == 0 {
			x := nextInt()
			arrays[iQuery] = append(arrays[iQuery], x)
		} else if query == 1 {
			fmt.Println(stringifyArray(arrays[iQuery]))
		} else if query == 2 {
			arrays[iQuery] = []int{}
		}
	}
}



Measured memory_bytes: 26204
### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline

    #n,m,k=map(int, readline().rstrip().split())
    #arr=list(map(int, readline().rstrip().split()))
    k=int(readline())
    ss=readline().rstrip()
    if len(ss) <= k:
        print(ss)
    else:
        print(ss[0:k]+"...")
    #yn(1)

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ----------------

Measured memory_bytes: 16160
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
const ll inf = 1e16;
const ll md = 1000000007;
ll aa[1005];
ll bb[1005];
ll cc[1005];

int main() {
  int x, y, z, k;
  cin >> x >> y >> z >> k;
  rep(i, x) cin >> aa[i];
  rep(i, y) cin >> bb[i];
  rep(i, z) cin >> cc[i];
  sort(aa, aa + x);
  sort(bb, bb + y);
  sort(cc, cc + z);
  priority_queue<vll> q;
  set<vll> fin;
  q.push({aa[x - 1] + bb[y - 1] + cc[z - 1], x - 1, y - 1, z - 1});
  rep(_, k) {
    vll v = q.top();
    q.pop();
    cout << v[0] << endl;
    ll i = v[1];
    ll j = v[2];
    ll h = v[3];
    if (i > 0 && fin.count({i - 1, j, h}) == 0) {
      q.push({aa[i - 1] + bb[j] + cc[h], i - 1, j, h});
      fin.insert({{i - 1, j, h}});
    }
    if (j > 0 && fin.count({i, j - 1, h}) == 0) {
      q.push({aa[i] + bb[j - 1] + cc[h], i, j - 1, h});
      fin.insert({{i, j - 1, h}});
    }
    if (h > 0 && fin.count({i, j, h - 1}) == 0) {
      q.push({aa[i] + bb[j] + cc[h - 1], i, j, h - 1});
      fin.insert({{i, j, h - 1}});
    }
  }
  return 0;
}


Measured memory_bytes: 1280
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>
#define pb push_back
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define rep(i,n) for(int i=0;i<n;i++)
#define INF (1<<20)
#define LLINF (1LL<<60)
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
    ll l, r;
    cin >> l >> r;
    ll ans = LLINF;
    for (ll i = l; i < r; i++)
    {
        for (ll j = i + 1; j <= r;j++){
            ans = min(ans, ((i % 2019) * (j % 2019)) % 2019);
            if(ans==0){
                cout<<'0';
                return 0;
            }
        }
    }
    cout << ans;
    return 0;
}


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

typedef long long ll;
typedef pair<int,int> P;
typedef map<int,int> M;
typedef vector<int> V;
typedef queue<int> Q;
typedef pair<long,long> PLL;
typedef map<long,long> MLL;
typedef vector<long long> VLL;
typedef vector<pair<int,int>> VP;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define MOD (1e9+7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
/*--------------------------------------------*/
int main(){
    int n;cin>>n;
    vector<string> s(n);
    rep(i,n)cin>>s[i];
    int m;cin>>m;
    vector<string> t(m);
    rep(i,m)cin>>t[i];
    sort(ALL(s));
    sort(ALL(t));
    int ans=0;
    rep(i,n){
        string tmp=s[i];
        int blue=0;
        int red=0;
        for(int j=i;j<n;j++){
            if(s[j]==tmp)blue++;
        }
        rep(k,m){
            if(t[k]==tmp)red++;
        }
        int temp=0;
        if(blue>red){
            temp=blue-red;
        }
        ans=max(ans,temp);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

struct UnionFind {
	const int V;
	// par[x] := xのroot
	vector<int> par;
	// sz[x] := xを含む集合のサイズ
	vector<int> sz;
	UnionFind(const int V) :
		V(V),
		par(vector<int>(V)),
		sz(vector<int>(V, 1))
		{
			for(int i = 0; i < V; ++i) par[i] = i;
		}
	bool unite(int x, int y) {
		x = root(x), y = root(y);
		if(same(x, y)) return false;
		if(y < x) swap(x, y);
		par[y] = x;
		sz[x] += sz[y];
		return true;
	}
	int root(int x) {
		if(par[x] == x) return x;
		return (par[x] = root(par[x]));
	}
	bool same(int x, int y) {
		return (root(x) == root(y));
	}
	int size(int x) {
		return sz[root(x)];
	}
};


vector<int> fd[100010];
vector<int> bc[100010];
int main() {
	int n, m, k; cin >> n >> m >> k;
	UnionFind uf(n);
	for(int i = 0; i < m; ++i) {
		int a, b; cin >> a >> b;
		--a, --b;
		fd[a].push_back(b);
		fd[b].push_back(a);
		uf.unite(a, b);
	}
	for(int i = 0; i < k; ++i) {
		int a, b; cin >> a >> b;
		--a, --b;
		bc[a].push_back(b);
		bc[b].push_back(a);
	}
	for(int i = 0; i < n; ++i) {
		int ans = uf.size(i);
		ans -= fd[i].size();
		for(int x : bc[i]) {
			if(uf.same(i, x)) {
				ans--;
			}
		}
		cout << ans - 1 << (i == n - 1 ? "\n" : " ");
	}
	return 0;
}

Measured memory_bytes: 12664
#include<stdio.h>
#define MAX 100000

typedef struct{
  int p,l,r;
}Node;
Node N [MAX];

int Depth(int i){//id　の深さ　上中
  int count=0;
  Node X=N[i];
  
  for(;X.p!=-1;count++)X=N[X.p];
  return count;
}

int Degree(int i){//子供の数　0-2
  int count=0;
  if(N[i].r!=-1)count++;
  if(N[i].l!=-1)count++;

  return count;
}

int Sibling(int i){//兄弟の id を返す
  int R,L;

  if(N[i].p==-1)return -1;
  L=N[N[i].p].l;
  R=N[N[i].p].r;

  return i!=L?L:R;
}

int Height(int i){//idの中下
  Node X=N[i];
  int a,b;
  a=b=0;
  
  if(X.r!=-1)a=Height(X.r)+1;//左右の子供をたどって長い方を高さとして採用
  if(X.l!=-1)b=Height(X.l)+1;
    
  return  a>=b ? a : b;
}



void Print(int i){
  int j;
  
  printf("node %d: ",i);
  printf("parent = %d, ",N[i].p);

  printf("sibling = %d, ",Sibling(i));
  printf("degree = %d, ",Degree(i));
  
  printf("depth = %d, ",Depth(i));
  printf("height = %d, ",Height(i));

  if(N[i].p==-1)printf("root\n");//親がいなかったらルート
  else if(N[i].l==-1&&N[i].r==-1)printf("leaf\n");//子供いなかったら葉
  else printf("internal node\n");//ほかはinternal
  return ;
}

int main(){
  int n;
  int i;
  int j;
  
  scanf("%d",&n);

  for(i=0;i<100000;i++){//INITIATE
    N[i].p = N[i].l = N[i].r = -1;
  }

  for(i=0;i<n;i++){//input
    scanf("%d",&j);
    scanf("%d",&N[j].l);
    scanf("%d",&N[j].r);
      
    if(N[j].l!=-1) N[N[j].l].p = j;//子供がいたら、そいつらの親おや決定
    if(N[j].r!=-1) N[N[j].r].p = j; 
  }
  
  
  for(i=0;i<n;i++){//idごとに必要
    Print(i);	
  }
  return 0;
}



Measured memory_bytes: 2972
import math
a,b = map(int,input().split())

x_a_min = a/0.08
x_a_max = (a+1)/0.08
x_b_min = b/0.1
x_b_max = (b+1)/0.1

if math.ceil(max(x_a_min,x_b_min))<math.ceil(min(x_a_max,x_b_max)):
    print(math.ceil(max(x_a_min,x_b_min)))
else:
    print(-1)

Measured memory_bytes: 3060
X, K, D = map(int, input().split())
import numpy as np
res = 0

count = abs(X) // D
pseudo = np.sign(X) * (abs(X) - count * D)

if abs(X) >= K * D:
    res = abs(abs(X) - K * D)
elif (K-count) % 2 == 0:
    res = abs(pseudo)
else:
    res = min(abs(pseudo + D), abs(pseudo - D))

print(res)

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

#ifdef LOCAL
#include "../dump.hpp"
#else
#define dump(...)
#define assert(...)
#endif

using namespace std;

#define rep(i,n) for(int i=0,i##_cond=(n);i<i##_cond;i++)
#define FOR(i,a,b) for(int i=(a),i##_cond=(b);i<i##_cond;i++)
#define ROF(i,a,b) for(int i=(a)-1,i##_cond=(b);i>=i##_cond;i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumulate(all(a),0)
#define sz(x) ((int)(x).size())
#define pb push_back
#define fst first
#define snd second

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main(){
#define int ll
  int a,b,x; cin >> a >> b >> x;
  if(a <= x and x <= a + b) cout << "YES\n";
  else cout << "NO\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>

using namespace std;

// #define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
// #define SIZE_OF_ARRAY(pro2) (sizeof(pro2)/sizeof(pro2[0]))

int main(){

    int n;
    cin >> n;
    int p[n];       //p_1はp[0]に対応
    for(int i=0;i<n;i++){
        cin >> p[i];
    }

    int max = -1;
    int max_i = -1;

    for(int k=0;k<n;k++){
        if(max < p[k]) {
            max = p[k];
            max_i = k;
        }
    }

    p[max_i] = p[max_i] / 2;
    int sum = 0;
    for(int j=0;j<n;j++){
        sum += p[j];
    }

    printf("%d", sum);

    // sort(pro1, pro1 + SIZE_OF_ARRAY(pro1));
    // sort(pro2, pro2 + SIZE_OF_ARRAY(pro2));

}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int H, W, i, j;
    
    while(1){
    cin >> H;
    cin >> W; 
    
    if(H==0 && W==0) break;
        for(i=0; i<H; i++){
            for(j=0; j<W; j++){
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
    }

    
    return 0;
    
}


Measured memory_bytes: 3080
void main() {
	auto ip = readAs!(ulong[]), a = ip[0], b = ip[1], x = ip[2];
	ulong f(ulong a) { return a == -1 ? 0 : a/x + 1; }
	(f(b) - f(a-1)).writeln;
}

// ===================================

import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
   long a,b,c,x,y;
   cin >> a >> b >> c >> x >> y;
   long ans = a * x + b * y;
   for(long i = 1;i <= max(x,y);i++){
        ans = min(ans,c * 2 * i + a * max(0l,x - i) + b * max(0l,y - i));
   }
   cout << ans << endl;
}


Measured memory_bytes: 256
n, A, B, C = map(int, input().split())
l = [int(input()) for _ in range(n)]

INF = 10**9

def dfs(cur, a, b, c):
    if cur == n:
        return abs(a-A) + abs(b-B) + abs(c-C) - 30 if min(a, b, c)>0 else INF

    ret0 = dfs(cur + 1, a, b, c)
    ret1 = dfs(cur + 1, a + l[cur], b, c) + 10
    ret2 = dfs(cur + 1, a, b + l[cur], c) + 10
    ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10
    return min(ret0, ret1, ret2, ret3)

print(dfs(0, 0, 0, 0))

Measured memory_bytes: 3064
#!/usr/bin/env python
# coding: utf-8
#

def return_H(x, y, h, cx, cy):
    retval_H = h + abs(x - cx) + abs(y - cy)
    return retval_H

def main(n, l):
    for cx in range(0, 101):
        for cy in range(0, 101):
            retl = []
            maxH = []
            for x, y, h in l:
                if h != 0:
                    retl.append(return_H(x, y, h, cx, cy))
                elif h == 0:
                    maxH.append(return_H(x, y, h, cx, cy))
            if len(maxH) > 0:
                if len(set(retl)) == 1 and retl[0] <= min(maxH):
                    print('{} {} {}'.format(cx, cy, retl[0]))
                    return
            else:
                if len(set(retl)) == 1:
                    print('{} {} {}'.format(cx, cy, retl[0]))
                    return
    
if __name__ == '__main__':
    try:
        n  = int(input().strip())
        l = []
        for i in range(n):
            l.append(list(map(int, input().strip().split(' '))))
        main(n, l)
    except EOFError:
        pass


Measured memory_bytes: 3064
#!/usr/bin/env python3
import collections as cl
import sys


def II():
    return int(sys.stdin.readline())


def MI():
    return map(int, sys.stdin.readline().split())


def LI():
    return list(map(int, sys.stdin.readline().split()))


def main():
    a, b, c = MI()
    k = II()

    while k > 0:
        if a >= b:
            b *= 2
        elif b >= c:
            c *= 2

        k -= 1

    print("Yes" if c > b > a else "No")


main()


Measured memory_bytes: 64744
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define double long double
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
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;}

int main(){
  ll N,sum=0,ans=0;
  cin>>N;
  vector<ll> A(N);
  bitset<MAX> DP;
  DP[0]=1;
  REP(i,N){
    cin>>A[i];
    sum+=A[i];
    DP|=(DP<<A[i]);
  }
  for(ans=(sum+1)/2; ans<MAX; ++ans){
    if(DP[ans]) break;
  }
  co(ans);
  return 0;
}

Measured memory_bytes: 2176
#!/usr/bin/env python3
#AGC29 B

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
a = LI()
a.sort()
f = defaultdict(lambda : 0)
for i in a:
    f[i] += 1
ans = 0
lst = [1<<i for i in range(32)]
for i in a[::-1]:
    if not f[i]:
        continue
    f[i] -= 1
    for j in lst:
        tmp = j - i
        if tmp <= 0:
            continue
        if f[tmp]:
            ans += 1
            f[tmp] -= 1
            break
print(ans)

Measured memory_bytes: 152224
import fractions

def gcd(n1,n2):
  if n1 == 0:
    return n2
  elif n2 == 0:
    return n1
  else:
    return fractions.gcd(n1,n2)

n = int(input())
a = list(map(int,input().split()))
l = [0]*(n+1)
r = [0]*(n+1)
for i in range(n+1):
  if i != 0:
    l[i] = gcd(l[i-1],a[i-1])
    r[n-i] = gcd(r[n+1-i],a[n-i])
m = [gcd(l[i],r[i+1]) for i in range(n)]
print(max(m))

Measured memory_bytes: 16148
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll zero = 0;
const ll INF = 10000000000000000; //10^16
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;

int top(int n){
    int tmp;
    while(n > 0){
        tmp = n % 10;
        n = n / 10;
    }
    return tmp;
}

int main(void){
    int N;
    cin >> N;
    vector<vector<ll>> c(10, vector<ll> (10)); //c_ij = 先頭がiで末尾がjのやつの個数
    
    int tmp0, tmp1;
    for(int i = 1; i <= N; i++){
        tmp0 = top(i); //log Nかかる
        tmp1 = i % 10;
        if(tmp1 != 0){
            c.at(tmp0).at(tmp1)++;
        }
    }
    
    ll ans = 0;
    for(int i = 1; i <= 9; i++){
        for(int j = 1; j <= 9; j++){
            ans += c.at(i).at(j) * c.at(j).at(i);
        }
    }
    
    printf("%lld\n", ans);
    
    
}




Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <stdio.h>
#include <vector>
#include <string>
#include <map>
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
//#define rep(i, n) for(int (i) = 0, TmP = (n); (i) < (int)TmP ; ++(i))
//#define int long long
#define asort(v, n) sort((v), (v + n)) //Using array
#define vsort(v) sort((v).begin(), (v).end()) // Using vector
#define vint vector<int>

using namespace std;

signed main(){
  string a;
  cin >> a;
  if(a[0] == '7' || a[1] == '7' || a[2] == '7')cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3596
while True:
    n,x=map(int,input().split())
    if n==0 and x==0:
        break
    else:
        cnt=0
        for i in range(1,x//3):
            a=i
            for j in range(i+1,(x-a)//2+1):
                b=j
                c=x-(a+b)
                if c<=n and a<b<c:
                    cnt+=1
        print(cnt)



Measured memory_bytes: 5592
#include <iostream>
#include <stdio.h>
#include <vector>

typedef long long ll;

#define rep(i,n) for(int i = 0; i < n; i++)
#define debug(x) cerr << #x << ": " << x << "\n";

using namespace std;
 
const ll INF = ll(1e18)+1;
const double PI=3.14159265358979323846;

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

  for(int i=A; i<=B; i++){
    if(i%K == 0){
      cout << "OK" << endl;
      return 0;
    }
  }
  cout << "NG" << endl;
  return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
} 

vector <vector <char> > v;
int r,c;
int bfs(int i,int j);
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    r=nxt(),c=nxt();
    vector <char> row(c);
    v.resize(r,row);
    for(int i=0;i<r;i++)
        for(int j=0;j<c;j++)
            cin>>v[i][j];
    int test=0;
    for(int i=0;i<r;i++)
        for(int j=0;j<c;j++)
            if(v[i][j]=='.'){
                test=max(test,bfs(i,j));
                //cout<<i<<" "<<j<<" "<<test<<endl;
            }
        cout<<test<<endl;
    
  

    return 0;   
}

int bfs(int i,int j)
{
    vector <vector <int> > visited;
    vector <int> row;
    row.resize(c,-1);
    visited.resize(r,row);
    visited[i][j]=0;
    queue <pair<int,int> > q;
    q.push({i,j});
    int ans=0;
    while(q.size()>0)
    {
        pair <int,int> p=q.front();
        q.pop();
        int x=p.first;
        int y=p.second;
        if(x-1>=0&&v[x-1][y]=='.'&&visited[x-1][y]==-1)
        {
            visited[x-1][y]=visited[x][y]+1;
            q.push({x-1,y});
            ans=max(ans,visited[x-1][y]);
        }
        if(x+1<r&&v[x+1][y]=='.'&&visited[x+1][y]==-1)
        {
            visited[x+1][y]=visited[x][y]+1;
            q.push({x+1,y});
            ans=max(ans,visited[x+1][y]);
        }
        if(y-1>=0&&v[x][y-1]=='.'&&visited[x][y-1]==-1)
        {
            visited[x][y-1]=visited[x][y]+1;
            q.push({x,y-1});
            ans=max(ans,visited[x][y-1]);
        }
        if(y+1<c&&v[x][y+1]=='.'&&visited[x][y+1]==-1)
        {
            visited[x][y+1]=visited[x][y]+1;
            q.push({x,y+1});
            ans=max(ans,visited[x][y+1]);
        }

    }
    return ans;

}


 
 


Measured memory_bytes: 256
#include <cstdio>
int n, a, m, d, mx, mc;
int main() {
	scanf("%d%*d%d", &n, &m);
	for(int i=1; i<n; i++) {
		scanf("%d", &a);
		d = a-m;
		if(d > mx) mx = d, mc = 1;
		else if(d == mx) mc++;
		if(a < m) m = a;
	}
	printf("%d", mc);
	return 0;
}

Measured memory_bytes: 128
/*QAQ三连：以前的题都补了吗，今天的题都做了吗，不会的算法都会了吗*/
/*金桔退役三连：退役选手不学不会不练*/
#include <bits/stdc++.h>
#define LDQ 1000000007
#define QAQ 0x3f3f3f3f
#define PI 3.14159265358979323846
using namespace std;
int main()
{
    int i;
    char s[100001];
    scanf("%s",s);
    if(strlen(s)%2==0)
    {
        if(s[0]==s[strlen(s)-1])
        {
            printf("First");
        }
        else
        {
            printf("Second");
        }
    }
    else
    {
        if(s[0]==s[strlen(s)-1])
        {
            printf("Second");
        }
        else
        {
            printf("First");
        }
    }
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,ans=0;
  string s,t;
  cin>>n>>s>>t;
  for(int i=0;i<n;i++){
    bool f=1;
    for(int j=0;j<=i;j++)
      if(t[j]!=s[n-i-1+j])f=0;
    if(f)ans=i+1;
  }
  cout<<2*n-ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <math.h>

typedef long long int ll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;

using namespace std;

int D[31][31];
int c[505][505];

ll d0[31], d1[31], d2[31];

ll diff(vector<int> v, int col)
{
	ll sum = 0;
	REP(i, v.size())
	{
		sum += D[v[i]][col];
	}
	return sum;
}

int main()
{
	int N, C;
	cin >> N >> C;
	REP(i, C)
	{
		REP(j, C)
		{
			cin >> D[i][j];
		}
	}
	vector<int> c0, c1, c2;
	REP(i, N)
	{
		REP(j, N)
		{
			cin >> c[i][j];
			c[i][j]--;
			if ((i + j + 2) % 3 == 0)
			{
				c0.push_back(c[i][j]);
			}
			else if ((i + j + 2) % 3 == 1)
			{
				c1.push_back(c[i][j]);
			}
			else
			{
				c2.push_back(c[i][j]);
			}
		}
	}

	REP(i, C)
	{
		d0[i] = diff(c0, i);
		d1[i] = diff(c1, i);
		d2[i] = diff(c2, i);
	}

	ll min = 1000 * 500 * 500 + 1;

	REP(i, C)
	{
		REP(j, C)
		{
			if (i == j)continue;
			REP(k, C)
			{
				if (i == k || j == k)continue;
				min = std::min(min, d0[i] + d1[j] + d2[k]);
			}
		}
	}

	cout << min << endl;

	return 0;
}

Measured memory_bytes: 2800
#include<cstdio>
#include<algorithm>
#include<cstring>
#define MN 2005
using namespace std;
int n,T[1<<12],f[MN][MN],col[2][MN<<1];
void add(int x,int y){while(x<=2*n)T[x]+=y,x+=(x&(-x));}
int que(int x){int res=0;while(x)res+=T[x],x-=(x&(-x));return res;}
int main(){
	scanf("%d",&n);char ch[5];int x;
	for(int i=1;i<=2*n;i++)scanf("%s%d",ch,&x),col[ch[0]=='B'][x]=i;memset(f,0x3f,sizeof(f));f[0][0]=0;
	for(int i=0;i<=n;i++){
		memset(T,0,sizeof(T));
		for(int j=1;j<=2*n;j++)add(j,1);
		for(int j=1;j<=i;j++)add(col[0][j],-1);
		for(int j=0;j<=n;j++){
			if(j)add(col[1][j],-1);
			if(j)f[i][j]=min(f[i][j],f[i][j-1]+que(col[1][j]));
			if(i)f[i][j]=min(f[i][j],f[i-1][j]+que(col[0][i]));
		}
	}printf("%d\n",f[n][n]);
}



Measured memory_bytes: 15872
N = int(input())

def aaa(N):
    ans = 0
    if N < 105:
        print(ans)
        return

    odd_list = [i for i in range(1, N+1) if i % 2 ==  1]
    odd_list2 = [i for i in range(105, N+1) if i % 2 ==  1]

    for j in odd_list2:
        c = 0
        for i in odd_list:
            if j % i == 0:
                c += 1
                if c == 8:
                    ans += 1
                    break
    print(ans)
aaa(N)


Measured memory_bytes: 3064
#include<stdio.h>
#define N 110
#define INF 10000000
#define COM 1
#define INCOM -1
int judg[N]={-1};
int A[N][N]={2001};
int main()
{
  int i,n,j,k,min=INF,all=0,roc=0,cnt=0,cnt2=0;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      scanf("%d",&A[i][j]);
      if(A[i][j]==-1){
        A[i][j]=INF;
      }
    }
  }
  judg[1]=COM;
  while(1){
    cnt2++;
    for(i=1;i<=n;i++){
      if(judg[i]==COM)cnt++;
      if(cnt==n)break;
      if(judg[i]==COM){
      for(j=1;j<=n;j++){
        if(A[i][j]==-1)continue;
        if(judg[j]!=COM){
        if(A[i][j]<min){
          min=A[i][j];
          roc=j;
          //printf("i=%d j=%d min=%d\n",i,j,min);
        }
        }
      }
      }
    }
       if(cnt==n)break;
    cnt=0;
    all+=min;
    //printf("min=%d ",min);
    //printf("all=%d\n",all);
    judg[roc]=COM;
    min=INF;
    //for(i=1;i<=n;i++)printf("judg[%d]=%d\n",i,judg[i]);
    //printf("\n");
  }
  printf("%d\n",all);
  return 0;
}


Measured memory_bytes: 2060