akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        sc.close();

        // 主処理
        String result;
        switch (s) {
            case "ABC":
                result = "ARC";
                break;
            default:
                result = "ABC";
                break;
        }

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 35508
import java.util.Scanner;

class Main {

    static Scanner scan;

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

        int a = scan.nextInt();
        int b = scan.nextInt();

        if (a == b) {
            System.out.println("a == b");
        } else if ( a < b ) {
            System.out.println("a < b");
        } else {
            System.out.println("a > b");
        }
    }
}



Measured memory_bytes: 26292
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <sstream>
#include <tuple>
#include <vector>

using namespace std;
using namespace chrono;

#ifdef DEBUG
	#define LOCAL_INPUT_FILE
#else
	//#define USE_FILE_IO
#endif

#ifdef USE_FILE_IO
	#define INPUT_FILE "input.txt"
	#define OUTPUT_FILE "output.txt"
	#define cin ____cin
	#define cout ____cout
	ifstream cin(INPUT_FILE);
	ofstream cout(OUTPUT_FILE);
#else
	#ifdef LOCAL_INPUT_FILE
		#define cin ____cin
		ifstream cin("input.txt");
	#endif
#endif

const int infinity = (int)1e9 + 42;
const int64_t llInfinity = (int64_t)1e18 + 256;
const int module = (int)1e9 + 7; 
const long double eps = 1e-8;

mt19937_64 randGen(system_clock().now().time_since_epoch().count());

inline void raiseError(string errorCode) {
	cerr << "Error : " << errorCode << endl;
	exit(42);
}

