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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

template<class T>inline bool chmax(T &a, const T &b) { if (b > a) { a = b; return true; } return false; }
template<class T>inline bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;

void solve() {
    int m;
    cin >> m;
    ll res = 0, sum = 0;
    for (int i=0; i<m; ++i) {
        ll d, c;
        cin >> d >> c;
        res += c;
        sum += d * c;
    }
    cout << res - 1 + (sum - 1) / 9 << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}


Measured memory_bytes: 256
N, Y = [int(i) for i in input().split()]
Y //= 1000
 
for i in range(N+1):
    for j in range(N-i+1):
        k = N - (i + j)
        if Y - (10*i + 5*j) == k:
            print(i, j, k)
            quit()
 
print(-1, -1, -1) 


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#include<cmath>
#include<algorithm>
#include<string.h>
using namespace std;
int main(){
    int k=1,i;
    char s[15],t[15];
    cin>>s>>t;
    for(i=0;i<strlen(s);i++){
        if(s[i]!=t[i]) {k=2;break;}
    }
    if(k==1 && strlen(s)+1==strlen(t)) cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}


Measured memory_bytes: 3592
#include <stdio.h>
#include <string.h>
void deleteFirst(int**);
void deleteLast(int**);
void insertOne(int**, int**, int, int);
int deleteOne(int**, int**, int);

int main(){
    int xs[2000001] = {};
    int* default_ptr = xs + 2000000;
    int* fp = default_ptr;
    int* lp = default_ptr;
    int len = 0;
    int n,i;
    char str[20];
    scanf("%d\n", &n);
    for(i = 0; i < n; ++i){
        fgets(str, sizeof(str), stdin);
        if(str[6] == 'F'){
            deleteFirst(&fp);
            --len;
        }else if(str[6] == 'L'){
            deleteLast(&lp);
            --len;
        }else{
            char *tp;
            int m;
            tp = strtok(str, " " );
            tp = strtok(NULL," ");
            sscanf(tp, "%d", &m);
            if(str[0] == 'i'){
                insertOne(&fp, &lp, m, len);
                ++len;
            }else if(deleteOne(&fp, &lp, m)){
                --len;
            }
        }
        
        if(len == 0){
            fp = default_ptr;
            lp = default_ptr;
        }
    }
    
    for(i = 0; i < lp - fp; ++i){
        if(*(fp + i) != -1){
            printf("%d ", *(fp + i));
        }
    }
    printf("%d\n", *lp);
}

void deleteFirst(int** fp){
    **fp = -1;
    while(**fp == -1) ++*fp;
}

void deleteLast(int** lp){
    **lp = -1;
    while(**lp == -1) --*lp;
}

void insertOne(int** fp, int** lp, int m, int len){
    if(len == 0)
        **fp = m;
    else{
        --*fp;
        **fp = m;
    }
}

int deleteOne(int** fp, int** lp, int m){
    for(int j = 0; j <= *lp - *fp; ++j){
        if(*(*fp + j) == m){
            *(*fp + j) = -1;
            if(j == 0)
                while(**fp == -1) ++*fp;
            else if((*fp + j) == *lp){
                while(**lp == -1) --*lp;
            }
            return 1;
        }
    }
    return 0;
}



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

int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  string a;
  a = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ";
  for (int i = 0; i < S.size(); i++) {
    for (int j = 0; j < 52; j++) {
      if (S.at(i) == a.at(j)) {
        S.at(i) = a.at(j+N);
        break;
      }
    }
  }
  
  cout << S << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	float h, high, low;
	
	high = 0; 
	low = 0;
	
	while (scanf("%f", &h) != EOF){
		if (high < h){
			high = h;
		}
		if (low == 0){
			low = h;
		}
		else if (low > h){
			low = h;
		}
	}
	
	printf("%.1f\n", high - low);
	
	return (0);
}

Measured memory_bytes: 648
import java.io.*;
import java.util.*;

public class Main {


    private void solve(InputReader in, PrintWriter out) {
        String s = in.next();
        int count = 0;
        int count2 = 0;
        char[] arr = s.toCharArray();
        if (arr[0] == 'A') {
            for (int i = 2; i < arr.length - 1; i++) {
                if (arr[i] == 'C') {
                    count++;
                }
            }
            for (int i = 1; i < arr.length; i++) {
                if (arr[i] >= 65 && arr[i] <= 90) {
                    count2++;
                }
            }
            if (count == 1 && count2 == 1) {
                out.println("AC");
            } else {
                out.println("WA");
            }
        } else {
            out.println("WA");
        }
    }


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

    private void run() {
        try (
                InputReader in = new InputReader(System.in);
                PrintWriter out = new PrintWriter(System.out)) {
            solve(in, out);
        }
    }


    static class InputReader implements AutoCloseable {
        private BufferedReader reader;
        private StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }


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

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

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

        @Override
        public void close() {

        }
    }

}


Measured memory_bytes: 22612
#include<iostream>
#include<cstdio>
using namespace std;
#define maxv 100005
int f[maxv],p[maxv];
int getfather(int s){
	if(s==f[s])
		return s;
	f[s]=getfather(f[s]);
	return f[s];
}
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
		scanf("%d",&p[i]);
	for(int i=1;i<=n;i++)
		f[i]=i;
	for(int i=1;i<=m;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		f[getfather(x)]=getfather(y);
	}
	int ans=0;
	for(int i=1;i<=n;i++)
		if(getfather(p[i])==getfather(i))
			ans++;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;
int main(int argc, char *argv[]) {
	int n,a,b;
	cin >> n;
	
	int res = 0;
	int at = 0;
	
	for(int i=0; i<n; i++){
		cin >> a >> b;
		if(a > at){
			res = a + b;
			at = a;
		}
	}
	cout << res << "\n";
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int i,k,H,W;
  while(1){
    scanf("%d %d",&H,&W);
    if(H==0&&W==0)break;
    for(i=0;i<H;i++){
      for(k=0;k<W;k++){
        if(i==0||i==H-1){
          printf("#");
        }else{
          if(k==0||k==W-1){
            printf("#");
          }else{
            printf(".");
          }
        }
      }
      printf("\n");
    }
    printf("\n");
  }
  return 0;
}

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

