akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

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

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;



int main(void){
  int n;
  cin >> n;
  VI a(n);
  set<int> col;
  int dendo = 0;
  REP(i, 0, n) {
    cin >> a[i];
    a[i] /= 400;
    if (a[i] < 8) {
      col.insert(a[i]);
    } else {
      dendo += 1;
    }
  }
  int cs = col.size();
  cout << max(cs, dendo ? 1 : 0) << " " << cs + dendo << endl;
}


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

#define ALL(c) c.begin(), c.end()
#define SZ(c) ((int)c.size())
#define REP(i, n) for (int i = 0, loop_num_##i = n; i < loop_num_##i; i++)

struct State {
	int idx;
	string s;

	char get_char() {
		if (idx >= SZ(s)) return '\n';
		return s[idx];
	}
	bool is_digit() {
		return '0' <= get_char() && get_char() <= '9';
	}
	bool is_end() {
		return idx == SZ(s);
	}
	void next(int n = 1) {
		idx += n;
	}
};

struct Node {
	vector<pair<Node*, int>> data;
	string immediate;
	int width;
	Node() : data(), immediate(""), width(0) {}
};

int parse_num(State &s) {
	string ret = "";
	while (s.is_digit()) {
		ret += s.get_char();
		s.next();
	}
	return stoll(ret);
}

Node *parse(State &s) {
	Node *ret = new Node();
	while (!s.is_end()) {
		if (s.is_digit()) {
			int repeat = parse_num(s);
			//cerr << "rep: " << repeat << endl;
			if (s.get_char() == '(') {
				s.next(); // skip '('
				Node *tmp = parse(s);
				ret->data.emplace_back(tmp, repeat);
				ret->width += tmp->width * repeat;
				if (ret->width > 1e8) ret->width = 1e9;
				s.next(); // skip ')'
			} else {
				Node *tmp = new Node();
				tmp->immediate = string("") + s.get_char();
				tmp->width = 1;
				ret->data.emplace_back(tmp, repeat);
				ret->width += 1 * repeat;
				if (ret->width > 1e8) ret->width = 1e9;
				//cerr << "immediate(1): " << tmp->immediate << endl;
				s.next();
			}
		} else {
			if (s.get_char() == ')') return ret;
			string genom;
			while (!s.is_end() && !s.is_digit() && s.get_char() != ')') {
				genom += s.get_char();
				s.next();
			}
			//cerr << "immediate: " << genom << endl;
			Node *tmp = new Node();
			tmp->immediate = genom;
			tmp->width = SZ(genom);
			ret->data.emplace_back(tmp, 1);
			ret->width += SZ(genom);
			if (ret->width > 1e8) ret->width = 1e9;
		}
	}
	return ret;
}

char solve(Node *node, int idx) {
	if (SZ(node->data) == 0) {
		if (SZ(node->immediate) <= idx) return '#';
		return node->immediate[idx];
	}
	int size = 0;
	for (int i = 0; i < SZ(node->data); i++) {
		int len = node->data[i].first->width * node->data[i].second;
		if (idx < size + len) {
			return solve(node->data[i].first, (idx - size) % (node->data[i].first->width));
		} else {
			size += len;
			//cerr << "size: " << size << endl;
		}
	}
	return '0';
}

signed main() {
	while (1) {
		string s;
		cin >> s;
		int idx;
		cin >> idx;
		if (s == "0" && idx == 0) break;
		State st {0, s};
		Node *root = parse(st);
		char ans = solve(root, idx);
		cout << ans << endl;
	}
}



Measured memory_bytes: 3608
#include <stdio.h>

#define S_SIZE 10000
#define T_SIZE 500
int main(void)
{
  long S[S_SIZE];
  int n;
  int i;
  long T[T_SIZE];
  int q;
  int found = 0;

  scanf("%5d", &n);
  for(i=0; i < n; i++) scanf("%10ld", &S[i]);

  scanf("%3d", &q);
  for(i=0; i < q; i++) scanf("%10ld", &T[i]);

  for(i=0; i < q; i++){
    int f, j;
    f = T[i];

    for(j = 0; j < n; j++){
      if(f == S[j]) break;
    }
    if(j < n) found++;
  }

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

  return 0;
}

Measured memory_bytes: 680
N=int(input())
ans=0
S=['']
flg=True
while flg:
  _S=[]
  for s in S:
    _S.append('3'+s)
    _S.append('5'+s)
    _S.append('7'+s)
  for _ in _S:
    if '3' in _ and '5' in _ and '7' in _:
      if int(_)<=N:
        ans+=1
      else:
        flg=False
  S=_S[:]
print(ans)

Measured memory_bytes: 9156
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <complex>
#include <iomanip>
#include <queue>
#include <bitset>
#include <numeric>
//定数
#define MOD 1000000007
//マクロ
#define rep(i,n)    for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))

#define vsort(v) sort((v).begin(), (v).end());

typedef unsigned long long int ull;
typedef long long lint;

using namespace std;




