akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        int n = ReadInt();
        long[] a = ReadLongArray();
        long ans = 0;
        long mod = (long)Math.Pow(10, 9) + 7;
        long sum = 0;
        for (int i = 0; i < a.Length; i++)
        {
            sum += a[i];
            sum %= mod;
        }

        for (int i = 0; i < n; i++)
        {
            sum -= a[i];
            if (sum < 0)
                sum += mod;
            ans += a[i] * sum;
            ans %= mod;
        }
        Console.WriteLine(ans);
    }
    static int ReadInt()
    {
        return int.Parse(Console.ReadLine());
    }
    static string[] ReadStringArray()
    {
        return Console.ReadLine().Split(' ');
    }
    static int[] ReadIntArray()
    {
        return ReadStringArray().Select(i => int.Parse(i)).ToArray();
    }

    static long[] ReadLongArray()
    {
        return ReadStringArray().Select(i => long.Parse(i)).ToArray();
    }
}

Measured memory_bytes: 47932
n, m = map(int, input().split())

ac_list = [0]*(n+1)
wa_list = [0]*(n+1)
wa = 0
ac = 0
if m == 0:
    pass
else:
    for i in range(m):
        p, s = input().split()
        p = int(p)
        if ac_list[p] == 1:
            continue
        if ac_list[p] == 0 and s == 'AC':
            ac_list[p] = 1
        #elif check_list[p] == 0 and s == 'WA':                                          
        else:
            wa_list[p] += 1
    for t_ac, t_wa in zip(ac_list, wa_list):
        if t_ac == 1:
            wa += t_wa
            ac += t_ac
print(ac, wa)

Measured memory_bytes: 4596
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}


int main(){
  int a,b,c,x,y,ans = 0;
  cin >> a >> b >> c >> x >> y;

  if( a >= 2*c){
    ans += 2*x*c;
    y = max(y-x,0);
    x = 0;
  }

  if( b >= 2*c){
    ans += 2*y*c;
    x = max(x-y,0);
    y = 0;
  }

  if(a+b >= 2*c){
    int minXY = min(x,y);
    ans += 2*c*minXY;
    x-= minXY;
    y-= minXY;
  }

  cout << a*x + b*y + ans << endl;

  return 0;
}


Measured memory_bytes: 256
// @author: arch_

#include <bits/stdc++.h>
using namespace std;

int main(void) {
    int x, n; cin >> n;
    string s, mark = "SHCD";
    bool cards[4][13] = {{false}};
    for (int i = 0; i < n; i++) {
        cin >> s >> x;
        cards[mark.find(s)][x - 1] = true;
    }
    for (int i = 0; i < 4; i++)
        for (int j = 0; j < 13; j++)
            if (!cards[i][j])
                cout << mark[i] << " " << j + 1 << "\n";
    return 0;
}

Measured memory_bytes: 3216
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define uint unsigned long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) {
    return a / gcd(a, b) * b;
}
int sigma(int n){
    int sum=0;
    for (int i=1; i<=(n); i++){
        sum+=i;
    }
    return sum;
}
signed main(){
    string S;
    cin >> S;
    int  gcount=0,lcount=0,count=0;
    int N = S.length();
    int p=0;
    while(p<N){
        while(1){
            if(S[p]=='>')gcount++;
            if(S[p]=='<')lcount++;
            p++;
            if((p==N)||((S[p-1]=='>')&&(S[p]=='<'))) break;
        }
        (gcount>=lcount)?(count = count + sigma(gcount) + sigma(lcount-1)):(count = count + sigma(gcount-1) + sigma(lcount));
        gcount=0;lcount=0;
    }
    cout << count << endl;

}


Measured memory_bytes: 900
/*
 * Author : Andrew J
*/
#include <bits/stdc++.h>
using namespace std;
#define rall(x) x.rbegin() , x.rend()
#define all(x) x.begin() , x.end()
#define fi first
#define se second
#define pb push_back
using ll = long long;
using ii = pair <int , int>;
using iii = pair <int , ii>;
using iiii = pair <ii , ii>;
void in(int &x);
const int N = 1e5 + 10;
const int inf = 1e9;
#define singleCase
// #define multipleCase
int n,m,dp[N][15],qryOrder[N][15];
vector <int> adj[N];
vector <iii> query;

int f(int u , int d) {
   if (d > 10) return inf;
   int &sol = dp[u][d];
   if (sol != -1) return sol;
   sol = inf;
   for (int i = d ; i <= 10 ; i++) {
      if (qryOrder[u][i] == -1) continue;
      sol = min(qryOrder[u][i] , sol);
   }
   for (int v : adj[u]) {
      sol = min(sol , f(v , d + 1));
   }
   return sol;
}

void inputAndInit() {
   memset (dp , -1 , sizeof dp);
   memset (qryOrder , -1 , sizeof qryOrder);
   in(n); in(m);
   for (int i = 0, u, v ; i < m ; i++) {
      in(u); in(v);
      adj[u].pb(v);
      adj[v].pb(u);
   }
   int q; in(q);
   query.resize(q);
   for (int i = 0, u, d , c ; i < q ; i++) {
      in(u); in(d); in(c);
      query[i] = {u , {d , c}};
   }
   reverse(all(query));
   for (int i = 0 ; i < query.size() ; i++) {
      int u = query[i].fi, d = query[i].se.fi, c = query[i].se.se;
      for (int j = 0 ; j <= d ; j++) {
         if (qryOrder[u][j] == -1) qryOrder[u][j] = i;
      }
   }
   return;
}

