akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

struct UFT{    //O(loga(n))
    int n;
    vi d, r;
    UFT(int n) : n(n), d(n, -1), r(n, 0){};
    int root(int i){
        if(d[i] < 0) return i;
        return d[i] = root(d[i]);
    }
    bool same(int x, int y){
        return root(x) == root(y);
    }
    bool unite(int x, int y){
        x = root(x);
        y = root(y);
        if(x == y) return false;

        if(r[x] < r[y]) swap(x, y);
        else if(r[x] == r[y]) r[x]++;
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    int size(int i){
        return -d[root(i)];
    }
};

int main(){
    int n;
    cin >> n;
    vector<int> x(n), y(n);
    map<int, int> mx, my;

    UFT uf(n);

    rep(i, n) {
        cin >> x[i] >> y[i];
        if(mx.count(x[i])) {
            uf.unite(i, mx[x[i]]);
        }
        else mx[x[i]] = i;
        if(my.count(y[i])) {
            uf.unite(i, my[y[i]]);
        }
        else my[y[i]] = i;
    }

    ll ans = 0LL;
    vector<vector<int>> v(n);
    rep(i, n) {
        v[uf.root(i)].pb(i);
    }

    for(auto&& g : v) {
        if(g.size() == 1) continue;
        set<int> sx, sy;
        for(auto&& i : g) {
            sx.insert(x[i]);
            sy.insert(y[i]);
        }
        ll sz_x = sx.size();
        ll sz_y = sy.size();
        if(sz_x == 1 || sz_y == 1) continue;
        ans += sz_x * sz_y;
        ans -= g.size();
    }
    cout << ans << '\n';
    return 0;
}

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

using namespace std;

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

  bool a = false;
  bool b = false;
  bool c = false;
  if (s[0] == 'A') a = true;

  for (int i = 2; i < s.size() - 1; ++i) {
    if (s[i] == 'C') {
      b = true;
      break;
    }
  }

  int count = 0;
  for (int i = 1; i < s.size(); ++i) {
    if (islower(s[i])) ++count;
  }
  c = count == (s.size() - 2);

  cout << ((a == true && b == true && c == true) ? "AC" : "WA") << endl;

  return 0;
}

Measured memory_bytes: 3644
H,W=map(int,input().split())
A=[list(map(int,input().split())) for i in range(H)]
B=[list(map(int,input().split())) for i in range(H)]
d=[[0]*W for j in range(H)]
m=80*(H+W)
d[0][0]=1<<m
for h in range(H):
    for w in range(W):
        x=abs(A[h][w]-B[h][w])
        if h>0:
            d[h][w]|=d[h-1][w]
        if w>0:
            d[h][w]|=d[h][w-1]
        d[h][w]=d[h][w]<<x|d[h][w]>>x
x,y=1<<m,1<<m
for i in range(99):
    if d[H-1][W-1]&x or d[H-1][W-1]&y:
        print(i)
        exit()
    x<<=1
    y>>=1


Measured memory_bytes: 20468
/*B - FizzBuzz Sum*/
#include <bits/stdc++.h>
using namespace std;

using Long = long long;

int main(){

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	Long n;
	cin >> n;

	Long ans = 0ll;
	
	for (Long i = 1; i <= n ; ++i)
	{
		if(i % 3 != 0 and i % 5 != 0){
			ans += i;
		}
	}

	cout << ans;

	return 0;
}

Measured memory_bytes: 3652
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;

int n,m;
int a[100];
int x[200],y[200];
const int INF=1000000000;
int main(){
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i];
	int ma=-INF,mi=INF,indexma,indexmi;

	for(int i=0;i<n;i++){
	//	ma=max(a[i],ma);
		if(ma<a[i]){
			ma=a[i];
			indexma=i;
		}
		if(mi>a[i]){
			mi=a[i];
			indexmi=i;
		}
		//mi=min(a[i],mi);
	}
	
	if(mi>0||mi<=0&&ma>=0&&abs(ma)>=abs(mi)){//正から足してくs
		for(int i=0;i<n;i++){
			a[i]+=ma;
			x[m]=indexma;
			y[m]=i;
			m++;
		}
		for(int i=1;i<n;i++){
			a[i]+=a[i-1];
			x[m]=i-1;
			y[m]=i;
			m++;
		}
		//cout<<"A!";
		cout<<m<<endl;
		//for(int i=0;i<n;i++)cout<<a[i]<<" ";cout<<endl;
		for(int i=0;i<m;i++)cout<<x[i]+1<<" "<<y[i]+1<<endl;
	}
	
	else if(ma<0||mi<=0&&ma>=0&&abs(mi)>abs(ma)){//最後尾から足してく
		//cout<<"A2";
		int cnt=0;
		for(int i=n-1;i>=0;i--){
			//cout<<m;
			a[i]+=mi;
			x[cnt]=indexmi;
			y[cnt]=i;
			cnt++;
		}

		for(int i=n-1;i>=1;i--){
			a[i-1]+=a[i];
			x[cnt]=i;
			y[cnt]=i-1;
			cnt++;
			//cout<<m<<endl;
		}
		
		cout<<cnt<<endl;

		//for(int i=0;i<n;i++)cout<<a[i]<<" ";cout<<endl;
		for(int i=0;i<cnt;i++)cout<<x[i]+1<<" "<<y[i]+1<<endl;
	}	

	return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		
		int count = 0;
		for (int i = a; i <= b; i++) {
			String s = String.valueOf(i);

			String reverse = new String();
			for (int j = s.length(); j > 0; j--) {
				reverse = reverse.concat(s.substring(j -1, j));
				
			}
			if (reverse.equals(s)) {
				count++;
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 41940
# https://atcoder.jp/contests/abc068/submissions/12987221
# C - Cat Snuke and a Voyage
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, m = map(int, input().split())

    edge = [[] for _ in range(n)]
    for _ in range(m):
        a, b = map(int, input().split())
        edge[a - 1].append(b - 1)
        edge[b - 1].append(a - 1)

    for i in edge[0]:
        if n - 1 in set(edge[i]):
            print("POSSIBLE")
            break
    else:
        print("IMPOSSIBLE")


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 38320
M, K = map(int, input().split())

if K == 0:
    ans = []
    for i in range(2 ** M):
        ans += [i, i]
    print(*ans)
elif M >= 2 and K < 2 ** M:
    b = list(range(2 ** M))
    b.remove(K)
    print(*(b + [K] + b[::-1] + [K]))
else:
    print(-1)


Measured memory_bytes: 66672
// Last Change: 01/07/2019 14:25:43.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

void LoopUntilZeroInpput() {
  int hogegegege = 0;
  while (cin >> hogegegege && hogegegege != 0) {
  }
}

class Cal {
private:
  int N;
  vector<int> a;
  vector<int> b;
  vector<int> c;
  ll dp[3][100005];

  void FillDP(int);
  void Answer(int);

public:
  Cal();
  void Main();
};

void Cal::FillDP(int top) {
  for (int i = 2; i <= top; i++) {
    dp[0][i] = max(dp[1][i - 1], dp[2][i - 1]) + a[i];
    dp[1][i] = max(dp[0][i - 1], dp[2][i - 1]) + b[i];
    dp[2][i] = max(dp[0][i - 1], dp[1][i - 1]) + c[i];
  }
}

void Cal::Answer(int index) {
  ll ans = max(dp[0][index], dp[1][index]);
  ans = max(ans, dp[2][index]);
  cout << ans << endl;
}

Cal::Cal() {
  cin >> N;
  a.resize(N + 1);
  b.resize(N + 1);
  c.resize(N + 1);
  for (int i = 1; i <= N; i++) {
    cin >> a[i] >> b[i] >> c[i];
  }
  dp[0][1] = a[1];
  dp[1][1] = b[1];
  dp[2][1] = c[1];
}

void Cal::Main() {
  FillDP(N);
  Answer(N);
}

int main() {
  Cal *cal = new Cal();
  cal->Main();
  delete cal;
  //LoopUntilZeroInpput();
}


Measured memory_bytes: 3712
import java.util.Scanner;

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

		// 入力値の取得
		int N = sc.nextInt();
		char[] S = sc.next().toCharArray();
		char[] T = sc.next().toCharArray();
		
		// 結果の出力
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < N; i++) {
			sb.append(S[i]);
			sb.append(T[i]);
		}
		System.out.println(sb.toString());
		
		sc.close();
	}
}


