akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>

int main()
{
	int a[101][101], b[101], c[101];
	int i, j;
	int n, m;

	scanf("%d%d", &n, &m);
	for (i = 0; i < n; i++) {
		for (j = 0; j < m; j++) scanf("%d", &a[i][j]);
	}
	for (j = 0; j < m; j++) scanf("%d", &b[j]);

	for (i = 0; i < n; i++) {
		c[i] = 0;
		for (j = 0; j < m; j++) c[i] += a[i][j] * b[j];
	}

	for (i = 0; i < n; i++) {
		printf("%d\n", c[i]);
	}
	return 0;
}


Measured memory_bytes: 2108
# include <cmath>
# include <iostream>
# include <queue>
# include <set>
# include <stack>
# include <string>
# include <vector>


using namespace std;
const int INF = 1001001001;


int n, x, y;


int main() {
    cin >> n >> x >> y;
    x--; y--;

    vector<vector<int>> d(n, vector<int>(n));
    for (int i=0; i<n; i++) {
        for (int j=0; j<n; j++) {
            d[i][j] = i > j ? i-j : j-i;
        }
    }

    for (int i=0; i<n; i++) {
        for (int j=x+1; j<n; j++) {
            if (i >= j) continue;

            int mid;
            if (j-x > y-j) {
                mid = d[j][y];
            }
            else {
                mid = d[x][j];
            }

            d[i][j] = min(d[i][j], d[i][x]+1+mid);
        }
    }


    //for (int i=0; i<n; i++) {
    //    for (int j=0; j<n; j++) {
    //        cout << d[i][j] << ' ';
    //    }
    //    cout << endl;
    //}

    vector<int> cnt(n, 0);
    for (int i=0; i<n; i++) {
        for (int j=i; j<n; j++) {
            cnt[d[i][j]]++;
        }
    }

    for (int i=1; i<n; i++) {
        cout << cnt[i] << endl;
    }
    return 0;
}



Measured memory_bytes: 16000
using System;

namespace _20190330AtCoderB
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] line = Console.ReadLine().Split(' ');
            int N = int.Parse(line[0]);
            string[] line2 = Console.ReadLine().Split(' ');
            string s = line2[0];
            int count = 0;
            string R = "R";
            foreach(char c in s)
            {
                if(c == R[0])
                {
                    count += 1;
                }
            }
            if (count > (N / 2)){ 
                Console.Write("Yes");
            }
            else
            {
                Console.Write("No");
            }
        }
    }
}


Measured memory_bytes: 11092
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n = I()
    a = LI()
    d = collections.defaultdict(int)
    for c in a:
        d[c] += 1
    r = 0
    ii = 2**32
    for k in sorted(d.keys(), reverse=True):
        while k < ii // 2:
            ii //= 2
        if k * 2 == ii:
            r += d[k] // 2
        else:
            t = ii - k
            u = min(d[t], d[k])
            r += u
            d[t] -= u
    return r


print(main())


Measured memory_bytes: 58124
// This amazing code is by Eric Sunli Chen.
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
template<typename T> void get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'; t=getchar());
	if(t=='-')neg=true,t=getchar();
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) get1(a),get1(b)
#define get3(a,b,c) get1(a),get2(b,c)
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);

vector<int> g[100111];
int n,m,mark[100111],tot[2],all[2];
bool dfs(int x,int mk)
{
	if(mark[x])
	{
		if(mark[x]!=mk)return false;
		else return true;
	}
//	printf("dfs %d %d\n",x,mk);
	mark[x]=mk;
	tot[mk-1]++;
	bool ret=true;
	for(int i=0;i<(int)g[x].size();i++)
		if(!dfs(g[x][i],3-mk))ret=false;
	return ret;
}
int main()
{
	get2(n,m);
	for(int i=1,u,v;i<=m;i++)
	{
		get2(u,v);
		g[u].pb(v);
		g[v].pb(u);
	}
	LL ans=0;
	int spare=0;
	for(int i=1;i<=n;i++)
	{
		if(mark[i])continue;
		tot[0]=tot[1]=0;
		int tmp=dfs(i,1);
		if(tot[0]+tot[1]==1)spare++;
		else all[tmp]++;
	}
//	printf("all %d %d spare= %d\n",all[0],all[1],spare);
	ans=1ll*n*n-1ll*(n-spare)*(n-spare)+2ll*all[1]*all[1]+2ll*all[0]*all[1]+1ll*all[0]*all[0];
	printendl(ans);
	return 0;
}

Measured memory_bytes: 10880
import java.util.Scanner;

public class Main implements Runnable {

    private static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        new Thread(null, new Main(), "", 128 * 1024 * 1024).start();
    }

    public void run() {
        String s = sc.next();
        if (s.length() < 26) {
            int[] count = charCount(s);
            for (int i = 0; i < 26; i++) {
                if (count[i] == 0) {
                    String ss = Character.toString((char) (i + 97));
                    System.out.println(s + ss);
                    return;
                }
            }
        } else {
            int[] countBack = new int[26];
            char z = s.charAt(25), zz = s.charAt(25);
            countBack[s.codePointAt(25) - 97]++;
            for (int i = 24; i >= 0; i--) {
                if (s.charAt(i) >= z + 1) {
                    z = s.charAt(i);
                    countBack[s.codePointAt(i) - 97]++;
                } else {
                    int[] countForward = charCount(s.substring(0, i + 1));
                    for (int j = s.charAt(i) - 97; j < 26; j++) {
                        if (countForward[j] == 0) {
                            s = s.substring(0,i) + (char)(j+97);
                            System.out.println(s);
                            return;
                        }
                    }
                }
            }
            System.out.println(-1);
        }
    }

    private int[] charCount(String str) {
        int[] count = new int[26];
        for (int i = 0; i < str.length(); i++) {
            count[str.codePointAt(i) - 97]++;
        }
        return count;
    }
}