using namespace std;

int main()
{
	string s;
	cin >> s;
	long long dp[11] = {};
	for (int i = 1; i <= s.size(); i++)
		for (int j = 0; j < i; j++)
			dp[i] += dp[j] + stoll(s.substr(j, i-j)) * (j > 0 ? (long long)pow(2, j-1) : 1);

	cout << dp[s.size()] << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		long start = System.currentTimeMillis();
		int INF = Integer.MAX_VALUE/2;
		StringBuilder ans = new StringBuilder();
		Scanner sc = new Scanner(System.in);
		int D = Integer.parseInt(sc.next());
		int[] c = new int[26];
		Arrays.setAll(c, i -> Integer.parseInt(sc.next()));
		int[][] s = new int[D][26];
		for(int i = 0; i < D; i++)
			Arrays.setAll(s[i], x -> Integer.parseInt(sc.next()));
		sc.close();
		int[] con = new int[D];
		TreeSet<Integer>[] used = new TreeSet[26];
		for(int i = 0; i < 26; i++) {
			used[i] = new TreeSet<>();
			used[i].add(-1);
		}
		for(int d = 0; d < D; d++) {
			int max = -INF, now = 0;
			for(int i = 0; i < 26; i++) {
				int temp = 0;
				temp += s[d][i];
				for(int j = 0; j < 26; j++)
					if(i != j)
						temp -= c[j] * (d - used[j].last());
				if(max < temp) {
					max = temp;
					now = i;
				}
			}
			con[d] = now;
			used[now].add(d);
		}
		for(int i = 0; i < 26; i++)
			used[i].add(D);
		Random r = new Random();
		while(true) {
			int d = r.nextInt(D);
			for(int q = 0; q < 26; q++) {
				int temp = 0;
				temp -= s[d][con[d]];
				temp += s[d][q];
				temp -= c[con[d]] * (used[con[d]].ceiling(d) - d) * (d - used[con[d]].lower(d));
				temp += c[q] * (d - used[q].lower(d)) * (used[q].ceiling(d) - d);
				if(temp > 0) {
					con[d] = q;
					used[con[d]].remove(d);
					used[q].add(d);
				}
			}
			if(System.currentTimeMillis() - start > 1850)
				break;
		}
		for(int i : con)
			ans.append((i+1) + "\n");
		System.out.println(ans);
	}

}


Measured memory_bytes: 59816
#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;
#define lowbit(x) (x&(-x))
#define max(x,y) (x>y?x:y)
#define min(x,y) (x<y?x:y)
#define MAX 100000000000000000
#define MOD 1000000007
#define PI 3.141592653589793238462
#define INF 1000000000
#define mem(a) (memset(a,0,sizeof(a)))
typedef long long ll;
vector<int>v[100006];
int x,y,n;
int ans[4]={0,0,0};
int vis[100006];
void bfs(int x,int y)
{
    mem(vis);
    vis[x]=1;
    vis[y]=2;
    queue<int>q;
    q.push(x);
    q.push(y);
    while(!q.empty())
    {
        int pos=q.front();
        ans[vis[pos]]++;
        q.pop();
        for(int i=0;i<v[pos].size();i++)
        {
            if(vis[v[pos][i]]) continue;
            vis[v[pos][i]]=vis[pos];
            q.push(v[pos][i]);
        }
    }
}
int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%d%d",&x,&y);
        v[y].push_back(x);
        v[x].push_back(y);
    }
    bfs(1,n);
    puts(ans[2]>=ans[1]?"Snuke":"Fennec");
}

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

int main() {
	int n; cin >> n;
	string s; cin >> s;	
	map<char, int>multiple;
	for (int i = 0; i < s.size(); i++) {
		multiple[s[i]]++;
	}

	long long ans = 1;
	for (auto&& x : multiple) {
		ans *= ((long long)x.second+1);
		ans %= 1000000007;
	}
	cout << (ans-1)%1000000007 << endl;

	return 0;
}

Measured memory_bytes: 512
import sys

input = sys.stdin.readline


def main():
    N, K = map(int, input().split())
    H = list(map(int, input().split()))
    H.sort(reverse=True)
    if K >= N:
        print(0)
    else:
        ans = sum(H[K:])
        print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 105360
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

S = input()

if S == "Sunny":
	print("Cloudy")
if S == "Cloudy":
	print("Rainy")
if S == "Rainy":
	print("Sunny")

Measured memory_bytes: 61036
#include "bits/stdc++.h"
#define ll long long
#define FOR(x) for(ll i = 0;i<(x);i++)
#define ALL(v) (v).begin(),(v).end()


using namespace std;


int main(){
ll a,b;
cin>>a>>b;
if(a>b)
cout<<a+a-1<<endl;
else if(b>a)
cout<<b+b-1<<endl;
else
cout<<a+b<<endl;
}


Measured memory_bytes: 256
using System;
//using System.Collections;
//using System.Collections.Generic;
//using System.Linq;

namespace problem
{
  class Test
  {
    static void Main()
    {
      while (true)
      {
        var s = Console.ReadLine().Split();
        if (s[0] == "0" && s[1] == "0") break;
        int H = int.Parse(s[0]);
        int W = int.Parse(s[1]);
        for (int i = 0; i < H; i++)
        {
          for (int j = 0; j < W; j++)
          {
            if (i > 0 && i < H - 1 && j > 0 && j < W - 1) Console.Write(".");
            else Console.Write("#");
          }
          Console.WriteLine();
        }
        Console.WriteLine();
      }
    }
  }
}


Measured memory_bytes: 8832
//
// Created by Tetsuya Shiota on 2019-04-13.
//

#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>

