akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
// #include <boost/multiprecision/cpp_int.hpp> 

#define gc getchar//_unlocked
#define pc putchar//_unlocked
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define pp pair<int,int>
#define ppl pair<ll,ll>
#define bigint boost::multiprecision::cpp_int
#define finp ios_base::sync_with_stdio(0);cin.tie(0);
#define bc __builtin_popcountll
#define afor(i,a,b) for(int i=a;i<=b;++i)
#define bfor(i,a,b) for(int i=a;i>=b;--i)
#define vi vector<int>
#define vpp vector<pp>
#define vll vector<ll>
#define fr first
#define se second

using namespace std;
using namespace __gnu_pbds;

char putnb[20];
void putn(ll n) {if(!n)pc('0');if(n<0)pc('-'),n=0-n;int pi=0;while(n)putnb[pi++]=(n%10)+'0',n/=10;while(pi)pc(putnb[--pi]);}
void sci(int *x) {register char c = gc();*x = 0;for(; (c<48)||(c>57);c = gc());for(; (c>47)&&(c<58);c = gc())*x = (int)((((*x)<<1) + ((*x)<<3)) + c - 48);}
void scll(ll *x)  {register char c = gc();*x = 0;for(; (c<48)||(c>57);c = gc());for(; (c>47)&&(c<58);c = gc())*x =  (ll)((((*x)<<1) + ((*x)<<3)) + c - 48);}
ll fp(ll a,ll b,ll c) {if(b==0)return 1%c; if(b==1)return a%c; ll ret=fp(a,b/2,c); ret=(ret*ret)%c; if(b&1)ret=(ret*a)%c; return ret;}

const ll mod=1e9 +7;
const ll mod2=1999999973;
const ll inf=1e18;
const int infs=1e9 + 1000;
const int N=100000;
const long double PI = acos(-1);

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;



int main()
{
  finp;

  ld ans;
  ll n,m,d;
  cin>>n>>m>>d;

  ans = (n - d)*(m - 1);
  if(d)ans*=2;
  ans/= n;
  ans/= n;

  cout<<fixed<<setprecision(9)<<ans;

  
return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main() { Models.GetInstance.Run(); }
    }

    public class Models
    {
        static Models instance = new Models();
        private Models() { }

        public static Models GetInstance
            {get{return instance;} }

        public void Run()
        {
            int counter = 0;
            string[] input = Console.ReadLine().Split(' ');
            int k = int.Parse(input[0]);
            int s = int.Parse(input[1]);
            
            for (int i = 0; i <= k; i++)
            {

                for (int j = 0; j <= k; j++)
                {
                    if (i + j > s) continue;
                    if (s - i - j > k) continue;
                    counter++;

                }
            }
            Console.WriteLine(counter);
            ;


        }

    }
    
}


Measured memory_bytes: 11092
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();

            string input;

            while (!string.IsNullOrEmpty(input = Console.ReadLine()))
            {
                int d = int.Parse(input);

                int sum = 0;
                int len = 600 / d;

                for (int i = 1; i < len; i++)
                    sum += d * i * d * i * d;

                sb.AppendLine(sum.ToString());
            }
            Console.Write(sb);
        }
    }
}

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

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

    char a;
    cin>>a;
    if((int)a>=65 && (int)a<=90)
        cout<<"A";
    else
        cout<<"a";
}


Measured memory_bytes: 3612
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

//// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.txt"