Measured memory_bytes: 35796
#include<bits/stdc++.h>
#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 fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    int A, B;
    cin >> A >> B;
    if (A + B >= 10)
    {
        cout << "error" << endl;
    }
    else
    {
        cout << A + B << endl;
    }
}


Measured memory_bytes: 256
//is there any case of -1 or any special corner cases ?
#include<bits/stdc++.h>
using namespace std;
#define int long long int 
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define vi vector<int>
#define pi pair<int,int>
#define all(v) v.begin(),v.end()
#define zeros(arr) memset(arr,0,sizeof(arr));
#define precise(num)  cout<<fixed; cout << std::setprecision(num)
#define nl cout<<"\n";
#define test int t;cin>>t;while(t--) 
const int maxx  = 2*1e6 , limit = 9*1e18 , MOD=1e9+7;
string binary(int n){bitset<60>b(n) ;string p =b.to_string();return p;}
int decimal(string n) { int dec_value = 0;  int base = 1;  for (int i = n.size() - 1; i >= 0; i--) { if (n[i] == '1') 
dec_value += base; base = base * 2; } return dec_value; } 
bool isPrime(int n){if (n <= 1) return false; if (n <= 3) return true;if (n % 2 == 0 || n % 3 == 0) return false;
for (int i = 5; i * i <= n; i = i + 6) if (n % i == 0 || n % (i + 2) == 0) return false; return true; }
int pow (int x, int n,int mod) {if (n == 0) return 1; int res = pow (x, n / 2,mod);res = (res * res) % mod;if (n % 2) res = (res * x ) % mod;return res;}

#define boost  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n';

int32_t main(){
        int n;
        cin>>n;
        
        string res ="";
        while(n){
            n--;
            int p = n % 26;
            
            // cout<< n <<" "<<p<<endl;
            
           // p--;
            //p = max(0ll,p);
            char l = p + 'a';
            
            res = l + res;
            n = n/26;
            
            
        }
        // reverse(all(res))
        cout<<res<<endl;
}


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

int main(){
  char s;
  cin>>s;
  if(s == 'A'){cout<<"T\n";}
  else if(s == 'T'){cout<<"A\n";}
  else if(s == 'G'){cout<<"C\n";}
  else if(s == 'C'){cout<<"G\n";}
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
 
using namespace std;
 
int main(void){
  string S;
  uint32_t f = 0;
  cin >> S;
  for(auto itr = S.begin(); itr != S.end(); itr++){
    if(f & 1 << *itr - 'a'){
      cout << "no" << endl;
      return 0;
    }
    f |= 1 << *itr - 'a';
  }
  cout << "yes" << endl;
  return 0;
}

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

ll gcd(ll a, ll b) {
    if (a%b==0) return b;
    else return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
    return a * b / gcd(a, b);
}

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

    ll a[N];
    rep(i, N) {
        cin >> a[i];
        a[i] = a[i] / 2;
    }

    bool ok = true;
    ll ai, k1 = 0, k2;
    rep(i, N) {
        ai = a[i];
        if (i==0) {
            while (ai %2 == 0) {
                ai /= 2;
                k1++;
            }
        } else {
            k2 = 0;
            while (ai %2 == 0) {
                ai /= 2;
                k2++;
            }
            if (k1 != k2) {
                ok = false;
                break;
            }
        }
    }

    ll x = 1;
    rep(i, N) x = lcm(x, a[i]);

    if (ok) cout << (M / x + 1) / 2 << endl;
    else cout << 0 << endl;

    return 0;
}



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