int main(){
    string S, T;

    //入力
    cin >> S >> T;

    cout << T << S << endl;

    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int MOD = 1000000007;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };
	static int[] mh8 = { -1, -1, -1, 0, 0, 1, 1, 1 };
	static int[] mw8 = { -1, 0, 1, -1, 1, -1, 0, 1 };

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int n = in.nextInt(), k = in.nextInt();
			int[][] mat = new int[4*k+1][4*k+1];
			int[][] sum = new int[4*k+1][4*k+1];
			for (int i = 0; i < n; i++) {
				int x = in.nextInt();
				int y = in.nextInt();
				String c = in.nextString();

				if (c.equals("W")) {
					y += k;
				}

				mat[x%(2*k)][y%(2*k)]++;
			}

			for (int x = 0; x <= 4*k; x++) {
				for (int y = 0; y <= 4*k; y++) {
					mat[x][y] = mat[x%(2*k)][y%(2*k)];
				}
			}

			for (int i = 0; i <= 4*k; i++) {
				for (int j = 0; j <= 4*k; j++) {
					sum[i][j] = mat[i][j];
					if (j-1 >= 0) sum[i][j] += sum[i][j-1];
					if (i-1 >= 0) sum[i][j] += sum[i-1][j];
					if (i-1 >= 0 && j-1 >= 0) sum[i][j] -= sum[i-1][j-1];
				}
			}

			int ans = 0;
			for (int x = 0; x <= 2*k; x++) {
				for (int y = 0; y <= 2*k; y++) {
					int tmp = 0;
					tmp += get(x, y, x+k-1, y+k-1, sum);
					tmp += get(x+k, y+k, x+2*k-1, y+2*k-1, sum);
					ans = Math.max(ans, tmp);
				}
			}

			out.println(ans);
		}

	}
	static int get(int x1, int y1, int x2, int y2, int[][] sum) {

		int res = sum[x2][y2];
		if (x1 > 0) res -= sum[x1-1][y2];
		if (y1 > 0) res -= sum[x2][y1-1];
		if (x1 > 0 && y1 > 0) res += sum[x1-1][y1-1];

		return res;
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

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

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

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}
	}

}


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

using namespace std;

const int INF = 1e9;
const int N = 1e5;
const int MOD = 1e9 + 7;

const double PI = acos(-1);



int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    string s, t;
    cin >> s >> t;
    t += s;
    cout << t;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;

int main(){ _;
  int n,a,b;
  string s;
  cin>>n>>a>>b;
  cin>>s;
  int aCnt=0,bCnt=0;
  for(char c:s){
    bool ok=false;
    if(c=='a'){
      if(a+b>aCnt+bCnt){
	ok=true;
	aCnt++;
      }
    }else if(c=='b'){
      if(a+b>aCnt+bCnt&&b>bCnt){
	ok=true;
	bCnt++;
      }
    }
    if(ok)
      cout<<"Yes\n";
    else
      cout<<"No\n";
  }
}


Measured memory_bytes: 848
import sys
import bisect
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces
nl = lambda: list(map(int, stdin.readline().split()))

n = ni()
a = na()
q = ni()
m = na()
def solve(i,m):
    if m == 0:
        return True
    if i >= n:
        return False
    if sum(a[i::]) < m:
        return False
    res = solve(i+1, m) or solve(i+1, m-a[i])

    return res
for mi in m:
    if solve(0, mi):
        print('yes')
    else:
        print('no')


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

int main () {

  std::vector<int> v[16384];
  int num;
  int depth;
  int N;
  std::string str;

  std::cin >> N;
  for(int i = 0; i < N; ++i) {

    for(int j = 0; j < 16384; ++j) {
      v[j].clear();
    }
    
    std::cin >> str;
    depth = 0;
    for(int j = 0; j < str.size(); ++j) {
      if( str[j] == '[' ) {
        depth += 1;
        num = 0;
      }
      else if( '0' <= str[j] and str[j] <= '9' ) {
        num *= 10;
        num += str[j] - '0';
      }
      else {
        depth -= 1;
        if( num != -1 ) {
          v[depth].push_back((num+1)/2);
        }
        else {
          std::sort(v[depth+1].begin(), v[depth+1].end());
          int sum = 0;
          for(int k = 0; k < (v[depth+1].size()+1)/2; ++k) {
            sum += v[depth+1][k];
          }
          v[depth].push_back(sum);
          v[depth+1].clear();
        }
        num = -1;
      }
    }
    std::cout << v[0][0] << std::endl;
  }

  return 0;
}

Measured memory_bytes: 1660
// Code by ajcxsu
// Problem: C

#include<bits/stdc++.h>
using namespace std;

typedef bitset<10> bs;
void solve(int k, int a, int b, vector<int> &op) {
    if(k==1) { op.push_back(a), op.push_back(b); return; }
    int c=0;
    vector<int> L, R;
    for(; ((1<<c)&a)==((1<<c)&b); c++);
    int na=(a&((1<<c)-1))|((a&((1<<k)-1-((1<<c+1)-1)))>>1);
    int nb=(b&((1<<c)-1))|((b&((1<<k)-1-((1<<c+1)-1)))>>1);
    // cerr<<a<<' '<<b<<' '<<c<<' '<<(bs)na<<endl;
    solve(k-1, na, na^1, L);
    solve(k-1, na^1, nb, R);
    for(int x:L) op.push_back(((x&((1<<c)-1))|((x&((1<<(k-1))-1-((1<<c)-1)))<<1))|((1<<c)&a));
    for(int x:R) op.push_back(((x&((1<<c)-1))|((x&((1<<(k-1))-1-((1<<c)-1)))<<1))|((1<<c)&b));
}

int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    int n, a, b;
    cin>>n>>a>>b;
    if(!((__builtin_popcount(a)+__builtin_popcount(b))&1)) cout<<"NO\n", exit(0);
    vector<int> ans;
    solve(n, a, b, ans);
    cout<<"YES\n";
    for(int x:ans) cout<<x<<' ';
    cout<<endl;
    return 0;
}

Measured memory_bytes: 1756
package main
import (
	"fmt"
)
func main() {
    
    var s1, s2 string
    fmt.Scan(&s1, &s2)
  
    var cnt int
    for i := 0; i < len(s1); i++ {
        if s1[i] != s2[i] {
            cnt++    
        }
    }
    
    fmt.Println(cnt)
}

Measured memory_bytes: 3384
#include <bits/stdc++.h>
using namespace std;
int main(){

string S, T;
cin >> S >> T;

int ans = 0;

for (int i = 0; i < S.size(); i++){
    if(S.at(i) != T.at(i)){
        ans ++;
    }
}

cout << ans << endl;

return 0;
}

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