int main() {
	int a, b, c;
	while (cin>>a>>b>>c) {
		int num = 0;
		for (int i = 1; i <= 10; ++i) {
			if (i != a&&i != b&&i != c) {
				int sum = a + b + i;
				if (sum <= 20)num++;
			}
		}
		if (num >=4)cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 3084
// B - Varied
#include <bits/stdc++.h>
using namespace std;

int main(){
	string s; cin>>s;
	for(int i=0; i<s.size()-1; ++i){
		for(int j=i+1; j<s.size(); ++j){
			if(s[i]==s[j]){
				puts("no");
				return 0;
			}
		}
	}
	puts("yes");
}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////

ll X;
ll i, j;
int main(){
    scanf("%lld",&X);
    ll a = X / 100;
    ll b = X % 100;
    if(b/5+(b%5!=0)<=a){
        printf("1");
    }else
    {
        printf("0");
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>
#include <string.h>
#include <string>

using namespace std;

int A;
int B;
int K;

int main()
{
        scanf("%d%d%d\n",&A,&B,&K);
        

        for (int i = 0; i < K; i++)
        {
            if (i%2==0)
            {
                if (A%2==1)
                {
                    A-=1;

                }
                A/=2;
                B+=A;

            }
            else{
                if (B%2==1)
                {
                    B-=1;

                }
                B/=2;
                A+=B;
            }


        }

        printf("%d %d\n",A,B );


}


Measured memory_bytes: 256
import collections
import itertools
import sys


def getint(): return int(input())
def getints(): return list(map(int, input().split()))

s = input()
k = getint() - 1

t = list(itertools.takewhile(lambda s: s == '1', s))

if len(t) > k:
    print(1)
else:
    i = len(t)
    print(s[i])


Measured memory_bytes: 3316
N, A, B = list(map(int, input().split()))
length = set()

def dp(n, cur):
    if n == 1:
        return 

if N == 1:
    if A == B:
        print(1)
    else:
        print(0)
else:
    if A > B:
        print(0)
    else:
        print( (B-A)*(N-2)+1 )
        

Measured memory_bytes: 2940
a=[list(map(int,input().split())) for _ in range(3)]
n=int(input())
b=[int(input()) for _ in range(n)]
atari=[]

for i in range(3):
    atari.append([a[i][0],a[i][1],a[i][2]])
for i in range(3):
    atari.append([a[0][i],a[1][i],a[2][i]])
    
atari.append([a[0][0],a[1][1],a[2][2]])
atari.append([a[0][2],a[1][1],a[2][0]])

for k in range(len(atari)):
    if len(list(set(atari[k]) & set(b)))==3:
        print("Yes")
        break
else:
    print("No")

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


def solve(N: int, M: int, V: int, P: int, A: "List[int]"):
    P -= 1
    A = sorted(A, reverse=True)

    result = 0

    cumsum = [0 for i in range(N+1)]
    for n in range(N-1):
        cumsum[n+1] = A[n] + cumsum[n]

    for n in range(N):
        if n < P:
            result += 1
        elif A[n] + M < A[P]:
            continue
        else:
            affords = M * V - M - M * (P-1)
            if affords <= 0:
                result += 1
                continue
            
            sunmmation = A[n] * (n-P) + M * (n-P) - (cumsum[n] - cumsum[P])
            affords -= sunmmation
            affords -= (N-n) * M

            if affords <= 0:
                result += 1
                continue
    print(result)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
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
    M = int(next(tokens))  # type: int
    V = int(next(tokens))  # type: int
    P = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, M, V, P, A)

if __name__ == '__main__':
    main()


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

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(a) (a).begin(), (a).end()

#define INF 1000000000

using namespace std;

class UnionFind {
   public:
    UnionFind(int n) : parent_(n), rank_(n) {
        for (int i = 0; i < n; ++i) {
            parent_[i] = i;
            rank_[i] = 0;
        }
    }

    int find(int x) {
        if (parent_[x] == x)
            return x;
        else
            return parent_[x] = find(parent_[x]);
    }

    void unite(int x, int y) {
        x = find(x);
        y = find(y);

        if (x == y) return;

        if (rank_[x] < rank_[y]) {
            parent_[x] = y;
        } else {
            parent_[y] = x;
            if (rank_[x] == rank_[y]) rank_[x]++;
        }
    }

    bool same(int x, int y) { return find(x) == find(y); }

    vector<int> parent_, rank_;
};

int main() {
    int N, M;
    cin >> N >> M;

    UnionFind uf(N);

    REP(i, M) {
        int x, y, z;
        cin >> x >> y >> z;
        x--;
        y--;

        uf.unite(x, y);
    }

    std::vector<int> classes;

    REP(i, N)
    classes.push_back(uf.find(i));

    sort(ALL(classes));
    classes.erase(unique(ALL(classes)), classes.end());

    cout << classes.size() << endl;

    return 0;
}


Measured memory_bytes: 1660
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int H = sc.nextInt();
    int W = sc.nextInt();
    boolean[][] table = new boolean[H][W];
    int[][] table2 = new int[H][W];
    for(int i = 0; i < table.length; i++){
      String str = sc.next();
      Arrays.fill(table2[i], -1);
      for(int j = 0; j < str.length(); j++){
        table[i][j] = (str.charAt(j) == '#') ? true : false;
      }
    }
    System.out.println(solve(table, table2));
  }
  
  public static long solve(boolean[][] table, int[][] table2){
    int count = 0;
    for(int i = 0; i < table.length; i++){
      for(int j = 0; j < table[i].length; j++){
        if(table2[i][j] == -1){
          saiki(table, table2, i, j, count);
          count++;
        }
      }
    }
    int[][] counts = new int[count+1][2];
    
    for(int i = 0; i < table.length; i++){
      for(int j = 0; j < table[i].length; j++){
        if(table[i][j] == true){
          counts[table2[i][j]][0]++;
        }else{
          counts[table2[i][j]][1]++;
        }
      }
    }
    long ans = 0;
    for(int i = 0; i < counts.length; i++){
      ans += (long)counts[i][0] * counts[i][1];
    }
    return ans;
  }
  
  public static void saiki(boolean[][] table, int[][] table2, int i, int j, int n){
    table2[i][j] = n;
    if(i-1 != -1){
      if(table[i][j] != table[i-1][j] && table2[i][j] != table2[i-1][j]){
        saiki(table, table2, i-1, j, n);
      }
    }
    if(j-1 != -1){
      if(table[i][j] != table[i][j-1] && table2[i][j] != table2[i][j-1]){
        saiki(table, table2, i, j-1, n);
      }
    }
    if(i+1 < table.length){
      if(table[i][j] != table[i+1][j] && table2[i][j] != table2[i+1][j]){
        saiki(table, table2, i+1, j, n);
      }
    }
    if(j+1 < table[0].length){
      if(table[i][j] != table[i][j+1] && table2[i][j] != table2[i][j+1]){
        saiki(table, table2, i, j+1, n);
      }
    }
  }
}

Measured memory_bytes: 42748
#include <iostream>
#include <locale>
#include <string>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
using namespace std;

int main() {
	static const double pi = 3.141592653589793;
	double a,b,c;
	double S,L,h;
	
	cin >> a >> b >> c;
	
	S = a*b*sin(pi*c/180)/2;
	h = S * 2 / a;
	L = a + b + sqrt(a*a+b*b-2*a*b*cos(pi*c/180));
	cout << fixed << setprecision(6) << S << endl;
	cout << fixed << setprecision(6) << L << endl;
	cout << fixed << setprecision(6) << h << endl;
	
	return 0;
}


Measured memory_bytes: 3508
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

int n;
string s;
int x,y;
int main(){
	cin >> n >> s;
	rep(i,n){
		if('A' <= s[i] && s[i] <= 'M') x++;
		else if('N' <= s[i] && s[i] <= 'Z') x--;
		else if('a' <= s[i] && s[i] <= 'm') y++;
		else y--;
	}
	string ans = "";
	if(x > 0) rep(i,x) ans.pb('A');
	else if(x < 0) rep(i,-x) ans.pb('N');
	
	if(y > 0) rep(i,y) ans.pb('a');
	else if(y < 0) rep(i,-y) ans.pb('n');
	cout << ans.size() << endl;
	cout << ans << endl;
}


Measured memory_bytes: 3300
#include<iostream>
#include<algorithm>
#include<utility>

using namespace std;

int main() {
	long long n, d, a;
	pair<long long, long long> *xh;
	xh = new pair<long long, long long>[200000];
	cin >> n >> d >> a;
	for(long long i = 0; i < n; i++){
		cin >> xh[i].first >> xh[i].second;
	}
	sort(xh, xh + n);
	long long res = 0;
	long long acc_d = 0;
	long long nearest_edge = 0;
	for(long long i = 0; i < n; i++) {
		long long xi = xh[i].first, hi = xh[i].second;
		while(nearest_edge < i
		   && xh[nearest_edge].first < xi) {
			acc_d -= xh[nearest_edge].second;
			nearest_edge++;
		}
		hi -= acc_d;
		long long c = hi <= 0 ? 0 : (hi + a - 1) / a;
		res += c;
		long long tot_dam = c * a;
		acc_d += tot_dam;
		xh[i].first = xi + 2 * d;
		xh[i].second = tot_dam;
	}
	cout << res << endl;
	delete[] xh;
}
	



Measured memory_bytes: 3328
def search(p,q):
  count = 0
  for i in range(n):
    for j in range(n):
      if a[i][0]-a[j][0] == p and a[i][1]-a[j][1] == q:
        count += 1
  return count
n = int(input())
a = []
for i in range(n):
  a.append(tuple(map(int,input().split())))
cc = 0
for i in range(n):
  for j in range(n):
    if i == j:
      continue
    else:
      p = a[i][0]-a[j][0]
      q = a[i][1]-a[j][1]
      cc = max(cc,search(p,q))
print(n-cc)


Measured memory_bytes: 42476
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)

