akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <map>
#include <vector>
using namespace std;

int main(int argc, char const *argv[]) {
  int N;
  cin >> N;
  vector<int> A1(N);
  vector<int> sub_sum1(N);
  vector<int> A2(N);
  vector<int> subsum2(N);
  for (int i = 0; i < N; i++) {
    cin >> A1[i];
  }
  sub_sum1[0] = A1[0];
  for (int i = 1; i < N; i++) {
    sub_sum1[i] = sub_sum1[i - 1] + A1[i];
  }
  int sum2 = 0;
  for (int i = 0; i < N; i++) {
    cin >> A2[i];
    sum2 += A2[i];
  }
  subsum2[0] = sum2;
  for (int i = 1; i < N; i++) {
    subsum2[i] = subsum2[i - 1] - A2[i - 1];
  }
  vector<int> ans_sum(N);
  for (int i = 0; i < N; i++) {
    ans_sum[i] = sub_sum1[i] + subsum2[i];
  }
  sort(ans_sum.begin(), ans_sum.end());
  cout << ans_sum.back() << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio> 
//#include<vector>
//#include<string>
//#include<cstring>
#include<algorithm> 
#define max(a,b) (a>b?a:b)
#define min(a,b) (a>b?b:a)
#define  endl '\n'
#define all(s) s.begin(),s.end()
#define lowbit(x) (x&-x)
#define fi first
#define se second 
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f; 
const int N=2e5+10;
int main()
{
	ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
	int n,m,q,k,len;
	int a[N];
	cin>>len>>n;
	int ans=0;
	for(int i=1;i<=n;i++) cin>>a[i];
	sort(a+1,a+n+1);
	for(int i=2;i<=n;i++){
		ans=max(a[i]-a[i-1],ans);
	}
	ans=max(ans,len-a[n]+a[1]);
	cout<<len-ans;

}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main(){
    int W,H,x,y,r;
    cin >> W >> H >> x >> y >> r;
    if (x+r<=W){
        if (x-r>=0){
            if (y+r<=H){
                if (y-r>=0){
                    cout << "Yes" <<endl;
                }else{
                    cout << "No"<<endl;
                }
            }else{
                cout << "No"<<endl;
                
            }
        }else{
            cout << "No"<<endl;
        }
    }else{
        cout << "No"<<endl;
    }
    return 0;
}


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

long A, B, N;

int main(void) {

    cin >> A >> B >> N;

    long x = N < B-1 ? N : B-1;
    cout << floor(A * x / B) - A * floor(x / B) << endl;

    return 0;

}

Measured memory_bytes: 3776
#include <bits/stdc++.h>
using  namespace std;
typedef long long ll;
ll mod = pow(10, 9) + 7;
int main(){
    ll n, ans=0, a;
    bool flag = true;
    cin >> n;
    ll A[n]={};
    for(ll i=0;i<n;i++){
        cin >> a;
        A[a]++;
    }
    if(n%2==1){
        if(A[0]!=1){
            flag = false;
        }
    }
    if(flag){
        for(ll i=n-1;i>0;i -= 2){
            if(A[i]!=2){
                flag = false;
                break;
            }
        }
    }
    if(flag){
      	ans = 1;
      	for(ll i=0;i<n/2;i++){
          	ans = ans*2%mod;
        }
    }
	
  	cout << ans << endl;
    return 0;
}


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

//省略形
#define rep(i,n) for(auto i=0; i<n ; ++i)
#define REP(i,a,b) for(auto i=a; i<b; ++i)
#define all(v) (v).begin() , (v).end()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvc = vector<vector<char>>;
using pii = pair<int , int>;
using pll = pair<long long , long long>;

//よく使う定数
const int INF = 1e9;
const int MOD = 1e9+7;
//逆元
const int INV = 1e9+5;

//UnionFindTree
struct union_find{
  vector<int> data;
  union_find(int size) : data(size , -1) { }

  void merge(int x , int y){
    x = root(x); y = root(y);
    if(x == y) return;
    if(data[y] < data[x]) swap(x , y);
    data[x] += data[y];
    data[y] = x;
    return; 
  }

  bool same(int x , int y){
    x = root(x) , y = root(y);
    return x == y;
  }

  int root(int x){
    return data[x] < 0 ? x : (data[x] = root(data[x]));
  }

  int size(int x){
    return -data[root(x)];
  }
};

//プロトタイプ宣言
void faster(void);
template <class T>
T get_digent(T);
template <class T>
T POW(T , T);
template <class T>
T modpow(T , T , T);
bool is_palindrome(string);

//メモ
//最大公約数:__gcd　|　最小公倍数:__lcm
//回文は反転させて一致すればよい

int main(){
  faster();
  int n,a,b,cnt=0;
  cin >> n;
  vi p(n),q(n),x(n);
  rep(i,n) x[i] = i+1;
  rep(i,n) cin >> p[i];
  rep(i,n) cin >> q[i];
  do{
    cnt++;
    bool flagp = true;
    bool flagq = true;
    rep(i,n){
      if (x[i]!=p[i]) flagp = false;
      if (x[i]!=q[i]) flagq = false;
    }
    if (flagp) a=cnt;
    if (flagq) b=cnt;
  }while(next_permutation(all(x)));
  cout << abs(a-b) << endl;
}























//同期解除
void faster(void){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}

//桁数取得
template <class T>
T get_digent(auto x){
  string s;
  s = to_string(x);
  ll digent = s.size();
  return digent;
} 

//繰り返し自乗法
template <class T>
T POW(T x, T y){
  if(y==0) return 1;
  if(y%2 == 1){
    ll temp = POW(x,y-1);
    return (temp*x);
  }
  else{
    ll temp = POW(x,y/2);
    return temp*temp;
  }
} 

//繰り返し自乗法(剰余)
template <class T>
T modpow(T x , T y , T mod){
  if(y == 0) return 1;
  if(y%2 == 1){
    ll temp = modpow(x,y-1,mod);
    return temp*x%mod;
  }
  else{
    ll temp = pow_mod(x,y/2,mod);
    return temp*temp%mod;
  }
}

bool is_palindrome(string s){
    string t(s.rbegin(),s.rend());
    return s == t;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
const int MOD = 1000000007;

int main(){
    ll N;cin>>N;
    vector<ll> town(5);
    REP(i,5) cin>>town[i];
    ll mint = *min_element(town.begin(),town.end());
    if(mint>=N){
        cout<<"5"<<endl;
        return 0;
    }
    if(N%mint != 0){
    cout<<5+N/mint<<endl;
    return 0;
    }
    cout<<5+N/mint-1<<endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        String[] s = new String[n];
        int[] p = new int[n];
        for (int i = 0; i < n; i++) {
            s[i] = sc.next();
            p[i] = Integer.parseInt(sc.next());
        }

        // 主処理
        String[] array = new String[n];
        for (int i = 0; i < array.length; i++) {
            array[i] = s[i] + String.format("%03d", Math.abs(100 - p[i])) + "," + String.format("%03d", i + 1);
        }

        Arrays.sort(array);
        for (int i = 0; i < array.length; i++) {
            int index = Integer.parseInt(array[i].replaceAll(".*,", ""));
            array[i] = Integer.toString(index);
        }
        String result = String.join("\n", array);

        // 出力
        System.out.println(result);
        sc.close();
    }
}


Measured memory_bytes: 21076
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <list>
#include <ctime>
#include <sstream>
#include <queue>
#include <stack>
#include <random>
#include <bitset>
#include <numeric>
#include <cassert>
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;
#define rep(x, b, e) for(int x=(b); x<(e); ++x)
#define ford(x, b, e) for(int x=((int)(b))-1; x>=(e); --x)
#define all(c) c.begin(),c.end()
#define sz(x) ((int)((x).size()))
#define pb push_back
#define st first
#define nd second
#define mp(x,y) make_pair(x,y)
typedef short int sint;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it) {
	*this << ((it != d.b) ? ", " : "") << *it;
  }
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

