akhauriyash/Code-Regression huggingface dataset:
/*
 　　　　　／＞　 フ
 　　　　　| 　_　 _|
 　 　　　／`ミ _x 彡
 　　 　 /　　　 　 |
 　　　 /　  ヽ　　 ?
 　／￣|　　 |　|　|
 　| (￣ヽ＿_ヽ_)_)
 　＼二つ
  */

#include <queue>
#include <vector>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define MP make_pair
#define ll long long
#define fi first
#define se second
using namespace std;

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

template<typename F>
inline void write(F x, char ed = '\n') {
    static short st[30];short tp=0;
    if(x<0) putchar('-'),x=-x;
    do st[++tp]=x%10,x/=10; while(x);
    while(tp) putchar('0'|st[tp--]);
    putchar(ed);
}

template <typename T>
inline void Mx(T &x, T y) { x < y && (x = y); }

template <typename T>
inline void Mn(T &x, T y) { x > y && (x = y); }

const int N = 2005;
ll len[N], x[N], y[N], cnt, n;
inline ll jue(ll x) { return x > 0 ? x : -x; }
int main() {
    read(n);
    for (int i = 1;i <= n; i++) {
        read(x[i]), read(y[i]);
        int t = (x[i] + y[i]) & 1;
        t ^= (x[1] + y[1]) & 1;
        if (t) { puts("-1"); return 0; }
    }
    if (!((x[1] + y[1]) & 1)) len[++cnt] = 1;
    write(cnt + 33);
    for (int i = 0;i <= 32; i++) len[++cnt] = 1ll << i;
    for (int i = cnt;i ; i--) write(len[i], ' ');
    puts("");
    for (int i = 1;i <= n; i++) {
        ll dx = 0, dy = 0;
        for (int j = cnt;j >= 1; j--) {
            ll tx = jue(x[i] - dx), ty = jue(y[i] - dy);
            if (tx >= ty) {
                if (x[i] > dx) { putchar('R'); dx += len[j]; }
                else { putchar('L'); dx -= len[j]; }
            }
            else {
                if (y[i] > dy) { putchar('U'); dy += len[j]; }
                else { putchar('D'); dy -= len[j]; }
            }
        }
        puts("");
    }
    return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
 
int main(){
 long long  int a,count;
 count=0;
 cin>>a;
 int i=1;
 while(i<a-i){
  if(a<=a-i){
    break;
  }
  if(a!=a-i){
    count++;
  }
  i++;
 }
 cout<<count<<endl;
}




Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<cfloat>
#include<functional>
#include<map>
#include<string>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<deque>
#include<set>
#include<bitset>
#include<list>
#include<numeric>
#include<complex>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<long long, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<long long, long long> ll_ll;
typedef pair<double, double> d_d;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define rep2d(i, j, n) for(i = 0;i < n;++i)for(j = i + 1;j < n;++j)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define scn(n, a) rep(i, n)cin >> a[i]
#define sc2n(n, a, b) rep(i, n)cin >> a[i] >> b[i]
#define pri(x) cout << x << "\n"
#define pri2(x, y) cout << x << " " << y << "\n"
#define pri3(x, y, z) cout << x << " " << y << " " << z << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define endl "\n"
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << x << "\n"
#define debug2(x, y) cout << " --- " << x << " " << y << "\n"
#define debug3(x, y, z) cout << " --- " << x << " " << y << " " << z << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)

vector<string> inp;

int nex(int t, int l, int sp){
  int res = 0;
  for(int i = l;i < sp;++i)res = 10 * res + (int)(inp[t][i] - '0');
  return res;
}

signed main(void){
  int i, j, k;
  for(int testcase = 0;testcase < 1234567;testcase++){
    for(k = 0;;k++){
      string tmp;
      if(!getline(cin, tmp))break;
      tmp += ",";
      inp.pb(tmp);
    }

    int f[100][100] = {0}, t, x = 0;
    rep(t, k){
      if(t > k / 2)++x;
      int cnt = x;
      for(int sp = 0;sp < inp[t].size();){
        int l = sp;
        for(;;)if(inp[t][++sp] == ',')break;
        f[cnt][t - cnt] = nex(t, l, sp);
        cnt++;
        sp++; l = sp;
      }
    }

    rep1(i, 100){
      f[i][0] += f[i - 1][0];
      f[0][i] += f[0][i - 1];
    }
    rep1(i, 100)rep1(j, 100)f[i][j] += max(f[i - 1][j], f[i][j - 1]);

    pri(f[99][99]);

/*/

//*/ break;
  }
  return 0;
}

Measured memory_bytes: 1248
import math

x = int(input())

def is_prime(n):
    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False
    return True

for i in range(x, 100004):
    prime = is_prime(i)
    if prime:
        print(i)
        exit()

Measured memory_bytes: 38896
from decimal import *
import math
A, B, H, M = map(int, input().split())

# 分に変換
mi = H * 60 + M
# 角度
b = Decimal(360 * M) / Decimal(60)
a = Decimal(360 * mi) / Decimal(720)

t = math.radians(max(a, b) - min(a, b))
t = math.cos(t)
print(math.sqrt(Decimal(A**2)+Decimal(B**2)-Decimal(2*A*B*t)))


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

int main(){
    int n, y;
    cin>>n>>y;
    int a=-1;
    int b=-1;
    int c=-1;
    for(int i=0; i<=n; i++){
        for(int j=0;j<=n-i;j++){
            if(10000*i+5000*j+1000*(n-i-j)==y){
                a=i;
                b=j;
                c=n-i-j;
                break;
            }
        }
    }
    cout<<a<<" "<<b<<" "<<c<<endl;
}


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

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

  const vector<int> di = {-1, -1, -1, 0, 0, 1, 1, 1};
  const vector<int> dj = {-1, 0, 1, -1, 1, -1, 0, 1};

  int h, w;
  cin >> h >> w;

  vector<string> sv(h);
  for (int i = 0; i < h; i++) {
    cin >> sv.at(i);
  }

  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (sv.at(i).at(j) == '#') continue;

      // count bombs
      int num = 0;
      for (int d = 0; d < 8; d++) {
        int x = i + di.at(d);
        int y = j + dj.at(d);

        if (x < 0 || x >= h) continue;
        if (y < 0 || y >= w) continue;
        if (sv.at(x).at(y) == '#') num++;
      }

      sv.at(i).at(j) = num + '0';
    }
  }

  for (int i = 0; i < h; i++) {
    cout << sv.at(i) << endl;
  }

  return 0;
}

