akhauriyash/Code-Regression huggingface dataset:
N = int(input())
red = [list(map(int, input().split())) for i in range(N)]
blue = [list(map(int, input().split())) for i in range(N)]

red.sort(key=lambda x:x[1], reverse=True)
blue.sort()

c = 0
for bx, by in blue:
    for i, (rx, ry) in enumerate(red):
        if rx<bx and ry<by:
            c += 1
            red.pop(i)
            break

print(c)

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

int main() {
    const double PI = acos(-1.0);
    double a, b, x;
    cin >> a >> b >> x;
    x /= a;
    cout << fixed << setprecision(10);
    if (x > a*b/2) cout << atan2((a*b-x)*2, a*a) * 180 / PI << endl;
    else cout << atan2(b*b, x*2) * 180 / PI << endl;
}

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

#define MAX 100
static const int WHITE = 0; // not visit
static const int GRAY = 1; // visited
static const int BLACK = 2; // searched

int n;
int M[MAX][MAX] = { 0 };
int color[MAX] = { WHITE };
int d[MAX], f[MAX], tt = 0;
int nt[MAX] = { 0 };

// get vertex next u
int next(int u) {
	for (int v = nt[u]; v < n; v++) {
		nt[u] = v + 1;
		if (M[u][v]) return v;
	}
	return -1;
}

void dfs_visit(int r) {
	for (int i = 0; i < n; i++) nt[i] = 0;
	stack<int> S;
	S.push(r);
	color[r] = GRAY;
	d[r] = ++tt;

	while (!S.empty()) {
		int u = S.top();
		int v = next(u);
		if (v != -1) {
			if (color[v] == WHITE) {
				color[v] = GRAY;
				d[v] = ++tt;
				S.push(v);
			}
		}
		else {
			S.pop();
			color[u] = BLACK;
			f[u] = ++tt;
		}
	}
}

void dfs() {
	for (int u = 0; u < n; u++) {
		if (color[u] == WHITE)  dfs_visit(u);
	}
	for (int i = 0; i < n; i++) {
		cout << i + 1 << " " << d[i] << " " << f[i] << endl;
	}
	return;
}

int main() {
	cin >> n;

	for (int i = 0; i < n; i++) {
		int k, u;
		cin >> u >> k;
		u--;
		for (int j = 0; j < k; j++) {
			int v;
			cin >> v;
			v--;
			M[u][v] = 1;
		}
	}

	dfs();
	return 0;

}

Measured memory_bytes: 3112
using System;
//using System.Collections.Generic;

public class Arai {
  public static void Main(string[] args) {
    string[] str1 = Console.ReadLine().Split();
    var h = int.Parse(str1[0]);
    var n = int.Parse(str1[1]);
    var sum = 0;
    
    string[] str2 = Console.ReadLine().Split();
    //var list = new List<int>();
    for (var i = 0; i < n; i++) {
      sum += int.Parse(str2[i]);
      if (h - sum <= 0) {
        Console.WriteLine("Yes");
        return ;
      }
    }
    
    Console.WriteLine("No");
  }
}

Measured memory_bytes: 18016
#include<bits/stdc++.h>
#define int long long
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(a) a.size()
#define re return 
#define MP make_pair
#define pb push_back
#define pii pair<int,int>
#define se second
#define fi first
using namespace std;
int cnt[26];
signed main(){
	ios_base::sync_with_stdio(0);
	string s;
	cin>>s;
	for(int i=0;i<sz(s);i++) cnt[s[i]-'A']++;
	int tmp=0;
	for(int i=0;i<26;i++) if(cnt[i]==2) tmp++;
	cout<<(tmp==2?"Yes":"No");
	re 0;
}

Measured memory_bytes: 3620
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

const int dx[8] = { 1,1,0,-1,-1,-1,0,1 };
const int dy[8] = { 0,1,1,1,0,-1,-1,-1 };


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a, b, c, x;
	cin >> a >> b >> c >> x;
	int cnt = 0;
	REP(i, a + 1) {
		REP(j, b + 1) {
			REP(k, c + 1) {
				if (i * 500 + j * 100 + k * 50 == x)cnt++;
			}
		}
	}
	cout << cnt << endl;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;
int n, a, x[60];

long long int dp[55][5005];

void solve(){
    long long int ans=0;
    for(int i=0;i<5001;i++){
        dp[0][i] = 0;
    }
    dp[0][2500+x[0]] += 1;
    for(int i=1;i<n;i++){
        dp[i][2500+x[i]] += 1;
        for(int j=0;j<=5000;j++){
            dp[i][j] += dp[i-1][j];
            if(dp[i-1][j]!=0){
                dp[i][j+x[i]] += dp[i-1][j];
            }            
        }
    }
    cout << dp[n-1][2500] << endl;
}

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

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int n , pos[N] , m;
long long K;

vector<int> multi(const vector<int> &A , const vector<int> &B) {
    vector<int> C = A;
    for (int i = 0 ; i < n ; ++ i) {
        C[i] = B[A[i]];
    }
    return C;
}

int main() {
    scanf("%d" , &n);
    for (int i = 0 ; i < n ; ++ i) {
        scanf("%d" , &pos[i]);
    }
    for (int i = n - 1 ; i > 0 ; -- i) {
        pos[i] -= pos[i - 1];
    }
    scanf("%d%lld" , &m , &K);
    vector<int> P(n) , I(n);
    for (int i = 0 ; i < n ; ++ i) {
        P[i] = I[i] = i;
    }
    //cout << 233 << endl;
    for (int i = 0 ; i < m ; ++ i) {
        int x;
        scanf("%d" , &x);
        -- x;
        swap(P[x] , P[x + 1]);
    }
    while (K) {
        if (K & 1) {
            I = multi(I , P);
        }
        P = multi(P , P);
        K >>= 1;
    }
    long long p = 0;
    for (int i = 0 ; i < n ; ++ i) {
        p += pos[I[i]];
        printf("%lld\n" , p);
    }
}