Measured memory_bytes: 25936
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 9223372036854775807; //10^18
const int inINF = 2147483647; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
    ll N, K;
    cin >> N >> K;
    vector<ll> A(N);
    for (ll i = 0; i < N; i++) {
        cin >> A[i];
    }
    if(K == 0){
        ll an = 0;
        for (ll i = 0; i < N; i++) {
            an += A[i];
        }
        printf("%lld\n", an);
        return 0;
    }
    vector<ll> two(42);
    two[0] = 1;
    for (ll i = 1; i < 42; i++) {
        two[i] = two[i-1] * 2;
    }

    vector<ll> x(42, 0);
    for (ll i = 0; i < N; i++) {
        for (ll j = 1; j < 42; j++) {
            if(A[i] & two[41-j]){
                x[j]++;
            }
        }    
    }

    vector<ll> dp0(42, 0), dp1(42, 0);
    ll d;
    for (ll i = 1; i < 42; i++) {
        if(K & two[41-i]){
            d = i;
            break;
        }
    }
    dp1[d] = 0;
    dp0[d] = (N - 2 * x[d]) * two[41-d];
    for (ll i = d+1; i < 42; i++) {
        dp1[i] = dp1[i-1] + max((N - 2 * x[i]) * two[41-i], zero);
        if(K & two[41-i]){
            dp1[i] = max(dp1[i], dp0[i-1]);
            dp0[i] = dp0[i-1] + (N - 2 * x[i]) * two[41-i];
        }
        else{
            dp0[i] = dp0[i-1];
        }
    }

    ll ans = max(dp0[41], dp1[41]);
    for (ll i = 0; i < N; i++) {
        ans += A[i];
    }
    printf("%lld\n", ans);

}

Measured memory_bytes: 4064
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>; // グラフ型
typedef long long ll;
#define _GLIBCXX_DEBUG

int main() {
  ll N, K, ans;
  cin >> K >> N;
  vector<ll> A(N);
  vector<ll> Diff(N);
  
  for (ll i=0; i < N; i++){
    cin >> A.at(i);
  }

  for (ll i=0; i < N-1; i++){
    Diff.at(i) = A.at(i+1) - A.at(i);
  }
  Diff.at(N-1) = A.at(0) + K - A.at(N-1);

  ll buf = 0;
  for (ll i=0; i < N; i++){
    if(buf < Diff.at(i)){
      buf =  Diff.at(i);
    }
  }

  ans = K - buf;



  
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 6412
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main()
{
	char a,b,c;
	string s,t,r;
	cin>>s>>t>>r;
	a=toupper(s[0]),b=toupper(t[0]),c=toupper(r[0]);
	cout<<a<<b<<c<<endl;
	return 0;
}

Measured memory_bytes: 768
#include<iostream>

using namespace std;

int main()
{
	int n;
	cin >> n;
	long long a[100005];
	long long b[100005];

	for(int i=1;i<=n;i++)
		cin >> a[i-1] >> b[i-1];

	long long ans=0;

	for(int i=n;i>=1;i--)
	{
		ans+=(b[i-1]-((a[i-1]+ans-1)%b[i-1]+1))%b[i-1];
	}

	cout << ans << endl;
}


Measured memory_bytes: 1792
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner kb = new Scanner( System.in);
		int a=kb.nextInt();
		int b=kb.nextInt();

		if( a < b ) {
			System.out.println( "a < b");		
		} else if( a == b ) {
			System.out.println( "a == b");
		} else {
			System.out.println( "a > b");				
		}
	}
}

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

int main()
{
  ll K;
  scanf("%lld",&K);
  ll X;
  scanf("%lld",&X);

  for (int i=X-K+1; i<X+K; i++) {
    if (i == X-K+1) cout << i;
    else cout << " " << i;
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int count = 700;
    for(int i = 0; i < 3; i++){
      if(s.charAt(i) == 'o')
        count += 100;
    }
    System.out.println(count);
  }
}

Measured memory_bytes: 23380
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll N;
int main(){
    cin>>N;
    vector<P> xl(N);
    int cnt=1;   
    
    for(int i=0;i<N;i++)cin>>xl.at(i).first>>xl.at(i).second;
    
    sort(xl.begin(),xl.end());
    ll ude=xl.at(0).second+xl.at(0).first;
    for(ll i=0;i<N-1;i++){
        if(xl.at(i+1).first-xl.at(i+1).second-ude>=0){
            
            cnt++;
            ude=xl.at(i+1).first+xl.at(i+1).second;
        }
        else{
            ude=min(ude,xl.at(i+1).first+xl.at(i+1).second);
        }
    }
    cout<<cnt<<endl;

}


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


int main(){
    long long int n, t;
    cin >> n >> t;
    long long int s[n], sum = t;
    if(n == 1){
        cout << t << endl;
    }
    else {
        for(int i = 0; i < n; i++){
            cin >> s[i];
        }
        for(int i = 1; i < n; i++){
            sum += min(t, s[i] - s[i-1]);
            //cout << "sum "<< sum << endl;
        }
        cout << sum << endl;
    }
}


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