void work() {
   inputAndInit();
   for (int i = 1 ; i <= n ; i++) {
      int DP = f(i , 0);
      if (DP == inf) {
         puts("0");
      } else {
         printf("%d\n" , query[DP].se.se);
      }
   }
   return;
}

int main() {
   #ifdef multipleCase
      int nQ; in(nQ);
      while (nQ--)
         work();
   #endif
   #ifdef singleCase
      work();
   #endif
   return 0;
}

void in(int &x) {
	bool neg = false;
	register int c;
	x = 0;
	c = getchar();
	if(c == '-') {
		neg = true;
		c = getchar();
	}
	for (; c > 47 && c < 58; c = getchar())
	  x = (x << 1) + (x << 3) + c - 48;
	if (neg) x *= -1;
}


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

template <typename T>
T gcd(T x, T y)
{
    if (y == 0)
        return x;
    return gcd(y, x % y);
}

template <typename T>
T lcm(T x, T y)
{
    if (x == 0 || y == 0)
        return 0;
    return x / gcd(x, y) * y;
}

int main()
{
    int N, M;
    cin >> N >> M;
    cout << (1900 * M + 100 * (N - M)) * pow(2, M) << endl;
}


Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn mat_chars(&mut self, row: usize) -> Vec<Vec<char>> {
        (0..row).map(|_| self.chars()).collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

const INF: i64 = 1 << 60;

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    loop {
        let n: usize = sc.get();
        if n == 0 {
            break;
        }
        let a: Vec<i64> = sc.vec(n);
        let mut ans = -INF;
        let mut sum = 0;
        for i in 0..n {
            sum = max(a[i], sum + a[i]);
            ans = max(ans, sum);
        }
        println!("{}", ans);
    }
}



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

typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

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

const ll INF = 1e18;
const ll MOD = 998244353;
const ll MX = 1000001;

long double X;

void solve() {
    cin >> X;
    for (int i = -1000; i <= 1000; i++) {
        for (int j = -1000; j <= 1000; j++) {
            if (pow(i, 5) - pow(j, 5) == X) {
                cout << i << " " << j;
                return;
            }
        }
    }
}

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
    ll T = 1; // cin >> T;
    while (T--) solve();
    return 0;
    // You should actually read the stuff at the bottom
}

/* Stuff to Look For
 * -----------------
 * Int overflow, array bounds
 * Initializing all variables, avoid weird behavior
 * Edge cases(n = 0, n = 1)
 * Just return 0 after result
 */


Measured memory_bytes: 4200
import sys
 
h, w, m = map(int, input().split(' '))
H = [0 for _ in range(h+1)]
W = [0 for _ in range(w+1)]
bomb = set()
for m in range(m):
  i, j = map(int, input().split(' '))
  bomb.add((i, j))
  H[i] += 1
  W[j] += 1
  
max_h = max(H)
max_w = max(W)
target_h = [i for i, v in enumerate(H) if v == max_h]
target_w = [i for i, v in enumerate(W) if v == max_w]
 
for m in target_h:
  for n in target_w:
    if (m, n) not in bomb:
      print(max_h + max_w)
      sys.exit()
	
print(max_h + max_w - 1)

Measured memory_bytes: 176636
/**
 * ABC043 A
 *
 * @date 2020.08.22
 * @author 焼き鮭 <yaki-shake@up-tri.me>
 */

#include <iostream>
#include <string>

using std::cin;
using std::cout;
using std::endl;

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

  cout << (n * (n + 1) / 2) << endl;

  return 0;
}

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


int main(){
    int n;
    cin >> n;
    
    if (n< 1000)
        cout << "invalid input. Type an interger more than 1000";
    
    for( int i = 0; i < 10; i++){
    
        if( (n/1000) == i && (n/100)%10 == i && (n/10)%10 == i){
            cout << "Yes"<<endl;
            break;
        }
        else if ((n/100)%10 == i && (n/10)%10 == i && n%10 == i){
            cout << "Yes"<<endl;
            break;
        }
        
        if(i==9)
            cout << "No";

    }
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var NM = ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        var (N, M) = (NM[0], NM[1]);

        var A = ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();

        var Asum = A.Sum();
        var threshold = (double)Asum / (4 * M);

        var count = A.Count(x => x >= threshold);

        var ans = (M <= count) ? "Yes" : "No";

        WriteLine(ans);
    }
}


Measured memory_bytes: 28164
S = str(input())+"R"

li = [0]*len(S)
count,index = 0,0

for i in range(len(S)-1):
    if S[i]!=S[i+1] and S[i+1] == "L":
        index = i
    count += 1

    if S[i]!=S[i+1] and S[i+1] == "R":
        count_R = i-index
        count_L = count-count_R
        li[index] = (count_R//2)+(count_L//2+count_L%2)
        li[index+1] = (count_L//2)+(count_R//2+count_R%2)
        count = 0

print(' '.join(map(str,li[:len(S)-1])))

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  map<int, int> cnt;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    cnt[a[i]]++;
    if (cnt[a[i]] == 2) {
      cout << "NO" << '\n';
      return 0;
    }
  }
  cout << "YES" << '\n';
  return 0;
}

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

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

using namespace std;

