akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-

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

MOD=998244353
D=[0]*(N+1)
D[1]=1

S=dict()
B=dict()
for i in range(K):
    L,R=map(int,input().split())
    S[i]=(L,R)
    B[i]=0


for i in range(2,N+1):
    for j in range(K):
        L,R=S[j][0],S[j][1]
        if i-L>0: B[j]+=D[i-L]
        if i-R-1>0: B[j]-=D[i-R-1]

        D[i]+=B[j]
        
    D[i]%=998244353

print(D[N])

Measured memory_bytes: 16944
import java.util.*;
class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Dice dice1 = new Dice(sc.nextInt(),sc.nextInt(),sc.nextInt(),sc.nextInt(),sc.nextInt(),sc.nextInt());
		Dice dice2 = new Dice(sc.nextInt(),sc.nextInt(),sc.nextInt(),sc.nextInt(),sc.nextInt(),sc.nextInt());
		boolean a = solv(dice1, dice2, 0);
		System.out.println((a)?"Yes":"No");
	}
	public static boolean solv(Dice dice1, Dice dice2,int count) {
		if(dice1.Top == dice2.Top && dice1.S == dice2.S && dice1.Bottom == dice2.Bottom && dice1.E == dice2.E && dice1.N == dice2.N && dice1.W == dice2.W) return true;
		if(count == 6) return false;
		Dice tmp = new Dice(dice2.Top,dice2.S,dice2.E,dice2.W,dice2.N,dice2.Bottom);
		tmp.TurnN();
		if(solv(dice1,tmp,count+1)) {
			return true;
		}
		tmp = new Dice(dice2.Top,dice2.S,dice2.E,dice2.W,dice2.N,dice2.Bottom);
        tmp.TurnS();
		if(solv(dice1,tmp,count+1)) {
			return true;
		}
		tmp = new Dice(dice2.Top,dice2.S,dice2.E,dice2.W,dice2.N,dice2.Bottom);
		tmp.TurnE();
        if(solv(dice1,tmp,count+1)) {
			return true;
		}
		tmp = new Dice(dice2.Top,dice2.S,dice2.E,dice2.W,dice2.N,dice2.Bottom);
		tmp.TurnW();
		if(solv(dice1,tmp,count+1)) {
			return true;
		}
		return false;
	}
}

class Dice {
	int Top; 
	int Bottom; 
	int N; 
	int S; 
	int W; 
	int E; 
	Dice(int a, int b, int c, int d, int e, int f) {
		Top = a;
		S = b;
		E = c;
		W = d;
		N = e;
		Bottom = f;
	}
	public void TurnN() {
		int tmp = Top;
		Top = S;
		S = Bottom;
		Bottom = N;
		N = tmp;
	}
	public void TurnW() {
		int tmp = Top;
		Top = E;
		E = Bottom;
		Bottom = W;
		W = tmp;
	}
	public void TurnE() {
		int tmp = Top;
		Top = W;
		W = Bottom;
		Bottom = E;
		E = tmp;
	}
	public void TurnS() {
		int tmp = Top;
		Top = N;
		N = Bottom;
		Bottom = S;
		S = tmp;
	}
}


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

using namespace std;

bool solve() {
  string S;
  cin >> S;

  if (S.length() % 2 == 1) return false;

  for (int i = 0; i < S.length() / 2; i++) {
    if (S[2 * i] != 'h' || S[2 * i+1] != 'i') return false;
  }
  return true;
}

int main() {
  cout << (solve() ? "Yes" : "No") << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
	int H,W,i,j,k;
	for(k=0; k<300; k++){
	    scanf("%d %d",&H,&W);
	    if(H==0 && W==0) break;
	    for(j=0; j<H; j++){
	        for(i=0; i<W; i++){
	            putchar('#');
	        }
	        putchar('\n');
	    }
	    putchar('\n');
    }
    return 0;
}


Measured memory_bytes: 2104
#include<bits/stdc++.h>
 
int main(){
 
using namespace std;
 
    int s,t=1;
    while(true){
        scanf("%d",&s);
        if(s==0) break;
        printf("Case %d: %d\n",t,s);
        t++;
    }
    return 0;
}






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

#define int ll
#define pb push_back

using ll=long long;
using vll=vector<ll>;
using vvll=vector<vll>;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vpii=vector<pii>;
using vvpii=vector<vpii>;

int solve(string s) {
    assert(s.size() > 0);
    s.push_back('.');
    int ops = 0;
    int i = 0;
    while (i < s.size()) {
        char currch = s[i];
        int samecnt = 0;
        for (int j = i; j < s.size() && s[j] == currch; ++j)
            ++samecnt;
        assert(samecnt >= 1);
        ops += samecnt/2;
        i = i+samecnt;
    }
    return ops;
}

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

    string s;
    cin >> s;
    int k;
    cin >> k;

    if (s.front() != s.back()) {
        cout << k*solve(s) << '\n';
        return 0;
    }

    char a = s.front();
    int n = 0;
    for (char c: s) {
        if (c == a)
            ++n;
        else
            break;
    }
    int m = 0;
    for (int i=s.size()-1; i>=0; --i) {
        if (s[i] == a)
            ++m;
        else
            break;
    }

    if (n == s.size()) {
        assert(n == m);
        cout << (n*k)/2 << '\n';
        return 0;
    }

    assert(n + m < s.size());
    int internal = solve(s.substr(n, s.size()-n-m));
    cout << k*internal + n/2 + m/2 + (k-1)*((n+m)/2) << '\n';
}


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