int main(){
  string N;
  cin>>N;
  if(N.at(0)=='7'||N.at(1)=='7'||N.at(2)=='7'){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector< vector<int> > VVI;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()

int main() {
  int N,K;
  cin>>N>>K;
  VI H(N);
  rep(i,N) cin>>H[i];
  int ans=0;
  rep(i,N) if(H[i]>=K) ans++;
  cout<<ans<<endl;
}



Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main()
{
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    for (int i = sy + 1; i <= ty; i++) cout << 'U';
    for (int i = sx + 1; i <= tx; i++) cout << 'R';
    for (int i = ty - 1; i >= sy; i--) cout << 'D';
    for (int i = tx - 1; i >= sx; i--) cout << 'L';
    cout << 'L';
    for (int i = sy; i <= ty; i++) cout << 'U';
    for (int i = sx; i <= tx; i++) cout << 'R';
    cout << "DR";
    for (int i = ty; i >= sy; i--) cout << 'D';
    for (int i = tx; i >= sx; i--) cout << 'L';
    cout << 'U';
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
using Graph = vector<vector<int>>;
typedef long long lint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldouble;
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<ull> ulvec;
typedef vector<double> dvec;
typedef vector<pair<int,int>> pvec;
typedef vector<pair<ll,ll>> plvec;
typedef vector<tuple<ll,ll,ll>> tvec;
typedef vector<string> svec;
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; }

ll dp[10003];
ll h,n;
ll a[100000],b[100000];

void solve(){
    priority_queue<ll,lvec,greater<ll>> que;
    //rep(i,n) dp[h+1][i]=h;
    ll cnt=10000000000;
    for(int i=h;i>=0;i--){
        for(int j=0;j<n;j++){
            if(i==h||(i!=h&&dp[i]>0)){
                if(i-a[j]>=0){
                    if(dp[i-a[j]]!=0) dp[i-a[j]]=min(dp[i]+b[j],dp[i-a[j]]);
                    else dp[i-a[j]]=dp[i]+b[j];
                }else{
                    if(i==0){
                        que.push(dp[i]);
                    }
                    else if(i-a[j]==0){
                        if(dp[i-a[j]]!=0) dp[i-a[j]]=min(dp[i]+b[j],dp[i-a[j]]);
                        else dp[i-a[j]]=dp[i]+b[j];
                        que.push(dp[i-a[j]]);
                    }else{
                        que.push(dp[i]+b[j]);
                    }
                    ll u;
                    // if(cnt>dp[i][j]+b[j]){
                    //     cnt=dp[i][j]+b[j];
                    // }
                //dp[0][j]=dp[i][j]+b[j];
                }
            }
        }
    }
    cout<<que.top()<<endl;
}

int main(){
    cin>>h>>n;
    rep(i,n)cin>>a[i]>>b[i];
    solve();
}

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

#define INF ((1<<30)-1)
#define LLINF (1LL<<60)
#define EPS (1e-10)

vector<int> g[101010];

int main() {
    int N, M;
    cin >> N >> M;
    vector<ll> h(N);
    rep(i, N) {
        cin >> h[i];
    }
    rep(i, M) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        g[a].emplace_back(h[b]);
        g[b].emplace_back(h[a]);
    }
    rep(i, N) sort(g[i].rbegin(), g[i].rend());

    ll ans = 0;
    rep(i, N) {
        if (g[i].size() > 0 and h[i] > g[i][0]) {
            ans++;
        }
        else if (g[i].size() == 0) ans++;
    }

    cout << ans << endl;

}


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

int main(){
  int L,R;cin>>L>>R;
  long int ans=1e+9;
  for(long int i=L+1;i<=min(R,L+2019);i++){
    for(long int j=L;j<i;j++){
      ans=min(ans,(i*j)%2019);
    }
  }
  cout<<ans<<endl;
}


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


typedef long long ll;
typedef vector <int> vi;
typedef pair< int ,int > pii;
typedef istringstream iss;
typedef ostringstream oss;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define sz size()
#define ln length()
#define rep(i,n) for(int i=0;i<n;i++)
#define fu(i,a,n) for(int i=a;i<=n;i++)
#define fd(i,n,a) for(int i=n;i>=a;i--)
#define all(a)  a.begin(),a.end() 
#define ESP (1e-9)

const int md = 100100 ;
int vis[1005] ;  
int main () {
	 vis[1] = 1 ; 
	 
	  for ( int i = 2 ; i <= 1000 ; ++i ){
	  	  for ( int j = i * i ; j <= 1000 ; j *= i ){
	  	  	   vis[j] = 1 ; 
		  }
	  }
	  
	  int x ; 
	  cin >> x ;
	  for ( int i = x ; i >= 1 ; --i ){
	  	  if ( vis[i] == 1 ) {
	  	  	  cout << i ;
	  	  	  break; 
			}
	  }
	  /*if ( x <= 3 ){
	  	  puts("1") ; 
	  }
	  else {
	  	  for ( int i = x ; i >= 4 ; --i){
	  	       int prm = 0 ;
	  	       int tmp = i  ;
			   for ( int j = 2 ; j * j <= tmp ; ++j){
			   	  if ( tmp % j == 0 ){
			   	      while ( tmp % j == 0 ) tmp /= j ; 
					++prm ; 	
				  }
			   	  // while ( i % j == 0 )  prm = 0 ;
			   }	
			   if ( tmp > 1 )  prm++; 
			   if ( prm == 1 ) {
			   	   cout << i ;
			   	   return 0; 
			   } 
		  }
	  } */
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n;
int a[125252], b[125252], c[125252];
ll bcnt[125252];

int main(){
  scanf("%d",&n);
  REP(i,n)scanf("%d",a+i);
  REP(i,n)scanf("%d",b+i);
  REP(i,n)scanf("%d",c+i);
  sort(a,a+n);
  sort(b,b+n);
  sort(c,c+n);
  int it = 0;
  bcnt[0] = 0;
  REP(i,n){
    while(it < n && a[it] < b[i])it++;
    bcnt[i+1] = bcnt[i] + it;
  }
  ll ans = 0;
  it = 0;
  REP(i,n){
    while(it < n && b[it] < c[i])it++;
    ans += bcnt[it];
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 2176
#include <math.h>
#include <stdbool.h>
#include <stdio.h>
int a[8], p[8], q[8], pCnt = 0, qCnt = 0, cnt = 0;
bool isUsed[8];
void perm(int n, int len) {
	if (len == n) {
		bool isP = true, isQ = true;
		for (int i = 0; i < n; i++) {
			// printf("%d ", a[i]);
			if (a[i] != p[i])
				isP = false;
			if (a[i] != q[i])
				isQ = false;
		}
		// printf("\n");
		if (isP)
			pCnt = cnt;
		if (isQ)
			qCnt = cnt;
		cnt++;
		return;
	}
	for (int i = 0; i < n; i++) {
		if (!isUsed[i]) {
			a[len] = i;
			isUsed[i] = true;
			perm(n, len + 1);
			isUsed[i] = false;
		}
	}
}
int main() {
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &p[i]);
		p[i]--;
	}
	for (int i = 0; i < n; i++) {
		scanf("%d", &q[i]);
		q[i]--;
	}
	perm(n, 0);
	printf("%d\n", abs(pCnt - qCnt));
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
    char s[200001],t[200001];
    scanf("%s",s);
    scanf("%s",t);
    long e=0;
    for(long i=0;i<(long)strlen(s);i++)if(s[i]!=t[i])e++;
    printf("%ld",e);
    return 0;
}

Measured memory_bytes: 4188
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <math.h>
#include <numeric>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;


int main(){
    ll N, M, X;

    cin >> N >> M >> X;

    ll C[N];
    ll A[N][M];
    ll sumC;
    ll LA[M];
    ll minC;
    ll p;
    ll ng;

    minC = 0;
    for(ll i = 0; i < M; i++){
        LA[i] = 0;
    }
    for(ll i = 0; i < N; i++){
        cin >> C[i];
        minC += C[i];
        for(ll j = 0; j < M; j++){
            cin >> A[i][j];
            LA[j] += A[i][j];
        }
    }

    for(ll i = 0; i < M; i++){
        if(LA[i] < X){
            cout << -1 << endl;
            return 0;
        }
    }

    for(ll p = 0; p < (1<<N); p++){
        sumC = 0;
        for(ll i = 0; i < M; i++){
            LA[i] = 0;
        }
        ng = 0;

        for(ll i = 0; i < N; i++){
            if(p & (1<<i)){
                sumC += C[i];
                for(ll j = 0; j < M; j++){
                    LA[j] += A[i][j];
                }
            }
        }

        for(ll i = 0; i < M; i++){
            if(LA[i] < X){
                ng = 1;
            }
        }
        if(ng == 0){
            if(minC > sumC){
                minC = sumC;
            }
        }
    }

    cout << minC << endl;
                

    return 0;
}


Measured memory_bytes: 3632
n,m,x=map(int,input().split())
a=[]
e=10**8
for i in range(n):
    b=list(map(int,input().split()))
    a.append(b)
for i in range(2**n):
    c=[0]*(m+1)
    s=0
    for j in range(n):
        if i>=2**(n-j-1):
            i-=2**(n-j-1)
            c=[x+y for (x,y) in zip(a[j],c)]
    for j in range(m):
        if c[1+j]<x:
            s+=1
    if s==0 and e>c[0]:
        e=c[0]
if e==100000000:
    print(-1)
else:
    print(e)

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

#define ll long long
#define MAX 300005
#define pp pair<int,pair<int,int>>
#define pb push_back
#define mod 1000000007
using namespace std;

/*
 * author: Kruti_20
 */

ll power(ll x, ll y);

ll gcd(ll a, ll b);

int dp[1005][1005];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int h, w;
    cin >> h >> w;
    string s[h];
    for (int i = 0; i < h; i++) cin >> s[i];
    dp[1][1] = 1;
    for (int i = 1; i <= h; i++) {
        for (int j = 1; j <= w; j++) {
            if ((i == 1 && j == 1) || s[i - 1][j - 1] == '#') continue;
            if (i == 0) dp[i][j] = (dp[i][j] + dp[i][j - 1]) % mod;
            else if (j == 0) dp[i][j] = (dp[i][j] + dp[i - 1][j]) % mod;
            else dp[i][j] = (dp[i][j] + dp[i - 1][j] + dp[i][j - 1]) % mod;
        }
    }
    cout << dp[h][w] << "\n";
    return 0;
}


ll power(ll x, ll y) {
    ll res = 1;
    x = x % mod;
    while (y > 0) {
        if (y & 1) res = (res * x) % mod;
        y = y >> 1;
        x = (x * x) % mod;
    }
    return res;
}

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


Measured memory_bytes: 5248
#include<iostream>
#include<string>// 加法 S.size() s.substr(l,r=s.size()-l) -> l文字目からr文字分
#include<cmath>//三角関数,rad
#include<algorithm>//__gcd()　lower_bound(a+l,a+r,x)-a でindex
// 配列  -> min/max({}) 
// vector-> *min_element(a+l,a+r)  *忘れず lとrで[l,r) 
//reverse(a+l,a+r)   配列aの[l,r)を逆順に strはreverse(all(s))
//sort(a+l,a+r,greater <int>()) 配列aの[l,r)昇順sort,大きい順はgreater<type>()
//vectorならall(v)
#include<ctime>//"clock()/CLOCKS_PER_SEC で秒数
#include<vector>//v.push_back(x),v.pop_back()
#include<queue>//q.push(x),front()で先頭を返す,pop()で削除, size(),empty()
#include<functional>//vector,queueと併用でpriority_queue
//宣言は priority_queue< Type, vector<Type>, greater<Type>> Q1; 
// pq.push(x),top()で参照 pop()で削除   greaterで最小 lessで最大がtopに
using namespace std;
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define print(i) std::cout << (i) << '\n'
void inlineprint(auto v){
  auto p=v.end()-1;
  for (auto y=v.begin();y<p;y++){cout<<*y<<" ";}
  cout<<*p<<"\n";
} 
inline int ceildiv(int a, int b) { return (a+b-1)/b; }
typedef pair<int,int> P;
const int inf = 10e7;
//int |x|<=2*10**9     long |x|<= 9*10**18

signed main(){
int n,s=0,sum=0;
cin>>n;vector<int> v(n),res(n);
rep(i,n){cin>>v[i];if (i%2)s+=v[i];sum+=v[i];}
res[0]=sum-2*s;int pre=res[0];
rep(i,n-1){res[i+1]=2*v[i]-pre;pre=res[i+1];}
inlineprint(res);
}


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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
#define POSSIBLE(condition) if(condition){cout << "POSSIBLE" << endl;}else{cout << "IMPOSSIBLE" << endl;}
#define Possible(condition) if(condition){cout << "Possible" << endl;}else{cout << "Impossible" << endl;}
#define possible(condition) if(condition){cout << "possible" << endl;}else{cout << "impossible" << endl;}
#define Size(n) (n).size()

typedef long long ll;


using namespace std;

const int INF = 1e9,MOD = 1e9 + 7,ohara = 1e6;
const ll LINF = 1e18;


long long int n,cnt=0,ans=0,a,b,c,d,cmp,cmpp,m,h,w,x,y,sum=0,pos,k,s;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz");
bool fl=true;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

      
      cin>>k>>s;
      rep(y,k+1){
        rep(z,k+1){
          x=s-y-z;
          if(x>=0 and x<=k)ans++;
        }
      }
     
     Cout(ans);

       
return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define IO ios::sync_with_stdio(false), cin.tie(0)
#define endl '\n'
#define pi acos(-1.0)
#define lowbit(x) ((x)&(-(x)))
#define debug(x) cout<<x<<'\n'
#define pii pair<ll,pair<ll,ll> >
using namespace std;
const ll INF=0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
//const ll mod = 1e9+7;
ll mod;
const double eps = 1e-6;
ll gcd(ll a, ll b) {return b==0?a:gcd(b, a%b);}
ll lcm(ll a, ll b) {return a/gcd(a, b)*b;}
ll mul(ll a,ll b){ll ans=0;a%=mod,b%=mod;while(b) { if(b&1) ans = (ans+a)%mod; a = (a*2)%mod; b >>= 1; }return ans;}
ll powmod(ll a,ll b){ ll ans = 1, pow = a; while(b) { if(b&1) ans = (ans*pow)%mod; pow = (pow*pow)%mod; b >>= 1; } return ans;}
//(b/a)%p=b*a^(p-2)%p
int pr(ll num){//判素
     if(num == 1) return 0;
     if(num ==2|| num==3 ) return 1 ;
     if(num %6!= 1&&num %6!= 5) return 0 ;
     int tmp =sqrt( num);
     for(int i= 5;i <=tmp; i+=6 )
          if(num %i== 0||num %(i+ 2)==0 )return 0 ;
     return 1 ;
}
int Day(int y,int m, int d){if(m==1||m==2) { m+=12; y--; }int w=(d+2*m+3*(m+1)/5+y+y/4-y/100+y/400)%7;return w+1;}
//int pri[1000005];
//void getpri(){
//    memset(pri,true,sizeof(pri));
//    pri[0]=pri[1]=0;
//    for(int i=2;i<=1000000;i++){
//        if(pri[i]){
//            for(int j=2*i;j<=1000000;j+=i)pri[j]=0;
//        }
//    }
//}
inline int read() {
    int c = 0, f = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9') {
        if (ch == '-') f = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9') {
        c = c * 10 + ch - '0';
        ch = getchar();
    }
    return c * f;
}
//int pre[100005];
//void init(){
//    for(int i=1; i<=100005;++i) pre[i]=i;
//}
//int getf(int x){
//    if(pre[x] == x) return x;
//    else return pre[x] = getf(pre[x]);
//}
//void join(int x,int y){
//    int a = getf(x);
//    int b = getf(y);
//    if(a!=b) pre[b]=a;
//}
//大小写转换
//String s;
//Form(s.begin(),s.end(),s.begin(),::toupper);
//Form(s.begin(),s.end(),s.begin(),::tolower);
//(char)toupper('a')
//(char)tolower('B')
//#pragma comment(linker, "/STACK:1024000000,1024000000")//外挂开栈
//stable_sort 排序不处理相同元素
//map<int,int>::reverse_iterator rit;
//for(rit=mp.rbegin();rit!=mp.rend();rit++)
//vec动态二维数组
//vector<vector<int>> g(26,vector<int>(100005));
//初始化vec里面套了n个vec
//lower_bound(begin,end,num) 有序数列中返回第一个>=num的数字的地址
//upper_bound( begin,end,num) 返回第一个>num的数字的地址
const int maxn=3e5+5;
int main(){
    IO;
    ll a,b;
    cin>>a>>b;
    ll c=a*b;
    cout<<c<<endl;
    return 0;
}