int main() {
	ios_base::sync_with_stdio(false);
	vi v{{1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51}};
	int k;
	cin >> k;
	cout << v[k - 1] << endl;
	
}

Measured memory_bytes: 256
#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
#define vint vector<int>
#define pint pair<int,int>
#define pb(a) push_back(a)
#define all(v) v.begin(),v.end()
#define dbg(x) cerr << #x << " = " << (x) << endl
#define yn(b) cout << ((b) ? "Yes" : "No") << endl
#define YN(b) cout << ((b) ? "YES" : "NO") << endl

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

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

	string S[3];

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

	for(int i = 0; i < 3; i++)
	{
		cout << S[i][i];
	}
	cout << endl;

	return 0;
}

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

using namespace std;

constexpr int MAX = 100000;

int res;
int num[MAX], visited[MAX];

void dfs(int v, int c, const vector<int>& a)
{
    visited[v] = 0; num[v] = c;
    int to = (v + a[v]) % a.size();
    if (visited[to] == -1) {
        dfs(to, c + 1, a);
    } else if(visited[to] == 0) {
        res += num[v] - num[to] + 1;
    }
    visited[v] = 1;
}

int main()
{
    int N;
    cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }
    
    memset(num, -1, sizeof(num));
    memset(visited, -1, sizeof(visited));
    
    res = 0;
    for (int i = 0; i < N; i++) {
        if (visited[i] == -1) {
            dfs(i, 1, a);
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 5416
#include<iostream> 
#include<math.h> 
#include<stdio.h> 
using namespace std; 
int main() { 
    double a,b,c,h,S,C;
    cin>>a>>b>>C; S=(a*b*sin((C/180)*M_PI))/2; 
    printf("%.8f\n",S);
    c=sqrt(a*a+b*b-2*a*b*cos((C/180)*M_PI));
    printf("%.8f\n",a+b+c);
    h=2*S/a; 
    printf("%.8f\n",h); 
    return 0;
    } 


Measured memory_bytes: 3388
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
	int n,a,b;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a>>b;
		int v=a%b;
		if(v==0){v+=b;}
		cout<<v<<endl;
	}
}

Measured memory_bytes: 1160
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
using namespace std;
int main() {
	int r, c;
	char m[51][51];
	queue<int> bfs;
	queue<int> bfs1;
	int bfs2[50][50] = { 0 };
	int ans = 0;
	int b1[4] = { 0,0,1,-1 };
	int b2[4] = { 1,-1,0,0 };
	cin >> r >> c;
	bfs.push(0);
	bfs1.push(0);
	int b3 = 0;
	for (int a = 0; a < r; a++) {
		for (int b = 0; b < c; b++) {
			cin >> m[b][a];
			if (m[b][a] == '#') {
				b3++;
			}
		}
	}
	for (;;) {
		if (bfs.empty()) {
			cout << "-1" << endl;
		}
		for (int i = 0; i < 4; i++) {
			if (m[bfs.front() + b1[i]][bfs1.front() + b2[i]] == '.' && bfs2[bfs.front() + b1[i]][bfs1.front() + b2[i]] == 0) {
				bfs.push(bfs.front() + b1[i]);
				bfs1.push(bfs1.front() + b2[i]);
				bfs2[bfs.front() + b1[i]][bfs1.front() + b2[i]] = bfs2[bfs.front()][bfs1.front()] + 1;
			}
		}
		ans++;
		bfs.pop();
		bfs1.pop();
		if (bfs.empty()) {
			cout << "-1" << endl;
			return 0;
		}
		if (bfs.front() == c-1 && bfs1.front() == r-1) {
			cout << r * c - bfs2[bfs.front()][bfs1.front()] - b3 - 1 << endl;
			return 0;
		}
	}
}