Measured memory_bytes: 256
//                          VIVEK UPADHYAY
//                          MANIT, BHOPAL(M.P)
/**********************************************************************************************/
/**********************************************************************************************/
//                        $$ JAB-TAK TODEGA NHI,
//                           TAB -TAK CHODEGA NHI :D

// g++ -std=c++11 file_name.cpp
// ./file_name.out
#include<iostream>
#include<algorithm>
#include<vector>
#include<list>
#include<cstdlib>
#include<unistd.h>
#include<string>
#include<cstring>
#include<stack>
#include<queue>
#include<utility>
#include<cmath>
#include<set>
#include<unordered_map>
#include<cstdio>
#include<map>
#include<numeric>
using namespace std;
#define F first
#define S second
#define mk(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define LINE cout<<"\n" ;
#define ok cout<<"ok\n" ;
#define dbg(x) cout<<#x<<" = "<<(x)<<"\n";
#define fill(A, VAL) memset(A, VAL, sizeof(A))
#define sz(a) ((int) a.size())
typedef long long ll ;
const int MAXN = 5*1e5 + 10;
ll inf  = 1e18 ;
using namespace std ;
int main () {
    string s ;
    cin >> s ;
    int c =0 ;
    for(int i =0 ;i < s.length() ;i++)
        if(s[i]=='o') c++ ;
    int len = 15 - s.length() ;
    if(c + len >= 8) cout<<"YES\n" ;
    else cout<<"NO\n" ;
    return 0 ;
}


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

#define li long long int
#define rep(i, to) for (li i = 0; i < ((li)(to)); i++)


li n, k;

inline li calc(li x) {
	return min(x * 2, x + k);
}

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

	li res = 1;
	rep(i, n) {
		res = calc(res);
	}
	cout << res << endl;

	return 0;
}

Measured memory_bytes: 256
use std::io::stdin;
use std::str::FromStr;
#[allow(dead_code, unused_mut)]
fn read<T: FromStr>() -> T {
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    s.trim().parse().ok().expect("1")
}
#[allow(dead_code, unused_mut)]
fn read_vec<T: FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().expect("2"))
        .collect()
}
#[allow(dead_code, unused_mut)]
fn read_two<T: FromStr>() -> (T, T) {
    let mut s = String::new();
    stdin().read_line(&mut s).unwrap();
    let mut x = s.split_whitespace().map(|x| x.parse().ok().unwrap());
    (x.next().unwrap(), x.next().unwrap())
}
#[allow(dead_code, unused_mut)]
fn read_three<T: FromStr>() -> (T, T, T) {
    let mut s = String::new();
    stdin().read_line(&mut s).unwrap();
    let mut x = s.split_whitespace().map(|x| x.parse().ok().unwrap());
    (x.next().unwrap(), x.next().unwrap(), x.next().unwrap())
}
#[allow(dead_code)]
fn remove_whitespace(s: &str) -> String {
    s.chars().filter(|c| !c.is_whitespace()).collect()
}

#[allow(unused_imports)]
use std::io::{stdout, Write};
#[allow(unused_imports)]
use std::collections::HashMap;
fn gcd(mut x: u64, mut y: u64) -> u64 {
    let mut z = x;
    let mut gcd_num = x;
    while z != 0 {
        gcd_num = z;
        z = y % x;
        y = x;
        x = z;
    }
    gcd_num
}
fn main() {
    let k:i32 = read();
    let (a, b) = read_two::<i32>();
    if a / k != b / k || a % k == 0 || b % k == 0 {
        println!("OK");
    } else {
        println!("NG");
    }

}