signed main() {
	#ifndef USE_FILE_IO
		ios_base::sync_with_stdio(false);
	#endif
	int n; cin >> n;
	int d; cin >> d;
	static int s[100][100];
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < d; ++j) {
			cin >> s[i][j];
		}
	}
	set<int> sq;
	for (int i = 0; i < 10000; ++i) {
		sq.insert(i*i);
	}
	int ans = 0;
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < i; ++j) {
			int dist = 0;
			for (int k = 0; k < d; ++k) {
				dist += (s[i][k] - s[j][k]) * (s[i][k] - s[j][k]);
			}
			if (sq.count(dist)) {
				++ans;
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 768
import java.util.Scanner;

public class Main{
    public static void main(String[] arg){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        while(n != 0){
            int[] s = new int[n];
            int sum = 0;
            double ave = 0;
            double a = 0;
            for(int i = 0; i<n; i++){
                s[i] = sc.nextInt();
                sum += s[i];
            }
            ave = (double) sum / n;
            for(int j = 0; j <n; j++){
                a += (double)(s[j] - ave)*(s[j] - ave) / n;
            } 
            double b = Math.sqrt(a);
            System.out.printf("%.8f\n",b);
            n = sc.nextInt();
        }
        sc.close();
    }
    
}


Measured memory_bytes: 31952
class NormalInput{
  input: string[];
  pointer: number;
  constructor(raw:string){
    this.input=raw.split(/ |\n/);
    this.pointer=0;
  }
  int():number{
    const ret= parseInt(this.input[this.pointer], 10);
    this.pointer++;
    return ret;
  }
  str():string{
    const ret= this.input[this.pointer];
    this.pointer++;
    return ret;
  }
  strs(length:number):string[]{
    let ret:string[]=[];
    for(let i=0;i<length;i++){
      ret.push(this.str());
    }
    return ret;
  }
  ints(length:number):number[]{
    let ret:number[]=[];
    for(let i=0;i<length;i++){
      ret.push(this.int());
    }
    return ret;
  }
}

function Main(_: NormalInput) {
  const S=_.str();
  let count=0;
  for(let c of S){
    if(c=='x')count++;
  }
  console.log((count>=8)?"NO":"YES");
}

//DO NOT EDIT
Main(new NormalInput(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
s=input()
t=input()

m=len(s)
n=len(t)

dp=[[0]*(n+1) for _ in range(m+1)]
trans=[[(-1,-1)]*(n+1) for _ in range(m+1)]

for i in range(m):
    for j in range(n):
        if s[i]==t[j]:
            dp[i+1][j+1]=dp[i][j]+1
            trans[i+1][j+1]=(i,j)
        else:
            if dp[i][j+1]>dp[i+1][j]:
                dp[i+1][j+1]=dp[i][j+1]
                trans[i+1][j+1]=(i,j+1)
            else:
                dp[i+1][j+1]=dp[i+1][j]
                trans[i+1][j+1]=(i+1,j)

ans=''

i=m
j=n
while i>0 and j>0:
    if s[i-1]==t[j-1]:
        ans=str(s[i-1])+ans
    i,j=trans[i][j]

print(ans)

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

using namespace std;

typedef long long ll;

const int INF = 1e9;

struct Node {
  int key_;
  Node *prev_, *next_;
  Node() : key_(0), prev_(NULL), next_(NULL) {}
  Node(int key) : key_(key), prev_(NULL), next_(NULL) {}
};

class List {
public:

  List() : head_(NULL), tail_(NULL), size_(0) {}
  ~List() {
    for (Node *p = head_, *q = NULL; p != NULL; p = q) {
      q = p->next_;
      //fprintf(stderr, "DEBUG: deleting %d\n", p->key_);
      delete(p);
    }
  }
  void insert(int val) {
    Node* node = new Node(val);
    if (head_ == NULL) {
      // empty
      head_ = tail_ = node;
    }
    else {
      node->next_ = head_;
      head_->prev_ = node;
      head_ = node;
    }
    ++size_;
    //print();
  }
  void del(int key)
  {
    if (size_ == 0) { return; }
    for (Node *p = head_; p != NULL; ) {
      if (p->key_ != key) {
        p = p->next_;
        continue;
      }
      Node* pp = p->prev_;
      Node* pn = p->next_;
      if (pp) {
        pp->next_ = pn;
      }
      if (pn) {
        pn->prev_ = pp;
      }
      if (p == head_) { head_ = pn; }
      if (p == tail_) { tail_ = pp; }
      delete p;
      --size_;
      break;
    }
  }

  void delFirst()
  {
    if (size_ == 0) { return; }
    if (size_ == 1) {
      delete head_;
      head_ = tail_ = NULL;
      --size_;
    }
    else {
      Node *p = head_;
      head_ = head_->next_;
      delete p;
      --size_;
    }
    //print();
  }

  void delLast()
  {
    if (size_ == 0) { return; }
    if (size_ == 1) {
      delete head_;
      head_ = tail_ = NULL;
      --size_;
    }
    else {
      Node *p = tail_;
      tail_ = tail_->prev_;
      tail_->next_ = NULL;
      delete p;
      --size_;
    }
    //print();
  }

  int size() const { return size_; }
  void print()
  {
    //fprintf(stdout, "size=%d\n", size_);
    for (Node *p = head_; p != NULL; p = p->next_) {
      if (p != head_) {
        fprintf(stdout, " ");
      }
      fprintf(stdout, "%d", p->key_);
    }
    fprintf(stdout, "\n");
  }

private:
  Node *head_, *tail_;
  int size_;
};

int main()
{
  List lst;
  int n = 0;
  fscanf(stdin, "%d", &n);
  char buf[64] = { '\0' };
  for (int i = 0; i < n; ++i) {
    int key = -1;
    fscanf(stdin, "%s", buf);
    if (buf[0] == 'i') {
      fscanf(stdin, "%d", &key);
      lst.insert(key);
    }
    else if (buf[6] == '\0') {
      fscanf(stdin, "%d", &key);
      lst.del(key);
    }
    else if (buf[6] == 'F') {
      lst.delFirst();
    }
    else if (buf[6] == 'L') {
      lst.delLast();
    }
  }
  lst.print();
  return 0;
}

Measured memory_bytes: 32368
//chiragjn
#include <bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define gibe_de_fast_io_b0ss ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
const ll mod = 1e9 + 7;
const ll INF = 0x7FFFFFFFFFFFFFFF/2;
int cache[100001][3] = {0};

int main(){
    gibe_de_fast_io_b0ss;
    int a, b, c, n;
    cin>>n;
    for(int i = 1; i <= n; i++) {
    	cin>>a>>b>>c;
    	cache[i][0] = a + max(cache[i - 1][1], cache[i - 1][2]);
    	cache[i][1] = b + max(cache[i - 1][0], cache[i - 1][2]);
    	cache[i][2] = c + max(cache[i - 1][0], cache[i - 1][1]);
    }
    cout<<max(max(cache[n][0], cache[n][1]), cache[n][2]);
    return 0;
}


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

int main()
{
	int n; cin >> n;
	
	vector<char> s(n);
	bool f = false;
	for (int i = 0; i < n; i++) {
		cin >> s[i];
		if (s[i] == 'Y') f = true;
	}

	string ans = "Three";

	if (f) ans = "Four";
	
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(int argc, char * argv[]){
   int H,W;
   scanf("%d %d",&H,&W);
   int i,j;
   int b = 0;
   char a = 'A';
   char *snuke = "snuke";
   char s[6] = {'\0'};
   for(i = 0; i < H; i++){
      for(j = 0; j<W; j++){
         scanf("%s",s);
         if(strcmp(s,snuke)==0){
            a += j;
            b = i+1;
         }
      }
   }
   printf("%c%d\n",a,b);
   return EXIT_SUCCESS;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main()
{
  int N, K;
  cin >> N >> K;
  vector <int> l(N);
  for (int i = 0; i < N; i++) {
    cin >> l[i];
  }
  sort(l.begin(), l.end());
  int ans = 0;
  for (int i = 1; i <= K; i++) {
    ans += l[N-i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);

		String[] line1 = sc.nextLine().split(" ");
		String[] line2 = sc.nextLine().split(" ");

		int[] label1 = new int[6];
		int[] label2 = new int[6];

		for (int i=0; i < 6; i++) {
			label1[i] = Integer.parseInt(line1[i]);
			label2[i] = Integer.parseInt(line2[i]);
		}

		Dice d1 = new Dice(label1);
		Dice d2 = new Dice(label2);

		char[] order = ( "LLLL" + "SWWW" + "LSSS" +
				"LEEE" + "LNNN" + "WRRR" ).toCharArray();

		for (int i=0; i < order.length; i++) {
			d2.kok(order[i]);
			if ( d1.check(d2) ) {
				System.out.println("Yes");
				break;
			}
			if (i == order.length -1) System.out.println("No");
		}
	}

}

class Dice {
	int ue,mae,migi,hidari,ushiro,shita;

	Dice(int[] label) {
		ue = label[0];
		mae = label[1];
		migi = label[2];
		hidari = label[3];
		ushiro = label[4];
		shita = label[5];
	}

	Dice kok(char newsrl) { // korogasu or kaitenn saseru
		int temp = 0;

		switch (newsrl) {
		case 'N':
			temp = ue;
			ue = mae;
			mae = shita;
			shita =ushiro;
			ushiro = temp;
			break;
		case 'S':
			temp = ue;
			ue = ushiro;
			ushiro = shita;
			shita = mae;
			mae = temp;
			break;
		case 'E':
			temp = ue;
			ue = hidari;
			hidari = shita;
			shita = migi;
			migi = temp;
			break;
		case 'W':
			temp = ue;
			ue = migi;
			migi = shita;
			shita = hidari;
			hidari = temp;
			break;
		case 'R':
			temp = mae;
			mae = migi;
			migi = ushiro;
			ushiro = hidari;
			hidari = temp;
			break;
		case 'L':
			temp = mae;
			mae = hidari;
			hidari = ushiro;
			ushiro = migi;
			migi = temp;
			break;
		}

		return this;
	}

	boolean check(Dice d) {
		if (this.ue == d.ue && this.mae == d.mae &&
				this.migi == d.migi && this.hidari == d.hidari &&
				this.ushiro == d.ushiro && this.shita == d.shita) {
			return true;
		} else
			return false;
	}

}

Measured memory_bytes: 26216
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define INF 1<<30

int main() {
  bool f = true;
  while(f) {
    string s;
    int hoge = 0;
    REP(i,3) {
      cin >> s;
      if (s == "0") {
        f = false;
        break;
      }
      int a = count(ALL(s),'A');
      int b = count(ALL(s),'B');
      if (hoge == 0)
        a--;
      else
        b--;
      if (a>b) {
        a++;
        hoge = 0;
      } else {
        b++;
        hoge = 1;
      }
      cout << a << " " << b << endl;
    }
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#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 all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define pb(a) push_back(a)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int main(){
	int n;
	while(1){
		cin>>n;
		if(n==0) break;
		pii d[10001]={};
		int p,a,b;
		rep(i,0,n){
			cin>>p>>a>>b;
			d[i].fi=a+b; d[i].se=p;
		}
		sort(d,d+n);
		reverse(d,d+n);
		o(d[0].se<<" "<<d[0].fi);
	}
}

Measured memory_bytes: 1240
#include<stdio.h>
int main(){

  char t,s[22];
  int i=0,j;
  fgets(s,21,stdin);

  while(s[i]!='\0')i++;
  for(j=0;j*2<i;j++){
    t=s[j];
    s[j]=s[i-j-1];
    s[i-j-1]=t;
  }
  printf("%s\n",s);
  return 0;
}

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

using ll    = long long;
using ull   = unsigned long long;
using veci  = vector<int>;
using vecll = vector<ll>;
#define EPS (1e-7)
#define INF (1e9)
#define PI  (acos(-1))
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define REP(i,n) for(int i= 0;i<(int)(n);++i)
#define pb push_back

veci enum_div(int n){
	veci ret;
	ret.pb(1);
	for(int i=1;i*i<n;i++){
		if(n%i==0){
			ret.pb(i);
			if(i != n/i){ret.pb(n/i);}
		}
	}
	ret.pb(n);
	return ret;
}
int gcb(int a,int b){return ((b == 0)? a : gcb(b,a%b));}
int gcd(int a,int b){return (a*b) / gcb(a,b);}

int main(){
    int m;
    cin >> m;
    cout << 48-m << endl;
    return 0;
}



Measured memory_bytes: 256
n = int(input())
t = [int(input()) for i in range(n)]

def gcd(a, b):
  if a<b:
    a, b = b, a
  if b==0:
    return a
  return gcd(b, a%b)

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

ans = 1
for i in range(n):
  ans = lcm(ans, t[i])
print(ans)

Measured memory_bytes: 3064
import itertools
D, G = [int(_) for _ in input().split()]
SPC = [[100 * (i + 1)] + [int(_) for _ in input().split()]
       for i in range(D)][::-1]
ans = 10**10
for i in range(D + 1):
    completes = set(itertools.combinations(range(D), i))
    for complete in completes:
        incomplete = sorted(set(range(D)) - set(complete))
        score = 0
        cnt = 0
        f = 0
        for j in complete:
            s, p, c = SPC[j]
            score += s * p + c
            cnt += p
        for j in incomplete:
            if score >= G:
                break
            s, p, c = SPC[j]
            d = min(p - 1, 1 + (G - score - 1) // s)
            score += s * d
            cnt += d
        if score >= G:
            ans = min(ans, cnt)
print(ans)


Measured memory_bytes: 9132
import java.io.*;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

    static class Task {

        private static final int MAX = 100005;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] arr = new int[n];
            int[] countArr = new int[MAX];
            long sum = 0;
            for (int i = 0; i < n; i++) {
                arr[i] = in.nextInt();
                countArr[arr[i]]++;
                sum += arr[i];
            }

            int q = in.nextInt();
            for (int i = 0; i < q; i++) {
                int b = in.nextInt();
                int c = in.nextInt();
                long count = countArr[b];
                sum += (count * (c - b));
                countArr[b] = 0;
                countArr[c] += (int) count;
                out.println(sum);
            }
        }
    }

    private static void sort(double[] arr) {
        Double[] objArr = Arrays.stream(arr).boxed().toArray(Double[]::new);
        Arrays.sort(objArr);
        for (int i = 0; i < arr.length; i++) {
            arr[i] = objArr[i];
        }
    }

    private static void sort(int[] arr) {
        Integer[] objArr = Arrays.stream(arr).boxed().toArray(Integer[]::new);
        Arrays.sort(objArr);
        for (int i = 0; i < arr.length; i++) {
            arr[i] = objArr[i];
        }
    }

    private static void sort(long[] arr) {
        Long[] objArr = Arrays.stream(arr).boxed().toArray(Long[]::new);
        Arrays.sort(objArr);
        for (int i = 0; i < arr.length; i++) {
            arr[i] = objArr[i];
        }
    }

    private static void solve() {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task task = new Task();
        task.solve(1, in, out);
        out.close();
    }

    public static void main(String[] args) {
        new Thread(null, () -> solve(), "1", 1 << 26).start();
    }

    static class InputReader {

        public BufferedReader reader;
        public 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());
        }

    }

}

Measured memory_bytes: 56616
object Main extends App{
  val sc = new java.util.Scanner(System.in)
  var a , b =sc.nextInt()
  if(b == 0) {print(a);sys.exit()}
  var c = List.fill(b)(sc.nextInt())
  if(c.indexOf(a) == -1){print(a);sys.exit()}
  c :+ a
  c = c.sorted
  var min = 0
  var max = 0
  if (c.indexOf(a) == 0){print(a-1);sys.exit()}
  min = c(c.indexOf(a) - 1)
  if(c.indexOf(a) != b-1) {
    max = c(c.indexOf(a)+1)
  }else{
    max = 105
  }
  var i = a-1
  var j = a+1
  var ans = 0
  while (i == min){
    i-=1
    if(!(c.indexOf(min)-1 == -1)) {
      min = c(c.indexOf(min) - 1)
    }else{
      min = i+1
    }
  }
  while (j == max){
    j+=1
    if(!(c.indexOf(max)+1 > b-1)) {
      max = c(c.indexOf(max) + 1)
    }else{
      max = j+1
    }
  }
  var ia = a-i
  var ja = a-j
  if(ia > a){print(0);sys.exit()}
  if(math.abs(ia)>math.abs(ja)){
    print(j)
  }else{
    print(i)
  }
}


Measured memory_bytes: 55620
#include <bits/stdc++.h>
#include <string.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m; i < n; i++) 
#define mod 1000000007
#define pi 3.1415926535
typedef long long ll;

int main(){
    string S,T;
    cin>>S>>T;
    if(S.size()+1==T.size()&&S==T.substr(0,S.size())){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3624
#pragma GCC optimize("Ofast,inline,unroll-loops,fast-math")
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#define N 320
using namespace std;

char a[N];
int f[N][N][N];

int main(void)
{
    int n, k;
    int i, j, t, o;

    scanf("%s %d", a + 1, &k);
    n = strlen(a + 1);
    if(n == 1)
    {
        printf("1\n");

        return 0;
    }
    if(n == 2)
    {
        printf("%d\n", 1 + (a[1] == a[2] || k));

        return 0;
    }

    for(i = 1, o = 0; i <= n; i ++)
        for(j = n; j > i; j --)
            for(t = 0; t <= k; t ++)
            {
                f[i][j][t] = max(f[i - 1][j][t], f[i][j + 1][t]);
                if(a[i] == a[j])
                    f[i][j][t] = max(f[i][j][t], f[i - 1][j + 1][t] + 1);
                else if(t)
                    f[i][j][t] = max(f[i][j][t], f[i - 1][j + 1][t - 1] + 1);

                // printf("left %d, right %d, change %d : %d\n", i, j, t, f[i][j][t]);
                o = max(o, f[i][j][t] * 2 + (i < j - 1));
            }
    printf("%d\n", o);

    return 0;
}


Measured memory_bytes: 120704
n,m=map(int,input().rstrip().split(' '))
maxL=0
minR=n+1
for i in range(m):
  l,r=map(int,input().rstrip().split(' '))
  maxL = max(maxL,l)
  minR = min(minR,r)
print(max(minR-maxL+1,0))

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

#define ft first
#define sd second
#define pb push_back
#define all(x) x.begin(),x.end()

#define ll long long int
#define vi vector<int>
#define vii vector<pair<int,int> >
#define pii pair<int,int>
#define plii pair<pair<ll, int>, int>
#define piii pair<pii, int>
#define viii vector<pair<pii, int> >
#define vl vector<ll>
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define mp make_pair
#define ms(x, v) memset(x, v, sizeof x)
#define pr_vec(v) for(int i=0;i<v.size();i++) cout << v[i] << " " ;

#define f_in(st) freopen(st,"r",stdin)
#define f_out(st) freopen(st,"w",stdout)

#define fr(i, a, b) for(i=a; i<=b; i++)
#define fb(i, a, b) for(i=a; i>=b; i--)
#define ASST(x, l, r) assert( x <= r && x >= l )
const int  p=31,po=1,N=(ll)1e5+1, M=(ll)1e9+1 ;
const int mod = (ll)1e9 +7;

//ll dp[2][100];
vl compute(string s){
        vl has(s.length());
        ll i;

        for(i=0;i<s.length();i++){
            if(i==0){
                has[i]=((s[i]-'a'+1))%mod;
            }
            else
                has[i]=(has[i-1]*p + (s[i]-'a'+1))%mod;
        }
        return has;
}

ll pow(ll x,ll p,ll m){
    if(p==0)
            return 1;
    if(p==1)
            return x;
    ll z=pow(x,p/2,m);
    if(p&1)
            return (z%m*z%m*x)%m;
    else
            return (z%m*z%m)%m;

}

ll inv(ll a,ll p){
    return pow(a,p-2,p)%p;
}
vl fact;
void mod_fact(ll n,ll m){
    fact.resize(n+1);
    fact[0]=1;
    ll i;
    for(i=1;i<fact.size();i++)
            fact[i]=(fact[i-1]%m * i)%m;
}

ll mod_combo(ll n,ll k,ll m){
    if(n<k)
      return 0;
    return fact[n]*inv((fact[k]%m * fact[n-k]%m)%m,m)%m;
}
int main(){
 ios_base::sync_with_stdio(0);
    ll n,m,mx;
    cin >> n >> m;
    mx=m;
    ll i,j,k,ans=1,res=0;
    mod_fact(n+64,mod);
//    cout << inv(n,m);
    for(i=2;i*i<=mx;i++){
        res=0;
        while(m%i==0){
            res++;
            m/=i;
        }
        if(res)
        {
            ans*=mod_combo(n+res-1,res,mod);
            ans%=mod;
        }
        // cout << i << " " << res << endl;
    }
    if(m!=1)
    {ans*=mod_combo(n,1,mod);
        ans%=mod;
    }
    cout << ans;
    return 0;
//    ll dp[n+1][m+1];
//    for(i=0;i<=n;i++)
//            for(j=0;j<=m;j++)
//                dp[i][j]=0;
//    for(i=1;i<=m;i++){
//            dp[1][i]=1;
//    }
//    for(i=1;i<=m;i++){
//        for(k=2;k<=n;k++){
//            dp[k%2][i]=0;
//            for(j=1;j<=i;j++){
//                if(i%j==0){
//                    dp[k][i]+=dp[(k-1)][i/j];
//                    dp[k][i]%=mod;
//                }
//            }
//        }
//    }
//
// //    for(i=0)
////    cout << dp[n%2][m] << " " << dp[(n-1)%2][m];
//    cout << dp[n][m];
    return 0;
}



Measured memory_bytes: 1024
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <cstring>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}

using Graph = vector<vector<int>>;

// 深さ優先探索
vector<bool> seen;
void dfs(const Graph& G, int v) {
    seen[v] = true; // v を訪問済にする

    // v から行ける各頂点 next_v について
    for (auto next_v : G[v]) {
        if (seen[next_v]) continue; // next_v が探索済だったらスルー
        dfs(G, next_v); // 再帰的に探索
    }
}



int main() {
    ll H, W;
    cin >> H >> W;
    vector<ll> dx = { 1,1,1,0,0,-1,-1,-1 };
    vector<ll> dy = { 1,0,-1,1,-1,1,0,-1 };
    vector<vector<char>> data(H+2, vector<char>(W+2));
    rep(i, H+2) {
        data.at(i).at(0) == '!';
        data.at(i).at(W+1) == '!';
    }
    rep(i, W + 2) {
        data.at(0).at(i) == '!';
        data.at(H+1).at(i) == '!';
    }
    rep(i, H) {
        string S;
        cin >> S;
        rep(j, W) {
            data.at(i + 1).at(j + 1) = S.at(j);
        }
    }

    rep(i, H) {
        rep(j, W) {
            if(data.at(i + 1).at(j + 1) =='#'){
                cout << '#';
                continue;
            }
            else {
                ll a = 0;
                rep(k, 8) {
                    if (data.at(i + 1 + dx.at(k)).at(j + 1 + dy.at(k)) == '#') {
                        a++;
                    }

                }
                cout << a;
            }
        }
        cout << endl;
    }
}

Measured memory_bytes: 3624
using System;

namespace WelcomeToAtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            long n = long.Parse(Console.ReadLine());
            
            String ret = "";

            n = n % 10;
            
            switch (n)
            {
                case 2:
                case 4:
                case 5:
                case 7:
                case 9:
                    ret = "hon";
                    break;
                case 0:
                case 1:
                case 6:
                case 8:
                    ret = "pon";
                    break;
                case 3:
                    ret = "bon";
                    break;

            }
            Console.WriteLine(ret);
        
        }

    }
}


Measured memory_bytes: 27328
//#include <bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<cstring>
#include<bitset>
#include<stack>

#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define scd(a) scanf("%d",&a)
#define scdd(a,b) scanf("%d%d",&a,&b)
#define scddd(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define ALL(x) x.begin(),x.end()
#define mst(var,val) memset(var,val,sizeof(var))
#define IOS ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ls rt<<1
#define rs rt<<1|1
#ifdef local
#define dbg(a) cout << #a": " << a << endl;
#else
#define dbg(a)
#endif // loacl


using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <double, double> pdd;
const ll inf=0x3f3f3f3f;
const long long INF=0x3f3f3f3f3f3f3f3fLL;
const double PI=acos(-1.0);
const long double eps=1e-6;
const int mod=1e9+7;
const int maxn=1e6+10;
const int N=2e5+10;
const int M=N<<1;
const ll mm=(1LL<<32);

template <class T>
inline void read(T &x) {
    x = 0;
    char c = getchar();
    bool f = 0;
    for (; !isdigit(c); c = getchar()) f ^= c == '-';
    for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48);
    x = f ? -x : x;
}