using namespace std;
int main(){
    int n, sum = 0, bf = 0, nw = 0;
    cin >> n;
    int a[n], b[n], c[n - 1];
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    for(int i = 0; i < n; i++){
        cin >> b[i];
    }
    for(int i = 0; i < n - 1; i++){
        cin >> c[i];
    }
    sum += b[a[0] - 1];
    bf = a[0] - 1;
    for(int i = 1; i < n; i++){
        sum += b[a[i] - 1];
        nw = a[i] - 1;
        if(nw - bf == 1) sum += c[bf];
        bf = nw;
    }
    cout << sum << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;

long long int n, m;
long long int p[100000];
long long int a[99999];
long long int b[99999];
long long int c[99999];

long long int d[99999];
long long int ans;
long long int pa;
long long int ic;

void add(int x, int y){
	if(x > y) swap(x, y);
	for(int i=0; x+i<y; i++){
		d[x+i-1]++;
	}
}

long long int cost(int x){
	pa = a[x] * d[x];
	ic = c[x] + b[x] * d[x];
	return min(pa, ic);
}

int main(){
	scanf("%lld %lld", &n, &m);
	for(int i=0; i<m; i++) scanf("%lld", &p[i]);
	for(int i=0; i<n-1; i++) scanf("%lld %lld %lld", &a[i], &b[i], &c[i]);

	for(int i=0; i<m-1; i++){
		add(p[i], p[i+1]);
	}
	
	for(int i=0; i<n-1; i++){
		ans += cost(i);
//		printf("%lld\n", cost(i));
	}
	printf("%lld\n", ans);

	return 0;
}

Measured memory_bytes: 6664
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>
#include <map>
#include <set>
#include <tuple>
#include <unordered_map>
#include <iterator>
#include <string>
#include <limits>

using namespace std;

using i64 = int64_t;
using P = pair<i64, i64>;
//i64 mod = 1000000007;
i64 mod = 998244353;
int int_max = 2147483647;
i64 INF = 1e16;
int max_n = 1e5;

template<typename IntType>
struct mat2d_t {
    mat2d_t(size_t h, size_t w) : h(h), w(w) {
        mat = std::vector<std::vector<IntType>>(h, std::vector<IntType>(w, 0));
    }
    mat2d_t(size_t h, size_t w, IntType init) : h(h), w(w){
        mat = std::vector<std::vector<IntType>>(h, std::vector<IntType>(w, init));
    }

    std::vector<IntType>& operator[](size_t p) {
        return mat[p];
    }

    const std::vector<IntType>& operator[](size_t p) const {
        return mat[p];
    }
    size_t height() const {
        return h;
    }
    size_t width() const {
        return w;
    }

private:
    std::vector<std::vector<IntType>> mat;
    size_t h;
    size_t w;
};

int main(int argc, char **argv) {
    i64 n, s;
    cin >> n >> s;

    vector<i64> as(n);
    for (i64 i=0;i <n; ++i) {
        cin >> as[i];
    }


    mat2d_t<i64> dp(n+1, s+1, 0);
    dp[0][0] = 1;
    for (i64 i=1; i<n+1; ++i) {
        i64 a = as[i-1];
        for (i64 j=0; j<s+1; ++j) {
            dp[i][j] += dp[i-1][j] * 2;
            if (0 <= j-a && j-a < s+1)
                dp[i][j] += dp[i-1][j-a];
            dp[i][j] %= mod;
        }
    }
/*
    for (int i= 0; i<n+1; ++i) {
        for (int j=0; j<s+1; ++j) {
            cout << dp[i][j] << " ";
        }
        cout << endl;
    }
*/
    cout << dp[n][s] << endl;

    return 0;
}


Measured memory_bytes: 73580
import sys
import fractions

def main():
    # a = sys.stdin.readline().strip()
    a, b, c, d = [int(i) for i in sys.stdin.readline().strip().split()]
    # [[int(i) for i in sys.stdin.readline().strip().split()] for _ in range(2)]
    n = b - a + 1
    # print(n)
    if a % c == 0:
        mi_c = a // c
    else:
        mi_c = a // c + 1
    ma_c = b // c
    n -= (ma_c - mi_c + 1)
    # print(ma_c, mi_c, n)

    if a % d == 0:
        mi_d = a // d
    else:
        mi_d = a // d + 1
    ma_d = b // d
    n -= (ma_d - mi_d + 1)
    # print(ma_d, mi_d, n)

    cd = (c * d) // fractions.gcd(c, d)
    if a % cd == 0:
        mi_cd = a // cd
    else:
        mi_cd = a // cd + 1
    ma_cd = b // cd
    n += (ma_cd - mi_cd + 1)
    # print(ma_cd, mi_cd, n)
    print(n)
    
main()


Measured memory_bytes: 5076
#include<stdio.h>
#include<math.h>
#include<string.h> 
int main()
{
	char s1[105],s2[105];
	while(scanf("%s%s",s1,s2)!=EOF)
	{
		int a[26]={0},b[26]={0}; 
		int i,j,l,flag1=0;
		l=strlen(s1); 
		for(i=0;i<l;i++) 
		{
			int t,flag=0;
			t=s1[l-1];
			for(j=l-1;j>0;j--)
				s1[j]=s1[j-1];
			s1[0]=t; 
			for(j=0;j<l;j++)
			{	
				if(s1[j]==s2[j])
					flag++; 
			}
			if(flag==l)
			{	
				flag1=1; 
				break; 
			} 
		} 
		if(flag1==1)
			printf("Yes\n");
		else	
			printf("No\n");			 
	} 
}

Measured memory_bytes: 128
# util functions

# debug
$debugFlag = ( ARGV[0] != nil )
p "==== DEBUG MODE ====" if $debugFlag

def pd(str)
  p str if $debugFlag
end

# input
inputs = []
lc = 0
while l = $stdin.gets do
  if lc == 1
    inputs << l.chomp
  else
    inputs << l.chomp.split(" ").map(&:to_i)
  end
  lc += 1
end

# input check
if $debugFlag
  p "--- INPUT (begin) ---"
  inputs.each do |l_i|
    p l_i
  end
  p "--- INPUT (end) ---"
  print "\n"
end

ss = inputs[1]
qs = inputs[2..-1]

# body
if $debugFlag
  p ss
  p qs
end

arr = []
idx = 0
sslen = ss.length
accnt = 0
while idx < sslen
  if ss[idx..idx+1] == "AC"
    accnt += 1    
    arr << accnt
    arr << accnt
    idx += 2
  else
    arr << accnt
    idx += 1
  end
end

pd ss
pd arr

qs.each do |s_j, e_j|
  chkarr = arr[s_j-1..e_j-1]
  if chkarr.size <= 1
    ret = 0
  else
    if ss[s_j-1..s_j] == "AC"
      min = chkarr[0]
    else
      min = chkarr[0] + 1
    end

    if chkarr[-2] == chkarr[-1]
      max = chkarr[-1]
    else
      max = chkarr[-1] - 1
    end
    
    if max < min
      ret = 0
    else
      ret = max - min + 1
    end
  end

  puts ret
end


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

int main()
{
    int a,b,c,n,sum,max,i;
    scanf("%d%d%d%d",&a,&b,&c,&n);
    sum=a+b+c;
    if(a>c)
        max=a;
    else max=c;
    if(b>max)
        max=b;
    sum-=max;
    for(i=1;i<=n;i++)
        max*=2;
    printf("%d",sum+max);

    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    int n;cin>>n;
    vector<int> a(n);
    ll ans=1,hiku=1;
    rep(i,n){
        cin>>a[i];
        if(a[i]%2){
            ans*=3;
            hiku*=1;
        }
        else{
            ans*=3;
            hiku*=2;
        }
    }
    cout<<ans-hiku<<endl;
    return 0;
}


Measured memory_bytes: 256
from itertools import permutations
import statistics

N = int(input())
box = [list(map(int, input().split())) for _ in range(N)]
p_box = permutations(box)
ans = []
for i in p_box:
    temp = 0
    for j in range(1, N):
        temp += ((i[j][0] - i[j-1][0])**2 + (i[j][1] - i[j-1][1])**2)**(1/2)
    ans.append(temp)

print(statistics.mean(ans))

Measured memory_bytes: 6556
//Wrong answer on test inf.
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x);i<=(y);i++)
using namespace std;
#define N 605
bool vis[N][N][2];
int n,cnt;
int main(){
	scanf("%d",&n);
	rep (op,0,1){
		int d,len=0;scanf("%d",&d);
		while (d%4==0) d/=4,len++;
		if (d%4==2){
			rep (i,0,2*n-1) rep (j,0,2*n-1)
				if (i>>len&1) vis[i][j][op]=1;
		} else{
			rep (i,0,2*n-1) rep (j,0,2*n-1)
				if ((i>>len)+(j>>len)&1) vis[i][j][op]=1;
		}
	}
	rep (i,0,2*n-1) rep (j,0,2*n-1)
		if (!vis[i][j][0]&&!vis[i][j][1]){
			printf("%d %d\n",i,j);
			if (++cnt==n*n) exit(0);
		}
	return 0;
}