Measured memory_bytes: 2792
#include<bits/stdc++.h>
#define ll long long
#define dl double
#define ull unsigned long long
#define eps (1e-6)
using namespace std;
const int N = 1e3+7;
struct node
{
    ll x;
    ll y;
    ll z;
};
node s[N], cnt[N];
bool cmp(node a, node b)
{
    return a.x+a.y+a.z > b.x+b.y+b.z;
}
int main()
{
    int n, m;
    ll ans = 0;
    scanf("%d%d", &n, &m);
    for(int i = 1; i <= n; i++)
    {
        scanf("%lld%lld%lld", &s[i].x, &s[i].y, &s[i].z);
    }
    for(int i = 0; i < 8; i++)
    {
        for(int j = 1; j <= n; j++)
        {
            cnt[j].x = s[j].x*((i&1)>0?1:(-1));
            cnt[j].y = s[j].y*((i&2)>0?1:(-1));
            cnt[j].z = s[j].z*((i&4)>0?1:(-1));
        }
        ll tmp = 0;
        sort(cnt+1, cnt+1+n, cmp);
        for(int j = 1; j <= m; j++)
        {
            tmp += cnt[j].x+cnt[j].y+cnt[j].z;
        }
        ans = max(ans, tmp);
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 256
<?php
  $a1 = explode(' ', trim(fgets(STDIN)));
  $h = explode(' ', trim(fgets(STDIN)));
  $n = $a1[0];
  $k = $a1[1];
  $ans = 0;
  foreach ($h as $num) {
    if ($num >= $k) {
      $ans++;
    }
  }
echo $ans . PHP_EOL;


Measured memory_bytes: 12792
#include<iostream>
#include<cmath>
#include<queue>
#include<algorithm>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
#define NODE 30
#define LIM 31
const double inf = 1e200;

class state{
public:
  int cur,prev,speed;
  double c;
  state(){};
  state(int tcur,int tprev,int tspeed,double tc):cur(tcur),prev(tprev),
						 speed(tspeed),c(tc){};
  bool operator<(const state & a)const{
    return c >a.c;
  }
};

double cost[30][30][31];
double dist[30][30];
int lim[30][30];
bool visited[30][30][31];

void solve(int n,int s,int g){
  rep(i,n)rep(j,n)rep(k,31)cost[i][j][k]=inf,visited[i][j][k]=false;
  priority_queue<state> Q;
  cost[0][0][1]=0;
  rep(i,n){
    if ( lim[s][i] >= 1){
      cost[i][s][1]=dist[s][i];
      Q.push(state(i,s,1,cost[i][s][1]));
    }
  }

  while(!Q.empty()){
    state now = Q.top();
    Q.pop();
    if ( visited[now.cur][now.prev][now.speed])continue;
    visited[now.cur][now.prev][now.speed]=true;
    if ( now.cur == g && now.speed == 1){
      printf("%.3lf\n",now.c);
      return;
    }
    rep(i,n){
      if ( i == now.prev || i == now.cur)continue;
      REP(j,-1,2){
	if ( now.speed + j > 0 && now.speed + j <= lim[now.cur][i] &&
	     cost[i][now.cur][now.speed+j] - now.c - dist[now.cur][i]/(now.speed+j) >0){
	  cost[i][now.cur][now.speed+j]=now.c+dist[now.cur][i]/(now.speed+j);
	  Q.push(state(i,now.cur,now.speed+j,cost[i][now.cur][now.speed+j]));
	}
      }
    }
  }

  puts("unreachable");
}


main(){
  int n,m;
  while(cin>>n>>m && n){
    rep(i,n)rep(j,n)lim[i][j]=0,dist[i][j]=inf;
    int s,g;
    cin>>s>>g;
    s--;g--;
    rep(i,m){
      int f,t,v;
      double d;
      cin>>f>>t>>d>>v;
      f--;t--;
      dist[f][t]=dist[t][f]=d;
      lim[f][t]=lim[t][f]=v;
    }
    solve(n,s,g);
  }
}

Measured memory_bytes: 2428
import java.io.BufferedReader;
import java.io.*;
import java.util.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Collections;
public class Main {
	public static void main(final String[] args){
    
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    //List<String> list = new ArrayList<>();
    String s = sc.next();
    
    char[] work = new char[n];

    for(int i = 0; i < n; i++){
            work[i] = s.charAt(i);
    
            }
    int count = 1;
    for(int i = 0; i < n-1; i++){
        if(work[i] != work[i+1]){
            count++;
        }
    }
    
    System.out.println(count);
    

    }
}

Measured memory_bytes: 25448
import java.util.*;
import java.util.Collections;
import java.util.ArrayList;

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

        int N = sc.nextInt();
        int lsum = 0;
        ArrayList<Integer> list = new ArrayList<Integer>();

        for(int i=0; i<N; i++){
            list.add(sc.nextInt());
        }

        Collections.sort(list);

        for(int i=0; i<N-1; i++){
            lsum += list.get(i);
        }
        if(lsum>list.get(N-1)){
            System.out.println("Yes");
        }
        else if(lsum<=list.get(N-1)){
            System.out.println("No");
        }
        
    }
}

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

ll a[55];
ll b[55];
ll l=1,r=1e16+1000;
int n;

int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    ll ans=0;
    sort(a+1,a+1+n,greater<ll>());
    while(a[1]>=n)
    {
        ll t=0;
        t+=a[1]/n;
        a[1]%=n;
        for(int i=2;i<=n;i++)
            a[i]+=t;
        ans+=t;
        sort(a+1,a+1+n,greater<ll>());
    }
    cout<<ans<<endl;