int main(void){
  int n;
  int *a, buf;
  int i, cnt = 0;

  cin >> n;
  a = new int[n];
  
  rep(i, n){
    cin >> a[i];
    if( ((i+1) % 2) == 1){
      if(a[i] % 2 == 1){
        cnt++;
      }
    }
  }

  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 3520
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		int[] a = new int[9];
		for(int i=0 ; i<n;i++) {
			int x = stdIn.nextInt();
			switch(x/400) {
			case 0:a[0]++;	break;
			case 1:a[1]++;	break;
			case 2:a[2]++;	break;
			case 3:a[3]++;	break;
			case 4:a[4]++;	break;
			case 5:a[5]++;	break;
			case 6:a[6]++;	break;
			case 7:a[7]++;	break;
			}
			if(x/400>7) {
				a[8]++;
			}
		}
		int i=0;
		int range = 0;
		while(i<8) {
			if(a[i++]>0) {
				range++;
			}
		}
		int min = range;
		int max = range + a[8];
		if(range==0) {
			min = 1;
			max = a[8];
		}
		System.out.println(min+" "+max);
	}
}


Measured memory_bytes: 23124
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<set>
#include<map>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD = 1000000007;
const int INF = 2000000000;

    ll N,M;
    ll A,B,C;
    map<string,int> S;
    ll ans=0;
int main(){
    ios_base::sync_with_stdio(false);
    cin>>N;
    REP(i,N){
        string s;
        cin>>s;
        if(S.find(s)!=S.end())S[s]++;
        else S.insert({s,1});
    }
    cin>>M;
    REP(i,M){
        string s;
        cin>>s;
        if(S.find(s)!=S.end())S[s]--;
        else S.insert({s,-1});
    }
    for(auto x:S){
        if(x.second>0)ans=max(ans,(ll)x.second);
    }
    cout<<ans<<endl;
    return 0;
}


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

int N,cnt=0;

int solve(long int,int,int,int);

int main(){
  cin >> N;
  solve(0,0,0,0);
  cout << cnt << endl;
  return 0;
}


int solve(long int m,int a,int b,int c){
  if(m<=N){
    if(a*b*c>=1)cnt++;
    if(10*m+3<=N)solve(10*m+3,a+1,b,c);
    if(10*m+5<=N)solve(10*m+5,a,b+1,c);
    if(10*m+7<=N)solve(10*m+7,a,b,c+1);
  }
  return 0;
}

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

const long long int mod=1000000000+7;
bool primes[50001];
int prime[50001];
int counter=0;
void sieve()
{
	memset(primes,false,sizeof(primes));
	for(int i=2;i<50001;i++)
	{
		if(!primes[i])
		{
			prime[counter++]=i;
			for(int j=i;j<50001;j+=i)
			primes[j]=true;
		}
	}
}

int power(int x,int y)
{
	int count=0;
	long long int z=y;
	while(x>=z)
	{
		count+=(x/z);
		z*=(long long int)y;
	}
	return count;
}

int main() {
	int n;
	sieve();
	//scanf("%d",&t);
//	while(t--)
//	{
		scanf("%d",&n);
		long long int ans=1;
		for(int i=0;i<counter;i++)
		{
			int powers=power(n,prime[i]);
			if(powers==0)break;
			ans=(ans*((long long int)(powers+1)))%mod;
		}
		ans=ans%mod;
		printf("%lld\n",ans);
//	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner scan = new Scanner(System.in);
      	String x = scan.next();
      	switch(x){
          case "A":
            System.out.println("T");
            break;
          case "T":
            System.out.println("A");
            break;
          case "C":
            System.out.println("G");
            break;
          case "G":
            System.out.println("C");
            break;
        }
    }
}

Measured memory_bytes: 21332
#include <stdio.h>

int main(void)
{
	int S,h,m,s;
	scanf("%d",&S);
	h = S / 3600;
	m = (S - h * 3600) / 60;
	s = S - (h * 3600 + m * 60);
	
	printf("%d:%d:%d\n",h,m,s);
	
	return 0;
}


Measured memory_bytes: 2096
n,x,y = map(int,input().split())
ans = [0]*(n-1)
x -= 1
y -= 1
for i in range(n-1):
    for j in range(i+1,n):
        dist = min(j-i,abs(x-i)+1+abs(j-y),abs(y-i)+1+abs(j-x))
        ans[dist-1] += 1
print("\n".join(map(str,ans)))

Measured memory_bytes: 45148
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define per1(i,n) for(int i=n;i>0;i--)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll x,k,d;
    cin>>x>>k>>d;
    x=abs(x);
    if(log10(k)+log10(d)>16){
        if((k-x/d)%2) cout<<d-x%d;
        else cout<<x%d;
    }
    else if(k*d>x){
        if((k-x/d)%2) cout<<d-x%d;
        else cout<<x%d;
    }
    else{
        cout<<x-k*d;
    }
}

Measured memory_bytes: 3924
m=int(input())
dc=[]
for _ in range(m):
  d,c=map(int,input().split())
  dc.append([d,c])
ans=0
a=[]
for d,c in dc:
  ans+=c-1
  ans+=((d*c)-1)//9
  a.append((d*c)%9 if (d*c)%9!=0 else 9)
