akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
const int MAXN = 200000 + 7;

vector<int> link[MAXN];

int main() {
  #ifdef LOCAL
    freopen("data.in", "r", stdin);
    freopen("data.out", "w", stdout);
  #endif
  int n, m;
  while(scanf("%d %d", &n, &m) != EOF) {
    int u, v;
    while(m--) {
      scanf("%d %d", &u, &v);
      link[u].push_back(v);
      link[v].push_back(u);
    }
    bool valid = false;
    for(int i = 0; i < link[1].size(); ++i) {
      int v = link[1][i];
      for(int j = 0; j < link[v].size(); ++j) {
        if(link[v][j] == n) {
          valid = true;
          break;
        }
      }
    }
    valid ? puts("POSSIBLE") : puts("IMPOSSIBLE");
    for(int i = 1; i <= n; ++i) link[i].clear();
  }
  return 0;
}

Measured memory_bytes: 12016
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define repA(i, a, n) for(int  i = a; i <= (n); ++i)
#define all(x) x.begin(), x.end()
#define sz(x) (int) (x).size()
#define fill(a) memset(a, 0, sizeof(a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define endl '\n'
#define init(n) int n;cin>>n;int a[n];rep(i,n)cin>>a[i];
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long int> vll;
typedef vector<pii> vii;
ll p=1000000007;
# define pi 3.141592
int b,c;
inline double f(double x){
	double v=(x*x+b*x+c)/sin(x);
	return v;
}
ll power(ll a,ll x){
    ll r=1;
    while(x!=0){
        if(x%2==1){
            r=r*a;
        }
        a=a*a;
        x=x/2;
    }
    return r;
}
void dfs(int i,vector<int> *graph,int *visit,vector<int> &temp ){
	temp.pb(i);
	visit[i]=1;
	for(auto j:graph[i]){
		if(visit[j]==0){
			dfs(j,graph,visit,temp);
		}
	}
	return ;
}
int main() {
  
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);
    int T=1;
    // cin>>T;
    while(T--){
    	int n,m,k;cin>>n>>m>>k;
    	map<int,int> ma;
    	int ans[n+1]={0};
    	vector<int> graph[n+1];
    	vector<int> block[n+1];
    	rep(i,m){
    		int a,b;cin>>a>>b;
    		graph[a].pb(b);
    		graph[b].pb(a);
    	}
    	rep(i,k){
    		int a,b;cin>>a>>b;
    		block[a].pb(b);
    		block[b].pb(a);
    	}
    	int visit[n+1]={0};
    	repA(i,1,n){
    		if(visit[i]==0){
    			vector<int> temp;
    			dfs(i,graph,visit,temp);
    			map<int,int> ma;
    			for(auto j:temp){
    				ma[j]=1;
    			}
    			for(auto j:temp){
    				int val=temp.size();val--;
    				map<int,int> maa;
    				for(auto k: graph[j]){
    					maa[k]=1;val--;
    				}
    				for(auto k: block[j]){
    					if(ma.find(k)!=ma.end()&&maa.find(k)!=ma.end()){
    						val--;
    					}
    				}
    				ans[j]=val;
    			}
    		}
    		cout<<ans[i]<<" ";
    	}
    } 	
    return 0;   
}	

Measured memory_bytes: 22000
# import math
# import bisect
# import heapq
# from collections import deque

def main():
    n, k = map(int, input().split())

    h = list(map(int, input().split()))
    inf = 10**7
    d = [inf] * n
    d[0] = 0

    for j in range(1, n):
        p = [d[i] + abs(h[j] - h[i]) for i in range(max(0, j - k), j)]

        d[j] = min(p)

    print(d[-1])

if __name__ == "__main__":
    main()

Measured memory_bytes: 13980
N,K = [int(c) for c in input().split()]
h = [int(c) for c in input().split()]

dp=[0]*N
for i in range(1,N):
    dp[i] = min([dp[j] + abs(h[i]-h[j]) for j in range(max(0,i-K),i) ])
print(dp[-1])



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

  using namespace std;

  #pragma comment(linker, "/stack:200000000")
  #pragma GCC optimize("Ofast")
  #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
  #pragma GCC optimize("-ffloat-store")

  #define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define int long long
  #define endl "\n"

  #define sz(a) ((int)(a).size())
  #define all(v) (v).begin(), (v).end()
  #define tr(c, it) for (auto(it) = (c).begin(); (it) != (c).end(); it++)
  #define pres(c, val) ((c).find(val) != (c).end())      //
  #define cpres(c, val) (find(all(c), val) != (c).end()) //

  #define pb push_back
  #define mp make_pair
  #define F first
  #define S second

  #define forf(i, a, b) for (int i = (a); i < (b); i++)
  #define forb(i, a, b) for (int i = (b); i >= (a); i--)
  #define fo(i, n) forf(i, 0, n)
  #define fob(i, n) forb(i, 0, n - 1)

  typedef vector<int> vi;
  typedef pair<int, int> pii;
  typedef vector<pair<int, int>> vpii;

  const int INF = 9e18;
  // const int N = 1e9 + 7;
  const int N = 998244353;

  const auto start_time = std::chrono::high_resolution_clock::now();

  void zark() {
    #ifdef ZARK
    auto end_time = std::chrono::high_resolution_clock::now();
    std::chrono::duration<double> diff = end_time - start_time;
    cerr << "Time Taken : " << diff.count() << "s\n";
    #endif
  }

  #ifdef ZARK
  #include "/home/aranjan/Desktop/CP/header.h"
  #else
  #define dbg(args...)
  #endif

  /* ------------------ Actual Coding Starts ------------------ */

  bool ispow5(int n) {
    int x = pow(n, 0.2);
    return x*x*x*x*x == n;
  }

  int com(vi a, vi b) {
    int n = sz(a);
    int cnt = 0;
    int i = 0, j= 0;
    while(i < n && j < n) {
      if(a[i] > b[j]) j++;
      else if(a[i] < b[j]) i++;
      else {
        int v = a[i];
        int a1 = 0, a2 = 0;
        while(a[i] == v && i < n) i++, a1++;
        while(b[j] == v && j < n) j++, a2++;
        cnt += a1*a2;
      }
    }
    return cnt;
  }

  void solve() {
    int n;
    cin >> n;
    vi a(n);
    fo(i, n) cin >> a[i];
    vi b, c;
    fo(i, n) b.pb(i+a[i]);
    fo(i, n) c.pb(i-a[i]);
    sort(all(b));
    sort(all(c));
    dbg(b);
    dbg(c);
    cout << com(b, c) << endl;
  }

  int32_t main() {
    fastio;
    #ifdef ZARK
    freopen("input.in", "r", stdin);
    #endif

    // freopen("txt.in", "r", stdin);
    // freopen("txt.out", "w", stdout);
    // cout << fixed << setprecision(35);

    solve();
    zark();
    return 0;
  }


