akhauriyash/Code-Regression huggingface dataset:
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

/*
 * AtCoder Beginner Contest 081 C "Not so Diverse"
 */
public class Main {

	public static void main(String[] args) {

		InputScanner in = new InputScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		int N = in.nextInt();
		int K = in.nextInt();
		int[] Ai = in.nextIntArray(N);

		int type = 0;
		int maxNum = 200000;
		int[] count = new int[maxNum];
		Arrays.fill(count, 0);
		for (int A : Ai) {
			if (count[A] == 0) {
				type++;
			}
			count[A]++;
		}

		int ans = N;
		Arrays.parallelSort(count);
		for (int i = maxNum - K; i < maxNum; i++) {

			if (count[i] == 0) {
				ans = 0;
				break;
			} else {
				ans -= count[i];
			}

		}

		out.println(ans);

		in.close();
		out.close();
	}

	/*
	 * extends java.util.Scanner
	 */
	static class InputScanner {

		Scanner scanner;

		public InputScanner(InputStream inputStream) {
			this.scanner = new Scanner(inputStream);
		}

		public int nextInt() {
			return scanner.nextInt();
		}

		public long nextLong() {
			return scanner.nextLong();
		}

		public double nextDouble() {
			return scanner.nextDouble();
		}
		public String next() {
			return scanner.next();
		}

		public int[] nextIntArray(int n) {
			int[] ret = new int[n];
			for (int i = 0; i < n; i++) {
				ret[i] = scanner.nextInt();
			}
			return ret;
		}

		public int[][] nextIntArray(int h, int w) {
			int[][] ret = new int[h][w];
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					ret[i][j] = scanner.nextInt();
				}
			}
			return ret;
		}

		public long[] nextLongArray(int n) {
			long[] ret = new long[n];
			for (int i = 0; i < n; i++) {
				ret[i] = scanner.nextLong();
			}
			return ret;
		}

		public long[][] nextlongArray(int h, int w) {
			long[][] ret = new long[h][w];
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					ret[i][j] = scanner.nextLong();
				}
			}
			return ret;
		}

		public double[] nextDoubleArray(int n) {
			double[] ret = new double[n];
			for (int i = 0; i < n; i++) {
				ret[i] = scanner.nextDouble();
			}
			return ret;
		}

		public double[][] nextDoubleArray(int h, int w) {
			double[][] ret = new double[h][w];
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					ret[i][j] = scanner.nextLong();
				}
			}
			return ret;
		}

		public String[] nextStringArray(int n) {
			String[] ret = new String[n];
			for (int i = 0; i < n; i++) {
				ret[i] = scanner.next();
			}
			return ret;
		}

		public String[] nextStringArray(int n, String split) {
			String[] ret = scanner.next().split(split);
			return ret;
		}

		public String[][] nextStringArray(int h, int w) {
			String[][] ret = new String[h][w];
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					ret[i][j] = scanner.next();
				}
			}
			return ret;
		}

		public String[][] nextStringArray(int h, int w, String split) {
			String[][] ret = new String[h][w];
			for (int i = 0; i < h; i++) {
				ret[i] = scanner.next().split(split);
			}
			return ret;
		}

		public void close() {
			scanner.close();
		}

	}

}


Measured memory_bytes: 64828
let () =
  let ns =
    let ss = (Str.split (Str.regexp " ") (read_line ())) in
    List.map int_of_string ss in
  let result = (match ns with
    | [a; b] when a > b -> "a > b"
    | [a; b] when a < b -> "a < b"
    | _  -> "a == b") in
  print_endline result

Measured memory_bytes: 2084
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> primeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)


vector<vll> s;
map<ll, bool> t;

void addPoint(ll r, vll& cnt) {
	t[r] = true;
	for (auto itr = s[r].begin(); itr != s[r].end(); itr++) {
		if (!t[*itr]) {
			cnt[*itr] += cnt[r];
			addPoint(*itr, cnt);
		}
	}
}

int main() {
	ll n, q,a,b,p,x;
	in(n);
	in(q);


	s.resize(n + 1);
	rep(i, 0, n - 1) {
		in(a);
		in(b);

		s[a].push_back(b);
		s[b].push_back(a);
	}


	vll cnt(n+1, 0);
	rep(i, 0, q) {
		in(p);
		in(x);

		cnt[p] += x;
	}

	addPoint(1,cnt);

	repeq(i, 1, n) {
		outn(cnt[i]);
	}

	return 0;

}


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

int main(){
    int n,m;
    cin >> n >> m;
    int h[n],p[n];
    for(int i = 1; i <= n; i++){
        cin >> h[i];
        p[i] = 0;
    }
    for(int i = 0; i < m; i++){
        int a,b;
        cin >> a >> b;
        p[a] = max(p[a],h[b]);
        p[b] = max(p[b],h[a]);
    }
    int count = 0;
    for(int i = 1; i <= n; i++){
        count += h[i] > p[i];
    }
    cout << count << endl;
    return 0;
}

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

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);
    long L = sc.nextInt();
    long R = sc.nextInt();
    sc.close();

    long min = 2019;

    for(int i = 0; i < 2019; i++){
      for(int j = i + 1; j < 2019; j++){
        long a = L + i;
        long b = L + j;
        if (a <= R && b <= R){
          long m = (a*b)%2019;
          if (m < min){
            min = m;
          }
        }
      }
    }

    System.out.println(min);

  }
  
}

Measured memory_bytes: 21716
package main

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