Measured memory_bytes: 2088
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=605,p=1000000007;
int read(){
	int f=1,g=0;char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') f=-1;
	for (;isdigit(ch);ch=getchar()) g=g*10+ch-'0';
	return f*g;
}
int n,K,ans,a[N],s[N][N],f[N][N],g[N];
void check(int &x,int y){if ((x+=y)>=p) x-=p;}
int main(){
	n=read()*2;K=read();
	for (int i=1;i<=n;i++) a[i]=i;
	for (int i=1;i<=K;i++){
		int u=read(),v=read();
		a[u]=v;a[v]=u;
	}
	g[0]=1;
	for (int i=2;i<=n;i++) g[i]=(ll)g[i-2]*(i-1)%p;
	for (int i=1;i<=n;i++)
	for (int j=i;j<=n;j++)
	s[i][j]=s[i][j-1]+(a[j]==j);
	for (int i=n;i;i--)
	for (int j=i+1;j<=n;j+=2){
		int fl=1;
		for (int k=i;k<=j;k++)
		fl&=(i<=a[k])&&(a[k]<=j);
		if (!fl){f[i][j]=0;continue;}
		f[i][j]=g[s[i][j]];
		for (int k=i+1;k<j;k+=2)
		check(f[i][j],p-(ll)f[i][k]*g[s[k+1][j]]%p);
	}
	for (int i=1;i<=n;i++)
	for (int j=i+1;j<=n;j+=2)
	check(ans,(ll)f[i][j]*g[s[1][i-1]+s[j+1][n]]%p);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int INF = 0x7fffffff;
const int tINF = INF>>2;
const ll LINF = 0x7fffffffffffffff;
const ll tLINF = LINF>>2;
const int maxn = 1e5;
const int modn = 1e9+7;

int a[maxn+10];
struct ifo{
    int x,y;
    bool operator< (const ifo &tmp)const{
        return x>tmp.x;
    }
};
vector<ifo> cc;

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

	int n, m;
	cin>>n>>m;
	for (int i=1; i<=maxn+5; ++i){
        a[i] = INF;
	}
	for (int i=1; i<=n; ++i){
        cin>>a[i];
	}
	sort(a+1, a+n+1);
	int b,c;
	while (m--){
        cin>>b>>c;
        cc.push_back({c,b});
	}
	sort(cc.begin(), cc.end());
	int p=1;
	for (auto it=cc.begin(); it!=cc.end(); ++it){
        if (a[p] >= (*it).x) break;
        while ((*it).y--){
            if (a[p] < (*it).x){
                a[p] = (*it).x;
                p++;
            }
        }
	}
	ll ans=0;
	for (int i=1; i<=n; ++i){
        ans += a[i];
	}
	cout<<ans<<endl;

	return 0;
}


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

namespace atcoder
{
	class Program
	{
		static int In => int.Parse(Console.ReadLine());
		static int[] Ins => Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
		static void Out(bool b) => Console.WriteLine(b ? "Yes" : "No");

		static void Main(string[] args)
		{
			var str = Console.ReadLine();
			int t = str.Length - 1;
			int ans = 0;
			for (int i = 0;i < str.Length && i <= t;i++)
			{
				if (str[i] == str[t])
				{
					t--;
					continue;
				}
				else if(str[i] == 'x' || str[t] == 'x')
				{
					ans++;
					if (str[t] == 'x')
					{
						i--;
						t--;
					}
				}
				else
				{
					ans = -1;
					break;
				}
			}
			Console.WriteLine(ans);
			//Console.ReadLine();
		}
	}
}

Measured memory_bytes: 13116
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	final static long MOD = 1000000007;
	public static void main(String[] args) throws Exception {
		// TODO 自動生成されたメソッド・スタブ

		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String W = in.readLine();

		String[] Ws = W.split(" ");
		long N = Long.parseLong(Ws[0]);
		long K = Long.parseLong(Ws[1]);


		long ans = N%K;
		ans = Math.min(ans, Math.abs(K-ans));
		System.out.println(ans);

	}
}


Measured memory_bytes: 20692
import java.util.*;

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

	public String parse(int t){
		return String.format("%02d:%02d:%02d",t/3600,(t%3600)/60,t%60);
	}

	public void run() {
		while(true){
			int h=sc.nextInt(),m=sc.nextInt(),s=sc.nextInt();
			if(h==-1 && m==-1 && s==-1)break;
			int rest=7200-h*3600-m*60-s;
			ln(parse(rest));
			ln(parse(3*rest));
		}

	}

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

	public static void pr(Object o) {
		System.out.print(o);
	}

	public static void ln(Object o) {
		System.out.println(o);
	}

	public static void ln() {
		System.out.println();
	}
}

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

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
string S;
cin>>S;
sort(S.begin(),S.end());
if(S[0]==S[1] &&
   S[1]!=S[2] &&
   S[2]==S[3]) cout<<"Yes"<<endl;
else cout<<"No"<<endl;

