akhauriyash/Code-Regression huggingface dataset:
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
 
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
 
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
 
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

// -----------------------------------------------------------------------------
// main
// -----------------------------------------------------------------------------
use std::collections::HashMap;
fn main(){
    input!{
        n: usize,
        m: usize,
        a: [usize; n]
    }
    let mut ans:usize = 0;
    let mut sa = vec![0;n+1];
    for i in 0..n{
        sa[i+1] = (sa[i]+a[i])%m;
    }
    let mut map = HashMap::new();
    for x in sa{
        *map.entry(x).or_insert(0) += 1;
    }
    for (_k,v) in map{
        ans += (v*(v-1))/2;
    }
    println!("{}", ans);
}



Measured memory_bytes: 14588
#include<stdio.h>

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

   if(a>b) swap(&a, &b);
   if(b>c) swap(&b, &c);
   if(a>b) swap(&a, &b);

   printf("%d %d %d\n", a, b, c);
   return 0;
}

int swap(int *a, int*b){
   int x = *a;
   int y = *b;
   *a = y;
   *b = x;
   return 0;
}

Measured memory_bytes: 596
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e5 + 10;

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n, k;
	cin >> n >> k;
	if (n % k) puts("1");
	else puts("0");
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
#include <cstdio>
#include <stack>
#include <numeric>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)

int main(){
    ll k,a,b;
    cin >> k >> a >> b;
    if(b-a>=3){
        if(k<=a-1){
            cout << k+1 << endl;
        }else{
            ll ans = 0;
            ans = a;
            k -= a-1;
            ans += (b-a)*(k/2);
            if(k%2==1)ans++;
            cout << ans << endl;
        }
    }else{
        cout << k+1 << endl;
    }

    return 0;
}

Measured memory_bytes: 888
def like2017(x):
  if isprime[x]:
    if isprime[(x+1)//2]:
      return True
  return False

n=108000
isprime=[True]*(n+1)
isprime[0]=isprime[1]=False
for i in range(2,n+1):
  if isprime[i]:
    for j in range(i*i,n+1,i):
      isprime[j]=False
cum=[]
cum.append(like2017(0))
for i in range(1,n+1):
  tmp=0
  if isprime[i]:
    if isprime[(i+1)//2]:
      tmp=1
  cum.append(cum[-1]+tmp)
#print(cum)
q=int(input())
for _ in range(q):
  l,r=map(int,input().split())
  print(cum[r]-cum[l-1])
  

Measured memory_bytes: 82920
from random import shuffle
from collections import Counter
def inpl(): return list(map(int, input().split()))

#N = 20000
#P = list(range(1, N+1))
#shuffle(P)

N = int(input())
P = inpl()

A = [0]*N
B = [0]*N
S = [10**9 - N] * (N)
for i, p in enumerate(P):
    S[p-1] += i

A[0] = 1
B[0] = S[0] - 1

for i in range(1, N):
    A[i] = max(A[i-1] + 1, S[i] - B[i-1] + 1)
    B[i] = S[i] - A[i]

for i in range(N-1):
    assert A[i] < A[i+1]
    assert B[i] > B[i+1]

assert B[-1] > 0
print(*A)
print(*B)


Measured memory_bytes: 46980
#include<bits/stdc++.h>
using namespace std;
int q[1000][1000];
int main(){
int a,b;
  int c[1000000]={};
  int d,e;
  cin>>a>>b;
  for(int i=0;i<b;i++){
    cin>>d>>e;
    c[d]++,c[e]++;
  }
  for(int i=1;i<=a;i++){
    cout<<c[i]<<"\n";
  }
}


Measured memory_bytes: 4096
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
 
        //input
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int sum = 100000;
        for(int i=0;i<N;i++){
            sum *= 1.05;
            if(sum%1000 != 0){sum += 1000 - sum % 1000;}
        }
         
         //output
        System.out.println(sum);
    }
}

Measured memory_bytes: 25956
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
        int P[] = new int[N];
        for(int i = 0; i < N; ++i){
            P[i] = sc.nextInt();
        }
        int count = 0;
        for(int i = 0; i < N-2; ++i){
            if(P[i] < P[i+1] && P[i+1] < P[i+2] || P[i] > P[i+1] && P[i+1] > P[i+2]){
             count += 1;   
            }
        }
        System.out.println(count);
	}
}
        

Measured memory_bytes: 35684
#include <bits/stdc++.h>
using namespace std;
const int maxn=100000+9;
int ans[maxn];
bool minimize(int &a,int b){return (a>b)?(a=b,1):0;}
int main(){
	vector<int> p;
	for(int t=6;t<=maxn;t*=6)p.push_back(t);
	for(int t=9;t<=maxn;t*=9)p.push_back(t);
	p.push_back(1);
	sort(p.begin(),p.end());
	int n;cin>>n;
	ans[0]=0;
	for(int m=1;m<=n;++m){
		ans[m]=n;
		for(int i=0;i<p.size();++i){
			if(p[i]>m)break;
			minimize(ans[m],ans[m-p[i]]+1);
		}
	}
	cout<<ans[n];
	return 0;
}


Measured memory_bytes: 640
#!/usr/bin/env python3
import sys


def solve(N: int, A: "List[List[int]]"):
    import numpy as np
    from scipy.sparse.csgraph import floyd_warshall
    A = np.array(A, dtype=np.float64)
    B = floyd_warshall(A, directed=True)
    if not np.array_equal(A, B):
        return -1
    delta = 1e-1
    _, pre = floyd_warshall(A-delta+np.identity(N)*delta, return_predecessors=True)
    return int(A[pre == [[i]*N for i in range(N)]].sum()) // 2

# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [[int(next(tokens)) for _ in range(N)] for _ in range(N)]  # type: "List[List[int]]"
    print(solve(N, A))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//const ull mod = 1e9 + 7;
const ll mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

// debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

// conversion number to bit
string num2bit(ll num, ll len){
  string bit = "";
  REP(i, len){
    bit += char('0'+(num>>i & 1));
  }
  return bit;
}

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

    //cout << "enumerate permutation: " << endl;
	//vector<ll> perm2 = {0, 1, 2, 3};
    ll N;
    cin >> N;
    vector<ll> x(N), y(N);
    REP(i, N) cin >> x[i] >> y[i];

	vector<ll> perm2(N);
	REP(i, N) perm2[i] = i;
	bool flag = true;
	ll cnt = 0;
	double res = 0.0;
	while(flag){
		//vprint(perm2);
		flag= next_permutation(perm2.begin(), perm2.end());
		//cout << perm2 << endl;
		REP(idx, N-1){
			ll i = perm2[idx];
			ll j = perm2[idx+1];
			res += sqrt((x[j] - x[i])*(x[j] - x[i]) + (y[j] - y[i])*(y[j] - y[i]));
		}
		cnt++;
	}
	//dump(cnt)
	printf("%.10f\n", res/cnt);
    return 0;
}

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