Measured memory_bytes: 11124
import sys
sys.setrecursionlimit(10000)

N,X = map(int, input().split())

ans = 0
for n in range(N,-1,-1):
  if X > (2**(n+2) - 3) / 2 :
    ans += 2**n #- 1 + 1
    X = X - (2**(n+1) - 3) - 2
  else:
    X -= 1
print(ans)

Measured memory_bytes: 3060
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n,d = LI()
    d *= d
    ans = 0
    for _ in range(n):
        x,y = LI()
        if x**2 + y**2 <= d:
            ans += 1
    print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 68724
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <ctime>
#include <map>
#include <queue>
#include <cstdlib>
#include <string>
#include <climits>
#include <set>
#include <vector>
using namespace std;
inline int read(){
	int k=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){k=k*10+ch-'0';ch=getchar();}
	return k*f;
}
inline void write(int x){
	if(x<0)putchar('-'),x=-x;
	if(x>9)write(x/10);putchar(x%10+'0');
}
inline void writeln(int x){
	write(x);puts("");
}
set<int>s;
int main()
{
	int n=read();
	for(int i=1;i<=n;i++){
		int x=read();
		if(!s.count(x))s.insert(x);
		else s.erase(s.find(x));
	}
	writeln(s.size());
	return 0;
}

Measured memory_bytes: 4864
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i ,n) for(int i = 0 ; i < (n) ; i ++ )
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using vin=vector<int>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;

int main() {
  ll n,m;
  cin>>n>>m;
  n-=2;
  m-=2;
  cout<<abs(n*m)<<endl;
}

Measured memory_bytes: 256
N = int(input())
S = input()
s1 = set()
s2 = set()
s3 = set()

for x in S:
    for y in s2:
        tmp = y+x
        if tmp not in s3:
            s3.add(tmp)
    for y in s1:
        tmp = y+x
        if tmp not in s2:
            s2.add(tmp)
    if x not in s1:
        s1.add(x)

print(len(s3))