Measured memory_bytes: 3680
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> Pi;

#define Fi first
#define Se second
#define pb(x) push_back(x)
#define sz(x) (int)x.size()
#define rep(i, n) for(int i=0;i<n;i++)
#define repp(i, n) for(int i=1;i<=n;i++)
#define all(x) x.begin(), x.end()

#define ABS(x) (((x) > 0 ) ? (x) : (-(x)))
#define MAX2(x, y) (((x) > (y)) ? (x) : (y))
#define MIN2(x, y) (((x) < (y)) ? (x) : (y))
#define MAX3(x, y, z) ( (x) > (y)  ? ( (x) > (z) ? (x) : (z)  ) : ( (y) > (z) ? (y) : (z) )  )
#define MIN3(x, y, z) ( (x) < (y)  ? ( (x) < (z) ? (x) : (z)  ) : ( (y) < (z) ? (y) : (z) )  )
#define MID3(val1,val2,val3) MAX2(MIN2(MAX2(val1,val2),val3),MIN2(val1,val2))


#define geti1(X) scanf("%d",&X)
#define geti2(X,Y) scanf("%d%d",&X,&Y)
#define geti3(X,Y,Z) scanf("%d%d%d",&X,&Y,&Z)
#define geti4(X,Y,Z,W) scanf("%d%d%d%d",&X,&Y,&Z,&W)