ans+=len(a)-1
ans+=((sum(a)-1)//9)
print(ans)


Measured memory_bytes: 116552
#include<cstdio>
#include<cstring>

char s[1000];

bool palindrome(int a, int b) {
  for (int i = a, j = b; i < j; i++, --j) {
    if (s[i] != s[j]) {
      return false;
    }
  }
  return true;
}

int main() {
  scanf("%s", s);
  int n = strlen(s);
  printf("%s\n", palindrome(0, n - 1) && palindrome(0, (n-1)/2-1) ? "Yes" : "No");
}


Measured memory_bytes: 128
#include<stdio.h>
int main(void){
    int a,b,c,ans;
    while(scanf("%d%d",&a,&b)!=EOF){
        ans=0;
        c=a+b;
        while(1){
            c=c/10;
            ans++;
            if(c==0){
                break;
            }
        }
        printf("%d\n",ans);
    }
    return 0;
}

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



int main(){
  char aa;
  cin >> aa;
  if('a' <= aa && aa <='z') cout << 'a' << endl;
  else cout << 'A' << endl;
}

Measured memory_bytes: 3592
#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 h, w;
    cin >> h >> w;
    vector<string> a(h);
    rep(i, h) cin >> a.at(i);
    vector<int> dellist;

    rep(i, w) {
        bool del = true;
        rep(j, h) {
            if(a.at(j).at(i) == '#') {
                del = false;
                break;
            }
        }
        if(del) {
            dellist.push_back(i);
        }
    }

    rep(i, h) {
        string s = a.at(i);
        rep(j, dellist.size()) {
            s.erase(dellist.at(j) - j, 1);
        }
        if(s.find("#") != string::npos) cout << s << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
const int INF = 1000000000;
int H, N, A[1000], B[1000], dptable[1000][10001];
int dp(int i, int j) {
	if (j <= 0) return 0;
	if (i == N) return INF;
	if (dptable[i][j] != -1) return dptable[i][j];
	return dptable[i][j] = min(dp(i + 1, j), dp(i, j - A[i]) + B[i]);
}
int main() {
	memset(dptable, -1, sizeof dptable);
	scanf("%d %d", &H, &N);
	for (int i = 0; i < N; ++i) scanf("%d %d", &A[i], &B[i]);
	printf("%d", dp(0, H));
	return 0;
}

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

int main()
{
    int n,i;
    cin>>n;
    int a[n];
    for(i=0;i<n;i++)
    cin>>a[i];
    int t[n+1];
    t[0]=0;
    t[1]=abs(a[1]-a[0]);
    for(i=2;i<n;i++)
    {t[i]=min(abs(a[i]-a[i-1])+t[i-1],abs(a[i]-a[i-2])+t[i-2]);
       // cout<<t[i]<<endl;
    }
    cout<<t[n-1]<<endl;
}

Measured memory_bytes: 4320
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){


}

Node treeSearch(Node u, int k){
  
  
}

Node treeSuccessor(Node x){
  
  
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
  
  
  
}

 
void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;
 
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
 
  while(x != NIL){
    y = x;
    if(z->key < x->key)
      x = x->left;
 
    else
      x = x->right;
  }
   
  z->parent = y;
 
  if(y == NIL)
    root = z;
 
  else if(z->key < y->key)
    y->left = z;
 
  else
    y->right = z;
}

void inorder(Node u){
  if(u!=NIL){
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
  }
}
void preorder(Node u){
  if(u!=NIL){
   
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
  }
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}

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

template <class T>
inline void read(T &res)
{
	res = 0; bool bo = 0; char c;
	while (((c = getchar()) < '0' || c > '9') && c != '-');
	if (c == '-') bo = 1; else res = c - 48;
	while ((c = getchar()) >= '0' && c <= '9')
		res = (res << 3) + (res << 1) + (c - 48);
	if (bo) res = ~res + 1;
}

const int N = 1e5 + 5;

int n, K, p[N], q[N], l[N], r[N], ip[N], iq[N], resl[N], resr[N], tmp[N], mid[N];
// f(n) = (2 -1 -2 1) + f(n - 6) + (-1 2 1 -2)
int main()
{
	read(n); read(K); int mt = K % 6; if (!mt) mt = 6;
	for (int i = 1; i <= n; i++) read(p[i]), ip[p[i]] = i;
	for (int i = 1; i <= n; i++) read(q[i]), iq[q[i]] = i;
	for (int i = 1; i <= n; i++) l[i] = q[ip[iq[p[i]]]], r[i] = ip[q[p[iq[i]]]];
	K = (K - mt) / 6; for (int i = 1; i <= n; i++) resl[i] = resr[i] = i;
	while (K)
	{
		if (K & 1)
		{
			for (int i = 1; i <= n; i++) tmp[i] = l[resl[i]];
			for (int i = 1; i <= n; i++) resl[i] = tmp[i];
			for (int i = 1; i <= n; i++) tmp[i] = r[resr[i]];
			for (int i = 1; i <= n; i++) resr[i] = tmp[i];
		}
		for (int i = 1; i <= n; i++) tmp[i] = l[l[i]];
		for (int i = 1; i <= n; i++) l[i] = tmp[i];
		for (int i = 1; i <= n; i++) tmp[i] = r[r[i]];
		for (int i = 1; i <= n; i++) r[i] = tmp[i];
		K >>= 1;
	}
	for (int i = 1; i <= n; i++)
		if (mt == 1) mid[i] = p[i];
		else if (mt == 2) mid[i] = q[i];
		else if (mt == 3) mid[i] = q[ip[i]];
		else if (mt == 4) mid[i] = q[ip[iq[i]]];
		else if (mt == 5) mid[i] = q[ip[iq[p[iq[i]]]]];
		else mid[i] = q[ip[iq[p[iq[q[p[iq[i]]]]]]]];
	for (int i = 1; i <= n; i++) printf("%d ", resl[mid[resr[i]]]);
	return puts(""), 0;
}

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