/*int main(void)
{
    uint64_t h, w;
    cin >> h >> w;

    uint64_t ans = 0;
    if (h % 2 == 0)
    {
        ans = (h / 2) * w;
    }
    else if (h % 2 != 0)
    { 
        for (int i = 1; i <= w; i++)
        {
            if (i%2 != 0) 
            { 
                ans += (h+1)/2; 
            }
            else
            {
                ans += (h-1)/2;
            }
        }
    }
    cout << ans << endl;
    
}*/

int main(void)
{
    long long h, w;
    cin >> h >> w;

    if (h == 1 || w == 1)
    {
        cout << 1 << endl;
    }
    else
    {
        cout << (h*w+1)/2 << endl;
    }
}


Measured memory_bytes: 256
/* ex 7_1
   offNaria */

#include <stdio.h>
#include <string.h>

typedef struct point
{
    int x_elem;
    int y_elem;
} point;

//b-aベクトルをaを中心として反時計まわりに90度回転し，始点をbにしたものの終点を計算する関数
point rotate(point a, point b);

int main(void)
{
    point p_1, p_2, p_3, p_4;
    scanf("%d %d %d %d", &p_1.x_elem, &p_1.y_elem, &p_2.x_elem, &p_2.y_elem);
    p_3 = rotate(p_1, p_2); //p_2-p_1ベクトルをp_1を中心として反時計回りに90度回転し，始点をp_2としたベクトルの終点がp_3
    p_4 = rotate(p_2, p_3); //p_3-p_2ベクトルをp_2を中心として反時計回りに90度回転し，始点をp_3としたベクトルの終点がp_4
    printf("%d %d %d %d\n", p_3.x_elem, p_3.y_elem, p_4.x_elem, p_4.y_elem);
    return 0;
}

point rotate(point a, point b)
{
    point rotatedVec = {b.x_elem + (a.y_elem - b.y_elem), b.y_elem + (b.x_elem - a.x_elem)};
    return rotatedVec;
}

Measured memory_bytes: 1708
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.stream.Stream;

public class Main {

  public static void main(String[] args) throws Exception {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(br.readLine());
    int[] a = Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
    int[] b = Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
    br.close();

    int[] a_cnt = new int[n + 1];
    int[] b_cnt = new int[n + 1];
    int[] c = new int[n + 1];
    int[] d = new int[n + 1];
    for(int i = 0; i < n; i++){
      a_cnt[a[i]]++;
      b_cnt[b[i]]++;
    }

    int max_d = 0;
    String[] array = new String[n];
    for(int i = 1; i <= n; i++){
      if(a_cnt[i] + b_cnt[i] > n){
        System.out.println("No");
        return;
      }
      c[i] = c[i - 1] + a_cnt[i];
      d[i] = d[i - 1] + b_cnt[i];
      max_d = Math.max(max_d, c[i] - d[i - 1]);
    }
    System.out.println("Yes");
    for(int i = 0; i < n; i++){
      array[i] = String.valueOf(b[( i + n - max_d) % n]);
    }
    System.out.println(String.join(" ", array));
  }
}

Measured memory_bytes: 86620
#include<cstdio>
#include<algorithm>
#include<vector>
#include<deque>
#include<stack>
#include<queue>
#include<string>
#include<iostream>
#include<tuple>
#include<utility>
#include<set>
#include<queue>
#include<iomanip>
#include<iterator>
//#include<chrono>
//#include<mt19937>
using namespace std;
typedef long long int llint;
const int big=1e9+100000;
const int mod=1e9+7;
const long double pai=3.141592653589793238462643;
#define mt make_tuple
#define mp make_pair
#define fir first
#define sec second
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define res resize
#define ins insert
#define era erase
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
int solve(const vector<int>& hi,int t,int w){
	int i,ans=0;
	stack<pair<int,int>>st;
	for(i=0;i<w;i++){
		int x=i;
		while((!st.empty())&&hi[i]<st.top().fir){
			maxeq(ans,(i-st.top().sec)*st.top().fir);
			x=st.top().sec;
			st.pop();
		}
		st.push(mp(hi[i],x));
		st.push(mp(t,i));
	}
	return ans;
}
int main(void){
	int i,j,h,w,ans=0;cin>>h>>w;
	vector<string>mat(h);
	for(i=0;i<h;i++){cin>>mat[i];}
	vector<int>a(w+1);a[w]=0;
	vector<vector<bool>>bs(h);
	for(i=0;i<h;i++){
		bs[i].res(w);
		if(i==0){continue;}
		for(j=0;j<w;j++){
			if(j==0){continue;}
			bs[i][j]=(mat[i][j]=='.')^(mat[i][j-1]=='.')^(mat[i-1][j]=='.')^(mat[i-1][j-1]=='.');
		}
	}
	
	for(i=0;i<h;i++){
		for(j=0;j<w;j++){
			if(bs[i][j]){a[j]=0;}
			a[j]++;
			//cout<<a[j]<<" ";
		}
		//cout<<endl;
		maxeq(ans,solve(a,i+1,w+1));
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4992
#include "bits/stdc++.h"
using namespace std;

int main() {
	double P[6], Q[6];
	for (int i = 0; i < 6; i++) cin >> P[i];
	for (int i = 0; i < 6; i++) cin >> Q[i];
	double L = 0, R = 1;
	while (R - L >= 0.00000000001) {
		double COUNT1 = 0, MID1 = (L * 2 + R) / 3.0;
		for (int i = 0; i < 6; i++) {
			COUNT1 += min(P[i] * MID1, Q[i] * (1.0 - MID1));
		}
		double COUNT2 = 0, MID2 = (L + R * 2) / 3.0;
		for (int i = 0; i < 6; i++) {
			COUNT2 += min(P[i] * MID2, Q[i] * (1.0 - MID2));
		}
		if (COUNT1 <= COUNT2) L = MID1;
		else R = MID2;
	}
	double ANS = 0;
	for (int i = 0; i < 6; i++) {
		ANS += min(P[i] * L, Q[i] * (1 - L));
	}
	printf("%.12lf\n", 1 - ANS / 100.0);
}

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

int main(){
  int n,m;
  cin >> n >> m;
  int l[m],r[m];
  rep(i,m)cin >> l[i] >> r[i];

  int max=0;
  int min=n;

  rep(i,m){
    if(max<l[i])max=l[i];
    if(min>r[i])min=r[i];
  }

  if(max<=min)cout << min-max+1 << endl;
  else cout << 0 << endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 200000;

int main()
{
  int R[MAX], n;

  cin >> n;

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

  int maxv = -2000000000;
  int minv = R[0];

  for(int i = 1 ; i < n ; i++){
    maxv = max(maxv, R[i] - minv);
    minv = min(minv, R[i]);
  }

  cout << maxv << endl;

  return 0;
}

Measured memory_bytes: 3884
use std::io::stdin;

fn main() {
    let mo:i64 = 1000000007;
    let mut st = String::new();
    stdin().read_line(&mut st).unwrap();
    let n = st.trim().parse::<i32>().unwrap();
    let mut st = String::new();
    stdin().read_line(&mut st).unwrap();
    let a:Vec<_> = st.trim().split(" ").map(|x| x.parse::<i32>().unwrap()).collect();

    let mut r:Vec<i32> = [-1,-1,-1].to_vec();
    let mut result:i64 = 1;
    for i in 0..n {
        let mut num = 0;
        let mut c:i64 = 0;
        for j in 0..3 {
            let I = i as usize;
            let J = j as usize;
            if a[I] == r[J]+1 {
                c += 1;
                num = J;
            }
        }
        r[num] += 1;
        result *= c;
        result %= mo;
    };
    

    println!("{:?}", result);
}

Measured memory_bytes: 4352
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;

int N, M;
bool e[10][10];
bool visited[10];

int solve(int n) {
  bool all = true;
  for(int i=0;i<N;i++)if(!visited[i])all=false;
  if(all) return 1;

  int p = 0;
  for(int i = 0; i < N; i++) {
    if(e[n][i] == false) continue;
    if(visited[i]) continue;

    visited[i] = true;
    p += solve(i);
    visited[i] = false;
  } 
  return p;
}


int main() {
  cin >> N >> M;
  for(int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    e[a-1][b-1] = e[b-1][a-1] = true;
  }

  visited[0] = true;
  std::cout << solve(0) << std::endl;
  return 0;
}


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

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


Measured memory_bytes: 3124
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			String tmp = sc.next();
			if(tmp.equals("0")) break;
			int sum = 0;
			char[] c = tmp.toCharArray();
			for(int i = 0; i < c.length; i++){
				sum += c[i]-'0';
			}
			System.out.println(sum);
		}
	}
}