#define GET_MACRO(_1,_2,_3,_4,NAME,...) NAME
#define geti(...) GET_MACRO(__VA_ARGS__, geti4, geti3, geti2, geti1) (__VA_ARGS__)

#define INF 1987654321
#define IINF 987654321987654321

#define MAX_V 1005
//int N,K,M;
ll p[100500];
ll sum = 0;
ll N;
int main()
{
	scanf("%lld",&N);
	repp(i,N){
		scanf("%lld",&p[i]);
		sum += p[i];
	}
	p[N+1] = p[1];
	ll q = N*(N+1)/2;
	if( sum % q != 0 ){
		cout << "NO"<< endl; return 0;
	}
	ll count = (ll) sum / ( ((ll)N*(N+1))/2 ) ;

	for(int i=1;i<=N;i++){
		ll diff = p[i+1]-p[i];
		ll t = (N-1)*count + diff;
		
		if( t % N != 0  || t < 0 ){
			cout << "NO" << endl; return 0;
		}
		ll a = t / N; ll b = count - a;
		if( b < 0 ){
			cout << "NO" << endl; return 0;
		}
	}

	cout << "YES";
}


Measured memory_bytes: 1024
using System;

namespace CSharp
{
    class Program
    {
        static void Main()
        {
            var N = Console.ReadLine();

            if (N[0] == '7' || N[1] == '7' || N[2] == '7')
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}

Measured memory_bytes: 25796
#include <bits/stdc++.h>
using namespace std;
#define MAX_D 11
#define INF 1<<30
typedef long long ll;
ll D, G, p[MAX_D], c[MAX_D];

int  main(void){
	cin >> D >> G;

	for(ll i=0; i<D; i++){
		cin >> p[i] >> c[i];
	}

	ll res = INF;
	for(ll i=0; i<(1<<D); i++){
		ll g = 0; ll n = 0;
		for(ll j=0; j<D; j++){
			if(i>>j&1){
				g += p[j] * (j+1) * 100 + c[j];
				n += p[j];
			}
		}

		if(G <= g) res = min(res, n);
		else{
			for(ll j=0; j<D; j++){
				if(!(i>>j&1) && G > g && G <= g + (j+1) * 100 * p[j]){
					res = min(res, n + ll(ceil(double(G - g) / (j+1) / 100)));
				}
			}
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 256
class SegTree:
    init_val = float('inf')  # 問題によって変える

    def __init__(self, init_l):
        self.n = len(init_l)
        self.n0 = 2 ** (self.n - 1).bit_length()  # n以上で最小の2のべき乗
        self.l = [self.init_val] * 2 * self.n0  # 区間外の値を初期化
        for i in range(self.n):
            self.l[i + self.n0 - 1] = init_l[i]
        for i in range(self.n0 - 2, -1, -1):
            self.l[i] = self.func(self.l[2 * i + 1], self.l[2 * i + 2])

    # 問題によって変える
    def func(self, x, y):
        return min(x, y)

    def update(self, i, new):
        i += self.n0 - 1
        self.l[i] = new
        while i + 1:
            i = (i - 1) // 2
            self.l[i] = self.func(self.l[i * 2 + 1], self.l[i * 2 + 2])

    # Gets min between [a, b)
    def query(self, a, b):
        return self._query(a, b, 0, 0, self.n0)

    def _query(self, a, b, k, l, r):
        if r <= a or b <= l:
            return self.init_val
        if a <= l and r <= b:
            return self.l[k]
        vl = self._query(a, b, k * 2 + 1, l, (l + r) // 2)
        vr = self._query(a, b, k * 2 + 2, (l + r) // 2, r)
        return self.func(vl, vr)

n, q = map(int, input().split())
l = [2**31-1]*n
s = SegTree(l)
for i in range(q):
    c, x, y = map(int, input().split())
    if c == 0:
        s.update(x, y)
    else:
        print(s.query(x, y+1))


Measured memory_bytes: 9488
#include <bits/stdc++.h>
#define int long long int
using namespace std;
template<typename T,typename U> using P=pair<T,U>;
template<typename T> using V=vector<T>;
template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}

template<typename T>auto&operator<<(ostream&s,const vector<T>&v){s<<"[";bool a=1;for(auto e:v){s<<(a?"":" ")<<e;a=0;}s<<"]";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const pair<T,U>&p){s<<"("<<p.first<<","<<p.second<<")";return s;}
template<typename T>auto&operator<<(ostream&s,const set<T>&st){s<<"{";bool a=1;for(auto e:st){s<<(a?"":" ")<<e;a=0;}s<<"}";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const map<T,U>&m){s<<"{";bool a=1;for(auto e:m){s<<(a?"":" ")<<e.first<<":"<<e.second;a=0;}s<<"}";return s;}
#define DUMP(x)  cerr<<#x<<" = "<<(x)<<endl;

struct edge { int to, cost; };

const int INF = 1e18;
const int MOD = 1e9+7;

signed main()
{
   int n; cin >> n;
   map<int,int> cnt;
   for (int i = 0; i < n; i++) {
      int a; cin >> a;
      cnt[a % 2]++;
   }

   if (n == 1 ||
       cnt[1] % 2 == 0) {
      cout << "YES" << endl;
   } else {
      cout << "NO" << endl;
   }

   return 0;
}


Measured memory_bytes: 256
#![allow(non_snake_case)]
use std::io::*;
use std::str::FromStr;
use std::cmp::*;

#[allow(dead_code)]
fn read<T : FromStr>() -> T {
  let token: String = stdin().lock()
    .bytes()
    .map(|c| c.expect("failed reading char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed parse")
}

#[allow(dead_code)]
fn read2<T : std::str::FromStr>() -> (T, T) {
  (read::<T>(), read::<T>())
}

#[allow(dead_code)]
fn read3<T : std::str::FromStr>() -> (T, T, T) {
  (read::<T>(), read::<T>(), read::<T>())
}

#[allow(dead_code)]
fn reads<T : std::str::FromStr>() -> Vec<T> {
  let mut line = String::new();
  stdin().read_line(&mut line).ok();
  line.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

struct SegTree<T: Copy> {
  n: usize,
  data: Vec<T>,
  zero: T,
  op: fn(T, T) -> T
}

impl<T: Copy> SegTree<T> {
  fn new(data_: &[T], zero: T, op: fn(T, T) -> T) -> Self {
    let m = data_.len();
    let mut n = 1;
    while n < m { n *= 2; }

    let mut data = vec![zero; 2*n];

    for i in 0..m {
      data[i + n - 1] = data_[i];
    }

    for ri in 0..n-2 {
      let i = n - 2 - ri; // [n-2 .. 0]
      data[i] = op(data[i*2+1], data[i*2+2]);
    }

    Self {
      n,
      data,
      zero,
      op
    }
  }

  #[allow(dead_code)]
  fn update(&mut self, i: usize, val: T) {
    let mut i = self.n - 1 + i;
    self.data[i] = val;
    while i > 0 {
      i = (i - 1) / 2;
      self.data[i] = (self.op)(self.data[i*2+1], self.data[i*2+2]);
    }
  }

  #[allow(dead_code)]
  fn query(&self, l: usize, r: usize) -> T {
    let mut l = l + self.n - 1;
    let mut r = r + self.n - 1;

    let mut res = self.zero;
    while l < r {
      if (l & 1) == 0 {
        res = (self.op)(res, self.data[l]);
      }
      if (r & 1) == 0 {
        res = (self.op)(res, self.data[r - 1]);
      }
      l = l / 2;
      r = (r - 1) / 2;
    }

    res
  }
}

fn main() {
  let n: usize = read();
  let k: usize = read();
  let mut xs: Vec<usize> = Vec::with_capacity(n);
  for _ in 0..n {
    let x = read();
    xs.push(x);
  }

  const LIMIT: usize = 300000 + 10;
  let mut seg = SegTree::new(
    &vec![0; LIMIT],
    std::i64::MIN,
    |x,y| max(x, y)
  );

  for x in xs {
    let l = if x >= k { x - k } else { 0 };
    let r = if x + k + 1 <= LIMIT { x + k + 1 } else { LIMIT };
    let head = seg.query(l, r);

    seg.update(x, head + 1);
  }

  let res = seg.query(0, LIMIT);
  println!("{}", res);
}

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

using namespace std;
typedef long long ll;
#define debug(x) cerr << x << "\n"
#define all(x) (x).begin(),(x).end()
#define exist(s, e)((s).find(e) != (s).end())

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string a,b,c;
    int ia=0,ib=0,ic=0;
    char turn = 'a';
    cin >> a >> b >> c;
    while(1) {
        switch(turn) {
            case 'a':
            if (ia == a.size()) {
                cout << "A\n";
                return 0;
            }
            turn = a[ia++];
            break;
            case 'b':
            if (ib == b.size()) {
                cout << "B\n";
                return 0;
            }
            turn = b[ib++];
            break;
            case 'c':
            if (ic == c.size()) {
                cout << "C\n";
                return 0;
            }
            turn = c[ic++];
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	for (int i=0;i<=21;i++)
	{
		if (a*i-i+1>=b)
		{
			cout<<i<<endl;
			return 0;
		}
		else continue;
	}
	return 0;
}

Measured memory_bytes: 256
class Factorial:
    def __init__(self,n,mod):
        self.f=[1]
        for i in range(1,n+1):
            self.f.append(self.f[-1]*i%mod)
        self.i=[pow(self.f[-1],mod-2,mod)]
        for i in range(1,n+1)[::-1]:
            self.i.append(self.i[-1]*i%mod)
        self.i.reverse()
    def factorial(self,i):
        return self.f[i]
    def ifactorial(self,i):
        return self.i[i]
    def comb(self,n,k):
        return self.f[n]*self.i[n-k]%mod*self.i[k]%mod
mod=10**9+7
h,w,a,b=map(int,input().split())
f=Factorial(h+w,mod)
ans=0
for i in range(b,w):
    ans=(ans+f.comb(h-a-1+i,i)*f.comb(a-1+w-i-1,w-i-1))%mod
print(ans)

Measured memory_bytes: 54516
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <cstdio>
#include <cstring>
#include <fstream>
#include <unordered_map>
#include <set>
#include <string>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <queue>

#define N 1009

using namespace std;

pair<int,int> p[N];
vector<int> dis;

int main(){
	int i,j,t1,t2,t3,t4,n,par;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d %d",&t1,&t2);
		p[i]=make_pair(t1,t2);
	}	
	par=abs((p[0].first+p[0].second)%2);
	for(i=1;i<n;i++){
		t1=abs((p[i].first+p[i].second)%2);
		if(t1!=par){
			printf("-1\n");
			return 0;
		}
	}
	if(!par){
		dis.push_back(1);
	}
	for(i=0;i<31;i++){
		dis.push_back(1<<i);
	}
	reverse(dis.begin(),dis.end());
	printf("%d\n",(int)dis.size());
	for(auto it : dis){
		printf("%d ",it);
	}
	printf("\n");
	for(i=0;i<n;i++){
		t1=p[i].first;
		t2=p[i].second;
		for(j=0;j<(int)dis.size();j++){
			if(abs(t1)>abs(t2)){
				if(t1<0){
					printf("L");
					t1+=dis[j];
				}
				else{
					printf("R");
					t1-=dis[j];
				}
			}
			else{
				if(t2<0){
					printf("D");
					t2+=dis[j];
				}
				else{
					printf("U");
					t2-=dis[j];
				}
			}
		}
		printf("\n");
	}
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int a,b,c,i,count;
    count = 0;
    scanf("%d %d %d", &a,&b,&c);

    for(i=a;i<=b;i++) {
        if(c%i == 0) {
            count = count + 1;
        }
    }
    printf("%d\n", count);
    return(0);
}



Measured memory_bytes: 2112
#include<bits/stdc++.h>
using namespace std;
int par1[200001],par2[200001];
vector<pair<int,int>> idx;
map<pair<int,int>,int> cnt;
int rep1(int n)
{
    if(par1[n]==n)
        return n;
    return par1[n]=rep1(par1[n]);
}
int rep2(int n)
{
    if(par2[n]==n)
        return n;
    return par2[n]=rep2(par2[n]);
}
int main()
{
    int i,j;
    int n,k,l;
    int a,b,res=0;
    scanf("%d %d %d",&n,&k,&l);
    for(i=1;i<=n;i++){
        par1[i]=i;
        par2[i]=i;
    }
    for(i=0;i<k;i++){
        scanf("%d %d",&a,&b);
        swap(a,b);
        int r1=rep1(a);
        int r2=rep1(b);
        par1[r1]=r2;
    }
    for(i=0;i<l;i++){
        scanf("%d %d",&a,&b);
        int r1=rep2(a);
        int r2=rep2(b);
        par2[r2]=r1;
    }
    for(i=1;i<=n;i++){

        idx.push_back(make_pair(rep1(i),rep2(i)));
    }

    for(i=0;i<idx.size();i++){
            //assert(idx[i].first == idx[i].second);
        cnt[idx[i]]++;
       // printf("%d %d\n",idx[i].first,idx[i].second);
    }
    for(i=0;i<idx.size();i++)
        printf("%d ",cnt[idx[i]]);
}


Measured memory_bytes: 15088
#include<cstdio>
#include<cstring> 
#include<iostream>
#include<algorithm>
using namespace std;
const int M=1200000;
int n,m,w[M],v[M],ans,ans1,ans2=1000000001;int a[M];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	printf("%d ",a[n]);
	int t=lower_bound(a+1,a+n+1,a[n]/2)-a;
	//printf("%d ",a[t]);
	for(int i=max(1,t-2);i<=min(t+2,n-1);i++) {
		if(a[i]==a[n]/2) {
			ans=a[i];break;
		}
		else if(a[i]<(a[n]/2)) ans1=max(a[i],ans1);
		else ans2=min(ans2,a[i]);
	}
	if(ans) printf("%d",ans);
	else if(ans1>=a[n]-ans2) printf("%d",ans1);
	else printf("%d",ans2);
} 

Measured memory_bytes: 2688
n, a, b = map(int, input().split())

cnt = 0
if (b-a)%2 == 1:
	if a-1 < n-b:
		cnt += a-1
		b = b - (a-1)
		a = 1
		cnt += 1
		b -= 1
		cnt += ((b-a)//2)
	else:
		cnt += n-b
		a = a + (n-b)
		b = n
		cnt += 1
		a += 1
		cnt += ((b-a)//2)
else:
	cnt += (b-a)//2
print(cnt)



Measured memory_bytes: 3064
n_quant =  [int(t) for t in input().split()]
que = []
for i in range(n_quant[0]):
    tmp = input().split()
    que.append((tmp[0], int(tmp[1])))

time = 0
while len(que) > 0:

    (name, val) = que.pop(0)
    if(val > n_quant[1]):
        que.append((name, val - n_quant[1]))
        time += n_quant[1]
    else:
        time += val
        print(name, time)



Measured memory_bytes: 12240
using System;

namespace A___ABC_Swap
{
    class Program
    {
        static void Main (string[] args)
        {
            var input = Console.ReadLine ().Split (' ');
            var x = int.Parse (input[0]);
            var y = int.Parse (input[1]);
            var z = int.Parse (input[2]);
            var temp = 0;
            temp = x;
            x = y;
            y = temp;
            temp = x;
            x = z;
            z = temp;
            Console.WriteLine ($"{x} {y} {z}");
        }
    }
}

Measured memory_bytes: 13140
/*   ꧁༒☬महाकाल☬༒꧂ ꧁༒ঔमहाकालঔ༒꧂
                   
                   ঔৣ۝महाकालᴳᵒᵈ۝ঔৣ            
 
 */ 
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template <typename T, typename cmp=less<T>> using oset =tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define ll long long 
#define mod 1000000007
#define inf 100000000000000
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define _it iterator
#define all(_x) _x.begin(),_x.end()
#define f first
#define s second
#define pb push_back
void mahakal(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
}
#define ar array
const ll maxN=3e3+1 , N=1e2+5;
ll dp[maxN][maxN];
ll n  , m ;
string s  ,  t , ans;
void solve(){
	cin>> s >> t ;
	ll n=s.length() , m=t.length();
	for(ll i=1;i<=n;i++){
		for(ll j=1;j<=m;j++){
			if(s[i-1]==t[j-1])dp[i][j]=1+dp[i-1][j-1];
			else dp[i][j]=max(dp[i-1][j] , dp[i][j-1]);
		}
	}
	ll i=n , j =m ;
	while(i>0 && j>0){
		if(s[i-1]==t[j-1]){
			ans.pb(s[i-1]);
			i--;j--;
		}
		else if(dp[i-1][j]>dp[i][j-1]){
			i--;
		}
		else{
			j--;
		}
	}
	reverse(ans.begin(),ans.end());
	cout<<ans<<endl;
}
int main(){
	//mahakal(),fast;
	ll t=1;
	// cin>> t ;
	while(t--)solve();

	return 0;
}

Measured memory_bytes: 73952
import java.util.Scanner;

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

        int[][] x = new int[n][d];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < d; j++) {
                x[i][j] = in.nextInt();
            }
        }

        int count = 0;
        for (int i = 0; i < n - 1; i++) {
            for (int j = i; j < n; j++) {
                int dist = 0;
                for (int k = 0; k < d; k++) {
                    dist += (Math.abs(x[i][k] - x[j][k])) * (Math.abs(x[i][k] - x[j][k]));
                }

                for (int k = 1; k <= Math.sqrt(dist); k++) {
                    if (k * k == dist) {
                        count++;
                        break;
                    }
                }
            }
        }

        System.out.println(count);

    }
}


Measured memory_bytes: 21588
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;

typedef long long LL;
ostream &debug = cout;

/* AOJ DPL_1_A */

const int N = 25;
const int M = 60005;
const int INF = 0x3f3f3f3f;

int n, m, a[N], dp[M];

signed main(void) {
	/* input */
	{
		scanf("%d%d", &m, &n);
		for (int i = 1; i <= n; i++)
			scanf("%d", a + i);
	}
	/* dynamic programming */
	{
		memset(dp, 0x3f, sizeof(dp)), dp[0] = 0;
		for (int i = 1, sum = 0; i <= n; sum += a[i++])
			for (int j = 0; j <= m; j++)
				dp[a[i] + j] = min(dp[a[i] + j], dp[j] + 1);
	}
	/* output */
	{
		printf("%d\n", dp[m]);
	}
//	system("pause");
}

Measured memory_bytes: 1428
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(n) begin(n),end(n)
using ll = long long;
using P = pair<int,int>;

int main() {
    int n, k;
    string s;
    cin >> n >> k >> s; k--;
    s[k] += 32;
    cout << s << endl;
    return 0;
}

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

using namespace std;
int main()
{
    int a, b, c;
    while(cin >> a >> b >> c)
    {
        int arr[3];
        arr[0] = a, arr[1] = b, arr[2] = c;
        sort(arr, arr + 3);
        cout << arr[2] * 10 + arr[1] + arr[0] << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import collections

n = int(input())
D = list(map(int, input().split()))
M = int(input())
T = list(map(int, input().split()))

cD = collections.Counter(D)
cT = collections.Counter(T)

for k, v in cT.items():
    if k not in cD or cD[k] < v:
        print('NO')
        break
else:
    print('YES')


Measured memory_bytes: 57056