func main() {
	sc := NewScanner()

	n := sc.NextInt()
	T := sc.NextInt()
	min := 1 << 31
	for i := 0; i < n; i++ {
		c := sc.NextInt()
		t := sc.NextInt()
		if t <= T && c < min {
			min = c
		}
	}
	if min == 1<<31 {
		fmt.Printf("TLE\n") // output for debug
	} else {
		fmt.Printf("%v\n", min)
	}
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			result = append(result, v)
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	result = append(result, v)

	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


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

typedef long long ll;
typedef long double ld;

int main(){
    ios_base::sync_with_stdio(false);
    cout.precision(10);
    cout<<fixed;

    string s;
    cin >> s;
    int n = s.size();
    string t = "keyence+";
    int i;
    for(i=0; i<n; i++){
        if(s[i] != t[i]) break;
    }
    int j;
    reverse(s.begin(), s.end());
    t.pop_back();
    reverse(t.begin(), t.end());
    t += "+";
    for(j=0; j<n; j++){
        if(s[j] != t[j]) break;
    }
    if(i+j >= 7){
        cout << "YES";
    }
    else cout << "NO";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll n, m, x;
  cin >> n >> m >> x;
  vector<ll> c(n);
  vector<vector<ll>> a(n, vector<ll>(m));
  REP(i, n) {
    cin >> c[i];
    REP(j, m) { cin >> a[i][j]; }
  }

  const ll INF = 1e18;
  ll ans = INF;

  REP(bit, (1LL << n)) {
    ll t = 0;

    vector<ll> p(m, 0);
    REP(i, n) {
      if (bit & (1LL << i)) {
        t += c[i];
        REP(j, m) { p[j] += a[i][j]; }
      }
    }

    bool ok = true;
    REP(j, m) {
      if (p[j] < x) {
        ok = false;
      }
    }

    if (ok) {
      ans = min(ans, t);
    }
  }
  if (ans == INF) {
    ans = -1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3636
from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations

def main():
    N, X, T = map(int, input().split())

    if N % X == 0:
        print((N // X) * T)
    else:
        print((N // X + 1) * T)

if __name__ == '__main__':
    main()

Measured memory_bytes: 10336
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm> // sort
#include <map> // pair

typedef long long ll;
using namespace std;

int main(){
    int a,b,k;
    cin>>a>>b>>k;
    int cnt =0;
    for(int i=100;i>=1;i--){
        if(a%i==0&b%i==0){
            cnt++;
            if(cnt==k){
                cout<<i;
                break;
            }
        }
    }
    
}

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

using namespace std;

int main() {
	int n, m, c, i = 0;
	int h, w;
	string line;
	
	cin >> n >> m >> c;
	cin.ignore();

	int b[m];
	int a[n][m];

	for(int i=0; i<m; i++){
		cin >> b[i];
	}

	for(int i=0; i<n; i++){
		for(int j=0; j<m; j++){
			cin >> a[i][j];
		}
	}

	int count = 0;
	for(int i=0; i<n; i++){
		int tokucho = 0;
		for(int j=0; j<m; j++){
			tokucho += a[i][j] * b[j];
		}
		if (tokucho + c > 0) {
			count++;
		}
	}

	cout << count << '\n';
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define out(a) cout << a << endl
#define outa(a, n) rep(_, n) cout << a[_] << " "; cout << endl
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (auto& ai : a) cin >> ai;
    /*
    int c = 0;
    while (1) {
        int bc = c;
        rep3(i, 1, n) {
            if (a[i - 1] > a[i]) { swap(a[i - 1], a[i]); c++; }
        }
        if (c > 1) { out("NO"); return 0;}
        if (bc == c) break;
    }
    out("YES");
     */
    auto b = a;
    sort(all(b));
    int c = 0;
    rep(i, n) if (a[i] != b[i]) c++;
    if (c <= 2) out("YES");
    else out("NO");
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        int r=sc.nextInt();
        int ans;
        if(n<=10){
            ans=r+100*(10-n);
        }else{
            ans=r;
        }

        System.out.println(ans);
    }

}


Measured memory_bytes: 25172
#include <stdio.h>
#include <math.h>

int main(void) {
  double x1, x2, y1, y2;
  scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);

  printf("%f\n", sqrt(pow(x2-x1, 2) + pow(y2-y1, 2)));

  return 0;
}




Measured memory_bytes: 2116
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//BEGIN CUT HERE
template<typename T>
struct BellmanFord{
  struct edge{
    int u,v;
    T w;
    edge(){}
    edge(int u,int v,T w):u(u),v(v),w(w){}
  };

  int n;
  vector< vector<int> > G;
  vector<int> used,reach;
  BellmanFord(int n):n(n),G(n),used(n,0),reach(n,0){}

  vector<edge> es;
  void add_edge(int u,int v,T c){
    es.emplace_back(u,v,c);
    G[u].emplace_back(v);
  }

  void dfs(int v){
    if(used[v]) return;
    used[v]=1;
    for(int u:G[v]) dfs(u);
  }

  T build(int from,int to,int &neg_loop){
    for(int i=0;i<n;i++){
      fill(used.begin(),used.end(),0);
      dfs(i);
      reach[i]=used[to];
    }
    const T INF = numeric_limits<T>::max();
    vector<T> ds(n,INF);
    ds[from]=0;
    for(int j=0;j<n;j++){
      bool update=0;
      for(auto e:es){
        if(!reach[e.u]||!reach[e.v]||ds[e.u]==INF) continue;
        if(ds[e.v]>ds[e.u]+e.w){
          ds[e.v]=ds[e.u]+e.w;
          update=1;
        }
      }
      if(!update) break;
      if(j==n-1){
        neg_loop=1;
        return INF;
      }
    }
    neg_loop=0;
    return ds[to];
  }
};
//END CUT HERE
//INSERT ABOVE HERE

signed main(){
  int n,m,p;
  cin>>n>>m>>p;
  BellmanFord<int> G(n);
  for(int i=0;i<m;i++){
    int a,b,c;
    cin>>a>>b>>c;
    a--;b--;
    G.add_edge(a,b,p-c);
  }
  int neg_loop;
  int res=G.build(0,n-1,neg_loop);
  if(neg_loop){
    cout<<-1<<endl;
    return 0;
  }
  cout<<max(-res,0)<<endl;
  return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>

using namespace std;

#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define dump(x) cerr << #x << "=" << x << endl

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef vector<string> vs;

int main(void) {

    vi abc(3);
    rep(i, 3) cin >> abc[i];

    sort(all(abc));
    int dl = abc[2] - abc[0];
    int ds = abc[2] - abc[1];

    if(dl%2==0 && ds%2==0) {
        cout << dl/2 + ds/2 << endl;
    } else if(dl%2!=0 && ds%2!=0) {
        cout << dl/2 + ds/2 + 1 << endl;
    } else {
        cout << ds/2 + dl/2 + 2 << endl;
    }
}


Measured memory_bytes: 256
h, w = map(int, input().split())

if h == 1 or w == 1:
  a = 1

elif h % 2 == 1 and w % 2 == 1:
	a = int((h * w + 1) / 2) 
else:
	a = int(h * w / 2)
    
print(a)


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

using namespace std;

const int N = (int)1e5 + 5;

int n, k, q, a[N], cnt[N];

void init() {
  cin >> n >> k >> q;
  for(int i = 1 ; i <= q ; ++i) cin >> a[i];
}
void solve() {
  for(int i = 1 ; i <= q ; ++i) cnt[a[i]]++;
  for(int i = 1 ; i <= n ; ++i) {
    if(cnt[i] > q - k) cout << "Yes\n";
    else cout << "No\n";
  }
}

int main() {
  init();
  solve();
}


Measured memory_bytes: 1536
import java.util.Scanner;
        public class Main {
        	 public static void main(String args[]){
        	Scanner scanner = new Scanner(System.in);
        	
        	String a=scanner.next();
        	String b=scanner.next();
               int n=0;
        	// 変数strの長さ分回す
        	for (int i = 0; i < a.length(); i++) {
        	    // strの先頭から1文字ずつString型にして取り出す
        	    String str1 = String.valueOf(a.charAt(i));
        	    String str2 = String.valueOf(b.charAt(i));
        	    if(!(str1.equals(str2))){
        	    	n=n+1;
                }}
        	   System.out.println(n);
         
        	}
        }

Measured memory_bytes: 55736
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    public struct Connection
    {
        public List<int> connects;
        public int currentCount;
        public int myCount;
        public Connection(int index)
        {
            this.connects = new List<int>();
            this.currentCount = 0;
            this.myCount = 0;
        }
    }
    
    public static void Main()
    {
        var nq = Console.ReadLine().Split(' ').Select(x => Int32.Parse(x)).ToArray();
        var N = nq[0];
        var Q = nq[1];
        
        var connections = new Connection[N];
        for (int i = 0; i < N; ++i)
        {
            connections[i] = new Connection(i);
        }
        
        for (int i=0;i<N-1;++i)
        {
            var ab = Console.ReadLine().Split(' ').Select(x => Int32.Parse(x)).ToArray();
            connections[ab[0] - 1].connects.Add(ab[1]-1);
            connections[ab[1] - 1].connects.Add(ab[0]-1);
        }

        for (int i = 0; i < Q; ++i)
        {
            var pq = Console.ReadLine().Split(' ').Select(x => Int32.Parse(x)).ToArray();
            connections[pq[0] - 1].myCount += pq[1];
        }

        var hashSet = new HashSet<int>();
        Dfs(0,hashSet,connections, 0);

        for (int i=0;i<N;++i)
        {
            Console.Write($"{connections[i].currentCount} ");
        }
    }

    static void Dfs(int currentCount, HashSet<int>hashSet, Connection[] connection, int index)
    {
        hashSet.Add(index);
        currentCount += connection[index].myCount;
        connection[index].currentCount = currentCount;
        foreach (var l in connection[index].connects)
        {
            if (!hashSet.Contains(l)) Dfs(currentCount,hashSet, connection, l);
        }
    }
}


Measured memory_bytes: 71356
N,C = map(int,input().split())
s = [0]*N
t = [0]*N
c = [0]*N
for i in range(N):
    s[i],t[i],c[i] = map(int,input().split())
    c[i] -= 1
    
rec = [[0]*(30) for _ in range(10**5+1)]
for i in range(N):
    rec[t[i]][c[i]] -= 1
    
for i in range(N):
    if rec[s[i]][c[i]] != 0:
        rec[s[i]][c[i]] += 1                
    else:
        rec[s[i]-1][c[i]] += 1

simu = [[0]*(30) for _ in range(10**5+1)]
tmp = 0
for j in range(30):
    simu[0][j] += rec[0][j]
    tmp += simu[i][j]
ans = tmp
for i in range(1,10**5+1):
    tmp = 0
    for j in range(30):
        simu[i][j] += simu[i-1][j] + rec[i][j]
        tmp += simu[i][j]
    ans = max(ans,tmp)
print(ans)

    
    


Measured memory_bytes: 115800
#pragma GCC optimize("Ofast")

#include <iostream>
#include <vector>

int main()
{
  //Digit=log2_10^18=59.7...
  constexpr int Digit=60;
  
  uint64_t N,K;
  std::cin>>N>>K;
  
  std::vector<std::vector<uint64_t>> a(Digit,std::vector<uint64_t>(N,0));
  for(uint64_t i=0;i!=N;i++)
  {
    std::cin>>a[0][i];
  }
  
  for(uint64_t i=1;i!=Digit;i++)
  {    
    for(uint64_t j=0;j!=N;j++)
    {
      a[i][j]=a[i-1][a[i-1][j]-1];
    }
  }
  
  uint64_t pos=1;
  for(uint64_t i=0;i!=Digit;i++)
  {
    if(K&(1ull<<i))
    {
      pos=a[i][pos-1];
    }
  }
  
  std::cout<<pos<<std::endl;
  
  return 0;
}

Measured memory_bytes: 98580
q, h, s, d = map(int, input().split())
n = int(input())
l = [q,h,s,d]
up = sorted([(q, 1, 0), (h/2, 2,1), (s/4, 4, 2), (d/8, 8, 3)])

nq = n * 4
price = 0
for i, e in enumerate(up):
    if nq >= e[1]:
        nn, nq = divmod(nq, e[1])
        price += l[e[2]] * nn
print(int(price))

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<ll,ll> P;
#define M 998244353
#define F first
#define S second
#define PB push_back
#define INF 100000000000000000
ll ka[10000],in[10000];
ll pw(ll x,ll y){
	ll res=1;
	while(y){
		if(y&1)res=res*x%M;
		y>>=1;
		x=x*x%M;
	}
	return res;
}
ll cm(ll x,ll y){
	return ka[x]*in[x-y]%M*in[y]%M;
}
ll n,x,ans;
int main(void){
    cin>>n>>x;
    ka[0]=1,in[0]=1;
    for(ll i=1;i<=n;i++){
		ka[i]=ka[i-1]*i%M;
		in[i]=pw(ka[i],M-2);
	}
    for(ll i=0;i<=n;i++){
		for(ll j=0;j+i<=n;j++){
			ll s=i+j*2,a=(s-x+1)/2;
			if(i==0&&(s<x||x%2))ans=(ans+cm(n,j))%M;
			else if(s<x)ans=(ans+cm(n,i)*cm(n-i,j)%M)%M;
			else if(s%2!=x%2&&j>=a*2)ans=(ans+cm(i+j-a*2,i)*cm(n,i+j)%M)%M;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    ll N;
    cin >> N;
    ll ans;
    rep(0, i, N + 1)
    {
        if (i * i > N)
        {
            break;
        }
        ans = i * i;
    }

    cout << ans << endl;
}

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

struct L{
    int a,b,c;
    L(int a=0,int b=0,int c=0):a(a),b(b),c(c){}
};

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

int main(){
    int n,m;
    cin>>n>>m;
    map<int,int> mpx,mpy;
    mpx[0]=0;
    mpy[0]=0;
    vector<L> lh,lv;
    for(int i=0;i<n;i++){
        int a,b,c;
        cin>>a>>b>>c;
        mpx[a]=0;
        mpx[b]=0;
        mpy[c]=0;
        lh.emplace_back(a,b,c);
    }
    for(int i=0;i<m;i++){
        int a,b,c;
        cin>>a>>b>>c;
        mpx[a]=0;
        mpy[b]=0;
        mpy[c]=0;
        lv.emplace_back(a,b,c);
    }
    vector<int> xs,ys;
    for(auto &p:mpx){
        p.second=xs.size();
        xs.emplace_back(p.first);
    }
    for(auto &p:mpy){
        p.second=ys.size();
        ys.emplace_back(p.first);
    }

    int h=xs.size()*2;
    int w=ys.size()*2;

    vector<vector<int>> d(h,vector<int>(w));
    for(int i=0;i<n;i++){
        int a=mpx[lh[i].a]*2;
        int b=mpx[lh[i].b]*2;
        int c=mpy[lh[i].c]*2;
        for(int x=a;x<=b;x++){
            d[x][c]=-1;
        }
    }
    for(int i=0;i<m;i++){
        int a=mpx[lv[i].a]*2;
        int b=mpy[lv[i].b]*2;
        int c=mpy[lv[i].c]*2;
        for(int y=b;y<=c;y++){
            d[a][y]=-1;
        }
    }

    queue<pair<int,int>> q;
    int sx=mpx[0]*2;
    int sy=mpy[0]*2;
    d[sx][sy]=1;
    q.emplace(sx,sy);
    while(!q.empty()){
        auto fr=q.front();
        int x=fr.first;
        int y=fr.second;
        q.pop();
        for(int i=0;i<4;i++){
            int nx=x+dx[i];
            int ny=y+dy[i];
            if(nx<0||ny<0||h<=nx||w<=ny){
                continue;
            }
            if(d[nx][ny]!=0){
                continue;
            }
            d[nx][ny]=1;
            q.emplace(nx,ny);
        }
    }

    ll ans=0;
    for(int x=0;x<h;x++){
        for(int y=0;y<w;y++){
            if(d[x][y]!=1){
                continue;
            }
            if(x==0||x==h-1||y==0||y==w-1){
                cout<<"INF"<<endl;
                return 0;
            }
            if(x%2==0||y%2==0){
                continue;
            }
            ll dx=xs[x/2+1]-xs[x/2];
            ll dy=ys[y/2+1]-ys[y/2];
            ans+=dx*dy;
        }
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 144488
from collections import deque
N = int(input())
#隣接リスト
g = [[] for i in range(N)]
for i in range(N-1):
  u,v,w = map(int,input().split())
  g[u-1].append([v-1,w])
  g[v-1].append([u-1,w])
q = deque()
#通ったかどうか
check = [0] * N
check[0] = 1
q.append(0)
ans = [-1] * N
ans[0] = 0
while len(q) > 0:
  e = q.popleft()
  for i,j in g[e]:
    if check[i] == 1:
      continue
    ans[i] = (ans[e] + j) %2
    check[i] = 1
    q.append(i)
for i in range(N):
  print(ans[i])


Measured memory_bytes: 46740
#include <bits/stdc++.h>
using namespace std;
typedef  long long ll;
int mod = 1e9+7;


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

    int n;
    cin>>n;

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

    vector<vector<double>> dp(n+1, vector<double>(n+1));
    dp[0][0] = 1;
    for(int i=1; i<=n; i++){
    	for(int j=0; j<=n; j++){
    		if(!j){
    			dp[i][j]=dp[i-1][j]*(1-p[i-1]);
    			continue;
    		}
    		dp[i][j] = dp[i-1][j-1]*p[i-1] + dp[i-1][j]*(1-p[i-1]);
    	}
    }
    double ans=0;
    for(int i=n/2+1; i<=n; i++){
    	ans += dp[n][i];
    }

    cout<<setprecision(12)<<ans;
	return 0;
}		


Measured memory_bytes: 70784
/*#include <iostream>
#include<iomanip>
#include<math.h>
using namespace std;
int main() {
int n=1;
  while(n!=0){
    cin>>n;
    int s[n];
    double sum=0;
    for(int i=0;i<n;i++){
      cin>>s[i];
      sum+=s[i];
    }
    double m=0,a=0;
    m=sum/n;
    for(int i=0;i<n;i++)a+=(s[i]-m)*(s[i]-m)/n;
    cout<<setprecision(10);
    cout<<sqrt(a)<<endl;
  }//pow(s[i]-m,2)
  return 0;
}*/
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

int main(){
    int n;
    while(1){
        cin >> n;
        if(n==0) break;
        int a[n];
        for(int i=0;i<n;i++) cin >> a[i];
        double m = 0;
        for(int i=0;i<n;i++) m += a[i];
        m /= n;
        double b = 0;
        for(int i=0;i<n;i++) b += (a[i]-m)*(a[i]-m)/n;
        cout << setprecision(10);
        cout << sqrt(b) << endl;
    }
}

Measured memory_bytes: 1236
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<cstdlib>

using namespace std;

int main(void) {

	int a,b,c;
	cin>>a>>b>>c;
	if(a>=b)swap(a,b);

	if(c>=a&&c<=b)cout<<"Yes\n";
	else cout<<"No\n";

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		try (Scanner scan = new Scanner(System.in)) {
			int inputM = scan.nextInt();
			if (inputM < 4 ) {
             	 System.out.println("0");
				return;
            }
			int inputD = scan.nextInt();

			int ans = 0;
			int D1 = inputD / 10;
			int D2 = inputD % 10;
			for (int i = 2; i <= D1; i++) {
				if (i != D1) {
					if (inputM > i * 9) {
						ans += 9 - 1;
					} else {
						int calc = inputM / i;
						if (calc > 9)
							calc = 9;
						ans += calc - 1;
					}
				} else {
					if(D2 > 1) {
						if (inputM > i * D2) {
							ans += D2 - 1;
						} else {
							int calc = inputM / i;
							if (calc > D2)
								calc = D2;
							ans += calc - 1;
						}
					}
				}
			}
			System.out.println(ans);
		}
	}

}

Measured memory_bytes: 22612
#include <bits/stdc++.h>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define mset(x, y) memset(x, y, sizeof x)
#define mcpy(x, y) memcpy(x, y, sizeof x)
using namespace std;

typedef long long LL;
typedef pair <int, int> pii;

inline int Read()
{
	int x = 0, f = 1, c = getchar();
	for (; !isdigit(c); c = getchar())
		if (c == '-')
			f = -1;
	for (;  isdigit(c); c = getchar())
		x = x * 10 + c - '0';
	return x * f;
}

const int MAXN = 200005;

struct Node { int x, y, i; bool operator < (const Node &b) const { return x < b.x; } } e[MAXN];
int n, m, q, mn, mx, bas, tot, lst, cur = -1, ans[MAXN];

int main()
{
#ifdef wxh010910
	freopen("data.in", "r", stdin);
#endif
	mx = m = Read();
	n = Read();
	for (int i = 1; i <= n; i ++)
		e[++ tot] = {Read(), 0, 0};
	q = Read();
	for (int i = 1, t, a; i <= q; i ++)
		t = Read(), a = Read(), e[++ tot] = {t, a, i};
	sort(e + 1, e + tot + 1);
	for (int i = 1; i <= tot; i ++)
	{
		int delta = (e[i].x - lst) * cur;
		if (e[i].i)
		{
			int ret = e[i].y + bas;
			if (ret < mn)
				ret = mn;
			if (ret > mx)
				ret = mx;
			ret += delta;
			if (ret < 0)
				ret = 0;
			if (ret > m)
				ret = m;
			ans[e[i].i] = ret;
		}
		else
		{
			mn += delta, mx += delta, bas += delta, lst = e[i].x, cur = -cur;
			if (mn < 0)
				mn = 0;
			if (mx < 0)
				mx = 0;
			if (mn > m)
				mn = m;
			if (mx > m)
				mx = m;
		}
	}
	for (int i = 1; i <= q; i ++)
		printf("%d\n", ans[i]);
	return 0;
}


Measured memory_bytes: 3968
/*
@author: sharrad99
*/
#include<bits/stdc++.h>
using namespace std;
int main(){

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	long long n, p;
	string s;
	cin >> n >> p >> s;

	long long res = 0;
	reverse(s.begin(), s.end());
	if(p == 2 or p == 5) {
		for(long long i = 0; i < n; i++) {
			long long x = s[i] - '0';
			if(x % p == 0) {
				res += (n - i);
			}
		}

		cout << res << '\n';
		return 0;
	}

	vector<long long> c(p);
	c[0]++;
	long long f = 1, cur = 0;
	for(long long i = 0; i < n; i++) {
		long long x = s[i] - '0';
		(cur += (f * x)) %= p;
		(f *= 10) %= p;
		res += c[cur];
		c[cur]++; 
	}

	cout << res << '\n';
}

Measured memory_bytes: 720
import java.util.Scanner;

public class Main {
	void run() {
		Scanner sc = new Scanner(System.in);

		char[] c = sc.next().toCharArray();
		boolean f1 = c.length % 2 == 0 ? true : false;
		boolean f2 = c[0] != c[c.length - 1] ? true : false;

		if (f1 != f2) {
			System.out.println("First");
		} else {
			System.out.println("Second");
		}
	}

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


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

using namespace std;

typedef long long ll;

int main(){
  ll N, G[100][100];
  cin >> N;
  for(int i = 0 ; i < N ; i++){
    for(int j = 0 ; j < N ; j++){
      cin >> G[i][j];
    }
  }
  ll ans = 0;
  for(int i = 0 ; i < N ; i++){
    for(int j = 0 ; j < i ; j++){
      ans += min(G[i][j],G[j][i]);
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1232
r,c = (int(x) for x in input().split())
T = [input().split() for i in range(r)]

for i in range(r):
    rTotal = 0
    for j in range(c):
        rTotal += int(T[i][j])
    
    T[i].append(rTotal)

newT = []

for i in range(c):
    cTotal = 0
    for j in range(r):
        cTotal += int(T[j][i])
    
    newT.append(cTotal)

total = 0
for i in range(len(newT)):
    total += newT[i]

newT.append(total)
T.append(newT)

for i in range(r + 1):
    print(*T[i])


Measured memory_bytes: 6728
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <map>
#ifdef sahdsg
#define DBG(...) printf(__VA_ARGS__)
#else
#define DBG(...) (void)0
#endif // sahdsg
#define REP(r,x,y) for(register int r=(x); r<y; r++)
using namespace std;
typedef long long LL;
vector<int> a;
int st[107], stn=0;
int main()
{
	int n; scanf("%d", &n);
	REP(i,0,n) {
		int t;
		scanf("%d", &t);
		a.push_back(t);
	}
	for(int i=n;i>0;i--) {
		if(a[i-1]==i) {
			st[stn++]=i;
			a.erase(a.begin()+i-1);
			i=n--;
		}
	}
	DBG("%d\n", stn);
	if(a.empty()) {
		while(0<stn--) {
			printf("%d\n", st[stn]);
		}
	} else {
		puts("-1");
	}
}

Measured memory_bytes: 256
using System;

namespace Homework
{
    class Program
    {
        static void Main(string[] args)
        {
            var firstLine = Console.ReadLine().Split(' ');
            var vacationDays = int.Parse(firstLine[0]);
            var homeworkNum = int.Parse(firstLine[1]);

            var secondLine = Console.ReadLine().Split(' ');
            var span = 0;
            for (int h = 0; h < homeworkNum; h++) span += int.Parse(secondLine[h]);

            Console.WriteLine(vacationDays >= span ? vacationDays - span : -1);
        }
    }
}


Measured memory_bytes: 28568
s = list(input())
if (s[0]==s[1] and s[2]==s[3] and s[0]!=s[2]) or (s[0]==s[2] and s[1]==s[3] and s[0]!=s[1]) or (s[0]==s[3] and s[1]==s[2] and s[0]!=s[1]):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
makeFrame :: Int -> Int -> [String]
makeFrame h w = [[if (x + y) `mod` 2 == 0 then '#' else '.' | x <- [1..w]] | y <- [1..h]]

printFrame :: [String] -> IO ()
printFrame frame = mapM_ putStrLn frame

main :: IO ()
main = do
  input <- getLine
  let [h, w] = map read $ words input :: [Int]
  if h == 0 && w == 0
    then do return ()
    else do
    mapM_ putStrLn $ makeFrame h w
    putStrLn ""
    main

Measured memory_bytes: 4116
#pragma GCC optimize "-O3"
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <bitset>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <queue>

#define mp make_pair
#define pb push_back


typedef long long ll;
typedef long double ld;

using namespace std;
const int MAXN = 1000100;

multiset<int> ss;
char s[MAXN];
char t[MAXN];
int lst[MAXN][26];
int n;
vector<pair<int, int> > vv;

int main() {
	scanf("%d", &n);
	scanf(" %s %s", s, t);
	if (strcmp(s, t) == 0) {
		cout << 0 << "\n";
		return 0;
	}
	for (int i = 0; i < 26; ++i)
		lst[0][i] = -1;
	lst[0][s[0] - 'a'] = 0;
	for (int i = 1; i < n; ++i) {
		for (int j = 0; j < 26; ++j)
			lst[i][j] = lst[i - 1][j];
		lst[i][s[i] - 'a'] = i;
	}
	int pr = n;
	for (int i = n - 1; i >= 0; --i) {
		pr = min(pr, i);
		if (pr < 0) {
			cout << -1 << "\n";
			return 0;
		}
		if (i != 0 && t[i] == t[i - 1])
			continue;
		if (lst[pr][t[i] - 'a'] == -1) {
			cout << -1 << "\n";
			return 0;
		}
		vv.push_back(make_pair(lst[pr][t[i] - 'a'], i));
		pr = min(pr, lst[pr][t[i] - 'a'] - 1);
	}
	int ans = 0;
	int dd = 0;
	for (int i = 0; i < (int)vv.size(); ++i) {
		dd -= 1;
		int x = vv[i].first;
		int y = vv[i].second;
		ss.insert(x - dd);
		while (!ss.empty() && *ss.rbegin() + dd >= y)
			ss.erase(prev(ss.end()));
		ss.insert(y - dd);
		ans = max(ans, (int)ss.size());
	}
	cout << ans << "\n";
	return 0;
}




Measured memory_bytes: 158568
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
    int n,m,c;cin >> n >> m >> c;
    vector<vector<int>> a(n,vector<int> (m));
    vector<int> b(m);
    rep(i,m)cin >> b[i];
    rep(i,n)rep(j,m)cin >> a[i][j];
    int ret =0 ;
    rep(i,n){
        int tmp = c;
        rep(j,m){
            tmp += a[i][j]*b[j];
        }
        if(tmp > 0)ret++;
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 3556
#include<iostream>
using namespace std;
int main()
{
	long long a,b,c,k;
	cin>>a>>b>>c>>k;
	if(k<=a)
	 cout<<k<<endl;
	else
	{
		if(k<=a+b)
		 cout<<a<<endl;
		else
		 cout<<a-(k-a-b)<<endl;
	}
	return 0;
}

Measured memory_bytes: 3544
#include<bits/stdc++.h>
 #include <ext/pb_ds/tree_policy.hpp>
 #include <ext/pb_ds/assoc_container.hpp>
 #include<chrono>
 using namespace std;
 using namespace std::chrono;      
 using namespace __gnu_pbds; 
 #define fastio     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
 #define fi         first
 #define se         second
#define int         long long 
 #define pb         push_back
 #define emp        emplace_back
 #define vv(x)      vector<x>
 #define mp(x,y)    map<x,y>
 #define dq(x)      deque<x>
 #define pql(x)     priority_queue<x>
 #define pqs(x)     priority_queue<x,vv(x),greater<x> >
 #define M          1000000007
 #define forf(i,a,b) for(int i=a;i<b;i++)
 #define it(x)      x::iterator
 #define ll         long long 
 #define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
 #define time__(d)  for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false); debug("%s time : %.4fs", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
 #define vii        vector<int>
 #define big        1e18
 #define sm         -2e9
 #define mkr        make_pair
 #define vpi        vector<pair<int,int> >
 #define pii        pair<int,int>
 #define rng        500005
 #define sz(x)      (int)x.size()
 #define rv(x)      reverse(x.begin(),x.end())
 #define out(x)     cout<<x.fi<<" "<<x.se<<endl;

//#define ordered_set tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update> 
  
void pr_init()
{
   
    #ifndef ONLINE_JUDGE
    freopen("gin.txt", "r", stdin);
    freopen("gout.txt", "w", stdout);
   
    #endif
}



int ispal(string s,int a,int b)
{
    int  l = b-a+1;
    
    for(int i=0;i<l/2;i++)
    {
        if(s[i]!=s[l-i-1]) return 0;
    }
    return 1;
}
void solve()
{
  
  int l;
  cin >> l;

  double len = l/3.0;
  
  printf("%0.10f\n",len*len*len);
}


int32_t main()
{
  pr_init();
  fastio;
  
  auto start = high_resolution_clock::now(); 
 
  solve();
  auto stop = high_resolution_clock::now();
  auto duration = duration_cast<microseconds>(stop - start); 
   // cout << "Time taken by function: "
   //       << duration.count() << " microseconds" << endl; 

 }
      
      

Measured memory_bytes: 3688
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>

using namespace std;

int main(){
	long long n, ans = 0;
	cin >> n;
	vector<long long> a(n), d(n);
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	long long k = accumulate(begin(a), end(a), 0LL), m = n * (n + 1) / 2;
	if(k % m != 0){
		cout << "NO" << endl;
		return 0;
	}
	k /= m;
	bool f = true;
	for(int i = 0; i < n; i++){
		d[i] = a[(i + 1) % n] - a[i] - k;
		if(d[i] % n != 0 || d[i] > 0){
			f = false;
			break;
		}
	}
	cout << (f? "YES":"NO") << endl;
	return 0;
}

Measured memory_bytes: 1792
function main()
	N=parse(Int,readline())
	A=map(x->parse(Int,x),split(readline()))
	S=sum(A)
	B=zeros(Int,N)
	for i=1:N
		B[i]=A[mod1(i+1,N)]-A[i]
	end
	all=div((N+1)*N,2)
	if S%all!=0
		println("NO")
		exit()
	end
	K=div(S,all)
	for i=1:N
		B[i]-=K
		if B[i]>0||B[i]%N!=0
			println("NO")
			exit()
		end
	end
	println("YES")
end
main()


Measured memory_bytes: 128732
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  char c;
  cin >> c;
  if (c == 'A') cout << 'T' << endl;
  else if (c == 'T') cout << 'A' << endl;
  else if (c == 'C') cout << 'G' << endl;
  else cout << 'C' << endl;
}

Measured memory_bytes: 256
#ifndef YK_INCLUDE
#include <bits/stdc++.h>
#endif //! YK_INCLUDE
int main() {
    std::cin.tie(nullptr); std::ios::sync_with_stdio(false);
    
    int N,K;
    std::cin >> N >> K;
    std::string S;
    std::cin >> S;
    
    S[K-1]=std::tolower(S[K-1]);
    
    std::cout << S << std::endl;
}

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

using namespace std;

const int N = 1e5+10, K = 110;

long long int dp[K][N] ,pr[N], mod = 1e9+7;

long long int ok(long long int &x) {
    x%=mod;
    x+=mod;
    x%=mod;
}

int main () {
    long long int n, k;
    cin >> n >> k;
    dp[0][0]=1;
    fill(pr,pr+N-5,1);
    pr[0]=0;
    for(int i = 0 ; i < n ; i++ ) {
        long long int x;
        cin >> x;
        for(int j = k ; j >= 0 ; j--) {
            dp[i+1][j]=pr[j+1]-pr[max(j-x,0ll)];
            ok(dp[i+1][j]);
        }
        for(int j = 0 ; j <= k + 1 ; j++ ) {
            pr[j]=(j==0)?0:pr[j-1]+dp[i+1][j-1];
            ok(pr[j]);
        }
    }
    cout << dp[n][k] << '\n';
}


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

int main() {
	// your code goes here
    string s, t;
    cin >> s >> t;
    int ans = INT_MAX;
    for (int i = 0; i <= s.length() - t.length();i++) {
        string temp = s.substr(i, t.length());
        //cout << temp << endl;
        int count = 0;
        for (int j = 0; j < temp.length();j++) {
            if (temp[j] != t[j]) {
                count++;
            }
        }
        ans = min (ans,count);
    }
    cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3604
from collections import Counter
num = int(input())
def pr(n):
   a = []
   while n % 2 == 0:
        a.append(2)
        n //= 2
   f = 3
   while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
   if n != 1:
      a.append(n)
   return a
if num == 1:
   print(0)
   quit()
prm = Counter(pr(num)).items()
ans = 0
for el,nm in prm:
   x = 1
   while True:
      if nm >= x:
         nm -= x
         ans += 1
         x += 1
      else:
         break
print(ans)

Measured memory_bytes: 9404
#include <stdio.h>
#include <math.h>

void swap(int *, int *);

int main(){
  int x, y, i, r, gcd;

  while(1){
  scanf("%d%d",&x, &y);
  if(x >= 1 && x <= pow(10,9) && y >= 1 && y <= pow(10,9)) break;
  }

  if(x < y) swap(&x,&y);
  while(y > 0){
    r = x % y;
    x = y;
    y = r;
  }

  printf("%d\n",x);
  return 0;
}

void swap(int *x, int *y){
  int a;
  a = *x;
  *x = *y;
  *y = a;
}

Measured memory_bytes: 592
import java.util.*;

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

        int sum = 0;
        int sumB = 0;
        int cnt = 0;

        while(sc.hasNextLine()){
            String[] s = sc.nextLine().split(",");
            int a = Integer.parseInt(s[0]);
            int b = Integer.parseInt(s[1]);

            sum += a * b;
            sumB += b;
            cnt++;
        }

        System.out.println(sum);
        System.out.println((int)Math.round((double)sumB / cnt));
    }
}

Measured memory_bytes: 12000
import Data.List
main = do
  getLine
  input <- map read . lines <$> getContents :: IO [Int]
  let score = sum input
      notMod10 = filter ((/=0) . flip mod 10) $ sort input
  if mod score 10 == 0 then if length notMod10 == 0
                              then print 0
                              else print $ score - (head notMod10)
                       else print score


Measured memory_bytes: 892
n = gets.to_i
arr = gets.split.map(&:to_i)
j = 't'
r = 0
b = 2
while j == 't'
  cnt = 0
  arr.each do |x|
    cnt += 1 if (x % b).zero?
  end
  if cnt == n
    b *= 2
    r += 1
  else
    j = 'f'
  end
end
p r

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    string s; cin >> s;
    int n = s.size();

    int s1 = 0;
    int s0 = 0;

    rep(i,n){
        if(s[i] == '0') s0++;
        else s1++;
    }

    int ans = 2*min(s1,s0);

    dunk(ans);
}

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



int main()
{
	int n;
	cin >> n;
	string s;
	cin >> s;
	s="0"+s+"0";
	int tmp=0;
	int mae[500010]={};
	reps(i, n)
	{
		if(s[i]=='1' && tmp==0) tmp=i, mae[i]=i;
		else if(s[i]=='1') mae[i]=tmp;
		if(s[i+1]=='0' && tmp!=0) tmp=0;
	}
	int dp[500010];
	dp[0]=0;
	reps(i, n)
	{
		dp[i]=dp[i-1];
		if(s[i]=='1' && s[i-1]=='0')
		{
			if(i-2>=0 && s[i-2]=='1')
			{
				dp[i]=max(dp[i], dp[mae[i-2]-1]+i-1-(mae[i-2]));
				if(mae[i-2]!=i-2) dp[i]=max(dp[i], dp[mae[i-2]]+i-2-(mae[i-2]));
			}
		}
		else if(s[i]=='1')
		{
			if(mae[i]-2>=0 && s[mae[i]-2]=='1')
			{
				dp[i]=max(dp[i], dp[mae[i]-3]+i-(mae[i]-1));
			}
		}
	}
	cout << dp[n] << endl;
	return 0;
}

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

int main() {
  ll int a;
  string s;
  cin >> a >> s;
  rep(i, 4) {
    if(s[i] == '.') s.erase(i, 1);
  }
  int b = stoi(s);
  
  cout << a * b / 100 << endl;
//  cout << s << endl;
  
  
  return 0;
}


Measured memory_bytes: 3592
#atcoder template
def main():
    import sys
    imput = sys.stdin.readline
    #文字列入力の時は上記はerrorとなる。
    #ここにコード
    #input
    n = int(input())

    #output
    while n > 0:
        n -= 1000

    print(-n)

    #N = 1のときなどcorner caseを確認！
if __name__ == "__main__":
    main()

Measured memory_bytes: 9160
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b , a % b);
}

ll mod(ll a){
  return (a % 1000000007);
}

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


int main(){
  ll a,b,x; cin >> a >> b >> x; ll ans = b/x - (a-1)/x;
  
  if(a == 0 && x != 1) ans++;
  
  cout << ans << endl;
  
}

Measured memory_bytes: 256
t=[int(input()) for _ in range(5)]
s=[]
for i in range(5):
    s.append(t[i]%10)
    t[i]=-(-t[i]//10)*10
S=sorted(s)[-5+s.count(0)]
if S==0:
    print(sum(t))
else:print(sum(t)-10+S)

Measured memory_bytes: 3060
Imports System.Collections.Generic
Imports System.Console

Module Program
    Sub Main()
        Dim A As Integer = NextInt()
        Dim B As Integer = NextInt()
        Dim S As String = ReadLine()
        Dim flg As Boolean
        Dim i As Integer

        For Each c As Char In S
            If i = A Then
                If c <> "-"c Then flg = True
            Else
                If c = "-"c Then flg = True
            End If
            i += 1
        Next

        WriteLine(New String() {"Yes", "No"}(B2I(flg)))
    End Sub

    Function B2I(ok As Boolean) As Integer
        If ok Then Return 1
        Return 0
    End Function

    Function NextInt() As Integer
        Return CInt(NextString())
    End Function

    Function NextString() As String
        Dim result As New List(Of Char)
        Do
            Dim tmp As Integer = Read()
            If tmp < 0 Then Exit Do
            Dim nextChar As Char = Chr(tmp)

            If Not Char.IsWhiteSpace(nextChar) Then
                result.Add(nextChar)
            ElseIf nextChar <> vbCr Then
                Exit Do
            End If
        Loop
        Return New String(result.ToArray())
    End Function

End Module


Measured memory_bytes: 20432
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <string>
#include <queue>
#include <numeric>
#include <ctype.h>
#include <limits>
#include <iomanip>

#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

typedef long long ll;

int main() {
	string s;
	cin >> s;
	bool ok = true;
	rep(i, 3) {
		if (s[i + 1] == s[i])ok = false;
	}
	if (ok)cout << "Good";
	else cout << "Bad";
	return 0;
}

Measured memory_bytes: 256