Measured memory_bytes: 3188
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);  
	cin.tie(NULL);
	int n,m;cin>>n>>m;
	int arr[n];ll sum=0;
	for(int i=0;i<n;i++){
		int a;cin>>a;
		arr[i] = a;
		sum += a;
	}
	sort(arr,arr+n);
	if(4*m*arr[n-m]<sum){
		cout<<"No"<<endl;
	}
	else{
		cout<<"Yes"<<endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <string>
#define ll long long

using namespace std;
typedef pair<int, int> P;

int main()
{
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max(max(a * c, a * d), max(b * c, b * d)) << endl;
    return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define P pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
#define inf 1000000000
#define mod 1000000007
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
int kaijo(int n){
	int ans=1;
	for(int i=2;i<=n;i++){
		ans*=i;
		ans%=mod;
	}
	return ans;
}
int modpow(int a,int b){
	if(b==0)return 1;
	if(b%2)return modpow(a,b-1)*a%mod;
	return modpow(a,b/2)*modpow(a,b/2)%mod;
}
int m,k;
signed main(){
	cin>>m>>k;
	if(k>=(1<<m)){
		puts("-1");
		return 0;
	}
	if(k==0){
		rep(i,(1<<m))cout<<i<<" "<<i<<" ";
		cout<<endl;
		return 0;
	}
	int cnt=0;
	rep(i,(1<<m))if(i!=k)cnt^=i;
	if(cnt!=k){
		puts("-1");
		return 0;
	}
	rep(i,(1<<m)){
		if(i!=k)cout<<i<<" ";
	}
	cout<<k<<" ";
	for(int i=(1<<m)-1;i>=0;i--){
		if(i!=k)cout<<i<<" ";
	}
	cout<<k<<endl;
	return 0;
}


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

int main(){
  string S,T;cin >> S >> T;
  if(S[0]==T[2]&&S[1]==T[1]&&S[2]==T[0]){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 * @throws NumberFormatException 
	 */
	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		
		Node[] heap = new Node[n+1];
		String[] tmpArray = br.readLine().split(" ");
		for(int i = 1; i <= n ;i++){
			heap[i] = new Node(Integer.parseInt(tmpArray[i - 1]));
		}
		
		for(int i = 1; i <= n ;i++){
			if(2*i < heap.length) heap[i].left = heap[2*i];
			if(2*i + 1 < heap.length) heap[i].right = heap[2*i + 1];
			heap[i].parent = heap[i/2];
		}
		
		for(int i = 1; i <= heap.length - 1 ; i++){
			System.out.print("node " + i + ": key = " + heap[i].key + ", ");
			if(heap[i].parent != null){
				System.out.print("parent key = " + heap[i].parent.key + ", ");
			}
			if(heap[i].left != null){
				System.out.print("left key = " + heap[i].left.key + ", ");
			}
			if(heap[i].right != null){
				System.out.print("right key = " + heap[i].right.key + ", ");
			}
			System.out.println();
		}
		
	}

}

class Node {
	int key;
	Node left;
	Node right;
	Node parent;
	
	public Node(int key){
		this.key = key;
		left = null;
		right = null;
		parent = null;
	}
}

Measured memory_bytes: 25488
s = int(input())

sec = s % 60
min =s // 60 #may be more than 60
hr = min // 60
min = min % 60

# line 3-6 can be replace with 9-11
hr = s // 3600
min = (s // 60) % 60
sec = s % 60

print(hr, min, sec, sep=':')


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

int main() {
    int n;
    cin >> n;
    if(n/1000 == n%1000/100 && n%1000/100 == n%100/10){
        cout << "Yes" << endl;
    } else if(n%1000/100 == n%100/10 && n%100/10 == n%10){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

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

int main() {
  int N;
  cin >> N;
  vector<long> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);

  for (int i = 0; i < N; i++) {
    if (A.at(i) == 0) return cout << 0 << "\n", 0;
  }

  long mx = 1e18;
  cpp_int ans = 1;
  for (int i = 0; i < N; i++) {
    ans *= A.at(i);
    if (ans > mx) return cout << -1 << "\n", 0;
  }
  cout << ans << "\n";
}

Measured memory_bytes: 4096
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i <= n; i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100000;

int main() {
	int n;
	cin >> n;
	vector<ll> v(n + 1, -1);
	v[n] = INFL;
	rep(i, n) {
		ll a;
		cin >> a;
		int j = lower_bound(v.begin(), v.end(), a) - v.begin() - 1;
		v[j] = a;
	}
	int ans = 0;
	for(int i = n - 1; i >= 0; i--) {
		if(v[i] == -1) break;
		else ans++;
	}
	cout << ans << endl;
}


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

typedef long long ll;
const ll INF = 1LL<<60, MOD = 1e9 + 7;
const double EPS = 1e-9, PI = 3.141592653589793;
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define all(v) (v).begin(), (v).end()
#define fi first
#define se second
#define m_p make_pair

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll a,b;
    cin >> a >> b;
    if(a>=10 || b>=10){
        cout << -1 << endl;
    }else{
        cout << a*b << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int l,r,d,count=0;
	scanf("%d %d %d", &l, &r, &d);
	
	for(int j=1; j<=100; j++){
		if(d*j>=l && d*j<=r){
			count++;
		}  
	}	
	
	
	printf("%d\n", count);
	
	return 0;
}

Measured memory_bytes: 1684
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

int main(){
  int n,a,b,c,d;
  cin>>n>>a>>b>>c>>d;
  a--;b--;c--;d--;
  string s;
  cin>>s;
  bool flag=false;
  if(d<c){
    for(int i=b+1;i<=min(d,n-2);i++){
      if(s[i]=='#' && s[i+1]=='#'){
        cout<<"No"<<endl;
        return 0;
      }
    }
    for(int i=b;i<=d;i++){
      if(i-1>=0 && i+1<n && s[i-1]=='.' && s[i+1]=='.' && s[i]=='.'){
        flag=true;
        break;
      }else{
        continue;
      }
    }
    if(!flag){
      cout<<"No"<<endl;
      return 0;
    }
    for(int i=a+1;i<=min(c,n-2);i++){
      if(s[i]=='#' && s[i+1]=='#'){
        cout<<"No"<<endl;
        return 0;
      }
    }
    cout<<"Yes"<<endl;
  }else{
    for(int i=b+1;i<=min(d,n-2);i++){
      if(s[i]=='#' && s[i+1]=='#'){
        cout<<"No"<<endl;
        return 0;
      }
    }
    for(int i=a+1;i<=min(c,n-2);i++){
      if(s[i]=='#' && s[i+1]=='#'){
        cout<<"No"<<endl;
        return 0;
      }
    }
    cout<<"Yes"<<endl;
  }
  return 0;
}


Measured memory_bytes: 640
#exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE']

def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def sum(a) a.inject(:+) end

def big(a,b) return (a>b)? a:b end

def small(a,b) return (a<b)? a:b end

def j(a,ind)
  hm = [0,@v-@p+1-(@n-ind)].max
  sp = ind - @p +1
  am = sp - hm
  spc = am*@m
  f = true
  buf = a[ind] + @m
  a[(@p-1)...ind].each do |d|
    if(d > buf)
      return false
    end
    spc -= d-a[ind]
    if(spc < 0)
      return false
    end
  end
  return f
end

def b_ser(a,l,r)
  mid = (l + r)/2
  if(l==r-1)
    return l
  elsif(j(a,mid))
    return b_ser(a,mid, r)
  else  #j(mid) == false
    return b_ser(a,l, mid)
  end
end

n,m,v,p = inp
a = inp.sort.reverse + [-1e20]
b = a[p-1]
@b = b
@m = m
@n = n
@v = v
@p  = p

p b_ser(a,0,n+1)+1

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

string s, t[5] = {"hi", "hihi", "hihihi", "hihihihi", "hihihihihi"};
bool f = 0;

int main()
{
	cin >> s;

	for (int i = 0; i < 5; i++)
		if (t[i] == s)
			f = 1;

	if(f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}


Measured memory_bytes: 256
# Aizu Problem 00137: Middle Square Method
#
import sys, math, os, copy

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


def middle_square(k):
    for step in range(10):
        k = (k**2 // 100) % 10000
        print(k)
        
    
N = int(input())
for case in range(1, N + 1):
    print("Case %d:" % case)
    k = int(input())
    middle_square(k)

Measured memory_bytes: 8284
from collections import Counter

N = int(input())
counter = Counter()

for i in range(N):
    s = input()
    lst = []
    for c in s:
        lst.append(c)
    lst.sort()
    lst = "".join(lst)
    counter[lst] += 1

cnt = 0

for v in counter.values():
    cnt += (v*(v-1))//2

print(cnt)

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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  int N, MA, MB; scanf("%d %d %d", &N, &MA, &MB);
  vector<int> A(N), B(N), C(N);
  for (int i = 0; i < N; ++i) {
    scanf("%d %d %d", &A[i], &B[i], &C[i]);
  }
  vector<vector<vector<int>>> dp(N + 5, vector<vector<int>>(405, vector<int>(405, INF)));
  dp[0][0][0] = 0;
  for (int i = 0; i < N; ++i) {
    for (int a = 0; a <= 400; ++a) {
      for (int b = 0; b <= 400; ++b) {
       dp[i + 1][a][b] = min(dp[i + 1][a][b], dp[i][a][b]);
        if (a - A[i] >= 0 and b - B[i] >= 0) {
          dp[i + 1][a][b] = min(dp[i][a][b], dp[i][a - A[i]][b - B[i]] + C[i]);
        }
      }
    }
  }

  int ans = INF;
  for (int a = 1; a <= 400; ++a) {
    for (int b = 1; b <= 400; ++b) {
      if (dp[N][a][b] == INF) { continue; }
      if (a * MB == b * MA) {
        ans = min(ans, dp[N][a][b]);
      }
    }
  }
  if (ans == INF) { ans = -1; }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 30336
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int a[222222];
int cnt[222222];

void proceed(int n)
{
	memset(cnt,0,sizeof(cnt));
	for(int i=0;i<n;i++)
	{
		int l = max(0,i-a[i]);
		int r = min(n-1,i+a[i]);
		cnt[l]++;
		cnt[r+1]--;
	}
	for(int i=1;i<=n;i++) cnt[i]+=cnt[i-1];
	for(int i=0;i<n;i++) a[i]=cnt[i];
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n,k; cin>>n>>k;
	for(int i=0;i<n;i++) cin>>a[i];
	for(int i=0;i<k;i++)
	{
		proceed(n);
		int mn=int(1e9);
		for(int j=0;j<n;j++) mn=min(mn,a[j]);
		if(mn>=n) break;
	}
	for(int i=0;i<n;i++)
	{
		cout<<a[i];
		if(i+1<n) cout<<' ';
	}
	cout<<'\n';
}	


Measured memory_bytes: 5320
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  double xs,ys,xt,yt;cin>>xs>>ys>>xt>>yt;
  ll n;cin>>n;
  double x[n],y[n],r[n];
  for(ll i=0;i<n;i++)cin>>x[i]>>y[i]>>r[i];
  double d[n][n];
  for(ll i=0;i<n;i++){
    for(ll j=i;j<n;j++){
      d[i][j]=max((double)0,pow(pow(x[i]-x[j],2)+pow(y[i]-y[j],2),0.5)-r[i]-r[j]);
      d[j][i]=d[i][j];
    }
  }
  for(ll i=0;i<n;i++){
    for(ll j=0;j<n;j++){
      for(ll k=0;k<n;k++){
        d[j][k]=min(d[j][k],d[j][i]+d[i][k]);
      }
    }
  }
  double ans=pow(pow(xt-xs,2)+pow(yt-ys,2),0.5);
  for(ll i=0;i<n;i++){
    for(ll j=0;j<n;j++){
      double kyo=max((double)0,pow(pow(x[i]-xs,2)+pow(y[i]-ys,2),0.5)-r[i]);
      double kyoo=max((double)0,pow(pow(x[j]-xt,2)+pow(y[j]-yt,2),0.5)-r[j]);
      ans=min(ans,kyo+kyoo+d[i][j]);
    }
  }
  cout<<fixed<<setprecision(10)<<ans<<endl;
}

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

int N, A[3][3], b[10];
bool appear[3][3];

int main(){
  for(int i=0;i<3;++i){
    for(int j=0;j<3;++j) cin >> A[i][j];
  }

  cin >> N;
  for(int i=0;i<N;++i) cin >> b[i];
  for(int i=0;i<N;++i){
    for(int j=0;j<N;++j){
      appear[i][j] = false;
      for(int k=0;k<N;++k){
        if(A[i][j] == b[k]) appear[i][j] = true;
      }
    }
  }

  string ANS = "No";
  for(int i=0;i<3;++i){
    if(appear[i][0] and appear[i][1] and appear[i][2]) ANS = "Yes";
  }
  for(int i=0;i<3;++i){
    if(appear[0][i] and appear[1][i] and appear[2][i]) ANS = "Yes";
  }
  if(appear[0][0] and appear[1][1] and appear[2][2]) ANS = "Yes";
  if(appear[0][2] and appear[1][1] and appear[2][0]) ANS = "Yes";

  cout << ANS << endl;
  return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

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

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

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

    string s;
    cin >> s;
    bool flag = true;
    ll n = s.size();

    if(s[n-1] == '1') flag = false;
    if(s[0] == '0') flag = false;
    REP(i, n/2){
    	if(s[i] != s[n-2-i]) flag = false;
    }
    if(!flag){
    	cout << -1 << endl;
    	return 0;
    }

    ll par = 1;
    REP(i, n-1){
    	ll now = i+2;
    	cout << par << " " << now << endl;
    	if(s[i] == '1') par = now;
    }
    return 0;
}

Measured memory_bytes: 1616
#include <bits/stdc++.h>
#define int long long
using namespace std;
int a[200005],i;

signed main(){
	int n,t,sum=0;
	cin>>n>>t;
	for(i=1;i<=n;i++)
		cin>>a[i];
	for(i=2;i<=n;i++){
		if(a[i]>=a[i-1]+t)
			sum+=t;
		else
			sum+=a[i]-a[i-1]; 
	}
	cout<<sum+t<<endl;
	return 0;
}

Measured memory_bytes: 5084
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>
#include <iterator>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
// template<class T> T gabs(const T& x) { return max(x, -x); }
// #define abs gabs

// extgcd(a, b) -> (gcd(a, b), x, y)
// ax + by = gcd(a, b)
tuple<i64, i64, i64> extgcd(i64 a, i64 b) {
    if (b > 0) {
        i64 g, x, y;
        tie(g, y, x) = extgcd(b, a % b);
        return make_tuple(g, x, y - a / b * x);
    } else {
        return make_tuple(a, 1, 0);
    }
}

int main() {
    i64 a, b;
    cin >> a >> b;
    i64 g, x, y;
    tie(g, x, y) = extgcd(a, b);
    // cerr << g << endl;
    cout << x << ' ' << y << endl;
    return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
string s;
int k;
vector<string>vs;
int main(){
	cin>>s>>k;
	for(int i=0;i<s.size();i++){
		string st;
		for(int j=i;j<s.size()&&j<i+k;j++){
			st+=s[j];
			vs.push_back(st);
		}
	}
	sort(vs.begin(),vs.end());
	string ans=vs[0];
	int cnt=1;
	for(int i=1;i<vs.size()&&cnt<k;i++){
		if(vs[i]!=ans){
			ans=vs[i];
			cnt++;
		}
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 1660
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef map<int, int> mii;
typedef map<char,int> mci;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vii;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define F first
#define S second
#define in insert
const int INF = 1e9 + 7;


int main(){
    int a; cin>>a;
    if(a==25) cout<<"Christmas";
    if(a==24) cout<<"Christmas Eve";
    if(a==23) cout<<"Christmas Eve Eve";
    if(a==22) cout<<"Christmas Eve Eve Eve";
}

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

int main() {
  int q;
  cin >> q;
  priority_queue<int, vector<int>, greater<int>> rq;
  priority_queue<int, vector<int>, less<int>> lq;
  int sz = 0;
  int64_t sum = 0, lsum = 0, rsum = 0;

  auto Push = [&](int v) {
    lq.push(v);
    sz++;
    lsum += v;
    while (lq.size() > (sz + 1) / 2) {
      lsum -= lq.top();
      rsum += lq.top();
      rq.push(lq.top());
      lq.pop();
    }
    while (!rq.empty() && !lq.empty() && rq.top() < lq.top()) {
      int x = lq.top(), y = rq.top();
      lq.pop();
      rq.pop();
      lsum -= x;
      rsum -= y;
      lsum += y;
      rsum += x;
      lq.push(y);
      rq.push(x);
    }
  };

  while (q--) {
    int t;
    cin >> t;
    if (t == 1) {
      int a, b;
      cin >> a >> b;
      sum += b;
      Push(a);
    } else {
      int med = lq.top();
      int64_t ans = sum + 1LL * med * lq.size() - lsum + rsum - 1LL * med * rq.size();
      cout << med << ' ' << ans << "\n";
    }
  }
}


Measured memory_bytes: 3452
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int r=sc.nextInt(),D=sc.nextInt(),x=sc.nextInt();


		for(int i=0;i<10;i++) {
			x=r*x-D;
			System.out.println(x);
		}
	}
}

Measured memory_bytes: 21716
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n,m,x = LI()
    s = LIR(n)
    ans = float("inf")
    for b in range(1<<n):
        cost = 0
        k = [0]*m
        for i in range(n):
            if b&(1<<i):
                cost += s[i][0]
                for j in range(m):
                    k[j] += s[i][j+1]
        if cost < ans and all([i >= x for i in k]):
            ans = cost
    if ans == float("inf"):
        print(-1)
    else:
        print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 69176
#include<stdio.h>
 
int main(){
  int i, j, k, n;
  
  scanf("%d", &n);
 
  int M[n][2];
  for(i=0; i<n; i++)
    {
      scanf("%d", &M[i][0]);
      scanf("%d", &M[i][1]);
    }
 
  int x[n][n];
 
  for(i=1; i<n; i++)
    {
      for(j=0; j<n; j++)
    {
      x[i][j]=10000001;
    }
    }
 
  for(j=0; j<n; j++)
    {
      x[0][j]=0;
    }
  for(j=0; j<n-1; j++)
    {
      x[1][j]=M[j][0]*M[j][1]*M[j+1][1];
    }
 
    for(i=2; i<n; i++)
    {
      for(j=0; j<n-i; j++)
    {
      for(k=0; k<i; k++)
        {
          if(x[i][j]>x[k][j]+x[i-k-1][j+k+1]+M[j][0]*M[i+j][1]*M[j+k][1])
        {
          x[i][j]=x[k][j]+x[i-k-1][j+k+1]+M[j][0]*M[i+j][1]*M[j+k][1];
        }
        }
    }
    } 
 
  printf("%d\n", x[n-1][0]);
 
  return 0;
}



Measured memory_bytes: 2056
#include<cstdio>
#include<iostream>
using namespace std;
int main()
{
    int n,a,b;
    scanf("%d%d%d",&n,&a,&b);
    if (n == 1)
    {
        if (a == b)
            printf("1\n");
        else
            printf("0\n");
    }
    else
    {
        if (a > b)
            printf("0\n");
        else
        {
            //long long sum = (n-2) * (b-a) + 1;
            printf("%lld\n",(long long)(n-2) * (b-a) + 1);
        }
    }
    return 0;
}

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

int solve(int x, const std::vector<int>& deltas)
{
  int d = 0;
  for (int i = 0; i < static_cast<int>(deltas.size()); ++i) {
    d += deltas[i];
    if (d > x) return i + 1;
  }
  return deltas.size() + 1;
}

int main()
{
  int n, x;
  std::cin >> n >> x;

  std::vector<int> deltas(n);
  for (auto& l : deltas) {
    std::cin >> l;
  }

  std::cout << solve(x, deltas) << std::endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	char S[4], T[4];
	int i;
	scanf("%s %s", S, T);
	int ans = 0;
	for(i = 0; i < 3; ++i){
		if(S[i] == T[i]){
			ans+=1;
		}
	}
	printf("%d", ans);
	return 0;
}


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

static class CodeJam
{
    class Solver
    {
        private int[] A;
        private int[] B;

        public Solver(string S, string T)
        {
            A = new int[S.Length + 1];
            for (int i = 0; i < S.Length; ++i)
            {
                switch (S[i])
                {
                case 'A': A[i + 1] = (A[i] + 1) % 3; break;
                case 'B': A[i + 1] = (A[i] + 2) % 3; break;
                }
            }
            B = new int[T.Length + 1];
            for (int i = 0; i < T.Length; ++i)
            {
                switch (T[i])
                {
                case 'A': B[i + 1] = (B[i] + 1) % 3; break;
                case 'B': B[i + 1] = (B[i] + 2) % 3; break;
                }
            }
        }

        public bool Solve(int a, int b, int c, int d)
        {
            int s = ((A[b + 1] - A[a]) % 3 + 3) % 3;
            int t = ((B[d + 1] - B[c]) % 3 + 3) % 3;
            return s == t;
        }
    }

    static void Main(string[] args)
    {
        var S = Console.ReadLine();
        var T = Console.ReadLine();
        var solver = new Solver(S, T);
        int q = int.Parse(Console.ReadLine());
        var queries = new int[q][];
        for (int i = 0; i < q; ++i) { queries[i] = Array.ConvertAll(Console.ReadLine().Split(), x => int.Parse(x) - 1); }
        foreach (var v in queries)
        {
            Console.WriteLine(solver.Solve(v[0], v[1], v[2], v[3]) ? "YES" : "NO");
        }
    }
}


Measured memory_bytes: 26548
#include <iostream>
#include <string>
#include <vector>
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }

int main(){
    int R; cin >> R;
    float ans = 2*R*M_PI;
    cout << ans << endl;
    return 0;
    
}

Measured memory_bytes: 3812
#include <iostream>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;

int main()
{
    int s, l;
    cin >> s >> l;
    vector<string> inp;
    for (int i = 0; i < s; i++)
    {
        string temp;
        cin >> temp;
        inp.push_back(temp);

    }
    sort(inp.begin(), inp.end());
    for (int i = 0; i < s; i++)
    {
        cout << inp[i];

    }
    
}

Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>
#include<vector>
using namespace std;
typedef long long ll;
const ll INF = 1e9L + 7;

int main() {
    int n,m;
    cin>>n>>m;
    ll grid[n][m];
    string wall[n];
    for(ll i=0;i<n;i++){
        cin>>wall[i];
        for(ll j=0;j<m;j++){
            if(wall[i][j]=='#'){
               // cout<<wall[i][j]<<" ";
                grid[i][j]=-1;
            }
            else grid[i][j]=0;
        }
    }
    grid[0][0]=1;
    for(ll i=0;i<n;i++){
        for(ll j=0;j<m;j++){
            if(i==0 && j==0){
                continue;
            }
            if(grid[i][j]!=-1){
                if(i>0 && grid[i-1][j]!=-1){
                    grid[i][j]=(grid[i][j]+(grid[i-1][j])%INF)%INF;
                }
                if(j>0 && grid[i][j-1]!=-1){
                    grid[i][j]=(grid[i][j]+(grid[i][j-1])%INF)%INF;
                }
            }
            
        }
    }
    cout<<grid[n-1][m-1]%INF;
    return 0;
}

Measured memory_bytes: 9088
#include <iostream>
#include <cmath>
#include <iomanip>
#include <stack>

using namespace std;


int c[1401][1401];
int dp[1401][1401];

struct RT {
	int point;
	int height;
};

int max_in_x(int *p,int size) {
	stack<RT> st;
	int cur = 0;
	int s = 0;

	*(p + size ) = 0;
	for (int i = 0; i <= size; i++) {
		int current_h = *(p + i);
		RT rect = {i,current_h};

		if (st.empty()) {
			st.push(rect);
		} else if (current_h > st.top().height) {
			st.push(rect);
		} else if (current_h < st.top().height) {
			RT start = st.top();
			start.point = i - 1;
			RT target;

			while(!st.empty() && st.top().height > current_h) {
			 	target = st.top();
				st.pop();
				s = max(s,(start.point -target.point + 1) * target.height);
				//cout << "s:" << s << endl;
			}
			target.height = current_h;
			st.push(target);
			
		} 
	}

	return s;
}


int main() {
	int W,H;
	cin >> H >> W;
	
	int v_max = 0;

	for (int y = 0; y < H; y++) {
		for (int x = 0; x < W; x++) {

			cin >> c[y][x];
			c[y][x] ^= 1;
			dp[y][x] = 0;			
		}
	}
	for (int x = 0; x < W; x++) {
		for (int y = 0; y < H; y++) {
			if (c[y][x] == 0) {
				dp[y][x] = 0;
				continue;
			}
			if (y==0) {
				dp[y][x] = 1;
				continue;				
			} 
			dp[y][x] = dp[y-1][x] + 1;
		}
	}

	int s_max = 0;

/*
	for (int y = 0; y < H; y++) {
		for (int x = 0; x < W; x++) {
			cout << setw(5) << dp[y][x] << " ";
		}
		cout << endl;
	}
*/

	for( int y = 0; y < H; y++) {
		
		//cout << "** s_max y:" << y << endl;
		int ret = max_in_x(dp[y],W); 
		//cout << "v:" << ret << endl;
		s_max = max(s_max,ret);
	}

	cout << s_max << endl;
	return 0;
}

Measured memory_bytes: 16528
using System;

namespace AtCoder.Abc
{
    class QuestionB
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            int k = int.Parse(Console.ReadLine());
            string s = Console.ReadLine();
            string result = "";
            if (s.Length <= k)
            {
                result = s;
            }
            else
            {
                result = s.Substring(0, k) + "...";
            }

            Console.WriteLine(result);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 27544
#!/usr/bin/env python3
import sys
def input():
    return sys.stdin.readline()[:-1]

def main():
    N = int(input())
    S = [0] * N
    P = [0] * N
    R = [0] * N
    for i in range(N):
        S[i] , P[i] = map(str, input().split())
    for i in range(N):
        R[i] = i + 1
    for i in range(N):
        P[i] = int(P[i]) * -1


    Z = zip(S, P, R)
    Z = sorted(Z)
    S, P, R = zip(*Z)

    for i in R:
        print(i)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9060
ai = lambda: list(map(int,input().split()))
ai_ = lambda: [int(x)-1 for x in input().split()]

n = int(input())
l = ai()
m = [0 for _ in range(n)]
f = 'Yes'
for i in range(1,n+1):
    if i == 1:
        m[-1] = l[-1]
    else:
        if l[-i]-m[-i+1]>1:
            f = 'No'
        m[-i] = min(l[-i],m[-i+1])

print(f)

Measured memory_bytes: 14704
#define _CRT_SECURE_NO_WARNINGS
//#define DEBUG
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

int main(void) {
#ifdef DEBUG
	printf("");
#endif

	int a, b, c;
	int i;
	int ans=1;
	scanf("%d", &a);
	scanf("%d", &b);
	scanf("%d", &c);
	if (b != a) {
		ans++;
	}
	if (c != b && c != a) {
		ans++;
	}

	printf("%d\n",ans);

	return 0;
}

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

using namespace std;

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

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


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

int main() {
	int n, m;
	vector<pi> stud;
	vector<pi> coord;
	int x, y;
	cin >> n >> m;
	REP(i, 0, n){
		cin >> x >> y;
		stud.PB(MK(x, y));
	}
	REP(i, 0, m){
		cin >> x >> y;
		coord.PB(MK(x, y));
	}
	
	for(auto i = stud.begin(); i < stud.end(); i++){
		x = i->F;
		y = i->S;
		int ans = 0;
		int distance = INT_MAX;
		int index = 1;
		for(auto j = coord.begin(); j < coord.end(); j++){
			int d = abs(x -j->F) + abs(y-j->S);
			if(d < distance){
				distance = d;
				ans = index;
			}
			++index;
		}
		cout << ans << endl;
	}

}


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

int N, p[5000], memo[5001], result[4];

int main() {
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> p[i];
  }
  // memoを利用して1番目を決め打ちした時の答えを求める
  for (int i = 0; i <= 3; i++) {
    memo[0] = i;
    for (int j = 1; j < N + 1; j++) {
      memo[j] = p[j - 1] - memo[j - 1];
      if (memo[j] < 0) {
        memo[j] = 0;
      }
    }
    result[i] = memo[0];
    for (int j = 1; j < N; j++) {
      result[i] += memo[j] * 2;
    }
    result[i] += memo[N];
  }
  // 4回の試行のうち最小を求める
  int min = result[0];
  for (int i = 1; i <= 3; i++) {
    if (min > result[i]) {
      min = result[i];
    }
  }
  cout << min << endl;
  return 0;
}



Measured memory_bytes: 3100
#include<iostream>
#include<queue>
#include<vector>
#include<algorithm>
#include<cassert>
#include<set>
#include<cassert>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
#define ALL(c)   (c).begin(),(c).end()
#define pb push_back
#define mp make_pair

typedef pair<int,int> pii;
typedef long long ll;
const int N = 20;
vector<pii> edge[N];

//return subtree of now include node 0 or not?
bool solve(int now,int prev,int &sum){
  bool ret=false;;
  rep(i,edge[now].size()){
    int next=edge[now][i].first;
    if (edge[next].size() == 1 && next != 0)continue;
    if (next == prev)continue;
    bool tmp=solve(next,now,sum);
    sum+=edge[now][i].second*(1-(int)tmp+1);
    ret|=tmp;
  }
  //cout << now+1 <<" " << (ret||now==0) << endl;
  return ret||now==0;
}

int solve(int n){
  int ans=(1<<21);
  rep(i,n){
    int sum=0;
    solve(i,-1,sum);
    //cout << i+1 <<" " << sum << endl;
    ans=min(ans,sum);
  }
  return ans;
}

main(){
  int n;
  while(cin>>n && n){
    rep(i,n)edge[i].clear();
    rep(i,n-1){
      int f,t,c;
      cin>>f>>t>>c;
      f--;t--;
      edge[f].pb(mp(t,c));
      edge[t].pb(mp(f,c));
    }
    cout << solve(n) << endl;
  }
  return false;
}

Measured memory_bytes: 0
n, m = list(map(int, input().split(" ")))
a_nm = [list(map(int, input().split(" "))) for i in range(n)]
b_nm = [int(input()) for k in range(m)]

for ab in a_nm:
    mul = 0
    for j in range(m):
        
        mul = mul + ab[j] * b_nm[j]
    print(mul)



Measured memory_bytes: 6012
#include<bits/stdc++.h>
#define MOD 1000000007
#define MOD2 1000000006
#define TEMPMOD1 998244353
#define TEMPMOD2 998244352
#define INF 1000000000000000007
#define NEGINF -1000000000000000007
#define vll vector<ll> 
#define vvll vector<vector<ll>>
#define pll pair<ll,ll>
#define plll pair<pll,ll>
#define vpll vector<pll>
using namespace std;
typedef long long int ll;

ll dp[100010][2];
string str1;
ll len;
//pll possible[3]={{1,0},{0,1},{0,0}};
ll ways(ll idx,ll tight)
{
    if(idx==len)
    {
        return 1;
    }
    if(dp[idx][tight]!=-1)
    {
        return dp[idx][tight];
    }
    ll result=0;
    if(tight==0)
    {
        result=(3*ways(idx+1,tight))%MOD;
        dp[idx][tight]=result;
        return result;
    }
    if(str1[idx]=='0')
    {
        result=ways(idx+1,tight);
        dp[idx][tight]=result;
        return result;
    }
    ll store;
    store=ways(idx+1,tight);
    store=(store*2)%MOD;
    result=(result+store)%MOD;
    store=ways(idx+1,0);
    result=(result+store)%MOD;
    dp[idx][tight]=result;
    return result;
}

int main()
{
    
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    memset(dp,-1,sizeof(dp));
    cin>>str1;
    len=str1.size();
    ll ans=ways(0,1);
    cout<<ans;
    return 0;
}

Measured memory_bytes: 6736
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
const ll MOD=1000000007;

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

int main(){
    ll N,M;
    string S,T;
    cin >> N >> M >> S >> T;
    ll L=lcm(N,M),G=gcd(N,M);
    bool can=true;
    int n=N/G,m=M/G;
    for (int i=0;i<G;i++){
        if (S[i*n]!=T[i*m]){
            can=false;
        }
    }
    if (can){
        cout << L << endl;
    }
    else {
        cout << -1 << endl;
    }
}

Measured memory_bytes: 512
import sys

input = sys.stdin.readline


def main():
    A, B, K = map(int, input().split())

    a = [i for i in range(A, A + K) if i <= B]
    b = [i for i in range(B - K + 1, B + 1) if A <= i]

    ans = sorted(set(a + b))
    print(*ans, sep="\n")


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Graph= vector<vector<ll>>;
struct edge{ll to ; ll cost ;} ;
using graph =vector<vector<edge>> ;
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define mpa make_pair
#define fi first
#define se second 
#define set20 cout<<fixed<<setprecision(20) ;
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
double pi=acos(-1) ;
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;}
 
ll dp[1025][100005] ;
 int main(){
 ll n ; cin>> n ;
 vector<ll> v(n) ,w(n) ;
 rep(i,n) cin>>v[i]>>w[i] ;
 ll q ; cin>> q ;
rep(i,100005){
  dp[0][i]=0;
}
rep2(i,1,min(1023ll,n)){
 rep(j,100005){
   if(j>=w[i-1]) dp[i][j]=max(dp[i/2][j],dp[i/2][j-w[i-1]]+v[i-1]) ;
   else dp[i][j]= dp[i/2][j] ;
 }
}

 while(q--){
  ll a, b ; cin>>a>>b ;
  if(a<=1023) cout<<dp[a][b]<<endl ;
  
  else{
    vector<ll> koho ;
    while(a>1023){
      koho.pb(a) ;
      a/=2 ;
    }
    ll ans= dp[a][b] ;
    ll len = koho.size() ;
   rep(i,1<<len){
     bitset<8> s(i) ;
     ll we=0 ;
     ll va=0 ;
     rep(j,8){
       if(s[j]) {
         we+= w[koho[j]-1] ;
         va+= v[koho[j]-1] ;
       }
       }
     if(we<=b) chmax(ans,dp[a][b-we]+va) ;

   } 
      cout<<ans<<endl ;
  }
}


   return 0 ;
 }



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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second

int main(int argc, char const *argv[]) {
  int n,k; cin >> n >> k;
  vector<int> a(n); REP(i,n) cin >> a[i];
  int ans = 0;
  REP(i,n) {
    if (a[i] >= k) ans++; 
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#define REP(i, a, b) for (auto i = (a); i < (b); ++i)
using namespace std;

using ll = long long;

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);

	int a, b; cin >> a >> b;
	cout << 1 + 2 + 3 - a - b;
}

Measured memory_bytes: 892
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <cmath>

#define	MOD 1000000007;
#define PI 3.14159265358979323846;
#define rep(i,n) for(ll i = 0;i<(ll)n;i++)
using namespace std;
typedef long long ll;
static const int MAX = 50;
static const long long INFTYL = 9223372036854775807;
static const int INFTY = 2147483647;
ll mod = 1000000007;

int main()
{
	int A, B;
	cin >> A >> B;
	string S;
	cin >> S;

	bool valid = false;
	if (S[A] != '-' || S.size() != A + B + 1) {
		valid = false;
	}
	else {
		rep(i, A + B + 1) {
			if (i != A) {
				if (S[i] == '-') {
					valid = false;
					break;
				}
				int t = S[i] - '0';
				if (t >= 0 && t <= 9) {
					valid = true;
				}
			}
		}
	}

	string ans;
	if (valid) {
		ans = "Yes";
	}
	else {
		ans = "No";
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256