//////////////
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct node{
    int a,num;
}in[300000];
int ans[300000];
bool cmp(node a,node b)
{
    return a.a<b.a;
}
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;++i)
    {
        int x;
        cin>>x;
        in[i].a=x;
        in[i].num=i;
    }
    sort(in+1,in+n+1,cmp);
    for(int i=1;i<=n;++i)
    {
        if(i<(n/2))
            ans[in[i].num]=in[n/2+1].a;
        else if(i==(n/2))
            ans[in[i].num]=in[n/2+1].a;
        else
            ans[in[i].num]=in[n/2].a;
    }
    for(int i=1;i<=n;++i)
        cout<<ans[i]<<endl;
	return 0;
}

Measured memory_bytes: 4480
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <iomanip>

using namespace std;

using ll = long long;
using ld = long double;
using lli = long long int;

#define PI 3.14159265358979323846264338327950L

int main(){
  ld A, B;
  long unsigned int temp;
  cin >> A >> B;
  
  temp = (long unsigned int )A*B;
  cout << temp <<endl;

  return 0;
}

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

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("1 6");
            //2
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("12345 678901");
            //175897
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();
        long[] wkArr = InputList[0].Split(' ').Select(X => long.Parse(X)).ToArray();

        long CurrSCnt = wkArr[0];
        long CurrCCnt = wkArr[1];

        long Answer = 0;

        //戦略1 SとcのペアでSccを作れるだけ作る
        long CanCreateCnt1 = Math.Min(CurrSCnt, CurrCCnt / 2);
        CurrSCnt -= CanCreateCnt1;
        CurrCCnt -= CanCreateCnt1 * 2;

        //戦略2 残ったcでSccを作れるだけ作る
        long CanCreateCnt2 = CurrCCnt / 4;

        Console.WriteLine(CanCreateCnt1 + CanCreateCnt2);
    }
}


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

//#include "atcoder.hpp"

int main() {
    int N, H, W, r = 0;
    vector<int> A, B;
    string S;
    
    cin >> N >> H >> W;

    for (int i=0;i<N;i++){
        int tmp;
        
        cin >> tmp;
        A.push_back(tmp);
        cin >> tmp;
        B.push_back(tmp);
        
        if (A.back() >= H && B.back() >= W)
            r++;
    }
    

    cout << r << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <stack>
#include <cassert>
#include <string>
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;
using ld = long double;

#define st first
#define nd second

const int MAXN = 1e6 + 5, inf = 1e9;
const ll INF = 1e18;
const ld PI = 3.1415926535897932384626433832795;

int deg[MAXN];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout << setprecision(13) << fixed;

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

    int n = 4;
    for (int i = 1; i < n; i++) {
        int a, b;
        cin >> a >> b;
        deg[a]++, deg[b]++;
    }

    int ctr =0;
    for (int i= 1; i<= n; i++) {
        ctr += deg[i] % 2;
    }

    cout << ((ctr == 0 || ctr == 2) ? "YES" : "NO") << "\n";
}