N, K = LI()
A = LI()

if N == K:
    print(1)
    exit()
N -= K
result = N / (K-1) + 1
if result % 1 != 0:
    result //= 1
    result += 1

print(int(result))



Measured memory_bytes: 16280
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int A = sc.nextInt();
	int B = sc.nextInt();
	int H = sc.nextInt();
	int M = sc.nextInt();
	int mi = H*60 + M; //分
	double kakuA = 0.5*mi;
	double kakuB = (6*mi)%360;
	double kaku = Math.abs(kakuA-kakuB);
	if(kaku > 180) kaku=360-kaku;
	double dd = A*A + B*B - 2*A*B*Math.cos(Math.toRadians(kaku));
	System.out.print( Math.sqrt(dd) );
    }
}


Measured memory_bytes: 35972
use scanner::Scanner;

fn main() {
    let mut sc = Scanner::new();
    let s: String = sc.read();
    let mut ans = String::new();
    for c in s.chars() {
        match c {
            '0' => { ans.push('0'); }
            '1' => { ans.push('1'); }
            'B' => { ans.pop(); }
            _ => (),
        }
    }
    println!("{}", ans);
}

mod scanner {
    pub struct Scanner<'a> {
        s: String,
        words: ::std::str::SplitWhitespace<'a>,
    }

    impl<'a> Scanner<'a> {
        pub fn new() -> Scanner<'a> {
            let s = String::new();
            let words = unsafe { ::std::mem::transmute(s.split_whitespace()) };
            Scanner { s: s, words: words }
        }

        pub fn read<T: ::std::str::FromStr>(&mut self) -> T {
            match self.words.next() {
                Some(x) => x.parse().ok().unwrap(),
                None => {
                    self.load();
                    self.read()
                }
            }
        }

        fn load(&mut self) {
            self.s.clear();
            ::std::io::stdin().read_line(&mut self.s).unwrap();
            self.words = unsafe { ::std::mem::transmute(self.s.split_whitespace()) };
        }
    }
}

Measured memory_bytes: 4352
#include <string>
#include <vector>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <functional>
#include <utility>
#include <map>
using namespace std;


#define prec(i) cout << fixed << setprecision(i)

const long long int MOD = 1000000007;


int ctoi(char c) {
	if (c >= '0' && c <= '9')
		return c - '0';
	else
		return -1;
}


int main()
{
	long long int k, x;

	cin >> k >> x;

	for (int i = x - k + 1; i < x + k; i++) {
		if (-1000000 <= i && i <= 1000000)
			cout << i << " ";
	}

	cout << endl;

	return 0;

}

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

int main(){
  int n,d;
  int c = 0;
  scanf("%d %d",&n,&d);

  int ary[11][11];
  for(int i = 0; i < n; i++){
    for(int j = 0; j < d; j++){
      scanf("%d",&ary[i][j]);
    }
  }

  for(int i = 0; i < n - 1; i++){
    for(int j = i + 1; j < n; j++){
      int sa = 0;
      for(int k = 0; k < d; k++){
	int tmp = ary[i][k] - ary[j][k];
	tmp = tmp * tmp;
	sa += tmp;
      }

      for(int l = 1; l * l <= 16000; l++){
	if(l * l == sa){
	  c++;
	  break;
	}
      }
    }
  }

      
  printf("%d\n",c);

}


Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>

#define MAX 500
#define TEST 0
int b[MAX],r[MAX];
int c[MAX][MAX];

int p[MAX];//pairing red->blue
bool v[MAX];//red[?]がすでに新しい割り当て先のないことが決まっている場合true

int gcd(int x,int y)
{
	while(y!=0)
	{
		int r=x%y;
		x=y;
		y=r;
	}
	return x;
}

