akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;


public class Main {
	
	public static void main(String[] args) throws IOException {	
		try(final Scanner sc = new Scanner(System.in)){
			final int N = sc.nextInt();
			
			int answer = 0;
			for(int i = 1; i <= N; i++) {
				final int a = sc.nextInt();
				if(i % 2 == 1 && a % 2 == 1) {
					answer++;
				}
			}
			
			System.out.println(answer);
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
		

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}


Measured memory_bytes: 32736
#include <iostream>
#include <vector>
#include <stack>

using namespace std;

struct Edge
{
	int to;
	bool odd;
};

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

	vector<vector<Edge>> edges(n, vector<Edge>());
	for(int i = 0; i < n - 1; i++) {
		int u, v, w;
		cin >> u >> v >> w;
		Edge e1 = {v - 1, w % 2 == 1}, e2 = {u - 1, w % 2 == 1};
		edges[u - 1].push_back(e1);
		edges[v - 1].push_back(e2);
	}

	bool odd[100000];
	odd[0] = false;
	bool checked[100000];
	for(int i = 0; i < 100000; i++) {
		checked[i] = false;
	}
	stack<int> stack;
	stack.push(0);
	checked[0] = true;
	while(!stack.empty()) {
		int s = stack.top();
		stack.pop();
		for(Edge e : edges[s]) {
			int t = e.to;
			if(!checked[t]) {
				checked[t] = true;
				odd[t] = odd[s] ^ e.odd;
				stack.push(t);
			}
		}
	}

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

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

int N, M, T;
int A[100];

int main() {
    cin >> N >> M >> T;
    for (int j = 0; j < N; ++j) {
        cin >> A[j];
    }

    int study[20101];
    fill(study, study+20101, 0);
    study[0] = 1;
    study[20100] = -1;
    for (int j = 0; j < N; ++j) {
        --study[A[j]-M];
        ++study[A[j]+M];
    }

    int count = 0;
    for (int j = 0; j < T; ++j) {
        if (j > 0) { study[j] += study[j-1]; }
        count += study[j] > 0 ? 1 : 0;
    }
    cout << count << endl;
    return 0;
}

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

using namespace std;

#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second

template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }

typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1ll<<29;
const bool debug = 0;

int p[5] = {1868, 1912, 1926, 1989, 2017};
char c[4] = {'M', 'T', 'S', 'H'};
int E, Y;

int main() {
	cin >> E >> Y;
	if (E == 0) {
		int idx;
		REP(i, 4) {
			if (p[i] <= Y && Y < p[i + 1]) {
				idx = i;
				break;
			}
		}
		
		printf("%c%d\n", c[idx], Y - p[idx] + 1);
	}
	else {
		printf("%d\n", Y + p[E-1] - 1);
	}
	return 0;
}

Measured memory_bytes: 3228
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
    	int k = sc.nextInt();

    	String aaa = Integer.toString(n,k);

    	System.out.println(aaa.length());
    }
}

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

#define pb push_back
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define REP(i,n) for(int _n=n, i=0;i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)
#define FORD(i,a,b) for(int i=(a),_b=(b);i>=_b;--i)
using ull = uint64_t;
using ll = int64_t;
using PII = pair<int, int>;
using VI = vector<int>;

string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B> string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
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; }
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 debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

const ll mod = 1000000007;

int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    int n, m;
    cin >> n >> m;
    int ans = 0;
    if (n > 0) {
    	ans += n * (n - 1) / 2;
    }
    if (m > 0) {
    	ans += m * (m - 1) / 2;
    }
    cout << ans << endl;

}

Measured memory_bytes: 256
def slove():
    import sys
    import itertools
    input = sys.stdin.readline
    n, m = list(map(int, input().rstrip('\n').split()))
    ks = [list(map(int, input().rstrip('\n').split())) for _ in range(m)]
    p = list(map(int, input().rstrip('\n').split()))
    ls = [True, False]
    cnt = 0
    for it in itertools.product(ls, repeat=n):
        b = True
        for j, v in enumerate(ks):
            tc = 0
            for i in range(len(v)):
                if i != 0:
                    if not it[v[i]-1]:
                        tc += 1
            if tc % 2 != p[j]:
                b = False
        if b:
            cnt += 1
    print(cnt)


if __name__ == '__main__':
    slove()


Measured memory_bytes: 41840
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PipedInputStream;
import java.util.*;