Measured memory_bytes: 256
def agc014_b():
    n, m = map(int, input().split())
    deg = [0]*n
    for _ in range(m):
        a, b = map(lambda x: int(x)-1, input().split())
        deg[a] += 1
        deg[b] += 1
    for k in deg:
        if k%2 == 1:
            return print('NO')
    print('YES')

if __name__ == '__main__':
    agc014_b()

Measured memory_bytes: 9672
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

    public static class edge {
        int from, to;
        long cost;
    }
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] str = br.readLine().split(" ");
        int n = Integer.parseInt(str[0]);
        int m = Integer.parseInt(str[1]);

        edge[] es = new edge[m];
        for(int i=0; i<m; i++){
            str = br.readLine().split(" ");
            edge ed = new edge();
            ed.from = Integer.parseInt(str[0]) - 1;
            ed.to = Integer.parseInt(str[1]) - 1;
            ed.cost = -Long.parseLong(str[2]);
            es[i] = ed;
        }

        long[] dist = new long[n];
        Arrays.fill(dist, Long.MAX_VALUE / 2);
        dist[0] = 0;

        for(int i=0; i<n; i++){
            for(int j=0; j<m; j++){
                edge ed = es[j];
                if(dist[ed.from] < Long.MAX_VALUE / 3)
                    dist[ed.to] = Long.min(dist[ed.to], dist[ed.from] + ed.cost);
            }
        }

        long ans = dist[n-1];

        for(int i=0; i<n; i++){
            for(int j=0; j<m; j++){
                edge ed = es[j];
                if(dist[ed.from] < Long.MAX_VALUE / 3)
                    dist[ed.to] = Long.min(dist[ed.to], dist[ed.from] + ed.cost);
            }
        }

        if(ans != dist[n-1]) System.out.println("inf");
        else System.out.println(-ans);
    }

}


Measured memory_bytes: 23892
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(in, out);
        out.close();
    }

    static class Task {

        void solve(InputReader in, PrintWriter out) {
            Set<Integer> correctSet = new HashSet<>();
            Map<Integer, Integer> penaltyMap = new HashMap<>();
            
            int N = in.nextInt();
            int M = in.nextInt();
            
            for (int i = 0; i < M; ++i) {
                int num = in.nextInt();
                String result = in.next();
                
                if ("AC".equals(result)) {
                    correctSet.add(num);
                } else if (!correctSet.contains(num)) {
                    int val = penaltyMap.containsKey(num) ? penaltyMap.get(num) : 0;
                    penaltyMap.put(num, val + 1);
                }
            }
            
            int correct = correctSet.size();
            int penalty = 0;
            
            for (int num : correctSet) {
                penalty += penaltyMap.containsKey(num) ? penaltyMap.get(num) : 0;
            }
            
            String ans = correct + " " + penalty;
            out.println(ans);
        }
    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

        String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

        int[] nextIntArray(int size) {
            int[] arr = new int[size];
            for (int i = 0; i < size; i++) {
                arr[i] = nextInt();
            }
            return arr;
        }

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

        long[] nextLongArray(int size) {
            long[] arr = new long[size];
            for (int i = 0; i < size; i++) {
                arr[i] = nextLong();
            }
            return arr;
        }
    }
}


Measured memory_bytes: 44144
#include<stdio.h>

int heap[2000000];
int size;

void max_heapify(int heap[], int i) {
    int l = 2 * i + 1;
    int r = 2 * i + 2;
    int largest;

    if (l <= size && heap[l] > heap[i]) {
        largest = l;
    } else {
        largest = i;
    }
    if (r <= size && heap[r] > heap[largest]) {
        largest = r;
    }

    if (largest != i) {
        int tmp = heap[i];
        heap[i] = heap[largest];
        heap[largest] = tmp;
        max_heapify(heap, largest);
    }
}

void insert(int k){
    int child = size;
    int parent = (child - 1) / 2;

    heap[size] = k;

    while(1){
        if(heap[parent] > heap[child] || child == 0)
            break;
        int tmp = heap[child];
        heap[child] = heap[parent];
        heap[parent] = tmp;

        child = parent;
        parent = (child - 1) / 2;
    }

    size++;
}

int extract_max(){
    int ret = heap[0];
    heap[0] = heap[size-1];
    size--;
    max_heapify(heap, 0);
    return ret;
}

int main(){
    char cmd[8];
    int k;

    while(1) {
        scanf("%s", cmd);
        if(cmd[0] == 'i'){
            scanf("%d", &k);
            insert(k);
        }else if(cmd[1] == 'x'){
            printf("%d\n", extract_max());
        }else{
            return 0;
        }
    }
}

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

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

  vector<int> change(n, 0);
  int c = 0;
  for (int i = 0; i < n; ++i) {
    change[i] = c;
    if (s[i] == 'W') ++c;
  }
  c = 0;
  for (int i = n - 1; i >= 0; --i) {
    change[i] += c;
    if (s[i] == 'E') ++c;
  }
  cout << *min_element(change.begin(), change.end()) << "\n";

  return 0;
}


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