Measured memory_bytes: 26424
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Set;

class Main {
    static int gcd (int a, int b) {
        if (b == 0)
            return a;
        else
            return gcd (b, a % b);
    }

    static final int MAXN = 1000001;
    static Set<Integer> factors;

    // stores smallest prime factor for every number
    static int[] spf = new int[MAXN];

    // Calculating SPF (Smallest Prime Factor) for every
    // number till MAXN.
    // Time Complexity : O(nloglogn)
    static void sieve(){
        spf[1] = 1;
        for (int i=2; i<MAXN; i++)

            // marking smallest prime factor for every
            // number to be itself.
            spf[i] = i;

        // separately marking spf for every even
        // number as 2
        for (int i=4; i<MAXN; i+=2)
            spf[i] = 2;

        for (int i=3; i*i<MAXN; i++) {
            // checking if i is prime
            if (spf[i] == i)
            {
                // marking SPF for all numbers divisible by i
                for (int j=i*i; j<MAXN; j+=i)

                    // marking spf[j] if it is not
                    // previously marked
                    if (spf[j]==j)
                        spf[j] = i;
            }
        }
    }

    // A O(log n) function returning primefactorization
    // by dividing by smallest prime factor at every step
    static boolean getFactorization(int x) {
        Set<Integer> temp = new HashSet<>();
        int copy = x;
        while (x != 1) {
            int f = spf[x];
            if(factors.contains(f) && !temp.contains(f)) {
                //System.out.println("For "+copy+" was common : "+f);
                return false;
            }
            factors.add(f);
            temp.add(f);
            x = x / spf[x];
        }

        return true;
    }

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        String[] s = br.readLine().split(" ");
        int[] a = new int[n];
        boolean[] res = new boolean[n];
        factors = new HashSet<>();
        sieve();

        for (int i = 0; i < n; i++) {
            a[i] = Integer.parseInt(s[i]);
        }
        int currGCD = a[n-1];
        boolean flag = true;
        getFactorization(a[n-1]);
        for (int i = n-2; i >=0 ; i--) {
            currGCD = gcd(a[i], currGCD);
            if(!getFactorization(a[i]))
                flag = false;
        }
        if(flag){
            System.out.println("pairwise coprime");
        }else if(currGCD == 1){
            System.out.println("setwise coprime");
        }else{
            System.out.println("not coprime");
        }
    }
}


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

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

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

const int MAX = 1e5 + 5;
const int INF = 1001001001;
const int MOD = 1e9 + 7;

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

    vector<int> A(N);
    rep(i, N) {
        cin >> A[i];
        A[i]--;
    }

    vector<int> B(100100, 0);
    rep(i, N) {
        B[ A[i] ]++;
    }

    int cnt = 0, ans = 0;
    for (int i : B) {
        if (0 < i ) {
            cnt += i - 1;
            ans++;
        }
    }

    cout << ans - cnt % 2 << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000


