akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long int
#define FASTIO std::ios::sync_with_stdio(false);
#define pb push_back
#define mp make_pair
#define ld long double
#define F first
#define S second
#define inf 1e18
#define err(x) cout<<x<<endl
#define all(x) x.begin(),x.end()
#define input_from_file  freopen("input.txt", "r", stdin);
#define sz 100005
using namespace std;



int main()
{


    FASTIO
    ll a,b,c;
    cin >> a >> b >> c;
    ll res = min(a,b+c);
     res = res - b;
    c-=res;
    cout << c;


return 0;
}


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

#define LL long long

const long long oo = 1e9 + 7;

char a[60],b[60];
int n;
char c[60];
long long ans;

int main( ) {
   // freopen("test.txt","r",stdin);
    cin >> n;
    int cnt =1;
    for (int i =1 ; i <= n; i++) cin >> a[i];
    for (int i =1 ; i <= n ; i++) cin >> b[i];
    int i = 1;
    while ( i <= n ) {
        if ( a[i] == b[i] ) {
            c[cnt] = 'x';
            i++;
        }
        else {
            c[cnt] = 'y';
            i += 2;
        }
        cnt++;
    }
    if ( c[1] == 'x') ans = 3;
    if ( c[1] == 'y') ans = 6;
    for (int i = 1 ; i <= cnt ; i++) {
        if ( c[i] == 'x' && c[i+1] == 'y' ) ans = 1LL*(ans*2);
        if ( c[i] == 'x' && c[i+1] == 'x' ) ans = 1LL*(ans*2);
        if ( c[i] == 'y' && c[i+1] == 'x' ) ans = 1LL*(ans*1);
        if ( c[i] == 'y' && c[i+1] == 'y' ) ans = 1LL*(ans*3);
        ans = ans % oo;
    }
    cout << ans;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <unordered_map>
#include <ctime>
#include <list>
#include <numeric>
#include <utility>
#include <ctime>
#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int main(){
  int h,w,d,q,l,r;
  int a[305][305];
  int cost[90005]={0};
  map<int,pi> data;
  cin>>h>>w>>d;
  rep(i,h)rep(j,w){cin>>a[i][j];data[a[i][j]]=mp(i,j);}
  REP(i,1,d+1){
    int cnt=i+d;
    while(cnt<h*w+5){
      cost[cnt]=abs(data[cnt-d].first-data[cnt].first)+abs(data[cnt-d].second-data[cnt].second)+cost[cnt-d];
      
      //cout<<cnt<<" "<<cost[cnt]<<endl;
      cnt+=d;
    }
  }
  //rep(i,w*h+1)cout<<i<<" "<<cost[i]<<endl;
  cin>>q;
  rep(i,q){
    cin>>l>>r;
    cout<<max(0,(cost[r]-cost[l]))<<endl;;
  }
  return 0;
}


Measured memory_bytes: 7424
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner stdin = new Scanner(System.in);
		while (stdin.hasNextLine()){
			int n = stdin.nextInt();
			int p = stdin.nextInt();
			if (n == 0 && p == 0) break;
			Game g = new Game(n, p);
			System.out.println(g.winner());
		}
		System.exit(0);
	}
}

class Player {
	private int pebbles = 0;
	public boolean hasPebbles() {
		return pebbles != 0 ? false : true;
	}
	public int getPebbles() {
		return pebbles;
	}
	public int putPebbles() {
		int tmp = pebbles;
		pebbles = 0;
		return tmp;
	}
	public void takePebble(){
		pebbles++;
	}
}

class Bowl {
	private int pebbles;
	public Bowl(int pebbles) {
		this.pebbles = pebbles;
	}
	public int getPebbles() {
		return pebbles;
	}
	public void draw(Player player) {
		if (pebbles == 0) {
			pebbles += player.putPebbles();
		}
		else {
			player.takePebble();
			pebbles--;
		}
	}
}

class Game {
	private Player[] players;
	private Bowl bowl;
	private int p;
	public Game(int n, int p){
		players = new Player[n];
		for (int i = 0; i < n; i++) {
			players[i] = new Player();
		}
		bowl = new Bowl(p);
		this.p = p;
	}

	public int winner() {
		int i = 0;
		while(! finished()) {
			bowl.draw(players[i]);
			i = (i + 1) % players.length;
		}
		if (--i < 0) i = players.length - 1;
		return i;
	}

	private boolean finished() {
		for (int  i = 0; i < players.length; i++) {
			int p = players[i].getPebbles();
			if (p == this.p) return true;
			if (p > 0) return false;
		}
		return false;
	}
}