Measured memory_bytes: 1664
# include <iostream>
# include <algorithm>
# include <queue>
# include <vector>
using namespace std;

static const int MAX = 10000;
static const int INFTY = (1 << 20);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n;
vector<pair<int, int> > adj[MAX];

void dijkstra() {
    priority_queue<pair<int, int> > PQ;
    int color[MAX], d[MAX];
    for ( int i = 0; i < n; i++ ) {
        d[i] = INFTY;
        color[i] = WHITE;
    }

    d[0] = 0;
    PQ.push(make_pair(0, 0));
    color[0] = GRAY;

    while( !PQ.empty() ) {
        pair<int, int> f = PQ.top();
        PQ.pop();
        int u = f.second;

        color[u] = BLACK;

        if ( d[u] < f.first * (-1) )
            continue;

        for ( int j = 0; j < adj[u].size(); j++ ) {
            int v = adj[u][j].first;
            if ( color[v] == BLACK )
                continue;
            if ( d[v] > d[u] + adj[u][j].second ) {
                d[v] = d[u] + adj[u][j].second;
                PQ.push(make_pair(d[v] * (-1), v));
                color[v] = GRAY;
            }
        }
    }

    for ( int i = 0; i < n; i++ ) {
        cout << i << " " << ( d[i] == INFTY ? -1 : d[i] ) << endl;
    }
}

void solve() {
    int k, u, v, c;

    cin >> n;
    for ( int i = 0; i < n; i++ ) {
        cin >> u >> k;
        for ( int j = 0; j < k; j++ ) {
            cin >> v >> c;
            adj[u].push_back(make_pair(v, c));
        }
    }

    dijkstra();
}