#define REP(i, b, n) for (Int i = b; i < Int(n); i++)
#define rep(i, n) REP(i, 0, n)
#define FOR(e, o) for (auto &&e : o)
#ifdef LOCAL
#define pp(x) cerr << __LINE__ << ' ' << #x << " = " << (x) << endl
#define dump(x)                                                                \
  cerr << __LINE__ << ' ' << #x << " : ";                                      \
  FOR(e, x) cerr << e << ' ';                                                  \
  cerr << endl;
#else
#define pp(x)
#define dump(x)
#endif

using namespace std;

using Int = long long;
using vi = vector<Int>;
using vvi = vector<vi>;
using pii = pair<Int, Int>;

template <typename T> void reverse(vector<T> &v) {
  reverse(v.begin(), v.end());
}

template <typename T> void sort(vector<T> &v) { sort(v.begin(), v.end()); }
template <typename T> void rsort(vector<T> &v) { sort(v.rbegin(), v.rend()); }

template <typename T> T sum(const vector<T> &v) {
  return accumulate(v.begin(), v.end(), T(0));
}

template <class T> void update_max(T &a, const T &b) { a = max(a, b); }
template <class T> bool update_min(T &a, const T &b) { a = min(a, b); }

struct BoolName : numpunct<char> {
  string t, f;
  BoolName(string t = "Yes", string f = "No") : t(t), f(f) {}
  string do_truename() const { return t; }
  string do_falsename() const { return f; }
};

class Solver {
public:
  Solver() {}
  vi ans = {-1, -1, -1};
  int N, Y;
  void input() {
    cin >> N >> Y;
    pp(N);
  }
  void solve() {
    rep(i, N + 1) {
      rep(j, N + 1) {
        int now = 0, k = (N - i - j);
        if (k < 0)
          break;
        now += i * 10000;
        now += j * 5000;
        now += k * 1000;
        if (Y == now) {
          ans = {i, j, k};
          dump(ans);
          return;
        }
      }
    }
  }
  void output() { cout << ans[0] << ' ' << ans[1] << ' ' << ans[2] << endl; }
};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(15) << boolalpha;
  cout.imbue(locale(cout.getloc(), new BoolName));
#ifdef LOCAL
  while (1) {
    Solver s;
    s.input();
    if (cin.eof())
      break;
    s.solve();
    s.output();
  }
#else
  Solver s;
  s.input();
  s.solve();
  s.output();
#endif
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define show(x) cerr<<#x<<"="<<x<<"\n"
typedef long long ll;
using namespace std;
const ll inf=(ll)1e14;
int n;
vector<pair<int,int> > aka,ao;

struct edge
{
  int to;
  ll cap;
  int rev;
};
vector<edge> v[211];
int level[211];
int iter[211];

void add_edge(int from,int to,ll cost){
  v[from].push_back({to,cost,(int)v[to].size()});
  v[to].push_back({from,0,(int)v[from].size()-1});
}

void bfs(int s){
  memset(level,-1,sizeof(level));
  queue<int> q;
  q.push(s);
  level[s]=0;
  while(!q.empty()){
    int now=q.front();
    q.pop();
    for(int i=0;i<(int)v[now].size();i++){
      if(v[now][i].cap>0 && level[v[now][i].to]<0){
        level[v[now][i].to]=level[now]+1;
        q.push(v[now][i].to);
      }
    }
  }
}

int dfs(int now,int t,ll f){
  if(now==t)return f;
  for(int &i=iter[now];i<(int)v[now].size();i++){
    if(v[now][i].cap>0 && level[now]<level[v[now][i].to]){
      int d=dfs(v[now][i].to,t,min(f,v[now][i].cap));
      if(d>0){
        v[now][i].cap-=d;
        v[v[now][i].to][v[now][i].rev].cap+=d;
        return d;
      }
    }
  }
  return 0;
}

int max_flow(int s,int t){
  int flow=0;
  for(;;){
    bfs(s);
    if(level[t]<0)return flow;
    memset(iter,0,sizeof(iter));
    int f;
    while((f=dfs(s,t,inf))>0){
      flow+=f;
    }
  }
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout<<fixed;
#ifdef LOCAL_DEFINE
  FILE *stream1;
  //FILE *stream2;
  stream1=freopen("in","r",stdin);
  //stream2=freopen("out","w",stdout);
  if(stream1==NULL)return 0;
  //if(stream2==NULL)return 0;
#endif
  cin>>n;
  int s=2*n;
  int t=s+1;
  for(int i=0;i<n;i++){
    int a,b;cin>>a>>b;
    aka.push_back({a,b});
    add_edge(s,i,1);
  }
  for(int i=0;i<n;i++){
    int a,b;cin>>a>>b;
    add_edge(n+i,t,1);
    ao.push_back({a,b});
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(aka[j].fi<ao[i].fi && aka[j].se<ao[i].se){
        add_edge(j,n+i,1);
      }
    }
  }
  cout<<max_flow(s,t)<<endl;
#ifdef LOCAL_DEFINE
  cerr<<"Time elapsed: "<<1.0*clock()/CLOCKS_PER_SEC<<"s.\n";
  fclose(stream1);
  //fclose(stream2);
#endif
  return 0;
}






Measured memory_bytes: 512
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;$n:expr) => {
        (0..$n).map(|_| scan!()).collect::<Vec<_>>()
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let n = scan!(i64);
    for c in n.to_string().chars() {
        if c == '9' {
            println!("Yes");
            return;
        }
    }
    println!("No");
}


Measured memory_bytes: 4352
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
using namespace std;

int main(){

  string str[1000];
  int a,b;

  while(cin >> a >> b, a, b){

    for(int i=0;i<a;i++) cin >> str[i];

    int x = 0,y = 0,count = 0,t = 0;

    while(1){
      if(count == 1000000){
	t = 1;
	break;
      }

      if(str[x][y] == '>') y++;
      else if(str[x][y] == '<') y--;
      else if(str[x][y] == '^') x--;
      else if(str[x][y] == 'v') x++;
      else break;
      count++;
    }

    if(t == 1) cout << "LOOP" << endl;
    else cout << y << " " << x << endl;

  }
}