Measured memory_bytes: 20384
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <numeric>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
//#define int long long

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

	char S[55][55];

	for (int i = 0; i < 55; i++)
	{
		for (int j = 0; j < 55; j++)
		{
			S[i][j] = '.';
		}
	}

	int H, W;
	cin >> H >> W;
	for (int i = 1; i <= H; i++)
	{
		for (int j = 1; j <= W; j++)
		{
			cin >> S[i][j];
			if (S[i][j] == '.')S[i][j] = '0';
		}
	}
	for (int i = 1; i <= H; i++)
	{
		for (int j = 1; j <= W; j++)
		{
			if (S[i][j] == '#')continue;
			if (S[i+1][j] == '#')S[i][j]++;
			if (S[i-1][j] == '#')S[i][j]++;
			if (S[i][j+1] == '#')S[i][j]++;
			if (S[i][j-1] == '#')S[i][j]++;
			if (S[i+1][j+1] == '#')S[i][j]++;
			if (S[i+1][j-1] == '#')S[i][j]++;
			if (S[i-1][j+1] == '#')S[i][j]++;
			if (S[i-1][j-1] == '#')S[i][j]++;
		}
	}
	for (int i = 1; i <= H; i++)
	{
		for (int j = 1; j <= W; j++)
		{
			cout << S[i][j];
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int N_MAX = 1000;
int main()
{
  int n,m,i,j;
  long long x,y,z,res;
  long long rr[8][N_MAX],r[8];
  cin >> n >> m;
  for(i=0;i<n;i++){
    cin >> x >> y >> z;
    rr[0][i]=x+y+z;
    rr[1][i]=x+y-z;
    rr[2][i]=x-y+z;
    rr[3][i]=x-y-z;
    rr[4][i]=-x+y+z;
    rr[5][i]=-x+y-z;
    rr[6][i]=-x-y+z;
    rr[7][i]=-x-y-z;
  }
  for(i=0;i<8;i++){
    r[i]=0;
    sort(rr[i],rr[i]+n,greater<long long>());
    for(j=0;j<m;j++)
      r[i]+=rr[i][j];
  }
  res=*max_element(r,r+8);
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
from sys import stdin

n = int(stdin.readline().rstrip())
l = [1,2,3,4,5,6,7,8,9,2,4,6,8,10,12,14,16,18,3,6,9,12,15,18,21,24,27,4,8,12,16,20,24,28,32,36,5,10,15,20,25,30,35,40,45,6,12,18,24,30,36,42,48,54,7,14,21,28,35,42,49,56,63,64,72,81]
ans = n in l
if ans == True:
    ans = "Yes"
else:
    ans = "No"
print(ans)


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

int gcd(int a, int b){
    while(b){
        int t = a;
        a = b;
        b = t%b;
    }
    return a;
}

int main() {
    int N, M; cin >> N >> M;
    string S, T; cin >> S >> T;
    
    int g = gcd(N, M);
    bool f = true;
    for(int i=0; i<g; i++)
        if(S[N*i/g] != T[M*i/g]) f = false;

    if(f) cout << (long long)N*M/g << endl;
    else cout << -1 << endl;

    return 0;
}


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

bool checkP(string str){
    string tt= str;
    reverse(tt.begin(),tt.end());
    if(str==tt) return true;
    else
    return false;
}

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	cout.tie(0);
    
    string str;
    cin>>str;
    int len;
    len = str.length();
    if(len%2==0)  cout<<"No"<<endl;
    else{
        bool p1=checkP(str);
        if(p1==false) cout<<"No"<<endl;
        else{
            string s1= str.substr(0,(len-1)/2);
            //cout<<s1<<"yfvju"<<endl;
            bool p2=checkP(s1);
            string s2= str.substr((len+1)/2,len/2);
            //cout<<s2<<"rrf"<<endl;
            bool p3 =  checkP(s2);
            
            if(p2==true && p3==true) cout<<"Yes"<<endl;
            else cout<<"No"<<endl;
        }
    }
    
    return 0;
}

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

int factorial(int n) {
  int ans = 1;
  for (int i = 1; i <= n; i++) {
    ans *= i;
  }
  return ans;
}

int main() {
  int n;
  cin >> n;
  int p[n], q[n];
  for (int i = 0; i < n; i++) cin >> p[i];
  for (int i = 0; i < n; i++) cin >> q[i];

  int pNum = 1;
  int qNum = 1;
  int miniCount = 0;

  for (int i = 0; i < n - 1; i++) {
    miniCount = 0;
    for (int mini = i + 1; mini < n; mini++) {
      if (p[i] > p[mini]) miniCount++;
    }
    pNum += (factorial(n - i - 1) * miniCount);
  }

  for (int i = 0; i < n - 1; i++) {
    miniCount = 0;
    for (int mini = i + 1; mini < n; mini++) {
      if (q[i] > q[mini]) miniCount++;
    }
    qNum += (factorial(n - i - 1) * miniCount);
  }

  cout << abs(pNum - qNum) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define Endl endl
#define NL <<"\n"

using namespace std;
using ll=long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
template<class T> using vv=vector<vector<T>>;
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
//#undef NUIP
#ifdef NUIP
#include "benri.h"
#else
#define out(args...)
#endif
#ifdef __cpp_init_captures
template<typename T>vector<T> table(int n, T v){ return vector<T>(n, v);}
template <class... Args> auto table(int n, Args... args){auto val = table(args...); return vector<decltype(val)>(n, move(val));}
#endif
const ll MOD=1e9+7; //998244353

int main(){
  ios_base::sync_with_stdio(false); cin.tie(0);
  cout<<fixed<<setprecision(0);
	ll n;
  cin>>n; n;
  ll k;
  cin>>k; k;
  ll s;
  cin>>s; s;
	vector<int> re(k,s);
	const int mx=1e9;
	if(s==mx){
		re.resize(n,1);
	}else{
		re.resize(n,s+1);
	}
	rep(i,n) cout<<re[i]<<" ";
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
 
const ll MOD=1e9+7;
const ll INF=1e18;
 
int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};

int sum[250005];
bool prime[250005];

int main(){
    prime[1] = true;
    int a = 0;
    for(int i = 2;i < 250000;i++){
        if(prime[i] == false){
            a++;
            for(int j = 1;i*j < 250000;j++){
                prime[i*j] = true;
            }
        }
        sum[i] = a;
    }
    while(true){
        int n;
        cin >> n;
        if(n == 0) break;
        cout << sum[n*2] - sum[n] << endl;
    }
}


Measured memory_bytes: 4216
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
const int P=1e9+7;
int n,m,cnt,num,a[N],b[N],d[N],f[N];
struct each{
	int l,r;
	bool operator == (each k){
		return l==k.l&&r==k.r;
	}
}c[N];
bool com(each x,each y){
	if(x.l==y.l)	return x.r>y.r;
	return x.l<y.l;
}
void add(int x,int y){
	while(x<=num){
		f[x]=(f[x]+y)%P;
		x+=x&-x;
	}
}
int query(int x){
	int ans=0;
	while(x){
		ans=(ans+f[x])%P;
		x-=x&-x;
	}
	return ans;
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)	scanf("%d",&a[i]);
	for(int i=1;i<=m;i++)	scanf("%d",&b[i]);
	sort(a+1,a+n+1),sort(b+1,b+m+1);
	n=unique(a+1,a+n+1)-a-1;
	m=unique(b+1,b+m+1)-b-1;
	for(int i=1;i<=n;i++){
		if(a[i]<b[1]||a[i]>b[m])	continue;
		int k=lower_bound(b+1,b+m+1,a[i])-b;
		if(b[k]==a[i])	continue;
		c[++cnt].l=a[i]-b[k-1];
		d[cnt]=c[cnt].r=b[k]-a[i];
	}
	d[cnt+1]=0;
	sort(d+1,d+cnt+2);
	sort(c+1,c+cnt+1,com);
	num=unique(d+1,d+cnt+2)-d-1;
	add(1,1);
	for(int i=1;i<=n;i++){
		if(c[i]==c[i-1])	continue;
		int k=lower_bound(d+1,d+num+1,c[i].r)-d;
		add(k,query(k-1));
	}
	printf("%d\n",query(num));
	return 0;
}


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

class Program
{
    static void Main(string[] args)
    {
        var inputs = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        var a = inputs[0];
        var b = inputs[1];
        var c = inputs[2];
        var d = inputs[3];

        bool isTakahashi = true;

        while (true)
        {
            if(isTakahashi){
                c = c - b;
                if(c <= 0)
                {
                    Console.WriteLine("Yes");
                    break;
                }
                isTakahashi = false;
            }
            else
            {
                a = a - d;
                if(a <= 0)
                {
                    Console.WriteLine("No");
                    break;
                }
                isTakahashi = true;
            }
        }

    }
}

Measured memory_bytes: 19032
//おまじない
//#include <bits/stdc++.h>
#include <iostream>
#include<iomanip>
#include <set>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
#define all(a) a.begin(),a.end()
#define P pair<int,int>
#define space ' '
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

ll mod = 998244353;
const int maxn = 100000;

int main(){
    
    ll n;
    ll ans = 1;
    ll mul[maxn+1]={0};
    ll d[maxn+1]={0};
    ll ml=0;
    
    cin >> n;
    rep(i,n){
        ll L;
        cin >> L;
        ml = max(ml,L);
        d[L]++;
        if((i==0&&L!=0)||(i!=0&&L==0)){
            ans=0;
        }
    }
    
    mul[0]=1;
    
    for(int i=ml;i>=1;i--){
        ll m = 1;
        ll L = d[i];
        ll L_1 =d[i-1];
        if(L_1==0){
            ans=0;
            break;
        }
        rep(j,L){
            m = m*L_1%mod;
        }
        mul[i]=m;
    }
    
    for(int i=ml;i>0;i--){
        ans = ans*mul[i]%mod;
    }
    
    cout << ans<<endl;
    
    return 0;
}


Measured memory_bytes: 1792
#include<cstdio>
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<algorithm>

//3 9 5 3 8 2 1 6 9 7 4

using namespace std;

int main(){
	int DP[101][21];
	int dansu,kansu;
	while(1){
		scanf("%d%d",&dansu,&kansu);
		if(dansu==0){
			break;
		}
		int hon[101];
		for(int i=1;i<=kansu;i++){
			scanf("%d",&hon[i]);
		}
		int atu[101];
		atu[0]=0;
		for(int i=1;i<=kansu;i++){
			atu[i]=atu[i-1]+hon[i];
		}
		for(int i=1;i<=kansu;i++){
			for(int j=1;j<=dansu;j++){
				DP[i][j]=210000000;
			}
		}
		for(int i=1;i<=kansu;i++){
			DP[i][1]=atu[i];
		}
		for(int i=1;i<=dansu;i++){
			DP[1][i]=atu[1];
		}
		
		for(int i=2;i<=kansu;i++){
			for(int j=2;j<=dansu;j++){
				for(int k=1;k<i;k++){
					DP[i][j]=min(max(DP[k][j-1],atu[i]-atu[k]),DP[i][j]);
				}
			}
		}
		
		/*
		for(int i=1;i<=kansu;i++){
			for(int j=1;j<=dansu;j++){
				printf("%6d",DP[i][j]);
			}
			puts("");
		}
		for(int i=1;i<=kansu;i++){
			printf("%d ",atu[i]);
		}
		puts("");
		*/
		
		printf("%d\n",DP[kansu][dansu]);
	}
}

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

#define each(i, c) for (auto& i : c)
#define mkp(a, b) make_pair(a, b)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9+7;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << ": " << p.second << ")"; return os; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ", "; os << ")"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; each (i, m) os << i << ", "; os << "}"; return os; }

int main() {
  ll x, n;
  cin >> x >> n;

  map<ll, bool> m;
  for (ll i = 0; i < n; ++i) {
    ll p;
    cin >> p;
    m[p] = true;
  }

  ll diff = 1e18;
  ll ans = 1e18;
  for (ll i = 0; i <= 200; ++i) {
    if (m.count(i)) continue;
    ll tmp = abs(x - i);
    if (tmp < diff ) {
      diff = tmp;
      ans = i;
    } else if (tmp == diff && i < ans) {
      diff = tmp;
      ans = i;
    }
  }

  cout << ans << endl;

  return 0;
}


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

int main() {
    int h, r;
    cin >> h >> r;
    if(h + r < 0) {
        cout << -1 << endl;
    } else if(h + r > 0) {
        cout << 1 << endl;
    } else {
        cout << 0 << endl;
    }
}



Measured memory_bytes: 3092
/*
 *  Author: Tara Prasad
 */
#include <bits/stdc++.h>
// #include "prettyprint.h"
using namespace std;

 #define LOGGING // May cause TLE or CE
#ifdef LOGGING
	#define LOG(x) cerr << "*** " << x << " ***" << endl;
	#define wi(x) what_is(x, '\n')
	#define wisp(x) what_is(x, ", ")
	#define what_is(x, terminator) cerr << #x << " = " << x << terminator;
#else
	#define LOG(x)
	#define wi(x)
	#define wisp(x)
	#define what_is(x, terminator)
#endif

#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define REV_ALL(x) x.rbegin(), x.rend()
#define SZ(x) (int)x.size()
#define CONTAINS(cont, val) (cont.find(val) != cont.end())
#define endl '\n'
#define IO_SPEED_UP ios::sync_with_stdio(false);cin.tie(NULL)
#define FOR(i, s, e) for(ll i = s; i < e; i++)
#define leftmost_set(x) __builtin_clzll(x)
#define PARENT(n) ((n) >> 1LL)
#define LCHILD(n) ((n) << 1LL)
#define RCHILD(n) (((n) << 1LL) + 1LL)
#define TWO_POWER(n) (1LL << (n))

typedef long long ll;typedef pair<ll, ll> ii;
typedef vector<ll> vi;typedef vector<bool> vb;
typedef vector<ii> vii;typedef vector<vi> vvi;

const ll PINF = 1E9 + 5;
const ll NINF = -1E9 - 5;
const ll M = 1E9 + 7;
const double EPS = 1E-9;
const double PI = 2 * acos(0);

template <typename T> ostream& operator<<(ostream& os, const vector<T> &p){os << "[ "; for (T x: p) os << x << " "; os << "]" << endl; return os;}
template <typename T> ostream& operator<<(ostream& os, const set<T> &p){os << "{ "; for (T x: p) os << x << " "; os << "}" << endl; return os;}
template <typename Tk, typename Tv> ostream& operator<<(ostream& os, const map<Tk, Tv> &p){os << "{ "; for (pair<Tk, Tv> x: p) os << x << " "; os << "}" << endl; return os;}
template <typename Tk, typename Tv> ostream& operator<<(ostream& os, const pair<Tk, Tv> &p){os << "{" << p.first << ',' << p.second << "}";return os;}

void get_arr(vi& a, int n) {
	if(SZ(a) < n) a.resize(n); for(int i = 0; i < n; i++) cin >> a[i];
}

void print_arr(const vi &a) {
	for(int i = 0; i < SZ(a); i++) {cout << a[i] << " ";} cout << endl;
}

ll nc2(ll n) {
	return n * (n - 1) / 2;
}

int main() {
	IO_SPEED_UP;
	if(fopen("tupni.txt", "r")) {
		freopen("tupni.txt", "r", stdin);
		freopen("tuptuo.txt", "w", stdout);
	}
	string s; cin >> s;
	vi cnt(26, 0);
	for (int i = 0; i < SZ(s); ++i) {
		cnt[s[i] - 'a']++;
	}
	wi(cnt)
	ll ans = nc2(SZ(s));
	for (int i = 0; i < 26; ++i) {
		ans -= nc2(cnt[i]);
	}
	cout << ans + 1 << endl;
	return 0;
}


Measured memory_bytes: 720
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
typedef unsigned long long ull ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define rrep(i , n) for ( int i = n-1; i >=0 ; i--)

#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

class UnionFind {
private:
	ull size_; 
	std::vector<ull> par, rank, count;

public:
	UnionFind() : size_(0), par(std::vector<ull>()), rank(std::vector<ull>()), count(std::vector<ull>()) {};
	UnionFind(ull size__) : size_(size__) {
		par.resize(size_); rank.resize(size_); count.resize(size__);
		for (ull i = 0; i < size_; i++) par[i] = i, rank[i] = 0, count[i] = 1;
	}
	ull size() { return size_; }
	// ull root(ull x) { return par[x] == x ? x : par[x] = root(par[x]); }
	
	ull root(ull x)
	{
		while(par[x] != x)
		{
			par[x] = par[par[x]];
			x = par[x];
		}
		return x;
	}
	
	bool same(ull x, ull y) { return root(x) == root(y); }

	void unite(ull x, ull y) {
		x = root(x), y = root(y);
		if (x == y) return;
		if (rank[x] < rank[y]) par[x] = y, count[y]+=count[x], count[x]=0;
		else if (rank[x] == rank[y]) par[y] = x, rank[x]++, count[x]+=count[y], count[y]=0;
		else par[y] = x, count[x] += count[y], count[y] = 0;
	}

	ull size__(ull x)
	{
		return count[root(x)];
	}

	bool operator==(const UnionFind &u) { return par == u.par; }
	bool operator!=(const UnionFind &u) { return par != u.par; }
};
/*
maybe sth wrong 
got wa in one problem
*/
ll modpow(ll a, ll b)
{
	if (b == 0)
	{
		return 1;
	}

	if (b % 2)
	{
		return a * modpow(a, b-1) % MOD;
	}
	else
	{
		ll halfB = b / 2;
		ll half = modpow(a, halfB);
		return half * half % MOD;
	}
}

ll calcComb(ll n, ll m)
{
	if (m > n-m)
	{
		return calcComb(n, n-m);
	}

	ll ansMul = 1;
	ll ansDiv = 1;

	rep(i, m)
	{
		ansMul *= (n-i);
		ansDiv *= (i+1);
		ansMul %= MOD;
		ansDiv %= MOD;
	}

	return ansMul * modpow(ansDiv, MOD - 2) % MOD;
}

__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}


int main()
{
	string s;
	cin >> s;
	
	ll dp[100005][13];
	memset(dp, 0, sizeof(dp));
	dp[0][0] = 1;

	int len = s.size();

	for(int i = 0; i < len; i++)
	{
		int c = -1;
		if (s[i] != '?')
		{
			c = s[i] - '0';
		}

		rep(j, 10)
		{
			if ( ( c != -1 ) &&  ( c != j ) )
			{
				continue;
			}
			rep(k, 13)
			{
				dp[i+1][ (k*10+j) % 13] += dp[i][k];
			}
		}
		rep(j, 13)
		{
			dp[i+1][j] %= MOD;
		}
	}

	cout << dp[len][5] << endl;

	return 0;
}


Measured memory_bytes: 10704
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define lp(i,n) for(int i=0;i<(n);++i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(),(x).end()
#define ctoi(x) (x - 'a') 
#define CTOI(x) (x - 'A')
#define BIT(x) (1 << (x))
using namespace std;

LL modinv(LL a){
    LL b = MOD, u = 1, v = 0;
    while(b){
        LL t = a / b;
        a -= t * b;swap(a, b);
        u -= t * v;swap(u, v);
    }
    u%=MOD;
    if(u < 0) u += MOD;
    return u;

}
LL exp(int a, int b){
    LL res = 1;
    LL sum = a;
    while(b){
        if(b&1)res = (res * sum) % MOD;
        sum = (sum * sum) % MOD;
        b>>=1;
    }
    return res;
}

int cul(int a, int b){
    int c = abs(a-b);
    return c * (c - 30) * (c - 30);
}

int M, W;
vector<int> m, w;
vector<vector<int> > dp;

int func(int used, int place){
    if(place == M)return 0;
    if(dp[place][used] >= 0)return dp[place][used];
    int res = 0;
    REP(i, W){
        if(used & BIT(i))continue;
        res = max(res, cul(m[place], w[i]) + func(used | BIT(i), place + 1));
    }
    return dp[place][used]=res;
}
int main(){
    while(cin >> M >> W && M){
        m = vector<int>(M);
        w = vector<int>(W);
        REP(i, M)cin>>m[i];
        REP(i, W)cin>>w[i];
        if(M > W){
            swap(m, w);
            swap(M, W);
        }
        dp = vector<vector<int> >(M, vector<int>(1<<W, -1));
        cout << func(0, 0) << endl;
    }
    return 0;
}



Measured memory_bytes: 3180
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for(int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

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

    ll ans = 1000;
    ll stock = 0;

    ll a[n];
    rep(i,n)cin >> a[i];

    rep(i,n){
        ll tmp = ans / a[i];
        ans -= tmp * a[i];
        stock += tmp;

        if(i == n - 1 || a[i] > a[i+1]){
            ans += stock * a[i];
            stock = 0;
        }
    }

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




Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 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; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N;
    string S;
    cin >>S;
    N=S.size();
    ll flag = 0;
    if(S[0]!='A'){
        flag = 1;
    }
    if(!(S[1]>='a'&&S[1]<='z')){
        flag = 1;
    }
    ll cnt=0;
    rep3(i,2,N-1){
        if(S[i] == 'C'){
            cnt++;
        }else if(S[i]>='a'&&S[i]<='z'){

        }else{
            flag = 1;
        }
    }
    if(!(S[N-1]>='a'&&S[N-1]<='z')){
        flag = 1;
    }

    if(flag==0 && cnt==1){
        cout<<"AC"<<endl;
    }else{
        cout << "WA" << endl;
    }
    


    return 0;
    

}

Measured memory_bytes: 3588
#include <stdio.h>

int main(void)
{
	int N = 0,L[201] = {0};
	int i = 0,j = 0,l = 0,ans = 0;
	scanf("%d",&N);
	for(i = 0;i < N * 2;i++)
		scanf("%d",&L[i]);
	for(i = 0;i < N * 2 - 1;i++){
		for(j = i + 1;j < N * 2;j++){
			if(L[i] > L[j]){
				l = L[i];
				L[i] = L[j];
				L[j] = l;
			}
		}
	}
	
	for(i = 0;i < N * 2;i += 2){
		ans += L[i];
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
 
#define int         long long
#define uint        unsigned int
#define ld          long double
#define showoff     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define pii         pair<int,int>
#define FOR(i,a,b)  for(int i=a;i<b;++i)
#define RFOR(i,a,b) for(int i=a;i>b;--i)
#define f           first
#define se          second
#define maxn        200005
#define all(v)      v.begin(),v.end()
#define sz(x)       (int)x.size()
#define mod         1000000007
#define pqueue      priority_queue<int>
#define pdqueue     priority_queue< int,vector<int> ,greater< int >>
 
using namespace std;
 
 
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
 
int power(int a,int n)
{
    a %= mod;
    if(n == 1)return a;
    if(n == 0)return 1;
    if(n%2)return (a*(power((a*a)%mod,n/2)%mod))%mod;
    return power((a*a)%mod,n/2)%mod;
}
const int inf = (int) 1e18;
 
int inverse(int x){
    return power(x,mod-2)%mod;//little fermat....
}

vector<int>adj[maxn],val(maxn);

void dfs(int x,int p){

	for(auto &y:adj[x]){
		if(y != p){
			val[y] += val[x];
			dfs(y,x);
		}
	}
}

signed main()
{
    showoff;
    int n,q;
    cin >> n >> q;
    FOR(i,1,n){
    	int u,v;
    	cin >> u >> v;
    	adj[u].pb(v);
    	adj[v].pb(u);
    }
    while(q--){
    	int p,x;
    	cin >> p >> x;
    	val[p] += x;
    }
    dfs(1,1);
    FOR(i,1,n+1)cout << val[i] << " ";
    return 0;
}
//*->for large size of matrix take int not long long if possible......
//*->always take maximum as inf for safer side ...   

Measured memory_bytes: 24320
#include <iostream>
#include <cstdio>
#define EMPTY -1
using namespace std;

int main()
{
  int h;
  for(;;){
    scanf("%d",&h);
    if(h==0)return 0;
    int map[h][5];
    //????????????????????????
    for(int i=0;i<h;i++){for(int j=0;j<5;j++){scanf("%d",&map[i][j]);}}
    bool next = true;    //???????¶????????????£?????´???false??¨??????for???????????????
    int point = 0;   //????¨????????????????
    for(;;){
      if(!next)break;
      next = false;
      //???????¨????????????????
      for(int i=0;i<h;i++){  //???????????????????????????????????????(i)
	for(int j = 0;j<5;j++){  //??????????§???°???(j)
	  if(map[i][j]==EMPTY)continue;
	  int count = 1;  //??£?¶??????????????????°(count)
	  int k;  //????????°???(k)
	  for(k=j+1;k<5;k++){
	    if(k>=5)break;
	    if(map[i][j]!=map[i][k])break;
	    count++;
	  }
	  if(count>=3){   //??£?¶???????????????´???
	    next = true;    //?¶????????????????????????????for??????????????????
	    point+=map[i][j]*count;  //????????????
	    for(int l=0;l<count;l++){ //????????????
	      map[i][j+l]=EMPTY;
	    }
	    count=1;
	  }
	}
      }
      //????????????
      for(int i=0;i<5;i++){  //???????????????????????????????????????(i,0-5)
	for(int j=h-1;j>=0;j--){  //??\?????????????§???°???(j,(h-1)-0)
	  if(map[j][i]!=EMPTY)continue;
	  for(int k=(j-1);k>=0;k--){  //????§???°???????????????????¨?
	    if(k<0)break;
	    if(map[k][i]!=EMPTY){  //?????????????????£??????????§???°?????¨??\?????????
	      map[j][i]=map[k][i];
	      map[k][i]=EMPTY;
	      break;
	    }
	  }
	}
      } 
    }
    printf("%d\n",point);
  }
}

Measured memory_bytes: 1188
import java.util.*;
import java.util.stream.Collectors;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        sc.nextLine();
        Map wordMap = new HashMap<String, Integer>();
        for (int i = 0; i < n; i++) {
            String s = sc.nextLine();
            if (wordMap.get(s) == null) {
                wordMap.put(s, 1);
            } else {
                wordMap.put(s, (int)wordMap.get(s) + 1);
            }
        }
        List<Map.Entry<String, Integer>> entryList = new ArrayList(wordMap.entrySet());
        // Mapを降順にする
        List<Map.Entry<String, Integer>> sortedEntryList = entryList.stream().sorted(new Comparator<Map.Entry<String, Integer>>() {
            @Override
            public int compare(Map.Entry<String, Integer> e1, Map.Entry<String, Integer> e2) {
                return e2.getValue().compareTo(e1.getValue());
            }
        }).collect(Collectors.toList());
        int maxCount = sortedEntryList.get(0).getValue();
        List<String> resultList = new ArrayList();
        for(Map.Entry<String, Integer> entry : sortedEntryList) {
            if (entry.getValue() == maxCount) {
                resultList.add(entry.getKey());
            } else {
                break;
            }
        }
        resultList.stream().sorted().forEach(r ->
            System.out.println(r)
        );
    }
}

Measured memory_bytes: 85972
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void)
{
  int n,c = 0;
  cin >> n;
  if(0 < n && n < 10) c = n;
  if(10 <= n && n < 100) c = 9;
  if(100 <= n && n < 1000) c = 9 + n - 99;
  if(1000 <= n && n < 10000) c = 909;
  if(10000 <= n && n < 100000) c = 909 + n - 9999;
  if(100000 <= n && n < 1000000) c = 90909;
  cout << c << endl;
  return 0;
}



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

Alist = list(map(int, input().split()))

left = 0
right = max(Alist)

while right - left > 1:
    mid = (left + right) // 2
    
    cnt = 0
    for A in Alist:
        if A % mid == 0:
            cnt += (A // mid) - 1
        else:
            cnt += (A // mid)
    
    if cnt <= K:
        right = mid
    else:
        left = mid

print(right)

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

int main(){
    int n;
    cin >> n;
    int a[100] = {0};
    int b[100];
    int c[100];
    for (int i = 1; i <= n; i++){
        cin >> a[i];
    }
    for (int i = 1; i <= n; i++){
        cin >> b[i];
    }
    for (int i = 1; i <= n-1; i++){
        cin >> c[i];
    }

    ll s = 0;
    for (int i = 1; i <= n; i++){
        s += b[a[i]];
    }
    
    for (int i = 1; i <= n-1; i++){
        if (a[i+1] == a[i]+1) {
            // cout << "y";
            s += c[a[i]];
        }

    }
    cout << s << "\n";
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string s;
int len;
bool a;
int main()
{
	a=false;
	cin>>s;
	len=s.length();
	for(int i=0;i<len;++i)
	{
		if(s[i]=='C')
			a=true;
		if(a&&s[i]=='F')
		{
			printf("Yes");
			return 0;
		}
	}
	printf("No");
	return 0;
} 

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <stack>
#include <map> 
#include <set>
#include <string>
#include <functional>
#include <list>
#include <random>
#include <time.h>
#include <iomanip>
#include <assert.h>
#include <numeric>
#include <new>
#define BIT(nr) (1ULL << (nr))
#define int long long
//#define ll long long
#define double long double
#define mod 1000000007
#define MAXN (int)1e+5 * 2+1
#define LL_MAX 9223372036854775807	//ない環境用
#define LL_HALFMAX 9223372036854775807 / 2	//ない環境用
#define MIN -(9223372036854775807 / 2)
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define mp make_pair
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }


using namespace std;

int cumM[2000000];
int cumC[2000000];
int N, Q;
string S;

int solve(int k) {
    int ans = 0;
    int left = -1, right = -1;
    REPS(i, N) {
        if (S[i] == 'D') {
            left = i;
            break;
        }
    }
    //Dがない
    if (left == -1) {
        return 0;
    }
    //しゃくとり
    int calcSum = 0;
    right = left + 1;
    while (left <= N) {
        while (right <= N && right - left < k) {
            //Cが見つかったらleft のD, right のCでつくれるDMCを加算
            if (S[right] == 'C') {
                calcSum += cumM[right] - cumM[left - 1];
            }
            right++;
        }

        ans += calcSum;

        //left を動かす
        int oldLeft = left;
        left++;
        while (left <= N && S[left] != 'D') {
            //Mが見つかったらoldLeftのD、rightまでにあるC でつくれるDMCを減算(rightは条件を満たすright + 1になっていることに注意)
            if (S[left] == 'M') {
                calcSum -= cumC[right-1] - cumC[left - 1];
            }
            left++;
        }
    }
    return ans;

}

signed main() {
    cin >> N >> S >> Q;
    S = "*" + S + "*";
    vector<int> querys(Q);
    rep(i, Q) {
        cin >> querys[i];
    }
    int mCou = 0;
    int cCou = 0;

    //累積和
    REPS(i, N+1) {
        if (S[i] == 'M') {
            mCou++;
        }
        if (S[i] == 'C') {
            cCou++;
        }
        cumC[i] = cCou;
        cumM[i] = mCou;
    }

    for (int i : querys) {
        cout << solve(i) << "\n";
    }


    return 0;
}


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

#ifdef NON_SUBMIT
#define TEST(n) (n)
#define tout cerr
#else
#define TEST(n) ((void)0)
#define tout cin
#endif

using namespace std;

vector<int> A(1), T;
bitset<5000> D[5001], D2;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt","r",stdin));
	TEST(freopen("output.txt","w",stdout));
	TEST(freopen("debug.txt","w",stderr));
	int N, K, ans=0;
	cin>>N>>K;
	for(int i=0;i<N;i++) {
		int a;
		cin>>a;
		if(a<K) A.push_back(a);
	}
	ans=N=A.size(); ans--;
	D[0][0]=D2[0]=1;
	for(int i=1;i<N;i++) D[i]=D[i-1]|(D[i-1]<<A[i]);
	for(int i=N-1;i>0;i--) {
		int k;
		T.clear();
		for(int j=0;j<K;j++) if(D[i-1][j]) T.push_back(j);
		k=T.size()-1;
		for(int j=0;j<K;j++) if(D2[j]) {
			while(k && j+T[k]>=K) k--;
			if(j+T[k]+A[i]>=K) {
				ans--;
				break;
			}
		}
		D2|=D2<<A[i];
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 6696
#include<bits/stdc++.h>
using namespace std;
long long read()
{
	char ch=getchar();long long x=0,ff=1;
	while(ch<'0'||ch>'9') {if(ch=='-') ff=-1;ch=getchar();}
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return x*ff;
}
void write(long long aa)
{
	if(aa<0) putchar('-'),aa=-aa;
	if(aa>9) write(aa/10);
	putchar('0'+aa%10);
	return;
}
const long long mod=1e9+7;
long long n,m;
long long X[100005];
struct node
{
	long long a[3][3];
}A,B,C,ans;
node operator *(node aa,node bb)
{
	for(long long i=0;i<3;++i) for(long long j=0;j<3;++j) 
	{
		C.a[i][j]=0;
		for(long long k=0;k<3;++k)
		(C.a[i][j]+=aa.a[i][k]*bb.a[k][j]%mod)%=mod;
	}
	return C;
}
void ksm(node aa,long long bb)
{
	while(bb)
	{
		if(bb&1) ans=ans*aa;
		bb>>=1;aa=aa*aa;
	}
	return;
}
int main()
{
	n=read(),m=read();
	ans.a[0][0]=ans.a[1][1]=ans.a[2][2]=1;
	A.a[0][0]=A.a[1][0]=A.a[2][0]=A.a[1][1]=A.a[0][2]=A.a[1][2]=1;
	A.a[2][1]=A.a[2][2]=2;
	B=A;B.a[0][2]=B.a[1][2]=0;B.a[2][2]=1;
	for(long long i=1;i<=m;++i)
	{
		X[i]=read();
		ksm(A,X[i]-X[i-1]-1);
		ans=ans*B;
	}
	ksm(A,n-X[m]-1);
	write((ans.a[2][0]+ans.a[2][1]+ans.a[2][2])%mod);
	return 0;
}

Measured memory_bytes: 1024
#入力
N = int(input())
B = list(map(int,input().split()))
A = [None for _ in range(N)]
#A最初の要素は最大でB最初の要素の値しかとれない
A[0] = B[0]
#中間に関してはAで大きい要素値を取ってしまうと2つのBに影響が出てしまう。
#よって隣り合ううち小さい方を取る
for i in range(1,N-1):
  A[i] = min(B[i-1],B[i])
#A最後の要素は最大でB最後の要素の値しか取れない
A[N-1] = B[N-2]
#結果
print(sum(A))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n,i,k,t,m,a[200001],b[200001],c[200001],ans[200001];
double d[200001];
int main(){
	scanf("%lld",&n);
	for(i=1;i<=n;i++)scanf("%lld",&a[i]);
	for(i=1;i<=n;i++)b[i]=ans[i]=i;
	scanf("%lld%lld",&m,&k);
	for(i=1;i<=m;i++){
		scanf("%lld",&t);
		swap(b[t],b[t+1]);
	}
	while(k){
		//prllf("%d\n",k);
		if(k&1){
			for(i=1;i<=n;i++)c[i]=ans[b[i]];
			for(i=1;i<=n;i++)ans[i]=c[i];
		}
		for(i=1;i<=n;i++)c[i]=b[b[i]];
		for(i=1;i<=n;i++)b[i]=c[i];
		k/=2;
	}
	for(i=1;i<=n;i++)d[i]=a[ans[i]]-a[ans[i]-1];
	for(i=1;i<=n;i++)printf("%.1lf\n",d[i]+=d[i-1]);
}

Measured memory_bytes: 7552
def main():
    S = input()
    odd_list=['R', 'U', 'D']
    eve_list=['L', 'U', 'D']
    odd = S[0::2]
    eve = S[1::2]
    for i in odd:
        if i not in odd_list:
            print('No')
            return
    for i in eve:
        if i not in eve_list:
            print('No')
            return
    print('Yes')

main()

Measured memory_bytes: 9056
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                   \
  ifstream in("atcoder-problems/abc141_a.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v) \
rep(l, v.size()) { cout << v[l] << " "; } \
cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18+100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  string S;
  cin >> S;

  string s = "Sunny", c = "Cloudy", r = "Rainy";
  string ans;
  if (S == s) {
    ans = c;
  } else if (S == c) {
    ans = r;
  } else {
    ans = s;
  }

  cout << ans << endl;
}

Measured memory_bytes: 3620
N,M=map(int,input().split())

L=0
R=N
for i in range(M):
    l,r=map(int,input().split())
    if l>L:
        L=l
    if r<R:
        R=r
if (R-L)>=0:
    print(R-L+1)
else:
    print(0)


Measured memory_bytes: 45288
#include <stdio.h>
int main(){
    char a[100],b[100],c[100];
    scanf("%s %s %s",a,b,c);
    int x,y;
    for(int i=0;i<100;i++){
        if(a[i]== 0){
            x = i;
            break;
        }
    }
    for(int i=0;i<100;i++){
        if(b[i]== 0){
            y = i;
            break;
        }
    }
    if(a[x-1]==b[0]&&b[y-1]==c[0])
        printf("YES\n");
    else
        printf("NO\n");
    return 0;
}


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

int N,K;
int ax[100],ay[100],az[100];
int bx[100],by[100],bz[100];
vector<long long> cx,cy,cz;

int t[100][100][100];
bool visited[100][100][100];

void add(int ax,int ay,int az,int bx,int by,int bz){
  for(int x=ax;x<bx;x++)
    for(int y=ay;y<by;y++)
      for(int z=az;z<bz;z++)
	t[x][y][z]++;
}

long long solve(){
  long long ans=0;
  for(int i=0;i<N;i++)
    add(ax[i],ay[i],az[i],bx[i],by[i],bz[i]);
  for(int x=0;x<(int)cx.size();x++)
    for(int y=0;y<(int)cy.size();y++)
      for(int z=0;z<(int)cz.size();z++)
	if(t[x][y][z]>=K)
	  ans+=(cx[x+1]-cx[x])*(cy[y+1]-cy[y])*(cz[z+1]-cz[z]);

  return ans;
}

void func(int* A,int* B,vector<long long> &C){
  C.clear();
  map<int,int> m;
  vector<int> v;
  for(int i=0;i<N;i++)v.push_back(A[i]),v.push_back(B[i]);
  sort(v.begin(),v.end());
  for(int i=0;i<2*N;i++){
    if(i&&v[i]==v[i-1])continue;
    m[v[i]]=C.size();
    C.push_back(v[i]);
  }
  for(int i=0;i<N;i++)A[i]=m[A[i]],B[i]=m[B[i]];
}

int main(){
  cin>>N>>K;
  for(int i=0;i<N;i++)
    cin>>ax[i]>>ay[i]>>az[i]>>bx[i]>>by[i]>>bz[i];
  func(ax,bx,cx),func(ay,by,cy),func(az,bz,cz);
  cout<<solve()<<endl;
  return 0;
}

Measured memory_bytes: 4884
import math
def com(n,r):
  return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))
n,k=map(int,input().split())
for i in range(1,k+1):
  if n-k+1<i:
    print(0)
  else:
    print(com(k-1,i-1)*com(n-k+1,i)%(10**9+7))

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

const int N = 101;
const int W = 10001;

int dp[N][W];
int weight[N];
int value[N];

int f(int i, int j)
{
    if (i <= 0 || j <= 0) return 0;
    if (dp[i][j] != -1) return dp[i][j];

    int a = max(f(i-1, j), f(i, j-1));
    if (j < weight[i-1]) return dp[i][j] = a;
    return dp[i][j] = max(a, f(i-1, j-weight[i-1]) + value[i-1]);
}

int main()
{
    fill(&dp[0][0], &dp[N-1][W], -1);
    int n, w;
    cin >> n >> w;
    for (int i=0; i < n; ++i) {
        cin >> value[i] >> weight[i];
    }

    cout << f(n, w) << endl;

    return 0;
}

Measured memory_bytes: 7528
#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(-1);
typedef long long ll;
typedef pair<int64_t,int64_t> pll;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
#define INF (2147483647)
#define mod (1000000007)
#define limit (7368791)
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define ALL(a) begin(a),end(a)
#define sz(s) (s).size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second

void solve()
{
    int n,m;
    cin>>n>>m;n++;
    vector<bool>a(n,0);
    REP(i,m){int x;cin>>x;a[x]=1;}
    vector<int>s(n,0);s[0]=1;if(a[1])s[1]=0;else s[1]=1;
    rep(i,2,n)
    {
        if(!a[i])s[i]=s[i-1]+s[i-2];
        s[i]%=mod;
    }
    cout<<s[n-1]<<endl;
}

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

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

#define pb push_back
#define fr first
#define sc second
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<int,pii> pip; 
const int INF = (1<<25);
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

int n, r, k, t;
int net[100][100];

void warshall_floyd() {
  for(int i=0; i<n; i++) {
    for(int j=0; j<n; j++) {
      for(int k=0; k<n; k++) {
	net[j][k] = min(net[j][k], net[j][i] + net[i][k]);
      }
    }
  }
}

int main() {

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

  for(int i=0; i<n; i++) {
    cin>> r>> k;  
    r--;
    for(int j=0; j<k; j++) {
      cin>> t;  
      t--;
      net[r][t] = 1;
    }
  }

  warshall_floyd();

  int p;
  cin>> p;
  for(int i=0; i<p; i++) {
    int s, d, v;
    cin>> s>> d>> v;
    s--; d--;
    if(net[s][d]+1>v) cout<< "NA"<< endl;
    else cout<< net[s][d]+1<< endl;
  }

}

Measured memory_bytes: 1200
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Queue;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		if (n == 0) {
			System.out.println(0);
			return;
		}
		Deque<Integer> q = new ArrayDeque<Integer>();
		StringBuilder st = new StringBuilder();
		while (true) {
			if (n == 0) {
				q.push(n%-2);
				break;
			}
			if (n%-2 < 0) {
				if (n%-2 == 0) {
					st.append('0');
				} else {
					st.append('1');
				}
				n = (n/-2)+1;
			} else {
				if (n%-2 == 0) {
					st.append('0');
				} else {
					st.append('1');
				}
				n /= -2;
			}
		}
		System.out.print(st.reverse());
	}
}


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