int main(){
  ll k;
  cin>>k;
  if(k==1||k==7){
    cout<<1<<endl;
    return 0;
  }
  ll now=7;
  for(int i=2;i<1100000;i++){
    now=now*10+7;
    now%=k;
    if(now==0){
      cout<<i<<endl;
      return 0;
    }
  }
  cout<<-1<<endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define scn(n) scanf("%d",&n)
#define scnll(n) scanf("%lld",&n)
#define nl printf("\n")
#define YES printf("YES\n")
#define Yes printf("Yes\n")
#define yes printf("yes\n")
#define NO printf("NO\n")
#define No printf("No\n")
#define no printf("no\n")
using namespace std;
int main(){
    string a,b;
    cin>>a;
    cin>>b;
    int al=a.length();
    int bl=b.length();
    int dp[al+1][bl+1];
    for(int i=0;i<=al;i++) dp[i][0]=0;
    for(int i=0;i<=bl;i++) dp[0][i]=0;

    for(int i=1;i<=al;i++){
        for(int j=1;j<=bl;j++){
            if(a[i-1]==b[j-1]) dp[i][j]=dp[i-1][j-1]+1;
            else dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
        }
    }
    string s;
    int i=al;
    int j=bl;
    while(i>0&&j>0){
        if(dp[i][j]==dp[i-1][j]) i--;
        else if(dp[i][j]==dp[i][j-1]) j--;
        else if(dp[i][j]==dp[i-1][j-1]){
            i--; j--;
        }
        else{
            s.pb(a[i-1]);
            i--; j--;
        }
    }
    reverse(s.begin(),s.end());
    cout<<s;
    nl;
}


Measured memory_bytes: 38780
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	n := nextInt()
	m := map[string]int{}

	for i := 0; i < n; i++ {
		m[nextStr()]++
	}
	maxnum := 0
	for v := range m {
		maxnum = max(maxnum, m[v])
	}
	var anslist []string
	for v := range m {
		if maxnum == m[v] {
			anslist = append(anslist, v)
		}
	}
	sort.Strings(anslist)

	for i := 0; i < len(anslist); i++ {
		fmt.Printf("%s\n", anslist[i])
	}

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

// ---- readfunc
func scanInit() {
	const cap = 200 * 1024 // Default=64
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 32564
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n;
int gyx(int x)
{
	if(x<=1)return 0;
	for(int i=2;i<=(int)sqrt(x);i++)
	{
		if(x%i==0)return 0;
	}
	return 1;
}
signed main()
{
	
	cin>>n;
	for(int i=n;;i++)
	{
		if(gyx(i))
		{cout<<i<<endl;
		return 0;
		}
	}
}

Measured memory_bytes: 256
#ifdef LOCAL111
	#define _GLIBCXX_DEBUG
#else
	#define NDEBUG
#endif
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
const int INF = 1e9;
using namespace std;
template<typename T, typename U> ostream& operator<< (ostream& os, const pair<T,U>& p) { os << '(' << p.first << ' ' << p.second << ')'; return os; }

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#ifdef LOCAL111
	#define DEBUG(x) cout<<#x<<": "<<(x)<<endl
	template<typename T> void dpite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
#else
	#define DEBUG(x) true
	template<typename T> void dpite(T a, T b){ return; }
#endif
#define F first
#define S second
#define SNP string::npos
#define WRC(hoge) cout << "Case #" << (hoge)+1 << ": "
template<typename T> void pite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}

typedef long long int LL;
typedef unsigned long long ULL;
typedef pair<int,int> P;

void ios_init(){
	//cout.setf(ios::fixed);
	//cout.precision(12);
#ifdef LOCAL111
	return;
#endif
	ios::sync_with_stdio(false); cin.tie(0);
}

int main()
{
	ios_init();
	string s;
	while(cin >> s) {
		int n = SZ(s);
		if(s[0] == '0' || s[n-1] == '1') {
			cout << -1 << endl;
			continue;
		}

		bool ex = true;
		
		REP(i, n/2) {
			if(s[i] != s[n-2-i]) {
				DEBUG(i);
				ex = false;
			}
		}

		vector<P> ans;
		ans.emplace_back(0, 1);
		int cnt = 1;
		int root = 1;
		FOR(i, 1, n/2) {
			if(s[i] == '1') {
				cnt++;
				ans.emplace_back(root, cnt);
				root = cnt;
			} else {
				DEBUG(i);
				cnt++;
				ans.emplace_back(root, cnt);
			}
		}
		DEBUG(root);
		if(!ex) {
			cout << -1 << endl;
		} else {
			REP(i, SZ(ans)) {
				cout << ans[i].F+1 << ' ' << ans[i].S+1 << endl;
			}
			REP(i, n-1-SZ(ans)) {
				cout << root+1 << ' ' << cnt+i+1+1 << endl;;
			}
		}
		
	}
	return 0;
}


Measured memory_bytes: 1992
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <map>
#include <set>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <stack>
#include <queue>
#include <utility>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(s) (s).begin(),(s).end()
#define rep(i,l,n) for(int i=l;i<n;i++)
#define rer(i,l,n) for(int i=l;i<=n;i++)
#define rrep(i,n,l) for(int i=n-1;i>=l;i--)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define pb(a) push_back(a);
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector<int> vi;
//typedef vector<lint> vli;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

ll n, sum = 0;
ll y[110], m[110], d[110];

int main() {
	cin >> n;
	REP(i, n) {
		cin >> y[i] >> m[i] >> d[i];
		sum = 195 * (y[i] - 1) + 5 * ((y[i] - 1) / 3);
		if (y[i] % 3 == 0) {
			sum += 20 * (m[i] - 1);
		}
		else {
			sum += 20 * (m[i] - 1) - (m[i] - 1) / 2;
		}
		sum += d[i] - 1;
		cout << 196470 - sum << endl;
		sum = 0;
	}
}

Measured memory_bytes: 1156
//直径がK以下の木とは？、直径の偶奇で場合分け
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int n, k;
int a[2000], b[2000];
vector<int> et[2000];

int dfs(int p, int v, int dist) {
	if (dist == 0) return 1;
	int sz = 0;
	for (int i = 0; i < et[v].size(); i++) {
		if (et[v][i] == p) continue;
		sz += dfs(v, et[v][i], dist - 1);
	}
	sz++;
	return sz;
}

int main() {
	int i;
	
	cin >> n >> k;
	for (i = 0; i < n - 1; i++) {
		cin >> a[i] >> b[i];
		a[i]--;
		b[i]--;
		et[a[i]].push_back(b[i]);
		et[b[i]].push_back(a[i]);
	}
	
	int tree_size = 0;
	if (k % 2) {
		for (i = 0; i < n - 1; i++) {
			tree_size = max(tree_size, dfs(b[i], a[i], k / 2) + dfs(a[i], b[i], k / 2));
		}
	}
	else {
		for (i = 0; i < n; i++) {
			tree_size = max(tree_size, dfs(-1, i, k / 2));
		}
	}
	cout << n - tree_size << endl;
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
typedef long long ll;
const ll mod=998244353;
const int N=3e3+5;
using namespace std;
int dp[N][N][2];
int main()
{
    int A,B,C,D;cin>>A>>B>>C>>D;
    if(C>A) dp[C][D][0]=1;
    if(D>B) dp[C][D][1]=1;

    ll ans=0;
    for(int i=C;i>=A;i--)
        for(int j=D;j>=B;j--)
    {
        dp[i][j-1][0]=(dp[i][j-1][0]+(ll)dp[i][j][1]*i)%mod;
        dp[i][j-1][1]=(dp[i][j-1][1]+(ll)dp[i][j][1]*i)%mod;
        dp[i-1][j][0]=(dp[i-1][j][0]+(ll)dp[i][j][0]*j)%mod;
        dp[i-1][j][1]=(dp[i-1][j][1]+(ll)dp[i][j][0])%mod;

        if(i==A&&j-1==B)
            ans=(ans+(ll)dp[i][j][1]*i)%mod;
        if(i-1==A&&j==B)
            ans=(ans+(ll)dp[i][j][0]*j)%mod;
    }
    if(A==C&&B==D) ans=1;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 73964
n = int(input())
w = list(map(int,input().split()))
p = w[0]
q = sum(w)-w[0]

res = abs(p-q)
for i in range(1,n):
  p += w[i]
  q -= w[i]
  res = min(res,abs(p-q))
print(res)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define reg register

using namespace std;

typedef long long ll;
const int maxn = 100005;

inline ll read() {
    reg ll s = 0, t = 0; reg char ch = getchar();
    while (!isdigit(ch)) t |= ch == '-', ch = getchar();
    while (isdigit(ch)) s = (s << 1) + (s << 3) + (ch ^ 48), ch = getchar();
    return t ? -s : s;
}

int n, q, k;
int sum[maxn];
int main() {
    n = read(), k = read(), q = read(); reg int x;
    for (reg int i = 1; i <= q; i++) x = read(), sum[x]++;
    for (reg int i = 1; i <= n; i++) {
        if (k - (q - sum[i]) <= 0) puts("No");
        else puts("Yes");
    }
    return 0;
}


Measured memory_bytes: 1024
import java.util.HashSet;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		int x = sc.nextInt();
		int n = sc.nextInt();

		HashSet<Integer> set = new HashSet<Integer>();

		for(int i = 0; i < n; i++){
			set.add(sc.nextInt());
		}

		if(!set.contains(x)){
			System.out.println(x);
			return;
		}

		for(int i = 1; ; i++){
			for(int j = 0; j < 2; j++){
				int tmp = x - i*(int)Math.pow(-1, j);

				if(!set.contains(tmp)){
					System.out.println(tmp);
					return;
				}
			}
		}
	}
}

Measured memory_bytes: 27240
#include<stdio.h>
 
int main()
{
  int t[4][3][10]={0};
  int b,f,r,v,i,j,k,n;
  scanf("%d",&n);
  for(i=0;i<n;i++){
  scanf("%d%d%d%d",&b,&f,&r,&v);
t[b-1][f-1][r-1]=t[b-1][f-1][r-1]+v;

      
    
  }
  for(i=0;i<4;i++){
    for(j=0;j<3;j++){
      for(k=0;k<10;k++){
	printf(" %d",t[i][j][k]);
      }
      printf("\n");
    }
    if(i!=3)printf("####################\n");
  }
  return 0;
}


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

int main() {
    int n;
    cin>>n;
    vector<int> w(n);
    vector<int> sum(n);
    rep(i,n){
        cin>>w[i];
        if(i==0) sum[i]=w[i];
        else sum[i]=sum[i-1]+w[i];
    }
    int ans=sum[n-1];
    rep(i,n-1){
        ans=min(ans,std::abs(sum[n-1]-sum[i]-sum[i]));
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3580
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)

	n := getNextInt(scanner)
	s := getNextString(scanner)
	t := getNextString(scanner)
	for i := 0; i < n; i++ {
		fmt.Fprintf(writer, "%c", s[i])
		fmt.Fprintf(writer, "%c", t[i])
	}

	fmt.Fprintln(writer, "")
	writer.Flush()
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector< vector<int> > VVI;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()

int main(){
  string S;
  cin>>S;
  if(S=="AAA"||S=="BBB") cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
typedef long long ll ;
#define rep(i, a, b) for (int i = a; i <= b; ++ i) 
const int N = 305, mo = 1e9 + 7;
using namespace std ;

int n, m, f[2][3][N][N] ;
struct poi {
	int l, r, val ;
} a[N] ;

inline void upd(int &x, int y) {
	x = (x + y) % mo ; 
}

bool cmp(poi a, poi b) {
	return a.r < b.r ;
}

int main() {
	scanf("%d%d", &n, &m) ;
	rep(i, 1, m) {
		scanf("%d%d%d", &a[i].l, &a[i].r, &a[i].val) ;
	}
	sort(a + 1, a + m + 1, cmp) ;
	int c = 0, top = 1 ;
	rep(i, 0, 2) f[c][i][0][0] = 1 ;
	rep(pos, 2, n + 1) {
		c ^= 1 ;
		rep(i, 0, 2) rep(j, 0, n) rep(k, 0, n) f[c][i][j][k] = 0 ;
		for ( ; top <= m && a[top].r == pos - 1 ; ++ top) {
			int l = a[top].l ;
			rep(i, 0, 2) rep(j, 0, pos - 1) rep(k, 0, pos - 1) {
				int cnt = (j >= l) + (k >= l) + 1 ;
				if (cnt != a[top].val) f[c ^ 1][i][j][k] = 0 ;
			}	
		}
		if (pos > n) break ;
		rep(i, 0, 2) rep(j, 0, pos - 1) rep(k, 0, pos - 1) {
			if (j + k && j == k) continue ;
			if (j == pos - 1) {
				rep(p, 0, pos - 1) upd(f[c][i][j][k], f[c ^ 1][(i + 1) % 3][k][p]) ;
			} else if (k == pos - 1) {
				rep(p, 0, pos - 1) upd(f[c][i][j][k], f[c ^ 1][(i + 2) % 3][p][j]) ;
			} else {
				upd(f[c][i][j][k], f[c ^ 1][i][j][k]) ;
			}
		}
	}
	int ans = 0 ; 
	rep(i, 0, 2) rep(j, 0, n - 1) rep(k, 0, n - 1) upd(ans, f[c ^ 1][i][j][k]) ;
	printf("%d\n", ans) ;
	return 0 ;
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
auto fl = [](auto a, auto b) { assert(b != 0); return a / b - (a % b != 0 && ((a >= 0) != (b >= 0)) ? 1 : 0); };
auto ce = [](auto a, auto b) { assert(b != 0); return a / b + (a % b != 0 && ((a >= 0) == (b >= 0)) ? 1 : 0); };
auto mo = [](auto a, auto b) { assert(b != 0); a %= b; if(a < 0) { a += abs(b); } return a; };
LL gcd(LL a, LL b) { return (b == 0 ? a : gcd(b, a % b)); }
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)

// ---- ----

int main() {
	LL n, k;
	cin >> n >> k;
	vector<LL> h(n);
	inc(i, n) { cin >> h[i]; }
	
	sort(RALL(h));
	
	LL s = 0;
	inc(i, n) { s += (i < k ? 0 : h[i]); }
	
	cout << s << endl;
	
	return 0;
}


Measured memory_bytes: 1792
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;
//const int inf = 1e9; //1(1倍)e(指数)9(10^9)
//const ll MX = 1e18; //1(1倍)e(指数)18(10^18)
//const ll MOD = 1e9 + 7; //1000000007で割った余りを聞かれたら使う
//加算代入演算子は+=
//int 2^31 10^9まで
//intは10桁、long longは18桁、doubleは308桁、long double は4932桁
//10^10くらいまででdoubleは誤差が発生しちゃう。なるべく整数にすること
//doubleからlong longにキャストするときは、+0.5で切り捨ての誤差を調整
//__int128()で128bit対応の整数（多倍長整数）
//||は片方が成り立つとき
int main()
{
    char str[200];
    scanf("%s", str);
    int n = strlen(str);
    for (int i = n - 2; i; i -= 2) {
        if(strncmp(str, str + i / 2, i / 2) == 0) {
            printf("%d\n", i);
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MN 200005
#define Mod 998244353
#define int long long
struct data{
	int x,y;
}w[MN];
int v1[MN],v2[MN];
bool cmp(data a,data b){
	return a.x<b.x;
}
int n,N,R[MN],L[MN],bin[MN],ans;
void add(int *a,int x,int v){
	while(x<=N){
		a[x]+=v;
		x+=(x&(-x));
	}
}
int ask(int *a,int x){
	int ans=0;
	while(x){
		ans=(ans+a[x])%Mod;
		x-=(x&(-x));
	}
	return ans;
}
int calc(int lu,int ru,int ld,int rd){

	return (((bin[lu]-1)*(bin[rd]-1)%Mod+(bin[ld]-1)*(bin[ru]-1)%Mod)%Mod

			+((bin[lu]-1)*(bin[ru]-1)%Mod*(bin[rd]-1)%Mod)
			+((bin[lu]-1)*(bin[ru]-1)%Mod*(bin[ld]-1)%Mod)
			+((bin[ld]-1)*(bin[ru]-1)%Mod*(bin[rd]-1)%Mod)
			+((bin[lu]-1)*(bin[ld]-1)%Mod*(bin[rd]-1)%Mod)

			+((bin[lu]-1)*(bin[ru]-1)%Mod*(bin[ld]-1)%Mod*(bin[rd]-1)%Mod))%Mod;
			
}
signed main(){
	scanf("%lld",&n);
	bin[0]=1;
	for(int i=1;i<=n;++i)bin[i]=(bin[i-1]<<1)%Mod;
	for(int i=1;i<=n;++i){
		scanf("%lld%lld",&w[i].x,&w[i].y);
		v1[++N]=w[i].x;v2[N]=w[i].y;
	}
	sort(v1+1,v1+1+N);sort(v2+1,v2+1+N);
	for(int i=1;i<=n;++i){
		w[i].x=lower_bound(v1+1,v1+1+N,w[i].x)-v1;
		w[i].y=lower_bound(v2+1,v2+1+N,w[i].y)-v2;
	}
	sort(w+1,w+1+n,cmp);
	for(int i=1;i<=n;++i)add(R,w[i].y,1);
	for(int i=1;i<=n;++i){
		add(L,w[i].y,1);add(R,w[i].y,-1);
		int lu=i-ask(L,w[i].y),ru=n-i-ask(R,w[i].y),ld=ask(L,w[i].y-1),rd=ask(R,w[i].y-1);
		ans=(ans+calc(lu,ru,ld,rd)+bin[n-1])%Mod;
//		cout<<"HI "<<i<<" "<<ans<<endl;
	}
	printf("%lld",ans);
	return 0;
} 


Measured memory_bytes: 11264
x1, y1, x2, y2 = map(int, input().split())
dx, dy = x2 - x1, y2 - y1
x3, y3 = x2 - dy, y2 + dx
x4, y4 = x1 - dy, y1 + dx

print(x3, y3, x4, y4)

Measured memory_bytes: 2940
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

signed main() {
	vector<int>h(5);
	while (cin >> h[0], h[0]) {
		vector<int>aiko(4, 0);
		aiko[h[0]]++;
		rep(i, 1, 5) {
			cin >> h[i]; aiko[h[i]]++;
		}
		if (aiko[1] && aiko[2] && aiko[3]||aiko[1]==5||aiko[2]==5||aiko[3]==5)rep(i,0,5)cout << 3 << endl;
		else {
			int win, lose;
			if (aiko[1] == 0) { win = 2; lose = 3; }
			else if (aiko[2] == 0) { win = 3; lose = 1; }
			else win = 1; lose = 2;
			rep(i, 0, 5) {
				if (h[i] == win)cout << 1 << endl;
				else cout << 2 << endl;
			}


		}

	}
	return 0;
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
 
using namespace std;
 
#define debug(x) '[' << #x << " is: " << x << "] "
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
 
const int mod = 1e9+7;
 
ll ans;
ll n,k;

struct Matrix{
	vector<vector<ll>> mat;

	Matrix(ll val){
		mat = vector<vector<ll>> (n,vector<ll> (n,val));
	}

	Matrix operator* (const Matrix &rhs){
		Matrix res = Matrix(0);

		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				for(int k=0;k<n;k++){
					res.mat[i][k] = (res.mat[i][k] + (mat[i][j] * rhs.mat[j][k])%mod)%mod;
				}
			}
		}
		return res;
	}
};

Matrix mat(0),idn(0);


Matrix calc(ll n,Matrix a){
	if(!n)return idn;
	Matrix res = calc(n/2,a);
	res = res * res;
	if(n%2){
		res = res * a;
	}
	return res;
}

void add_mod(ll &a,ll b){
	a += b;
	if(a >= mod)a -= mod;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.precision(10);
	cout << fixed;
	#ifndef ONLINE_JUDGE
//		freopen("input.txt","r",stdin);
	#endif

	cin>>n>>k;
	
	mat = idn = Matrix(0);

	for(int i=0;i<n;i++){
		idn.mat[i][i] = 1;
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			cin>>mat.mat[i][j];
		}
	}
	Matrix res = calc(k,mat);
	ll ans = 0;
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++){
			add_mod(ans,res.mat[i][j]);
		}
	cout << ans << endl;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007
#define Vi vector<int>
#define Vl vector<long long>
#define pb(a) push_back(a)

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=10000000000000000001;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};
struct edge{int to,cost;};
struct pos{
	int x,y;
};

int main() {

	int n;
	cin>>n;
	rep(i,n){
		ll a=0,b=0,f=0;
		rep(j,10){
			ll x;
			cin>>x;
			if(f==1)continue;
			if(x<a&&x<b)f=1;
			else if(x>max(a,b)){
				if(a>b)a=x;
				else b=x;
			}else{
				if(a>b)b=x;
				else a=x;
			}
		}
		if(f==0)cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}

	return 0;
}



Measured memory_bytes: 3100
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <set>
#include <sstream>
#include <map>
#include <queue>
#include <stack>

using namespace std;

int w,h;
int sx,sy,gx,gy;
//int d[22][22];
int res;
int dx[]={0,1,0,-1};
int dy[]={-1,0,1,0};
int table[22][22];
void dfs(int y,int x,int cnt){
	
	if(cnt==11 || res<=cnt) return;
	
	for(int k=0;k<4;k++){
		int ny=y,nx=x;
		while( (0<=nx+dx[k] && nx+dx[k]<w) && (0<=ny+dy[k] && ny+dy[k]<h) && (table[ny+dy[k]][nx+dx[k]]!=1) ){
			nx+=dx[k],ny+=dy[k];
			if(nx==gx && ny==gy){
				res=cnt;
				break;
			}
		}
		 
		if(nx==x && ny==y){
			//cout<<"case1"<<endl;
			continue;
		}
		 
		if((0<=nx+dx[k] && nx+dx[k]<w) && (0<=ny+dy[k] && ny+dy[k]<h) && (table[ny+dy[k]][nx+dx[k]]==1)){
			table[ny+dy[k]][nx+dx[k]]=0;
			dfs(ny,nx,cnt+1);
			table[ny+dy[k]][nx+dx[k]]=1;
		}else if(nx!=gx || ny!=gy){
			//cout<<"case2"<<endl;
			continue;
		}else{
			dfs(ny,nx,cnt+1);
		}		 

	}
	
}

int main()
{
	
	while(cin>>w>>h,w||h){
		
		for(int y=0;y<h;y++){
			for(int x=0;x<w;x++){
				cin>>table[y][x];
				if(table[y][x]==2) sy=y,sx=x;
				if(table[y][x]==3) gy=y,gx=x;
			}
		}
		res=1e7;
		
		//y,x,cnt,table
		dfs(sy,sx,1);
/*
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				cout<<(d[i][j]==1e7 ? 0 : d[i][j])<<" ";
			}
			cout<<endl;
		}
*/
		if(res==1e7) res=-1;
		cout<<res<<endl;
		
	}

	
	
	return 0;
}

Measured memory_bytes: 1160
import java.util.*;
import java.util.Collections;
import java.util.ArrayList;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        String s = sc.next();
        String t = sc.next();
        String S = "";
        String T = "";
        int ls = s.length();
        int lt = t.length();
        ArrayList<String> lists = new ArrayList<String>();
        ArrayList<String> listt = new ArrayList<String>();

        for(int i=0; i<ls; i++){
            lists.add(s.substring(i, i+1));
        }
        for(int i=0; i<lt; i++){
            listt.add(t.substring(i, i+1));
        }

        Collections.sort(lists);
        Collections.sort(listt, Collections.reverseOrder());

        ArrayList<String> al = new ArrayList<String>();

        for(int i=0; i<ls; i++){
            S += lists.get(i);
        }
        al.add(S);
        for(int i=0; i<lt; i++){
            T += listt.get(i);
        }
        al.add(T);

        Collections.sort(al);

        if(al.get(0).equals(S) && !S.equals(T)){
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        }
    } 
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
int main()
{
     long long int l,r;
     cin>>l>>r;
     if(r-l>=2018)
     {
          cout<<0;
     }
     else
     {
          long long int res=2020,i,ans,j;
          for(i=l;i<=r;i++)
          {
               for(j=i+1;j<=r;j++){
               ans=(i*j)%2019;
               res=min(ans,res);
               }
          }
          cout<<res;
     }
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

typedef long long int ll;
const int INF =INT32_MAX;


int N,K;
int h[100005];

int dp[100005];

int main(){
    cin>>N>>K;
    for(int i=0;i<N;++i)cin>>h[i];
    for(int i=0;i<N;++i)dp[i]=INF;
    dp[0]=0;
    for(int i=0;i<N;++i){
        for(int j=1;j<=K;++j){
            dp[i+j]=min(dp[i]+abs(h[i+j]-h[i]),dp[i+j]);
        }
    }
    cout<<dp[N-1]<<endl;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <limits.h>

int main(void)
{
	int array[100000], i, j, n, k, sum, max;
	
	while (1){
		scanf("%d %d", &n, &k);
		
		if (n == 0 && k == 0){
			break;
		}
		
		for (i = 0; i < n; i++){
			scanf("%d", &array[i]);
		}
		
		for (i = 0; i < n - 1; i++){
			array[i + 1] += array[i];
		}
		
		max = INT_MIN;
		
		for (i = 0; i <= n - k; i++){
			if (i == 0){
				sum = array[k - 1];
			}
			else {
				sum = array[i + k - 1] - array[i - 1];
			}
			
			if (max < sum){
				max = sum;
			}
		}
		
		printf("%d\n", max);
	}
	
	return (0);
}

Measured memory_bytes: 988
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int n;
    string s;
    cin >> n >> s;
    int ans = 0;
    int x = 0;
    rep(i, n){
        if(s[i] == 'I') x++;
        else x--;
        ans = max(ans, x);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
vs,e = map(int,input().split())
edges = [[0]*vs for j in range(vs)] #隣接行列
for i in range(e):
  u,v,c = map(int,input().split())
  edges[u][v] = c                   #隣接行列にコストを追加していく

# print('edges',edges)

def bfs(s,t,edges):
  vs = len(edges) #隣接行列の縦の長さ
  visited = [False]*vs #頂点はvs個
  visited[s] = True    #bfsの始点をtrueに
  que = [s]
  parents = [-1]*vs
  while que:
    u = que.pop(0)   #queの先頭から主人公を取り出す
    if u == t:       #主人公が終点なら親を返す
      return parents
    for v in range(vs): #頂点v分forを回す
      if not visited[v] and edges[u][v] >0: #未訪問かつ容量があれば
        parents[v] = u  #vの親に始主人公sを入れる
        visited[v] = True
        que.append(v)
  return None


inf = float('inf')
ans = 0
while True:
  parents = bfs(0,vs-1,edges) #bfsで親を探す
  # print('parents',parents)
  if parents is None:
    break
  v = vs-1 #後ろから
  f = inf
  while parents[v] != -1:
    u = parents[v]
    f = min(f,edges[u][v]) #フローの量
    v = u

  ans += f
  v = vs - 1
  while parents[v] != -1:
    u = parents[v]
    edges[u][v] -=f     #逆辺分を押し戻す
    edges[v][u] +=f     #逆辺分を追加
    v = u
print(ans)














Measured memory_bytes: 5696
s = input()
ans ='AC'
if s[0]!='A':
  ans = 'WA'

if s[2:-1].count('C')!=1 or s.count('C')>=2:
  ans = 'WA'
  
nc = []  
for c in s[1:]:
  if c!= 'C':
    nc.append(c)
if not ''.join(nc).islower():
  ans = 'WA'

print(ans)  

Measured memory_bytes: 3064
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<functional>
#include <random>
#include<iostream>
#include<iomanip>
using namespace std;
int dp_left[200001];/*1日目からi日目まで見て、何日働けるか？*/
int dp_right[200001];

int main() {
	int N, K, C;
	string S;
	cin >> N >> K >> C;
	cin >> S;

	dp_left[0] = 0;
	for (int i = 1; i <= N; i++) {
		int mae;
		if (i <= C) {
			mae = dp_left[0];
		}
		else {
			mae = dp_left[i - C - 1];
		}
		if (S[i - 1] == 'o') {
			if (mae + 1 > dp_left[i - 1]) {
				dp_left[i] = mae + 1;
			}
			else {
				dp_left[i] = dp_left[i - 1];
			}
		}
		else {
			dp_left[i] = dp_left[i - 1];
		}
//		cout << dp_left[i] << " ";
	}
//	cout << "\n";

	dp_right[0] = 0;
	for (int i = 1; i <= N; i++) {
		int mae;
		if (i <= C) {
			mae = dp_right[0];
		}
		else {
			mae = dp_right[i - C - 1];
		}
		if (S[N - i] == 'o') {
			if (mae + 1 > dp_right[i - 1]) {
				dp_right[i] = mae + 1;
			}
			else {
				dp_right[i] = dp_right[i - 1];
			}
		}
		else {
			dp_right[i] = dp_right[i - 1];
		}
//		cout << dp_right[i] << " ";
	}
	if (dp_left[N] > K) {
		cout << "\n";  return 0;
	}
	
	for (int i = 0; i < N; i++) {
		if (dp_left[i] + dp_right[N - 1 - i] < K) {
			cout << i + 1 << "\n";
		}
	}
	
}

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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    string s; cin>>s;
    int n=s.length();
    int res=1e9;
    int a=0;
    int b=0;
    for(int i=0;i<n;i++)
    {
        if(i%2==0)
        {
            if(s[i]=='1') a++;
        }
        if(i%2==1)
        {
            if(s[i]=='0') a++;
        }
    }
    for(int i=0;i<n;i++)
    {
        if(i%2==0)
        {
            if(s[i]=='0') b++;
        }
        if(i%2==1)
        {
            if(s[i]=='1') b++;
        }
    }\
    cout<<min(a,b);
    return 0;
}


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

int main() {
  ll L, R;
  cin >> L >> R;

  if (R - L >= 2019) {
    cout << 0 << endl;
    return 0;
  }

  ll minv = 2019;
  for (ll i = L; i < R; i++) {
    for (ll j = i+1; j <= R; j++) {
      minv = min(minv, (i*j)%2019);
    }
  }

  cout << minv << endl;
}


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

int main() {
	int N, K;
	cin >> N >> K;
	int64_t ans = 0;
	for (int i = K + 1, j;i <= N;++ i) {
		j = (N + 1) / i;
		ans += min(N, j * (i - K) + max(0, N - j * i - K + 1));
	}
	cout << ans;
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

まず、自明にa, b>K
ここで、bを固定すると、Kからb-1, b+Kから2b-1……が条件を満たす
ということは、N≧nb-1においてb-K個と、nb-1>N≧(n-1)bとなるような値においてN-(n-1)b-K+1個
後はnに関しては、(N+1)/b≧nより求まる
*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define prin(a) cout<<(a)<<endl
using ll=int64_t;
using namespace std;

//define gcd and lcm (using 64bit)
ll gcd(ll a,ll b){
    if (a < b) {
        //^はxor(bitwise operator)。以下三行でswap(a,b)を行っている。
        a ^= b;
        b ^= a;
        a ^= b;
    }
    //only when b==0,this program finds that b means false and returns a.
    return b ? gcd(b, a % b) : a;
}

ll lcm(ll a,ll b){
    return a * b / gcd(a, b);
}


int main(){
    int a;
    string s;
    cin>>a>>s;
    cout<<(a>=3200? s: "red")<<endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <set>
#include <cmath>
#include <map>
#include <cstring>
#include <stack>
#include <cstdio>
#include <complex>
#include <iomanip>
#include <cctype>
#include <cassert>
#include <numeric>
#include <climits>
#include <deque>
#include <random>
#include <functional>
#include <unordered_map>
#define rep(i,n) for(int i=0;i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define show(x) cout << #x << " = " << x << endl;
int main(){
    int n,m;
    cin >> n >> m;
    int a[100][100];
    vector<pii>p;
    rep(i,m){
        int c,d;
        cin >>c >> d;
        p.push_back(pii(c,d));
    }
    int ans = 0;
    rep(i,m){
        rep(i,100){
            rep(j,100){
                a[i][j] = 1<<28;
            }
            a[i][i] = 0;
        }
        rep(j,m){
            if(j!=i){
                int c = p[j].first;
                int d = p[j].second;
                a[c-1][d-1] = 1;
                a[d-1][c-1] = 1;
            }
        }
        rep(k,n){
            rep(i,n){
                rep(j,n){
                    a[i][j] = min(a[i][j],a[i][k] + a[k][j]);
                }
            }
        }
        bool ok = true;
        rep(i,n){
            rep(j,n){
                if(a[i][j] == 1<<28){
                    ok = false;
                }
            }
        }
        if(!ok){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{

    public static void main(String args[]){

        Scanner scan = new Scanner(System.in);
        Integer a = scan.nextInt();
        Integer b = scan.nextInt();

        if(a > b){
            for(int i=0;i<a;i++)
                System.out.print(b);
        }else{
            for(int i=0;i<b;i++)
                System.out.print(a);
        }
    }

    static int factorial(int n){
        if(n == 0){
          return 1;
        }
        return n * factorial(n-1);
      }
}


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

int main() {
  string S;
  cin >> S; 
  int c = 0;
  
  for(int i = 0; i < 3; i++){
    if(S[i] == S[i+1]){
      c++;
      cout << "Bad" << endl;
      break;
    }
  }
if(c == 0){
  cout << "Good" << endl;
}
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<array>
#include<algorithm>
#include<deque>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<list>

int main(void) {
	using namespace std;
	int N, A,res;
	cin >> N >> A;
	res = N * N - A;
	cout << res << endl;

	/*int a, b,c;
	cin >> a >> b;
	c = a * b;
	c = c % 2;
	if (c == 0) {
		cout << "Even" << endl;
	}
	else if(c == 1){
		cout << "Odd" << endl;
	}*/

	/*int A, B, a, b, c;
	cin >> A >> B;
	a = A + B;
	b = A - B;
	c = A * B;
	if (a > b && a > c) {
		cout << a << endl;
	}
	else if (b > a && b > c) {
		cout << b << endl;
	}
	else if (c > a && c > b) {
		cout << c << endl;
	}*/

	/*int K, S,res = 0;
	cin >> K >> S;
	for (int X = 0; X <= K;X++) {
		for (int Y = 0; Y <= K; Y++) {
			for (int Z = 0; Z <= K; Z++) {
				if (X + Y + Z == S) {
					res += 1;
				}

			}
		}
	}
	cout << res << endl;*/

	/*int N,a;
	cin >> N;
	set<int>s;
	for (int i = 0; i < N;i++) {
		cin >> a;
		s.insert(a);
	}
	cout << s.size() << endl;*/

	/*int N, a, res;
	vector<int>vec;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> a;
		vec.push_back(a);
	}
	sort(vec.begin(), vec.end());
	res = vec[vec.size() - 1] - vec[0];
	cout << res << endl;*/

	/*int Alice = 0, Bob = 0,a,N;
	deque<int>dec;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> a;
		dec.push_back(a);
	}
	sort(dec.rbegin(), dec.rend());
	for (int i = 0; i < N;i++) {
		if (i % 2 == 0) {
			Alice += dec[0];
			dec.pop_front();
		}
		else if (i % 2 == 1) {
			Bob += dec[0];
			dec.pop_front();
		}
	}
	cout << Alice - Bob << endl;*/
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
 
const double EPS = 1e-10;
const ll INF = 100000000;
const ll MOD = 1000000007;

ll h, w, n;
vector<int> vec[200000];

int main() {
    cin >> h >> w >> n;
    rep(i,n) {
        int x, y; cin >> x >> y;
        x--; y--;
        vec[y].push_back(x);
    }
    rep(i,w) sort(vec[i].begin(), vec[i].end());
    int pos = 0;
    int ans = h;
    rep(i,w) {
        rep(j,vec[i].size()) {
            if (i+pos == vec[i][j]) pos++;
            else if (i+pos < vec[i][j]) ans = min(ans, vec[i][j]); 
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 8704
#include <iostream>
#include <string.h>
#include <cstdint>
using namespace std;

#define NC 30

int ca[NC*NC];
int ta[3][NC] = {0};



int main() {
	int n, c;
	int x;
	int min = INT32_MAX;

	cin >> n >> c;

	for( int i = 0; i < c; i++) {
		for ( int j = 0; j < c; j++ ) {
			cin >> ca[i*c+j];
		}
	}

	for( int i = 0; i < n; i++) {
		for ( int j = 0; j < n; j++ ) {
			cin >> x;
			ta[(i+j)%3][x-1]++;
		}
	}

	for( int i = 0; i < c; i++ ) {
		for( int j = 0; j < c; j++ ) {
			for( int k = 0; k < c; k++ ) {
				if( i != j && j != k && k != i ) {
					int sum = 0;
					for( int l = 0; l < c; l++ ) {
						sum += ta[0][l]*ca[l*c+i];
						sum += ta[1][l]*ca[l*c+j];
						sum += ta[2][l]*ca[l*c+k];
					}
					if( sum < min ) {
						min = sum;
					}
				}
			}
		}
	}

	cout << min << "\n";

	return 0;
}


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

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

    string s;
    cin>>s;
    int ans=0;
    for(int i=0;i<s.size();i++){
        if(ans==0 && s[i]=='C')ans++;
        if(ans==1 && s[i]=='F')ans++;
    }
    if(ans==2)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

}

Measured memory_bytes: 256
import numpy as np

N, M = list(map(int, input().split()))
s = [0]*M
c = [0]*M
check = 1
for i in range(M):
    s[i], c[i] = list(map(int, input().split()))
    if ((N > 2) & (s[i] == 1) & (c[i] == 0)):
        check = 0

if check == 0:
    print('-1')
else:
    if N > 1:
        max = 10 ** N - 1
        min = 10 ** (N - 1)
    else:
        max = 9
        min = 0

    answer = -1

    for i in range(max, min-1, -1):
        flag = 1
        for j in range(M):
            if s[j] <= N:
                if int(str(i)[s[j]-1]) != c[j]:
                    flag = 0
        if flag == 1:
            answer = i
    print(answer)

Measured memory_bytes: 12488
var
	a,b:int64;
	i,k:longint;
begin
	read(a,b,k);
	for i:=1 to k div 2 do
	begin
		b:=b+a div 2;
		a:=a div 2;
		a:=a+b div 2;
		b:=b div 2;
	end;
	if k mod 2=1 then
	begin
		b:=b+a div 2;
		a:=a div 2;
	end;
	writeln(a,' ',b);
end.


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

int main(){
    int m, k;
    cin >> m >> k;

    int pow2m = 1;
    for(int i=0; i<m; i++){
        pow2m *= 2;
    }
    if(k >= pow2m){
        cout << -1 << endl;
        return 0;
    }

    if(m == 0){
        cout << 0 << " " << 0 << endl;
        return 0;
    }
    if(m == 1){
        if(k == 0) cout << 0 << " " << 0 << " " << 1 << " " << 1 << endl;
        if(k == 1) cout << -1 << endl;
        return 0;
    }

    vector<int> ans;
    for(int i=0; i<pow2m; i++){
        if(i != k) ans.push_back(i);
    }
    ans.push_back(k);
    for(int i=pow2m-1; i>=0; i--){
        if(i != k) ans.push_back(i);
    }
    ans.push_back(k);
    
    for(int i=0; i<ans.size(); i++){
        cout << ans[i];
        if(i == ans.size() - 1) break;
        cout << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 2932
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int>pii;
#define sf(x) scanf("%d",&x)
#define sfl(x) scanf("%lld",&x)
#define lli long long int
#define ll64 int64_t
#define pb push_back
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define frr(i,a) for(int i=0;i<a;i++)
#define frl(i,a) for(lli i=0;i<a;i++)
int main()
{
    lli n;
    double d;
    cin>>n>>d;
    double p,q;
    lli c=0;
    frr(i,n)
    {
        cin>>p>>q;
        double x=sqrt(p*p+q*q);
        if(x<=d)
        {
            c++;
        }
    }
    cout<<c<<endl;
}


Measured memory_bytes: 3812
#include <bits/stdc++.h>
#define int long long
using namespace std;
int cnt[100007];
signed main(){
	int n;
	cin >> n;
	int cnt = 1;
	n--;
	while(n >= pow(26, cnt)){
		n -= pow(26, cnt);
		cnt++;
	}
	string s;
	for(int i = 0; i < cnt; i++){
		s += char(n % 26 + 'a');
		n /= 26;
	}
	for(int i = s.size() - 1; i >= 0; i--) cout << s[i];
	return 0;
}

Measured memory_bytes: 4096
import java.util.*;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        String a = sc.next();
        String b = sc.next();
        String c = sc.next();
        int ans = 0;
        for (int i = 0; i < x; i++) {
            Set<String> set = new HashSet<String>();
            set.add(a.substring(i, i + 1));
            set.add(b.substring(i, i + 1));
            set.add(c.substring(i, i + 1));
            ans += (set.size() - 1);
        }
        System.out.println(ans);
    }

}


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

int main(void)
{
	char str[20];
	int mojisu;
	int a;
	
	scanf("%s", str);
	
	mojisu = strlen(str);
	
	for (a = mojisu - 1; a >= 0; a--){
		printf("%c", str[a]);
	}
	
	printf("\n");
	
	return (0);
}

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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  int n; cin >> n;
  int d,x; cin >> d >> x;
  vector<int> a(n); rep(i,n) cin >> a[i];

  int ans = x;
  rep(i,d)
    rep(j,n)
    if(i*a[j]+1<=d) ans++;

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


Measured memory_bytes: 3544
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, l, r) for (int i = (l); i < (r); i++)
#include <bits/stdc++.h>
//~ #include <atcoder/all>
using namespace std;
using ll = long long;
//~ using P = pair<int, int>;

template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
//~ int A = (1<<2) | (1<<3) | (1<<5) | (1<<7);
//~ for (int bit=A; ; bit=(bit-1)&A){
//~ if (!bit) break;
//~ }
int next_combination(int sub)
{
    int x = sub & -sub, y = sub + x;
    return (((sub & ~y) / x) >> 1) | y;
}
//~ int n=5;
//~ int k=3; // nCkの組み合わせ、ただしk=0には対応してない
//~ int bit=(1<<k)-1; // 1000 -> 0111
//~ for(; bit < (1<<n); bit=nex_combination(bit){
//~ }
bool isPrime(int a)
{
    if (a == 2)
        return true;
    if (a <= 1 || a % 2 == 0)
        return false;

    for (int i = 3; i * i <= a; i += 2)
    {
        if (a % i == 0)
            return false;
    }
    return true;
}
//~ vector<int> a = {1, 14, 32, 51, 51, 51, 243, 419, 750, 910};
vector<int> a;
// index が条件を満たすかどうか
bool isOK(int index, int key)
{
    if (a[index] >= key)
        return true;
    else
        return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key)
{
    int ng = -1;            //「index = 0」が条件を満たすこともあるので、初期値は -1
    int ok = (int)a.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

    /* ok と ng のどちらが大きいかわからないことを考慮 */
    while (abs(ok - ng) > 1)
    {
        int mid = (ok + ng) / 2;

        if (isOK(mid, key))
            ok = mid;
        else
            ng = mid;
    }
    return ok;
}

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

//~ int v[100100];
//~ int INF = 1 << 30;
//~ vector<vector<int>> dp(310, vector<int>(310));
//~ ll dp[110][100100];
//~ vector<int> dp(100100, 0));

//~ int seen[110];
//~ int ans[110][2];
//~ ll MOD = 1e9 + 7;

int main()
{
    string a, b;
    cin >> a >> b;

    string con;
    con = a + b;
    double judg1 = sqrt(stoi(con));
    int judg2 = judg1;

    if (judg1 == judg2)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 3600