int main(){
	
	int A,B,C;
	cin>>A>>B>>C;
	
	if((A-C)*(C-B)<0){
		cout<<"No"<<endl;
	}
	else{
		cout<<"Yes"<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main() {
    int a,b;cin>>a>>b;
    cout<<a*b<<endl;
    return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int ans,n,m,g[110][110],f[110],l;
bool chk(int x){
    for(int i=0;i<l;i++)
        if(!g[x][f[i]]) return false;
    return true;
}
void updata(){
    int tmp=0;
    for(int i=0;i<l;i++){
        int tmp2=0;
        for(int j=0;j<l;j++)if(i!=j){
            if(tmp2==0 || g[f[i]][f[j]]<tmp2)
                tmp2=g[f[i]][f[j]];
        }
        tmp+=tmp2;
    }
    if(tmp > ans)
        ans=tmp;
}
void dfs(int x){
    f[l++]=x;
    updata();
    for(int i=x+1;i<=n;i++)
        if(chk(i)){
            dfs(i);
        }
    --l;
}
int main()
{
    while(~scanf("%d%d",&n,&m)){
        memset(g,0,sizeof(g));
        for(int i=0;i<m;i++){
            int x,y,z;
            scanf("%d%d%d",&x,&y,&z);
            g[x][y]=g[y][x]=z;
        }
        ans=0;
        for(int i=1;i<=n;i++){
            l=0;
            dfs(i);
        }
        printf("%d\n",ans);
    }
    return 0;
}

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

int n, m;
std::string str;
std::vector<int> a;

long long solve() {
    if (a.size() == 1) {
        return 1ll * n * m / 2;    
    } long long res = 0, tmp = 0;
    if (str[0] == str[n - 1]) {
        for (int i = 0; i < a.size(); i++) {
            res += a[i] / 2;
        } res = res + (res - a[0] / 2 - a.back() / 2 + (a[0] + a.back()) / 2) * (m - 1ll);
    } else {
        for (int i = 0; i < a.size(); i++) {
            res += a[i] / 2;
        } res = 1ll * res * m;
    } return res;
}

int main() {
    std::cin >> str >> m; n = str.size(); str += " ";   
    for (int i = 1, j = 0; i <= n; i++) {
        j++;
        if (str[i - 1] != str[i]) {
            a.push_back(j); j = 0;
        }
    }
    std::cout << solve() << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#define ll  long long
#define out(a) printf("%d",a)
#define writeln printf("\n")
using namespace std;
int a,b,c,num,l,n;
int read()
{
	int s=0,t=1; char c;
	while (c<'0'||c>'9') {if (c=='-') t=-1; c=getchar();}
	while (c>='0'&&c<='9') {s=s*10+c-'0'; c=getchar();}
	return s*t;
}
ll readl()
{
	ll s=0,t=1; char c;
	while (c<'0'||c>'9') {if (c=='-') t=-1; c=getchar();}
	while (c>='0'&&c<='9') {s=s*10+c-'0'; c=getchar();}
	return s*t;
}
int main()
{
	a=read(); b=read(); c=read();
	n=read();
	if (a>=b&&a>=c) num=a,l=b+c;
	if (b>=a&&b>=c) num=b,l=a+c;
	if (c>=b&&c>=a) num=c,l=a+b;
	
	for (int i=1;i<=n;i++)
	  num*=2;
	out(num+l);
	return 0;
}

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

#define CH(N,A,B) (A<=N&&N<B)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define RREP(i,a,b) for(int i=(b-1);a<=i;i--)

using namespace std;

string s;
int state[3], ind;

int parse(){
  while(s[ind]==')') ind++;
  if(s[ind]=='0'||s[ind]=='1'||s[ind]=='2'){
    return (int)(s[ind]-'0');
  }
  if(s[ind]=='P'||s[ind]=='Q'||s[ind]=='R'){
    return state[s[ind]-'P'];
  }
  if(s[ind]=='*') return 1;
  if(s[ind]=='+') return 2;

  if(s[ind]=='-'){
    pair< int, pair<int,int> > p;
    ind++;
    p.second.first = parse();
    p.first = 0;
    if(p.second.first == 0) return 2;
    if(p.second.first == 1) return 1;
    if(p.second.first == 2) return 0;
  }
  if(s[ind]=='('){
    pair< int, pair<int,int> > p;
    ind++;
    p.second.first = parse();
    ind++;
    p.first = parse();
    ind++;
    p.second.second = parse();
    if(p.first == 1){
      if(p.second.first==0 || p.second.second==0) return 0;
      else if(p.second.first==2 && p.second.second==2) return 2;
      else return 1;
    }else if(p.first == 2){
      if(p.second.first==2 || p.second.second==2) return 2;
      else if(p.second.first==0 && p.second.second==0) return 0;
      else return 1;
    }
  }
  return -999999;
}

int main() {
  while(1){
    cin>>s;
    if(s==".") break;
    int cnt = 0;
    /*(0,0,0)~(1,1,1)*/
    REP(pi,0,3){
      REP(qi,0,3){
        REP(ri,0,3){
          state[0]=pi; state[1]=qi; state[2]=ri;
          ind = 0;
          if(parse() == 2) cnt++;
        }
      }
    }
    cout<<cnt<<endl;
  }
  return 0;
}

Measured memory_bytes: 3216
#include <bits/stdc++.h>
#define long long long
#define ull unsigned long long
#define up(i,a,b) for (int i=a; i<=b; i++)
#define down(i,a,b) for (int i=a; i>=b; i--)
#define endl '\n'
#define pb push_back
#define X first
#define Y second
#define II pair<int, int>
#define III pair<int, pair<int, int> >
#define V vector
#define debug(X) cerr<< #X << " = " <<X << endl
#define debug2(X,Y) cerr<< #X << " = " <<X << ","<<#Y<<" = "<<Y<<endl
#define show(X,a,b) {cerr << #X << " = "; up(__,a,b) cerr << X[__] << ' '; cerr << endl;}
#define gc getchar
#define pc putchar

using namespace std;

inline void read(int &x)
{
    register int c = gc();
    x = 0;
    int neg = 0;
    for (;((c<48 || c>57) && c != '-') ;c = gc());
    if(c=='-') {neg=1;c=gc();}
    for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x=-x;
}
inline void writeln(int x){

         char buffor[21];
         register int i=0;
         int neg=0; if (x<0) {neg=1; x= -x;}
         do{
               buffor[i++]=(x%10)+'0';
               x/=10;
            } while(x);
           i--;
           if (neg) pc('-');
           while(i>=0) pc(buffor[i--]);
           pc('\n');
       }
const int N= (int) 2e5+10;
int n,m;
II p[N];
int it[4*N], low[4*N], high[4*N],lazy[4*N],id[N];

void input()
{
    cin>>n>>m;
    up(i,1,n) cin>>p[i].X>>p[i].Y;
}


//it
void build(int x,int l,int r)
{
    low[x]= l; high[x]= r; it[x]= 0; lazy[x]= 0;
    if (l==r) return;
    int m= (l+r)/2;
    build(2*x,l,m); build(2*x+1,m+1,r);
}
void downlazy(int x)
{
	if (lazy[x]==0) return;
	it[2*x]+= lazy[x]; it[2*x+1]+= lazy[x];
	lazy[2*x]+= lazy[x]; lazy[2*x+1]+= lazy[x];
	lazy[x]= 0;
}
void update(int x,int l,int r,int val)
{
    if (low[x]> r or high[x]< l) return;
    if (low[x]>=l and high[x]<= r)
	{
        it[x]+= val; lazy[x]+= val; return;
	}
	downlazy(x);
	update(2*x,l,r,val); update(2*x+1,l,r,val);
	it[x]= max(it[2*x],it[2*x+1]);
}
int query(int x,int l,int r)
{
	if (low[x]> r or high[x]< l) return -N;
	if (low[x]>=l and high[x]<= r) return it[x];
	downlazy(x);
	return max(query(2*x,l,r), query(2*x+1,l,r));
}
//
void solve()
{
	sort(p+1,p+1+n);
	int maxx= 0;
	build(1,1,m+1);
	up(R,1,m+1) update(1,R,R,-(m-R+1) );

	int cur= 0;
    up(L,0,m)
    {
        while ( cur< n and p[cur+1].X==L)
		{
			update(1,1,p[cur+1].Y,1); cur++;
		};

		int q= query(1,L+1,m+1);
		maxx= max(maxx, q-L); //debug(maxx);
    }

    cout<<max(n-m,maxx);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);// scanf phai bo
    #define TASK "tmp"
  //  freopen(TASK".inp","r",stdin);
   // freopen(TASK".out","w",stdout);

    input();
    solve();

    return 0;
}


Measured memory_bytes: 14336
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll ,ll> pll;
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define all(X) (X).begin(), (X).end()
#define REP(i,x,y) for(ll i = x;i <= y;++i)
vector<string> vec_splitter(string s) {
    for(char& c: s) c = c == ','?  ' ': c;
    stringstream ss; ss << s;
    vector<string> res;
    for(string z; ss >> z; res.push_back(z))
        ;
    return res;
}
void debug_out(vector<string> args, int idx) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, Head H, Tail... T) {
    if(idx > 0) cerr << ", ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, T...);
}
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __VA_ARGS__)
void localTest() {
    #ifndef ONLINE_JUDGE
        freopen("inp", "r", stdin);
        freopen("out", "w", stdout);
    #endif      
}
const ll N = 2e5 + 5;
ll A[N];
int main() {

    localTest();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n, xo = 0;
    cin >> n;
    for(ll i = 1;i <= n;++i) cin >> A[i], xo ^= A[i];
    for(ll i = 1;i <= n;++i) cout << (xo ^ A[i]) << " ";
    cout << "\n";
    
    return 0;
}

Measured memory_bytes: 5220
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    char ch; cin >> ch;
    if(ch == 'A') cout << 'T' << endl;
    else if(ch == 'T') cout << 'A' << endl;
    else if(ch == 'C') cout << 'G' << endl;
    else if(ch == 'G') cout << 'C' << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<double> vd;
typedef pair<double,double> PD;
typedef pair<int,P> ed;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
const double eps = 1e-10;
  
int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  int ans = 0;
  rep(t,120) {
    if(A <= t && t < B && C <= t && t < D) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

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

const int
	MAX = 5005,
	MOD = 924844033;
int n, m, l, a[MAX], f[MAX], dp[MAX][MAX];

void add(int &x, int y) {
	x += y;
	x %= MOD;
}

int main() {
	scanf("%d%d", &n, &m);

	int l = 0, it = 0;
	for(int i = 1; i <= m; i++) {
		it++;
		for(int j = 1; j <= (n - i) / m; j++) {
			a[++l] = it;
		}

		it++;
		for(int j = 1; j <= (n - i) / m; j++) {
			a[++l] = it;
		}
	}

	dp[0][0] = 1;

	for(int i = 1; i <= l; i++) {
		int head = (a[i] != a[i - 1]);

		for(int j = 0; j <= n; j++) {
			if(head) {
				if(j > 0)
					add(dp[i][j], dp[i - 1][j - 1]);

				add(dp[i][j], dp[i - 1][j]);
			}

			else {
				if(i > 1 && j > 0)
					add(dp[i][j], dp[i - 2][j - 1]);

				add(dp[i][j], dp[i - 1][j]);
			}
		}
	}

	f[0] = 1;
	for(int i = 1; i <= n; i++)
		f[i] = 1LL * f[i - 1] * i % MOD;

	int ans = 0;
	for(int i = 0; i <= n; i++) {
		int v = 1LL * f[n - i] * dp[l][i] % MOD;

		if(i % 2 == 0) {
			add(ans, v);
		}

		else add(ans, MOD - v);
	}

	printf("%d\n", ans);
	return 0;
}

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

int check(string a, string b){
    set<char> seta ;
    for (size_t i = 0; i < a.size(); i++)
    {
        seta.insert(a.at(i)) ;
    }
    
    set<char> setb ;
    for (size_t i = 0; i < b.size(); i++)
    {
        setb.insert(b.at(i)) ;
    }
    
    int i = 0 ;
    int j = 0 ;
    int count = 0 ;
    string t = "abcdefghijklmnopqrstuvwxyz" ;
    for (size_t i = 0; i < t.size(); i++)
    {
        int p = seta.count(t.at(i)) ;
        int q = setb.count(t.at(i)) ;
        if (p > 0 && q > 0)
        {
            count ++ ;
        }
        
    }
    return count ;
}

int main(){
    int n ;
    cin >> n ;
    string s ;
    cin >> s ;
    int ans = 0 ;
    for (size_t i = 1; i < n; i++)
    {
        string a = s.substr(0,i) ;
        string b = s.substr(i,n-i) ;
        int temp = check(a,b) ;
        if (ans < temp)
        {
            ans = temp ;
        }
        
    }
    cout << ans << endl ;
}


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

#define for_(i,a,b) for(int i=(a);i<(b);++i)
#define for_rev(i,a,b) for(int i=(a);i>=(b);--i)
#define allof(a) (a).begin(),(a).end()
typedef long long lint;
template< typename T > using Vec = vector< T >;

int main() {
	int H, W, N;
	cin >> H >> W >> N;
	
	Vec< Vec< int > > ans(H, Vec< int >(W, 0));

	int x = 0, y = 0, dx = 1;
	for_(i,0,N) {
		int a; cin >> a;		
		for_(j,0,a) {
			ans[y][x] = i+1;
			x += dx;
			if (x < 0) ++y, x = 0, dx = 1;
			if (x >= W) ++y, x = W - 1, dx = -1;
		}
	}
	
	for_(i,0,H) for_(j,0,W) cout << ans[i][j] << (j < W - 1 ? " " : "\n");
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String a = scan.next();
		String b = scan.next();
		String c = scan.next();
		scan.close();
		char[] ac=a.toCharArray();
		char[] bc=b.toCharArray();
		char[] cc=c.toCharArray();
		if(ac[ac.length-1]==bc[0] &&
				bc[bc.length-1]==cc[0])System.out.println("YES");
		else System.out.println("NO");
	}
}

Measured memory_bytes: 21716
while True:
    H, W = map(int, input().split())
    if H == 0 and W == 0:
        break
    for i in range(H):
        for j in range(W):
            if (i + j) % 2 == 0:
                print("#", end="")
            else:
                print(".", end="")
        print()
    print()

Measured memory_bytes: 9012
n = int(input())
a = list(map(int,input().split()))
q = 0
z = 1000
p = []*z
m = []*z
for i in range(z):
    p.append([])
    m.append([])
for i in range(n):
    x = i+1-a[i]
    if(x > 0):
        if(x in p[x%z]):
            m[x%z][p[x%z].index(x)][0] += 1
        else:
            m[x%z].append([1,0])
            p[x%z].append(x)
    x = i+1+a[i]
    if(x in p[x%z]):
        m[x%z][p[x%z].index(x)][1] += 1
    else:
        m[x%z].append([0,1])
        p[x%z].append(x)
    
for i in range(z):
    for j in range(len(m[i])):
        q += m[i][j][0]*m[i][j][1]
print(q)

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

using namespace std;

int main()
{
    int n,m;
    int mod=1000000007;
    cin>>n>>m;
    char c[n][m];
    int ans[n][m]={};
    ans[0][0]=1;
    for(int i=0;i<n;i++)
        for(int j = 0; j < m ; j++){
            cin>>c[i][j];
            if(i>0 &&c[i-1][j]=='.' ){
                ans[i][j]+=ans[i-1][j];
            }
            if(j>0&&c[i][j-1]=='.'){
                ans[i][j]+=ans[i][j-1];
            }
            ans[i][j]%=mod;
        }
        cout<<ans[n-1][m-1]<<endl;
}



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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var l = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = l[0], K = l[1];
            var h = Console.ReadLine().Split().Select(int.Parse).ToArray();

            var count = 0;
            for (var i = 0; i < N; i++)
                if (h[i] >= K) count++;

            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 19168
#include <algorithm>
#include <iostream>

using namespace std;

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

    int x[n];
    for (int i = 0; i < n; i++) {
        cin >> x[i];
        x[i] -= (i + 1);
    }

    sort(x, x + n);

    int b = x[n / 2];
    long sadness = 0;
    for (int i = 0; i < n; i++) {
        sadness += abs(x[i] - b);
    }

    cout << sadness << endl;

    return 0;
}