int main()
{
	int n;
	int d[100][100];
	cin >> n;
	for(int i = 0; i< n; i++)
		for (int j = 0; j < n; j++)
			cin >> d[i][j];

	int sl = -100000;
	for (int p = 0; p < n; p++)
	{
		for (int q = 0; q <= p; q++)
		{
			vector<int> a = vector<int>(100, 0);
			for (int r = q; r <= p; r++)
			{
				for (int t = 0; t < n; t++)
				{
					a[t] += d[r][t];
				}
			}


			vector<int> s = vector<int>(1, 0);
			bool f = true;
			bool plus = false;
			for (int i = 0; i < n; i++)
			{
				if (a[i] >= 0)
				{
					if (!f)
						f = true;
					if (!plus)
						plus = true;
					s[0] += a[i];
				}
				else if (s[0] > abs(a[i]))
				{
					if (f)
					{
						s.push_back(s[0]);
						f = false;
					}
					s[0] += a[i];
				}
				else
				{
					s[0] = 0;
				}

			}
			if (!plus)
			{
				int max = a[0];
				for (int i = 1; i < n; i++)
				{
					if (max < a[i])
						max = a[i];
				}
				if (sl < max)
					sl = max;
				continue;
			}
			for (int i = 1; i < s.size(); i++)
			{
				if (s[i] > s[0])
					s[0] = s[i];
			}
			if (sl < s[0])
				sl = s[0];
		}
	}
	cout << sl << endl;

	return 0;
}

Measured memory_bytes: 3176
#include<stdio.h>
int main(void){
int a, b;
    scanf("%d %d", &a, &b);
    if(a>b){
        printf("a > b\n");
    }else if(a<b){
        printf("a < b\n");
    }else{
        printf("a == b\n");
    }
    return 0;
}