int main() {
  int N;
  cin >> N;
  map<int, int> ns;
  int a;
  int over8 = 0;
  for(int i = 0; i < N; ++i) {
    cin >> a;
    auto idx = a / 400;
    if(idx < 8) {
      ns[idx]++;
    } else {
      over8++;
    }
  }
  auto minv = ns.size() > 0 ? ns.size() : 1;
  auto maxv = ns.size() + over8;
  cout << minv << " " << maxv << endl;
  return 0;
}

Measured memory_bytes: 384
#include <stdio.h>

int searchII(int *S, int t, int min, int max){
    int mid;
    while (min < max) {
        mid = (min + max) / 2;
        if (S[mid] == t) return 1;
        t > S[mid] ? (min = mid + 1) : (max = mid);
    }
    return 0;
}

int main(){
    int n, q, S[1000000], T[50000], i, j, c = 0;
    scanf("%d", &n);
    for (i = 0;i < n;i++) scanf("%d", S + i);
    scanf("%d", &q);
    for (i = 0;i < q;i++) scanf("%d", T + i);
    for (i = 0;i < q;i++)
        c += searchII(S, T[i], 0, n);
    printf("%d\n", c);
    return 0;
}

Measured memory_bytes: 1188
#include <iostream>
using namespace std;
int main(){
	int x,y;
	cin >> x >> y;
	bool flag = false;
	for (int i = x; i>=0; i--){
		if ((i*2+(x-i)*4)==y)
			flag = true;
	}
	if (flag) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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

public class Solution
{
    public static void Main()
    {
        var s = Console.ReadLine();

        var cur = "";
        int k = 0;
        for (int i = 0; i < s.Length;)
        {
            var next = "" + s[i++];
            while(next == cur && i < s.Length)
            {
                next += s[i++];
            }
            if(next != cur)
            {
                k++;
                cur = next;
            }
        }

        Console.WriteLine(k);
    }
}

Measured memory_bytes: 17328
N = int(input())
t = [0] * (N+1)
x = [0] * (N+1)
y = [0] * (N+1)
t[0] = x[0] = y[0] = 0
for i in range(1,N+1):
  t[i],x[i],y[i] = map(int,input().split())
flag = True
for i in range(1,N+1):
  temp = (t[i]-t[i-1]) - (abs(x[i]-x[i-1]) + abs(y[i]-y[i-1]))
  if temp < 0 or temp % 2 == 1:
    print("No")
    flag = False
    break
if flag:
  print("Yes")

Measured memory_bytes: 11636
#include <iostream>
#include<math.h>
using namespace std;
typedef long long int ll;

int main(void){
    ll n;
    cin>>n;
    ll h[n],dp[n];
    for(int i=0;i<n;i++){
        cin>>h[i];
    }
    dp[0]=0;
    for(int i=1;i<n;i++){
        if(i==1)dp[i]=abs(h[1]-h[0]);
        else{
            dp[i]=fmin(dp[i-1]+abs(h[i-1]-h[i]),dp[i-2]+abs(h[i-2]-h[i]));
        }
    }

    cout<<dp[n-1]<<endl;

}

Measured memory_bytes: 1792