int match(int bl,int n,bool v[MAX])
{
	if(bl<0)
	{
		puts("error bl<0");
		exit(1);
	}
	for(int i=0;i<n;++i)
	{
		if(!c[bl][i] || v[i])continue;
		v[i]=true;
		int ano=p[i];
		if(p[i]<0)
		{
			p[i]=bl;
			return 1;
		}
		int sub=match(p[i],n,v);
		if(sub>0)
		{
			p[i]=bl;
			return sub;
		}
	}
	return 0;
}

int main(void)
{
	int m,n;
while(scanf("%d%d",&m,&n)==2 && (m||n))
{
	int count=0;
	for(int i=0;i<m;++i)
	{	
		scanf("%d",b+i);
	}
	for(int j=0;j<n;++j)
	{
		scanf("%d",r+j);
		p[j]=-1;
	}
	for(int i=0;i<m;i++)
	{
		for(int j=0;j<n;j++)
		{
			c[i][j]=gcd(b[i],r[j])!=1?1:0;
		}
	}
	for(int i=0;i<m;++i)
	{
		for(int j=0;j<n;j++)
		{
			v[j]=false;
		}
		int res=match(i,n,v);
		count+=res;
	}
	printf("%d\n",count);
	if(TEST)
	{
		for(int j=0;j<n;j++)
		{
			printf("(%d,%d)\n",p[j],j);
		}
	}
}
	return 0;
}

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

int main() {
  int A, B;
  string S, T, U;
  cin >> S >> T >> A >> B >> U;
  if(U == S){
      cout << A-1 << " " << B << endl;
  }
  else if(U == T){
      cout << A << " " << B-1 << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
using ll = long long;
 
const ll MOD = 1000000007;
 
//1-indexであることに注意
struct BIT {
    int n;
    vector<int> data;
 
    BIT(int n) : n(n), data(n + 1, 0) {}
    
    int sum(int i) {
        int s = 0;
        while (i > 0) {
            s += data[i];
            i -= i & -i;
        }
        return s;
    }
    
    void add(int i, int x) {
        while (i <= n) {
            data[i] += x;
            i += i & -i;
        }
    }
};
 
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<ll> p(n);
    vector<ll> q(n);
	for (int i = 0; i < n; i++) cin >> p[i];
    for(int i = 0; i < n; i++) cin >> q[i];
	vector<ll> f(n);
	f[0] = 1;
	for (int i = 1; i < n; i++) {
		f[i] = f[i - 1]*i;
	}
	ll ans = 1;
	BIT b(100010);
	for (int i = 0; i < n - 1; i++) {
		ans = (ans + f[n - 1 - i] * (p[i] - 1 - b.sum(p[i]))) ;
		b.add(p[i], 1);
	}
    vector<ll> f2(n);
	f2[0] = 1;
	for (int i = 1; i < n; i++) {
		f2[i] = f2[i - 1]*i;
	}
	ll ans2 = 1;
	BIT c(100010);
	for (int i = 0; i < n - 1; i++) {
		ans2 = (ans2 + f2[n - 1 - i] * (q[i] - 1 - c.sum(q[i]))) ;
		c.add(q[i], 1);
	}
    cout << abs(ans-ans2) << endl;
}

Measured memory_bytes: 1024
def main():
    S = input()
    c = S.find("C")
    f = S[::-1].find("F")
    # print(c, len(S) - f - 1)
    if c >= 0 and f >= 0 and c < len(S) - f - 1:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)

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

    if ( a == b && a != c || a == c && a != b || b == c && b != a ) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

    return 0;
}


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

ll ceil(ll a, ll b) {
    if (b < 0) {
        a *= -1;
        b *= -1;
    }
    if (a >= 0) {
        return (a + b - 1) / b;
    } else {
        return a / b;
    }
}

ll floor(ll a, ll b) {
    if (b < 0) {
        a *= -1;
        b *= -1;
    }
    if (a < 0) {
        return (a - b + 1) / b;
    } else {
        return a / b;
    }
}