Measured memory_bytes: 1236
!全探索
implicit none
INTEGER :: x,a,b,c,count,i,j,k
READ(5,*) a,b,c,x
count = 0

do i=0,a
    do j=0,b
        do k=0,c
            if (x==500*i+100*j+50*k) then
                count = count+1
            endif
        enddo
    enddo
enddo

WRITE(6,*) count

end


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

int main()
{
    int n;
    int i, key = 0, next, ans = 0;
    
    cin >> n;
    
    int a[n];
    
    for(i = 0; i < n; i++) {
        cin >> a[i];
    }
    
    next = 1;
    
    do {
        next = a[next-1];
        ans++;
        
        if(next == 2) {
            key = 1;
        } else if((next == 1) || (ans == n)) {
            key = 1;
            ans = -1;
        }
        
    } while(key == 0);
    
    
    cout << ans << "\n";
    
    return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include<vector>
#include<map>
#include<queue>
typedef long long ll;
using namespace std;

int main() {
	ll n,m;cin>>n>>m;
	vector<ll> p(m),q(m),c(m);
	map<ll,map<ll,vector<vector<ll>>>> ma;
	map<ll,map<ll,ll>> use,d;
	ll def=1;
	for(int i=0;i<13;i++)def*=10;
	for(int i=0;i<m;i++){
		cin>>p[i]>>q[i]>>c[i];
		p[i]--;
		q[i]--;
		vector<ll> v(3);
		v[1]=q[i];
		v[2]=c[i];
		v[0]=0;
		ma[p[i]][c[i]].push_back(v);
		v[1]=p[i];
		ma[q[i]][c[i]].push_back(v);
		v[1]=p[i];
		v[2]=-1;
		v[0]=0;
		ma[p[i]][c[i]].push_back(v);
		v[2]=c[i];
		v[0]=1;
		ma[p[i]][-1].push_back(v);
		v[1]=q[i];
		v[2]=-1;
		v[0]=0;
		ma[q[i]][c[i]].push_back(v);
		v[2]=c[i];
		v[0]=1;
		ma[q[i]][-1].push_back(v);
		use[p[i]][c[i]]=1;
		use[q[i]][c[i]]=1;
		use[p[i]][-1]=1;
		use[q[i]][-1]=1;
		d[p[i]][c[i]]=def;
		d[q[i]][c[i]]=def;
		d[p[i]][-1]=def;
		d[q[i]][-1]=def;
	}
	d[0][-1]=0;
	d[n-1][-1]=def;
//	vector<vector<ll>> use(n,make_pair1);
//	use[0]=0;

//	vector<ll> d(n,def);
//	d[0]=0;

	priority_queue<vector<ll>,vector<vector<ll>>,greater<vector<ll>>> pq;
	vector<ll> v(3);
	v[0]=0;
	v[1]=0;
	v[2]=-1;
	pq.push(v);
	while(pq.size()){
//		cout<<v[0]<<' '<<v[1]<<' '<<v[2]<<endl;
		v=pq.top();
		pq.pop();
		if(use[v[1]][v[2]]==0)continue;
		use[v[1]][v[2]]=0;
		if((v[1]==n-1)*(v[2]==-1)){
			d[n-1][-1]=v[0];
			break;
		}
		for(int i=0;i<ma[v[1]][v[2]].size();i++){
			vector<ll> next(3);
			next[0]=v[0]+ma[v[1]][v[2]][i][0];
			next[1]=ma[v[1]][v[2]][i][1];
			next[2]=ma[v[1]][v[2]][i][2];
			if(use[next[1]][next[2]]){
				if(d[next[1]][next[2]]>next[0]){
					d[next[1]][next[2]]=next[0];
					pq.push(next);
				}
			}
		}
	}
	if(d[n-1][-1]!=def){
		cout<<v[0]<<endl;
	}else{
		cout<<-1<<endl;
	}




	return 0;
}

Measured memory_bytes: 219312
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

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

int main(){
    int X;
    cin >> X;
    if(X >= 30) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>

int main(){
    ll N, M;
    cin >> N >> M;
    VS s(N);
    rep(i,0,N)cin>>s[i];

    rep(i,0,M+2)cout<<'#';
    cout<<endl;
    rep(i,0,N)cout<<'#'<<s[i]<<'#'<<endl;
    rep(i,0,M+2)cout<<'#';
    cout<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main() {
  unsigned long A,B;
  int count;
  B = 100;
  A = 0;
  count = 0;
  scanf("%lu", &A);
  while (1)
  {
      count++;
      B = B*1.01;
      if(B >= A){
          printf("%d", count);
          break;
      } 

  }
  return 0;
}

Measured memory_bytes: 1736
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <queue>
using namespace std;
using pint = pair<int,int>;

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

int H, W;
string fi[110];
int dist[110][110]; // BFS 用

int main() {
    // 入力
    cin >> H >> W;
    int wnum = 0;
    for (int i = 0; i < H; ++i) {
        cin >> fi[i];
        for (int j = 0; j < W; ++j) {
            if (fi[i][j] == '.') ++wnum;
        }
    }

    // BFS
    memset(dist, -1, sizeof(dist));
    dist[0][0] = 1;
    queue<pint> que;
    que.push(pint(0, 0));
    while (!que.empty()) {
        pint cur = que.front();
        que.pop();
        int x = cur.first;
        int y = cur.second;
        for (int dir = 0; dir < 4; ++dir) {
            int nx = x + dx[dir];
            int ny = y + dy[dir];
            if (nx < 0 || nx >= H || ny < 0 || ny >= W) continue;
            if (fi[nx][ny] == '#') continue;
            if (dist[nx][ny] == -1) {
                dist[nx][ny] = dist[x][y] + 1;
                que.push(pint(nx, ny));
            }
        }
    }
    if (dist[H-1][W-1] == -1) cout << -1 << endl;
    else  cout << wnum - dist[H-1][W-1] << endl;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
   cin >> a[i];
  }
  sort(a.begin(),a.end());
  int s=n/2;
  cout << a[s]-a[s-1] << endl;
  return 0;
}
  

Measured memory_bytes: 640
import sys
# sys.setrecursionlimit(100000)


def input():
    return sys.stdin.readline().strip()


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def main():
    S = list(input())
    k = input_int()

    # 方針: 左の文字から貪欲に a を作る
    #       余ったk は一番右の文字の操作につかう
    for i in range(len(S)):
        c = ord(S[i])
        if c == ord("a"):
            continue
        dif = ord("z") - c + 1
        if dif <= k:
            S[i] = "a"
            k -= dif
    # 余ったkを一番右の文字の操作に使う
    S[-1] = chr(ord("a") + ((ord(S[-1]) - ord("a")) + (k % 26)))
    print("".join(S))
    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 76944
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#define ll long long
#define N 100010
using namespace std;

ll n,m,tot,ans,a[N],father[N],cnt[N];
vector<ll> t,q[N];

inline ll read(){
	ll x=0,tmp=1;
	char ch=getchar();
	while(!isdigit(ch)){
		if(ch=='-') tmp=-1;
		ch=getchar();
	}
	while(isdigit(ch)){
		x=(x<<3)+(x<<1)+(ch^48);
		ch=getchar();
	}
	return tmp*x;
}

ll searchfather(ll v){
	if(father[v]==v) return father[v];
	return father[v]=searchfather(father[v]);
}

int main(){
	n=read(); m=read();
	for(ll i=1; i<=n; i++){
		a[i]=read();
		father[i]=i;
	}
	while(m--){
		ll x=read()+1,y=read()+1;
		ll f1=searchfather(x),f2=searchfather(y);
		if(father[f1]!=f2) father[f1]=f2;
	}
	for(ll i=1; i<=n; i++){
		father[i]=searchfather(i);
		if(!cnt[father[i]]) cnt[father[i]]=++tot;
		q[cnt[father[i]]].push_back(a[i]);
	}
	if(tot==1) return printf("0\n")&0;
	for(ll i=1; i<=tot; i++) sort(q[i].begin(),q[i].end());
	for(ll i=1; i<=tot; i++) ans+=q[i][0];
	for(ll i=1; i<=tot; i++){
		for(ll j=1; j<q[i].size(); j++) t.push_back(q[i][j]);
	}
	sort(t.begin(),t.end());
	if(t.size()<tot-2) return printf("Impossible\n")&0;
	for(ll i=0; i<tot-2; i++) ans+=t[i];
	cout<<ans<<endl;
	return 0;
}

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

using ll = long long;

#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) rfor_(i,0,(n))

int H, W;

int main(){
	cin.tie(0);
	
	while(cin>>H>>W,H||W) {
	    rep(i, H) {
	        rep(j, W) {
	            cout<<((i+j)%2?'.':'#');
	        }
	        cout<<endl;
	    }
	    cout<<endl;
	}
	return 0;
}



Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int A[N];
char ans[N],ch,q;
bool ac[N];
int n,x,m;
int main(){
    scanf("%d %d",&m,&n);
    for(int i=0;i<n;++i){
        scanf("%d %c%c",&x,&ch,&q);
        if(ch=='A') ac[x]=1;
        else if(!ac[x])A[x]++;
    }
    int sum=0 , sAc=0;
    for(int i=1;i<=m;++i){
        sum+=A[i]*ac[i];
        sAc+=ac[i];
    }
    printf("%d %d\n",sAc,sum);
    return 0;
}


Measured memory_bytes: 768
#include "bits/stdc++.h"
using namespace std ;
int h(string x){return x=="AC";}
int mp[int(2e5)] ;
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n , m ;
	cin >> n >> m ;
	int sol = 0 , pen = 0 ;
	
	for(int i = 0 ; i < m ; i++)
	{
		string res ;
		int pro ;
		cin >> pro >> res ;
		if(mp[pro]==int(1e8)) continue ;
		if(h(res)){  sol++; pen += mp[pro] ;mp[pro] = 1e8 ;}
		else mp[pro] += 1 ;
	}
	cout << sol << " " << pen << '\n' ;

}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()

int main(){
    double x,y,z;
    double max=0;
    int L;cin>>L;
    L*=3;
    for(int x=0;x<=L;x++){
        for(int y=0;y<=L;y++){
            z=L-x-y;
            if(max<=x*y*z){
                max=x*y*z;
            }
        }  
    }
    max/=27;
    printf("%.12f",max);
}

Measured memory_bytes: 3700
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define int int64_t
#define double long double
#define rep(i, N) for(int i=0; i<N; i++)
#define repr(i, N) for(int i=N-1; i>=0; --i)
#define all(v) v.begin(),v.end() 
using namespace std;
//using pr = pair<int, int>;
using tup  = tuple<int, int, int>;
using vec  = vector<int>;
using vvec = vector<vec>;

//プロトタイプ宣言

//グローバル変数
const int INF = 1000000000;
//const int MAX_N = ;
//const int MAX_M = ;
//vvec dp(MAX_N, vec(MAX_M));

//関数：
/* メイン・プログラム */
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);

	int n; cin >> n;
	vector<pair<int, int>> rg(n);
	rep(i, n) {
		int a, b;
		cin >> a >> b;
		rg[i].second = a-b;
		rg[i].first = a+b;
	}
	
	sort(rg.begin(), rg.end());
	
	int cur = -1*INF;
	int ans = 0;
	rep(i, n) {
		if(cur <= rg[i].second) {
			ans++;
			cur = rg[i].first;
		}
	}

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