Measured memory_bytes: 1024
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>

using namespace std;

typedef long long ll;
const ll nmax = 1e9 + 7;
const ll mod = 998244353;
const double PI = 2 * asin(1);

int main(){
  ll A, B, K; cin >> A >> B >> K;

  ll ans1 = max(0ll, A - K);
  if (ans1 == 0){
    ll ans2 = max(0ll, A + B - K);
    cout << ans1 << " " << ans2 << endl;
  }else{
    cout << ans1 << " " << B << endl;
  }
  

  return 0;
}


Measured memory_bytes: 256
use std::io::*;

mod segment_tree {
    use std::cmp::*;
    pub struct SegmentTree {
        data: Vec<usize>,
        datb: Vec<usize>,
    }
    impl SegmentTree {
        pub fn new(n: usize) -> SegmentTree {
            let size = n.next_power_of_two();
            SegmentTree {
                data: vec![0; size * 2],
                datb: vec![0; size * 2],
            }
        }
        pub fn update(&mut self, a: usize, b: usize, x: usize, i: usize, l: usize, r: usize) {
            if a <= l && r <= b {
                self.data[i] += x;
            } else if l < b && a < r {
                self.datb[i] += x * (min(b, r) - max(a, l));
                self.update(a, b, x, i * 2 + 1, l, (l + r) >> 1);
                self.update(a, b, x, i * 2 + 2, (l + r) >> 1, r);
            }
        }
        pub fn query(&self, a: usize, b: usize, i: usize, l: usize, r: usize) -> usize {
            if r <= a || b <= l {
                0
            } else if a <= l && r <= b {
                self.data[i] * (r - l) + self.datb[i]
            } else {
                let mut res = self.data[i] * (min(b, r) - max(a, l));
                res += self.query(a, b, i * 2 + 1, l, (l + r) >> 1);
                res += self.query(a, b, i * 2 + 2, (l + r) >> 1, r);
                res
            }
        }
    }
}

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let q: usize = itr.next().unwrap().parse().unwrap();
    let mut st = segment_tree::SegmentTree::new(n + 2);
    for _ in 0..q {
        let c: usize = itr.next().unwrap().parse().unwrap();
        let s: usize = itr.next().unwrap().parse().unwrap();
        let t: usize = itr.next().unwrap().parse().unwrap();
        if c == 0 {
            let x: usize = itr.next().unwrap().parse().unwrap();
            st.update(s - 1, t, x, 0, 0, n);
        } else {
            println!("{}", st.query(s - 1, t, 0, 0, n));
        }
    }
}



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