int main(){
	int t,n,max,min,i,j,mae,ato;
	
	scanf("%d",&t);
	
	for(i=0;i<t;i++){
		scanf("%d",&n);
		max=0;
		min=0;
		scanf("%d",&mae);
		for(j=1;j<n;j++){
			scanf("%d",&ato);
			if(ato-mae>max)max=ato-mae;
			if(mae-ato>min)min=mae-ato;
			mae=ato;
		}
		printf("%d %d\n",max,min);
	}
	return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<math.h>
using namespace std;
 
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl
 
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
 
int N,key,j;
 
int main(){
    cin>>N;
    int A[N];
    rep(i,N){
        cin>>A[i];
        if(i>0)cout<<" ";
        cout<<A[i];
    }
    cout<<endl;
    repi(i,1,N){
        key=A[i];
        j=i-1;
        while(j>=0&&A[j]>key){
            A[j+1]=A[j];
            j--;
        }
        A[j+1]=key;
        rep(k,N){
            if(k>0)cout<<" ";
            cout<<A[k];
        }
        cout<<endl;
    }
}


Measured memory_bytes: 3132
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
int main(void){
    double a,l,x;
    double h,s;
    while(cin>>a>>l>>x){
        s=sqrt(a*a*(double)l*(double)l/4.0-a*a*a*a/16.0);
        h=sqrt(pow((l+x)/2.0,2)-l*l/4.0);
        s+=h*l;
        printf("%.10f\n",s);
    }
}

Measured memory_bytes: 3060
#include <stdio.h>

int sum[2][105];
int main () {
	int r,c;
	scanf("%d%d",&r,&c);
	int x[c+1][r+1];
	for (int i=0;i<=r;i++){
		for (int j=0;j<=c;j++){
			if (i!=r){
				if (i!=r && j!=c) scanf("%d",&x[j][r]);
				sum[0][i]+=x[j][r];
				sum[1][j]+=x[j][r];
				if (j==c) {
					printf("%d\n",sum[0][i]);
					sum[1][c]+=sum[0][i];
				}
				else printf("%d ",x[j][r]);
			}
			if (i==r) {
				if (j!=c)
				printf ("%d ",sum[1][j]);
				if (j==c)
				printf ("%d",sum[1][j]);
			}
		}
	}
	printf("\n");
}



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

#define PI 3.14159265359
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descsort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;

int main(void)
{
    string  s;
    cin>>s;
    bool can=false;
    rep(i,0,s.size()){
        if(s[i]=='C')can=true;
        if(s[i]=='F' && can==true){cout<<"Yes"<<endl;return 0;}
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3624
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
#define mem(a,v) memset((a), (v), sizeof (a))
#define enl printf("\n")
#define case(t) printf("Case #%d: ", (t))
#define ni(n) scanf("%d", &(n))
#define nl(n) scanf("%lld", &(n))
#define nai(a, n) for (int i = 0; i < (n); i++) ni(a[i])
#define nal(a, n) for (int i = 0; i < (n); i++) nl(a[i])
#define pri(n) printf("%d\n", (n))
#define prl(n) printf("%lld\n", (n))
#define pii pair<int, int>
#define pil pair<int, long long>
#define pll pair<long long, long long>
#define vii vector<pii>
#define vil vector<pil>
#define vll vector<pll>
#define vi vector<int>
#define vl vector<long long>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef cc_hash_table<int,int,hash<int>> ht;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;
const double pi = acos(-1);
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const int MAXN = 1e6 + 5;
const double eps = 1e-9;
int a[MAXN];

int main() {
	int n; ni(n); nai(a, n);
	ll sm = 0;
	for (int i = 0; i < n; i++) sm += (ll) a[i];
	ll k = ((ll)n*(ll)(n+1)) / 2ll;
	if (sm % k != 0) return !printf("NO\n");
	k = sm / k;
	for (int i = 0; i < n; i++)
		if (k - (a[(i+1)%n] - a[i]) < 0 || (k - (a[(i+1)%n] - a[i])) % n != 0)
			return !printf("NO\n");
	printf("YES\n");
	return 0;
}


Measured memory_bytes: 640
(defun solve (K lst)
  (loop for x in (cons 0 (mapcar #'- (nthcdr K lst) lst))
        with y = (loop for x in lst for i below K sum x)
        maximize (incf y x)))

(let ((N (read))
      (K (read)))
     (format t "~F" (solve K (loop repeat N collect (/ (1+ (read)) 2)))))

Measured memory_bytes: 67940
import java.util.Scanner;


public class Main {
	  
	public static void main(String args[]) {
		    Scanner scanner = new Scanner(System.in);
		    
		    int S = scanner.nextInt();
		    if(S < 1200)
		    {
		    	System.out.println("ABC");
		    }
		    else if(1200 <= S && S < 2800)
		    {
		    	System.out.println("ARC");
		    }
		    else 
		    {
		    	System.out.println("AGC");
		    }
		    scanner.close();}
		  }

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

int main() {
  int n,q; cin >> n;
  long S[n]; for (int i =0; i<n; i++) cin >> S[i];
  cin >> q;
  long T[q]; for (int i =0; i<q; i++) cin >> T[i];
  
  int C =0;
  for (int i =0; i<q; i++) {
    long x = T[i];
    long maxS = n, minS = 0;
    while (maxS - minS > 1) {
      long midS = (maxS + minS) / 2;
      if (x < S[midS]) {
        maxS = midS;
      } else {
        minS = midS;
      }
    }
    if (S[minS] == x) C++;
  }
  cout << C << endl;
}


Measured memory_bytes: 4276
// 2020-09-21 02:34:14
// clang-format off
#include <bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }
// #include <atcoder/convolution>
// #include <atcoder/dsu>
// #include <atcoder/fenwicktree>
// #include <atcoder/lazysegtree>
// #include <atcoder/math>
// #include <atcoder/maxflow>
// #include <atcoder/mincostflow>
// #include <atcoder/modint>
// #include <atcoder/scc>
// #include <atcoder/segtree>
// #include <atcoder/string>
// #include <atcoder/twosat>
// #include <atcoder/all>
// using namespace atcoder;

// clang-format on
void answer() {
  int n;
  cin >> n;
  vector<int> mpx(n), ans(n);
  vector<P> p;
  rep(i, n) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    mpx[x] = i;
    p.emplace_back(P(x, y));
  }
  sort(ALL(p));
  int miny = n, cx = -1;
  for (auto [x, y] : p) {
    chmin(miny, y);
    if (n - miny - 1 == x) {
      REPC(xi, cx + 1, x) ans[mpx[xi]] = x - cx;
      cx = x;
    }
  }
  rep(i, n) cout << ans[i] << '\n';
}

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 6868
from collections import deque

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

edges = [[] for _ in range(N)]

for _ in range(M):
    fr, to = map(int, input().split())
    fr -= 1
    to -= 1
    edges[fr].append(to)

for start in range(N):
    st = deque([(start, True)])
    L = deque()
    V = set()

    while st:
        now, isFirst = st.pop()
        if isFirst:
            L.append(now)

            if now in V:
                break

            V.add(now)

            st.append((now, False))

            for to in edges[now]:
                st.append((to, True))
        else:
            L.pop()
            V.remove(now)
    else:
        continue

    loopStart = L.pop()
    while L[0] != loopStart:
        L.popleft()

    ans = []
    K = len(L)
    for i, now in enumerate(L):
        for to in edges[now]:
            if i + 1 >= K or to == L[i + 1]:
                ans.append(now + 1)
                break
        else:
            break
    else:
        print(0)
        print()
        # print(len(ans))
        # print(*ans, sep='\n')
        exit()

print(-1)

Measured memory_bytes: 3572
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder.Contest.A
{
	static class Program
	{
		public static void Main(string[] args)
		{
			var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
			Console.SetOut(sw);

			var cin = new Scanner();

            for (int i = 0; i < 5; i++)
            {
				int x = cin.NextInt();
                if (x == 0) Console.WriteLine(i + 1);
            }

			Console.Out.Flush();
		}
	}

	class Scanner
	{
		string[] s;
		int i;

		char[] cs = new char[] { ' ' };

		public Scanner()
		{
			s = new string[0];
			i = 0;
		}

		public string Next()
		{
			if (i < s.Length) return s[i++];
			string st = Console.ReadLine();
			while (st == "") st = Console.ReadLine();
			s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
			if (s.Length == 0) return Next();
			i = 0;
			return s[i++];
		}

		public int NextInt()
		{
			return int.Parse(Next());
		}

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = NextInt() + add;
			}
			return Array;
		}

		public long NextLong()
		{
			return long.Parse(Next());
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = NextLong() + add;
			}
			return Array;
		}

		public double NextDouble()
		{
			return double.Parse(Next());
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = NextDouble() + add;
			}
			return Array;
		}
	}
}

Measured memory_bytes: 27548
def solve(string):
    n, m, q, *lrpq = map(int, string.split())
    lr, pq = lrpq[:2 * m], lrpq[2 * m:]
    t = [[0] * (n + 1) for _ in range(n + 1)]
    for l, r in zip(lr[::2], lr[1::2]):
        t[l][r] += 1
    for i in range(n + 1):
        for j in range(n + 1):
            if j > 0:
                t[i][j] += t[i][j - 1]
    for i in range(n + 1):
        for j in range(n + 1):
            if i > 0:
                t[i][j] += t[i - 1][j]

    ans = [
        str(t[q][q] - t[p - 1][q] - t[q][p - 1] + t[p - 1][p - 1])
        for p, q in zip(pq[::2], pq[1::2])
    ]
    return "\n".join(ans)


if __name__ == '__main__':
    n, m, q = map(int, input().split())
    print(solve('{} {} {}\n'.format(n, m, q) + '\n'.join([input() for _ in range(m + q)])))


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

// 全探索