template <class T>
inline void write(T x) {
    if (x < 0) {
        putchar('-');
        x = -x;
    }
    T y = 1;
    int len = 1;
    for (; y <= x / 10; y *= 10) ++len;
    for (; len; --len, x %= y, y /= 10) putchar(x / y + 48);
}
ll qpow(ll a,ll b,ll MOD)
{
    ll ans=1;
    while(b)
    {
        if(b&1) ans=(ans*a)%MOD;
        b>>=1;
        a=(a*a)%MOD;
    }
    return ans;
}

ll dp[66][2][2],L,R;
ll dfs(int x, bool Left, bool Right, bool keep) {
    if(x < 0) return 1;
    if( ~ dp[x][Left][Right] && !keep)
        return dp[x][Left][Right];
    ll ans = 0;
    int l = 0, r = 1;
    if(Left) l = L >> x & 1;
    if(Right) r = R >> x & 1;
    for(int i = l ; i <= 1 ; i++) {
        for (int j = i ; j <= r ; j++) {
            if (j == 1 && keep) {
                if(i == 1) ans += dfs(x-1, Left && i == l, Right && j == r, keep && j == 0);
            }
            else ans += dfs(x-1, Left && i == l, Right && j == r, keep && j == 0);
        }
    }
    ans %= mod;
    if(!keep) dp[x][Left][Right] = ans;
    return ans;
}
int main()
{
#ifdef local
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
#endif // local
    IOS;
    cin>>L>>R;
    mst(dp,-1);
    cout<<dfs(60,1,1,1)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  int P = 0,W = 0,G = 0, Y = 0;
  for (int i = 0; i < N; i++){
    string s;
    cin >> s;
    //cout << s << endl;
   	if(s == "P") P = 1;
   	if(s == "W") W = 1;
    if(s == "G") G = 1;
    if(s == "Y") Y = 1;
  }
  
  int count = 0;
  count = P + W + G + Y;
  if(count == 4){
    cout << "Four" << endl;
  }
  else{
    cout << "Three" << endl;
  }

}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define min(a,b) ((a)<(b)?(a):(b))
int main(void){
    long long i,n,ans=0,minus=0,min=1e9,a;
    scanf("%lld",&n);
    for(i=0;i<n;i++){
        scanf("%lld",&a);
        if(a<0) minus++;
        ans+=abs(a);
        min=min(min,abs(a));
    }
    if(minus%2) ans-=2*min;
    printf("%lld",ans);
}