/*	(n * m) % dvs = ((n%dvs) * (m%dvs)) % dvs
*/

//std::string str;
//str = std::to_string(int i);
//bitset<3> s(N);
//int ans = (char)grid - '0';
//int id = lower_bound(all(arr), x) - arr.begin();
//cout << fixed << setprecision(10) << tld << endl;
//vector<int> sub(itr,itr+d); //イテレーターで部分数列(i=0...d)を指定

/*	struct data {
	char *name;
	int age;
	int height;
	double weight;
};*/

/*	string ans(lgd, '0');
	string &refer = ans;
	for(int i=0; i<lgd; i++) refer[i] = (char)vd[i] + '0';*/

/*	map<int,int> mp;
for(auto p : mp) {
	ct += p.second*(p.second-1); }

map<int,int>::iterator itr;
for(itr = mp.begin(); itr != mp.end(); itr++) {
	ans += itr->second * (itr->second-1);
}*/


Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define INF (1<<29)

typedef pair<int, int> pii;

int dp[150][10][80]; //[i][j][k] i???????????§??§(i???,j??????)????????§?????????k????????£????????§????????¨??????????°????
vector<pii> stone[150]; // x[0-indexed], suberi
int n, m;

int main() {
	while (cin >> n >> m, n || m) {
		fill(dp[0][0], dp[n][0], INF);
		REP(i, n) stone[i].clear();
		
		REP(i, n) {
			int k;
			scanf("%d", &k);
			REP(j, k) {
				int a, b;
				scanf("%d %d", &a, &b);
				stone[i].push_back(pii(a, b));
			}
		}
		
		REP(i, stone[0].size()) dp[0][i][m] = 0;
		if (m != 0) REP(i, stone[1].size()) dp[1][i][m - 1] = 0;
		
		REP(i, n - 1) REP(j, stone[i].size()) REP(k, m + 1) {
			pii &from = stone[i][j];
			
			// 1????£???°???
			if (i < n - 2 && k > 0) {
				REP(l, stone[i + 2].size()) {
					pii &to = stone[i + 2][l];
					int cost = (from.second + to.second) * abs(from.first - to.first);
					dp[i + 2][l][k - 1] = min(dp[i + 2][l][k - 1], dp[i][j][k] + cost);
				}
			}
			
			REP(l, stone[i + 1].size()) {
				pii &to = stone[i + 1][l];
				int cost = (from.second + to.second) * abs(from.first - to.first);
				dp[i + 1][l][k] = min(dp[i + 1][l][k], dp[i][j][k] + cost);
			}
		}
		
		int ans = INF;
		REP(i, stone[n - 1].size()) REP(j, m + 1) ans = min(ans, dp[n - 1][i][j]);
		REP(i, stone[n - 2].size()) FOR(j, 1, m + 1) ans = min(ans, dp[n - 2][i][j]);
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3644
#include<iostream>
#include<string>
using namespace std;
string s,t;
bool bad=false,allow=false;
int main(){
	cin >> t;
	s+='%%%%%%%%';
	s+=t;
	s+='%%%%%%%';
	for (int i=0;i<s.length();i++){
		if (s[i]=='e'){
			if ((s[i+1]=='r')&&(s[i+2]=='a')&&(s[i+3]=='s')&&(s[i+4]=='e')){
				i+=4;
				allow=true;
			}else if ((allow)&&(s[i+1]=='r')){
				i+=1;
				allow=false;
			}else{
				bad=true;
			}
		}else if (s[i]=='d'){
			if ((s[i+1]=='r')&&(s[i+2]=='e')&&(s[i+3]=='a')&&(s[i+4]=='m')){
				i+=4;
				allow=true;
			}else{
				bad=true;
			}
		}else if (s[i]=='r'){
			if (allow){
				allow=false;
			}else{
				bad=true;
			}
		}else if (s[i]!='%'){
			bad=true;
			allow=false;
		}
	}
	if (bad){
		cout << "NO\n";
	}else{
		cout << "YES\n";
	}
	return 0;
}

Measured memory_bytes: 3740
#include <bits/stdc++.h>
typedef long long lint;
using namespace std;
const int MAXN = 101;
const int INF = 1e9 + 7;
int w[MAXN],v[MAXN],dp[MAXN][100001];
int N,W;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> N >> W;
	for (int i = 0; i < N; ++i) {
		cin >> w[i] >> v[i];
	}
	int sumv = v[0];
	vector<vector<int> > dp(N,vector<int>(1e5+1,INF));
	dp[0][0] = 0, dp[0][v[0]] = w[0];
	for (int i = 1; i < N; ++i) {
		sumv += v[i];
		for (int j = 0; j <= sumv; ++j) {
			for (int k = 0; k < i; ++k) {
				if (j < v[i] || dp[k][j - v[i]] == INF) continue;
				dp[i][j] = min(dp[i][j], dp[k][j - v[i]] + w[i]);
			}
		}
	}
	int ans = -1;
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < dp[i].size(); ++j) {
			if (dp[i][j] > W) continue;
			ans = max(ans, j);
		}
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 42744
#include <bits/stdc++.h>
#define ll long long
using namespace std;
template <typename T> void read(T &x) {
	x = 0; int f = 1; char c = getchar();
	while (!isdigit(c)) {if (c == '-') f = -1; c = getchar();}
	while (isdigit(c)) x = x * 10 + c - '0', c = getchar(); x *= f;
}
const int N = 100010;
int cnt, len, d[N], p[N], vis[N], head[N];
struct Edge {int next, num;} e[N * 3];
struct Node {int x, y;} ans[N];
int Find(int x) {return p[x] == x ? x : p[x] = Find(p[x]);}
void add(int x, int y) {e[++cnt] = (Edge) {head[x], y}, head[x] = cnt;}
void dfs(int x, int fa) {
	vis[x] = 1;
	for (int p = head[x]; p; p = e[p].next) {
		int k = e[p].num; if (k == fa) continue;
		dfs(k, x);
		if (d[k] & 1) ans[++len] = (Node) {k, x}, d[k]++;
			else ans[++len] = (Node) {x, k}, d[x]++;
	}
}
int main() {
	int n, m; read(n), read(m), len = 0;
	if (m & 1) return puts("-1"), 0;
	for (int i = 1; i <= n; i++) p[i] = i;
	for (int i = 1; i <= m; i++) {
		int x, y; read(x), read(y);
		int tx = Find(x), ty = Find(y);
		if (tx == ty) ans[++len] = (Node) {x, y}, d[x]++;
			else add(x, y), add(y, x), p[tx] = ty;
	}
	for (int i = 1; i <= n; i++)
		if (!vis[i]) dfs(i, 0);
	for (int i = 1; i <= m; i++) cout << ans[i].x << ' ' << ans[i].y << '\n';
	return 0;
}

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

using namespace std;

#define int long long
#define ll long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl


struct UnionFind {
	vector< int > data;

	UnionFind(int sz) {
		data.assign(sz, -1);
	}

	bool unite(int x, int y) {
		x = find(x), y = find(y);
		if (x == y) return (false);
		if (data[x] > data[y]) swap(x, y);
		data[x] += data[y];
		data[y] = x;
		return (true);
	}

	int find(int k) {
		if (data[k] < 0) return (k);
		return (data[k] = find(data[k]));
	}

	int size(int k) {
		return (-data[find(k)]);
	}
};

signed main() {

	int N, M;
	cin >> N >> M;
	UnionFind uf(N);

	rep(i, M) {
		int x, y, z;
		cin >> x >> y >> z;
		x--; y--;
		uf.unite(x, y);
	}

	int ans = 0;
	rep(i, N) {
		if (uf.unite(0, i)) ans++;
	}
	cout << ans+1 << endl;


	return 0;
}


Measured memory_bytes: 1024
// #pragma GCC target("avx")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
// #define BEGIN_STACK_EXTEND(size) void * stack_extend_memory_ = malloc(size);void * stack_extend_origin_memory_;char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);*stack_extend_dummy_memory_ = 0;asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
// #define END_STACK_EXTEND asm volatile("mov %%rax, %%rsp"::"a"(stack_extend_origin_memory_));free(stack_extend_memory_);

#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<unordered_map>
#include<complex>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-11;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 11100000;
const int UF_SIZE = 3100000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	inline long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
	int UF[UF_SIZE];
	void init_UF(int n){
		for(int i=0;i<n;i++)UF[i]=-1;
	}
	int FIND(int a){
		if(UF[a]<0)return a;
		return UF[a]=FIND(UF[a]);
	}
	void UNION(int a,int b){
		a=FIND(a);b=FIND(b);if(a==b)return;
		if(UF[a]>UF[b])swap(a,b);
		UF[a]+=UF[b];UF[b]=a;
	}
}
// ここから編集しろ