int main() {
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  
  bool can = false;
  for (int i = 0; i <= k; i++) {
    for (int j = 0; j <= k; j++) {
      for (int l = 0; l <= k; l++) {
        int x = a * (1 << i);  // 2のi乗
        int y = b * (1 << j);  // 2のj乗
        int z = c * (1 << l);  // 2のl乗
        if (i + j + l <= k and x < y and y < z) can = true;
      }
    }
  }
  
  cout << (can ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3652
S=input()

m_len=0
len=0

acgt={'A','C','G','T'}

for i in S:
    if i in acgt:
        len+=1
        #print(i,len)
    else:
        #print(i,len,m_len)
        if len>m_len:
            m_len=len
        len=0
        
if len>m_len:
    m_len=len

print(m_len)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 4005

int N,L,R;
int table[NUM];

void func(){

	for(int i = 1; i <= N; i++){
		scanf("%d",&table[i]);
	}

	int ans = 0;
	int min_index;

	for(int x = L; x <= R; x++){

		min_index = BIG_NUM;

		for(int i = 1; i <= N; i++){
			if(x%table[i]== 0){
				min_index = i;
				break;
			}
		}

		if(min_index != BIG_NUM){

			if(min_index%2 == 1)ans++;

		}else{

			if(N%2 == 0)ans++;
		}
	}
	printf("%d\n",ans);
}

int main(){

	while(true){
		scanf("%d %d %d",&N,&L,&R);
		if(N == 0 && L == 0 && R == 0)break;

		func();
	}

	return 0;
}



Measured memory_bytes: 3188
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN+1];
int head , tail, n;

void enqueue(P x){
  Q[tail] = x;
  if(tail == n){
    tail =0;
  }else{
    tail++;
  }


}

P dequeue(){
  P y;
  y = Q[head];
  if(head == n){
    head = 0;
  }else{
    head++;
  }
  return y;

}

int empty(){
  if(head == tail){
    return 0;
  }else{
    return 1;
  }
}



int main(){
  int elaps = 0, c=0;
  int i, q;
  P u;
  scanf("%d %d", &n, &q);

  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }

  head = 1;
tail = 0;
  while(c<n){
   P u = dequeue();
    if(u.t > q){
       elaps += q;
      u.t -= q;
      enqueue(u);
     
    }else{
      elaps += u.t;
      printf("%s %d\n",u.name, elaps);
      c++;
    }
  }
  
  
  return 0;
}



Measured memory_bytes: 6864
s = input()
diff_01, diff_10 = 0, 0
for i in range(len(s)):
    if i % 2 == 0:
        if s[i] == '0':
            diff_10 += 1
        else:
            diff_01 += 1
    if i % 2 == 1:
        if s[i] == '0':
            diff_01 += 1
        else:
            diff_10 += 1
print(min(diff_01, diff_10))

Measured memory_bytes: 3188
n, x = map(int,input().split())
a = list(map(int,input().split()))
a_min = [0] * n

if a[0] > x:
    a_min[0] = x
else:
    a_min[0] = a[0]

ans = a[0] - a_min[0]

for i in range(n - 1):
    if a_min[i] + a[i + 1] > x:
        a_min[i + 1] = x - a_min[i]
    else:
        a_min[i + 1] = a[i + 1]
    ans += (a[i + 1] - a_min[i + 1])

print(ans)


Measured memory_bytes: 63984
K = int(input())
N=50

ans=[N-1]*N

d = K//N
r = K%N
for i in range(N):
    ans[i] += N*d-d*(N-1)

for i in range(r):
    ans[i] += N-(r-1)
for i in range(r,N):
    ans[i] -=r
print(N)
print(" ".join(map(str,ans)))


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

#define INC(i, a, b) for(int i = a; i < b; ++i)
#define DEC(i, a, b) for(int i = a; i >= b; --i)
#define REP(i, n) INC(i, 0, n)

typedef unsigned int uint;
typedef unsigned long ul;
typedef long long  ll;
typedef unsigned long long ull;

void TFprint(bool b, std::string T, std::string F){
    if(b){
        std::cout << T;
    }else{
        std::cout << F;
    }
}

int main(){
    int n; std::cin >> n;
    ull a[n];
    ull b[n];

    REP(i, n){
        std::cin >> a[i];
        std::cin >> b[i];
    }

    ull count = 0;

    DEC(i, n - 1, 0){
        a[i] += count;
        ull goal = a[i] / b[i];
        if(a[i] % b[i] > 0){
            goal++;
        }
            
        count += goal * b[i] - a[i];
    }

    std::cout << count << std::endl;
    return 0;
}

Measured memory_bytes: 1792
#greedy customers
N=int(input())
ans=0
d=[int(input()) for _ in range(N)]
if d[0]>1:
    ans+=d[0]-1
d[0]=1
now=2
for i in range(1,N):
    if d[i]==now:
        now+=1
    else:
        #d[i]!=now:
        if d[i]<now:
            pass
        elif d[i]>now:
            if d[i]%now==0:
                K=d[i]//now
                if K==2:
                    ans+=1
                    d[i]=1
                elif K>2:
                    ans+=K-1
                    d[i]=1                
            elif d[i]%now!=0:
                u,v=divmod(d[i],now)
                ans+=u
                d[i]=v
print(ans)                   

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