int main() {
    int K;
    cin >> K;
    vector<ll> A(K + 1, 0);
    for (int i = 1; i <= K; i++) {
        cin >> A[i];
    }

    vector<ll> L(K + 1, 0), R(K + 1, 0);
    L[K] = 2;
    R[K] = 2;
    for (int i = K; i >= 1; i--) {
        if (!(L[i] % A[i] == 0 || L[i] / A[i] < R[i] / A[i])) {
            cout << -1 << endl;
            return 0;
        }
        L[i - 1] = ceil(L[i], A[i]) * A[i];
        R[i - 1] = floor(R[i], A[i]) * A[i] + A[i] - 1;
    }
    cout << L[0] << " " << R[0] << endl;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#include <complex>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,C,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

mat dist(10,vec(10,-1));

int main() {
    cin>>H>>W;
    rep(i,10){
        rep(j,10){
            cin>>A;
            dist[i][j] = A;

        }
    }
    rep(roop,10) {
        rep(k, 10) {
            rep(i, 10) {
                rep(j, 10) {
                    if ((i != j) && dist[i][j] > dist[i][k] + dist[k][j]){
                        dist[i][j] = dist[i][k] + dist[k][j];
                    }
                }
            }
        }
    }
    ll ans = 0;
    rep(i,H){
        rep(j,W){
            cin>>A;
            if((A != -1) && (A != 1)){
                ans += dist[A][1];
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

typedef long long ll;

bool uruu(int y) {
	if (y % 4) return false;
	if (y % 400 == 0) return true;
	if (y % 100 == 0) return false;
	return true;
}

ll Day(int y, int m, int d) {
	ll ret = d;

	int mon[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

	int sum = 0;
	for (int i = 1; i <= 12; ++i) sum += mon[i];

	mon[2] = uruu(y) ? 29 : 28;
	for (int i = 1; i < m; ++i) ret += mon[i];

	for (int i = 1; i < y; ++i) {
		if (uruu(i)) ret += sum+1;
		else ret += sum;
	}

	return ret;
}

int main() {
	int y1, m1, d1, y2, m2, d2;
	while (cin >> y1 >> m1 >> d1 >> y2 >> m2 >> d2, y1 > -1) {
		cout << ( Day(y2, m2, d2) - Day(y1, m1, d1) ) << endl;
	}
}

Measured memory_bytes: 1156
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cctype>

using namespace std;

int main()
{
    string str;
    cin >> str;
    bool f = true;

    if (str[2] != str[3] || str[4] != str[5])
    {
        f = false;
    }

    if (f)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}

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

int dp[31][1 << 16];
int a[30], b[30];
int main() {
	int n, c;
	while (scanf("%d%d", &n, &c), n) {
		memset(a, 0, sizeof(a));
		memset(b, 0, sizeof(b));
		rep(i, n)rep(j, 16) {
			int d; scanf("%d", &d); a[i] |= d << j;
		}
		rep(i, c)rep(j, 16) {
			int d; scanf("%d", &d); b[i] |= d << j;
		}
		memset(dp, -1, sizeof(dp));
		dp[0][0] = 0;
		rep(i, n)rep(j, 1 << 16) {
			if (dp[i][j] == -1)continue;
			rep(k, c) {
				int v = (j | a[i]), cnt = 0;
				rep(t, 16) {
					if ((v >> t & 1) && (b[k] >> t & 1)) {
						v ^= 1 << t; cnt++;
					}
				}
				dp[i + 1][v] = max(dp[i + 1][v], dp[i][j] + cnt);
			}
		}
		printf("%d\n", *max_element(dp[n], dp[n] + (1 << 16)));
	}
}

Measured memory_bytes: 11148
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>


#define fs first
#define sc second

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;


const ll MAX_N = 151000;

template<typename T>
class LazySegmentTree{
public:
    //セグメント木を持つグローバル変数
    int n;
    T node[2 * MAX_N - 1];
    T lazy[2 * MAX_N - 1];

    void init(int n_, T init_num){
        n = 1;
        while(n < n_) n *= 2;
        for(int i = 0; i < 2*n-1; i++){
            node[i] = init_num;
            lazy[i] = 0;
        }
    }

    void eval(int k, int l, int r){
        if(lazy[k] != 0){
            node[k] += lazy[k];

            if(r - l > 1){
                lazy[2*k+1] += lazy[k];
                lazy[2*k+2] += lazy[k];
            }
            lazy[k] = 0;
        }
    }

    void add(int a, int b, int k, int l, int r, T x){
        eval(k, l, r);
        if(r <= a || b <= l){
            return;
        }

        if (a <= l && r <= b) {
            lazy[k] = x;
            eval(k, l, r);
        }
        else{
            add(a, b, 2*k+1, l, (l+r)/2, x);
            add(a, b, 2*k+2, (l+r)/2, r, x);
            node[k] = min(node[2*k+1], node[2*k+2]);
        }
    }


    // [a, b)の最小値を求める。
    // kは節点の番号、l, rはその節点が[l, r)に対応づいていることを表す。
    // query(a, b, 0, 0, n)で外からは呼び出す。
    ll query(int a, int b, int k, int l, int r) {
        if (r <= a || b <= l) {
            return LONG_LONG_MAX;
        }

        eval(k, l, r);
        if (a <= l && r <= b) {
            return node[k];
        } else {
            ll vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
            ll vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
            return min(vl, vr);
        }
    }
};


int main(){
    ll N, M;
    cin >> N >> M;

    LazySegmentTree<ll> st;
    st.init(N, 0);
    for(int i = 0; i < M; i++){
        int q, s, t, x;
        cin >> q;
        if(q == 0) {
            cin >> s >> t >> x;
            st.add(s, t+1, 0, 0, st.n, x);
        }
        else{
            cin >> s >> t;
            cout << st.query(s, t+1, 0, 0, st.n) << endl;

        }
    }


    return 0;

}



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

// マクロ //
#define rep(i,N) for(int i = 0; i < (int)(N); i++)
#define all(x) x.begin(), x.end()
#define sort(x) sort(all(x))
#define uniq(x) x.erase(unique(all(x)), x.end())
#define vsum(x) accumulate(all(x), 0)
#define cou(x) cout << x << endl
#define y() cout << "Yes" << endl
#define n() cout << "No" << endl
#define Y() cout << "YES" << endl
#define N() cout << "NO" << endl
#define x2(x) (x) * (x)
#define db(i) cout << #i << " = " << i;

// 型エイリアス //
using lint = long long;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vi = vector<int>;
using vli = vector<lint>;
using vc = vector<char>;
using vs = vector<string>;
using vb = vector<bool>;
using vvi = vector<vi>;
using vvli = vector<vli>;
using vvb = vector<vb>;
using vvc = vector<vc>;
using vvs = vector<vs>;
using mii = map<int, int>;
using mili = map<int, lint>;
using mci = map<char, int>;
using mcli = map<char, lint>;
using msi = map<string, int>;
using msli = map<string, lint>;


// 関数 //
template<class T, class Q> lint gcd_(T a, Q b) {
    int t;
    while (b != 0) {
        t = a % b;
        a = b;
        b = t;
    }
    return a;
}

template<class T, class Q> lint lcm_(T a, Q b) {
    return a * b / gcd(a, b);
}

double distance(pii a, pii b) {
    double dist;
    dist = sqrt(x2(a.first - b.first) + x2(a.second - b.second));
    return dist;
}

lint perm(int a) {
    lint perm = 1;
    for (int i = a; i >= 1; i--) {
        perm *= i;
    }
    return perm;
}

lint combination(int n, int m) {
    long double c = 1;
    for (int i = n, k = 1; i > m; i--, k++) {
        c *= i;
        c /= k;
    }
    return (lint)c;
}

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

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

// 定数 //
const double pi = acos(-1);
const int mod = 1000000007;
const int MOD = 998244353;
const int inf = 1045141919;
const lint linf = ((1LL << 62) - 1);


// キーワード //
#define elif else if

// End of Template //



int main() {

    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);

    int n;
    cin >> n;
    vs s(n);
    rep(i, n) {
        cin >> s[i];
    }
    sort(s);
    uniq(s);
    cou(s.size());
}

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

int main(){

  int A,B,X;
  int ans;

  cin >> X >> A >> B;

  ans = X - A;
  for(int i = 0;;i++){
    ans = ans - B;
    if(ans < 0){
      cout << ans + B << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
A,B,C,X,Y=map(int,input().split())
"""
X枚のA、Y枚のBが必要
ABピザの値段2枚が安いかどうかが分かれ目
"""
ans=(X+Y)*(A+B+C)
#2枚のピザのほうが安いとき
for i in reversed(range(max(X,Y)+1)):#全部ABピザにしちゃう場合から
    num_c=i*2
    num_a=max(0,X-i)
    num_b=max(0,Y-i)
    if ans>num_a*A+num_b*B+num_c*C:
        ans=num_a*A+num_b*B+num_c*C
print(ans)


Measured memory_bytes: 67708
s=int(input())
a=[]
na=[]
a.append(s)
for i in range(1,10**6):
    if a[i-1]%2==0:
        a.append(a[i-1]/2)
    else:
        a.append(a[i-1]*3+1)
    na=set(a)
    if len(na)!=i+1:
        print(i+1)
        exit()

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

int main() {

  string s;

  cin >> s;

  string document;

  for(int i=0;i<s.size();i++){
    if(s.at(i) == '0'){
      document.append("0");
    }
    if(s.at(i) == '1'){
      document.append("1");
    }
    if(s.at(i) == 'B'){
      if(document.empty()==0)
        document.erase(document.end()-1,document.end());
      else{}
    }
  }
  cout << document;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(ll i = n;i >= 0;--i)
#define FOR(i,m,n) for(ll i = m, i##_len=(n);i <i##_len; ++i)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;
 
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}


int main(void)
{
    ll n;
    cin >> n;
    string s;
    cin >> s;
    vector<ll> cntlw(n, 0);
    vector<ll> cntre(n, 0);
    
    if(s[0] == 'W'){
        cntlw[0] = 1;
    }

    FOR(i,1,n){
        if(s[i] == 'W'){
            cntlw[i] = cntlw[i-1] + 1;
        }
        else{
            cntlw[i] = cntlw[i - 1];
        }
    }

    if(s[n-1] == 'E'){
        cntre[n-1] = 1;
    }

    REPR(i,n-2){
        if(s[i] == 'E'){
            cntre[i] = cntre[i + 1] + 1;
        }
        else{
            cntre[i] = cntre[i + 1];
        }
    }

    ll minc = cntre[1];
    FOR(i, 1, n - 1)
    {
        ll cnt = cntlw[i - 1] + cntre[i + 1];
        if(minc >= cnt){
            minc = cnt;
        }
    }

    cout << min(minc,cntlw[n-2]) << endl;
    return 0;
}

Measured memory_bytes: 5380
n, a = map(int, input().split())
l = list(map(int, input().split()))

t = 50*n+1
dp = [[0]*t for _ in range(n+1)]

for i in range(n):
  x = l[i]
  for j in reversed(range(n+1)):
    for k in range(t):
      if dp[j][k] != 0:
        dp[j+1][k+x] += dp[j][k]
  dp[0][x] += 1

ans = 0
for i in range(n):
  ans += dp[i][a*(i+1)]

print(ans)

Measured memory_bytes: 4596
#include<bits/stdc++.h>
#define endl "\n"

typedef long long ll;
using namespace std;

//ll const N = 32000;

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

    int N, cnt = 0, minn = 200000;
    cin >> N;

    int arr[N];

    for(int i = 0; i < N; i++)
    {
        cin >> arr[i];
        if(arr[i] <= minn)
        {
            cnt++;
            minn = arr[i];
        }
    }

    cout << cnt;

    return 0;
}

Measured memory_bytes: 4300
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define ff first
#define ss second
#define sf ss.ff
#define tt ss.ss
#define input(a) scanf("%lld",&a)
#define M 1000000007
#define inf 1<<30
#define DIN freopen("input.txt","r",stdin);
#define DOUT freopen("output.txt","w",stdout);

using namespace std;

typedef long long int ll;
typedef pair<ll,ll> ii;
typedef pair<ll,ii> iii;
typedef vector<ll> vll;
typedef vector<ii> vii;
typedef vector<iii> viii;

/*
 *Use abbreviation:
 *dsu ->Disjoint Set Union
 *bit ->Binary Indexed Tree
 *math ->Mathematical Functions(gcd,fact,bigMod,ncr)
 *test ->For test cases
 */

ll n,sm;

int main()
{
    cin>>n;
    sm=n+!(n&1);
    cout<<(n*(n-2)+(n&1))/2<<endl;
    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            if(i+j==sm)
                continue;
            cout<<i<<" "<<j<<endl;
        }
    }
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<string>
#include<array>
#include<cmath>
#include<vector>
#include<utility>
#include<algorithm>
using namespace std;


int main() {
	string b;
	cin >> b;
	if (b=="A") {
		cout << "T";
	}else if (b == "T") {
		cout << "A";
	}else if (b == "C") {
		cout << "G";
	}
	else {
		cout << "C";
	}
}

Measured memory_bytes: 256
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        while (true) {
            String[] arr = br.readLine().split(" ");
            int m = Integer.parseInt(arr[0]);
            int f = Integer.parseInt(arr[1]);
            int r = Integer.parseInt(arr[2]);
            if (m == -1 && f == -1 && r == -1){
                break;
            }

            if (m == -1 || f == -1){
                System.out.println("F");
            }else if (m + f >= 80){
                System.out.println("A");
            }else if (m + f >= 65){
                System.out.println("B");
            }else if (m + f >= 50){
                System.out.println("C");
            }else if (m + f >= 30) {
                if (r >= 50){
                    System.out.println("C");
                }else{
                    System.out.println("D");
                }
            } else{
                System.out.println("F");
            }
        }
    }
}

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

using namespace std;

#define ll long long
#define pii pair<int, int>
#define pb push_back
#define pli pair<ll, int>
#define pil pair<int, ll>
#define clr(a, x) memset(a, x, sizeof(a))

const double pi = acos(-1.0);
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;

/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define TREE tree<pli, null_type, greater<pli>, rb_tree_tag, tree_order_statistics_node_update>
TREE T;
*/

struct gg {
	string s;
	int p, id;
	bool operator < (const gg &g) const {
		return s < g.s || s == g.s && p > g.p;
	}
} g[105];
int main() {
	int n; scanf("%d", &n);
	for (int i = 1; i <= n; ++i) {
		cin >> g[i].s >> g[i].p; g[i].id = i;
	}
	sort(g + 1, g + n + 1);
	for (int i = 1; i <= n; ++i) cout << g[i].id << endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int main() {
  ll n,k;
  cin>>n>>k;
  vll x(n);
  int zero=inf;
  rep(i,0,n) {
    cin>>x[i];
    if(zero==inf &&x[i]>=0){
      zero=i;
    }
  }
  if(zero==inf) zero=n-1;
  ll ans=inf;
  rep(i,0,k){
    if(zero-k+i+1>=0 && zero+i<n){
      if(x[zero+i-k+1]<0 && 0 <x[zero+i]){
            ll d=min(abs(x[zero-k+i+1]),abs(x[zero+i]));
            ll cnt=0;
            cnt+=d+abs(x[zero-k+i+1])+abs(x[zero+i]);
            ans=min(ans,cnt);
      }
      else {
       
        ll cnt=0;
        cnt+=max(abs(x[zero-k+i+1]),abs(x[zero+i]));
        ans=min(ans,cnt);
        
      }
     // cout<<ans<<endl;
    }
  }
  cout<<ans<<endl;
}
//k通り調べる　絶対値の小さい方から 0の位置

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

 int main () {
   int a, b, c, f = 0;
   cin >> a >> b >> c;
     
     for ( int x = a; x <= b; x++ ){
       if ( c % x == 0 ) f++;
     }
     
     cout << f << endl;
              
    return 0;
 }    

Measured memory_bytes: 1160
#include <math.h>
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <numeric>
using namespace std;

int f_ggd(int n1, int n2)
{
	int m = n1;
	int n = n2;
	if (n2 > n1) {
		m = n2;
		n = n1;
	}
	int t;
	while (m != n) {
		t = n;
		n = m - n;
		m = t;
	}
	return m;
}

long long f_ggd2(long long n1, long long n2)
{
	long long m = n1;
	long long n = n2;
	if (n2 > n1) {
		m = n2;
		n = n1;
	}
	long long r = n % m;
	while (r != 0) {
		n = m;
		m = r;
		r = n % m;
	}
	return m;
}

long long f_lcm(long long n1, long long n2)
{
//	return n1 * n2 / gcd(n1, n2);
//	return n1 * n2 / f_ggd(n1, n2);
	return n1 * n2 / f_ggd2(n1, n2);
}

int main()
{
	long long a, b, c, d, e;
	cin >> a >> b >> c >> d;
	e = f_lcm(c, d);

	long long x1 = (a - 1) / c;
	long long x2 = b / c;
	long long x3 = x2 - x1;

	long long y1 = (a - 1) / d;
	long long y2 = b / d;
	long long y3 = y2 - y1;

	long long z1 = (a - 1) / e;
	long long z2 = b / e;
	long long z3 = z2 - z1;

	long long ans = (b - a + 1) - (x3 + y3 - z3);

	cout << ans << endl;

	return(0);
}





Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const ll INFLL = 1001001001001001001;  // > 10^18
const int MOD = (int)1e9 + 7;
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;

int main () {
    
    string s; cin >>s;
    set<char> a;

    for (int i = 0; i < s.length(); i++) {
        a.insert(s[i]);
    }
    for (char moji = 'a'; moji <= 'z'; moji++) {
        if (!a.count(moji)) {
            cout << moji << endl;
            return 0;
        } 
    }
    cout << "None" << endl;
    return 0;
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,n,m) for(int i=n;i<=(int)(m);i++)
#define RFOR(i,n,m) for(int i=(int)(n);i>=m;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(std::unique(all(x)), x.end());
typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;
const double PI=acos(-1);
using namespace std;
vector<int> dx={1,0,-1,0};
vector<int> dy={0,1,0,-1};
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

struct RollingHash {
    int n;
    vector<pair<ll,ll>> vec,pw;
    ll mod1,mod2,base1,base2;
    
    RollingHash(string &s) {
        srand(time(NULL));
        n=sz(s);
        vec.resize(n+1);
        pw.resize(n+1);
        pw[0]={1,1};
        
        mod1=1e9+93;
        mod2=1e9+97;
        base1=(ll)rand()%((ll)1e7+9);
        base2=(ll)rand()%((ll)1e7+9);
        rep(i,n) {
            pw[i+1].first=pw[i].first*base1%mod1;
            pw[i+1].second=pw[i].second*base2%mod2;
            vec[i+1].first=(vec[i].first*base1+(ll)s[i])%mod1;
            vec[i+1].second=(vec[i].second*base2+(ll)s[i])%mod2;
        }
    }
    
    //[l,r)
    pair<ll,ll> get(int l,int r) {
        ll fi,se;
        fi=(vec[r].first-vec[l].first*pw[r-l].first+mod1*mod1)%mod1;
        se=(vec[r].second-vec[l].second*pw[r-l].second+mod1*mod2)%mod2;
        return make_pair(fi,se);
    }
};

int main() {
    int n;
    string s;
    cin>>n>>s;
    RollingHash rlh(s);
    
    int ng = n/2+1, ok = 0;
    while (ng - ok > 1) {
        int mid = (ng + ok) / 2;
        
        bool f=false;
        for(int i=0;i+mid-1<n;i++) {
            for(int j=i+mid;j+mid-1<n;j++) {
                if(rlh.get(i,i+mid)==rlh.get(j,j+mid)) {
                    f=true;
                    break;
                }
            }
            if(f) break;
        }
        
        (f ? ok : ng) = mid;
    }
    
    cout<<ok<<endl;
}


Measured memory_bytes: 384
#include<stdio.h>
#include<stdlib.h>

int cmp(const void *a,const void *b){
  return *(int*)a - *(int*)b;
}

int main(void){
  int n,i,ans=0;
  scanf("%d",&n);
  int a[n];
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  qsort(a,n,sizeof(int),cmp);
  a[n-1] = a[n-1]/2;
  for(i=0;i<n;i++){
    ans+=a[i];
  }
  printf("%d\n",ans);
  return 0;
}

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


using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,s) for (auto i = begin(s); i != end(s); ++i)
#define itrepd(i,s) for (auto i = --end(s); i != begin(s); --i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
#define rall(f,x,...) [&](decltype(x)& whole) { return (f)(rbegin(whole), rend(whole), ##__VA_ARGS__); }(x)
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e17;
ll mod = static_cast<ll>(1e9 + 7);
std::ostream& endn(std::ostream& os) { return os.put(os.widen('\n')); }
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T> constexpr T pow2(const T a) { return a * a; }
template<class T, class ... Args> constexpr T mins(T& a, Args... args) { return a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr T maxs(T& a, Args... args) { return a = max<T>({ a,args... }); }
template<typename A, size_t N, typename T>
void fillArray(A(&array)[N], const T& val) { std::fill((T*)array, (T*)(array + N), val); }

int n;
int a[105];
void solve() {
    cin >> n;
    rep(i, n) cin >> a[i];

    bool ok = true;
    rep(i, n) if (a[i] % 2 == 0) {
        if (a[i] % 3 != 0 && a[i] % 5 != 0) { ok = false; break; }
    }

    if (ok) cout << "APPROVED" << endn;
    else cout << "DENIED" << endn;

}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    cout << flush;
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  int fx = 0, x = N;
  int i = 0;
  while(true) {
    fx += (x % 10);
    x = x / 10;
    if(x == 0) {
      break;
    }
    
  }
  
  if(N % fx == 0) {
    cout << "Yes" << endl;
  }
  
  else {
    cout << "No" << endl;
  }
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char er[]="erase";
char dr[]="dream";
int main()
{
    string str;
    cin>>str;
    int len=str.size();
    int flag=0;
    for(int i=0;i<len;i++)
    {
        if(str[i]=='d')//dream---,县推理到dreamer
        {
            int j=i;
            for(j=i;j<=i+4;j++)
            {
                if(j>=len||dr[j-i]!=str[j])
                {
                    flag=1;
                    break;//
                }
            }
            if(j==i+5)
            {
                i=j-1;
                if(str[j]=='e'&&str[j+1]=='r'&&str[j+2]!='a')
                {
                    i=j+1;
                }
            }
        }else if(str[i]=='e')
        {
            int j=i;
            for(j=i;j<=i+4;j++)
            {
                if(j>=len||er[j-i]!=str[j])
                {
                    flag=1;
                    break;//
                }
            }
            if(j==i+5)
            {
                i=j-1;
                if(str[j]=='r')
                {
                    i=j;
                }else
                {
                    i=j-1;
                }
            }
        }else
        {
            flag=1;
        }
        if(flag==1)break;
    }
    if(!flag)printf("YES\n");
    else printf("NO\n");
    return 0;
}


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

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

long long MOD = 10000000000 + 7;

int main(){
  cout << setprecision(10);

  string S; cin >> S;
  string T; T = S;
  reverse(T.begin(), T.end());

  int ans = 0;
  for(int i = 0; i < S.size()/2; i++){
    if(S[i] != T[i]) ans++;
  }
  cout << ans << endl;

}


Measured memory_bytes: 3628
N,K=map(int,input().split())
a=list(map(int,input().split()))

mod=10**9+7
dp=[[0]*(K+1) for i in range(N+1)]
dp[0][0]=1

for i in range(N):
  acc=[0]*(K+2)
  for j in range(K+1):
    acc[j+1]=acc[j]+dp[i][j]
    acc[j+1]%=mod
  for j in range(K+1):
    dp[i+1][j]=acc[j+1]-acc[max(0,j-a[i])]
    dp[i+1][j]%=mod
print(dp[N][K])


Measured memory_bytes: 219108
X,N = map(int,input().split())
if N ==0:
  print(X)
  exit()
p = [int(i) for i in input().split()]



for i in range(1000000):
  x = X-i
  if x not in p:
    print(x)
    exit()
  x = X+i
  if x not in p:
    print(x)
    exit()

Measured memory_bytes: 9192