int main(){
	long long a;
	scanf("%lld",&a);
	int ret=0;
	for(int i=2;(long long)i*i<=a;i++){
		if(a%i)continue;
		int cnt=0;
		while(a%i==0){
			a/=i;
			cnt++;
		}
		int now=1;
		while(cnt>=now){
			cnt-=now;
			ret++;
			now++;
		}
	}
	if(a>1){
		ret++;
	}
	printf("%d\n",ret);
}

Measured memory_bytes: 1732
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
using namespace std;
const int maxn = 1e5 + 10;
int num[maxn];
int main()
{
	int n, k;
	cin >> n >> k;
	for (int i = 0; i < n; ++i)
		cin >> num[i];
	sort(num, num + n);
	long long min = 1000000000000;
	for (int i = 0; i <= n - k; ++i)
		min = min < (num[i + k-1] - num[i]) ? min : (num[i + k-1] - num[i]);
	cout << min << endl;

}

Measured memory_bytes: 640
n, k = map(int, input().split())
a = [0] * (n + 1)
for i in range(1, n + 1):
    a[i] = i
c1 = [0] * (n + 1)
c1[1] = 1
for i in range(2, n + 1):
    c1[i] = c1[i - 1] + a[i]
# print(c1)
c2 = [0] * (n + 1)
c2[n] = a[n]
for i in range(n - 1, -1, -1):
    c2[i] = c2[i + 1] + a[i]