Measured memory_bytes: 256
#include  <bits/stdc++.h>
using namespace std;
static int fast_io = []() { std::ios::sync_with_stdio(false); cin.tie(nullptr); return 0; }();
int main(){
  string input;
  cin>>input;
  for(auto &x:input){
    if(x==','){
      x=' ';
    }
  }
  cout<<input<<"\n";  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <limits.h>
#include <cmath>
#include <time.h>
#include <functional>
#include <cstdio>
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define MOD1 1000000007;
#define MOD2 1000007
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
/* ここからが本編 */
/*  */
int dic[20000000];
ull pow(ull x,ull n) {
  ull res = 1;
  while(n > 0) {
    if(n&1) res = res * x;
    x = x * x;
    n >>= 1;
  }
  return res;
}
int dic_op(char str[14],int& key)
{
  int j;
  int f = 1;
  int g = 0;
  for(j = 0;j<10;j++) {
    if(str[j] == 'A')
      g += f * 1;
    else if(str[j] == 'C')
      g += f * 2;
    else if(str[j] == 'G')
      g += f * 3;
    else if(str[j] == 'T')
      g += f * 4;
    else break;
    f *= 5;
  }
  key = 0;
  if(j == 10) {
    f = 1;
    for(;j<10;j++) {
      if(str[j] == 'A')
        key += f * 1;
      else if(str[j] == 'C')
        key += f * 2;
      else if(str[j] == 'G')
        key += f * 3;
      else if(str[j] == 'T')
        key += f * 4;
      else break;
        f *= 5;
    }
  }
  return g;
}
int main()
{
  int i,j,k,l;
  long n;
  long ans = 0;
  char opstr[7];
  char str[13];
  int key;
  int a = 1;
  cin >> n;
  for (i = 0; i < n; i++) {
    scanf("%s %s",opstr,str);
    if(opstr[0] == 'i') {
      int tmp = dic_op(str,key);
      if( (dic[tmp] >> key) % 2 == 0) {
        dic[tmp] += 1 << key;
      }
    }
    else if(opstr[0] == 'f') {
      int tmp = dic_op(str,key);
      /*
      printf("tmp = %d\n",tmp);
      printf("key = %d\n",key);
      printf("dic[tmp] = %d\n",dic[tmp]);
      */
      if( (dic[tmp] >> key) % 2 == 1) {
        puts("yes");
      }
      else {
        puts("no");
      }
    }
  }
  return 0;
}

Measured memory_bytes: 39168
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=100050;
//ここまでテンプレ
int R,C;
bool is_shu(int x,int y){
	return (x==0 || y==0 || x==C || y==R);
}
int main(){
	cin>>C>>R;
	int N;
	cin>>N;
	set<tint> tes;
	for(int i=0;i<N;i++){
		int x[2],y[2];
		cin>>x[0]>>y[0]>>x[1]>>y[1];
		if(!is_shu(x[0],y[0]) || !is_shu(x[1],y[1]))
			continue;
		for(int j=0;j<2;j++){
			if(x[j]==0)
				tes.insert(mt(0,y[j],i));
			else if(y[j]==R)
				tes.insert(mt(1,x[j],i));
			else if(x[j]==C)
				tes.insert(mt(2,-y[j],i));
			else if(y[j]==0)
				tes.insert(mt(3,-x[j],i));
		}
	}
	stack<int> sta;
	for(tint T:tes){
		int a,b,c;
		tie(a,b,c)=T;
		if(sta.size()==0)
			sta.push(c);
		else if(sta.top()==c)
			sta.pop();
		else
			sta.push(c);
		//cout<<c<<" ";
	}
	if(sta.size()<=2)
		cout<<"YES"<<endl;
	else
		cout<<"NO"<<endl;
	return 0;
}

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

using namespace std;
#define int long long
#define rep(i, n) for(int i=0;i<(n);++i)
#define INF (1ll<<60)
#define FI first
#define SE second
#define u_b upper_bound

vector<int> c[26];

signed main() {
    string A;
    cin >> A;
    rep(i, A.size()) {
        c[A[i] - 'a'].push_back(i);
    }
    int ans = 1;
    rep(i, A.size()) {
        int ch = A[i] - 'a';
        int num = c[ch].end() - u_b(c[ch].begin(), c[ch].end(), i);
        ans += A.size() - i - 1 - num;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3444
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    while(1){
        int a;
        cin>>a;
        if(a==0)return 0;
        int total=0;
        int N;
        cin>>N;
        for(int i=0;i<N;i++){
            int A,B;
            cin>>A>>B;
            total+=B-A;
        }
        if(a<=total)puts("OK");
        else cout<<a-total<<endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include <iostream>


using namespace std;

int main() {
    long long N;
    cin >> N;
    
    long long A[N ], B[N];
    for (long long i = 0; i < N; ++i) {
        cin >> A[i] >> B[i];
    }
    
    long long res = 0;
    
    for (long long i = N-1; i > -1; --i) {
      
        long long r = 0;
       
        r = (A[i] + res) % B[i];
        if (r != 0) res += B[i] - r;
    }
    
    cout << res << endl;
}

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

using namespace std;

#define int long long

using ll = long long;
using pii =  pair<int, int>;

const int IINF =  0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const int INF = sizeof(int) == sizeof(long long) ? LINF : IINF;
const ll MOD = 1e9+7;

#define for_(i,a,b) for(int i = (a);i < (b);i++)
#define rfor_(i,a,b) for(int i = (b)-1;i >= (a);i--)

#define rep(i,n) for_(i,0,n)
#define rrep(i,n) rfor_(i,0,n)

#define pb push_back
//#define eb emplace_back
#define mp make_pair
#define ft first
#define sd second

#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define rev(a) reverse(all(a))

#define endl '\n'

const int limit = 100007;

char s[7];
int n;

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

	cin>>s;
	n = strlen(s);
	rep(i, n-1) {
		if(s[i]=='A' && s[i+1]=='C') {
			cout<<"Yes"<<endl;
			return 0;
		}
	}

	cout<<"No"<<endl;

	return 0;
}


Measured memory_bytes: 256
{-# LANGUAGE CPP #-}
#define MOD (1000000007 :: Integer)
import Prelude hiding (mod)

mod :: Integer -> Integer -> Integer
mod x y
  | x >= y    = mod (x - y) y
  | otherwise = x
infixl 7 `mod`

calc' :: String -> Integer
calc' [x] = 3
calc' [x,y] = 6
calc' (x:y:xs)
  | x == y  = 6 * calc (x:y:xs)
  | x /= y  = 3 * calc (x:y:xs)

calc :: String -> Integer 
calc [x,y]
  | x == y = 1
  | x /= y = 2
calc [x,y,z]
  | x == y    = 1
  | y == z    = 2
  | otherwise = 4
calc (x:y:z:w:xs)
  | x == y && z == w  = 3 * calc(z:w:xs)
  | x == y && z /= w  = calc(z:w:xs)
  | x /= y            = 2 * calc(y:z:w:xs)

main :: IO ()
main = do
  getLine
  str <- getLine
  getLine
  putStrLn . show . flip mod MOD . calc' $ str


Measured memory_bytes: 508
#include <queue>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
#include <map>

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef vector<ll> vint;
typedef vector<string> vstr;
typedef pair<ll, ll> pint;
ll inf = (1LL << 50);

//bool operator< (pint a, pint b) {
	//return a.second < b.second;

//}



ll gcd(ll a, ll b) {

	if (b == 0)
		return a;

	return gcd(b, a % b);


}

ll max(ll a, ll b) {
	if (a < b) {
		return b;
	}
	else
		return a;

}

ll min(ll a, ll b) {
	if (a < b)
		return a;

	return b;
}




pint dx[4] = { {1, 0}, {-1, 0}, {0, 1}, {0, -1} };

vector<pint> list;








float t[1000], v[1000], minv[1000];

int main() {
	ll N;

	ll sum_t = 0;
	cin >> N;

	rep(i, N) {
		cin >> t[i + 1];

	}
	rep(i, N)
		cin >> v[i+1];



	for (int i = N+1; i >= 0; i--) {
		
		if (minv[i] > v[i - 1]) {

			minv[i - 1] = v[i - 1];
		}
		else {

			minv[i - 1] = min(v[i - 1], minv[i] + t[i-1]);

		}

	}

	float nowv = 0;
	float sum = 0;
	for(int i = 1; i <= N; i++){


	


		if (minv[i + 1] >= minv[i]) {
			float s = (float)min(t[i], minv[i] - nowv);

			sum += s * (2.0 * nowv + s) / 2.0 + (t[i] - s) * minv[i];

		
			nowv = nowv + s;
		}


		else {
			float vel = (nowv + minv[i+1] + t[i]) / 2;


			if (minv[i + 1] - nowv > t[i]) {

				sum += (nowv + nowv + t[i]) * t[i] / 2;

				nowv = nowv + t[i];
			}
			
			else {

				sum += (vel + nowv) * (vel - nowv) / 2 + (minv[i + 1] + vel) * (t[i] - (vel - nowv)) / 2;


				if (vel > minv[i]) {

					sum -= (vel - minv[i]) * (t[i] - minv[i] + minv[i + 1] - minv[i] + nowv) / 2;
					
				}

				nowv = minv[i + 1];

			}
			

			
		}


	}
	
	
	printf("%f\n", sum);



	return 0;
}

Measured memory_bytes: 256
num = gets.to_i
s = []
h = []
c = []
d = []

def look_for_lost(kind, a)
  a = a.sort
  for i in 1..13 do
    flag = false
    a.each do |x|
      if x == i then flag = true end
    end
    if flag == false then puts "#{kind} #{i}" end
  end
end

for i in 1..num do
  card = gets.chomp
  case card.split(" ")[0]
  when "S" then
    s << card.split(" ")[1].to_i
  when "H" then
    h << card.split(" ")[1].to_i
  when "C" then
    c << card.split(" ")[1].to_i
  when "D" then
    d << card.split(" ")[1].to_i
  end
end

look_for_lost("S", s)
look_for_lost("H", h)
look_for_lost("C", c)
look_for_lost("D", d)

Measured memory_bytes: 6108
#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx2")

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#define NMAX 200001

int a[NMAX], up[NMAX], bt[NMAX];
int imos[NMAX];

void reset(int n) {
    for(int i = 0; i < n; i++) imos[i] = 0;
}

int get_int() {
    int res = 0;
    char c = getchar();
    while(c != EOF && c != ' ' && c != '\n') {
        res *= 10;
        res += c - '0';
        c = getchar();
    }
    return res;
}

void put_int(int n) {
    char c[30];
    int sz = 0;
    c[sz++] = (n % 10) + '0';
    n /= 10;
    while(n > 0) {
        c[sz++] = (n % 10) + '0';
        n /= 10;
    }
    for(int i = sz-1; i >= 0; i--) {
        putchar(c[i]);
    }
    putchar('\n');
}

int max(int a, int b) { 
    if(a > b) return a;
    else return b;
}

int min(int a, int b) { 
    if(a < b) return a;
    else return b;
}

int main(){

    int n, k;
    n = get_int();
    k = get_int();
    for(int i = 0; i < n; i++) a[i] = get_int();

    for(int itr = 0; itr < k; itr++) {
        reset(n+1);
        for(int i = 0; i < n; i++) {
            if(i > a[i]) bt[i] = i - a[i];
            else bt[i] = 0;
            if(n < i + a[i] + 1) up[i] = n;
            else up[i] = i + a[i] + 1;
        }
        for(int i = 0; i < n; i++){
            imos[bt[i]]++;
            imos[up[i]]--;
        }
        int acc = 0;
        for(int i = 0; i < n; i++){
            acc += imos[i];
            a[i] = acc;
        }
        int sum = 0;
        for(int i = 0; i < n; i++) sum += a[i];
        if(sum == n * n) break;
    }

    for(int i = 0; i < n; i++) put_int(a[i]);
    return 0;
}


Measured memory_bytes: 4848
import java.util.*;
import java.io.*;

public class Main {

 public static void main(String[] args) {
     
    Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
    int M = in.nextInt(); // Scanner has functions to read ints, longs, strings, chars, etc.
    int N = in.nextInt();
    int[] A = new int[M];
    long sum = 0;
    for(int i = 0; i < N; i++) {
        sum += in.nextInt();
    }
    
    if(sum > M) {
        System.out.println(-1);
    }
    else {
        System.out.println(M-sum);
    }
    
    
  }
  
}

Measured memory_bytes: 50208
#include <cstdio>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <climits>

using namespace std;

int main(void)
{
    int n,m;

    cin >>n >>m;

    int maxL = 0;
    int minR = INT_MAX;
    for(int i = 0; i < m; i++){
        int l,r;
        cin >>l >>r;
        minR = min(minR, r);
        maxL = max(maxL, l);
    }

    if(minR - maxL < 0){
        printf("0\n");
    }else{
        printf("%d\n", minR - maxL+1);
    }

    return 0;
}

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

int main()
{
	char ch;
	while (1) {
		scanf("%c", &ch);
		if (isalpha(ch)) {
			if (islower(ch)) printf("%c", toupper(ch));
			else printf("%c", tolower(ch));
		
	} else printf("%c", ch);
	if (ch == '\n') break;

}
return 0;
}

Measured memory_bytes: 2600
#include <bits/stdc++.h>
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nyan "(=^･ω･^=)"
#define mkp make_pair
#define lP pair<ll, ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;

int N;
ll DP[3000], S[3001];
string s;

int main() {
	cin >> N >> s;
	for (int i = 0; i != N; ++i)
		DP[i] = 1;
	for (int i = 0; i != N - 1; ++i) {
		for (int j = 0; j != N - i; ++j)
			S[j + 1] = S[j] + DP[j];
		if (s[i] == '>') {
			for (int j = 0; j != N - i - 1; ++j) {
				DP[j] = (S[N - i] - S[j + 1]) % mod;
			}
		}
		else {
			for (int j = 0; j != N - i - 1; ++j) {
				DP[j] = S[j + 1] % mod;
			}
		}
	}
	cout << DP[0] << endl;
	return 0;
}

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

int main(){
  int a,b;
  cin >> a >> b;
  if(a == 1 || b == 1){
    if(a == 2 || b == 2){
      cout << 3;
    }
    else{
      cout << 2;
    }
  }
  else{
    cout << 1;
  }
}




Measured memory_bytes: 256
let n=read_int()open Array
let a=init n(fun _->Scanf.scanf"%d "(fun e->e))and b=make n 0and c=make 10001 0;;iter(fun e->c.(e)<-c.(e)+1)a;iteri(fun i _->if i<>0then c.(i)<-c.(i)+c.(i-1))c;for i=n-1downto 0do c.(a.(i))<-c.(a.(i))-1;b.(c.(a.(i)))<-a.(i);done;print_int b.(0);for i=1to n-1do print_string" ";print_int b.(i);done;print_newline()

Measured memory_bytes: 36124
import java.io.*;
import java.io.IOException;
import java.util.*;

@SuppressWarnings({"rawtypes", "unchecked"})
class Main {
    final static int INF = 1 << 28;
    final static long LNF = 1L << 60;
    final static double EPS = 1e-9;
    final static double GOLDEN_RATIO = (1.0 + Math.sqrt(5)) / 2.0;

    static final long MOD = 1_000_000_007;
    static final String YES = "YES";
    static final String NO = "NO";

    public static void main(String[] args) throws Exception {
        final MyScanner sc = new MyScanner();
        long N;
        N = sc.nextLong();
        long[] A = new long[(int)(N)];
        for(int i = 0 ; i < N ; i++){
                A[i] = sc.nextLong();
        }
        solve(N, A);
    }

    static void solve(long N, long[] A){
        Arrays.sort(A);
        for (int i = 0; i < A.length - 1; i++) {
            if(A[i] == A[i+1]) {
                System.out.println("NO");
                return;
            }
        }
        System.out.println("YES");
    }


    static class MyScanner {
 
        BufferedReader br;
        StringTokenizer st;
 
        MyScanner(FileReader fileReader) {
            br = new BufferedReader(fileReader);
        }
 
        MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
 
        String nn() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
 
        String next() {
            return nn();
        }

        String nextLine() {
            String ans = "";
            try {
                ans = br.readLine();
            } catch (IOException ex) {
                ex.printStackTrace();
            }
            return ans;
        }
 
        char nextChar() {
            return nn().charAt(0);
        }
 
        int nextInt() {
            return Integer.parseInt(nn());
        }
 
        long nextLong() {
            return Long.parseLong(nn());
        }
 
        double nextDouble() {
            return Double.parseDouble(nn());
        }
 
        Integer[] niArr0(int n) {
            Integer[] ar = new Integer[n];
            for (int i = 0; i < n; i++) {
                ar[i] = nextInt();
            }
            return ar;
        }
 
        Integer[] niArr1(int n) {
            Integer[] ar = new Integer[n + 1];
            for (int i = 1; i <= n; i++) {
                ar[i] = nextInt();
            }
            return ar;
        }
 
        Long[] nlArr0(int n) {
            Long[] ar = new Long[n];
            for (int i = 0; i < n; i++) {
                ar[i] = nextLong();
            }
            return ar;
        }
 
        Long[] nlArr1(int n) {
            Long[] ar = new Long[n + 1];
            for (int i = 1; i <= n; i++) {
                ar[i] = nextLong();
            }
            return ar;
        }
    }

}


Measured memory_bytes: 46596
#include<stdio.h>
int main()
{
    int n,a[11],i,p,max=0,sum=0;
    scanf("%d", &n);
    for(i=1;i<=n;i++)
    {
        scanf("%d",&p);
        if(p>=max)
            max=p;
        sum=sum+p;
    }
    sum=sum-(max/2);
    printf("%d\n", sum);
    return 0;

}


Measured memory_bytes: 1728
from collections import defaultdict
from math import gcd

N = int(input())

MOD = 1000000007
d_plus = defaultdict(int)  # + or ∞
d_minus = defaultdict(int)  # - or 0
ans = 1
ans_00 = 0
for i in range(N):
    a, b = map(int, input().split())
    if a == 0 and b == 0:
        ans_00 += 1
    elif a == 0:
        d_minus[0] += 1
    elif b == 0:
        d_plus[float('inf')] += 1
    else:
        g = gcd(a, b)
        if (a > 0) ^ (b > 0):
            d_plus[(abs(a // g), abs(b // g))] += 1
        else:
            d_minus[(abs(a // g), -abs(b // g))] += 1


def pair(p):
    if p == 0:
        return float('inf')
    elif p == float('inf'):
        return 0
    else:
        a, b = -p[1], p[0]
        if a < 0:
            a, b = -a, -b
        return a, b


for m in d_minus:
    d_plus[pair(m)]
for p in d_plus:
    ans *= (pow(2, d_plus[p], MOD) + pow(2, d_minus[pair(p)], MOD) - 1)
    ans %= MOD
print((ans - 1 + ans_00) % MOD)


Measured memory_bytes: 156020
#include <iostream>
#include <cctype>
#include <string>
using namespace std;

int main(){

    //input
    std::string input;
    if(getline(cin, input)){
        for(int i = 0; i < input.size(); i++){
            if(islower(input[i]) != 0){
                input[i] = toupper(input[i]);
            }else if(isupper(input[i]) != 0){
                input[i] = tolower(input[i]);
            }else{
                continue;
            }
        }
        cout << input << endl;
    }
}



Measured memory_bytes: 3140
N = int(input())
s = []
for i in range(0,N):
    a = input()
    s.append(sorted(a))
s = sorted(s)
t = 0
i = 0
while i<N:
    for j in range(i+1,N):
        if s[i]==s[j]:
            t = t+j-i
        else:
            break
    i = j
    if i==N-1:
        break
print(t)

Measured memory_bytes: 25392
#!/usr/bin/env python3
import sys


def solve(N: int, M_a: int, M_b: int, a: "List[int]", b: "List[int]", c: "List[int]"):
    INF=1000000000
    NMAX=40
    ABMAX=10
    dp = [[[INF for _ in range(NMAX*ABMAX+1)] for _ in range(NMAX*ABMAX+1)] for _ in range(NMAX+1)]
    dp[0][0][0] = 0
    for i in range(N):
        for ca in range(NMAX*ABMAX+1):
            for cb in range(NMAX*ABMAX+1):
                if dp[i][ca][cb] == INF:
                    continue
                dp[i+1][ca][cb] = min(dp[i+1][ca][cb], dp[i][ca][cb])
                dp[i+1][ca+a[i]][cb+b[i]] = min(dp[i+1][ca+a[i]][cb+b[i]], dp[i][ca][cb]+c[i])

    ans = INF
    for i in range(1, NMAX*ABMAX+1):
        for j in range(1, NMAX*ABMAX+1):
            if (i*M_b == j * M_a):
                ans = min(ans, dp[N][i][j])
    
    if ans == INF:
        ans = -1
    
    print(ans)
    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M_a = int(next(tokens))  # type: int
    M_b = int(next(tokens))  # type: int
    a = [int()] * (N)  # type: "List[int]"
    b = [int()] * (N)  # type: "List[int]"
    c = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
        c[i] = int(next(tokens))
    solve(N, M_a, M_b, a, b, c)

if __name__ == '__main__':
    main()


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

typedef long long ll;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0LL)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;}
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);}
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;}
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;}


bool isOk(ll key,ll value){
  return key >= value;
}

ll binary_search(vector<ll> a,ll key){
  ll ok = a.size()-1;
  ll ng = 0;

  while(abs(ok - ng) > 1){
    ll mid = (ok + ng) / 2;
    if(isOk(key,a[mid]))ok = mid;
    else ng = mid;
  }
  return ok;
}

int main() {
  cin.tie(0); ios::sync_with_stdio(0);
  int n;cin>>n;
  vector<int> h(n);rep(i,n)cin>>h[i];
  h[0]--;
  rep(i,n){
    if(!i)continue;
    if(h[i-1] != h[i]){
      --h[i];
    }
    if(i+1 < n && h[i] > h[i+1]){
      print("No");
      return 0;
    }
  }
  print("Yes");
  return 0;
}


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

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

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N; cin >> N;
    rep(i, N) cout << "ACL";
    cout << endl;
    return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <string.h>
#include <algorithm>
#include <cmath>

using ll = long long;
const ll INF = __LONG_LONG_MAX__;

using namespace std;

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

    int m = A + B;

    if (m % 2 == 0) {
        cout << (A+B)/2 << endl;
    } else {
        cout << "IMPOSSIBLE" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
N = gets.to_i
H = gets.split.map(&:to_i)
max = 0
num = 0
(N-1).times do |i|
    if H[i] >= H[i+1] then
        num += 1
    else
        max = num if max < num
        num = 0
    end
end
max = num if max < num
puts max

Measured memory_bytes: 8580
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <limits>
#include <numeric>
#include <queue>
#include <cmath>
#include <set>
#include <map>

using namespace std;

#define INF (1ll<<60)
#define INFint (1<<30)
#define MOD 1000000007
#define BOUND 27182818284

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

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

template<class T>
bool umax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
bool umin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// gcd
template<typename T>
T gcd(T a, T b) {
    if (a == 0)
        return b;
    return gcd(b % a, a);
}

int findGCD(int arr[], int n) {
    int result = arr[0];
    for (int i = 1; i < n; i++)
        result = gcd(arr[i], result);
    return result;
}

template<typename T>
T lcm(T m, T n) {
    // 引数に0がある場合は0を返す
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    fill((T *) array, (T *) (array + N), val);
}


int dx[5] = {1, 0, -1, 0};
int dy[5] = {0, 1, 0, -1};

// v.front() = -BOUND;
// v.back() = BOUND;

//struct edge{
//    int cost, to;
//
//    edge(int in_cost, int in_to){
//        cost=in_cost;
//        to=in_to;
//    }
//    bool operator<(const edge &a) const
//    {
//        return cost > a.cost;
//    }
//};

map<pair<lli,lli>, bool>black;
map<pair<lli, lli>, bool> used;
vector<lli>num(10,0);
int da[3]={1,0,-1}, db[3]={1,0,-1};

lli H, W, N;
bool check(lli h, lli w){
    if( !(2<=h && h<=H-1 && 2<=w && w<=W-1) )
        return false;
    if(used[pair<lli,lli>(h,w)])
        return false;

    used[pair<lli,lli>(h,w)]=true;
    return true;
}

int black_count(lli h, lli w){
    int count=0;
    for(int j : da){
        for(int k : db){
            if(black[pair<lli,lli>(h+j, w+k)]) {
                count++;
            }
        }
    }
    return count;
}
int main() {
    cin >> H >> W >> N;
    vector<lli>A(N), B(N);
    num[0]=(H-2)*(W-2);

    rep(i,N) {
        cin >> A[i] >> B[i];
        black[pair<lli,lli>(A[i], B[i])]=true;
    }

    for(int i=0; i<N; i++){
        for(int j : da){
            for(int k : db){
                int check_a=A[i]+j, check_b=B[i]+k;
                if(check(A[i]+j, B[i]+k)) {
                    num[black_count(check_a, check_b)]++;
                }
            }
        }
    }

    for(int i=1; i<10; i++){
        num[0]-=num[i];
    }
    for(int i=0; i<10; i++){
        cout << num[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 214272
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;


int main(){

    ll n, a, b;
    cin >> n >> a >> b;

    if(a > b) cout << 0 << endl;
    else if(n == 1){
        if(b - a > 0) cout << 0 << endl;
        else cout << 1 << endl;
    }
    else{
        cout << (b - a) * (n - 2) + 1 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
const int maxn = 1e3 + 5;
using namespace std;

int n,k;
long long ans = 1;

int main(){
	scanf("%d %d", &n, &k);
	for(int i = 1; i < n; i++){
		ans *= (k - 1);
	}
	ans *= k;
	printf("%lld",ans);
	return 0;
}

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

int main() {
    int A,B,C,X,Y;
    cin >> A >> B >> C >> X >> Y;

    long long  mini=2*C*max(X,Y);
    for(long long i=1;i<=max(X,Y);i++){

        if(max(X,Y)-i>=X) mini=min(mini,B*i+2*C*(max(X,Y)-i));
        else if(max(X,Y)-i>=Y) mini=min(mini,A*i+2*C*(max(X,Y)-i));
        
        if(i>X) mini=min(mini,A*X+B*i+2*C*(max(X,Y)-i));
        else if(i>Y) mini=min(mini,B*Y+A*i+2*C*(max(X,Y)-i));
        else mini=min(mini,(A+B)*i+2*C*(max(X,Y)-i));
    }
    cout << mini << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <map>
#define ll long long
const int MOD = 1e9+7;
const double PI=3.1415926535;
using namespace std;


int main(){
	double a, b, x;
	cin >> a >> b >> x;
	if (x <= a*a*b/2){
		double y = 2*x/(a*b);
		double theta = atan(y/b);
		cout << setprecision(10) << 90 - theta*180/PI << endl;
	}else{
		double y = 2*x/(a*a) - b;
		double z = b - y;
		double theta = atan(a/z);
		cout << setprecision(10) << 90 - theta*180/PI << endl;
	}
	return 0;
}

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

using namespace std;

int main(){
    int i;
    vector<int> N(4);
    bool a=false, b=false, c=false, d=false;

    for (i=0; i<4; i++) cin >> N[i];
    
    for (i=0; i<4; i++){
        if (N[i]==1) a = true;
        else if (N[i]==9) b = true;
        else if (N[i]==7) c = true;
        else if (N[i]==4) d = true;
    }

    if (a && b && c && d) cout << "YES" << '\n';
    else cout << "NO" << '\n';
}

   

Measured memory_bytes: 256
import kotlin.comparisons.compareBy
fun main(args: Array<String>) {
    val N = nextInt()
    val S = Array(N) { next() }
    val M = S.groupBy { it }.map { it.key to it.value.size }.sortedWith(compareBy({ -it.second }, { it.first }))
    val max = M[0].second
    println(M.filter { it.second == max }.map { it.first }.joinToString(separator="\n"))
}
fun next() = readLine()!!
fun nextInt() = Integer.parseInt(next())
fun listOfString() = next().split(" ")
fun listOfInt(delta: Int = 0) = listOfString().map { Integer.parseInt(it) + delta }
fun printErr(value: Any) = System.err.println(value)


Measured memory_bytes: 121500
/*{{{*/
//#pragma GCC optimize("O3")

#include <bits/stdc++.h>

#ifdef __linux__
#define getchar getchar_unlocked
#define putchar putchar_unlocked
#endif

typedef long long ll;
typedef std::pair<int, int> pii;

std::string Name = __FILE__;
std::string iput = Name.substr(0, Name.length() - 4) + ".in";
std::string oput = Name.substr(0, Name.length() - 4) + ".out";

template <class T> inline bool chkmin(T &x, T y) { return x > y ? x = y, true : false; }
template <class T> inline bool chkmax(T &x, T y) { return x < y ? x = y, true : false; }

template <class T> inline T &read(T &x)
{
    static int f;
    static char c; 
    for (f = 1; !isdigit(c = getchar()); ) {
        if (c == '-')
            f = -1;
    }
    for (x = 0; isdigit(c); c = getchar()) {
        x = x * 10 + c - 48;
    }
    return x *= f;
}
 
template <class T> inline void write(T x, const char p = '\n')
{
    static int top;
    static int s[30];
    if (x < 0) {
        x = -x;
        putchar('-');
    }
    do s[++ top] = x % 10 + 48;
    while (x /= 10);
    while (top)
        putchar(s[top --]);
    putchar(p);
}
/*}}}*/
 
const int maxn = 2e5 + 5;
 
long long n;
long long T;
long long a[maxn];
long long ans;


void exec()
{
    read(n);
    read(T);
    read(a[1]);
    for (int i = 2; i <= n; ++ i) {
        read(a[i]);
        if (a[i - 1] + T < a[i]) ans -= a[i] - a[i - 1] - T;
    }
    ans += a[n] + T;
    write(ans);
}

/*{{{*/
int main() 
{
    if (fopen(iput.c_str(), "r") != NULL) {
        freopen(iput.c_str(), "r", stdin);
        freopen(oput.c_str(), "w", stdout);
    }

    exec();

    fclose(stdin);
    fclose(stdout);

    return 0;
}
/*}}}*/




Measured memory_bytes: 1792
#include<stdio.h>
int main(void){
  int n;
  int flg=0;
  scanf("%d",&n);
  for(int i=1;i<10;i++){
    for(int j=1;j<10;j++){
      if(n==i*j){
        flg=1;
        break;
      }
    }
  }
  if(flg==1){
    printf("Yes\n");
  }
  else{
    printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 128
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <utility>
#include <memory>
#include <functional>
#include <deque>
#include <cctype>
#include <ctime>
#include <numeric>
#include <list>
#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll;
typedef vector<vector<long long> > vvll;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _rep(i,n) _rep2((i),0,(n))
#define _rep2(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) GET_MACRO(__VA_ARGS__, _rep2, _rep)(__VA_ARGS__)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define fi first
#define se second
#define mkp make_pair
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

void mainmain(){
	ll a,b;
	cin>>a>>b;
	if(a<=0 && 0<=b){
		cout<<"Zero"<<endl;
	}
	else if(0 < a){
		cout<<"Positive"<<endl;
	}
	else{
		if((min(b,-1LL)-a)%2==0){
			cout<<"Negative"<<endl;
		}
		else{
			cout<<"Positive"<<endl;
		}
	}
}


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

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include<algorithm>
using namespace std;

int main(){
  string S;
  cin >> S;
  int ans=0;
  for(int i=0;i<S.size()-1;i++){
   if(S[i]!=S[i+1]){
    ans++; 
   }
  }
  cout << ans << endl;
return 0;}

Measured memory_bytes: 512