Measured memory_bytes: 128
#include <iostream>
#include<cstring>
char a[1000000];
using namespace std;
int main()
{
	cin >> a + 1;
	int flag = 0;
	int len = strlen(a + 1);
	for (int i = 1; i < len; i++)
	{
		if (i + 1 <= len && a[i + 1] == a[i])
		{
			cout << i << " " << i + 1 << endl;
			flag = 1;
			break;
		}
		if (i + 2 <= len && a[i + 2] == a[i])
		{
			cout << i << " " << i + 2 << endl;
			flag = 1;
			break;
		}
	}
	if(flag == 0)
	cout << "-1 -1" << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std ; 
# define pb push_back
# define ll long long
# define mp make_pair 
# define endl "\n"
# define vi vector<int>
# define vc vector<char>
# define vll vector<ll> 
# define pi pair<int,int> 
const int MOD = 1e9 + 7 ; 
const ll inf = 1e18 ; 


int main() {

	int  n , k ; 
	cin >> n >> k ; 
	vi a(n) ; 
	for(int i = 0 ; i < n ; ++i)
		cin >> a[i] ;
	for(int i = k ; i < n ; ++i) {
		if(a[i] > a[i-k]) {
			cout << "Yes" ; 
		} else {
			cout << "No" ; 
		}
		cout << endl ; 
	}
	return 0; 
}


Measured memory_bytes: 4048
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int[] arr = new int[N+1000];
        int[] memo = new int[N+1000];

        for (int i = 0; i < N; i++) {
            arr[i] = sc.nextInt();
            memo[i]=-1;
        }

        int[] dp = new int[N+1000];
        for (int i = 0; i <dp.length ; i++) {
            dp[i] = Integer.MAX_VALUE;
        }
        dp[1] = 0;
        for (int i = 2; i <= N ; i++) {
            for (int j = Math.max(1,i-K) ; j <= i-1 ; j++) {
                int val  =Math.min(dp[i], dp[j] +Math.abs(arr[j-1]-arr[i-1]));
                dp[i] = val;
            }
        }
        System.out.println(dp[N]);
//        System.out.println(recur(arr,memo,N-1));

    }

    static public int recur(int[] arr,int[] memo, int idx){
        if(memo[idx]!=-1) return memo[idx];
        if(idx <=0){
            return 0;
        }

        int min = Integer.MAX_VALUE;
        if(idx-1>=0)
        min = Math.min(min, recur(arr,memo,idx-1) + Math.abs(arr[idx] - arr[idx-1]));

        if(idx-2>=0)
        min = Math.min(min, recur(arr,memo,idx-2) + Math.abs(arr[idx] - arr[idx-2]));

        memo[idx] =min;
        return min;
    }


}



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