using namespace std;

int main()
{
	long long N;
	cin >> N;

	long long res = N - 1;

	for (long long i = 2; i*i <= N; i++)
	{
		if (N % i != 0) { continue; }

		long long _res = (i - 1) + (N / i - 1);
		if (_res < res)
		{
			res = _res;
		}
	}

	cout << res << endl;
}



Measured memory_bytes: 256
#include <algorithm>

#include <bitset>

#include <complex>

#include <deque>

#include <exception>

#include <fstream>

#include <functional>

#include <iomanip>

#include <ios>

#include <iosfwd>

#include <iostream>

#include <istream>

#include <iterator>

#include <limits>

#include <list>

#include <locale>

#include <map>

#include <memory>

#include <new>

#include <numeric>

#include <ostream>

#include <queue>

#include <set>

#include <sstream>

#include <stack>

#include <stdexcept>

#include <streambuf>

#include <string>

#include <typeinfo>

#include <utility>

#include <valarray>

#include <vector>



#if __cplusplus >= 201103L

#include <array>

#include <atomic>

#include <chrono>

#include <condition_variable>

#include <forward_list>

#include <future>

#include <initializer_list>

#include <mutex>

#include <random>

#include <ratio>

#include <regex>

#include <scoped_allocator>

#include <system_error>

