akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,m,x,y;
  cin>>n;
  vector<string> w(n);
  for(int i=0;i<n;i++){
    cin>>w[i];
  }
  int sum=0;
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      if(w[i]==w[j]){
        sum++;
      }
    }
  }
  for(int i=0;i<n-1;i++){
    if(w[i][w[i].size()-1]!=w[i+1][0]){
      sum++;
    }
  }
  if(sum>0){
    cout<<"No"<<endl;
  }
  else{
    cout<<"Yes"<<endl;
  }
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
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 c = sc.nextInt();
		String ans = "NO";
		for (int i = 1; i <= b; i++) {
			if ((a * i) % b == c) {
				ans = "YES";
				break;
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define time_taken_start int begtime = clock();
#define time_taken_end int endtime = clock(); \
cerr << "\n\n" << "Time elapsed: " << \
(endtime - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n"; \
return 0;
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define mod 1000000007
#define inf 100000000000000007
#define eps 0.000000000001
#define pi acosl(-1)
#define pdd pair<ld,ld>
#define pll pair<ll,ll>
#define ff first
#define ss second
#define vpl vector<pll>
#define vll vector<ll>
#define mseti multiset <ll>
#define msetd multiset <ll,greater<ll>>
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound 
#define stp fixed<<setprecision(20)
#define endl '\n'
void solve()
{
    ll n;
    cin>>n;
    ll x,y,f=0,q=0;
    for(ll i=0;i<n;i++)
    {
        cin>>x>>y;
        if(x==y)
            q++;
        if(q==3)
            f=1;
        if(x!=y)
            q=0;
    }
    if(f)
        cout<<"Yes";
    else
        cout<<"No";
}
int main()
{
    FAST
    #ifdef ayk_16
    freopen("input.txt","rt",stdin);
    freopen("output.txt","wt",stdout);
    #endif
    time_taken_start
    ll t=1;
    //cin>>t;
    for(ll i=0;i<t;i++)
    {
        //cout<<"Case #"<<i+1<<": ";
        solve();
    }
    time_taken_end
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=1e5+5;
int va[26],vb[26];
char a[N],b[N];
vector<int>v[26];
int main()
{
    scanf("%s%s",a,b);
    int n=strlen(a),m=strlen(b),x,flag=0;
    for(int i=0; i<n; i++)
    {
        x=a[i]-'a';
        va[x]=1;
        v[x].push_back(i+1);
    }
    for(int i=0; i<m; i++)
        if(va[b[i]-'a']==0)
        {
            flag=1;  break;
        }
    if(flag)
        puts("-1");
    else
    {
        ll len=0;
        int now=0;
        for(int i=0; i<m; i++)
        {
            int k=b[i]-'a';
            int pos=upper_bound(v[k].begin(),v[k].end(),now)-v[k].begin();
            if(pos==v[k].size())
            {
                len+=n;
                now=0;
                pos=upper_bound(v[k].begin(),v[k].end(),now)-v[k].begin();
            }
            now=v[k][pos];
        }
        printf("%lld\n",now+len);
    }

    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define fs first
#define sc second
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main(){
  int h,w,n;
  cin>>w>>h>>n;
  vector<int>x(n),y(n),a(n);
  rep(i,n)cin>>x[i]>>y[i]>>a[i];
  int q[w][h]={0};
  rep(i,n){
    if(a[i]==1){
      rep(k,x[i]){
        rep(j,h){
          q[k][j]++;
        }
      }
    }
    else if(a[i]==2){
      for(int k=x[i];k<w;k++){
        rep(j,h){
          q[k][j]++;
        }
      }
    }
    else if(a[i]==3){
      rep(k,w){
        rep(j,y[i]){
          q[k][j]++;
        }
      }
    }
    else {
      rep(k,w){
        for(int j=y[i];j<h;j++){
          q[k][j]++;
        }
      }
    }
  }
  int ans=0;
  rep(i,w){
    rep(j,h){
      if(q[i][j]==0)ans++;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
// #define dump() fprintf(stderr, "#%s.%d\n", __func__, __LINE__);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumplll(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%ld, %ld, %ld)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
 
struct S002 {
  int n;
  S002& operator > (long& x) {
    n = x;
    return *this;
  }
  S002& operator > (long&& x) {
    n = x;
    return *this;
  }
  S002& operator >= (long& x) {
    if( scanf("%ld", &x) <= 0 ) exit(0);
    return *this;
  }
  S002& operator >= (double& x) {
    if( scanf("%lf", &x) <= 0 ) exit(0);
    return *this;
  }
  S002& operator >= (std::string& s) {
    if( not (std::cin >> s) ) exit(0);
    return *this;
  }
  template<typename a>
  S002& operator >= (std::vector<a>& v) {
    v.resize(n);
    for(long i = 0; i < n; ++i) {
      *this >= v[i];
    }
    return *this;
  }
  template<typename a, std::size_t s>
  S002& operator >= (std::array<a, s>& x) {
    for(long i = 0; i < (long)s; ++i) {
      *this >= x[i];
    }
    return *this;
  }
};


struct Solver {
  long n, t;
  std::vector<long> xs;
  Solver() {
    S002 reader;
    reader >= n >= t >n>= xs;
  }
  void solve() {
    std::sort(xs.begin(), xs.end());
    long res = n * t;
    for(long i = 1; i < n; ++i) {
      res -= std::max((long)0, t - (xs[i] - xs[i-1]));
    }
    printf("%ld\n", res);
  }    
  ~Solver() { fprintf(stderr, "--end--\n"); }
};
 

int main() {
  loop std::unique_ptr<Solver>(new Solver())->solve();
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int K;
    cin >> K;
    if (K % 2 == 0)
        cout << K * K / 4 << endl;
    else
    {
        cout << (K / 2) * (K / 2 + 1) << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cmath>

using namespace std;

int main() {
    int r;
    cin >> r;
    double pi = 3.14;
    cout << 2*pi*r << endl;
}


Measured memory_bytes: 3724
#include<stdio.h>
int main(void){
  int A,B,ans;
  scanf("%d",&A); scanf("%d",&B);
  if(A > 9 || B > 9 || A < 0 || B < 0){
    ans = -1;
  }else{
    ans = A * B;
  }
  printf("%d",ans);
return 0;
}

Measured memory_bytes: 128
use std::io::{stdin, Read};

macro_rules! parse {
    ($it: ident ) => {};
    ($it: ident, ) => {};
    ($it: ident, $var:ident : $t:tt $($r:tt)*) => {
        let $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
}

macro_rules! parse_val {
    ($it: ident, [$t:tt; $len:expr]) => {
        (0..$len).map(|_| parse_val!($it, $t)).collect::<Vec<_>>();
    };
    ($it: ident, $t: ty) => {
        $it.next().unwrap().parse::<$t>().unwrap()
    };
}

fn primes(s: usize) -> Vec<usize> {
    let mut c = 1;
    let mut ret = vec![];
    while c * c < s {
        if s % c == 0 {
            ret.push(c);
            ret.push(s / c);
        }
        c += 1;
    }
    if c * c == s {
        ret.push(c);
    }
    ret
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    parse!(it, n: usize, k: usize, a: [usize; n]);
    let s = a.iter().sum::<usize>();
    let mut ret = 1;
    for p in primes(s) {
        let mut b = a.iter().map(|&x| x % p).collect::<Vec<_>>();
        b.sort();
        let c: Vec<usize> = b
            .iter()
            .scan(0, |s, &x| {
                *s += x;
                Some(*s)
            })
            .collect();
        b.reverse();
        let d: Vec<usize> = b
            .iter()
            .scan(0, |s, &x| {
                *s += (p - x) % p;
                Some(*s)
            })
            .collect();
        for i in 0..(n - 1) {
            if c[i] == d[n - i - 2] && c[i] <= k {
                ret = std::cmp::max(ret, p);
                continue;
            }
        }
    }
    println!("{}", ret);
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k,m[10050],l=0;
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>m[i];
    }
    sort(m,m+n);
    for(int i=0;i<k;i++){
        l=l+m[i];
    }
    cout<<l<<"\n";
    return 0;
}


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

int main() {
  int n, a;
  a = 0;
  cin >> n;
  vector<int> sale(n);
  for (int i = 0; i < n; i++) {
    cin >> sale.at(i);
  }
  sort(sale.begin(), sale.end());
  reverse(sale.begin(), sale.end());
  
  for (int i =0; i < n; i++) {
    if (i == 0) {
      a += sale.at(i) / 2;
    }
    else {
      a += sale.at(i);
    }
  }
  cout << a << endl;
}



Measured memory_bytes: 256
/*
* @Author: wxyww
* @Date: 2020-02-16 20:46:35
* @Last Modified time: 2020-02-16 21:09:35
*/
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<ctime>
#include<bitset>
#include<cstring>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;

ll read() {
	ll x=0,f=1;char c=getchar();
	while(c<'0'||c>'9') {
		if(c=='-') f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9') {
		x=x*10+c-'0';
		c=getchar();
	}
	return x*f;
}

int main() {
	int a = read(),b = read(),c = read();
	if(a == b && a != c) {
		puts("Yes");return 0;
	}
	if(a == c && a != b) {
		puts("Yes");return 0;
	}
	if(b == c && a != b) {
		puts("Yes");return 0;
	}
	puts("No");
	return 0;
}

Measured memory_bytes: 256
N = int(input())
a_ls=list(map(int, input().split()))

ans=1
for i in range(N):
	ans*=a_ls[i]
	if ans>10**18:
		ans=-1
		break

if 0 in a_ls:
	ans=0

print(ans)


# 2darray [[0] * 4 for i in range(3)]

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

int main() {
    int n; cin >> n;
    int sum = 0;
    int t[n];
    for (int i = 0; i < n; i++) {
        cin >> t[i];
        sum += t[i];
    }
    int m; cin >> m;
    int p[m], x[m];
    for (int i = 0; i < m; i++) cin >> p[i] >> x[i];
    for (int i = 0; i < m; i++) {
        int dif = t[p[i] - 1] - x[i];
        cout << sum - dif << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int main(){
    int R,G,B,N; cin>>R>>G>>B>>N;

    int64_t ans=0;
    rep(r,0,N/R+1){
        rep(g,0,(N-r*R)/G+1){
            if((N-r*R-g*G)%B==0) ans++;
        }
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fr(i, n, m) for(int i = (n); i < (m); i ++)
#define pb push_back
#define st first
#define nd second

using namespace std;
typedef long long ll;
ll const inf = 1e9;
ll const mod = 1e9 + 7;
int main()
{
    int n;
    cin >> n;
    int a[n];
    int b[n];
    fr(i, 0, n) cin >> a[i];
    fr(i, 0, n) cin >> b[i];
    fr(i, 1, n) a[i] += a[i - 1];
    for(int i = n - 2; i >= 0; i --) b[i] += b[i + 1];
    int ans = 0;
    fr(i, 0, n){
        ans = max(ans, a[i] + b[i]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
let pair f s = s |>
               Str.split (Str.regexp " ") |>
               List.map f |>
               (function | [a; b] -> (a, b)
                         | _ -> failwith "invalid input")

let frame (h, w) =
  let row1 = (String.make w '#') ^ "\n" in
  let rec rows i acc =
    let row2 = "#" ^ (String.make (w-2) '.') ^ "#\n" in
    if i > 0 then rows (i-1) (row2 :: acc) else acc in
  String.concat "" (List.concat [[row1]; rows (h-2) []; [row1]])

let rec loop () =
  match read_line () with
  | "0 0" -> ()
  | line -> loop (print_endline (frame (pair int_of_string line)))

let () = loop ()

Measured memory_bytes: 2280
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define pii pair<int,int>
#define LL long long

using namespace std;

int main () {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin >> n;
    double av=0;
    double a[n+5];
    for (int i=1;i<=n;i++) cin >> a[i];
    for (int i=1;i<=n;i++) av+=a[i];
    av/=n;
    int ans=0;
    double mini=INT_MAX;
    for (int i=1;i<=n;i++) {
      if (abs(a[i]-av)<mini) {
        mini=abs(a[i]-av);
        ans=i;
      }
    }
    cout << ans-1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 100005
using namespace std;
typedef long long ll;
int vis[N],a[N];
void creat()
{
    for(int i=2; i<=400; i++)
    {
        if(!vis[i])
        {
            for(int j=i*2; j<=N; j+=i)
                vis[j]=1;
        }
    }
}
int main()
{

    memset(vis,0,sizeof(vis));
    creat();
    vis[1]=1;
    int sum=0,n;
    for(int i=1; i<=N; i++)
    {
        if(i%2==1)
        {
            if(vis[i]==0&&vis[(i+1)/2]==0)
                sum++;
        }

        a[i]=sum;
    }
    while(scanf("%d",&n)==1)
    {
        while(n--)
        {
            int c,b;
            scanf("%d%d",&c,&b);

            printf("%d\n",a[b]-a[c-1]);
        }
    }
}

Measured memory_bytes: 1408
Module Module1

    Sub main()
        Dim user2 As List(Of String) = New List(Of String)(Split(Console.ReadLine(), " "))
        Dim natuyasumiKikan As Long = user2(0)
        Dim syukudai As Long = user2(1)
        Dim result As Long = -1

        Dim user3 As List(Of String) = New List(Of String)(Split(Console.ReadLine(), " "))
        Dim syukudaies As New List(Of Long)(Array.ConvertAll(user3.ToArray, Function(i As String) CLng(i)))

        If syukudaies.Sum <= natuyasumiKikan Then
            result = natuyasumiKikan - syukudaies.Sum

        End If
        Console.WriteLine(result)
    End Sub
  end module

Measured memory_bytes: 47572
#include <iostream>
#include <string>
#include <functional>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <set>

using namespace std;

int n, a, b;

int main() {
    cin >> n >> a >> b;
    cout << min(a, b) << " ";
    if (a + b <= n) cout << "0\n"; else cout << a + b - n << 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;

struct V {
  double x, y;
  V( double x=0, double y=0) : x(x), y(y) {}
  V& operator+=( const V& v) { x += v.x; y += v.y; return *this; }
  V operator+(const V& v) const {return V(*this) += v;}
  V& operator-=( const V& v) { x -= v.x; y -= v.y; return *this; }
  V operator-( const V& v) { return V(*this) -= v;}
  double dot(const V& v) const { return x*v.x + y*v.y; }	// 内積
  double cross(const V& v) const { return x*v.y - y*v.x; }	// 外積
  double norm2() const { return x*x+y*y;}
  double norm() const { return sqrt(norm2());}
  int ort() const {  // orthant
    if (y>0 && x>0) return 1;
    else if (y>0 && x<=0) return 2;
    else if (y<=0 && x<=0) return 3;
    else return 4;
  }
  bool operator<(const V& v) const {
    int o = ort(), vo = v.ort();
    if (o != vo) return o < vo;
    return cross(v) > 0;
  }
};
istream& operator>>(istream& is, V& v) {
  is >> v.x >> v.y; return is;
}
ostream& operator<<(ostream& os, const V& v) {
  os << "(" << v.x << "," << v.y << ")"; return os;
}

int main() {
  int n;
  cin >> n;
  vector<V> v(n);
  REP(i,n) cin >> v[i];
  sort( v.begin(), v.end() );
//  REP(i,n) cout << v[i];
  double ans = 0;
  REP(l,n) {
    int r = l;
    V now;
    REP(i,n) {
      now += v[r];
      ans = max( ans, now.norm());
      r = (r+1)%n;
    }
  }
  printf("%.12f\n",ans);

  return 0;
}


Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string.h>
#define s(n)                        scanf("%d",&n)
#define sc(n)                       scanf("%c",&n)
#define sl(n)                       scanf("%I64d",&n)
#define sf(n)                       scanf("%lf",&n)
#define ss(n)                       scanf("%s",n)
#define INF                         (int)1e9
#define EPS                         1e-9
#define bitcount                    __builtin_popcount
#define gcd                         __gcd
#define forall(i,a,b)               for(int i=a;i<b;i++)
#define foreach(v, c)               for( typeof( (c).begin()) v = (c).begin();  v != (c).end(); ++v)
#define all(a)                      a.begin(), a.end()
#define in(a,b)                     ( (b).find(a) != (b).end())
#define pb                          push_back
#define fill(a,v)                    memset(a, v, sizeof a)
#define sz(a)                       ((int)(a.size()))
#define mp                          make_pair
#define MOD                         1000000007
typedef long long ll;
/*For you see , each day i love you
 more.Today more than yesterday
  less than tomorrow.*/
using namespace std;
double rad = M_PI/180;
pair<double , double> find_coord(double theta , double len)
{
	if(theta <= 90)
	{
		theta = (90-theta)*rad;
		return mp(len*cos(theta) , len*sin(theta));
	}
	else if(theta <= 180)
	{
		theta = (theta-90)*rad;
		return mp(len*cos(theta) ,-1.0*len*sin(theta));
	}
	else if(theta <= 270)
	{
		theta = (270-theta)*rad;
		return mp(-1.0*len*cos(theta) ,-1.0*len*sin(theta));
	}
	else
	{
		theta = (theta-270)*rad;
		return mp(-1.0*len*cos(theta) , len*sin(theta));
	}
}

int main()
{
	int a,b,h,m;
	cin>>a>>b>>h>>m;
	//convert it to minutes
	h = h*60 + m;
	double theta1 = (h%(12*60))*(0.5);
	double theta2 = (h%60)*(6.0);
	pair<double , double> pos1 = find_coord(theta1 , 1.0*a);
	pair<double , double> pos2 = find_coord(theta2 , 1.0*b);
	
	printf("%.9f\n",sqrt((pos1.first - pos2.first)*(pos1.first - pos2.first) + (pos1.second-pos2.second)*(pos1.second-pos2.second)));
	
	return 0;
}

Measured memory_bytes: 4068
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define speed                     \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0);
#define ll long long
#define pb push_back
#define mem1(a) memset(a, -1, sizeof(a))
#define mem0(a) memset(a, 0, sizeof(a))
#define endl "\n"
#define mod 1000000007
#define mod1 998244353
#define ff first
#define ss second
#define MAX 500005
#define N 10004
#define INF 1000000009
#define all(v) v.begin(), v.end()
#define sbit(a) __builtin_popcount(a)
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef pair<ll, ll> pll;
typedef pair<pll, ll> ppl;
typedef map<ll, ll> mpll;
typedef map<vector<ll>, ll> mpvl;
ll power(ll x, ll y, ll p)
{
    ll res = 1;
 
    x = x % p;
 
    if (x == 0)
        return 0;
    while (y > 0)
    {
 
        if (y & 1)
            res = (res * x) % p;
 
        y = y >> 1;
        x = (x * x) % p;
    }
 
    return res;
}
void solve()
{
 
    ll n, x, m;
    cin >> n >> x >> m;
    ll ans = x;
    ll t = x * x;
    ll c = 0;
    map<ll, ll> mp;
    n--;
    ll s[m + 1];
    mem0(s);
    ll tans = 0;
    ll tmp;
    for (ll i = 1; i <=m + 1; i++)
    {
        ll md = t % m;
        if (!mp.count(md))
        {
            tans += md;
            t = md * md;
        }
        else
        {
            c = i - mp[md];
            tmp = mp[md];
            break;
        }
        mp[md] = i;
        s[i] = tans;
    }
   
    tmp--;
    n -= tmp;
    ll div = n / c;
    ll md = n % c;
    ans += (div * (s[c + tmp] - s[tmp]));
    ans += s[tmp];
    ans += s[tmp + md] - s[tmp];
    cout << ans << endl;
}
int main()
{
    speed;
    ll kk;
    kk = 1;
    //cin >> kk;
    while (kk--)
    {
 
        solve();
    }
 
    return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define inf 1e16 + 1
#define ll long long
#define mm 1000000007
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define pii pair<int, int>
#define pll pair<ll, ll>

#define show(x) cout<<#x<<" "<<x<<'\n'
#define iosbase ios_base::sync_with_stdio(false); cin.tie(NULL);
#define oset tree<int , null_type, less_equal<int> , rb_tree_tag, tree_order_statistics_node_update>

using namespace std;
using namespace __gnu_pbds;

int main()
{
    iosbase;
    int n,d;
    cin>>n>>d;
    int div= 2*d+1;
    cout<<(n-1)/div +1 <<'\n';
}

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vll = vector<ll>;
template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

int main() {
    int H, N; cin >> H >> N;
    vint A(N);
    for (auto &v : A) cin >> v;
    if (accumulate(begin(A), end(A), 0) < H) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
    return (0);
}

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

using namespace std;

int main()
{
  int a, b, ans;
  char op;

  while(true)
  {
    cin >> a >> op >> b;
    if(op == '?')
      break;
    switch(op)
    {
    case '+':
      ans = a +	b;
      break;
    case '-':
      ans = a - b;
      break;
    case '*':
      ans = a * b;
      break;
    case '/':
      ans = a /	b;
    }
    cout << ans	<< endl;
  }
  return 0;
}

Measured memory_bytes: 1164
#pragma GCC optimize("O4")
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
//#define MOD (ll)(998244353)
#define MOD (ll)(1e9+7)
#define INF (1e15)
#define int ll
#define EPS (1e-6)
using namespace std;
using ll=long long;
using pii=pair<int,int>;

int gcd(int a,int b) { return b==0?a:gcd(b,a%b); }
int lcm(int a,int b) { return a/gcd(a,b)*b; }
int fpow(int b,int p){
	if(p==0) return 1;
	int h=fpow(b,p/2);
	if(p%2) return h*b%MOD*h%MOD;
	return h*h%MOD;
}

int32_t main() {
#ifdef LOCAL_TEST
	freopen("E:\\Jimmy\\2 Coding\\1 C++\\input.in","r",stdin);
	freopen("E:\\Jimmy\\2 Coding\\1 C++\\output.out","w",stdout);
	freopen("E:\\Jimmy\\2 Coding\\1 C++\\error.out","w",stderr);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0);

	//code...
	int n; cin>>n;
	vector<int> v(n);
	for(auto &i:v)
		cin>>i;
	int s=0;
	For(i,0,n-2) For(j,i+1,n-1){
		s+=v[i]*v[j];
	}
	cout<<s<<"\n";
	return 0;
}

Measured memory_bytes: 256
# https://atcoder.jp/contests/abc075/tasks/abc075_c

from collections import defaultdict

N, M = map(int, input().split())
par = [-1] * N
G = defaultdict(list)

########################################
class UnionFind(object):
    def __init__(self, n):
        self.par = [-1] * n
    
    def find(self, x):
        if self.par[x] < 0:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        
        if x == y:
            return False
        else:
            if self.par[x] > self.par[y]:
                x, y = y, x
            self.par[x] += self.par[y]
            self.par[y] = x
            return True

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def size(self, x):
        return -self.par[self.find(x)]
########################################

edges = []
ufG = UnionFind(N)
for _ in range(M):
    ai, bi = map(int, input().split())
    ai, bi = ai - 1, bi - 1
    edges.append((ai, bi))
    G[ai].append(bi)
    G[bi].append(ai)
    ufG.unite(ai, bi)

# 1本以外を入れたグラフを考える
count = 0
for m in range(M):
    ufGm = UnionFind(N)
    for k in range(M):
        if k == m:
            continue
        ai, bi = edges[k]
        ufGm.unite(ai, bi)

    flag = False
    for k in range(N):
        if ufGm.size(k) != ufG.size(k):
            flag = True
            break
    if flag:
        count += 1
print(count)

Measured memory_bytes: 74740
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
    using namespace std;
 
    int main(){
      string s;
      cin >> s;
      cout << 2018;
      REP(i,4,s.size()) cout << s[i];
      cout << endl;
      return 0;}

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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  
  int l = a + b;
  int r = c + d;

  if (l > r) {
    cout << "Left" << endl;
  } else if (l < r) {
    cout << "Right" << endl;
  } else {
    cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <iomanip>
#include <cstring>
#include <string.h>
#include <iterator>
#include <math.h>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <limits.h>
#include <string>
#include <bitset>
#include <map>
#include <numeric>
#include<unordered_map>


#define endl cout<<"\n"
#define lli long long int
#define ld long double
#define M_PI (3.14159265358979323846264338327950288)
#define MOD (10e9 + 7)

using namespace std;

//fast-exponentiation-lli
unsigned lli expo_fast(lli a, lli b) {
	a = a;
	lli result = 1;
	while (b) {
		//multiplyint(tos(result), a);
		if (b & 1)result = (result * a);
		b >>= 1;
		a = (a*a);
	}
	return (result);
}


void take_in(vector<lli> *arr) {
	for (int i = 0; i < arr->size(); i++)cin >> (*(arr))[i];
}


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

}

/* Iterative Function to calculate (x^y)%p in O(log y) */
unsigned lli power(lli x, unsigned lli y, lli p)
{
	lli res = 1;      // Initialize result 
	x = x % p;  // Update x if it is more than or equal to p 
	while (y > 0) {
		// If y is odd, multiply x with result 
		if (y & 1)res = (res*x) % p;
		// y must be even now 
		y = y >> 1;
		x = (x*x) % p;
	}
	return res;
}


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n,k; cin >> n>>k; vector<lli>arr(n+1);
	for (int i = 1; i <= n; i++)cin >> arr[i];
	vector<lli>dp(n + 1);
	dp[1] = 0;
	for (int i = 2; i <= n; i++) {
		lli x = LLONG_MAX;
		for (int j = i-1; j >= max(1, i - k); j--) {
			x = min(x, abs(arr[i] - arr[j]) + dp[j]);
		}
		dp[i] = x;
	}
	cout << dp[n];
	//system("PAUSE");
}

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

#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000

typedef long long LL;
typedef long double LD;

vector<vector<int>> e;
vector<vector<int>> re;
vector<pair<int,int>> num;
vector<int> aa;

int dfs(int x,int id){
  num[x].first=-2;
  for(auto nx:e[x]){
    if(num[nx].first==-1) id = dfs(nx, id);
  }
  num[x].first = id;
  id++;
  return id;
}

void dfs2(int x,int id){
  aa[x]=id;
  for(auto nx:re[x]){
    if(aa[nx]==-1) dfs2(nx,id);
  }
}

int main(){
  while(1){
    int n;
    cin >> n;
    if(n==0) return 0;
    e=vector<vector<int>>(n);
    re=vector<vector<int>>(n);
    vector<double> p(n);
    int m, a;
    for(int i=0;i<n;i++){
      cin >> p[i];
      cin >> m;
      for(int j=0;j<m;j++){
        cin >> a;
        a--;
        e[i].push_back(a);
        re[a].push_back(i);
      }
    }
    
    num=vector<pair<int,int>>(n);
    for(int i=0;i<n;i++) num[i]={-1,i};
    int id=0;
    for(int i=0;i<n;i++){
      if(num[i].first==-1) id = dfs(i, id);
    }
    sort(all(num),greater<pair<int,int>>());
    aa = vector<int>(n,-1);
    id=0;
    for(int i=0;i<n;i++){
      if(aa[num[i].second]==-1) dfs2(num[i].second,id++);
    }
    vector<bool> ok(id,true);
    vector<double> pr(id,1);
    for(int i=0;i<n;i++){
      for(auto nx:e[i]){
        if(aa[nx]!=aa[i]) ok[aa[nx]]=false;
      }
    }
    for(int i=0;i<n;i++){
      pr[aa[i]]*=p[i];
    }
    double ans=1;
    for(int i=0;i<id;i++){
      if(ok[i]) ans*=(1-pr[i]);
    }
    cout << fixed << setprecision(10) << ans << endl;
  }
  return 0;
}



Measured memory_bytes: 3352
#include<bits/stdc++.h>
using namespace std;
int n,a,k,res;
int mex(int a,int k)
{
	if(a%k==0)return a/k;
	else if(a<k)return 0;
	else return mex(a-(a/k+1)*ceil(1.0*(a-a/k*k)/(a/k+1)),k);
}
int main()
{
	scanf("%d",&n);
	while(n--)
	{
		scanf("%d%d",&a,&k);
		res^=mex(a,k);
	}
	if(res)puts("Takahashi");
	else puts("Aoki");
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
class Main{
	
	public static void main(String[] args) {
		Scanner Cf=new Scanner(System.in);
		int N=Cf.nextInt();
		int H=Cf.nextInt();
		int W=Cf.nextInt();
		
		int rows=N;
		int columns=N;
		
		int diffROWS=rows-H;
		int diffColumns=columns-W;
		
		diffROWS=diffROWS+1;
		diffColumns=diffColumns+1;
		System.out.println(diffColumns*diffROWS);
		
		
	}

}


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

int main() {
	int n,k,x;
	cin>>n>>k;
	int ans=0;
	for (int i=0;i<n;i++){
		cin>>x;
		ans+=min(abs(x-k),abs(0-x))*2;
	}
	cout<<ans;
	
	return 0;
}

Measured memory_bytes: 256
def translate(a):
    x = ['S', 'H', 'C', 'D', 0, 1, 2, 3]
    num = x.index(a)
    if num < 4:
        return x[num + 4]
    else:
        return x[num - 4]

        
card = [[0 for i in range(13)] for j in range(4)]
n = int(input())

for row in range(n):
    card_input = list(input().split())
    card[translate(card_input[0])][int(card_input[1]) - 1] = 1

for i in range(4):
    for j in range(13):
        if card[i][j] == 0:
            print(translate(i), j + 1)


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

lint mod = 1e+9 + 7;
string s;

int main() {
    cin >> s;
    int n = s.length();
    lint a = 0, ab = 0, abc = 0;
    lint pattern = 1;
    for (int i = 0; i < n; i++) {
        if (s[i] == 'A') {
            a = (a + pattern) % mod;
        } else if (s[i] == 'B') {
            ab = (ab + a) % mod;
        } else if (s[i] == 'C') {
            abc = (abc + ab) % mod;
        } else {
            abc = (ab + abc * 3) % mod;
            ab = (ab * 3 + a) % mod;
            a = (a * 3 + pattern) % mod;
            pattern = pattern * 3 % mod;
        }
    }
    cout << abc << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cctype>
#include <string>
#include <map>
#include <set>
#include <math.h>
#include <cmath>
#define ll long long

using namespace std;
using P = pair<int,int>;

int main(){

  int A, B, C, X, Y, Z;
  cin >> A >> B >> C >> X >>Y;
  int ans = 0;

  if(X > Y) Z = (X - Y)*A;
  else Z = (Y - X)*B;

  if(A+B < 2*C){
    cout << A*X+B*Y << endl;
  } else {
    int a = max(X, Y)*2*C;
    int b = min(X, Y)*2*C + Z;
    if(a > b) cout << b << endl;
    else cout << a << endl;
  }

  return 0;
}



Measured memory_bytes: 3568
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

int main() {
    int N;
    cin >> N;
    vector<ll> dishes(N);
    ll ans = 0;
    REP(i, N) {
        ll x, y;
        cin >> x >> y;
        ans -= y;
        dishes[i] = x + y;
    }

    sort(ALL(dishes));
    reverse(ALL(dishes));
    REP(i, N) {
        if(i%2 == 0) ans += dishes[i];
    }

    cout << ans << endl;

    return 0;
}

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

using namespace std;
#define ll long long
#define ld long double
#define f first
#define s second

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

    ll n,m,c=0,s=0;
    cin >> n >> m;
    ll a[n+2];
    for(int i=1; i<=n; i++)
    {
        cin >> a[i];
        s += a[i];
    }

    ld ss = (ld)1/(ld)4*m;

    for(int i=1; i<=n; i++)
    {
        if (a[i]*4*m >= s) c++;
    }

    if (c >= m) cout << "Yes\n";
    else cout << "No\n";

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<map>
#include<set>

using namespace std;

typedef long long ll;
typedef vector<int> VI;

#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR1(i,n) for(int (i)=1;(i)<(n);(i)++)
#define eFOR(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define eFOR1(i,n) for(int (i)=1;(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
constexpr auto INF = 1000000000;
constexpr auto LLINF = 9223372036854775807;
constexpr auto mod = 1000000007;

ll gcd(ll a, ll b) {
	while (1) {
		if (a < b) swap(a, b);
		if (!b) break;
		a %= b;
	}
	return a;
}

int main() {

	int n;
	cin >> n;
	bool zero = 0;
	int cnt = 0;
	ll mn = LLINF, sum = 0;
	FOR(i, n){
		ll b;
		cin >> b;
		if (b == 0)zero = 1;
		if (b < 0)cnt++;
		sum += abs(b);
		mn = min(mn, abs(b));
	}
	if (zero)cout << sum << endl;
	else if (cnt % 2 == 1)cout << sum - mn * 2 << endl;
	else cout << sum << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<lint>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

const int MAX_D = 10;

vec l;

void cut(string& s) {
    int c = 0;
    int n = s.size();
    rep(i, n) {
        if (s[i] == '0') c++;
        else break;
    }
    s.erase(0, c);
}

lint to_integer(string s) {
    lint res = 0;
    int n = s.size();
    lint t = 1;
    for (int i = n-1; i >= 0; i--) {
        int nd = s[i] - '0';
        res += nd * t;
        t *= 10;
    }
    return res;
}

void dfs(string s, bool f = false, int prev=-1) {
    if (s.size() == MAX_D) {
        cut(s);
        auto p = to_integer(s);
        if (p > 4000000000LL) return;
        l.push_back(to_integer(s));
    }
    else {
        rep(d, 10) {
            if (prev != -1) {
                if (abs(prev - d) > 1) {
                    continue;
                }
            }
            if (d != 0) dfs(s + to_string(d), true, d);
            else {
                if (f) dfs(s + to_string(d), f, 0);
                else dfs(s + to_string(d), f, -1);
            }
        }
    }
}

int main() {
    int k;
    cin >> k;

    dfs("");
    sort(all(l));

    cout << l[k] << endl;
    return 0;
}

Measured memory_bytes: 1400
import sys

input = sys.stdin.readline
n,k = map(int,input().split())
a = list(map(int,input().split()))

p = [1]
for i in range(n):
    p.append(a[p[i]-1])

if k <= n:
    print(p[k])
else:
    # 周期の来る前の回数
    num = p.index(p[-1])
    p = p[num:]

    # 周期
    pn = len(p)-1
    k -= num

    # 回数/周期のあまり
    ans = k%pn
    print(p[ans])

Measured memory_bytes: 100668
#include <iostream>
#include <map>

#define MOD 1000000007

typedef long long ll;

std::map<int, int> mp;

void prime_factorization(int m) {
    for (int i=2; i*i<=m; ++i) {
        while ( m%i == 0 ) {
            ++mp[i];
            m /= i;
        }
    }
    if (m != 1) ++mp[m];
}

ll solve(const int &n) {
    ll ans = 1;
    for (int i=1; i<=n; ++i) {
        prime_factorization( i );
    }
    std::map<int, int>::iterator itr = mp.begin();
    while (itr != mp.end()) {
        ans *= (ll) (itr->second + 1);
        ans %= MOD;
        ++itr;
    }
    return ans;
}

int main() {
    int n;
    std::cin >> n;
    std::cout << solve( n ) << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
struct EQ{
  float x;
  float y;
  float a;
};

float fy(struct EQ,struct EQ);
float fx(struct EQ,struct EQ);


int main(void){

  struct EQ eq1,eq2;
  float x,y;
 while(scanf("%f %f %f %f %f %f",&eq1.x,&eq1.y,&eq1.a,&eq2.x,&eq2.y,&eq2.a)!=EOF){
 
   y=fy(eq1,eq2);
   x=fx(eq1,eq2);
 printf("%0.3f %0.3f\n",x,y); 
 }
  return 0;
  }

float fy(struct EQ eq1,struct EQ eq2){

  float y,a,x;

  if(eq1.x==0 && eq1.a!=0){ 

    if(eq1.y<0){
      eq1.y=-eq1.y;
      eq1.a=-eq1.a;
    }
    y=eq1.a/eq1.y;
  }
 
  else if(eq2.x==0 && eq2.a!=0){ 

    if(eq2.y<0){
      eq2.y=-eq2.y;
      eq2.a=-eq2.a;
    }
    y=eq2.a/eq2.y;
  }
  else if(eq1.x==0 && eq1.a==0){  
    y=0;
  }
  else if(eq2.x==0 && eq2.a==0){
    y=0;
  }

  else{

  eq1.y=eq1.y/eq1.x;
  eq1.a=eq1.a/eq1.x;
 
  eq2.y=eq2.y/eq2.x;
  eq2.a=eq2.a/eq2.x;

   y=eq1.y-eq2.y;
  a=eq1.a-eq2.a;
  if(y<0){
    y=-y;
    a=-a;
  }

   y=a/y;

  if(y==-0){
    y=0;
  }


  }
  return y;

  }

float fx(struct EQ eq1,struct EQ eq2){

  float x,a;

  if(eq1.y==0 && eq1.a!=0){ 
    
    if(eq1.x<0){
      eq1.x=-eq1.x;
      eq1.a=-eq1.a;
    }
    x=eq1.a/eq1.x;
  }
  
  else if(eq2.y==0 && eq2.a!=0){ 
    
    if(eq2.x<0){
      eq2.x=-eq2.x;
      eq2.a=-eq2.a;
    }
    x=eq2.a/eq2.x;
  }
  else if(eq1.y==0 && eq1.a==0){  
    x=0;
  }
  else if(eq2.y==0 && eq2.a==0){
    x=0;
  }

  else{

  eq1.x=eq1.x/eq1.y;
  eq1.a=eq1.a/eq1.y;

  eq2.x=eq2.x/eq2.y;
  eq2.a=eq2.a/eq2.y;

  x=eq1.x-eq2.x;
  a=eq1.a-eq2.a;

  if(x<0){
    x=-x;
    a=-a;
  }
 
  x=a/x;

  if(x==-0){
    x=0;
  }

  }

  return x;

  }

Measured memory_bytes: 1076
#include <bits/stdc++.h>
using namespace std;
 
string S;
int N;
 
void input() {
    cin >> N;
    cin >> S;
}
 
void solve() {
    input();
    string tmp = "No";
    int K = N / 2;
    if(N % 2 == 0 && S.substr(0, K) == S.substr(K, K)) tmp = "Yes";
    cout << tmp << endl;
    return;
}
 
int main() {
    solve();
    return 0;
}

Measured memory_bytes: 256
N = int(input())
S = list(input())
Q = int(input())


#セグメント木
#次の2つの処理をO(log N)で実施することができる
# s, tが与えられた時、区間[s, t)の最小値を求める
# i, xが与えられた時、a_iの値をxに変更する

# INIT = 10 ** 18 #初期値 答えに関係ないもの
MAX_N = 10 ** 6 #与えられる要素数の最大

data = [0] * (2 * MAX_N - 1) #MAX_Nで初期化

#ここに機能をもたせる
def func(vl, vr):
    return (vl | vr)

def init(n_):
    #簡単のため要素数を2のべき乗に
    n = 1
    while n < n_:
        n *= 2
    return n

n = init(N)

def update(k, a): #k番目の値をaに変更 0-index
    # B[a] = k
    k += n - 1
    data[k] = (1 << a)
    while k > 0: #登りながら更新
        k = (k - 1)//2
        data[k] = func(data[k * 2 + 1], data[k * 2 + 2])

def query(a, b, k = 0, l = 0, r = n):
    if r <= a or b <= l:
        return 0
    if a <= l and r <= b:
        return data[k]
    else:
        vl = query(a, b, k * 2 + 1, l, (l + r)//2)
        vr = query(a, b, k * 2 + 2, (l + r)//2, r)
        return func(vl, vr)

def initialize(A): #リストAを与えて初期化する
    for i, a in enumerate(A):
        data[i + n - 1] = (1 << (ord(a) - 97))
        # B[a] = i
    for i in range((2 * n - 3)//2, -1, -1):
        data[i] = func(data[i * 2 + 1], data[i * 2 + 2])

# def index(a): #要素aがもとのどこに保存されているかを返す関数
#     return B[a]

# def value(index): #indexが与えられた時、index番目の値を得る
#     return data[index + n - 1]

#初期値の入力
initialize(S)

# print (data)

#クエリの数
# Q = int(input())
for _ in range(Q):
    a, b, c = map(str, input().split())
    if a == '1':
        update(int(b) - 1, (ord(c) - 97))
    else:
        tmp = query(int(b) - 1, int(c))
        count = 0
        for j in range(26):
            if (tmp >> j) & 1 == 1:
                count += 1
        # print (tmp)
        print (count)
# print (data)

Measured memory_bytes: 54824
#include <iostream>
#include <vector>
#include <unordered_set>
#include <numeric>
#include <unordered_map>

using namespace std;

vector<int> father;

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

void connect(int a, int b) {
	int ra = find(a);
	int rb = find(b);
	if (ra != rb) father[rb] = ra;
}

int main() {
	ios_base::sync_with_stdio(false);
	int n, m, k;
	cin>>n>>m>>k;
	father = vector<int>(n+1, 0);
	iota(father.begin(), father.end(), 0);
	vector<unordered_set<int>> fs(n+1);
	vector<unordered_set<int>> bl(n+1);
	for (int i = 0; i < m; i++) {
		int a, b;
		cin>>a>>b;
		fs[a].insert(b);
		fs[b].insert(a);
		connect(a, b);
	}
	for (int i = 0; i < k; i++) {
		int c, d;
		cin>>c>>d;
		bl[c].insert(d);
		bl[d].insert(c);
	}
	unordered_map<int, int> mp;
	for (int i = 1; i <= n; i++) {
		mp[find(i)]++;
	}
	for (int i = 1; i <= n; i++) {
		int res = mp[find(i)] - 1 - fs[i].size();
		for (auto &j : bl[i]) {
			if (find(j) == find(i)) {
				res--;
			}
		}
		cout<<res<<" ";
	}
	return 0;

}

Measured memory_bytes: 33316
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;
int q;
typedef long long LL;
LL LLsqrt(LL x){
    LL L=0,R=1e9,mid,ans=-1;
    while (L<=R){
        mid=(L+R)>>1;
        if (mid*mid<=x)
            L=mid+1,ans=mid;
        else
            R=mid-1;
    }
    return ans;
}
int main()
{
    long long a,b;
    scanf("%d",&q);
    while(q--)
    {
        long long ans=0;
        scanf("%lld%lld",&a,&b);
        long long c=a*b-1;
        long long p=LLsqrt(c);
        ans+=2*p;
        if(a!=b)
            ans--;
            if(p)
        if(p==c/p)
            ans--;
        printf("%lld\n",ans);
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n, r;
  cin >> n >> r;
  if(n < 10){
    r += 100 * (10 - n);
  }
  cout << r << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n,k;
	cin>>n>>k;
	int a[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	bool dp[k+1]={false};
	for(int i=0;i<=k;i++)
	{
		for(int j=0;j<n;j++)
		{
			if(i>=a[j]&&dp[i-a[j]]==0)
			{
				dp[i]=1;
				break;
			}
		}
	}
	if(dp[k])
	{
		cout<<"First";
		return 0;
	}
	cout<<"Second";
	return 0;
}

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

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

    if(a+W < b)
        cout << b-a-W;
    else if(b+W < a)
        cout << a-b-W;
    else
        cout << 0;
    cout << endl;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
ops = [list(map(lambda x: int(x) - 1, input().split())) for i in range(M)]

# num[i]: 箱iに入っているボールの数
# flg[i]: 箱iに赤いボールが入っている可能性があるかどうか
num = [1] * N
flg = [True] + [False] * (N - 1)

for x, y in ops:
    num[y] += 1
    if flg[x]:
        flg[y] = True

    num[x] -= 1
    if num[x] == 0:
        flg[x] = False

print(flg.count(True))


Measured memory_bytes: 29732
#include <iostream>

using namespace std;

char f(char x, char y) {
    if (x < y) {
        return '<';
    } else if (x > y) {
        return '>';
    }
    return '=';
}

int main() {

    char x, y;
    cin >> x >> y;

    char result = f(x, y);
    cout << result << endl;

    return 0;
}


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

using namespace std; 

string solve(string str){
	if(str[0] != 'A')
		return "WA";

	int count = 0; 
	int index = 0; 

	for(int i = 2; i < str.size()-1; i++){
		if(str[i] == 'C'){
			count++; 
			index = i; 
		}
	}
	if(count != 1){
		return "WA"; 
	}
	for(int i = 1; i < str.size(); i++){
		if(i != index && str[i] >= 'A' && str[i] <= 'Z'){
			return "WA"; 
		}
	}
	return "AC"; 
}


int main(){
 
 	string s; 
 	getline(cin,s); 
	cout << solve(s) << endl; 
	return 0;
}


Measured memory_bytes: 256