int main() {
    // freopen("infile", "r", stdin);
    // freopen("outfile", "w", stdout);
    solve();
    return 0;
}


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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repp(i, n, m) for(int (i) = (n); (i) < (m); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define ldou long double
#define fi first
#define se second
#define setpre(x) std::cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define outs(x) cout << (x) << " "
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ std::cout << " [LOGGER] " << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , "; logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 200005;

/* ...o(^-^)o... */

int main(){
    string s;
    rep(i,3){
        cin >> s;
        cout << s[i];
    }
    cout << endl;
}

Measured memory_bytes: 3544
# C - GCD on Blackboard
from collections import defaultdict

n = int(input())
a = list(int(x) for x in input().split())

def gcd(x, y):
    if x==0:
        return y
    else:
        return gcd(y%x, x)

# 左から
L = [0]*(n+1)
L[0] = 0
for i in range(n):
    L[i+1] = gcd(L[i], a[i])

# 右から
R = [0]*(n+1)
R[n-1] = a[n-1]
for i in range(1, n)[::-1]:
    R[i-1] = gcd(R[i], a[i-1]) 

ans = 0
for i in range(n):
    ans = max(ans, gcd(L[i], R[i+1]))

print(ans)

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

using namespace std;

typedef long long ll;

const int N=200050;
const ll MOD=1e9+7;
int n;
int a[N],p[N];
ll f[N];

int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;++i) scanf("%d",&a[i]);
	f[0]=0;f[1]=1;
	memset(p,0,sizeof(p));p[a[1]]=1;
	for (int i=2;i<=n;++i){
		f[i]=f[i-1];
		if (a[i]!=a[i-1])
			f[i]=(f[i]+f[p[a[i]]])%MOD;
		p[a[i]]=i;
	}
	printf("%lld\n",f[n]);
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
int n,m,last,num;
pair<int,pair<int,int> > a[100010];
vector<pair<int,pair<int,int> > > v;
int main(){
	cin>>n>>m;
	for (int i=0;i<m;i++) cin>>a[i].first>>a[i].second.first;
	for (int i=0;i<m;i++) a[i].second.second=i;
	sort(a,a+m);
	last=a[0].first;num=2;
	v.push_back(pair<int,pair<int,int> >(a[0].second.second,pair<int,int>(1,a[0].first)));
	for (int i=1;i<m;i++)
		if (a[i].first==last){
			v.push_back(pair<int,pair<int,int> >(a[i].second.second,pair<int,int>(num,a[i].first)));
			num++;
		}
		else{
			num=1;
			v.push_back(pair<int,pair<int,int> >(a[i].second.second,pair<int,int>(num,a[i].first)));
			last=a[i].first;
			num++;
		}
	sort(v.begin(),v.end());
	for (int i=0;i<v.size();i++){
		int x=v[i].second.second,y=v[i].second.first,b=0,c=0;
		while (x>0){
			x/=10;
			b++;
		}
		while (y>0){
			y/=10;
			c++;
		}
		for (int j=0;j<6-b;j++) cout<<0;
		cout<<v[i].second.second;
		for (int j=0;j<6-c;j++) cout<<0;
		cout<<v[i].second.first;
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 3956
N, K = map(int, input().split())
S = input()

if K == 1:
    S = S[0].lower() + S[1:]
elif K == N:
    S = S[:-1] + S[N-1].lower()
else:
    S = S[:K-1] + S[K-1].lower() + S[K:]
print(S)

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

int		main(void)
{
	int d;

	cin >> d;
	string ans = "Christmas";

	if(d < 25)
		ans += " Eve"; 
	if (d < 24)
		ans += " Eve";
	if (d < 23)
		ans += " Eve";
	cout << ans << endl;
}


Measured memory_bytes: 256
a = list(map(int, input().strip().split(' ')))

if not(len(set(a)) == len(a)):
    print('NO')
else:
    if a.count(1) == a.count(9) == a.count(7) == a.count(4)  == 1:
        print('YES')
    else:
        print('NO')

Measured memory_bytes: 3060
#include <iostream>

using namespace std;

const string week[7]={"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
int main()
{
    string s;
    cin>>s;
    for(int i=0 ; i<7;i++){
        if (s==week[i]){
            int diff = 7-i;
            cout<<diff<<endl;
            break;
        }
    }
}


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

dp = [[0.0 for _ in range(N + 1)] for _ in range(N + 1)]
dp[1][1] = p_list[0]
dp[1][0] = 1 - p_list[0]

for i in range(2, N + 1):
    for j in range(i + 1):
        dp[i][j] = p_list[i - 1] * dp[i - 1][j - 1] + (1 - p_list[i - 1]) * dp[i - 1][j]

print("{:.10f}".format(sum(dp[N][N // 2 + 1:])))



Measured memory_bytes: 121308
#include <bits/stdc++.h>
using namespace std;
#define scn(T, i, iter) for (T i: iter)
#define rep(i,n) for (int i = 0; i < n; ++i)
const int MOD = 1000000007;


int main() {
  int64_t a, b, x, begin, end;
  cin >> a >> b >> x;

  int64_t ans = (b/x) - (a/x);
  if (a % x == 0) ans++;

  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
struct data
{
    int a;
    int b;
    int c;
    int d;
};
data mark[110000];
priority_queue<pair<int,pair<int,int > > > PQ;
int check(int a)
{
    int b=a;
    int cnt=0;
    while(a!=0)
    {
        a=a/10;
        cnt++;
    }
    return 6-cnt;

}
int main()
{
    int n,a,b,c,d,m;
   scanf("%d%d",&n,&m);
    for(int i=0; i<m; i++)
    {
        scanf("%d%d",&a,&b);
        PQ.push(make_pair(a*-1,make_pair(b*-1,i+1)));
    }
    int last_pre=-1;
    int cnt=0;
    while(!PQ.empty())
    {
        a=PQ.top().first*-1;
        b=PQ.top().second.first*-1;
        if(a==last_pre)
            cnt++;
        else
        {
            last_pre=a;
            cnt=1;
        }
        d=PQ.top().second.second;
        mark[d].a=check(a);
        mark[d].b=a;
        mark[d].c=check(cnt);
        mark[d].d=cnt;
        PQ.pop();
    }
    for(int i=1;i<=m;i++)
    {
        while(mark[i].a!=0)
            {
                printf("0");
                mark[i].a--;
            }
            printf("%d",mark[i].b);
        while(mark[i].c!=0)
            {
                printf("0");
                mark[i].c--;
            }
            printf("%d",mark[i].d);
        printf("\n");
    }
}


Measured memory_bytes: 4340
#include <stdio.h>
#include <string>
#include <algorithm>
#include <iostream>
#include <cmath>
using namespace std;

char B[1];

int main() {
    scanf("%s", B);
    
    if ( B[0] == 'A' ) {
        printf("T\n");
    } else if ( B[0] == 'C' ) {
        printf("G\n");
    } else if ( B[0] == 'G' ) {
        printf("C\n");
    } else {
        printf("A\n");
    }
    
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
const int N = 2e5 + 54;
int n, a[N], s[N];
long long ans;
int main() {
	std::cin >> n;
	for (int i = 1; i <= n; ++i) std::cin >> a[i], ++s[a[i]];
	for (int i = 1; i <= n; ++i) 
		if (s[i]) ans += (long long) s[i] * (s[i] - 1) / 2;
	for (int i = 1; i <= n; ++i) {
		std::cout << ans - s[a[i]] + 1 << '\n';
	}
}


Measured memory_bytes: 3712
#include<iostream>
#include<algorithm>
#include<string>
#include<stack>
#define rep(i,n) for(int i=0;i<(int)n;i++)
using namespace std;

int main(){
  string cipher;
  while(cin >> cipher){
    if(cipher==".")break;

    int cnt = 0;
    rep(i,cipher.size()){
      while(cipher[i] == '+' || cipher[i] == '-'){
	cnt += (cipher[i] == '+')? 1 : -1;
	cipher.erase(cipher.begin()+i);
      }
      if(cnt != 0){
	if(cipher[i] != '?'){
	  cipher[i] = 'A' + ( (cipher[i]-'A' + cnt) % 26 + 26) % 26;
	}
	cnt = 0;
      }
    }

    stack<int> open;
    rep(i,cipher.size()){
      if(cipher[i] == '[')open.push(i);
      else if(cipher[i] == ']'){
	int start = open.top(); open.pop();
	string rev = cipher.substr(start+1,i-start-1);
	reverse(rev.begin(), rev.end());
	cipher = cipher.substr(0,start) + rev + cipher.substr(i+1);
	i -= 2;
      }
    }

    rep(i,cipher.size()){
      if(cipher[i] == '?')cipher[i] = 'A';
    }
    cout << cipher << endl;
  }
}

Measured memory_bytes: 1208
while 1:
    pay = int(raw_input())
    if (pay == 0):
        break;
    change = 1000 - pay
    coin = [1, 5, 10, 50, 100, 500]
    n_coin = [0, 0, 0, 0, 0, 0]
    success = 0

    if (change > coin[5]):
        change -= coin[5]
        n_coin[5] = 1
        for i4 in range(5):
            for i3 in range(2):
                for i2 in range(5):
                    for i1 in range(2):
                        for i0 in range(5):
                            if (change == coin[4] * i4 + coin[3] * i3 + coin[2] * i2 + coin[1] * i1  + coin[0] * i0):
                                success = 1
                                break;
                        if (success):break;
                    if (success):break;
                if (success):break;
            if (success):break;
        n_coin[4] = i4
        n_coin[3] = i3
        n_coin[2] = i2
        n_coin[1] = i1   
        n_coin[0] = i0
    
        su = 0
        for i in range(6):
            su += n_coin[i]
    else:
        for i4 in range(5):
            for i3 in range(2):
                for i2 in range(5):
                    for i1 in range(2):
                        for i0 in range(5):
                            if (change == coin[4] * i4 + coin[3] * i3 + coin[2] * i2 + coin[1] * i1  + coin[0] * i0):
                                success = 1
                                break;
                        if (success):break;
                    if (success):break;
                if (success):break;
            if (success):break;
        n_coin[4] = i4
        n_coin[3] = i3
        n_coin[2] = i2
        n_coin[1] = i1   
        n_coin[0] = i0
    
        su = 0
        for i in range(6):
            su += n_coin[i]
    print su

Measured memory_bytes: 4340
N, H = map(int, input().split())
a = []
b = []
for i in range(N):
    a1, b1 = map(int, input().split())
    a.append(a1)
    b.append(b1)

am = max(a)

bm = []
for i in range(N):
    if b[i] > am:
        bm.append(b[i])
bm.sort()

ans = 0
while len(bm) > 0:
    attack = bm.pop()
    H -= attack
    ans += 1

    if H <= 0:
        print(ans)
        exit()

print(ans + -(-H//am))

Measured memory_bytes: 12080
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    ll N, K;
    cin >> N >> K;
    vvi Sushi(N, vi(0));

    rep(i, N){
        ll t, d; cin >> t >> d; t--;
        Sushi[t].emplace_back(d);
    }
    rep(i, N) sort(all(Sushi[i]), greater<ll>());

    vi top, other;
    rep(i, N){
        if(Sushi[i].size() != 0){
            rep(j, Sushi[i].size()){
                if(j == 0) top.emplace_back(Sushi[i][j]);
                else other.emplace_back(Sushi[i][j]);
            }
        }
    }
    ll var = top.size();
    sort(all(top), greater<ll>()); top.emplace_back(-INFLL);
    sort(all(other), greater<ll>()); other.emplace_back(-INFLL);

    ll ans = 0, preans = 0, cnt = 0;
    ll pos_t = 0, pos_o = 0;
    while(cnt < K){
        if(top[pos_t] >= other[pos_o]){
            ans += top[pos_t];
            pos_t++;
        }
        else{
            ans += other[pos_o];
            pos_o++;
        }
        cnt++;
    }
    pos_o--;
    ans += (pos_t)*(pos_t);
    preans = ans;
    while(pos_t < K && pos_t < var){
        ll tmp = preans;
        tmp -= ((pos_t)*(pos_t) + other[pos_o]);
        tmp += top[pos_t] + (pos_t+1)*(pos_t+1);
        pos_t++; pos_o--;
        chmax(ans, tmp);
        preans = tmp;
    }
    cout << ans << endl;
}


Measured memory_bytes: 9712
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
signed main(){
  int A,B;
  cin>>A>>B;
  cout<<(A-1)*(B-1);
  }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i < (int)(n); i++)
#define Sort(a) sort(a.begin(), a.end())
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;} return false;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;} return false;}

int main(){
    int x;
    cin >> x;
    int ans = 0;
    if(x >= 400 && x < 600) {
        ans = 8;
    }
    if(x >= 600 && x < 800) {
        ans = 7;
    }
    if(x >= 800 && x < 1000) {
        ans = 6;
    }
    if(x >= 1000 && x < 1200) {
        ans = 5;
    }
    if(x >= 1200 && x < 1400) {
        ans = 4;
    }
    if(x >= 1400 && x < 1600) {
        ans = 3;
    }
    if(x >= 1600 && x < 1800) {
        ans = 2;
    }
    if(x >= 1800 && x < 2000) {
        ans = 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3620
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    while(1){
        int N;
        int fie[10001];
        int ans=100000;
        cin>>N;
        if(N==0)break;
        for(int i=0;i<N;i++)cin>>fie[i];
        for(int i=0;i<N;i++){
            int memo=fie[i],l=i,r=i,cou=1;
            for(int j=1;j<=3;j++){
                fie[i]=j;
                l=i,r=i,cou=1;
                while(1){
                    //printf("[%d][%d][%d][%d][%d]\n",i,j,l,r,cou);
                    int fg=1;
                    if(l!=0){
                        if(fie[l]==fie[l-1]){
                            l--;
                            cou++;
                            fg=0;
                        }
                    }
                    if(r!=N-1){
                        if(fie[r]==fie[r+1]){
                            r++;
                            cou++;
                            fg=0;
                        }
                    }
                    if(fg==1&&(cou<4))break;
                    if(fg==1&&(l==0||r==N-1)){cou=0;break;}
                    if(fg==1&&fie[l-1]!=fie[r+1]){cou=0;break;}
                    if(fg==1){
                        l--,r++;
                        cou=2;
                    }
                }
                //printf("[%d]\n",(l-0)+((N-1)-r)+cou);
                ans=min(ans,(l-0)+((N-1)-r)+cou);
                fie[i]=memo;
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}

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

using namespace std;

int main()
{
    /*1
    freopen("flat.in", "r", stdin);
    freopen("flat.out", "w", stdout);
    */
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    long long mn=1e10,mx=0;
    cin>>n;
    for(int i=0;i<n;i++){
        long long x;
        cin>>x;
        mx=max(mx,x);
        mn=min(mn,x);
    }
    cout<<mx-mn<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>

int a[2002][2002];
int b[2002][2002];
char s[4];

inline int f(int (*d)[2002], int sx, int sy, int ex, int ey) {
	return d[ex][ey] - d[ex][sy] - d[sx][ey] + d[sx][sy];
}

int main() {
	int i, j, n, m, t, r = 0;
	scanf("%d%d", &n, &m);
	while (n--) {
		scanf("%d%d%s", &i, &j, s);
		if (s[0] == 'W') a[i % (m + m) + 1][j % (m + m) + 1]++;
		else b[i % (m + m) + 1][j % (m + m) + 1]++;
	}
	for (i = 1; i <= m + m; i++) for (j = 1; j <= m + m; j++) {
		a[i][j] += a[i - 1][j] + a[i][j - 1] - a[i - 1][j - 1];
		b[i][j] += b[i - 1][j] + b[i][j - 1] - b[i - 1][j - 1];
	}
	for (i = 1; i <= m; i++) for (j = 1; j <= m; j++) {
		t =
			f(a, 0, 0, i, j) +
			f(b, i, 0, i + m, j) +
			f(a, i + m, 0, m + m, j) +
			f(b, 0, j, i, j + m) +
			f(a, i, j, i + m, j + m) +
			f(b, i + m, j, m + m, j + m) +
			f(a, 0, j + m, i, m + m) +
			f(b, i, j + m, i + m, m + m) +
			f(a, i + m, j + m, m + m, m + m);
		if (t > r) r = t;
		t =
			f(b, 0, 0, i, j) +
			f(a, i, 0, i + m, j) +
			f(b, i + m, 0, m + m, j) +
			f(a, 0, j, i, j + m) +
			f(b, i, j, i + m, j + m) +
			f(a, i + m, j, m + m, j + m) +
			f(b, 0, j + m, i, m + m) +
			f(a, i, j + m, i + m, m + m) +
			f(b, i + m, j + m, m + m, m + m);
		if (t > r) r = t;
	}
	printf("%d\n", r);
	return 0;
}


Measured memory_bytes: 31488
#include <cstdio>
#include <iostream>
#include <math.h>
#include <string>
using namespace std;
string a, b;
int main(){
	cin >> a >> b;
	if(a.length() > b.length())  cout << "GREATER" << endl;
	else if(a.length() < b.length())  cout << "LESS" << endl;
	else {
		if(a > b) cout << "GREATER" << endl;
		else if(a < b) cout << "LESS " << endl;
		else cout << "EQUAL" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
program four_coloring
  implicit none
  integer :: h, w, d, c(500,500), i, j, p, q
  integer :: x(0:4000,-2000:2000)
  integer, parameter :: RYGB(0:3) = (/82,89,71,66/)
  character(500) :: s
  c = 0
  x = 0
  read(*,*) h, w, d
  do p = 0, 4000, d
    do q = -2000, 2000, d
      i = mod(p/d,2)+2*mod((q+2000)/d,2)
      x(p:min(p+d-1,4000),q:min(q+d-1,2000)) = RYGB(i)
    end do
  end do
  do i = 1, h
    do j = 1, w
      p = i+j
      q = i-j
      c(i,j) = x(p,q)
    end do
  end do
  do i = 1, h
    s = ""
    do j = 1, w
      s(j:j) = achar(c(i,j))
    end do
    write(*,'(a)') trim(adjustl(s))
  end do
  stop
end program four_coloring

Measured memory_bytes: 64000
n = int(input())
p = list(map(int, input().split()))

cnt = 0
swap = []
for i in range(n):
    if p[i] != i + 1:
        cnt += 1
        swap.append(i)
if cnt == 0:
    print('YES')
    exit()
if cnt == 2:
    p[swap[0]], p[swap[1]] = p[swap[1]], p[swap[0]]
    for i in range(n):
        if p[i] != i + 1:
            print('NO')
            exit()
    print('YES')
else:
    print('NO')


Measured memory_bytes: 3064
#include<iostream>

int main() {
	int a, b;
	std::cin >> a >> b;
	int i, ans = -1;
	for (i = 1; i <= 1000; i++) {
		if ((int)(i*0.08) == a&&(int)(i*0.1) == b) {
			ans = i;
			break;
		}
	}

	std::cout << ans << std::endl;

	return 0;
}

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

const int mod = 1000000007;

int main() {
	char S[101];
	scanf("%s", S);
	for (int i = 0; S[i] != 0; i++) {
		if (i % 2) {
			if (S[i] == 'R') {
				printf("No");
				return 0;
			}
		}
		else {
			if (S[i] == 'L') {
				printf("No");
				return 0;
			}
		}
	}
	printf("Yes");
	return 0;
}


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

int main(){
	
	for(int first=1; first < 10; ++first)
	{
		for(int second=1; second < 10; ++second)
		{
			cout << first << "x" << second << "=" << first * second << endl;
		}
	}

    return 0;
}

Measured memory_bytes: 1112
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
 
#define rep for(int i = 0;i<n;i++)
const long long MOD = 1000000007;

vector<vector<int>> graph(100001,vector<int>());

int main(){
  string s;cin >> s;
  string ans;
  if(s=="Sunny") ans = "Cloudy";
  else if(s=="Cloudy") ans ="Rainy";
  else if(s=="Rainy") ans ="Sunny";
  cout << ans << endl;
}

Measured memory_bytes: 2560
#include<iostream>
#include<vector>
#include<queue>
#include <cmath>
#include <string>
#include <algorithm>
using namespace std;

int main()
{
  int n,a;
  cin >>n;
  bool ist=false;
  
  if (n%10 == 9 || n/10 ==9)ist=true;
  
  if (ist==true){
    cout << "Yes";
  }else{
    cout << "No";
  }
  

    return 0;
}






Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> VI;
typedef vector<VI> VVI;//例: VVI dp(10, vector<int>(10, INF);
typedef priority_queue<int, vector<int>, less<int> > QUE_int;
const int INF = 2 * pow(10, 9) + 1;//+1しないとREになるかも(out of rangeになるんかな?? )

vector<int> dx = { -1, 0, 1, 0, -1, -1, 1, 1 };
vector<int> dy = { 0, -1, 0, 1, -1, 1, -1, 1 };

ll max(ll a, ll b) { return (a > b) ? a : b; }
ll min(ll a, ll b) { return (a < b) ? a : b; }

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

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = pow(10, 9) + 7;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x%mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const {
		mint res(*this);
		return res /= a;
	}
};
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
	vector<mint> fact, ifact;
	combination(int n) :fact(n + 1), ifact(n + 1) {
		assert(n < mod);
		fact[0] = 1;
		for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
		ifact[n] = fact[n].inv();
		for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
	}
	mint operator()(int n, int k) {
		if (k < 0 || k > n) return 0;
		return fact[n] * ifact[k] * ifact[n - k];
	}
};



template <typename TYPE>
void print_vec(const vector<TYPE>& v){
	for(int i=0; i<v.size(); i++){
		cout << v[i] << " ";
	}
	cout << endl;
}

vector<ll> enum_divisor(ll x){
	ll tmp = x;
	vector<ll> res;
	for(ll i=1; i*i<=x; i++){
		if(tmp%i == 0){
			res.push_back(i);
			if(i*i != tmp) res.push_back(tmp/i);//iが√tmpのときは重複して数えないようにする
		} 
	}
	return res;
}

////////////////////////////////////////////////////////////////
#define PI 3.14159265359
int main(void) {
	
	double R;
	cin >> R;
	
	double ans = 2 * PI * R;
  	cout << fixed;//小数点を確実に8桁で表示するためのもの
  	cout << setprecision(8) <<ans << endl; 


}



Measured memory_bytes: 3816
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
#include <numeric>
#include <string>

#define debug(s) cout << s << endl
#define debug1(s, t) cout << s << " " << t << endl

using namespace std;
using i64 = long long;

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

    double at;
    if (2 * x <= a * a * b)
    {
        double dn = 2.0 * (double)x;
        double up = a * b * b;
        at = atan(up / dn);
    }
    else
    {
        double up = 2.0 * (double)(a * a * b - x);
        double dn = a * a * a;
        at = atan(up / dn);
    }

    printf("%.10lf", at * 180.0 / acos(-1.0));

    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
sorta = sorted(a)
sflag = False
for i in range(n - 1):
  if sorta[i] == sorta[i + 1]:
    sflag = True
    break
if sflag == True:
  print('NO')
else:
  print('YES')

Measured memory_bytes: 25684
////#include "stdafx.h"
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <tuple>
#include <numeric>
#include <assert.h>
#include <functional>
#include <unordered_map>
#include <cstdint>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define REP(i, n)				for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)			for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF						2e9
#define MOD						(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)				(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)				(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)			((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)				(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)				(!IsOdd((x)))						
#define	BitSetV(Val,Bit)		((Val) |= (Bit))			
#define	BitTstV(Val,Bit)		((Val) & (Bit))				
#define ArrayLength(x)			(sizeof( x ) / sizeof( x[ 0 ]))
#define	MAX_QWORD				((QWORD)0xFFFFFFFFFFFFFFFF)
#define M_PI					3.14159265358979323846
typedef long long				ll;
typedef unsigned long long int	QWORD;
typedef unsigned long long		SQWORD;
typedef pair<ll, ll>			P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
vector<P> city[100001];

void dispY(int yLen)
{
	if (0 < yLen) {
		REP(i, yLen) {
			cout << "U";
		}
	} else {
		REP(i, yLen * -1) {
			cout << "D";
		}
	}
}

void dispX(int xLen)
{
	if (0 < xLen) {
		REP(i, xLen) {
			cout << "R";
		}
	} else {
		REP(i, xLen * -1) {
			cout << "L";
		}
	}
}

int main()
{
	int X;
	cin >> X;
	if (X == 7 || X == 5 || X == 3) cout << "YES";
	else cout << "NO";
	cout << endl;
	return 0;
}


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

int main() {
    int n;
    cin >> n;
    int H[n];

    for (int i=0; i<n; i++) cin >> H[i];
    int maxv = H[0];

    for (int i=1; i<n; i++) {
        maxv = max(maxv, H[i]);
        
        if(maxv - 1 - H[i] > 0) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 640