string s;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr); cout.tie(nullptr);
  
  cin >> s;
  if(s[2] == s[3] && s[4] == s[5]) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
  
  return 0;
}

Measured memory_bytes: 256
# python template for atcoder1
from collections import Counter
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


N = int(input())
A = list(map(int, input().split()))

C = Counter(A)

C_freq = C.most_common()
ma = C_freq[-1][0]
mi = C_freq[0][0]


cost = float('inf')

# for j in range(mi, ma+1):
for j in range(-100, 100+1):
    tmp = 0
    for i, v in C.items():
        tmp += v*(j-i)**2
    cost = min(cost, tmp)
print(cost)


Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T> ostream& operator<<(ostream& s,const multiset<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1'000'000'007;
const ll inf=1'000'000'000'000'000'00;
const int INF=1'000'000'000;
const double EPS=1e-10;
const double PI=acos(-1);

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    string s;
    cin>>s;
    int ans=0;
    if(s[1]=='R'){
        ans++;
        if(s[0]=='R') ans++;
        if(s[2]=='R') ans++;
    }else{
        if(s[0]=='R' || s[2]=='R') ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3564
#pragma comment(linker, "/STACK: 1024000000,1024000000")
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define em emplace
#define pii pair<int,int>
#define de(x) cout << #x << " = " << x << endl
#define dd(x) cout << #x << " = " << x << " " << endl
#define clr(a,b) memset(a,b,sizeof(a))
#define INF (0x3f3f3f3f)
#define LINF ((long long)(0x3f3f3f3f3f3f3f3f))
#define F first
#define S second
using namespace std;


typedef long long ll;
int main() {
	ll a, b;
	cin >> a >> b;
	if ( (a+b) & 1 ) puts("IMPOSSIBLE");
	else cout << (a+b>>1) << '\n';
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N,A,B;
  cin >> N >> A >> B ;
  long long m = A + B ;
  long long a = N/m , b = N%m ;
  if(b < A){
    cout << a*A + b << endl;
  }
  else{
    cout << a*A + A<< endl;
  }
  return 0;
}

Measured memory_bytes: 256
N,K=map(int,input().split())
A=list(map(int,input().split()))
cnt=0
mod=10**9+7
for i in range(N):
    for j in range(N):
        if A[i]>A[j]:
            if i<j:
                cnt+=(K*(K+1)//2)%mod
            else:
                cnt+=(K*(K-1)//2)%mod
print(cnt%mod)

Measured memory_bytes: 3188
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>

typedef struct _data_st
{
    int sum;
    struct _data_st *next;
} data_st;

int main(int argc, char *argv[])
{
    data_st *head = NULL, *tail = NULL;
    for (char digits[1002] = {}; fgets(digits, 1002, stdin) && !(strlen(digits) && digits[0] == '0');)
    {
        data_st *data = (data_st *)calloc(sizeof(data_st), 1);
        if (!data)
        {
            break;
        }
        for (char *elm = digits; isdigit(*elm); ++elm)
        {
            data->sum += *elm - '0';
        }
        head = head ?: data;
        if (tail)
        {
            tail->next = data;
        }
        tail = data;
    }
    while (head)
    {
        data_st *data = head;
        head = head->next;
        printf("%d\n", data->sum);
        free(data);
    }
    tail = NULL;
    return 0;
}



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

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	
	long long ans = a[0] - 1;
	int wari = 2;
	
	for(int i = 1; i < n; i++){
		if(a[i] == wari){
			wari++;
		}else{
			if(a[i] % wari == 0){
				a[i] -= wari + 1;
				ans++;
			}
			ans += a[i] / wari;
			a[i] %= wari;
		}
	}
	
	cout << ans << endl;
	
	return 0;
}

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

using ll = long long;
using pii = pair<int, int>;
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define per(i, b) per2(i, 0, b)
#define per2(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define ALL(c) (c).begin(), (c).end()
#define SZ(x) ((int)(x).size())

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }

template <class T, class U>
void chmin(T& t, const U& u) {
    if (t > u) t = u;
}
template <class T, class U>
void chmax(T& t, const U& u) {
    if (t < u) t = u;
}

template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "{";
    rep(i, v.size()) {
        if (i) os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

#ifdef LOCAL
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << H;
    debug_out(T...);
}
#define debug(...) \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif

int main() {
    int N;
    ll T;
    cin >> N >> T;
    V<ll> A(N);
    rep(i, N) cin >> A[i];
    map<ll, int> M;
    ll x = A[0];
    rep(i, N) {
        chmin(x, A[i]);
        M[A[i] - x]++;
    }
    auto it = --M.end();
    cout << it->se << endl;
    return 0;
}

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

int main()
{
    ll n;
    cin >> n;
    vector<ll> a(n);
    vector<ll> flgs(n, 0);
    rep(i, n){
        cin >> a[i];
    }

    ll ans=0;
    ll i = 1;
    while(true){
        if(flgs[i-1] == 1){
            cout << -1 << endl;
            return 0;
        }
        flgs[i-1] = 1;
        i = a[i-1];
        ans++;
        if(i == 2){
            break;
        }
    }

    cout << ans << endl;


    return 0;
}


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

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MIN(a, b) ((a) > (b) ? (b) : (a))
#define MAX(a, b) ((a) < (b) ? (b) : (a))

const long long INF = 1LL << 60;
typedef unsigned long long ll;
const long long MOD = 1000000000 + 7;

int main()
{
    int n;
    cin >> n;
    map<char, int> initial;
    string s;
    rep(i, n)
    {
        cin >> s;
        if (s[0] == 'M' || s[0] == 'A' || s[0] == 'R' || s[0] == 'C' || s[0] == 'H')
        {
            initial[s[0]]++;
        }
    }
    ll cnt = 0;
    char march[5] = {'M', 'A', 'R', 'C', 'H'};
    for (int bit = 0; bit < (1 << 5); bit++)
    {
        if (__builtin_popcount(bit) != 3)
            continue;
        ll mult = 1;
        rep(i, 5)
        {
            if (bit & (1 << i))
                mult *= initial[march[i]];
        }
        cnt += mult;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3596
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    S = input()
    Q = int(input())
    x = tuple(map(int,input().split()))
    for k in x:
        d = 0
        m = 0
        dm = 0
        dmc = 0
        for i in range(N):
            if S[i] == "D":
                d += 1
            elif S[i] == "M":
                m += 1
                dm += d
            elif S[i] == "C":
                dmc += dm
            if i >= k-1:
                if S[i-k+1] == "D":
                    dm -= m
                    d -= 1
                elif S[i-k+1] == "M":
                    m -= 1
        print(dmc)
    
if __name__ == "__main__":
    main()


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

int main()
{
	while ( true )
	{
		int K;
		cin >> K;
		if ( K == 0 )
			break;
		long long s = 0;
		for ( int i=0; i<K*(K-1)/2; i++ )
		{
			int t; cin >> t;
			s += t;
		}

		cout << s / (K-1) << endl;
	}
}

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

int main() {
  int x, n;
  cin >> x >> n;
  vector<int> p(n);
  bool flug = true;
  rep(i, n) {cin >> p[i]; if (p[i] == x) flug = false;}
  if (flug) {cout << x << endl; return 0;}

  for (int i=1; i<60; i++) {
    flug = true;
    int y = x - i;
    rep(j, n) {
      if (p[j] == y) flug = false;
    }
    if (flug) {cout << y << endl; return 0;}

    flug = true;
    y = x + i;
    rep(j, n) {
      if (p[j] == y) flug = false;
    }
    if (flug) {cout << y << endl; return 0;}
  }



  return 0;
}

/*
*/


Measured memory_bytes: 3600
import sys

if sys.platform =='ios':
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def MAP(): return [int(s) for s in input().split()]

"""
配列再利用によりdpの次元削減を行うパターン
"""

N, W = MAP()

dp = [0 for _ in range(W+1)]

for _ in range(N):
	v, w = MAP()
	for sum_w in range(W+1):
		#print(item, sum_w)
		if sum_w >= w:
			dp[sum_w] = max(dp[sum_w-w]+v, dp[sum_w])
		else:
			dp[sum_w] = dp[sum_w]

#print(dp)
print(dp[-1])



Measured memory_bytes: 5736
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));

            return;
        }

        public void Solve(ConsoleInput cin)
        {

            var N = cin.ReadInt;
            var M = cin.ReadInt;
            var X = cin.ReadIntArray(M);

            if (N >= M) {
                Console.WriteLine('0');
                return;
            }

            Array.Sort(X);

            int[] L = new int[M - 1];
            for (int i = 0; i < M - 1; i++)
            {
                L[i] = X[i + 1] - X[i];
            }

            Array.Sort(L);
            Array.Reverse(L);
            int remaining = 0;
            for (int i = 0; i < N - 1; i++)
            {
                remaining += L[i];
            }

            int ans = (X[M - 1] - X[0]) - remaining;

            Console.WriteLine(ans);

            return;
        }
    }

    public static class Extensions
    {
        public static string Reverse(this string sourse)
        {
            char[] chrAry = sourse.ToCharArray();
            Array.Reverse(chrAry);
            return new string(chrAry);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}


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

#define rep(i, n) for(int i=0; i < n; i++)
#define REP(i, n, m) for(int i=n; i < m; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define ALL(v) v.begin(), v.end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)

using namespace std;
using ll=long long;

ll mod=1000000007;

const ll INF = 1LL << 60;

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 main() {
  string s; cin >> s;
  rep(i,s.size()){
    if(i%2 && s[i]=='R') {cout << "No";return 0;}
    if(!(i%2) && s[i]=='L') {cout << "No";return 0;}
  }
  cout << "Yes";
}

Measured memory_bytes: 384
//
// Created by yuu on 2019-05-01.
//

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <math.h>
#include <stack>
#include <queue>

using namespace std;


int main(void){
    string s;
    cin>>s;

    int temp=0;
    int max=0;
    for (int i = 0; i < s.size(); ++i) {
        if(s[i]=='A' || s[i] == 'C' || s[i]=='G' || s[i]=='T'){
            temp++;
        }else{
            if(max < temp){
                max = temp;
            }
            temp = 0;
        }
    }
    if(max<temp){
        max = temp;
    }

    cout<<max<<endl;

    return 0;
}

Measured memory_bytes: 256
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=-1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

S=get_nsp.reverse
flag=true
que=[]
S.each do|s|
  que.push(s)
  if que.size==5
      str=que.join("")
      if str=="esare" or str=="maerd"
          que=[]
      end
  elsif que.size==6
      str=que.join("")
      if str=="resare"
          que=[]
      end
  elsif que.size==7
      str=que.join("")
      if str!="remaerd"
          flag=false
          break
      else
          que=[]
      end
  end
end
puts yn_judge(flag,"YES","NO")

Measured memory_bytes: 14204