//system("pause");
return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define UNIQUE(v) { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); }
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) { cerr << "[DEBUG] " #q ": ["; REP(i, (q).size()) { cerr << (q)[i] << (i == i_len-1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; }
template<class T> T gcd(const T &a, const T &b) { return a < b ? gcd(b, a) : b ? gcd(b, a % b) : a; }
template<class T> T lcm(const T &a, const T &b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
#define CHOKUDAI_ const
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using cll = DANCE_ DANCE_ CHOKUDAI_;
using  ld = long double;
using namespace std;

// モジュール

// 処理内容
int main() {

    ll n; scanf("%lld", &n);

    RANGE(i, 0, n-2) RANGE(j, i+1, n-1) {
        ll d = i ^ j;
        ll ans = 0; for (ll l = d & -d; l; ans++) l >>= 1;
        printf("%lld%c", ans, " \n"[j==n-1]);
    }
    
}

Measured memory_bytes: 512
#include <algorithm> //STLͨ���㷨
#include <cmath> //������ѧ����
#include <cstdio> //��������/�������
#include <iostream> //����������/���
#include <cstring> //�ַ�������
#include <string> //�ַ�����
#define itn int
#define fro for
#define ll long long
#define reg register
#define inf 1234567890
#define rep(i,a,b,c) for (int i=a;i<=b;i+=c)
/*#include <bitset> //STLλ������
#include <cstype> //�ַ�����
#include <cerrno> //���������
#include <complex> //������
#include <clocale> //���屾�ػ�����
#include <cstdlib> //������������ڴ���亯��
#include <deque> //STL˫�˶�������
#include <exception> //�쳣������
#include <fstream> //�ļ�����/���
#include <functional> //STL�������㺯��(���������)
#include <limits> //�����������������ֵ����
#include <list> //STL�����б�����
#include <map> //STLӳ������
#include <iomanip> //����������/���
#include <ios> //��������/���֧��
#include <iosfwd> //����/���ϵͳʹ�õ�ǰ������
#include <istream> //����������
#include <ostream> //���������
#include <queue> //STL��������
#include <set> //STL��������
#include <sstream> //�����ַ�������
#include <stack> //STL��ջ����
#include <stdexcept> //��׼�쳣��
#include <streambuf> //�ײ�����/���֧��
#include <utility> //STLͨ��ģ����
#include <vector> //STL��̬��������
#include <cwchar.h>//���ַ�����������/���
#include <cwctype.h> //���ַ�����*/

using namespace std;

int ans;

int max(int x,int y){return x>y?x:y;}

int min(int x,int y){return x<y?x:y;}

int abs(int x){return x>0?x:-x;}

int gcd(int x,int y){return (!y)?x:gcd(y,x%y);}

void exgcd(int a,int b,int &d,int &x,int &y){if (!b){d=a,x=1,y=0;}else{exgcd(b,a%b,d,y,x);y-=x*(a/b);}}

int quick_power(ll a,int b){ll r=1;for (;b;b>>=1,a=a*a)if (b&1) r=r*a;return r;}

inline char read() {
	static const int IN_LEN = 1000000;
	static char buf[IN_LEN], *s, *t;
	return (s == t ? t = (s = buf) + fread(buf, 1, IN_LEN, stdin), (s == t ? -1 : *s++) : *s++);
}
template<class T>
inline void read(T &x) {
	static bool iosig;
	static char c;
	for (iosig = false, c = read(); !isdigit(c); c = read()) {
		if (c == '-') iosig = true;
		if (c == -1) return;
	}
	for (x = 0; isdigit(c); c = read()) x = x * 10 + (c ^ '0');
	if (iosig) x = -x;
}

char sr[10000000],z[20];int C=-1,Z=0;
void Ot(){fwrite(sr,1,C+1,stdout),C=-1;}
void print(int x){
	if (x<0) sr[++C]='-',x=-x;
    while(z[++Z]=x%10+48,x/=10);
    while(sr[++C]=z[Z],--Z);sr[++C]='\n';
}
//int find(int x){return fa[x]=fa[x]==x?x:find(fa[x]);}

//void add(int x,int y,int z){to[++cnt]=y;v[cnt]=z;Next[cnt]=head[x];head[x]=cnt;}
int a[128],tong[128],pre[128],du[128],sta[128],top=0;
int main()
{
	int n;read(n);
	for (int i=1;i<=n;i++) read(a[i]);
	for (;a[1];)
	{
		int flag=1;
		for (int i=n;i;i--)
			if (a[i]==i)
			{
				flag=0;
				sta[++top]=a[i];
				for (int j=i;j<=n;j++) a[j]=a[j+1];
				i=n;
			}
//		for (int j=1;j<=n;j++) cout<<a[j];cout<<endl;
		if (flag) return puts("-1"),0;
	}
	for (;top;top--) print(sta[top]);
	Ot();
	return 0;
}









Measured memory_bytes: 2432
program sample
    implicit none
  
    integer(8) :: i,j,m,n,a
    integer(8),allocatable :: x(:),y(:)
  
    read(*,*) n
    allocate(x(n))
    read(*,*)x
    m=0
    do i=1,n
        a=x(i)
        if(x(a)==i)then
            m=m+1
        end if
    end do
    write(*,*) m/2
  
    stop
end program sample
  



Measured memory_bytes: 3804
N = int(input())
A = list(map(int,input().split()))
m = [1] * N
for i in range(0,len(A)):
    for j in range(0,len(A)):
        if i == j:
            continue
        else:
            m[i] *= A[j] 
print(m[0]*A[0]/sum(m))

Measured memory_bytes: 9068
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
#include <cstdint>
using namespace std;
using LL = long long;

int main() {
	int N;
	vector<LL>vec;
	cin >> N;
	LL top = 0;
	for (int i = 0; i < N; ++i) {
		LL tmp; cin >> tmp; vec.push_back(tmp);
		top += tmp * (i % 2 == 0 ? 1LL : -1LL);
	}
	top /= 2;
	vector<int>ans;
	ans.push_back(top);
	for (int i = 1; i < N; ++i) {
		ans.push_back(vec[i - 1] - ans.back());
	}
	for (int i = 0; i < N; ++i) {
		cout << ans[i] * 2 << " \n"[i == N - 1];
	}
	return 0;
}

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef pair<double, double> pdd;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
//const int mod = ;

int main() {
  std::ios::sync_with_stdio(false); std::cin.tie(0);
  int n;
  cin >> n;
  ++n;
  vi x(n), y(n), t(n);
  for (int i = 1; i < n; ++i) {
    cin >> t[i] >> y[i] >> x[i];
  }
  bool fail = 0;
  for (int i = 0; i + 1 < n; ++i) {
    int dx = abs(x[i+1]-x[i]) + abs(y[i+1]-y[i]);
    int dt = t[i+1] - t[i];
    if (dt < dx || dt % 2 != dx % 2) {
      fail = 1;
    }
  }
  if (fail) cout << "No\n";
  else cout << "Yes\n";
  return 0;
}

Measured memory_bytes: 1408
//#include <bits/stdc++.h>
#include <iostream>
#include <climits>

using namespace std;

#define rep(i , n) for(int i=0 ; i<n ; i++)
#define rep1(i , n) for(int i=1 ; i<=n ; i++)

typedef long long int ll;


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

	int n,l;
	int arr[2001];
	cin >> n >> l;

	for(int i=1 ; i<=n ; i++)
		arr[i] = l+i-1;

	int sum = 0;
	for(int i=1 ; i<=n ; i++)
		sum += arr[i];

	int minDiff = INT_MAX;
	int ans = -1;
	for(int i=1 ; i<=n ; i++)
	{
		if(abs(sum-(sum-arr[i]) ) < minDiff)
		{
		    minDiff = abs(sum-(sum-arr[i]));
		    ans = sum-arr[i];
		}
	}

	cout << ans;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
dia = []
for _ in range(N-1):
    dia.append(list(map(int, input().split())))

def to_next(start_time, sta):
    
    time = 0
    if dia[sta][1] > start_time:
        time += dia[sta][1] - start_time
    elif start_time % dia[sta][2] != 0:
        time += dia[sta][2] * (start_time // dia[sta][2] + 1) - start_time
    time += dia[sta][0]
    return time

def to_end(sta):
    time = 0
    while sta != N-1:
        time += to_next(time, sta)
        sta += 1
    return time
for i in range(N - 1):
    print(to_end(i))
print(0)

Measured memory_bytes: 3188
#include <stdio.h>

int main(void) {
  char str[3];
  int i;
  int ans = 700;
  scanf("%s", str);
  for (i = 0; i < 3; i++) {
    if (str[i] == 'o') ans += 100;
  }
  printf("%d\n", ans);
  return 0;
}



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

int main()
{
    int c[3][3], flag = 0;
    for (int i = 0; i < 3; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            cin >> c[i][j];
        }
    }

    if (c[0][0] - c[0][2] == c[1][0] - c[1][2] && c[1][0] - c[1][2] == c[2][0] - c[2][2] && c[0][0] - c[0][1] == c[1][0] - c[1][1] && c[1][0] - c[1][1] == c[2][0] - c[2][1])
    {
        flag = 1;
    }

    if (flag == 1)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;
const int INF = 0x3f3f3f3f;

struct Node{
	int key;
	Node *p, *l, *r;
};

Node *root, *NIL;

void insert(int key){
	Node *y = NIL;
	Node *x = root;
	Node *z;

	z = (Node *)malloc(sizeof(Node));
	z->key = key;
	z->l = NIL;
	z->r = NIL;

	while(x != NIL){
		y = x;
		if(z->key < x->key)		x = x->l;
		else	x = x->r;
	}

	z->p = y;
	if(y == NIL)
		root = z;
	else{
		if(z->key < y->key)		y->l = z;
		else	y->r = z;
	}
}

void preParse(Node *u){
	if(u == NIL)	return;
	cout << " " << u->key;
	preParse(u->l);
	preParse(u->r);
}

void inParse(Node *u){
	if(u == NIL)	return;
	inParse(u->l);
	cout << " " << u->key;
	inParse(u->r);
}

Node * find(Node *u, int key){
	while(u != NIL && key != u->key){
		if(key < u->key)	u = u->l;
		else	u = u->r;
	}
	return u;
}

int main(){
	int n, temp;
	char s[10];
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> s;
		if(s[0] == 'i'){
			cin >> temp;
			insert(temp);
		}
		else if(s[0] == 'f'){
			cin >> temp;
			Node *flag = find(root, temp);
			if(flag != NIL)	cout << "yes" << endl;
			else	cout << "no" << endl;
		}
		else{
			inParse(root);
			cout << endl;
			preParse(root);
			cout << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 21832
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define mp              make_pair
#define pb              push_back
#define all(a)          (a).begin(), (a).end()
#define sz(a)           a.size()
#define srt(a)          sort(all(a))
#define mem(a, h)       memset(a, (h), sizeof(a))
#define F               first
#define S               second
#define forr(i, b, e)   for(ll i = b; i < e; i++)
#define forg(i, b, e, m)    for(ll i = b; i < e; i+=m)
//ll in(){ll r=0,c;for(c=getchar();c<=32;c=getchar());if(c=='-') return -in();for(;c>32;r=(r<<1)+(r<<3)+c-'0',c=getchar());return r;}
 
using namespace std;
//using namespace __gnu_pbds;
 
typedef long long       ll;
typedef unsigned long long      ull;
typedef pair<ll, ll>  ii;
typedef vector<ll>     vi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
//find_by_order kth largest  order_of_key <
const ll tam = 3000020;
const ll MOD = 1e9+7;
const ll MOD1 = 988244535;
const double EPS = 1e-9;
const double PI = acos(-1);
#define offset 1000020
#define forite(it,a,b) for(auto it=a;it!=b;it++)

int main()
{
    ios::sync_with_stdio(0); cin.tie(0);
    int n;
    cin>>n;
    int lasti=0;
    for(int i=1;i*(i+1)/2<n;i++)
    {
        lasti=i;
    }    
    cout<<lasti+1<<endl;
}   
// read the question correctly (is y a vowel? what are the exact constralls?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs ll?) ARRAY OUT OF BOUNDS

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
    int R;
    cin >> R;
    if (R < 1200)
    {
        cout << "ABC";
    }
    else if (R < 2800)
    {
        cout << "ARC";
    }
    else
    {
        cout << "AGC";
    }
}

Measured memory_bytes: 504
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vii = vector<vi>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
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; }

int main(){
  string s;
  cin >> s;
  string t;
  rep(i,sz(s)){
    if(s[i]=='0'){
      t.pb('0');
    }
    else if(s[i]=='1'){
      t.pb('1');
    }
    else if(s[i]=='B'&&sz(t)>0){
      t.erase(sz(t) - 1);
    }
  }
  print(t);
}

Measured memory_bytes: 256
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
#include <iostream>
#include <sstream>
#include <set>
using namespace std;

int main()
{
  int n, m;
  cin >> n >> m;
  vector<int> A(m);
  vector<int> odd_idx;
  for (int i=0; i<m; i++) {
    cin >> A[i];
    if (A[i] % 2) odd_idx.push_back(i);
  }
  int odd_cnt = odd_idx.size();
  if (odd_cnt > 2) {
    cout << "Impossible" << endl;
    return 0;
  }
  if (odd_cnt >= 1) swap(A[0], A[odd_idx[0]]);
  for (int i=1; i<m; i++)
    if (A[i] % 2) swap(A[i], A[m-1]);

  for (int i=0; i<m; i++)
    cout << A[i] << " ";
  cout << endl;

  if (A.size() == 1) {
    A.push_back(1);
    A[0] --;
  } else {
    A[0] ++;
    A[m-1] --;
  }

  int st = 0;
  int fi = A.size()-1;
  int cnt = A.size();
  if (!A[st]) { st ++; cnt --; }
  if (!A[fi]) { fi --; cnt --; }
  cout << cnt << endl;
  for (int i=st; i<=fi; i++)
    cout << A[i] << " ";
  cout << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(a) (a).begin(), (a).end()
typedef vector<int> vi;
const int INF = 1LL << 60; //10e18+10e17ちょっとくらい
const int MOD = 1000000007;
const int MAX_N = 200100;

int mp[10000001];
signed main()
{
    //  以降 cin の入力元が 'input.txt' になる
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());jo
    rep(i, 10000000)
    {
        int idx = i + 1;
        while (idx <= 10000000)
        {
            mp[idx]++;
            idx += i + 1;
        }
    }
    int n;
    cin >> n;
    int ans = 0;
    rep(i, n)
    {
        ans += ((i + 1) * mp[i + 1]);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 81748
import java.util.*;
 
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    String[] str = new String[N];
    Set<String> set = new HashSet<>();
    for (int i = 0; i < N; i++) {
      str[i] = sc.next();
      set.add(str[i]);
    }
    for (int i = 1; i < N; i++) {
      if (str[i].charAt(0) != str[i - 1].charAt(str[i - 1].length() - 1)) {
        System.out.println("No");
        return;
      }
    }
    if(set.size() == N){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}
    

Measured memory_bytes: 35936
/**
 * THIS IS MOOONI'S CODE !
 * HACK IT IF YOU CAN !
**/
#include <bits/stdc++.h>
 
using namespace std;

template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

//#define LOCAL 
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  long long ans = 0;
  for (int i = 0; i <= n; i++) {
    ans += (i % 3 != 0 && i % 5 != 0 ? i : 0);
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3612
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll K, X;
  cin >> K >> X;
  for (int i = X - K + 1; i < X + K; i++) {
    cout << i << " ";
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 3576
import math

A, B = map(int, input().split())

minA = math.ceil(A / 0.08)
minB = math.ceil(B / 0.1)
small = min(minA, minB)
large = max(minA, minB)

#print (minA,minB)

for i in range(small, large+1):
    if (math.floor(i * 0.08) == A and math.floor(i * 0.1) == B):
        print (i)
        exit(0)
print ("-1")


Measured memory_bytes: 3060
A="abcdefghijklmnopqrstuvwxyz"
S=input()
S=sorted(set(S))

for i in range(len(S)):
	if S[i]!=A[i]:
		print(A[i])
		exit()
if len(S)<len(A):
	print(A[len(S)])
	exit()
print("None")

Measured memory_bytes: 9152
import numpy as np

N, K = map(int, input().split(' '))
A = tuple(map(int, input().split(' ')))
indexes = np.arange(0, N)

dp = np.zeros(shape=N + 1, dtype=np.int64)

for k in range(K):
    np.add.at(dp, np.maximum(0, indexes - A), 1)
    np.add.at(dp, np.minimum(N, indexes + A + 1), -1)
    A = dp.cumsum()[:-1]
    if np.all(A == N):
        break
    dp *= 0

print(' '.join(map(str, A)))


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

#define TRACE(x) cerr << #x << " :: " << x << endl
#define _ << " " <<
#define SZ(x) (int)(x).size()
#define ALL(x) (x).begin(),(x).end()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define RFOR(i,a,b) for (int i=(a);i>=(b);--i)
using ll=long long;

const int mxN = 2e5+5;
const int mxH = 1e6+5;
const ll inf = 1e18;

int N, H[mxN];
ll C;

ll dp[mxN];

struct Line {
	ll m, c;
	ll eval(int x) {
		return m*x + c;
	}
};

struct node {
	int s, e, m; // [s,e)
	Line v;
	node *l, *r;
	node(int s, int e): s(s), e(e), m((s+e)/2) {
		v = { 0, inf };
		if (s+1 != e) {
			l = new node(s,m);
			r = new node(m,e);
		}
	}
	
	void update(Line a) {
		bool lef = a.eval(s) < v.eval(s);
		bool mid = a.eval(m) < v.eval(m);
		if (mid) swap(v,a);
		
		if (s+1 == e) return;
		else if (lef != mid) l->update(a);
		else r->update(a);
	}
	
	ll query(int a) {
		if (s+1 == e) return v.eval(a);
		else return min(v.eval(a), (a < m ? l : r)->query(a));
	}
} lct(1,mxH);

int main() {
	//freopen("in.txt","r",stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    cin >> N >> C;
    FOR(i,1,N) { cin >> H[i]; }

	dp[1] = 0;
	lct.update({ -2*H[1], (ll)H[1]*H[1] });
	FOR(i,2,N){
		dp[i] = lct.query(H[i]) + (ll)H[i]*H[i] + C;
		lct.update({ -2*H[i], dp[i] + (ll)H[i]*H[i] });
	}
	cout << dp[N] << '\n';
}


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

#define int long long
#define ff first
#define ss second
#define loop(i,k,n) for(int i=k;i<n;++i)
#define rloop(i,n,k) for(int i=n;i>=k;i--)
#define vi vector<int>
#define vvi vector<vector<int> >
#define vpii vector<pair<int,int> >
#define all(v) v.begin(),v.end()
#define mset(a,i) memset(a,i,sizeof(a))
#define mii map<int,int>  
#define pii pair<int,int>
#define deb(...) __f(#__VA_ARGS__, __VA_ARGS__)
#define mp make_pair
#define pb push_back
#define mod 1000000007  
#define endl "\n"
#define inf 1e18

template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { if(0) return; cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args){   
    if(0) return; 
    const char* comma = strchr (names + 1, ',');
    cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}
void get_it_done(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}
int gcd(int a,int b){
    if(b==0) return a;
    if(a<b) return gcd(b,a);
    return gcd(b,a%b);
}
const int N = 3e5+5;

int32_t main(){
    get_it_done();
    int q=1;
    // cin >> q;
    while (q--){
        int n;
        cin>>n;
        set<string> s;
        loop(i,0,n){
            string a;
            cin>>a;
            s.insert(a);
        }
        cout<<s.size();

        
    }
}


Measured memory_bytes: 19184
n,x=map(int,input().split())
if x==1 or x==2*n-1:print("No")
elif n==x:
    print("Yes")
    for i in range(1,2*n):print(i)
else:
    print("Yes")
    a=list(range(1,x-1))
    a.extend(list(range(x+2,2*n)))
    a.insert(n-2,x+1)
    a.insert(n-1,x)
    a.insert(n,x-1)
    for i in a:print(i)

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

const int maxN = 1e5 + 5; 
vector<int> sons[maxN];
int N, l[maxN], e, pre[maxN], q1[maxN], q2[maxN], ed, q[maxN];
bool caterpillar[maxN];
struct edge{
	int v, fa;
}G[maxN << 1];
void add(int u, int v) {
	G[e].v = v; G[e].fa = l[u]; l[u] = e++;
}
int dfs(int u, int fa, int& ans) {
	ans = u; int maxx = 0; pre[u] = 0;
	for(int i = l[u]; i != -1; i = G[i].fa) {
		int v = G[i].v;
		if(v == fa) continue; 
		int tmp, t;
		if((t = dfs(v, u, tmp)) + 1 > maxx) 
		maxx = t + 1, ans = tmp, pre[u] = v;
	}
	return maxx;
}
int solve(int u, int* f) {
	int tot = 0;
	for(int k = 1; k <= ed; ++k) {
		int i = q[k];
		//cout <<i<<"**"<<endl; 
		int sz = 0;
		for(int j = l[i]; j != -1; j = G[j].fa) 
			if(!caterpillar[G[j].v]) sz++;
		int tmp = tot;
		for(int j = 1; j <= sz; ++j) f[++tot] = tmp + j + 1;
		f[++tot] = tmp + 1;
	}
	return tot;
}
bool cmp() {
	for(int i = 1; i <= N; ++i) {
		if(q1[i] < q2[i]) return 1;
		if(q1[i] > q2[i]) return 0;
	}
	return 1;
}
int main() {
	scanf("%d", &N); 
	for(int i = 1; i <= N; ++i) l[i] = -1;
	for(int i = 1; i < N; ++i) {
		int u, v; scanf("%d%d", &u, &v);
		add(u, v); add(v, u);
	}
	int u, v;
	dfs(1, -1, u); dfs(u, -1, v);
	//cout <<u<<' '<<v<<endl; 
	for(int i = u; i; i = pre[i]) caterpillar[i] = 1, q[++ed] = i;
	if(solve(u, q1) < N) {
		printf("-1\n");
		return 0;
	} 
	for(int i = 1; i * 2 <= ed; ++i) swap(q[i], q[ed - i + 1]);
	solve(v, q2);
	if(cmp()) {
		for(int i = 1; i <= N; ++i) printf("%d ", q1[i]);
	} else for(int i = 1; i <= N; ++i) printf("%d ", q2[i]);
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> P(N);
  for (int i = 0; i < N; i++) cin >> P.at(i);

  int ans = 0;
  for (int i = 0; i + 1 < N; i++) {
    if (P.at(i) == i + 1) {
      swap(P.at(i), P.at(i + 1));
      ans++;
    }
  }

  cout << ((P.at(N - 1) == N) ? ++ans : ans) << "\n";
}

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

#define endl '\n'
#define int long long

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

	int n; cin >> n;
	string s; cin >> s;
	if(s.size() > n) {
		s =  s.substr(0, n);
		s += "...";
	}
	cout << s << endl;

	return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (int i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define ALL(v) v.begin(), v.end()

const int MAX = 5e3+10;

ll dp[MAX][MAX]; // dp[a][b] : 1つめの先頭をa, 2つめの先頭をbとした時の最大一致

int N;
string S;

int solve() {
    ll ans = 0;
    REPR (b, N) REPR (a, b) {
        if (S[b] == S[a]) {
            dp[a][b] = min(b-a, dp[a+1][b+1] + 1);
            ans = max(ans, dp[a][b]);
        }
    }
    return ans;
}

int main() {
    cin >> N >> S;
    cout << solve() << endl;
}

Measured memory_bytes: 194944
n,m=map(int,input().split())
s1=[input() for _ in range(n)]
s2=[input() for _ in range(m)]
ans='No'
for i in range(n-m+1):
  for j in range(n-m+1):
    flg=0
    for k in range(m):
      if s1[j+k][i:i+m]==s2[k]:
        flg+=1
    if flg==m:
      ans='Yes'
print(ans)

Measured memory_bytes: 9188
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>

using namespace std;

int main(){
	int h, w, d;
	cin >> h >> w >> d;
	vector<pair<int, int>> a(h * w + 1);
	vector<int> b(h * w + 1);
	for(int i = 1; i <= h; i++){
		for(int j = 1; j <= w; j++){
			int z;
			cin >> z;
			a[z] = {i, j};
		}
	}
	for(int i = d + 1; i < b.size(); i++){
		b[i] = b[i - d] + (abs(a[i].first - a[i - d].first) + abs(a[i].second - a[i - d].second));
	}
	int q;
	cin >> q;
	for(int i = 0; i < q; i++){
		int l, r;
		cin >> l >> r;
		cout << b[r] - b[l] << endl;
	}
	return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define sqr(x) ((x)*(x))
#define mp make_pair
#define ones(x) __builtin_popcount(x)
#define fast_io() ios_base::sync_with_stdio(0);cin.tie(0);
#define debug(x) cerr << #x << ": " << x << endl;
#define REP(i,x,y) for(int (i)=(x);(i)<(y);(i)++)
#define REPIT(it,A) for(auto it = (A.begin()); it!=A.end();it++)
#define fst first
#define snd second
#define itm1 fst.fst
#define itm2 fst.snd
#define itm3 snd
#define mt(a,b,c) mp(mp(a,b),c)
#define sz(v) int(v.size())
 
 
typedef pair<int,int> ii;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair< ii, int > tri;
typedef unsigned int uint;
typedef vector<int> vi;
typedef unsigned int ui;
typedef vector<ii> vii;

 

const long double PI = acos(-1);
const int  INF = 2e9 + 5;
const ll LINF = 1e18 + 5;
const ll MOD = 1e9 + 7;


int a[1 << 8];


int main() {
	int n; scanf("%d", &n);
	for(int i = 0; i < n << 1; ++i) scanf("%d", &a[i]);
	sort(a, a + 2 * n);
	int sum = 0;
	for(int i = 0; i < n << 1; ++i) {
		if(i % 2 == 0) sum += a[i];
	}

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





	return 0;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define REVETSE(c) reverse((c).begin(),(c).end())
#define SUM(c) accumulate((c).begin(),(c).end(),0)
#define ALL(a)  (a).begin(),(a).end()
// int gcd(int a,int b){return b?gcd(b,a%b):a;}
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> T maxt(T x,T y) {
    if (x>y) return x;
    else return y;
}
template<class T> T mint(T x,T y) {
    if (x>y) return y;
    else return x;
}
//sort(v.rbegin(), v.rend(), [](auto& x, auto& y){return x[1] < y[1];});
//cout << fixed << setprecision(10) << ans << defaultfloat << endl;
typedef long long ll;
typedef vector<int> Vi;
typedef vector<ll> Vl;
typedef vector<double> Vd;
typedef vector<string> Vs;

/* //約数列挙
vector< int64_t > divisor(int64_t n) {
  vector< int64_t > ret;
  for(int64_t i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}*/

int main() {
  ll N,M;
  cin >> N >> M;
  Vl a;ll x;
  REP(i,N){
    cin >> x;
    a.push_back(x);
  }
  ll g=a[0]/2;
  FOR(i,1,N){
    g = g*(a[i]/2)/gcd(g,a[i]/2);
    }
  for(auto i:a) {
    if (g%i!=i/2) {
      cout << 0 << endl;
      return 0;
    }
  }
  if (M-g>=0) {
    cout << (M-g)/(2*g)+1 << endl;
    }
  else {cout << 0 << endl;}
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
inline ll in() { ll x; cin >> x; return x; }
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
const int MX = 200005;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

vector<pair<ll,int>> factorize(ll n) {
  vector<pair<ll,int>> res;
  for(ll i = 2; i*i <= n; ++i) {
    if (n%i) continue;
    res.emplace_back(i,0);
    while (n%i == 0) {
      n /= i;
      res.back().second++;
    }
  }
  if (n != 1) res.emplace_back(n,1);
  return res;
}

vector<int> to[2505];
vector<int> rto[2505];
bool reachablefrom1[2505];
bool reachableToN[2505];
bool ok[2505];

void dfs(int v) {
  if (reachablefrom1[v]) return;
  reachablefrom1[v] = true;
  for (int u : to[v]) {
    dfs(u);
  }
}
void rdfs(int v) {
  if (reachableToN[v]) return;
  reachableToN[v] = true;
  for (int u : rto[v]) {
    rdfs(u);
  }
}

int main() {
  ll a, b;
  cin >> a >> b;
  ll g = gcd(a,b);
  auto f = factorize(g);
  int ans = f.size() + 1;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <iostream>

using namespace std;

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

  if(0 < a) {
    cout << "Positive" << endl;
    return 0;
  }
  else if(a <= 0 && 0 <= b) {
    cout << "Zero" << endl;
    return 0;
  }
  else {
    int count = b - a + 1;
    if(count % 2 == 0) {
      cout << "Positive" << endl;
    }
    else {
      cout << "Negative" << endl;
    }
    return 0;
  }
}

Measured memory_bytes: 256