using namespace std;

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

    int n, h, w;
    cin >> n >> w >> h;
    int tate[200010] = {0}, yoko[200010] = {0};
    for (int i = 0; i < n; i++)
    {
        int x, y, wi;
        cin >> x >> y >> wi;
        tate[max(y - wi, 0)]++;
        tate[min(h, y + wi)]--;
        //cout<<max(y-wi,0)<<" "<<min(h,y+wi)<<endl;
        yoko[max(x - wi, 0)]++;
        yoko[min(w, x + wi)]--;
    }
    for (int i = 1; i < w; i++)
        yoko[i] += yoko[i - 1];
    for (int i = 1; i < h; i++)
        tate[i] += tate[i - 1];
    //cout<<yoko[50000]<<endl;
    bool flag1 = true, flag2 = true;
    for (int i = 0; i < w; i++)
        if (yoko[i] == 0)
            flag1 = false;
    for (int i = 0; i < h; i++)
        if (tate[i] == 0)
            flag2 = false;
    if (flag1 || flag2)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


Measured memory_bytes: 4768
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
//絶対値
long long int change_plus(long long int a) {
	if (a < 0) { return -a; }
	if (a >= 0) { return a; }
}
//大小比較(大)
long long int big(long long int a, long long int b) {
	if (a >= b) {
		return a;
	}
	else {
		return b;
	}
}

//大小比較(小)
long long int small(long long int a, long long int b) {
	if (a >= b) {
		return b;
	}
	else {
		return a;
	}
}

int main() {
	long long int n, m, k = 0;
	char str[15],str2[15],str3[15];
	scanf("%s%s%s",str,str2,str3);
	if (str[strlen(str)-1]== str2[0] && str2[strlen(str2) - 1] == str3[0]) { printf("YES"); return 0; }
	
	printf("NO");
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<cmath>
#include<math.h>
//#include<array>
#include<algorithm>
#include<queue>
#include<deque>
#include<vector>
//#include<utility>
//#include<set>
#include<map>
//#include<list>
//#include<bitset>
//#include<iomanip>

using namespace std;
using LLI = long long int;
LLI N;

//配列,座標
/*array<int, 8>dir_x = { 0,0,1,1,1,-1,-1,-1 };
array<int, 8>dir_y = { 1,-1,1,0,-1,1,0,-1 };
array<int, 4>dir_x2 = { 0,0,1,-1 };
array<int, 4>dir_y2 = { 1,-1,0,0 };
char alp[] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };*/

//Union Find
class UnionFind {
public:
	vector<int>data;
	UnionFind(int size) :data(size, -1) {};
	bool unionset(int x, int y) {
		x = root(x), y = root(y);
		if (x != y) {
			if (data[y] < data[x]) {
				swap(x, y);
			}
			data[x] += data[y];
			data[y] = x;
		}
		return x != y;
	}
	bool findset(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

//最大公約数,最小公倍数
/*LLI gcd(LLI x, LLI y) {
	LLI  r;
	if (x < y) {
		swap(x, y);
	}
	r = x % y;
	while (r != 0) {
		x = y;
		y = r;
		r = x % y;
	}
	return y;
}
LLI lcm(LLI x, LLI y) {
	return x / gcd(x, y) * y;
}*/

//組み合わせ
/*long nCr(int n, int r) {
	long ans = 1;
	for (int i = n; i > n - r; i--) {
		ans = ans * i;
	}
	for (int i = 1; i < r + 1; i++) {
		ans = ans / i;
	}
	return ans;
}
long nHr(int n, int r) {
	n = n + r - 1;
	return nCr(n, r);
}*/

//素数判定
/*bool IsPrime(int num)
{
	if (num < 2) return false;
	else 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;
}*/

//桁数
/*LLI GetDigit(LLI num) {
	LLI digit = 0;
	while (num != 0) {
		num /= 10;
		digit++;
	}
	return digit;
}*/

//サンプル
/*const int n_max = 8;
array<array<bool, n_max>, n_max>graph;
int dfs(int v,int N,array<bool,n_max>visited) {
	int ret = 0;
	bool all_visited = true;
	for (int i = 0; i < N;i++) {
		if (visited[i] == false) {
			all_visited = false;
		}
	}
	if (all_visited) {
		return 1;
	}
	for (int i = 0; i < N;i++) {
		if (graph[v][i] == false) {
			continue;
		}
		if (visited[i] == true) {
			continue;
		}
		visited[i] = true;
		ret += dfs(i,N,visited);
		visited[i] = false;
	}
	return ret;
}*/

//サンプル
/*vector<vector<int>>sub;
int dfs(int id) {
	if (sub[id].size() == 0) {
		return 1;
	}
	int minP = (int)1e9;
	int maxP = 0;
	for (int i : sub[id]) {
		int P = dfs(i);
		minP = min(minP, P);
		maxP = max(maxP, P);
	}
	return minP + maxP + 1;
}*/

//#define debug(x) cerr << #x << " : " << x << endl
//#define debugv(x) cerr << #x << " : "; for(auto i:x) cerr << i << ", "; cerr<<endl
//cout << "Yes" << endl;
//cout << "No" << endl;



int main(void) {
	double a;
	cin >> a;
	cout << (2 * a) * 3.1415926 << endl;
}

Measured memory_bytes: 3236
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)x.size())
#define FOR(i,a,b) for (int i=a;i<=b;++i)
#define FORD(i,a,b) for (int i=a;i>=b;--i)
using namespace std;
typedef long long LL;
typedef pair<int,int> pa;
typedef vector<int> vec;
void getint(int &v){
    char ch,fu=0;
    for(ch='*'; (ch<'0'||ch>'9')&&ch!='-'; ch=getchar());
    if(ch=='-') fu=1, ch=getchar();
    for(v=0; ch>='0'&&ch<='9'; ch=getchar()) v=v*10+ch-'0';
    if(fu) v=-v;
}
int n,a[1000010],las[1000010],stk[1000010],top,ap[1000010],nxt[1000010],tp[1000010],v[1000010],now;
LL k,cir,hang;
int main(){
	cin>>n>>k;
	FOR(i,1,n) getint(a[i]);
	FOR(i,n+1,n*3) a[i]=a[i-n];
	FORD(i,n*3,n+2){
		las[a[i]]=i;
	}
	FORD(i,n,1){
		nxt[i]=(las[a[i+1]]-1)%n+1,tp[i]=(las[a[i+1]]-1)/n;
		las[a[i+1]]=i+1;
	}
	memset(v,-1,sizeof(v));
	now=n;
	hang=0;
	while (1){
		if (v[now]!=-1){
			cir=hang-v[now];
			hang+=(k-hang)/cir*cir;
			break;
		}
		v[now]=hang;
		if (hang+tp[now]<=k){
			hang+=tp[now];
			now=nxt[now];
		}
		else break;
	}
	while (1){
		if (hang+tp[now]<=k){
			hang+=tp[now];
			now=nxt[now];
		}
		else break;
	}
	while (1){
		++now;
		if (now>n){now=1;++hang;}
		if (hang>k) break;
		if (ap[a[now]]){
			while (stk[top]!=a[now]){
				ap[stk[top]]=0;
				--top;
			}
			--top;
			ap[a[now]]=0;
		}
		else stk[++top]=a[now],ap[a[now]]=1;
	}
	FOR(i,1,top) cout<<stk[i]<<' ';
	return 0;
}

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

#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()
#define INT_MAX_HALF (INT_MAX / 2)
#define EPS (1e-10)

using namespace std;
typedef long long ll;

int main(){

    int n, m;
    cin >> n >> m;

    int sum = 0;

    rep(i, m){
        int tmp;
        cin >> tmp;

        sum += tmp;
    }

    if(sum > n){
        cout << -1 << endl;
    }else{
        cout << n - sum << endl;
    }
    
    return 0;
}


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

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

  cout << ans << endl;
}

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

