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

typedef long lint;
typedef long long llint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const ll INF = 1<<21;
// static const ll MOD = 1e9 + 7;

bool compPair(const pair<int, int>& arg1, const pair<int, int>& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

int main(void) {
    int h, w;
    cin >> h >> w;

    vector<vector<int>> a(h, vector<int>(w, 0));
    int atmp;
    for(int ih=0;ih<h;ih++) {
        for(int iw=0;iw<w;iw++) {
            cin >> atmp;
            a.at(ih).at(iw) = atmp;
        }
    }

    int iw=0, ihbfr=0, iwbfr=0, ihnow, iwnow, n=0;
    vector<vector<int>> ans(h*w, vector<int>(4, 0));
    for(int ih=0;ih<h;ih++) {
        iw = 0;
        while(iw<w) {
            if(ih==0&&iw==0) {
                iw++;
                continue;
            }
            if(ih%2==0) {
                ihnow = ih;
                iwnow = iw;
            }
            else {
                ihnow = ih;
                iwnow = w-iw-1;
            }
            if(a.at(ihbfr).at(iwbfr)%2==1) {
                a.at(ihbfr).at(iwbfr)--;
                a.at(ihnow).at(iwnow)++;
                ans.at(n).at(0) = ihbfr+1;
                ans.at(n).at(1) = iwbfr+1;
                ans.at(n).at(2) = ihnow+1;
                ans.at(n).at(3) = iwnow+1;
                n++;
            }
            iw++;
            ihbfr = ihnow;
            iwbfr = iwnow;
        }
    }

    cout << n << endl;
    for(int in=0;in<n;in++) {
        cout << ans.at(in).at(0) << " " << ans.at(in).at(1) << " " << ans.at(in).at(2) << " " << ans.at(in).at(3) << endl;  
    }

    return 0;
}


Measured memory_bytes: 16768
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;



int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n, m, i, j, k, nn, x, y, xx, yy, p, ct;
	int v[4][2] = { 1, 0, 0, 1, -1, 0, 0, -1 };
	cin >> n >> m >> nn;
	vector<int> a(nn);
	for (i = 0; i < nn; i++) cin >> a[i];

	vector<vector<int>> ans(n, vector<int>(m, -1));
	ct = 0;
	for (i = 0; i < nn; i++) {
		for (j = 0; j < a[i]; j++) {
			if (ct == 0) {
				x = 0; y = 0; p = 0;
			}
			else {
				while(1) {
					xx = x + v[p][0]; yy = y + v[p][1];
					if ((xx >= 0) && (xx < n) && (yy >= 0) && (yy < m) && (ans[xx][yy] == -1)) break;
					p = (p + 1) % 4;
				}
				x = xx; y = yy;
			}
			ct++;
			ans[x][y] = i + 1;
		}
	}

	for (i = 0; i < n; i++) {
		for (j = 0; j < m; j++) cout << ans[i][j] << " ";
		cout << "\n";
	}

	return 0;
}



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

int main(){
	int i;
	string str;
	cin>>str;
	for(i=0;i<str.size();i++){
		if(str[i] > 'C'){
			str[i]-= 3;
		}
		else{
			str[i]= 'X' - 'A' + str[i];
		}
	}
	cout<<str<<endl;
	return 0;
}

Measured memory_bytes: 1180
import sys
import math
from fractions import gcd
# import queue
# from collections import Counter
# from itertools import accumulate
from functools import reduce

def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

big_prime = 1000000007