Measured memory_bytes: 2048
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;n>i;++i)
#define MOD 1000000007
using namespace std;
using ll=int64_t;
using pii=pair<int,int>;
using vi=vector<int>;
using VI=vector<ll>;
using vis=vector<string>;
using vvi=vector<vi>;
//最大公約数
int gcd(int a,int b){
    if(a%b==0)
    return b;
    return gcd(b,a%b);
}
//最小公倍数
int lcm(int a,int b){
   return a*b/gcd(a,b);
}
bool prime(int num){
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2){
        if (num % i == 0)
        return false;
    }
    return true;
}
int main(){
    int a,b;
    cin>>a>>b;
    cout<<a*b<<endl;
}

Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <istream>
#include <map>
#include <set>
#include <queue>
#define rep0(i,n) for (int i = 0; i <= (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)
#define REP(a,b) for (int i = a; i <= (b); ++i) 
using namespace std;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
//
	int a, b;
	cin >> a >> b;
	int count = 0;
	REP(a, b) {
		string s = to_string(i);
		if (s[0] == s[4]) {
			if (s[1] == s[3]) {
				++count;
			}
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

  int N;
  cin >> N;
  int ans = 0;
  int a;
  for (int i = 0; i < N; ++i) {
    cin >> a;
    ans += a - 1;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
/*
[agc001] E - BBQ Hard
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
#define ALL(c) (c).begin(), (c).end()

const int MAX_N = 200000;
const int MAX_A = 2000;
const int MOD = 1e9 + 7;

class gf {
public:
    int n;
    static int mod_inv(int a, int m) {
        int u = 0, v = 1;
        while (a != 0) {
            int t = m / a;
            m -= t * a;
            u -= t * v;
            swap(a, m);
            swap(u, v);
        }
        return (u + MOD) % MOD;
    }
    gf() : n(0) {}
    gf(int n) : n(n % MOD) {}
    gf operator+(gf x) { return gf((n + x.n) % MOD); }
    gf operator-(gf x) { return gf((n - x.n + MOD) % MOD); }
    gf operator*(gf x) { return gf((1LL * n * x.n) % MOD); }
    gf operator/(gf x) { return *this * x.inv(); }
    gf& operator+=(gf x) { return *this = (*this + x); }
    gf& operator-=(gf x) { return *this = (*this - x); }
    gf& operator*=(gf x) { return *this = (*this * x); }
    gf& operator/=(gf x) { return *this = (*this / x); }
    gf inv() { return gf(mod_inv(n, MOD)); }
};

gf fact[4 * MAX_A + 1];

gf combi(int n, int k) {
    return (n < 0 || k < 0 || n - k < 0) ? 0
                                         : fact[n] / (fact[k] * fact[n - k]);
}

int N;
int A[MAX_N], B[MAX_N];
gf m_raw[2 * (MAX_A + 1)][2 * (MAX_A + 1)];

gf& m(int x, int y) { return m_raw[x + MAX_A][y + MAX_A]; }

ll solve() {
    fact[0] = 1;
    for (int i = 1; i <= 4 * MAX_A; i++) {
        fact[i] = fact[i - 1] * i;
    }

    for (int i = 0; i < N; i++) {
        m(-A[i], -B[i]) += 1;
    }
    for (int i = -MAX_A; i <= MAX_A; i++) {
        for (int j = -MAX_A; j <= MAX_A; j++) {
            m(i + 1, j) += m(i, j);
            m(i, j + 1) += m(i, j);
        }
    }

    gf ans = 0;
    for (int i = 0; i < N; i++) {
        ans += m(A[i], B[i]);
        ans -= combi(2 * A[i] + 2 * B[i], 2 * A[i]);
    }
    ans /= 2;

    return ans.n;
}

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> A[i] >> B[i];
    }

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 64384
n, a, b = map(int, input().split())
mod = 10**9+7

def nCk(n, k):
    a = 1
    for i in range(n, n-k, -1):
        a *= i
        a %= mod
    b = 1
    for i in range(1, k+1):
        b *= i
        b %= mod
    a *= pow(b, mod-2, mod)
    return a

ans = pow(2, n, mod)-1
ans -= nCk(n, a)+nCk(n, b)
print(ans%mod)


Measured memory_bytes: 9156
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
#include<fstream>
#include<set>
using namespace std;
typedef long long ll;

#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++)
#define out(str) cout << str << endl
#define ALL(a) (a).begin(),(a).end()
#define INF (1<<29)

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; }

int H,W,cnt,to,ans=1;


int main(){
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    cin>>H>>W;
    int tate[H][W],yoko[H][W];
    char m[H+2][W+2];

    rep(i,H+2){
        rep(j,W+2){
            if(i==0||i==H+1||j==0||j==W+1){
                m[i][j]='#';
            }
            else{
                cin>>m[i][j];
                tate[i-1][j-1]=0;
                yoko[i-1][j-1]=0;
            }
        }
    }
    rep(i,H){
        rep(j,W){
            if(m[i+1][j+1]=='.'){
                cnt=1;
                to=j+2;
                while(m[i+1][to]=='.'){
                    cnt++;
                    to++;
                }
                repi(k,j,to-1)tate[i][k]=cnt;
                j=to-1;
            }
        }
    }

    rep(i,W){
        rep(j,H){
            if(m[j+1][i+1]=='.'){
                cnt=1;
                to=j+2;
                while(m[to][i+1]=='.'){
                    cnt++;
                    to++;
                }
                repi(k,j,to-1)yoko[k][i]=cnt;
                j=to-1;
            }
        }
    }
    rep(i,H)rep(j,W)ans=max(ans,tate[i][j]+yoko[i][j]);
    // rep(i,H){
    //     rep(j,W){
    //         printf("%d ",tate[i][j]);
    //     }
    //     out("");
    // }
        
    
    out(ans-1);
    

}


Measured memory_bytes: 35456
#include <bits/stdc++.h>
template<class T> inline bool chmin(T&a, T b){if(a > b){a = b; return true;}else{return false;}}
template<class T> inline bool chmax(T&a, T b){if(a < b){a = b; return true;}else{return false;}}
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1.0)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    int l, r, d, ans = 0;
    cin >> l >> r >> d;
    for(int i = l; i <= r; i++)ans += (i % d == 0);
    cout << ans << endl;
}


Measured memory_bytes: 3592
N,X=map(int,input().split())
S=list(map(int,input().split()))
S.sort(reverse=True)
DP=[[0]*(X+1) for i in range(N+1)]
mod=10**9+7
inv=[0,1]
for i in range(2,N+10):
  inv.append((-inv[mod%i]*(mod//i))%mod)
DP[0][X]=1
for i in range(N):
  DP[0][X]=DP[0][X]*(i+1)%mod
for i in range(N):
  for j in range(X+1):
    DP[i+1][j]=(DP[i+1][j]+DP[i][j]*(1-inv[N-i]))%mod
    DP[i+1][j%S[i]]=(DP[i+1][j%S[i]]+DP[i][j]*inv[N-i])%mod
P=0
for i in range(X+1):
  P=(P+DP[N][i]*i)%mod
print(P)

Measured memory_bytes: 222484
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <math.h>
#include <numeric>


int main() {
	int n;

	std::cin >> n;

	std::vector<int> v(n);

	for (size_t i = 0; i < n; i++)
	{
		std::cin >> v[i];
	}

	auto max = std::max_element(v.begin(), v.end());
	int second = 0;

	for (size_t i = 0; i < n; i++)
	{
		if (max - v.begin() != i) {
			second = std::max(second, v[i]);
		}
	}

	for (size_t i = 0; i < n; i++)
	{
		if (v[i] == *max) {
			std::cout << second << std::endl;
		}
		else {
			std::cout << *max << std::endl;
		}
	}

}

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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()

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

ll n,m,ans;
const ll MOD=1000000007;

ll calc(ll a) {
	ll sum=1;
	FOR(i,1,a+1) (sum*=i)%=MOD;
	return sum;
}

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

	cin>>n>>m;
	if(abs(n-m)>=2) {
		cout<<'0'<<endl;
		return 0;
	}
	if(n==m) {
		ans=(((calc(n)*calc(n))%MOD)*2)%MOD;
	}
	else {
		ans=(calc(n)*calc(m))%MOD;
	}
	cout<<ans%MOD<<endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.*;
 
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String a = sc.nextLine();
        String b = sc.nextLine();
      
      if(a.charAt(0)==b.charAt(2)&&a.charAt(1)==b.charAt(1)&&a.charAt(2)==b.charAt(0)){
        System.out.print("YES");
      }else{
        System.out.print("NO");
      }
      
    }
}

Measured memory_bytes: 21972
import java.io.*;
import java.util.*;
public class Main{
	public static void main(String args[]) throws Exception{
		Scanner cin= new Scanner(System.in);
		int a= cin.nextInt();
		int b= cin.nextInt();
		int c= cin.nextInt();
		
		int buf;
		
		if( a>b || a>c ){
			buf= a;
			if(	b<c ){
				a=b;
				b=buf;
			}
			else{
				a=c;
				c=buf;
			}
		}
		if( b>c ){
			buf=b;
			b=c;
			c=buf;
		}
		
		System.out.println(a+" "+b+" "+c);
	}
}

Measured memory_bytes: 17160
#include<bits/stdc++.h>
using namespace std;
int n;
long long res = 0;
void dfs(long long a,int mask){
    if(a>n) return;
    if(mask==7) res++;
    dfs(a*10+3,mask|1);
    dfs(a*10+5,mask|2);
    dfs(a*10+7,mask|4);
}
int main(){
    ios::sync_with_stdio(false), cin.tie(0);
    cout.tie(0);
    cin>>n;
    dfs(0,0);
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int[] a = new int [3];
		for(int i = 0;i < n;i++){
			a[0] = in.nextInt();
			a[1] = in.nextInt();
			a[2] = in.nextInt();
			for(int j = 0;j < 3;j++){
				a[j] = a[j] * a[j];
			}
			for(int j = 0;j < 3;j++){
				if(a[j%3] == a[(j+1)%3] + a[(j+2)%3]){
					System.out.println("YES");
					break;
				}else if(j == 2){
					System.out.println("NO");
				}
			}
		}
	}
}

Measured memory_bytes: 23376
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define lower(a) transform(a.begin(),a.end(),a.begin(),::tolower)
#define upper(a) transform(a.begin(),a.end(),a.begin(),::toupper)
//#define min(a) *min_element(a.begin(),a.end())
//#define max(a) *max_element(a.begin(),a.end())
#define pdd pair<long double,long double>
#define prnt(a) for(auto x:a) cout<<x<<" ";
#define pb push_back
#define all(x) x.begin(),x.end()
#define endl '\n'
#define PI 3.1415926535897932385
#define INF 1000000000000000
#define M 1000000007
#define ve  vector<ll>;


 
 
int main()
{

ll n,x,t;
cin>>n>>x>>t;

ll temp;
if(n%x==0)
{
    temp=n/x;
}
else{
    temp=n/x + 1;
}
cout<<temp*t<<endl;


  
return 0;
}


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

using namespace std;

#define V vector
typedef long long ll;
typedef unsigned long long ull;

typedef V<int> vi;
typedef V<ll> vll;
typedef V<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef V<pll> vpll;

#define f(i,a) for(int i = 0 ; i < a ; i++)
#define fll(i,a) for(ll i = 0 ; i < a ;i++)
#define forab(i,a,b) for(int i = a ; i < b ; i++)
#define prec(x) cout<<fixed<<setprecision(x)
#define ff first
#define ss second

#define pb push_back
#define mp make_pair
#define numberofdigits(x) floor(log10(x)) + 1
#define MAXN 100001

ll binpow(ll a, long long b) {
	ll res = 1;
	while (b > 0) {
		if (b & 1)
			res = (res * a);
		a = (a * a);
		b >>= 1;
	}
	return res;
}

void solve()
{
	char ch;
	cin >> ch;

	if (ch >= 'a' && ch <= 'z')
	{
		cout << "a\n";
		return;
	}

	if (ch >= 'A' && ch <= 'Z')
	{
		cout << "A\n";
		return;
	}
}

int main() {

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

	int t = 1;
	//cin >> t;

	while (t--)
	{
		solve();
	}
	return 0;
}


Measured memory_bytes: 3612
IDENTIFICATION DIVISION.
PROGRAM-ID. 174A.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 X          PIC S9(02).
01 OUT        PIC ZZ9.
*>
PROCEDURE DIVISION.
  ACCEPT X.
*>
  IF (X >= 30)
    DISPLAY 'Yes'
  ELSE
    DISPLAY 'No'
  END-IF.
*>
  STOP RUN.


Measured memory_bytes: 3736
n,k_num = map(int,input().split())
info =[list(map(int,input().split())) for i in range(n)]
li_x = []
li_y = []

for i in range(n):
 # if info[i][0] not in li_x:
    li_x.append(info[i][0])
 # if info[i][1] not in li_y:
    li_y.append(info[i][1])

li_x = sorted(li_x)
li_y = sorted(li_y)

bunpu = [[0]*n for i in range(n)]
for i in range(n):
  for j in range(n):
    if info[i][0]==li_x[j]:
      zahyo_x=j
      break
  for k in range(n):
    if info[i][1]==li_y[k]:
      zahyo_y=k
      break
  bunpu[zahyo_x][zahyo_y]=1

ruiseki = [[0]*n for i in range(n)]


for i in range(0,n):
  for j in range(0,n):
    ruiseki[i][j] = bunpu[i][j]
#横方向(j)の累積
for i in range(n):
  for j in range(1,n):
    ruiseki[i][j] = ruiseki[i][j-1] + ruiseki[i][j]
#縦方向(i)の累積
for j in range(n):
  for i in range(1,n):
    ruiseki[i][j] = ruiseki[i-1][j] + ruiseki[i][j]

#print(bunpu)
#print(ruiseki)

ans = float("inf")

for i in range(len(li_x)):
  for j in range(i,len(li_x)):
    for k in range(len(li_y)):
      for l in range(k,len(li_y)):
        count = ruiseki[j][l]
        if 0<=k-1:
          count -= ruiseki[j][k-1]
        if 0<=i-1:
          count -= ruiseki[i-1][l]
        if 0<=k-1 and 0<=i-1:
          count += ruiseki[i-1][k-1]      
        if count ==k_num:
          ans = min(ans,(li_x[j]-li_x[i])*(li_y[l]-li_y[k]))
print(ans)


Measured memory_bytes: 3192
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define ull unsigned long long
#define db double
#define pb push_back
#define ppb pop_back
#define all(x) (x).begin(), (x).end()

template <typename T>
using pr = array <T, 2>;

template <typename T>
using ord_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 303, K = 300 * 300 + 3, MOD = 998244353;
int n, a[N], dp[N][K], f[N][K], p[N];

void add(int & x, int y) {
	x += y;
	if (x >= MOD) {
		x -= MOD;
	}
}

void sub(int & x, int y) {
	x -= y;
	if (x < 0) {
		x += MOD;
	}
}

int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	
	p[0] = 1;
	for (int i = 1; i < N; i++) {
		p[i] = p[i - 1] * 2 % MOD;
	}
	int inv = (MOD + 1) / 2;
	cin >> n;
	int t = 0;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		t += a[i];
	}
	dp[0][0] = p[n];
	f[0][0] = 2;
	int res = 0;
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j <= t; j++) {
			dp[i][j] = dp[i - 1][j];
			f[i][j] = f[i - 1][j];
			if (j >= a[i]) {
				add(dp[i][j], (ll)dp[i - 1][j - a[i]] * inv % MOD);
				add(f[i][j], f[i - 1][j - a[i]]);
			}
			if (i == n && j >= (t + 1) / 2 && j < t) {
				add(res, dp[i][j]);
				sub(res, f[i][j]);
			}
		}
	}
	res = (ll)res * 3 % MOD;
	int all = 1;
	for (int i = 0; i < n; i++) {
		all = (ll)all * 3 % MOD;
	}
	sub(all, (ll)p[n] * 3 % MOD);
	add(all, 3);
	cout << (all - res + MOD) % MOD;
}


Measured memory_bytes: 212864
#include<iostream>
#include<vector>
using namespace std;
int main()
{
  int n;
  cin>>n;
  vector<int> a(n);
  int i;
  for(i = 0; i < n; i++)cin >> a.at(i);
  int max = 0;
  int ch = 0;
  for(i = 0; i < n; i++)
  {
    if(max < a.at(i))
    {
      max = a.at(i);
      ch = i;
    }
  }
  a.at(ch) *= -1;
  int max2 = 0;
  for(i = 0; i < n; i++)
  {
    if(max2 < a.at(i))max2 = a.at(i);
  }
  for(i = 0; i < n; i++)
  {
    if(i == ch)cout << max2 << endl;
    else cout << max << endl;
  }
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) {if (a<b) { a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, const T &b) {if (b<a) { a=b; return 1;} return 0;}
struct init{init(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}}init_;

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 4e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//
// 1~1e5までの値について素数:自身の値, 合成数:最小の素因数 の配列を返す
constexpr int PSIZE = 1e6 + 1;
struct eratosthenes_sieve{
    int Primes[PSIZE];
    bool isPrime[PSIZE];
    constexpr eratosthenes_sieve(): Primes(), isPrime(){
        iota(Primes, Primes + PSIZE, 0);
        fill(isPrime, isPrime + PSIZE, 0);
        for (int i = 2; i < PSIZE; i++){
            if (Primes[i] != i) continue;
            for (int s = i * 2; s < PSIZE; s += i){
                Primes[s] = i;
            }
            isPrime[i] = true;
        }
    }
    
    // 数値vの素因数の配列を昇順で取得
    vector<int> get_pfactor(int v){
        vector<int> res;
        int p = Primes[v];
        while(v > 1){
            while (Primes[v] == p) v /= Primes[v];
            res.emplace_back(p);
            p = Primes[v];
        }
        reverse(res.begin(), res.end());
        return res;
    }

    // 数値vの素因数分解を取得
    map<int, int> get_factrization(int v){
        map<int, int> mp;
        while(v>1){
            mp[Primes[v]]++;
            v /= Primes[v];
        }
        return mp;
    }
};
using ES = struct eratosthenes_sieve;

int main() {
    ll N;
    cin >> N;
    vl A(N);
    rep(i, N) cin >> A[i];

    ll sgcd = A[0];
    repe(i, 1, N) sgcd = gcd(sgcd, A[i]);

    ES es;
    vc<bool> B(1000005);

    bool isok = true;
    rep(i, N){
        auto V = es.get_pfactor(A[i]);
        repa(c, V){
            if(B[c]){
                isok = false;
                break;
            }
            B[c] = true;
        }
    }

    if(isok)
        cout << "pairwise coprime" << endl;
    else if(sgcd == 1)
        cout << "setwise coprime" << endl;
    else
        cout << "not coprime" << endl;
}

Measured memory_bytes: 16252
/* it was worth becoming a chemist */
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef double db;
typedef long double ld;
typedef unsigned int uni;
typedef unsigned long long unll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef pair<long long, int> pli;
typedef pair<int, long long> pil;
typedef vector<int> vi;
typedef vector<long long> vll;

#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)x.size()
#define NAME "puts"
#define F first
#define S second

const ll INF = 1e18;
const int inf = 1e9;
const int mod = 1e9 + 7;
const db EPS = (db) 1e-9;
const db pi = acos(-1.0);
const int MAXN = 1e5 + 5;

int n;
ll a[MAXN];
ll res, sum;

int main() {
    
    cin >> n;
    for (int i = 1; i <= n; i++) {
    	cin >> a[i];
    }
    for (int i = 1; i <= n; i++) {
    	if (a[i] == 0) {
    		res += (sum >> 1ll);
    		sum = 0;
    	}
    	else sum += a[i];
    }
    res += (sum >> 1ll);
	cout << res;
	
    return 0;
}


Measured memory_bytes: 1152
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
#include <cstdio>
#include <stack>
#include <numeric>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf 1000000007
#define mod 1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)
ll dp[28];

int main(){
    int n;
    string s;
    cin >> n >> s;
    
    for(int i=0;i<n;i++){
        dp[s[i]-'a']++;
    } 
    ll ans = 1;
    for(int i=0;i<26;i++){
        ans *= dp[i]+1;
        ans %= mod;
    }
    ans += mod-1;
    ans %= mod;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <cstring>

using namespace std;

typedef long long ll;

const int mod = 998244353;

int add(int i, int j) { return ((i += j) < mod ? i : i -= mod); }
int mult(int i, int j) { return (ll) i * j % mod; }

int A[3000];

int k;
int dp[3000][3001];

int f(int i, int j) {
    if(j < 0) return 0;
    if(j == 0) return i + 2;
    if(i < 0) return 0;
    if(dp[i][j] > -1) return dp[i][j];
    int mx = f(i - 1, j);
    mx = add(mx, f(i - 1, j - A[i]));
    
    return dp[i][j] = mx;
}

int main() {
    int n; cin >> n >> k;
    memset(dp, -1, sizeof dp);
    
    for(int i = 0; i < n; ++i)
        cin >> A[i];
    int mx = 0;
    for(int i = 0; i < n; ++i)
        mx = add(mx, f(i, k));
    
    cout << mx;
    
    return 0;
}

Measured memory_bytes: 35584
#include<bits/stdc++.h>
using namespace std;
int a,b,c,s1,s2,s3;
int main()
{
    cin>>a>>b>>c;
    s1=a+b;
    s2=b+c;
    s3=a+c;
    cout<<min(s1,min(s2,s3))<<endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define rep(i, a, b) for (int i=a; i<(b); i++)
#define rp(i, a) for (int i=0; i<(a); i++)
#define repd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define rpd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


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

    ll n;
    cin >> n;
    ll a[n];
    ll sum = 0;
    rp(i,n){
      cin >> a[i];
      sum +=a[i];
    }
    ll ans = INF;
    rp(i,n-1){
      sum -=2*a[i];
      if(ans > abs(sum)) ans = abs(sum);
    }
    cout << ans << endl;

    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<string>
using namespace std;
int main(){
    int n,sum,l=0,k=0;
    string s;
    cin>>s;
    n=s.size();
    for(int i=0;i<n;i++){
        if(s[i]=='0'){
            l++;
        }
        else{
            k++;
        }
    }
    if(k>l){
        sum=l*2;
    }
    else{
        sum=k*2;
    }
    printf("%d\n",sum);
    return 0;
}


Measured memory_bytes: 512
# coding: utf-8
# Your code here!
import datetime

text = input()
time = datetime.datetime.strptime(text,"%Y/%m/%d")
heisei = datetime.datetime.strptime("2019/04/30","%Y/%m/%d")

if time <= heisei :
    print("Heisei")
else:
    print("TBD")


Measured memory_bytes: 4336
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	string s="#",w[100];
	cin>>n;
	bool ok=true;
	for(int i=0;i<n;i++){
		cin>>w[i];
		if(i){
			bool have=false;
			for(int j=0;j<i;j++) if(w[j]==w[i]) have=true;
			if(have||w[i-1][w[i-1].size()-1]!=w[i][0]) ok=false;
		}
	}
	if(ok) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
# coding: utf-8
# Your code here!

import sys

N = int(input())
x = list(map(int, input().rstrip().split(' ')))

output = [-1] * N
for i in range(N):
    generated_order = x[-i-1] - 1
    
    count_empty = 0
    flag_insert = False
    for j in range(N):
        if output[j] == -1 and count_empty == generated_order:
            output[j] = x[-i-1]
            flag_insert = True
            break
        elif output[j] == -1:
            count_empty += 1
    
    if flag_insert == False:
        print(-1)
        sys.exit()
        
for i in output:
    print(i)

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

using namespace std;

#define INF 1000007
#define MOD 1000000007
#define maxn 10001
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
#define int long long
const double PI = acos(-1);
typedef pair<int, int> P;

int gcd(int a, int b)
{
    return b ? gcd(b, a % b) : a;
}

int lcm(int a, int b) { return a / gcd(a, b) * b; }

int mpow(int N, int P, int M) //繰り返し自乗法
{
    if (P == 0)
        return 1;
    if (P % 2 == 0)
    {
        int t = mpow(N, P / 2, M);
        return t * t % M;
    }
    return N * mpow(N, P - 1, M) % M;
}

int counter(int x) //bit計算
{
    if (x == 0)
        return 0;
    return counter(x >> 1) + (x & 1);
}

vector<bool> prime(maxn + 1, true); //素数テーブル
void prime_table(void)
{
    prime[0] = false;
    prime[1] = false;
    for (int i = 2; i * i <= maxn; i++)
    {
        if (!prime[i])
        {
            continue;
        }
        for (int j = i + i; j <= maxn; j += j + i)
        {
            prime[j] = false;
        }
    }
}

bool IsPrime(int num) //素数判定
{
    if (num < 2)
        return false;
    else if (num == 2)
        return true;
    else if (num % 2 == 0)
        return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }

    return true;
}
vector<int> divisor(int n) //約数列挙
{
    vector<int> ret;
    for (int i = 1; i * i <= n; i++)
    {
        if (n % i == 0)
        {
            ret.push_back(i - 1);
            if (i * i != n)
            {
                ret.push_back((n / i) - 1);
            }
        }
    }
    sort(ret.begin(), ret.end());
    return (ret);
}

signed main()
{
    int N, M;
    cin >> N >> M;
    vector<int> H(N);
    rep(i, N)
    {
        cin >> H[i];
    }
    vector<vector<int>> AB(N);
    rep(i, M)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        AB[a].push_back(b);
        AB[b].push_back(a);
    }
    int ans = 0;

    rep(i, N)
    {
        bool check = true;
        rep(j, AB[i].size())
        {
            int x = AB[i][j];
            if (H[i] <= H[x])
            {
                check = false;
                break;
            }
        }
        if (check)
        {
            ans++;
        }
    }
    cout << ans << endl;
}

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

int main(){
  int a,b,c;
  cin >>a >>b >>c;
  if(a==b && a==c) cout << "No" << endl;
  else if(a!=b && a!=c && b!=c) cout << "No" << endl;
  else cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 384