c2.reverse()
# print(c2)
ans = 0
for i in range(k - 1, n + 1):
    ans += c2[i] - c1[i] + 1
print(ans % 1000000007)

Measured memory_bytes: 70060
n, l = gets.split.map(&:to_i)
segments = []
seg = []
n.times do
    x = gets.to_i
    if seg.size <= 1
        seg << x
    elsif (seg[-2] - seg[-1])  * (seg[-1] - x) < 0
        segments << seg
        seg = [seg[-1], x]
    else
        seg << x
    end
end
segments << seg
p segments.map {|a| a.map {|x| l - x}.inject(:+)}.max


Measured memory_bytes: 13224
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define pb push_back
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f
#define endl '\n'
#define ll long long
#define f first
#define int long long
#define s second
#define FAST cin.tie(0), cout.tie(0), ios::sync_with_stdio(0)
#define debug(x) cout << "DEBUG " << x << endl
#define debug2(x, y) cout << "DEBUG " << x << " " << y << endl
#define debug3(x, y, z) cout << "DEBUG " << x << " " << y << " " << z<< endl
#define debug4(x, y, z, o) cout << "DEBUG " << x << " " << y << " " << z<< " " << o << endl
using namespace std;
typedef pair<int, int> pii;
typedef pair<int, pair<int, int>> ppi;
typedef vector<vector<int>> mat;
const ll mod = 1e9+7;
const int MAXN = 2e5+5;

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

	double ans = 0;
	for(int i = 0; i < n; i++) {
		double x;
		cin >> x;
		ans += (1.0/x);
	}
	cout <<  1.0/ans << endl;
}


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