int main() {
    int n;
    cin >> n;
    pair<pair<string, int>, int> data[n];

    for (int i = 0; i < n; i++) {
        string x;
        int y, z;
        cin >> x >> y;
        z = i + 1;
        data[i] = make_pair(make_pair(x, -y), z);
    }

    sort(data, data + n);

    for (int i = 0; i < n; i++) {
        cout << data[i].second << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl
#define debugvec(v)   rep(i, v.size()) cerr << "L" << __LINE__ << ": " << #v << "[" << i << "] = " << v[i] << endl;
#define debugvec2(v)  cerr << "L" << __LINE__ << ": " << #v << " = { "; rep(i, v.size()) cerr << v[i] << (i + 1 == v.size() ? "" : ", "); cerr << " }" << endl;
typedef long long ll;  /* 10^18 くらいまでいける */

int main(){
  string s;
  cin >> s;
  deque<char> q;
  for (char c : s) q.push_back(c);
  bool flip = false;
  int q_num;
  cin >> q_num;
  rep(qi, q_num){
    int ty;
    cin >> ty;
    if (ty==1){
      flip = !flip;
    }else{
      int f; char c;
      cin >> f >> c;
      if (flip){
        f = 3-f;
      }
      if (f==1){
        q.push_front(c);
      }else{
        q.push_back(c);
      }
    }
  }
  if (flip)
    reverse(q.begin(), q.end());
  
  string ans;
  for (char c : q) ans += c;
  cout << ans << endl;
  return 0;

  return 0;
}

Measured memory_bytes: 1412
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
#include<set>
#include<queue>

using namespace std;

int main()
{
	int a,b;
	cin >> a >> b;
	b--;
	a--;
	int ans=(b+a-1)/a;
	cout << ans << endl;




}


Measured memory_bytes: 256
import sys
from bisect import bisect_right

input = sys.stdin.readline


def main():
    N = int(input())
    A = [0] * N
    for i in range(N):
        A[i] = int(input())

    A = [-a for a in A]

    colors = []
    for a in A:
        idx = bisect_right(colors, a)
        if idx == len(colors):
            colors.append(a)
        else:
            colors[idx] = a

    ans = len(colors)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 16908
#include<bits/stdc++.h>
using namespace std;
#define ll long long int

struct S{
    int w,s,v;
    bool operator <(S const &b) const {
        return (w+s<b.w+b.s);
    }

};

int main()
{
    int n;
    cin>>n;
    vector<S> boxes(n);
    int mx_cap=20005;;
    for(int i=0;i<n;i++){
        cin>>boxes[i].w>>boxes[i].s>>boxes[i].v;
        //mx_cap=max(mx_cap,boxes[i].s+boxes[i].w);

    }
    sort(boxes.begin(),boxes.end());
  vector<ll> dp(mx_cap+1,0);

  for(auto box:boxes){
     for(int cap=min(box.s,mx_cap-box.w);cap>=0;--cap){
         dp[cap+box.w]=max(dp[cap+box.w],dp[cap]+box.v);
     }
  }

       ll ans=INT_MIN;
       for(int cap=1;cap<=mx_cap;cap++){
         ans=max(ans,dp[cap]);
       }

    cout<<ans;
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
#define ll long long
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
 


int main(){
    fast;
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    
    while (a > 0 && c > 0)
    {
        c = c - b;
        if (c > 0)
        {
            a = a - d;
        }
    }
    
    if (c <= 0)
    { 
        cout << "Yes";
    } 
    if (a <= 0)
    {
        cout << "No";
    }
    return 0;
}




Measured memory_bytes: 3624
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define int long long
#define x first
#define y second
#define pb push_back
#define speed ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
template<class L,class R> ostream& operator<<(ostream& cout,pair<L, R> P)
{return cout<<'('<<P.x<<','<< P.y<<')';}
template<class T> ostream& operator<<(ostream& cout,vector<T> V)
{cout<<"[ ";for(auto v:V)cout<<v<<' ';return cout<<']';}

#define N 1000000007
inline int ex(int a, int b){
	if(b==0||a==1){return 1;}
	if(a==0||b==1){return a;}
	int tmp=ex(a,(b/2));
	if(b%2){return ((((tmp*tmp)%N)*a)%N);}
	else{return ((tmp*tmp)%N);}
}
inline int inv(int k){
	if(k==1){return 1;}
	else{return ex(k,N-2);}
}
vector<vector<int>> arr;
int NN=1000001;
void sieve(){
    
    arr.resize(NN);
    for(int i=2;i<NN;++i){
        if(arr[i].empty()){
        	for(int j=i;j<NN;j+=i)
        	{
        		arr[j].push_back(i);
        	}
        }
    }
}

vector<int> inp;
map<int,int> mp;
void fact(int num)
{
	vector<int> vec=arr[num];
	for(auto it:vec)
	{
		int tmp=0;
		while(num%it==0){++tmp;num/=it;}
		mp[it]=max(mp[it],tmp);
	}
}
signed main()
{
	speed
	int n;cin>>n;
	inp.resize(n);
	sieve();
	for (int i = 0; i < n; ++i)
	{
		cin>>inp[i];
		fact(inp[i]);
	}

	int ans=1;
	for(int i=0;i<NN;++i)
	{
		if(mp[i]==0){continue;}
		ans*=ex(i,mp[i]);
		ans%=N;
	}
	int fin=0;
	for(auto it:inp)
	{
		fin+=(ans*inv(it));
		fin%=N;
	}
	cout<<fin<<"\n";
}

Measured memory_bytes: 132736
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define rep(i, n, s) for (int i = s; i < (int)(n); i++)
#define PI 3.14159265358979323846

ll calcNumOfCombination(ll n, ll r) {
    ll num = 1;
    for (ll i = 1; i <= r; i++) {
        num = num * (n - i + 1) / i;
    }
    return num;
}

int gcd(int x, int y) { return (x % y) ? gcd(y, x % y) : y; }

int findSumDigits(int s) {
    int num = 0;
    int temp = 0;
    while (s) {
        temp = s % 10;
        num += temp;
        s = s / 10;
    }
    return num;
}

int countDivisorNum(int n) {
    int count = 0;
    for (int i = 1; i <= n; i++) {
        if (n % i == 0) {
            count++;
        }
    }
    return count;
}

int main() {
    int a, b;
    cin >> a >> b;
    int ans = a * b;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3632
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <utility>

int testcase_ends() {
  size_t n;
  scanf("%zu", &n);
  if (n == 0) return 1;

  std::vector<char> cs(n);
  for (auto& ci: cs) scanf(" %c", &ci);

  std::vector<size_t> p(26);
  for (size_t i = 0; i < n; ++i) {
    char c = cs[i];
    size_t j = c-'A';
    ++p[j];

    size_t j1 = std::max_element(p.begin(), p.end()) - p.begin();

    size_t max2 = 0;
    for (size_t k = 0; k < 26; ++k) {
      if (k == j1) continue;
      max2 = std::max(max2, p[k]);
    }
    if (p[j1] > max2+(n-i-1)) return !printf("%c %zu\n", char(j1+'A'), i+1);
  }
  puts("TIE");
  return 0;
}

int main() {
  while (!testcase_ends()) {}
}



Measured memory_bytes: 2664
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Convert;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var XY = cin.ReadIntArray(2);
			WriteLine(XY[0] + (XY[1] / 2));
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}

Measured memory_bytes: 11220
def q1():
    weekday = {
        'SUN': 7, 'MON': 6, 'TUE': 5, 'WED': 4, 'THU': 3, 'FRI': 2, 'SAT': 1}
    S = input()
    print(weekday[S])


if __name__ == '__main__':
    q1()


Measured memory_bytes: 2940
#include<iostream>
#define MOD 1000000007
using namespace std;
int memo[100005];
int dfs(int target);
int main(){
  int n,m;
  cin>>n>>m;
  for(int i=0;i<=n;i++){
    memo[i]=-1;
  }
  for(int i=0;i<m;i++){
    int index;
    cin>>index;
    memo[index]=0;
  }
  cout<<dfs(n)%MOD<<endl;
  return(0);
}

int dfs(int target){
  if(memo[target]!=-1){
    return(memo[target]);
  }
  if(target==1){
    return(1);
  }
  if(target==0){
    return(1);
  }
  return(memo[target]=(dfs(target-1)%MOD+dfs(target-2)%MOD)%MOD);
}


Measured memory_bytes: 3712
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<map>

using namespace std;

int main(){

    int N;
    cin >> N;

    unsigned long ans;

    if(N % 2 == 0) ans = N / 2 - 1;
    else ans = N / 2;

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <cstdio>
#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
using namespace std;

int main() {
	int n;
	cin >> n;
	int mx = -1000000, mn = 1000000;
	long long int sum = 0;
	REP(i, n){
		int x;
		cin >> x;
		mn = min(x, mn);
		mx = max(x, mx);
		sum += x;
	}
	cout << mn << " " << mx << " " << sum << endl;
	return 0;
}


Measured memory_bytes: 3112
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O2")
// #pragma GCC optimization ("unroll-loops")
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;
#define int ll
#define pb push_back
#define pob pop_back
#define __bp __builtin_popcount
using pii = pair<int,int>;
using pil = pair<int,ll>;
using pli = pair<ll,int>;
using pdd = pair<ld,ld>;
using vint = vector<int>;
using vll = vector<ll>;
using vpii = vector<pii>;
using vpil = vector<pil>;
using vpli = vector<pli>;
#define F first
#define S second
const int N = 2e5+5;//(1 << 18) + 5;
//const ll inf = 1e18+7;
const int Inf = 1e9+7;
const ll INF = 1e18+7;
const int Mod = 1e9+7;
const ld eps = 1e-9;
#ifndef M_PI
#define M_PI 3.1415926535
#endif

void io()
{
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cerr.tie(NULL);
//	freopen("sweets.in", "r", stdin);
//	freopen("sweets.out", "w", stdout);
//	cout << setprecision(7) << fixed;
}

int n, k;

void solve()
{
	cin >> n;
	bool ok = 0;
	int cnt = 0;
	for (int i = 0; i < n; ++i)
	{
		int x, y;
		cin >> x >> y;
		if (x == y)
		{
			++cnt;
		}
		else
		{
			if (cnt > 2)
				ok = 1;
			cnt = 0;
		}
	}
	if (cnt > 2)
		ok = 1;
	cout << (ok ? "Yes": "No") << '\n';
}

signed main()
{
	io();
	int tt = 1;
	// cin >> tt;
	while (tt--) {
		// solve();
		solve();
//		cerr << '\n';

	}
}

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

int main()
{
    int n;
    long long sum = 0;
    std::vector<int> v;
    std::cin>>n;
    v.resize(n);
    for(int i=0;i<n;i++){
        std::cin>>v[i];
        sum += v[i];
    }
    long long min_abs = 10000000000000000;
    long long cur = v[0];
    for(int i=1;i<n;i++){
        min_abs = std::min(std::abs(sum - cur*2),min_abs);
        cur += v[i];
    }
    std::cout<<min_abs<<std::endl;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n,m=0,t=0;
    cin>>n;
    for(int i=0;i<n;i++){
        int s;
        cin>>s;
        if(s%4==0)m++;
        else if(s%2==0){
            t++;
        }
    }
    if(t==0){
        if(n/2<=m)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    else{
        if((n-t+1)/2<=m)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
}


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

#define ll long long

int main() {
    ll A, B;

    scanf("%lld%lld", &A, &B);

    if(A%2 == 0 && B%2 == 1) {
        printf("%lld\n", ((B - A + 1)/2)%2);
    }
    if(A%2 == 0 && B%2 == 0) {
        printf("%lld\n", B^(((B - A)/2)%2));
    }
    if(A%2 == 1 && B%2 == 1) {
        printf("%lld\n", A^(((B - A)/2)%2));
    }
    if(A%2 == 1 && B%2 == 0) {
        if(0 < B - A - 1)printf("%lld\n", A^B^((B - A - 1)/2)%2);
        else printf("%lld\n", A^B);
    }
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <boost/multiprecision/cpp_int.hpp>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = boost::multiprecision::cpp_int;
using P = std::pair<ll, ll>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll A, V;
ll B, W;
ll T;

int main() {
  std::cin >> A >> V >> B >> W >> T;

  ll d = A-B < 0 ? B-A : A-B;

  if( d <= T*(V-W) )
    std::cout << "YES" << std::endl;
  else
    std::cout << "NO" << std::endl;

  return 0;
}

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

int main() {
  int N;

  cin >> N;

  vector<int> d(N);

  for (int i = 0; i < N; i++) {
    cin >> d.at(i);
  }

  sort(d.begin(), d.end());

  int h = 1;
  for (int i = 1; i < N; i++) {
    if (d.at(i - 1) < d.at(i)) {
      h++;
    }
  }

  cout << h << endl;
}


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

using namespace std;

int a,b;
int main()
{
   cin>>a>>b;

   if (b==1) return !printf("0\n");
   b-=a;

   if (b<=0) return !printf("1\n");
   int ans = 1;

   while(b>0)
   {
       ans++;
       b-=(a-1);
   }

   cout<<ans<<endl;
}


Measured memory_bytes: 256
void main() {
  problem();
}

void problem() {
  auto A = scan!long;
  auto B = scan!long;

  long solve() {
    return A * B;
  }

  solve().writeln;
}

// ----------------------------------------------

import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.math, std.typecons, std.numeric;
T[][] combinations(T)(T[] s, in int m) {   if (!m) return [[]];   if (s.empty) return [];   return s[1 .. $].combinations(m - 1).map!(x => s[0] ~ x).array ~ s[1 .. $].combinations(m); }
string scan(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T scan(T)(){ return scan.to!T; }
T[] scan(T)(int n){ return n.iota.map!(i => scan!T()).array; }
void deb(T ...)(T t){ debug writeln(t); }
alias Point = Tuple!(long, "x", long, "y");

// -----------------------------------------------


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

int main(){
	int n, W;
  	cin>>n>>W;
  	long long v[101], w[101];
  	for(int i=1;i<=n;i++) cin>>w[i]>>v[i];
  	
  	long long dp[101][100001] = {0};
  
  
  	for(int i=1;i<=n;i++){
      for(int j=1;j<=W;j++){
        if(j - w[i]>=0)
        	dp[i][j] = max(dp[i-1][j], dp[i-1][j-w[i]]  + v[i]);
        else dp[i][j] = dp[i-1][j];
      }
    }
  	
  
  
  	cout<<dp[n][W]<<endl;
  	
  return 0;
}

Measured memory_bytes: 79104
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <algorithm>
#include <cstring>
#define N 100000
using namespace std;

int main() {
  char a[3];
  int b=0,c=0,d=0;
  for(int i = 0;i < 3;i++)
    cin >> a[i];
  for(int i = 0;i < 3;i++){
    if(a[i] == 'a')
      b = 1;
    if(a[i] == 'b')
      c = 1;
    if(a[i] == 'c')
      d = 1;
  }
  if((b+c+d) == 3)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

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

int main()
{
	int x1,y1,x2,y2;
	int x3,y3,x4,y4;
	int dx,dy;
	cin >> x1 >> y1 >> x2 >> y2;
	dx=x2-x1;
	dy=y2-y1;
	x3=x2-dy;
	y3=y2+dx;
	x4=x3-dx;
	y4=y3-dy;
	cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long x,a,b,c,ans=0;
    cin>>a>>b>>c>>x;
    for(int i=0;i<=a;i++)
        for(int j=0;j<=b;j++)
            for(int z=0;z<=c;z++)
                if(i*500+j*100+z*50==x)ans++;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
 
using namespace std;

 
const int MAX_N = int(1e6) + 10;
const long long int MOD=1e9+7;
const long long int INF=1e18;
 
typedef long long int ll;
typedef unsigned long long int llu;
 
 
 
inline ll mul(ll a,ll b){
 
    a=(a+MOD)%MOD;
    b=(b+MOD)%MOD;
    ll c=a*b;
    c=(c+MOD)%MOD;
    return c;
}
inline ll add(ll a,ll b){
    a=(a+MOD)%MOD;
    b=(b+MOD)%MOD;
    ll ans=(a+b);
    ans=(ans+MOD)%MOD;
    return ans;
}
ll power(ll a,ll b,ll c=0){
    ll ans=1;
    while(b){
        if(b&1){
            ans=mul(ans,a);
        }
        a=mul(a,a);
        b=b/2;
    }
    return ans;
}
 
  
 
 
#define all(x) (x).begin(),(x).end()




//s.reserve(32768); //updated !
//s.max_load_factor(0.25);














int main(){

    int n;
    cin>>n;

    ll ans=0;
    for(int i=1;i<=n;i++){
        int x=n/i;
        if(x%2==0)ans+=i*1LL*(x/2LL)*1LL*(x+1);
        else ans+=i*1LL*((x+1)/2LL)*1LL*(x);
    }

    cout<<ans;
   
   
   
    
}


 
    



    



    
    
    




    


    

    






    
    

    
 
    
 

 
 
    
 
 


Measured memory_bytes: 3576
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.Closeable;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Random;

public class Main {
	static ContestScanner in;
	static Writer out;
	public static void main(String[] args) {
		Main main = new Main();
		try {
			in = new ContestScanner();
			out = new Writer();
			main.solve();
			out.close();
			in.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	void solve() throws IOException {
		char[] s = in.nextToken().toCharArray();
		int ans = s.length;
		for(int i = 0; i < 26; i++) {
			ans = Math.min(ans, set(s.clone(), (char)(i + 'a')));
		}
		System.out.println(ans);
	}
	
	int set(char[] s, char c) {
		boolean ok = true;
		for(int i = 0; i < s.length; i++) {
			if(s[i] != c) ok = false;
		}
		if(ok) return 0;
		for(int i = 0; i < s.length; i++) {
			ok = true;
			for(int j = 0; j < s.length - i - 1; j++) {
				if(s[j + 1] == c) s[j] = c;
				if(s[j] != c) ok = false;
			}
			if(ok) return i + 1;
		}
		return s.length - 1;
	}
}

class Writer extends PrintWriter{
	public Writer(String filename)throws IOException
	{super(new BufferedWriter(new FileWriter(filename)));}
	public Writer()throws IOException{super(System.out);}
}
class ContestScanner implements Closeable{
	private BufferedReader in;private int c=-2;
	public ContestScanner()throws IOException 
	{in=new BufferedReader(new InputStreamReader(System.in));}
	public ContestScanner(String filename)throws IOException
	{in=new BufferedReader(new InputStreamReader(new FileInputStream(filename)));}
	public String nextToken()throws IOException {
		StringBuilder sb=new StringBuilder();
		while((c=in.read())!=-1&&Character.isWhitespace(c));
		while(c!=-1&&!Character.isWhitespace(c)){sb.append((char)c);c=in.read();}
		return sb.toString();
	}
	public String readLine()throws IOException{
		StringBuilder sb=new StringBuilder();if(c==-2)c=in.read();
		while(c!=-1&&c!='\n'&&c!='\r'){sb.append((char)c);c=in.read();}
		return sb.toString();
	}
	public long nextLong()throws IOException,NumberFormatException
	{return Long.parseLong(nextToken());}
	public int nextInt()throws NumberFormatException,IOException
	{return(int)nextLong();}
	public double nextDouble()throws NumberFormatException,IOException 
	{return Double.parseDouble(nextToken());}
	public void close() throws IOException {in.close();}
}

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

int n;
vector<int> x, y;

int main() {
    cin >> n;
    x.resize(n), y.resize(n);
    for (int i = 0; i < n; i++) {
        cin >> x[i] >> y[i];
        x[i]--, y[i]--;
    }
    vector<vector<int>> x_fiber(1e5), y_fiber(1e5);
    for (int i = 0; i < n; i++) {
        x_fiber[x[i]].push_back(i);
        y_fiber[y[i]].push_back(i);
    }
    vector<bool> x_visited(1e5, false);
    vector<bool> y_visited(1e5, false);
    lint ans = 0;
    for (int i = 0; i < n; i++) {
        if (x_visited[x[i]] || y_visited[y[i]]) {
            continue;
        }
        set<int> used;
        set<int> x_set, y_set;
        queue<int> bfs;
        bfs.push(i);
        while (!bfs.empty()) {
            int now = bfs.front();
            bfs.pop();
            used.insert(now);
            x_set.insert(x[now]);
            y_set.insert(y[now]);
            if (!x_visited[x[now]]) {
                x_visited[x[now]] = true;
                for (auto e : x_fiber[x[now]]) {
                    bfs.push(e);
                }
            }
            if (!y_visited[y[now]]) {
                y_visited[y[now]] = true;
                for (auto e : y_fiber[y[now]]) {
                    bfs.push(e);
                }
            }
        }
        if (x_set.size() <= 1 || y_set.size() <= 1) {
            continue;
        }
        lint plus = (lint)x_set.size() * (lint)y_set.size();
        ans += plus - (lint)used.size();
    }
    cout << ans << endl;
}

Measured memory_bytes: 21224
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(long i = 0; i < n; i++)
#define erep(i, n) for(long i = 1; i <= n; i++)
const long MOD = 1000000007;

int main(){long N, M;
cin >> N >> M;
long ans;
if(M <= 2 * N){
    ans = M / 2;
}
else{
    ans = N + (M - 2 * N) / 4;
}


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




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

#define ll  int
#define intmax INT_MAX
#define pi 3.14159265358979323846
#define ff first 
#define ss second
#define pb push_back
#define watch(x) cerr<<(#x)<<"  "<<x<<"\n";
const int MOD=998244353;
const int MAXN = 1e2+4,W=1e5+3;
long long dp[MAXN][W],w[MAXN],v[MAXN],wt;

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

int n; cin>>n>>wt;
for(int i=1;i<=n;i++)cin>>w[i]>>v[i];

for(int i=1;i<=n;i++){
	for(int j=1;j<=wt;j++){
          if(w[i]<=j) dp[i][j]=max(dp[i-1][j-w[i]]+v[i],dp[i-1][j-1]);
          else dp[i][j]=dp[i-1][j];
  }
}
cout<<dp[n][wt]<<"\n";

return 0;
}


Measured memory_bytes: 81700