#include <thread>

#include <tuple>

#include <typeindex>

#include <type_traits>

#include <unordered_map>

#include <unordered_set>

#endif
using namespace std;



int main()
{
	int n,k;
	cin >> n>>k;
	int ans = 0;
	for (int i = 0;i < n;i++) {
		int x;
		cin>> x;

		if (x < k - x)ans += 2 * x;
		else ans += 2 * (k - x);

	}
	cout << ans << endl;
}

Measured memory_bytes: 384
# -*- coding: utf-8 -*-
"""
Created on Wed Sep  9 21:55:15 2020

@author: liang
"""

N = int(input())
V = list(map(int,input().split()))
V.sort(reverse=True)
#print(V)
for i in range(N-1):
    tmp = 0
    tmp += (V.pop() + V.pop())/2
    V.append(tmp)

print(V[0])

Measured memory_bytes: 9176
#include <iostream>
#define ll long long
using namespace std;

ll gcd(ll a, ll b){
	if(a%b>0) return gcd(b, a%b);
	return b;
}

bool judge(ll a, ll b, ll c, ll d){
	if(min(a, d)<b) return false;
	ll n=gcd(b, d);
	ll r=c/n;
	if(a%n>c%n) --r;
	return r+1 > b/n-1;
}

int main() {
	int T;
	cin >> T;
	ll A, B, C, D;
	for(int t=0; t<T; ++t){
		cin >> A >> B >> C >> D;
		if(judge(A, B, C, D)) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
 int i,j,x,y,n;
 cin >> n >> x >> y;
 int a[n+1][n+1];
 int ans[n];
 for(i=1;i<=n;i++)
 {
  ans[i-1]=0;
  for(j=1;j<=n;j++)
  a[i][j]=abs(i-j);
 }
 for(i=1;i<=x;i++)
 {
  for(j=1;j<=n;j++)
  a[i][j]=min(a[i][j],x-i+1+abs(y-j));
 }
 for(i=y;i<=n;i++)
 {
  for(j=1;j<=n;j++)
  a[i][j]=min(a[i][j],i-y+1+abs(x-j));
 }
 for(i=(x+1);i<y;i++)
 {
  for(j=1;j<=n;j++)
  a[i][j]=min(i-x+1+abs(j-y),min(a[i][j],y-i+1+abs(j-x)));
 }
 for(i=1;i<=n;i++)
 {
  for(j=1;j<=n;j++)
  ans[a[i][j]]++;
 }
 for(i=1;i<n;i++)
 cout << ans[i]/2 << "\n";
 return 0;
}

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

using namespace std;

#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define MP make_pair
#define PB push_back
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
const double pi=acos(-1.0);
typedef pair<int, int> PII;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;


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

int mp[1000+1][1000+1];
int dp[1000+1][1000+1];
int main()
{
    IOS
    int n, m;
    cin >> n >> m;
    REP(i,n)
    {
        REP(j,m)
        {
            char c;
            cin >> c;
            mp[i][j]= (c!='#');
        }
    }

    dp[1][1]=1;
    REP(i,n+1)
    {
        if(i==0)    continue;
        REP(j,m+1)
        {
            if(j==0)    continue;
            if(mp[i-1][j-1])
            {
                dp[i][j] = (dp[i][j]+dp[i-1][j])%MOD;
                dp[i][j] = (dp[i][j]+dp[i][j-1])%MOD;
            }
        }
    }

    cout << dp[n][m];
    
}

Measured memory_bytes: 8064
#include <iostream>

using namespace std;

int main() {
	int a, b, c, d, e;
	cin >> a >> b >> c >> d >> e;
	if (a < 0) {
		if (b <= 0) {
			cout << (b - a)*c << endl;
		}
		else {
			cout << ((0 - a)*c) + d + (b*e) << endl;
		}
	}
	else {
		cout << (b - a)*e << endl;
	}
	return 0;
}

Measured memory_bytes: 3096
#include <cstdio>
#include <queue>
#include <algorithm>

using namespace std;

int main()
{
	char s1[10] , s2[10];
	scanf("%s %s",s1 , s2);
	if(s1[0] == s2[0]) printf("=\n");
	else if(s1[0] > s2[0]) printf(">\n");
	else printf("<\n");
}

Measured memory_bytes: 128