public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int N = 0, M = 0;

		String line;
		while ((line = br.readLine()) != null) {
			String[] n = line.split(",");
			int a = Integer.parseInt(n[0]);
			int b = Integer.parseInt(n[1]);
			int r = Integer.parseInt(n[2]);

			if (a == b) {
				if (r*r != a*a+b*b) M++;
			} else {
				if (r*r == a*a+b*b) N++;
			}
		}
		System.out.println(N);
		System.out.println(M);

	}
}

Measured memory_bytes: 16900
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#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) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

signed main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s,t;
  cin >> s >> t;
  bool flag[26];
  REP(i,26){
    flag[i] = false;
  }

  int n = s.length();

  vec v(26);
  REP(i,n){
    if(!flag[s[i] - 'a']){
      v[s[i] - 'a'] = t[i] - 'a';
      flag[s[i] - 'a'] = true;
    }
    else{
      if(t[i] - 'a' != v[s[i] - 'a']){
        cout << "No" << endl;
        return 0;
      }
    }
  }
  
  bool check = true;
  REP(i,26){
    FOR(j,i+1,26){
      if(flag[i] && flag[j] && v[i] == v[j]){
        check = false;
      }
    }
  }
  if(check){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  
  
  return 0;
}

Measured memory_bytes: 916
using System;
using System.Linq;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        string outHead = "abcdefghijklmnopqrstuvwxyz";
        int[] charCord = new int[outHead.Length];

        while (true)
        {
            string input = Console.ReadLine();
            if (input == null) break;
            
            for (int i = 0; i < input.Length; i++)
            {
                int cord = Convert.ToInt32(input[i]);
                if (cord > 96 && cord < 123)
                {
                    charCord[cord - 97]++;
                }
                if (cord > 64 && cord < 91)
                {
                    charCord[cord - 65]++;
                }
            }
        }

        for (int i = 0; i < outHead.Length; i++)
        {
            Console.WriteLine(outHead[i] + " : " + charCord[i]);
        }
    }
}



Measured memory_bytes: 15884
#include <bits/stdc++.h>
#define long long long
//#include <ext/numeric>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define oo 0x3f3f3f3f
//#define OO 0x3f3f3f3f3f3f3f3f
//#define popcount(n) __builtin_popcount(n)
//#define popcountll(n) __builtin_popcountll(n)

using namespace std;

//using namespace __gnu_cxx;
//using namespace __gnu_pbds;
//template<typename T>
//using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
//struct mul {
//    long operator()(const long &n1, const long &n2) const {
//        return (n1 * n2) % Mod;
//    }
//};
//
//long identity_element(const mul &m) {
//    return 1LL;
//}

//long rand_int(long l, long r) { //[l, r]
//    static mt19937_64 gen(chrono::steady_clock::now().time_since_epoch().count());
//    return uniform_int_distribution<long>(l, r)(gen);
//}

const double PI = acos(-1.0);


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

    int n;
    cin >> n;
    vector<int> arr(n);
    for (int &x : arr)
        cin >> x;
    int ans = oo;
    for (int a = -100; a <= 100; ++a) {
        int tmp = 0;
        for (int &x : arr) {
            tmp += abs(x - a) * abs(x - a);
        }
        ans = min(ans, tmp);
    }

    cout << ans << '\n';


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793

int main(){
int s;
cin >> s;
if(s>=1200)cout << "ARC" << endl;
else cout << "ABC" << endl;
   
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;using ll=long long;using vi=vector<int>;using vvi=vector<vi>;using vl=vector<ll>;using vvl=vector<vl>;using P=pair<int,int>;using PL=pair<ll,ll>;using vp=vector<P>;using vpl=vector<PL>;
template<typename T>constexpr auto inf=numeric_limits<T>::max()/2;constexpr int INF=inf<int>,MOD=1000000007;constexpr ll LINF=inf<ll>;
#define _ol3(_1,_2,_3,name,...)name
#define _rep(i,n)_repi(i,0,n)
#define _repi(i,a,b)for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...)_ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n)for(int i=n-1;i>=0;--i)
#define REPA(i,v)REP(i,v.size())
#define all(v)(v).begin(),(v).end()
#define bit(n)(1ll<<(n))
#define uniq(v)sort(all(v));v.erase(unique(all(v)),v.end())
#define F first
#define S second
#define endl '\n'
#define cho(n,a,b)cout<<((n)?a:b)<<endl
void YES(int n){cho(n,"YES","NO");}void Yes(int n){cho(n,"Yes","No");}void Poss(int n){cho(n,"Possible","Impossible");}
void _print(ostream&){}template<class T,class...U>void _print(ostream&s,T&&t,U&&...u){s<<t<<(sizeof...(u)?' ':'\n');_print(s,u...);}
template<class...T>void print(T&&...t){_print(cout,t...);}
#ifndef LOCAL
struct osd{template<class T>osd&operator<<(const T&t){return*this;}};osd cer_;
#define dprint(...)
#define cerr cer_
#else
template<class...T>void dprint(T&&...t){_print(cerr,t...);}
#endif
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>ostream&operator<<(ostream&o,const vector<T>&v){for(auto&&i:v)o<<i<<' ';return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(T&j:v)i>>j;return i;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){return o<<p.F<<' '<<p.S;}
template<class T,class U>istream&operator>>(istream&i,pair<T,U>&p){return i>>p.F>>p.S;}
template<class T>ostream&operator<<(ostream&o,const set<T>&v){for(auto&&i:v)o<<i<<' ';return o;}
template<class T>ostream&operator<<(ostream&o,const multiset<T>&v){for(auto&&i:v)o<<i<<' ';return o;}
template<class T>vector<T>&operator<<(vector<T>&v,const T&t){v.push_back(t);return v;}
template<class T>set<T>&operator<<(set<T>&v,const T&t){v.insert(t);return v;}
template<class T>multiset<T>&operator<<(multiset<T>&v,const T&t){v.insert(t);return v;}

int main(){
    cin.tie(0);ios::sync_with_stdio(0);cout<<fixed<<setprecision(10);
    ll n;
    cin>>n;
    print(n*(n-1)/2);
    return 0;
}


Measured memory_bytes: 256