public class Main {
    private static final int MOD = (int) Math.pow(10, 9);
    private static final int[][] DIRS = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};

    public static void main(String[] args) {
        FastReader sc = new FastReader();
        int a = sc.nextInt();
        int b = sc.nextInt();
        print("" + ( b * 2 - a));
        System.exit(0);
    }

    static  private void print(String s) {
        System.out.println(s);
    }

    static private int log2(int x) {
        return (int)(Math.log(x) / Math.log(2));
    }

    static private long gcd(long m, long n) {
        if (m < n) { return gcd(n, m); }
        if (m % n == 0) { return n; }
        return gcd(n, m%n);
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try{
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


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

int main(void)
{
    char s[4];
    scanf("%s", s);

    int a=0, b=0;
    if(strncmp(&s[0],"0",1)==0 && strncmp(&s[1],"0",1)!=0) a=1;
    if(strncmp(&s[0],"1",1)==0 && (strncmp(&s[1],"0",1)==0 || strncmp(&s[1],"1",1)==0 || strncmp(&s[1],"2",1)==0)) a=1;

    if(strncmp(&s[2],"0",1)==0 && strncmp(&s[3],"0",1)!=0) b=1;
    if(strncmp(&s[2],"1",1)==0 && (strncmp(&s[3],"0",1)==0 || strncmp(&s[3],"1",1)==0 || strncmp(&s[3],"2",1)==0)) b=1;

    if(a==0 && b==0) printf("NA");
    else if(a==0 && b==1) printf("YYMM");
    else if(a==1 && b==0) printf("MMYY");
    else printf("AMBIGUOUS"); 

    return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;
typedef long long ll;
const int MAXN = 1e5+10;

int n;
ll a[MAXN];

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

void solve() {
  ll ans = a[0];
  for (int i=1;i<n;i++) {
    ans = gcd(ans, a[i]);
  }
  cout << ans << endl;
}

int main() {
  cin >> n;
  for (int i=0;i<n;i++) {
    cin >> a[i];
  }
  solve();
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<complex>
#define lol(i,n) for(int i=0;i<n;i++)
#define out(x) cout<<(x?"Yes":"No")<<endl;
#define mod 1000000007
typedef long long ll;

using namespace std;

int main(){
    int r;cin>>r;
    if(r<1200)cout<<"ABC"<<endl;
    else if(r<2800)cout<<"ARC"<<endl;
    else cout<<"AGC"<<endl;
    return 0;
}


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

int d, n, m, shop[100001], k[10000];

int main()
{
	while (true){
		cin >> d;
		if (!d) break;
		cin >> n >> m;
		for (int i = 1; i < n; i++){
			cin >> shop[i];
		}
		shop[0] = 0;
		shop[n] = d;
		for (int i = 0; i < m; i++){
			cin >> k[i];
		}

		sort(shop, shop + n);
		int sum = 0;
		for (int i = 0; i < m; i++){
			int *s2 = upper_bound(shop, shop + n + 1, k[i]);
			int *s1 = s2 - 1;
			sum += min(k[i] - *s1, *s2 - k[i]);
		}
		cout << sum << endl;
	}
	return 0;
}

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

int main(void) {
  string s,t;
  cin >> s >> t;

  string need(t.size(),'?');
  bool ok = false;
  for (int i = s.size()-1; i >= 0; i--) {
    if (i + t.size()-1 < s.size()) {
      int id = i;
      for (int j = 0; j < t.size(); j++) {
        if (!(s[i+j] == '?' || s[i+j] == t[j])) {
          id = -1;
          break;
        }
      }
      if (id != -1) {
        for (int j = 0; j < t.size(); j++) {
          s[id+j] = t[j];
        }
        ok = true;
        break;
      }
    }
  }
  if (ok) {
    for (int i = 0; i < s.size(); i++) {
      if (s[i] == '?') s[i] = 'a';
    }
    cout << s << endl;
  } else {
    cout << "UNRESTORABLE" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
n = int(input())
a = [int(input())-1 for _ in range(n)]
# -1をしたので、if a[s] == 1になったら終了
#print(a)
cnt = 0
visit = [0] #出発点は訪れてる
i = 0 # bottom position a[i] = next_bottom
while cnt <= n:#無限ループになる理由がわからん in が最悪のケースでO(nlogn)
    cnt += 1
    #print(visit)
    """if a[i] in visit:#循環するのでbreak
        print(-1)
        exit(0)"""
    if a[i] == 1: #ボタン２を押すので今までの回数を答える
        print(cnt)
        exit(0)
    else:# i を更新　visitに現在のボタンを追加する
        #visit.append(a[i])
        i = a[i]
print(-1)

Measured memory_bytes: 7112
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10; //1e-9?
constexpr ld pi = 3.1415926535897932;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

void acc(VL& x) { FOR(i, 1, x.size())x[i] += x[i - 1]; }
ll sum(VL& x, int l, int r) { return (l == 0 ? x[r] : x[r] - x[l - 1]); }

ll dif(VL& x, int l, int m, int r) { return abs(sum(x, l, m - 1) - sum(x, m, r)); }

void solve(VL& ret, VL& x, int le, int ri) {
    int l = le + 1, r = ri;
    while (r - l > 2) {
        int m1 = (l * 2 + r) / 3, m2 = (l + r * 2) / 3;
        if (dif(x, le, m1, ri) < dif(x, le, m2, ri))r = m2;
        else l = m1;
    }
    ll a = -LLINF, b = LLINF;
    eFOR(i, l, r)if (dif(x, le, i, ri) < b - a) {
        a = sum(x, le, i - 1);
        b = sum(x, i, ri);
    }
    ret.push_back(a);
    ret.push_back(b);
}

int main() {
    init();

    int n; cin >> n;
    VL a(n); cin >> a;
    acc(a);

    ll ans = LLINF;
    FOR(i, 1, n - 2) {
        VL s;
        solve(s, a, 0, i);
        solve(s, a, i + 1, n - 1);
        SORT(s);
        chmin(ans, s[3] - s[0]);
    }
    cout << ans << "\n";
}

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

int main() {
  int n, m;
  while (true) {
    cin >> n >> m;
    if (n==0 && m==0) {
      break;
    }
    int a[n];
    for (int i=0; i<n; i++) {
      cin >> a[i];
    }
    int ans = -INT_MAX;
    for (int i=0; i<n; i++) {
      for (int j=0; j<n; j++) {
	if (i!=j && a[i]+a[j]<=m) {
	  ans = max(ans,a[i]+a[j]);
	}
      }
    }
    if (ans<0) {
      cout << "NONE" << endl;
    } else {
      cout << ans << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std ;
int h , n ;
int main()
{
	int x ;
	scanf("%d%d" , &h , &n) ;
	while(n --)  scanf("%d" , &x) , h -= x ;
	if(h <= 0)  printf("Yes\n") ;
	else  printf("No\n") ;
	return 0 ;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
int main(){
    int n;
    std::string s1, s2, s3;
    std::cin >> s1;
    std::cin >> s3;
    s2 =s1;
    n = s1.length();
    for(int i=0; i<=n; i++){
        s2 = s2[n-1]+s2.substr(0,n-1);
        if( s2 == s3 ){
            std::cout << "Yes" << std::endl;
            return 0;
        }
    }   
    std::cout << "No" << std::endl;
    return 0;
}


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


int main()
{
    int a,b;
    cin>>a>>b;
    if(a%3==0)
    {
        cout<<"Possible";
    }
    else if(b%3==0)
            {
                cout<<"Possible";
            }
            else if(( a+b )%3 ==0)
            {
                cout<<"Possible";
            }
            else
                cout<<"Impossible";

}


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

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) if((x)>(y))(x)=(y)
#define chmax(x,y) if((x)<(y))(x)=(y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<bool> vb;
typedef vector<ld> vld;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b/gcd(a,b);}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int k;
double l, r, p, e, t, res;

void rec(double l, double r, double ps, int n) {
	double h = (l+r)/2;
	if (n==k) {
		if (fabs(h-t)<=e) res += ps;
		return;
	}
	if (h>=t) rec(l,h,ps*(1.0-p),n+1), rec(h,r,ps*p,n+1);
	else rec(h,r,ps*(1.0-p),n+1), rec(l,h,ps*p,n+1);
}

signed main() {
	cin >> k >> l >> r >> p >> e >> t;
	rec(l,r,1,0);
	printf("%.10lf\n",res);
}


Measured memory_bytes: 3308
#include <iostream>
#include <cstdio>
#include <map>
#define PII pair<ll, ll>
#define F first
#define S second
using namespace std;

typedef long long ll;
ll h, w, n, c[15];
PII t;
map<PII, ll> m;
int main()
{
	ll i, j, t1, t2, t3;
	cin >> h >> w >> n;
	c[0] = (h - 2) * (w - 2);
	while (n--) {
		scanf("%lld %lld", &t1, &t2);
		for (i = t1; i < t1 + 3; i++) {
			for (j = t2; j < t2 + 3; j++) {
				if (i > 2 && j > 2 && i <= h && j <= w) {
					t.F = i, t.S = j;
					t3 = m[t]++;
					c[t3]--, c[t3 + 1]++;
				}
			}
		}
	}
	for (i = 0; i <= 9; i++) printf("%lld\n", c[i]);
    return 0;
}

Measured memory_bytes: 56448
A,B,C=map(int,input().split())
x=dict()
x[5]=0
x[7]=0

if A==5:
    x[5]+=1
elif A==7:
    x[7]+=1
if B==5:
    x[5]+=1
elif B==7:
    x[7]+=1
if C==5:
    x[5]+=1
elif C==7:
    x[7]+=1
flag=False
if x[5]==2:
    if x[7]==1:
        flag=True

if flag:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;
const int INF = 1000000000;
const ll LINF = 1000000000000000000; //1e18
const double EPS = 1e-10;

int main(void)
{
    string T;
    cin >> T;

    if (T[0] == '?')
    {
        if (T[1] == 'D' || T[1] == '?')
        {
            T[0] = 'P';
        }
        else
        {
            T[0] = 'D';
        }
    }

    for (int i = 1; i < T.size() - 1; i++)
    {
        if (T[i] == '?')
        {
            if (T[i - 1] == 'P')
            {
                T[i] = 'D';
            }
            else if (T[i - 1] == 'D')
            {
                if (T[i + 1] == 'D')
                {
                    T[i] = 'P';
                }
                else if (T[i + 1] == 'P')
                {
                    T[i] = 'D';
                }
                else if (T[i + 1] == '?')
                {
                    T[i] = 'P';
                }
            }
        }
    }

    if (T[T.size() - 1] == '?')
    {
        T[T.size() - 1] = 'D';
    }

    for (int i = 0; i < T.size(); i++)
    {
        cout << T[i];
    }
    printf("\n");
    return (0);
}

Measured memory_bytes: 3748
from collections import Counter

def p(x):
    a=[]
    while x%2==0:
        a.append(2)
        x//=2
    f=3
    while f*f<=x:
        if x%f==0:
            a.append(f)
            x//=f
        else:
            f+=2
    if x!=1:
        a.append(x)
    return a

N=int(input())
c=Counter(p(N))
ans=0
for k,v in c.items():
    i=1
    j=1
    while i<=v:
        ans+=1
        j+=1
        i+=j
print(ans)

Measured memory_bytes: 9464
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
cnt = float('inf')
ans = 0
for i in range(n):
  ans += b[a[i]-1]
  if a[i] == cnt+1:
    ans += c[a[i]-2]
  cnt = a[i]
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int mod = 1e9 + 7;
const int inf = 2e18;

signed main() {
    int N;
    cin >> N;
    map<int, int> check;
    for (int i = 0; i < N; i++) {
        int temp;
        cin >> temp;
        if (check[temp] == 1) {
            cout << "NO" << endl;
            return 0;
        }
        check[temp] = 1;
    }
    cout << "YES" << endl;
}

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

#define stdi stdin
#define stdo stdout

#define dbl double 
#define llo long long 

#define sz size
#define pb push_back
#define mp make_pair

#define st first 
#define nd second 
#define mid ((l+r)>>1)

#define ft(i,a,b) for (int i=(int)a;i<=(int)b;i++)
#define fd(i,a,b) for (int i=(int)a;i>=(int)b;i--)

using namespace std;
const llo oo=1e13;
const int nmax=4e5+100;
int n;
llo dp[nmax][2],a[nmax];
int main()
{
    ios_base::sync_with_stdio(false);
    //freopen("SelectHalf.inp","r",stdi);
    //freopen("SelectHalf.out","w",stdo);
    cin>>n;
    ft(i,1,n) 
    {
        cin>>a[i];
        //dp[i]=-oo;
    }
    dp[2][0]=a[1],dp[2][1]=a[2];
    ft(i,3,n)
    {
        if (i%2)
        {
            dp[i][0]=max(dp[i-1][0],dp[i-1][1]);
            dp[i][1]=max(dp[i-2][1],dp[i-2][0])+a[i];
        }
        else 
        {
            dp[i][0]=a[i-1]+dp[i-2][0];
            dp[i][1]=max(dp[i-2][0],dp[i-2][1])+a[i];

        }
        //cout<<i<<": "<<dp[i][0]<<" "<<dp[i][1]<<endl;
    }
    cout<<max(dp[n][0],dp[n][1]);
}

Measured memory_bytes: 8304
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8931145141919364364,LMOD=998244353;
inline long long mod(long long n,long long m){return(n%m+m)%m;}
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

int main(){
    int n,h,w; cin>>n>>h>>w;
    cout<<(n-h+1)*(n-w+1)<<endl;
    return 0;
}


Measured memory_bytes: 256
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

const int N = 303 , P = 1e9 + 7;
int n , a[N][N] , f[N][N] , pw2[N * N];
int Pow(int x,int t) {int r=1;for(;t;t>>=1,x=ll(x)*x%P)if(t&1)r=ll(r)*x%P;return r;}
inline void pp(int &x,int d) {if((x+=d)>=P)x-=P;}
inline int mul(int a,int b) {return ll(a)*b%P;}

int main(){
  rep(i,0,N*N) pw2[i] = i ? pw2[i-1] * 2 % P : 1;
  scanf("%d",&n);
  rep(i,0,n) rep(j,0,n) scanf("%d",a[i]+j);
  int rank = 0;
  rep(j,0,n) {
    int id = -1;
    rep(i,rank,n) if(a[i][j]) {
      id = i;
      break;
    }
    if(id == -1) continue;
    rep(k,0,n) swap(a[rank][k] , a[id][k]);
    rep(i,rank+1,n) if(a[i][j]) {
      rep(k,0,n) a[i][k] ^= a[rank][k];
    }
    rank++;
  }
  f[0][0] = 1;
  rep(i,0,n) rep(j,0,i+1) if(f[i][j]) {
    pp(f[i+1][j] , mul(f[i][j] , pw2[j]));
    pp(f[i+1][j+1] , mul(f[i][j] , (pw2[n] - pw2[j] + P) % P));
  }
  int ans = 0;
  rep(i,rank,n+1) pp(ans , mul(f[n][i] , mul(f[i][rank] , pw2[n*(n-i)])));
  ans = mul(ans , Pow(f[n][rank] , P - 2));
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 1280
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

int main()
{
	string s;
	cin >> s;

	string res;
	for (int i= 0; i < s.length(); i += 2)
	{
		res += s.substr(i, 1);
	}

	cout << res << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
using namespace __gnu_pbds; 
using namespace std;
#define ull         unsigned long long int
#define ll          long long int
#define pb          push_back
#define pii         pair<int,int>
#define F           first
#define S           second
#define vi          vector<int>
#define vli          vector<ll>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define M_PI        3.14159265358979323846
#define mp          make_pair
#define sz(x)       (int)x.size()
#define matrix      vector<vector<ll>>
#define forn(i,a,b)  for(int i=a;i<b;i++)
#define eps 0.0000000001
#define all(a)      (a).begin(),(a).end()
#define ordered_set     tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update> 
 
const long long INF = (long long) 1e11+1;
const long long mod = (long long) 998244353;
const long long hell = (long long) 1000000007;

ll power(ll x,ll y,ll m){
  ll res=1;
  while(y>0){
    if(y%2) res=(x%m*res%m)%m;
    x=(x%m*x%m)%m;    
    y=y/2;
  }
  
  return res%m;
}
 
ll modinv(ll x){
  return power(x,hell-2,1);
}

ll gcd(ll a,ll b){
    while(b!=0){
		ll t=b;
		b=a%t;
		a=t;
	}
	return a;
}    
    
void fastIO(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
} 

void solve(){
    int x;
    cin>>x;
    
    int f=(x+1000-1)/1000;
    f*=1000;
    f-=x;
    cout<<f;
}    
    
int main(){
   fastIO();
   int test;
   //cin>>test;
   test=1;    
   
   while(test--)
   solve();
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main() {
  ll N, A, B;
  cin >> N >> A >> B;
  ll ans = N / (A+B) * A;
  ll a = N % (A+B);
  ans += min(A,a);
  cout << ans << endl;
  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}
#define MPlus(x,y) {x=(x+y)%M;}
#define MSub(x,y) {x=(x-y+M)%M;}
#define MMul(x,y) {x=(x*y)%M;}


signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);

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


}

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

int main() {

  int N;
  cin >> N;
  vector <int> a(N);
  for (int i = 0; i < N; i++) 
      cin >> a.at(i);
  int ans = 1000000;
  for (int i = 1; i <= 100; i++) {
      int T =0;
      for (int j = 0; j < N; j++) {
          T += (a.at(j)-i)*(a.at(j)-i);
      }
      if(T<ans)
        ans = T;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
/************************Code by Hardik Aggarwal!!!!***********************************/


#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
using namespace std;

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL); 

#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double
/*#define endl '\n'*/
#define debug cout << "Hold right there sparky.....\n";
#define forn(low,high,i) for(i=low;i<high;i++)
#define forrev(high,low,i) for(i = high; i>= low;i--)
#define trace(x) cerr << #x << ": " << x << " " << endl;

typedef long long int ll;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
const ll mod =1e9+7;
const ll maxn=100005;
vector<vector<vector<ld>>> memo(3e2+5, vector<vector<ld>>(3e2+5, vector<ld> (3e2+5, -1)));
 
ld dp(int n, int n1, int n2, int n3){
	if(n1 == 0 && n2 == 0 && n3 == 0)
		return 0;
	if(memo[n3][n2][n1] != -1)
		return memo[n3][n2][n1];
 
	memo[n3][n2][n1] = 0;
	if(n3)
		memo[n3][n2][n1] += (1+dp(n, n1, n2+1, n3-1))*n3/(ld)n;
	if(n2)
		memo[n3][n2][n1] += (1+dp(n, n1+1, n2-1, n3))*n2/(ld)n;
	if(n1)
		memo[n3][n2][n1] += (1+dp(n, n1-1, n2, n3))*n1/(ld)n;
	memo[n3][n2][n1] += (n-n1-n2-n3)/(ld)n;
	memo[n3][n2][n1]/=(1-(n-n1-n2-n3)/(ld)n);
	return memo[n3][n2][n1];
}

int main()
{
	
	IOS


	ll n;
	cin>>n;
	ll a[n];
	ll cnt[4];
	memset(cnt,0,sizeof(cnt));
	for(ll i=0;i<n;i++)
		{
			cin>>a[i];
			cnt[a[i]]++;
		}

	

	cout<<setprecision(15)<<dp(n,cnt[1],cnt[2],cnt[3]);







}
	

Measured memory_bytes: 450816
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
#include <cassert>
#include <random>
#include<iostream>
#include<cmath>

struct Point {
	double x, y;
	double distance_from(const Point that) const {
		return std::sqrt((x - that.x) * (x - that.x) + (y - that.y) * (y - that.y));
	}
};
int factorial(int n) {
	int result = 1;
	while (n != 0) {
		result *= n--;
	}
	return result;
}
int main() {
	int n; std::cin >> n;
	std::vector<Point> points(n);
	for (auto& p : points) std::cin >> p.x >> p.y;
	long double sum_distance = 0;
	for (auto i = 0; i < n; ++i) {
		for (auto j = i + 1; j < n; ++j) {
			sum_distance += points[i].distance_from(points[j]) * factorial(n - 1) * 2;
		}
	}
	std::cout << std::fixed << std::setprecision(15) << sum_distance / factorial(n) << '\n';
}


Measured memory_bytes: 888
#include <iostream>
#include <queue>
#include <map>
#include <bitset>
#include <string>
#include <set>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <iomanip>
#include <ctime>
#include <stack>
#include <cstdlib>
#include <numeric>
#include <cassert>
#include <complex>
#include <iterator>
//#include <unordered_map>
using namespace std;
#define maxn 500007
#define maxm 400007
#define maxq 1000007
#define maxl 1234
#define modn 998244353 
#define scan(a) scanf("%d",&a)
#define scanl(a) scanf("%lld",&a)
#define scanl2(a,b) scanf("%lld%lld",&a,&b)
#define scans(a) scanf("%s",a)
#define scans2(a,b) scanf("%s%s",a,b)
#define scand(a) scanf("%lf",&a)
#define scan2(a,b) scanf("%d%d",&a,&b)
#define scand2(a,b) scanf("%lf%lf",&a,&b)
#define scan3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define scan4(a,b,c,d) scanf("%d%d%d%d",&a,&b,&c,&d)
#define scan5(a,b,c,d,e) scanf("%d%d%d%d%d",&a,&b,&c,&d,&e)
#define print(a) printf("%d\n",a);
#define printl(a) printf("%lld\n",a);
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define rrep(i,a,b) for(int i=a;i>= b;i--)
#define fscan(a) fscanf(stream,"%d", &a);
#define mp      make_pair	
#define pb      push_back
#define eb      emplace_back
#define mm(a,b) memset(a,b,sizeof a)
#define log2(n) (double)(log(n) / log(2.0))
#define _crt_disable_perfcrit_locks
#define bll __int128
#pragma warning(disable:4996)
typedef long long ll;
typedef unsigned long long ull;
const int inf = 0x3f3f3f3f;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef map <ll, ll> mll;
typedef pair <ll, ll> pll;
typedef map <int, int> mii;
typedef pair <int, int> pii;
typedef map <char, int> mci;
typedef map <char, char> mcc;
typedef pair <char, int> pci;
typedef complex<double> cd;
typedef vector<complex<double> > vcd;
const double eps = 1e-8;
const double PI = 2 * acos(0.0);

int cc, bb; char ch; inline int F() {
	while (ch = getchar(), (ch < 48 || ch> 57) && ch != '-'); ch == '-' ? cc = bb = 0 : (cc = ch - '0', bb = 1);
	while (ch = getchar(), ch > 47 && ch < 58)cc = (cc << 1) + (cc << 3) + (ch ^ 48); return bb ? cc : -cc;
}
void write(int x) {
	int y = 10, len = 1;
	while (y <= x) { y *= 10; len++; }
	while (len--) { y /= 10; putchar(x / y + 48); x %= y; }
}
ll pow2(ll a, ll b, ll mod) {
	ll r = 1, base = a;
	while (b) {
		if (b & 1) r = r * base % mod;
		base = base * base % mod;
		b >>= 1;
	}
	return r;
}
ll inv(ll a, ll n) {
	return pow2(a, n - 2, n);
	//return pow2(a, oula(n) - 1, n);
}
int main() {
	//ios::sync_with_stdio(0);
	//cin.tie(0);
	//FILE* stream = fopen("L:/20.in", "rb+")
	int n;
	cin >> n;
	ll res = 0;
	for (int i = 1; i <= n ; i++){
		if(i%3==0||i%5==0)continue;
		res += i;
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 3632
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int main() {
	char a[1005], b[1005];
	while(~scanf("%s %s", a, b)) {
	int lena, lenb;
	lena = strlen(a);
	lenb = strlen(b);
	int flag = 0;
	if(lena < lenb)	printf("LESS\n");
	else if(lena > lenb) printf("GREATER\n");
	else {
		for(int i = 0; i < lena; i++) {
			if(a[i] > b[i]) {
				flag = 1;
				printf("GREATER\n");
				break;
			}
			else if(a[i] < b[i]) {
				flag = 1;
				printf("LESS\n");
				break;
			}
		}
		if(flag == 0) printf("EQUAL\n");
	}
	}
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, x, z, min;
  z = 0;
  cin >> N;

  for (int i = 0; i < N; i++){
    cin >> x;
    if (x == 0){
      min = 0;
    break;
    }
    else{
         z = 0;
         while (x % 2 == 0){
         z++;
         x /= 2;
         }
         if (i == 0){
         min = z;
         continue;
         }
         else if (min > z){
         min = z;
         }
    }
  }
  cout << min <<endl;
}

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

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define f(i,a,b) for(int i=a;i<b;i++)
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
int ketasuu(int x){
  int n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}


ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

int main(){
  int n;cin>>n;
  vi x(n) ,y(n);
  rep(i,n) cin>>x[i]>>y[i];
  double ans =0;
  rep(i,n){
    rep(j,n){
      ans +=sqrt( (x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]) ) ;
    }
  }
  ans = ans /(double)n;
  printf("%.10lf\n",ans );
  

  
}
  

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

namespace competitive_programming
{
    class Program
    {
        static void Main(string[] args)
        {
            var main = new Program();
            main.solve();
        }

        void solve()
        {
            int N = int.Parse(Console.ReadLine());
            var S = Console.ReadLine();
            long r = S.Count(c => c == 'R');
            long g = S.Count(c => c == 'G');
            long b = S.Count(c => c == 'B');
            long count = r * g * b;
            

            for(int i = 0;i < N; i++)
            {
                for(int j = 1;j < N; j++)
                {
                    if (i - j < 0 || i + j >= N || i - j >=N || i + j < 0) continue;
                    if (S[i - j] != S[i] && S[i] != S[i + j] && S[i - j] != S[i + j]) count--;
                }
            }
            if (count < 0) count = 0;

            Console.WriteLine(count);
        }

        public static long Gcd(long a, long b)
        {
            Func<long, long, long> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
    }

    struct Vector2
    {
        public Vector2(long x, long y)
        {
            this.x = x;
            this.y = y;
        }
        public long x;
        public long y;
    }

    struct Vector3
    {
        public int x;
        public int y;
        public int z;
    }
}


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

const int Maxn = 2005;

int n, x, y;
int dist[Maxn][Maxn];
int res[Maxn];

int main()
{
    scanf("%d %d %d", &n, &x, &y);
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= n; j++)
            dist[i][j] = abs(i - j);
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= n; j++)
            dist[i][j] = min(dist[i][j], min(dist[i][x] + 1 + dist[y][j], dist[i][y] + 1 + dist[x][j]));
    for (int i = 1; i <= n; i++)
        for (int j = i + 1; j <= n; j++)
            res[dist[i][j]]++;
    for (int i = 1; i < n; i++)
        printf("%d\n", res[i]);
    return 0;
}


Measured memory_bytes: 15872
def encode(s):
#  r = [0]*26
#  for n in range(len(s)):
#    r[ord(s[n]) - ord('a')] += 1
#  return r
#  r = list(s)
#  r.sort()
#  return r
  r = 0
  for n in range(len(s)):
    so = ord(s[n]) - ord('a')
    r += 11**so
  return r

N = int(input())

S = [0]*N

for n in range(N):
  s = str(input())
  S[n] = encode(s)

S.sort()

ct = 0
M=1
ps=""
for cs in S:
  if cs==ps:
    M+=1
  else:
    ct += int((M**2-M)/2)
    M=1
    ps=cs
ct += int((M**2-M)/2)

print(ct)
      
  

Measured memory_bytes: 62668
//#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

#define rep(i,n) for(ll (i)=0;(i)<(ll)(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007LL
#define INF (1LL<<60LL)
#define int long long
#define MAX_N (100001)
typedef long long ll;

using namespace std;


signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n; cin >> n;
	vector<int> v(n);
	rep(i, n) cin >> v[i];
	int cnt = 0;
	int ans = 0;
	rep(i, n - 1) {
		if (v[i] >= v[i + 1]) cnt++;
		else cnt = 0;
		ans = max(ans, cnt);
	}
	cout << ans << endl;
}

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

#define ll long long
#define ld long double
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define FOR(I,N) for(I=0;I<N;++I)

int dp[3001][3001];
string s,t;

int solve(int x, int y)
{
	if(x<0 || y<0)
		return 0;
	if(dp[x][y]!=-1)
		return dp[x][y];
	if(s[x]==t[y])
		dp[x][y]=1+solve(x-1,y-1);
	else
		dp[x][y]= max(solve(x-1,y),solve(x,y-1));
	return dp[x][y]; 
}

int main()
{
	memset(dp,-1,sizeof(int)*(3001*3001));
	cin>>s>>t;
	int x=s.size();
	int y=t.size();
	--x;--y;
	int n = solve(x,y);
	if(n==0)
	{
		cout<<' ';
		return 0;
	}
	string ans(n,'x');
	--n;
	while(x>0 && y>0 && n>=0)
	{
		if(dp[x-1][y-1]+1 == dp[x][y] && s[x]==t[y])
		{
			ans[n] = s[x];
			--x;--y;
			--n;
		}
		else if(dp[x-1][y-1] == dp[x][y])
		{
			--x;--y;
		}
		else
		{
			if(dp[x-1][y]>=dp[x][y-1])
				--x;
			else
				--y;
		}
	}
	if(n==0)
	{
		if(x==0)
			ans[x]=s[x];
		else
			ans[y]=t[y];
	}
	cout<<ans;
}

Measured memory_bytes: 35712
#include <iostream>
#include <fstream>
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <functional>
#include <string> 
#include <vector>
#include <bitset>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

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

const ll MOD = (ll)1e9 + 7;
const ll HINF = (ll)1e18;
const ll LINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;

template<class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl;exit(0);}else return;}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
void YN(bool flg) {cout << ((flg) ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << ((flg) ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << ((flg) ? "yes" : "no") << endl;}

int main() {
	ll N,K; cin >> N >> K;
	V<ll> dp(K+2,0),a(N);
	REP(i, N) cin >> a[i];
	corner(K == 0, 1);
	dp[K] = 1;
	REP(i,N){
		auto tmp = dp;

		for (int j = K; 0 <= j; --j) (tmp[j] += tmp[j + 1]) %= MOD;
		for (int j = K - 1; 0 <= j; --j) (dp[j] += (MOD + tmp[j + 1] - tmp[min(j + 1 + a[i],K+1)])%MOD) %= MOD;		
	}
	cout << dp[0] << endl;
	return 0;
}



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

#define LLINF (1LL<<60)
typedef long long ll;

//C++14 (GCC 5.4.1)
ll gcd(ll x, ll y) {
  if (y == 0) return x;
  return gcd(y, x%y);
}
int main() {
    ll A,B,C,D;
    cin >>A>>B>>C>>D;
    
    //-----------------------------------
    ll gcdcd=gcd(C,D);
    ll lcmcd=C*D/gcdcd;
    ll toB=B-B/C-B/D+B/lcmcd;
    ll toAm=A-1-(A-1)/C-(A-1)/D+(A-1)/lcmcd;
    ll ans = toB-toAm;
    

    cout << ans <<endl;
    return (0);
}

Measured memory_bytes: 256
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**8) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n,m = li()
ball = [1]*n
inred = [0]*n
inred[0] = 1

for _ in range(m):
    x,y = li_()
    if inred[x] and ball[x] == 1:
        inred[x] = 0
        ball[x] = 0
        
        inred[y] = 1
        ball[y] += 1
        
    elif inred[x] and ball[x] > 1:
        ball[x] -= 1
        
        inred[y] = 1
        ball[y] += 1
        
    else:
        ball[x] -= 1
        ball[y] += 1
        
ans = 0
for ri in inred:
    ans += ri
print(ans)

Measured memory_bytes: 4596
#include <stdio.h>
char a[110];
long long k;
long long ans;
long long l=1;
long long t;
bool start = true;
bool same = false;
int main(){
	scanf("%s",a);
	scanf("%lld",&k);
	for(int i=0;a[i]!=0;i++){
		if(a[i]==a[i+1]){
			l++;
		} else if(a[i+1]==0&&a[i]==a[0]){
			same = true;
		} else {
			if(start){
				start = false;
				t = l;
			} else {
				ans += l/2;
			}
			l=1;
		}
	}
	if(start) printf("%lld\n",(l*k)/2);
	else if(same) printf("%lld\n",((t+l)/2)*(k-1)+t/2+l/2+ans*k);
	else printf("%lld\n",(l/2+t/2+ans)*k);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
#define f(i, l, r) for (int i = l; i <= r; i++)
#define rf(i, r, l) for (int i = r; i >= l; i--)
#define all(x) (x).begin(), (x).end()
#define sf(a) scanf("%d",&a)
#define llsf(a) scanf("%lld", &a)
#define l l
#define r r
#define lch (o << 1)
#define rch (o << 1 | 1)
#define mid ((l + r) >> 1)
#define mem(x, y) memset(x, y, sizeof(x))

const int inf = 2e9 + 7;
const ll INF = INT64_MAX;
double eps = 1e-6;
int mod = 1e9 + 7;
const int N = 1e6 + 10;
const double pi = acos(-1.0);

int main() {
#ifdef local
	freopen("in.txt", "r", stdin);
#endif
	int n; sf(n);
	cout << ((n % 2) ? n * 2 : n);
}

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

using namespace std;

int main() {
  vector<vector<int>> vec(3, vector<int>(3));
  for (int i = 0; i < 3; ++i)
    for (int j = 0; j < 3; ++j)
      cin >> vec[i][j];

  bool flag = false;
  for (int a1 = 0; a1 <= 100; ++a1) {
    int b1 = vec[0][0] - a1;
    int b2 = vec[0][1] - a1;
    int b3 = vec[0][2] - a1;
    int a2 = vec[1][0] - b1;
    int a3 = vec[2][0] - b1;
    vector<int> as = {a1, a2, a3};
    vector<int> bs = {b1, b2, b3};
    bool flag2 = true;
    for (int i = 0; i < 3; ++i) {
      for (int j = 0; j < 3; ++j) {
        if (vec[i][j] != as[i] + bs[j])
          flag2 = false;
      }
    }
    if (flag2)
      flag = true;
  }
  cout << (flag ? "Yes" : "No") << endl;

}


Measured memory_bytes: 3604