int main(int argc, char const *argv[])
{
	long long a,b,c,x,y;
	cin>>a>>b>>c>>x>>y;
	long long ans=1000000000000000LL;
	for (long long i = 0; i <= max(x,y)*2LL; i+=2LL)
	{
		long long nans=i*c;
		nans+=max(0LL,x-i/2LL)*a;
		nans+=max(0LL,y-i/2LL)*b;
		ans=min(ans,nans);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;
int main(void){
    int n, k, ans = 0;
    vector<int> v;
    cin >> n >> k;
    v.assign(n, 0);
    
    for(int i = 0; i < n; i++) {
        cin >> v[i];
    }
    
    for(int left = 0; left <= n; left++){
        for(int right = 0; left + right <= n && left + right <= k; right++) {
            vector<int> w;
            int sum = 0;
            
            for(int i = 0; i < left; i++){
                w.push_back(v[i]);
                sum += v[i];
            }
            
            for(int i = 0; i < right; i++){
                w.push_back(v[n-1-i]);
                sum += v[n-1-i];
            }
            
            sort(w.begin(), w.end());
            ans = max(ans, sum);
            for(int i = 0; i < w.size() && i < k-right-left; i++){
                sum -= w[i];
                ans = max(ans, sum);
            }
        }
    }
    cout << ans << endl;
}

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

lint mod = 1e+9 + 7;
int n;
vector<lint> a;

//素因数分解unordered_map版　O(√n)
template <typename T>
unordered_map<T, T> pf_um(T n) {
    unordered_map<T, T> res;
    for (long long int i = 2; i * i <= n; i++)
        while (n % i == 0) {
            res[i]++;
            n /= i;
        }
    if (n != 1) res[n]++;
    return res;
}

// a^n mod pを計算　O(log n)
long long pow_mod(long long a, long long n, long long p) {
    if (n == 0) return 1;
    if (n & 1) return pow_mod(a, n - 1, p) * a % p;
    long long temp = pow_mod(a, n / 2, p);
    return temp * temp % p;
}

// Z_pでのaの逆元を計算 O(log p)
// depend:pow_mod
long long inv_mod(long long a, long long p) {
    return pow_mod(a, p - 2, p);
}

int main() {
    cin >> n;
    a.resize(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    unordered_map<lint, lint> lcm;
    for (int i = 0; i < n; i++) {
        unordered_map<lint, lint> pf = pf_um(a[i]);
        for (auto e : pf) {
            if (lcm[e.first] < e.second) {
                lcm[e.first] = e.second;
            }
        }
    }
    lint l = 1;
    for (auto e : lcm) {
        l = l * pow_mod(e.first, e.second, mod) % mod;
    }
    lint ans = 0;
    for (int i = 0; i < n; i++) {
        lint temp = l * inv_mod(a[i], mod);
        ans = (ans + temp) % mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 768
#include <stdio.h>
 
int main()
{
  int n,sum=0;
  scanf("%d",&n);
  int p[n],i;
  for(i=0;i<n;++i)
       scanf("%d",&p[i]);
  
  int j,temp;
  for(i=0;i<n;++i) 
  {
    for(j=i+1;j<n;++j) 
    {
      if(p[i]>p[j])
      {
        temp=p[i];
        p[i]=p[j];
        p[j]=temp;
      }
    }
  }
  
  for(i=0;i<n-1;++i)
      sum+=p[i];
  
  sum+=p[n-1]/2;
  
  printf("%d",sum);
}
  

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
using namespace std;
vector<long long>ans;
long long snum(long long x)
{
	long long s=0;
	while (x) s+=x%10,x/=10;
	return s;
}
double f(long long x)
{
	return (double)x/(double)snum(x);
}
bool check(long long x)
{
	if (x<10000 || x>10000000000ll) return false;
	while (x%10==0) x/=10;
	if (x==1) return true;
	return false; 
}
int main()
{
	vector<long long> ans;
	long long stp=1;
	for (long long i=1;i<=1e15;i+=stp)
	{
		long long tm=1;
		if (check(i+1ll)) stp=(i+1ll)/10;
		long long tmp=i;
		while (tmp%10==9) tmp/=10,tm*=10;
		if (f(i)<=f(i+tm)) ans.push_back(i);
	}
	int k;
	scanf("%d",&k);
	for (int i=0;i<k;i++)
		printf("%lld\n",ans[i]);
	return 0;
}


Measured memory_bytes: 256
from collections import defaultdict

n = int(input())
ds = map(int, input().strip().split())
m = int(input())
ts = map(int, input().strip().split())

prepared = defaultdict(int)

for d in ds:
    prepared[d] += 1

for t in ts:
    if prepared[t] > 0:
        prepared[t] -= 1
    else:
        print('NO')
        exit(0)

print('YES')


Measured memory_bytes: 59484
/*
   Author : Vikram Singh
   Problem : knapsack 1

*/

#include<bits/stdc++.h>

using namespace std;

#define int long long

const int MAX = (long long)(1e5) + 11;
int dp[MAX];

signed main(){
    int n, need;
    cin >> n >> need;

    pair<int, int> p[n];
    for(int i = 0; i < n; i++){
        cin >> p[i].first >> p[i].second;
    }

    int fill = -1 * (long long)(1e18);
    for(int i = 0; i <= need; ++i) dp[i] = fill;

    dp[0] = 0;
    int res = 0;
    for(int i = 0; i < n; i++){
    	for(int j = need; j >= p[i].first; j--){
    		dp[j] = max(p[i].second + dp[j - p[i].first], dp[j]);
    	}
    }
    
    for(int i = 0; i <= need; i++) res = max(res, dp[i]);
    cout << res;
    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<cstdio>
#include<algorithm>
using namespace std;

int main() {
  int N;
  scanf("%d", &N);
  int a[N];
  for (int i=0 ; i<N ; i++) scanf("%d", &a[i]);
  sort(a, a+N);
  int res = 0;
  int cnt = 1;
  for (int i=1 ; i<N ; i++) {
    if (a[i] != a[i-1]) {
      if (a[i-1] < cnt) res += cnt - a[i-1];
      else if (a[i-1] > cnt) res += cnt;
      cnt = 1;
    } else {
      cnt++;
    }
  }
  if (a[N-1] < cnt) res += cnt - a[N-1];
  else if (a[N-1] > cnt) res += cnt;
  printf("%d\n", res);
}

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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef unsigned long long llu;

#define author ayushtomar
#define rf freopen("in.txt", "r", stdin)
#define wf freopen("out.txt", "w", stdout)
#define debug(x) cerr<<#x<<" "<<x<<endl;
#define f first
#define mp make_pair
#define pb push_back
int A[1<<21],L[1<<21],R[1<<21];
stack < int  > S;
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&A[i]);
    S.push(1);
    L[1]=1;
    for(int i=2;i<=n;i++)
    {
        while(S.size() && A[i]<A[S.top()])
        {
            S.pop();
        }
        L[i]=(S.size())? S.top()+1 : 1;
        S.push(i);
    }
    while(S.size())S.pop();
    S.push(1);
    for(int i=2;i<=n;i++)
    {
        while(S.size()&& A[i]<A[S.top()])
        {
            R[S.top()]=i-1;
            S.pop();
        }
        S.push(i);
    }
    while(S.size())
    {
        R[S.top()]=n;
        S.pop();
    }
    ll ans=0;
    for(int i=1;i<=n;i++)
{
    ll tot=(i-L[i]+1);
    tot=tot*1LL * (R[i]-i+1);
    ans= ans+A[i]*tot;
}
cout<<ans<<"\n";




 return 0;
}


Measured memory_bytes: 3128
coin_500 = int(input())
coin_100 = int(input())
coin_50 = int(input())
total = int(input())

counter = 0

for count_500 in range(coin_500 + 1):
    for count_100 in range(coin_100 + 1):
        for count_50 in range(coin_50 + 1):
            if count_500 * 500 + count_100 * 100 + count_50 * 50 == total:
                counter += 1

print(counter)


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

int main() {

  string S;
  cin >> S;
  int N;
  N = S.size();
  int ans = 0;
  for (int i = 0; i <= N / 2 - 1; i++) {
    if (S.at(i) != S.at(N - i - 1)) {
      ans++;
    }
  }
  cout << ans << endl;

}


Measured memory_bytes: 256
using System;
using System.Linq;

class Problem {
    static int Euclid(int a, int b) {
        var r = a % b;
        while (r != 0) {
            a = b;
            b = r;
            r = a % b;
        }
        return b;
    }
    public static void Main() {
        var data = Console.ReadLine().Split().Select(int.Parse).ToArray();
        Console.WriteLine(Euclid(data[0], data[1]));
    }
}


Measured memory_bytes: 9540
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define INSEG(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(false);
        cout << setprecision(15) << fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int N, M;
    cin >> N >> M;
    string S;
    cin >> S;
    vector<vector<int>> g(N);
    vector<int> scnt(N), ocnt(N);
    REP(i, M) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        g[a].pb(b);
        g[b].pb(a);
    }
    REP(v, N) {
        FORE(w, g[v]) {
            if (S[v] != S[w]) ocnt[v]++;
            else scnt[v]++;
        }
    }
    
    vector<bool> alive(N, true);
    queue<int> q;
    REP(v, N) {
        if (ocnt[v] < 1 || scnt[v] < 1) {
            q.push(v);
            alive[v] = false;
        }
    }
    while (!q.empty()) {
        int v = q.front(); q.pop();
        FORE(w, g[v]) {
            if (!alive[w]) continue;

            if (S[w] != S[v]) ocnt[w]--;
            else scnt[w]--;
            
            if (ocnt[w] < 1 || scnt[w] < 1) {
                alive[w] = false;
                q.push(w);
            }
        }
    }

    bool ans = false;
    REP(i, N) {
        ans |= alive[i];
    }
    cout << (ans ? "Yes" : "No") << endl;
    return (0^_^0);
}



Measured memory_bytes: 15568
#include <iostream>

using namespace std;

long long dp0[2005][2005];
long long dp1[2005][2005];

int main(int argc, char *argv[])
{
	int N, M;
	int S[2005], T[2005];
	long long mod = 1000000007;

	cin >> N >> M;
	for (int i = 0; i < N; i++) {
		cin >> S[i];
	}
	for (int i = 0; i < M; i++) {
		cin >> T[i];
	}

	dp0[0][0] = 1;
	for (int i = 0; i < N + 1; i++) {
		for (int j = 0; j < M + 1; j++) {
			(dp0[i + 1][j] += dp0[i][j] % mod) %= mod;
			(dp1[i][j] += dp0[i][j] % mod) %= mod;
			(dp1[i][j + 1] += dp1[i][j] % mod) %= mod;
			if (S[i] == T[j]) {
				(dp0[i + 1][j + 1] += dp1[i][j] % mod) %= mod;
			}
		}
	}
	cout << dp1[N][M] << endl;

	return 0;
}

Measured memory_bytes: 62976
//#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 rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    vs c(3);
    rep(i, 3) cin >> c[i];
    rep(i, 3) cout << c[i][i];
    cout << endl;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define rep(i, n) REP(i, 0, n)
#define REP(i, l, r) for (int i = l; i < r; ++i)
#define int long long
#ifdef DEBUG
#define dout cout
#else
std::stringstream dout;
#endif
using namespace std;
typedef pair<int, int> P;
struct edge {
  int to, cost;
};
// other libs
int gcd(int a, int b) {
  if (a % b == 0)
    return b;
  else
    return gcd(b, a % b);
}
int lcm(int a, int b) {
  return a * b / gcd(a, b);
}

class dijkstra {
private:
  int V;
  int d[100002];
  priority_queue<P, vector<P>, greater<>> que;

public:
  dijkstra(int v, int s, vector<edge> G[]) {
    V = v;
    update(s, G);
  }

  void update(int s, vector<edge> G[]) {
    fill(d, d + V + 1, 100000000000ll);
    d[s] = 0;
    que.push(make_pair(0, s));
    while (!que.empty()) {
      P p = que.top();
      que.pop();
      int v = p.second;
      if (d[v] < p.first)
        continue;
      rep(i, G[v].size()) {
        edge e = G[v][i];
        if (d[e.to] > d[v] + e.cost) {
          d[e.to] = d[v] + e.cost;
          que.push(make_pair(d[e.to], e.to));
        }
      }
    }
  }

  int find(int e) {
    return d[e];
  }
};
template<typename T>
class Union_Find {
private:
  vector<T> t, s;

public:
  Union_Find(T max_length) {
    rep(i, max_length + 1) {
      t.push_back(i);
      s.push_back(1);
    }
  }

  void Union(T x, T y) {
    if (same(x, y))
      return;
    T tx = Find(x), ty = Find(y);
    if (s[tx] < s[ty]) {
      s[ty] += s[tx];
      t[tx] = ty;
    }
    else if (s[tx] > s[ty]) {
      s[tx] += s[ty];
      t[ty] = tx;
    }
    else if (tx > ty) {
      t[tx] = ty;
      s[ty] += s[tx];
    }
    else {
      t[ty] = tx;
      s[tx] += s[ty];
    }
  }
  T Find(T n) {
    if (t[n] == n)
      return n;
    else
      return t[n] = Find(t[n]);
  }

  bool same(T x, T y) {
    return Find(x) == Find(y);
  }

  T get_Size(size_t a) {
    return s[a];
  }
};
bool ifPrime(int n) {
  if (n == 1)
    return false;
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0)
      return false;
  }
  return true;
}

set<int> prime_num_factor(int n){
  if(n<2)return set<int>();
  set<int> prime;
  prime.insert(2);
  for(int i=3;i<=n;i++){
    for(int it:prime){
      if(it*it>i){
        prime.insert(i);
        break;
      }
      if(i%it==0)break;
    }
  }
  return prime;
}
vector<int> makeDivisors(int n){
  vector<int> re;
  REP(i,1,sqrt(n)+1){
    if(n%i==0){
      re.push_back(i);
      if(i!=n/i)re.push_back(n/i);
    }
  }
  return re;
}
int modPow(int a,int n,int mod){
  int ret=1;
  while(n){
    if(n&1)ret=ret*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return ret;
}
signed main(signed argc, char* argv[]) {
  int n;
  cin>>n;
  vector<int> d(n,0);
  int mx=0;
  rep(i,n){
    int in;
    cin>>in;
    if(i==0&&in>0){
      cout<<0<<endl;
      return 0;
    }
    d[in]++;
    mx=max(in,mx);
  }

  if(d[0]>1){
    cout<<0<<endl;
    return 0;
  }
  int ans=1;
  REP(i,1,mx+1){
    int a=modPow(d[i-1],d[i],998244353);
    ans=ans*a%998244353;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 1024