"""
# 標準入力取得
## 文字列
 =  sys.stdin.readline().rstrip()
 =  list(sys.stdin.readline().rstrip())

## 数値
 =  int(sys.stdin.readline())
 =  map(int, sys.stdin.readline().split())
 =  list(map(int, sys.stdin.readline().split()))
 =  [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""

N =  int(sys.stdin.readline())
L =  list(map(int, sys.stdin.readline().split()))

X = reduce(gcd, L)

cnt = 0
while True:
    if X == 1:
        print(cnt)
        exit()
    X = X >> 1
    cnt += 1

Measured memory_bytes: 71020
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();

            while (true)
            {
                int n = int.Parse(Console.ReadLine());

                if (n == 0) break;

                int sum = 0;

                for (int i = 0; i < n; i++)
                {
                    int[] input = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
                    int s = input[0] + input[1] + input[2];
                    int w = input[3];

                    if (s > 160 || w > 25) continue;

                    int rank = CheckS(s);

                    if (w > rank * 5) rank = CheckW(w);

                    sum += (600 + (200 * rank));
                }
                sb.AppendLine(sum.ToString());
            }
            Console.Write(sb);
        }

        static int CheckS(int s)
        {
            if (s > 140) return 5;
            if (s > 120) return 4;
            if (s > 100) return 3;
            if (s > 80) return 2;
            if (s > 60) return 1;
            return 0;
        }

        static int CheckW(int w)
        {
            if (w > 20) return 5;
            if (w > 15) return 4;
            if (w > 10) return 3;
            if (w > 5) return 2;
            if (w > 2) return 1;
            return 0;
        }
    }
}

Measured memory_bytes: 9408
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int D;
  cin >> D;

  vector<int> c(26);
  REP(i, 26) cin >> c[i];

  vector<vector<int>> s(D, vector<int>(26));
  REP(i, D) REP(j, 26) cin >> s[i][j];

  vector<int> last(26, -1);

  vector<int> t(D);
  REP(i, D){
    cin >> t[i];
    t[i]--;
  }

  int ans = 0;
  REP(i, D){
    ans += s[i][t[i]];
    last[t[i]] = i;

    REP(j, 26){
      ans -= (i-last[j])*c[j];
    }
    cout << ans << "\n";
  }

  return 0;
}

Measured memory_bytes: 3712
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        ArrayList<Long> li = new ArrayList<>();
        long ans = 4;
        long max = 0;
        for(int i = 0; i < 5; i++){
            max = Math.max(max,(long)Math.ceil((double)n/sc.nextDouble()));
        }
        System.out.println(ans+max);
    }
}

Measured memory_bytes: 25684
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long ll;

int main() {
  string s;
  cin >> s;
  int x = 0;
  char c = s[0];
  REP(i,1,s.size()) {
    if(c != s[i]) {
      x++;
      c = s[i];
    }
  }
  cout << x << endl;
  return 0;
}


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

#define rep(i, n) for(int i=0; i < (n); ++i)
#define ll long long

template<class T> using v = std::vector<T>;
template<class T> using vv = v<v<T>>;

const int mod = 1000000007;
//const int mod = 998244353;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; }}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 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;}

// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    string s;
    cin >> n >> s;

    if (n % 2 != 0) {
        cout << "No" << endl;
        return 0;
    }
    if (s.substr(0, n/2) == s.substr(n/2, n/2)) {
        cout << "Yes" << endl;
    } else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scanner = new Scanner(System.in);
        String[] input = scanner.nextLine().split(" ");
        scanner.close();
        String combined = input[0] + input[1];
        Integer combinedNum = Integer.parseInt(combined);
        List<Integer> heihou = new ArrayList<>();
        for( int i=1; i<=1000; i++){
            heihou.add(i*i);
        }
        if(heihou.contains(combinedNum)){
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 21844
'use strict'
function otoshidama(stdin) {
  const inputs = stdin.split(' ')
  const n = inputs[0]
  const y = inputs[1]
  for (let i = 0;i <= n;i++) {
    const remain = y - 10000 * i
    if (remain === 0 && n === i) return console.log(n, 0, 0)
    else if (remain < 0) break
    for (let j = 0;j <= n - i;j++) {
      const sen = n - i - j
      const result = remain - 5000 * j - 1000 * sen
      if (result === 0) return console.log(i, j, sen)
      else if (result < 1000) break
    }
  }
  return console.log(-1, -1, -1)
}
otoshidama(require('fs').readFileSync(0, 'utf8'))

Measured memory_bytes: 7756
if __name__ == "__main__":
    while True:
        h, w = map(lambda x: int(x), input().split())

        if (w == 0 & h == 0):
            break

        for i in range(h):
            if (i == 0 or i == (h - 1)):
                print("#" * w)
            else:
                print("#" + "." * (w - 2) + "#")

        print()



Measured memory_bytes: 5608
#include<stdio.h>
#include<string.h>

char c;
char exchange(char c){
  
  if('a' <= c && c <= 'z') {
    return c + ('A' - 'a');
  }
  
  return c;
}

int main(void){
int i,len;
char s[4906];
scanf("%[a-z, ., ,]", s);

  len = strlen(s);
  for(i = 0; i < len;i++) {
    s[i] = exchange(s[i]);
  }
  
  printf("%s",s);
  

printf("\n");
return 0;
}



Measured memory_bytes: 2104
n = int(input())
m = {}
 
for i in range(n):
  s = "".join(sorted(list(input())))
  if s in m.keys():
    m[s] = m[s] + 1
  else:
    m[s] = 1
 
ans = 0
for s in m.keys():
  ans += m[s] * (m[s] - 1) // 2
 
print(ans)

Measured memory_bytes: 17808
import itertools
def main():
    n,m = map(int,input().split())
    S = []
    for _ in range(m):
        s = list(map(int,input().split()))
        s.pop(0)
        S.append(s)
    p = list(map(int,input().split()))
    status = [[0,1] for i in range(n)]
    cnt = 0
    for on in itertools.product(*status):
        flag = 0
        for i in range(m):
            s = 0
            for j in range(len(S[i])):
                if on[S[i][j]-1]==1:
                    s += 1
            if s%2==p[i]:
                flag += 1
                if flag==m:
                    cnt += 1
                continue
            else:
                break
    print(cnt)
        

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include <iostream>
#include <climits>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
 
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

#define MOD 1000000007LL

int main()
{
  ll ans;
  int a;

  cin >> a;

  ans = a+a*a+a*a*a;

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


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define ve vector
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)

int main(){
    ll n,c;
    cin >> n >> c;
    ve<P> xv(n);
    rep(i,n) cin >> xv[i].first >> xv[i].second;
    ve<ll> sr(n+1), sl(n+1),slm(n+1),srm(n+1);
    sr[0] = 0;
    sl[0] = 0;
    rep(i,n){
        sr[i+1] = sr[i] + xv[i].second;
        sl[i+1] = sl[i] + xv[n-i-1].second;
    }
    srm[0] = 0;
    slm[0] = 0;
    rep(i,n){
        srm[i+1] = max(srm[i], sr[i+1] - xv[i].first);
        slm[i+1] = max(slm[i], sl[i+1] - c + xv[n-i-1].first);
    }
    ll ans = 0;
    rep(i,n){
        ll memo = sr[i+1] - xv[i].first * 2;
        memo += slm[n-i-1];
        ans = max(ans,memo);
        memo = sl[i+1] -(2*c - xv[n-i-1].first * 2);
        memo += srm[n-i-1];
        ans = max(ans,memo);
    }
    ans = max(ans,srm[n]);
    ans = max(ans,slm[n]);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 8008
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }



int main() {
  int a,b,c,d;
  scanf("%d%d%d%d", &a,&b,&c,&d);

  FOR(i,1,d-b) cout << 'U';
  FOR(i,1,c-a) cout << 'R';
  FOR(i,1,d-b) cout << 'D';
  FOR(i,1,c-a) cout << 'L';
  cout << 'L';
  FOR(i,1,d-b+1) cout << 'U';
  FOR(i,1,c-a+1) cout << 'R';
  cout << 'D';
  cout << 'R';
  FOR(i,1,d-b+1) cout << 'D';
  FOR(i,1,c-a+1) cout << 'L';
  cout << 'U' << endl;


}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
using namespace __gnu_pbds; 
using namespace std;
#define ull         unsigned long long int
#define ll          long long int
#define pb          push_back
#define pii         pair<int,int>
#define F           first
#define S           second
#define vi          vector<int>
#define vli          vector<ll>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define M_PI        3.14159265358979323846
#define mp          make_pair
#define sz(x)       (int)x.size()
#define matrix      vector<vector<ll>>
#define forn(i,a,b)  for(int i=a;i<b;i++)
#define eps 0.0000000001
#define all(a)      (a).begin(),(a).end()
#define ordered_set     tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update> 
 
const long long INF = (long long) 1e11+1;
const long long mod = (long long) 998244353;
const long long hell = (long long) 1000000007;

ll power(ll x,ll y){
  ll res=1;
  while(y>0){
    if(y%2) res=(x%hell*res%hell)%hell;
    x=(x%hell*x%hell)%hell;    
    y=y/2;
  }
  
  return res%hell;
}
 
ll modinv(ll x){
  return power(x,hell-2);
}

ll gcd(ll a,ll b){
    while( b != 0)
	{
		ll  t = b;
		b= a %t;
		a = t;
	}
	return a;
}    
    
void fastIO(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
ll n,m,k;
ll a[200005],b[200005],prea[200005],preb[200005];

void solve(){
    cin>>n>>m>>k;
    
    forn(i,0,n)
    cin>>a[i];
    
    forn(i,0,m)
    cin>>b[i];
    
    prea[0]=0;
    preb[0]=0;
    
    for(int i=0;i<n;i++)
    prea[i+1]=prea[i]+a[i];
    
    for(int i=0;i<m;i++)
    preb[i+1]=preb[i]+b[i];           
    
    int ans=0;
    
    for(int i=0;i<=n;i++){
        if(prea[i]<=k){
            ll rem=k-prea[i];
            int ind;
            if(rem>=preb[m]){
                ind=m;
            }
            else
            ind=upper_bound(preb,preb+m,rem)-preb-1;
            ans=max(ans,i+ind);
        }
        else
        break;
    }
    
    cout<<ans;
}    
    
int main(){
   fastIO();
   int test;
   //cin>>test;
   test=1;    
    
   while(test--)
   solve();
}

Measured memory_bytes: 9900
import sys
from bisect import bisect_right
input = sys.stdin.readline
A, B, Q = map(int, input().split())
INF = 10 ** 18
s = [-INF] + [int(input()) for i in range(A)] + [INF]
t = [-INF] + [int(input()) for i in range(B)] + [INF]
xs = [int(input()) for i in range(Q)]
for x in xs:
    b, d = bisect_right(s, x), bisect_right(t, x)
    res = INF
    for S in [s[b - 1], s[b]]:
        for T in [t[d - 1], t[d]]:
            d1, d2 = abs(S - x) + abs(T - S), abs(T - x) + abs(S - T)
            res = min(res, d1, d2)
    print(res)

Measured memory_bytes: 16256
#include <stdio.h>
int main() {
	int h, w, k;
	scanf("%d%d%d", &h, &w, &k);
	char c[7][7];
	int ans = 0;
	char tc[7][7];
	for (int i = 0; i < h; i++) {
		scanf("%s", c[i]);
	}
	for (int bitw = 0; bitw < (1 << w); bitw++) {
		for (int bith = 0; bith < (1 << h); bith++) {
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					tc[i][j] = c[i][j];
				}
			}
			int cnt = 0;
			for (int i = 0; i < h; i++) {
				if ((bith >> i) & 1) {
					for (int j = 0; j < w; j++) {
						tc[i][j] = 'r';
					}
				}
			}
			for (int i = 0; i < w; i++) {
				if ((bitw >> i) & 1) {
					for (int j = 0; j < h; j++) {
						tc[j][i] = 'r';
					}
				}
			}
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					if (tc[i][j] == '#') {
						cnt++;
					}
				}
			}
			if (cnt == k) {
				ans++;
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1724
#include <iostream>
#include <queue>
#include <iomanip>
#include <map>
#include <bitset>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(c) c.begin(),c.end()
#define PB push_back
#define INF 1100000000
#define LLINF 1100000000000000000
#define MOD 1000000007
#define FI first
#define SE second
#define MP make_pair

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

int main()
{
  string S; cin >> S;
  int ans = accumulate(ALL(S), 0, [](int acc, char n) -> int {
      return acc + (n == '1');
      });
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#define rep(i, a, b) for(int i = (a); i < (b); i++)
using namespace std;

int main() {
  int a, b, c, x, cnt = 0;
  cin >> a >> b >> c >> x;
  rep(i, 0, a+1) {
    rep(j, 0, b+1) {
      rep(k, 0, c+1) {
        if(500 * i + 100 * j + 50 * k == x) {
          cnt++;
        }
      }
    }
  }
  cout << cnt;
}


Measured memory_bytes: 256
list_data = [input() for _ in range(2)]

s = list_data[0]
t = list_data[1]

len_t = len(t)

max_correct = 0
for i in range(len(s)-len(t)+1):
  correct = 0
  for j in range(len(t)):
    if s[i+j] == t[j]:
      correct += 1
  
  if max_correct < correct:
    max_correct = correct

print(len_t - max_correct)

Measured memory_bytes: 9092
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
using namespace std;
#define INF 0x3f3f3f3f
const int maxn=2e5+10;
#define _rep(i,a,b) for(int i=(a);i<=(b);++i)
int n,a[maxn];
vector<int> v;
map<int,int> mp;

int main()
{
    #ifdef __LOCAL__
        freopen("1.in","r",stdin);
        freopen("1.out","w",stdout);
    #endif
    cin>>n;
    _rep(i,1,n)
    {
        cin>>a[i];
        if(mp[a[i]]==0)
            v.push_back(a[i]);
        mp[a[i]]++;
    }
    long long sum=0;
    for(unsigned int i=0;i<v.size();i++)
        sum+=1ll*mp[v[i]]*(mp[v[i]]-1)/2;
    // cout<<sum<<endl;
    _rep(i,1,n)
    {
        long long ans=sum;
        ans-=mp[a[i]]*(mp[a[i]]-1)/2;
        ans+=(mp[a[i]]-1)*(mp[a[i]]-2)/2;
        cout<<ans<<endl;
    }

    return 0;
}

Measured memory_bytes: 9720
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

int main (){
	int X,Y;cin>>X>>Y;
	int ans=abs(X)-abs(Y);
	ans=abs(ans);
	if(X<0&&Y<X)ans+=2;
	else if(X>0&&Y>0&&X>Y)ans+=2;
	else if(X<0&&Y<=0&&X<Y)ans+=0;
	else if(X<0&&Y<0&&X<Y)ans++;
	else if((X<0&&Y>0)||(X>0&&Y<0))ans++;
	else if(X==0&&Y<0)ans++;
	else if(X>0&&Y==0)ans++;
	cout<<ans<<endl;
   return 0;
}

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

int main(){
	while(1){
		long n, a, b, c, x;
		long frame;
		long y[100];
		
		cin >> n >> a >> b >> c >> x;
		if(n==0) break;
		for(long i=0; i<n; ++i) scanf(" %ld", &y[i]);
		
		frame=0;
		for(long i=0; i<n; ++i){
			
			while(frame<=10000 && y[i]!=x){
				//printf("x=%ld\n", x);
				x=(a*x+b)%c;
				++frame;
			}
			
			if(frame>10000 || i==n-1) break;
			x=(a*x+b)%c;
			++frame; //同時押しはできないので１フレーム進む
		}
		
		if(frame>10000) printf("-1\n");
		else printf("%ld\n", frame);
		
	}
	return 0;
}

Measured memory_bytes: 1232
S = input()
N = len(S)

mod = 10**9 +7
dp = [[0] * 13 for i in range(10**6)]

dp[0][0] = 1
for i,s in enumerate(S):
    keta = (N-i-1)%6
    if s != "?":
        for j in range(13):
            amari = (j + int(s)*10**keta)%13 #桁を追加
            dp[i+1][amari] += dp[i][j]
    else:
        for j in range(13):
            for k in range(10):
                amari = (j + k*10**keta)%13
                dp[i+1][amari] += dp[i][j]
    for j in range(13):
        dp[i+1][j] %= mod
print(dp[N][5]%mod)

Measured memory_bytes: 224032
def slove():
    import sys
    input = sys.stdin.readline
    a, b, c = list(map(int, input().rstrip('\n').split()))
    abc1 = sorted([a, b, c])
    if abc1[1] == c:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    slove()


Measured memory_bytes: 38256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <string>
#include <queue>
#include <iomanip>
#include <iterator>

// #define MOD 1000000007
// #define INF 1000000001

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


template <class T>
ostream &operator<<(ostream &o, const vector<T>&obj) {
    o << "["; for (int i = 0; i < (int)obj.size(); ++i) o << (i > 0 ? ", " : "") << obj[i]; o << "]"; return o;
}
template <class T, class U>
ostream &operator<<(ostream &o, const pair<T, U>&obj) {
    o << "(" << obj.first << ", " << obj.second << ")"; return o;
}
template <class T, class U>
ostream &operator<<(ostream &o, const map<T, U>&obj) {
    o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}
template <class T>
ostream &operator<<(ostream &o, const set<T>&obj) {
    o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}

void print() {
    cout << "\n";
}
template<class Head, class... Body>
void print(Head head, Body... body) {
    cout << head << " ";
    print(body...);
}

int main(int argc, char const *argv[]) {
    int n, m;
    cin >> n >> m;
    cout << (n-1) * (m-1) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
ll Gcd(ll a,ll b){ if(a%b == 0) return b; else return Gcd(b,a%b); }
int main()
{
	ll n,x; cin >> n >> x;
	ll d = Gcd(n,x);
	cout << d * (n/d*3LL-3LL) << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Set;
import java.util.StringTokenizer;

public class Main {
    int n;
    char[] cs;

    public static void main(String args[]) {
        new Main().run();
    }

    void run() {
        FastReader sc = new FastReader();
        n = sc.nextInt();
        cs = sc.next().toCharArray();
        int ans = 0;
        for (int i = 0; i < cs.length - 1; i++) {
            Set<Character> x = new HashSet<>();
            Set<Character> y = new HashSet<>();
            for (int j = 0; j <= i; j++) {
                x.add(cs[j]);
            }
            for (int j = i + 1; j < cs.length; j++) {
                y.add(cs[j]);
            }
            int count = 0;
            for (char c : x) {
                if (y.contains(c)) {
                    count++;
                }
            }
            if (ans < count) {
                ans = count;
            }
        }
        System.out.println(ans);
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 25044
#include <bits/stdc++.h>
#include <string.h>
#define rep(i, n) for(int i = 0; i<(n); i++)
using namespace std;
typedef long long ll;
static const int MAX = 200000; 
//pi = 3.14159265358979323846

int main() {

    int n, k;
    string s;
    cin >> n >> k >> s;
    int count = 0;
    rep(i, n - 1){
        if(s[i] == s[i + 1]) count++;
    }
    cout << min(n - 1, count + 2 * k) << endl;

}




Measured memory_bytes: 512
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <math.h>
#define REP(i, b, n) for (Int i = b; i < Int(n); i++)
#define rep(i, n) REP(i, 0, n)
using namespace std;
using Int = long long;
Int inf = 1000000000000000001LL;
using vi = vector<Int>;
using vvi = vector<vi>;
using pii = pair<Int,Int>;
using mapis = unordered_map<Int,string>;
using mapii = unordered_map<Int,Int>;

Int GCD(Int a, Int b){
    if(b==0) return a;
    if(a < b) return GCD(b, a);
    unsigned r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}

Int LCM(Int a, Int b){
    return a*b/GCD(a,b);
}


int main() {
    Int N;
    Int ans = 0;
    cin >> N;

    string S;
    cin >> S;

    rep(i,1000){
        ostringstream ss;
        ss << std::setw(3) << std::setfill('0') << i;

        string cand = ss.str();
        string tmp = S;
        int cand_i=0;
        rep(j,S.size()){
            if(S[j]==cand[cand_i]){
                cand_i++;
            }
            if(cand_i==3){
                break;
            }
        }

        if(cand_i == 3){
            ans++;
        }
    }


    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define inf 0x3f3f3f3f
#define maxn 300005
#define eps 1e-5
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
inline ll read()
{
    ll x=0,f=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int n,m,p,k;
char ch[1005];
bool solve(int l,int r){
	int i;
	for(i=l;i<=r;i++) if(ch[i]!=ch[r-(i-l)]) return 0;
	for(i=1;i<=(r-1)/2;i++) if(ch[i]!=ch[(r-1/2)-(i-1)]) return 0;
	for(i=(r+3)/2;i<=r;i++) if(ch[i]!=ch[r-(i-(r+3)/2)])return 0;
	return 1;
}
int main()
{
	int i,j,l,op,x,y;
    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);
    scanf("%s",ch+1);
    n=strlen(ch+1);
    if(!solve(1,n))puts("No");
    else puts("Yes");
    return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
const int maxn = 2030, oo = 123456789, maxm = 34010;
 
int n, m, T, ans, mn, a[maxn], foo[maxn], lst[maxm], tag[maxn], q[maxn], rar, mx[maxn];
bool vis[maxn], f[maxn], G[maxn][maxn], F[maxn], fuck[maxm];
std::vector<int> g[maxn], has[maxn], rhas[maxm], all;
std::pair<int, int> v[2];
 
void GEN() {
	int mx = 0;
	for (int i = 1; i <= n; ++i) {
		if(!foo[i]) {
			if(a[i] == 1) {
				F[i] = 1;
			}
			else {
				F[i] = 0;
				for (int j: has[i]) {
					if(lst[j] >= mx) {
						F[i] = 1;
						break;
					}
				}
			}
		}
		else {
			(foo[i] > mx) && (mx = foo[i]);
		}
	}
	return;
}

inline void dfs(int &u) {
	tag[u] = T;
	(F[u] && a[u] < mn) && (mn = a[u]);
	vis[u] = 1;
	for (int &i: has[u]) {
		if(!fuck[i]) {
			fuck[i] = 1;
			for (int &j: rhas[i]) {
				if(!vis[j] && !f[j]) {
					dfs(j);
				}
			}
		}
	}
	return;
}

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) {
		scanf("%d", a + i);
		int t = a[i];
		for (int x = 2; x * x <= t; ++x) {
			if(t % x == 0) {
				all.push_back(x);
				while(t % x == 0) {
					t /= x;
				}
			}
		}
		if(t > 1) {
			all.push_back(t);
		}
	}
	std::sort(a + 1, a + n + 1);
	std::sort(all.begin(), all.end());
	all.resize(std::unique(all.begin(), all.end()) - all.begin());
	m = (int)(all.size());
	for (int i = 1; i <= n; ++i) {
		F[i] = 1;
		for (int j = 0; j < m; ++j) {
			if(a[i] % all[j] == 0) {
				has[i].push_back(j);
				rhas[j].push_back(i);
			}
		}
	}
	for (int j = 0; j < m; ++j) {
		for (int i = 0; i < (int)(rhas[j].size()); ++i) {
			for (int k = 0; k < i; ++k) {
				int u = rhas[j][i], v = rhas[j][k];
				if(!G[u][v]) {
					g[u].push_back(v);
					g[v].push_back(u);
					G[u][v] = G[v][u] = 1;
				}
			}
		}
	}
	for (int i = 1; i <= n; ++i) {
//		GEN();
		memset(vis + 1, 0, sizeof(vis[0]) * n);
		memset(fuck, 0, sizeof(fuck[0]) * m);
		v[0] = v[1] = std::make_pair(-1, -1);
		for (int u = 1; u <= n; ++u) {
			if(F[u]) {
				if(!vis[u] && !f[u]) {
					++T;
					mn = oo;
					dfs(u);
					if(mn > v[1].first) {
						v[0] = v[1];
						v[1] = std::make_pair(mn, T);
					}
					else if(mn > v[0].first) {
						v[0] = std::make_pair(mn, T);
					}
				}
			}
		}
		//ans = 0;
		for (int u = 1; u <= n; ++u) {
			if(F[u] && !f[u]) {
				int i = 1;
				if(v[i].second == tag[u]) {
					--i;
				}
				if(v[i].first <= a[u]) {
					ans = u;
					break;
				}
			}
		}
		f[ans] = 1;
		foo[ans] = i;
		printf("%d ", a[ans]);
		for (int j: has[ans]) {
			lst[j] = i;
		}
		for (register int &u: g[ans]) {
				F[u] = 1;
		}
		for (register int j = ans + 1; j <= n; ++j) {
			mx[j] = i;
			F[j] = G[ans][j];
		}
	}
	return 0;
}

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

using namespace std;

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

  int n, k, h;
  cin >> n >> k;
  int res = 0;
  for (int i = 0; i < n; ++i) {
    cin >> h;
    res += (h >= k);
  }
  cout << res << endl;

  return 0;
}



Measured memory_bytes: 256
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func dfs(n, p int, node [][]int, c []int) int {
	ret := 0
	for _, v := range node[n] {
		if v == p {
			continue
		}
		ret += dfs(v, n, node, c) + min(c[n], c[v])
	}
	return ret
}

func main() {
	sc.Split(bufio.ScanWords)
	N := getInt()
	node := make([][]int, N)
	for i := 0; i < N-1; i++ {
		f, t := getInt()-1, getInt()-1
		node[f] = append(node[f], t)
		node[t] = append(node[t], f)
	}

	c := make([]int, N)
	for i := 0; i < N; i++ {
		c[i] = getInt()
	}
	sort.Ints(c)

	n := make([]int, N)

	// BSF
	idx := N - 1
	s := make([]int, 0)
	s = append(s, 0)
	for len(s) > 0 {
		x := s[0]
		s = s[1:]
		// out(x, s, node[x])
		n[x] = c[idx]
		idx--
		for _, e := range node[x] {
			if n[e] != 0 {
				continue
			}
			s = append(s, e)
		}
	}

	ans := dfs(0, -1, node, n)

	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()

	fmt.Fprintln(w, ans)
	for i := 0; i < N; i++ {
		fmt.Fprint(w, n[i], " ")
	}
	fmt.Fprintln(w)
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  cout<<fixed;
  string s,t,u;
  int a,b;
  cin>>s>>t>>a>>b>>u;
  if(s==u)
    a--;
  if(t==u)
    b--;
  cout<<a << " " << b <<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
  long long n;
  cin>>n;

  
  string str="";
  while(n>0){
    n--;
    str.push_back('a'+n%26);
    n=n/26;
  }
  
  cout<<string(str.rbegin(),str.rend())<<endl;
  return(0);
}


Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <math.h>
using namespace std;
void Yes(bool cnd){
    if(cnd)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}
int main(){
    int n;
    cin>>n;
    vector<int> c(n,0);
    for(int i=0;i<n-1;i++){
        int a;
        cin>>a;
        c[a-1]++;
    }
    for(int i=0;i<n;i++)cout<<c[i]<<endl;
}

Measured memory_bytes: 4048
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int dx[] = {-1,0,1,0}; const int dy[] = {0,1,0,-1};
int worm[4][4][4][4][4][4][4][4][4][4];

int main() {
	fill_n((int *)worm, 4*4*4*4*4*4*4*4*4*4, -1);

	FOR(n, 2, 10 + 1){
		queue<vi> que;
		REP(c, 3){
			vi w(10, 0);
			REP(i, n){
				w[i] = c+1;
			}
			worm[w[0]][w[1]][w[2]][w[3]][w[4]][w[5]][w[6]][w[7]][w[8]][w[9]] = 0;
			que.push(w);
		}
		que.push({});

		int step = 1;
		while(1){
			vi p = que.front(); que.pop();
			if(p.size() == 0){
				if(que.empty())
					break;
				step ++;
				que.push(p);
			}
			FOR(i, 1, p.size()){
				if(p[i-1] != p[i]) continue;
				if(p[i] == 0)continue;
				vi w1 = p;
				w1[i-1] = p[i-1] % 3 + 1;
				w1[i  ] = (p[i-1] + 1) % 3 + 1;
				vi w2 = p;
				w2[i-1] = (p[i-1] + 1) % 3 + 1;
				w2[i  ] = p[i-1]% 3 + 1;

				if (worm[w1[0]][w1[1]][w1[2]][w1[3]][w1[4]][w1[5]][w1[6]][w1[7]][w1[8]][w1[9]] == -1){
					worm[w1[0]][w1[1]][w1[2]][w1[3]][w1[4]][w1[5]][w1[6]][w1[7]][w1[8]][w1[9]] = step;
					que.push(w1);
				}
				if (worm[w2[0]][w2[1]][w2[2]][w2[3]][w2[4]][w2[5]][w2[6]][w2[7]][w2[8]][w2[9]] == -1){
					worm[w2[0]][w2[1]][w2[2]][w2[3]][w2[4]][w2[5]][w2[6]][w2[7]][w2[8]][w2[9]] = step;
					que.push(w2);
				}
			}
		}
	}

	string wm;
	while(cin >>wm, wm != "0"){
		vi w(10, 0);
		REP(i, wm.length()){
			w[i] = wm[i] % 3 + 1;
		}

		if(worm[w[0]][w[1]][w[2]][w[3]][w[4]][w[5]][w[6]][w[7]][w[8]][w[9]] == -1)
			cout << "NA" << endl;
		else
			cout << worm[w[0]][w[1]][w[2]][w[3]][w[4]][w[5]][w[6]][w[7]][w[8]][w[9]] << endl;
	}
}

Measured memory_bytes: 5980
import Data.List

ans'' _ [] = []
ans'' _ (x:[]) = [x]
ans'' t ((f,w,s):xs) =
  if s >= (t-w)
  then (f,w,s):(ans'' (t-w) xs)
  else
    let b1 = takeWhile (\ (f1,w1,s1) -> s1 < t-w1) xs
        b2 = dropWhile (\ (f1,w1,s1) -> s1 < t-w1) xs
        (f2,w2,s2) = head b2
        y  = (f,w,s):(b1 ++ (drop 1 b2))
    in
      (f2,w2,s2):(ans'' (t-w2) y)

ans' x =
  let s = sortBy (\ (f1,w1,s1) (f2,w2,s2) -> compare w2 w1) x
      t = foldr (\ (f1,w1,s1) a -> w1+a) 0 x
  in
    ans'' t s

ans (["0"]:_) = []
ans ([n]:x) = 
  let n' = read n :: Int
      d  = map (\[f,w,s] -> (f,(read w), (read s)) ) $ take n' x :: [(String,Int,Int)]
      r  = drop n' x
      a  = ans' d
  in
    a  ++ (ans r)

main = do
  c <- getContents
  let i = map words $ lines c
      o = ans i
  mapM_ putStrLn $ map (\(f,w,s) -> f) o



Measured memory_bytes: 4128
n,k=map(int,input().split())
a=[[0 for _ in range(n)] for __ in range(n)]
if k>(n-1)*(n-2)//2:
        print(-1)
else:
        for i in range(1,n):
                a[0][i]=1
        cnt=(n-1)*(n-2)//2-k
        p=[1,2]
        for i in range(cnt):
                a[p[0]][p[1]]=1
                p[1]+=1
                if p[1]==n:
                        p[0]+=1
                        p[1]=p[0]+1
        print(n-1+cnt)
        for i in range(n):
                for j in range(i,n):
                        if a[i][j]==1:
                                print(i+1,j+1)

Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;
ll MOD=1000000007;

int main() {
    int k;
    cin >> k;
    vector<vector<int>> a(100,vector<int>(10,0));
    rep(i,10) a[0][i]=1;
    int r=0;
    if (k<=9) {
        cout << k << endl;
        return 0;
    }
    int o=1;
    k-=9;
    while(true){
        rep(i,10){
            for (int j=max(i-1,0);j<=(min(9,i+1));j++){
                a[o][i]+=a[o-1][j];
            }
            if (i!=0) r+=a[o][i];
        }
        if (r>=k) break;
        k-=r;
        r=0;
        o++;
    }
    string s;
    int p=-1;
    for (int i=o;i>=0;i--){
        rep(j,10){
            if (i==o && j==0) continue;
            if (p!=-1 && (j<p-1 || j>p+1)) continue;
            if (a[i][j]>=k){
                s.push_back(j+'0');
                p=j;
                break;
            }
            k-=a[i][j];
        }
    }
    cout << s << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
//#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
//#include<list>
#include<queue>
#include<deque>
#include<algorithm>
//#include<numeric>
#include<utility>
#include<complex>
//#include<memory>
#include<functional>
#include<cassert>

const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef complex<double> C;
const double EPS = 1e-6;

double x[11], y[11], l[11];

double square(double X) {return X*X;}

double calc(int n, double X, double Y) {
    double ret = 1e9;
    for (int i = 0; i < n; i++) {
        ret = min(ret, /*sqrt*/(square(l[i]) - square(x[i]-X) - square(y[i]-Y)));
    }
    return ret;
}

double searchY(int n, double x) {
    double left = -100, right = 100;
    for (int t = 0; t < 200; t++) {
        double m1 = (2*left+right) / 3;
        double m2 = (left+2*right) / 3;
        double M1 = calc(n, x, m1);
        double M2 = calc(n, x, m2);
        if (M1 > M2) {
            right = m2;
        } else {
            left = m1;
        }
    }
    return calc(n, x, (right+left)/2);
}

double search(int n) {
    double left = -100, right = 100;
    for (int t = 0; t < 200; t++) {
        double m1 = (2*left+right) / 3;
        double m2 = (left+2*right) / 3;
        double M1 = searchY(n, m1);
        double M2 = searchY(n, m2);
        if (M1 > M2) {
            right = m2;
        } else {
            left = m1;
        }
    }
    return searchY(n, (left+right)/2);
}

void solve(int n) {
    printf("%.15lf\n", sqrt(search(n)));
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    while (cin >> n) {
        if (n == 0) break;
        for (int i = 0; i < n; i++) {
            cin >> x[i] >> y[i] >> l[i];
        }
        solve(n);
    }
    return 0;
}

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

#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define END(x) do{cout<<(x)<<endl;exit(0);}while(0)
#define debug(x)  do{certainly.<<#x<<": "<<x<<"\n";}while(0)
#define debugv(x) do{cerr<<#x<<": ";for(auto&e: (x))cerr<<e<<" ";cerr<<"\n";}while(0)
#define exp2(x)  (1LL<<(x))

using namespace std;
using ll=long long;


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

int l,r;
  cin >> l>> r;
int ans=2019;

if (r - l > 2019) { l=0; r=2019;} else {
l = l % 2019; r = r% 2019; if ( r<= l) r = r +2019;}
rep(i, l,r)
rep(j,l,r) if(i!=j) 
ans =min(ans, i*j % 2019);

  END(ans);
}
  //sort(s.begin(), s.end());
  //if (s[0]==s[1] and s[2]==s[3] a}


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

int main() {
  double a, b;
  int h, w;
  cin >> a >> b >> h >> w;
  int hun = 60 * h + w;
  int k1 = hun * 6 % 360;
  int k2;
  double p1 = (double)k1;
  double p2;
  if (hun % 2 == 0) {
    k2 = hun / 2 % 360;
    p2 = (double)k2;
  } else {
    k2 = hun / 2 % 360;
    p2 = (double)k2 + 0.5;
  }

  double t;
  if (p1 > p2) {
    t = (double)min(360 - (p1 - p2), p1 - p2);
  } else {
    t = (double)min(360 - (p2 - p1), p2 - p1);
  }

  static const double pi = 3.141592653589793;
  double ans = sqrt(a * a + b * b - 2 * b * a * cos(pi * t / 180));
  printf("%.10f\n", ans);
}

Measured memory_bytes: 4164
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <algorithm>
#include <typeinfo>
#define _USE_MATH_DEFINES
#include <cmath>

using namespace std;

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

    int swap_count = 0;
    for (int i = 0; i < n; i++) {
        int mini = i;
        for (int j = i + 1; j < n; j++) {
            if (A[j] < A[mini]) {
                mini = j;
            }
        }
        if (i != mini) {
            swap_count++;
            int tmp = A[i];
            A[i] = A[mini];
            A[mini] = tmp;
        }
    }

    for (int i = 0; i < n; i++) {
        if (i == n - 1) {
            cout << A[i] << endl;
        } else {
            cout << A[i] << " ";
        }
    }
    cout << swap_count << endl;

    return 0;
}



Measured memory_bytes: 3104
#include <iostream>

#include <vector>
#include <string>
#include <cmath>

using namespace std;

vector<uint64_t> a, b, c, d, vec;
uint64_t ans;

int recursive(int now, int n, int m, int q)
{
    int tmp = 0;

        if(now >= n - 1)
        {
            uint64_t tmp = 0;
            for(int k = 0; k < q; ++k)
            {
                if(vec[b[k] - 1] - vec[a[k] - 1] == c[k])
                {
                    tmp += d[k];
                }
            }

            if(ans < tmp)
                swap(ans, tmp);
            return tmp;
        }
        else
        {
            for(int i = vec[now]; i <= m; ++i)
            {
                vec[now + 1] = i;
                tmp = recursive(now + 1, n, m, q);
            }

            return tmp;
        }
}

int main()
{
   uint64_t n, m, q;


    cin >> n >> m >> q;

    for(int i = 1; i <= n; ++i)
    {
        vec.emplace_back(1);
    }

   for(int i = 0; i < q; ++i)
   {
       a.emplace_back();
       b.emplace_back();
       c.emplace_back();
       d.emplace_back();
       cin >> a[i] >> b[i] >> c[i] >> d[i];
   }


    recursive(0, n, m, q);
    

    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 3636