akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int H = scan.nextInt();
        int W =scan.nextInt();
        String str = scan.nextLine();
        String[][] board = new String[H][W];
        for (int i = 0; i < H; i++) {
            String line_i = scan.nextLine();
            board[i] = line_i.split("");         
        }
        scan.close();
        for (int i = 0 ; i < H; i++) {
            Boolean checker = false;
            for (int j=0 ; j < W && !checker; j++) {
                if (board[i][j].getBytes()[0] == "#".getBytes()[0] ) {
                    checker = true;
                    break;
                }
            }            
            if (!checker) {
                H--;
                for (int w = i; w < H; w++) {
                    board[w] = board[w+1];
                }
                i--;
            }            
        }for (int j = 0; j < W; j++) {
            Boolean checker = false;
            for (int i = 0; i < H && !checker; i++) {
                if (board[i][j].getBytes()[0] == "#".getBytes()[0] ) {
                    checker = true;
                    break;
                }                
            }            
            if (!checker) {
                W--;
                for (int i = 0; i < H; i++) {
                    for (int k = j; k < W; k++) {
                        board[i][k] = board[i][k+1];
                    }
                }
                j--;
            }
            
        }

        for (int i = 0; i < H; i++) {
            for (int j=0; j < W;j++) {
                System.out.print(board[i][j]);
            }
            System.out.println();
        }
        
    }
}

Measured memory_bytes: 40112
#include <iostream>
#include <queue>
#include <string>
#define rep(i,n) for(int (i)=0;(i)<(n);++(i))
using namespace std;


int main()
{
	int n; cin >> n;
	int t; cin >> t;
	queue<pair<int,string>> p;
	rep(i,n)
	{
		string s;cin>>s;
		int x;cin>>x;
		p.push(make_pair(x,s));
	}
	int now=0;
	while (p.size()!=0)
	{
		p.front().first-=t;
		if(p.front().first<=0)
		{
			now += t + p.front().first;
			cout<<p.front().second<<" "<<now<<endl;
			p.pop();
		}
		else
		{
			now+=t;
			pair<int, string> x=p.front();
			p.pop();
			p.push(x);
		}
	}
	return 0;
}


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

vector<int> pi;

int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		int p;
		cin>>p;
		pi.push_back(p);
	}
	int count=0;
	for(int j=0;j<n;j++){
		if(pi[j]!=j+1)count++;
	}
	if(count<=2)cout<<"YES";
	else cout<<"NO";
}

Measured memory_bytes: 3560
#include<algorithm>
#include <iostream>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<string>
#include<cstdlib>
#include<ctime>
#include<vector>
#include<map>
using namespace std;

int main(){
//srandom((unsigned long)time(NULL));

//5no倍数
// 7 amari 2
//3nobaisuu
//6amari2
//dottikaga%=0katuC!=0,  a%b==a nozoku
int a,b,c;
cin>>a>>b>>c;
if(a==1){
    cout<<"YES"<<endl;
    return 0;
}

int x=1;
if(a%b==0){
    if(c!=0)x=0;
}
if(b%a==0){
    if(c!=0 && a%b!=a)x=0;
}

for(int i=2;i<a+1;i++){
    if(a%i==0){
        if(b%i==0){
            if(c%i!=0)x=0;
        }
    }
}

if(x==0)cout<<"NO"<<endl;
else cout<<"YES"<<endl;


return 0;
}

Measured memory_bytes: 256
s1,s2,s3=input().split()
a=str(s1)
b=str(s2)
c=str(s3)
A=a[0]
B=b[0]
C=c[0]
x=chr(ord(A)-32)
y=chr(ord(B)-32)
z=chr(ord(C)-32)
ans=x+y+z
print(ans)

Measured memory_bytes: 3064
/*input
2
100
200



*/

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

#define rep(i,j,n) for(i=j;i<n;i++)
#define repi(i,j,n) for(i=j;i>n;i--)
#define inf 100001
#define M 1000000007
#define ll long long
#define vll vector<long long>
#define vi vector<int>
#define pll pair<long long,long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define vpll vector<pair<long long,long long> >
#define pb push_back
#define pf pop_front
#define mp make_pair
#define F first
#define S second

using namespace std;
using namespace __gnu_pbds; 

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


ll power(ll a,ll m,ll mod){
	ll ans=1;
	while(m){
		if(m%2){
			ans*=a;
			ans%=(mod);
		}
		a=(a*a)%(mod);
		m>>=1;
	}
	return ans;
}


void init(long long* a,long long n,long long val){
	for(long long i=0;i<n;i++)
		a[i]=val;
}



int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);	
	ll h,w,n;
	cin>>h>>w>>n;
	cout<<ceil((double)n/max(h,w));
	return 0;
}




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

int ut[100002];
long long int utc[100002];
int f1(int n){
	while(n!=ut[n]){
		n=ut[n];
	}
	return n;
}
void f2(int t,int n){
	while(t!=ut[t]){
		int t1=ut[t];
		ut[t]=n;
		t=t1;
	}
	ut[t]=n;
}


int main() {
	// your code goes here
	int n,m;
	std::vector<int> from1,to1;
	std::vector<long long int> ans;
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int a,b;
		cin>>a>>b;
		from1.push_back(a);
		to1.push_back(b);
	}
	for(int i=1;i<=n;i++){
		ut[i]=i;
		utc[i]=1;
	}
	long long int t=0;
	for(int i=m-1;i>=0;i--){
		ans.push_back(t);
		int t1=f1(from1[i]);
		int t2=f1(to1[i]);
		if(t1!=t2){
			t+=utc[t1]*utc[t2];
			utc[t1]+=utc[t2];
			f2(from1[i],t1);
			f2(to1[i],t1);
		}
		
	}
	long long int all=(((long long int)n)*(n-1))/2;
	for(int i=m-1;i>=0;i--){
		cout<<all-ans[i]<<"\n";
	}
	return 0;
}

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

int main(){
  int h, n;
  cin >> h >> n;
  int count = 0;
  std::vector<int> a(n);
  for (int i = 0; i < n; i++) {
    std::cin >> a.at(i);
    count += a.at(i);
  }
  if (count >= h) {
    std::cout << "Yes" << '\n';
  }
  else{
    std::cout << "No" << '\n';
  }
  return 0;
}


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

using namespace std;

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

	string ans="No";
	if(s[0]==s[1] && s[2]==s[3] && s[0]!=s[2]) ans="Yes";
	if(s[0]==s[3] && s[1]==s[2] && s[0]!=s[1]) ans="Yes";
	if(s[0]==s[2] && s[1]==s[3] && s[0]!=s[1]) ans="Yes";
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int n,S[500000],count=0,i,a[500000];
int MergeSort(int S[],int left,int right);
int main()
{
	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%d",&S[i]);
	MergeSort(S,0,n-1);
	for(i=0;i<n;i++){
		printf("%d",S[i]);
		if(i<n-1)
		printf(" ");
	}
	printf("\n%d\n",count);
	return 0;
}
int MergeSort(int S[],int left,int right)
{
	int mannaka,j,k;
	if(left>=right)
		return S[n];
	mannaka=(left+right)/2;
    MergeSort(S,left,mannaka);        
    MergeSort(S,mannaka+1,right);   
    for(i=left;i<=mannaka;i++)
        a[i]=S[i];
    for(i=mannaka+1,j=right;i<=right;i++,j--)
        a[i]=S[j];
	i=left;
    j=right; 
    for(k=left;k<=right;k++){
		count++;
        if (a[i]<=a[j])      
            S[k]=a[i++];
        else
            S[k]=a[j--];
	}
}

Measured memory_bytes: 4936
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int gcd(int x, int y) {
    if(y == 0) {
        return x;
    }

    return gcd(y, x%y);
}

int main() {
    int n, k;
    cin >> n >> k;
    int a[n];
    rep(i, n) {
        cin >> a[i]; 
    }
    sort(a, a+n);

    if(a[n-1] < k) {
        cout << "IMPOSSIBLE" << endl;
        return 0;
    }
    else {
        int g = a[0];
        for(int i = 1; i < n; i++) {
            g = gcd(g, a[i]);
        }

        if(k%g == 0) {
            cout << "POSSIBLE" << endl;
            return 0;
        }
        else {
            cout << "IMPOSSIBLE" << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 2100100100;
const int MOD = 1e9 + 7;

ll N, M, K, Q;
string S;

using P = pair<int, int>;
int main() {
    cin >> N;
    vector<int> a(N);
    vector<P> ans;
    int id = 0;
    int absmax = 0;
    for (int i = 0; i < N; i++) {
        cin >> a.at(i);
        if (chmax(absmax, abs(a[i]))) {
            id = i;
        }
    }

    if (a[id] > 0) {
        for (int i = 0; i < N; i++) {
            ans.push_back(make_pair(id + 1, i + 1));
        }
        for (int i = 0; i < N - 1; i++) {
            ans.push_back(make_pair(i + 1, i + 2));
        }
    } else {
        for (int i = 0; i < N; i++) {
            ans.push_back(make_pair(id + 1, i + 1));
        }
        for (int i = N - 1; i > 0; i--) {
            ans.push_back(make_pair(i + 1, i));
        }
    }

    cout << (int)ans.size() << endl;
    for (auto p : ans) {
        cout << p.first << " " << p.second << endl;
    }
}


Measured memory_bytes: 256
package main

import "fmt"

/*
 <url:http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_5_A&lang=jp>
 */

func init() {
}

func main() {
	for {
		var H, W int
		fmt.Scanf("%d %d", &H, &W)
		if H == 0 && W == 0{
			break
		}
		for i := 0; i < H; i++ {
			for j := 0; j < W; j++ {
				fmt.Print("#")
			}
			fmt.Print("\n")
		}
		fmt.Print("\n")
	}
}

Measured memory_bytes: 1124
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+10;
ll a[N];
ll b[N];
ll tot1,tot2,k;
ll num(ll x){
    ll cnt=0;
    int l=0,r=tot1-1;
    while(l<r){
        while(l<r&&a[l]*a[r]>x)--r;
        cnt+=r-l++;
    }
    l=0,r=tot2-1;
    while(l<r){
        while(l<r&&b[l]*b[r]>x)--r;
        cnt+=r-l++;
    }
    if(x>=0)return cnt+tot1*tot2;
    x=-x;
    l=0;r=tot2-1;
    while(l<tot1){
        while(r>=0&&a[l]*b[r]>=x)--r;
        cnt+=tot2-r-1;
        ++l;
    }
    return cnt;
}
int main(){
    int n;
    cin>>n>>k;
    for(int i=0;i<n;++i){
        ll tmp;
        cin>>tmp;
        if(tmp<0)a[tot1++]=-tmp;
        else b[tot2++]=tmp;
    }
    sort(a,a+tot1);
    sort(b,b+tot2);
    ll l=-1e18-1,r=1e18+1;
    while(l<r){
        ll mid=(l+r)>>1;
        if(num(mid)>=k)r=mid;
        else l=mid+1;
    }
    printf("%lld",l);
    return 0;
}

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

#define mp make_pair
#define F first
#define S second
#define B begin
#define E end
#define PB push_back
#define endl "\n"

#define FORS(i, j, k, step) for (int i=j; i<k; i+=step)
#define FOR(i, j, k) for (int i=j; i<k; i++) 
#define RFORS(i, j, k, step) for (int i=j; i>=k; i-=step)
#define RFOR(i, j, k, step) for(int i=j; i>=k; i--)
#define REP(i, k) for(int i = (0); i < (k); i++ )
#define RREP(i, k) for(int i = j; i >= (k); i-- )

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

template<typename T>
void read_vec(vector<T>& v, int n){
    T tmp;
    REP(i, n){
        cin>>tmp;
        v.push_back(tmp);
    }
}

void solve(){
	int n;
	cin>>n;

	vi d1, d2;

	int x, y;
	REP(i, n){
		cin>>x>>y;
		d1.PB(x);
		d2.PB(y);
	}

	for(int i =0; i< n-2; i++){
		if(d1[i] == d2[i] && d1[i+1] == d2[i+1] && d1[i+2] == d2[i+2]){
			cout<<"Yes"<<endl;
			return;
		}
	}
	
	cout<<"No"<<endl;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int TC =1;
    //cin>>TC;

    REP(tc, TC){
    	solve();
    }

}

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

using namespace std;

int main(void) {
    string s;
    int cnt[30] = {};
    bool flag = true;
    cin >> s;
    for (int i = 0; i < s.size(); i++) {
        cnt[s[i] - 'a']++;
        if (cnt[s[i] - 'a'] >= 2) flag = false;
    }

    if (flag) cout << "yes\n";
    else cout << "no\n";
    return 0;
}

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

using namespace std;

const int Maxn = 2010;
const int Inf = 0x7fffffff;

int n , k , tot , sum;
int last[Maxn];

struct Edge {
	int fm;
	int to;
	int next;
} e[Maxn<<1];

inline void add(int u , int v) {
	e[++tot] = { u , v , last[u] };
	last[u] = tot;
}

inline void dfs(int x , int fa , int dep) {
	
	if(dep > (k>>1))	return ;
	
	sum ++;
	for(register int i=last[x]; i; i=e[i].next) {
		register int son = e[i].to;
		if(son == fa)	continue;
		dfs(son,x,dep+1);
	}
	
}

int main() {
	
	scanf("%d%d",&n,&k);
	for(register int i=1,x,y; i<n; i++) {
		scanf("%d%d",&x,&y);
		add(x,y);
		add(y,x);
	}
	
	register int minl = Inf;
	if(!(k&1)) {
		for(register int i=1; i<=n; i++) {
			sum = 0;
			dfs(i,0,0);
			minl = min(minl,n-sum);
		}
	}
	else {
		for(register int i=1; i<n; i++) {
			sum = 0;
			dfs(e[i].fm,e[i].to,0);
			dfs(e[i].to,e[i].fm,0);
			minl = min(minl,n-sum);
		}
	}
	
	printf("%d\n",minl);
	
	return 0;
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    //*
    int a, b;
    cin >> a >> b ;
    //*/

    /*
    vector<int> vec(3);
    cin >> vec.at(0) >> vec.at(1) >> vec.at(2) ;
    
    sort(vec.begin(), vec.end());
    */
    
    /*
    if( a % b == 0 ){
        cout << 0 << endl;
    } else {
        cout << 1 << endl;
    }
    */
    
    cout << a - b + 1 << endl;

    return 0; 
}


Measured memory_bytes: 3560
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
#define forn(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define fore(i,b,a)for(int i=(b),_a=(a);i>=_a;i--)
#define rep(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define vi vector<int>
#define vpii vector<pii>
#define m_p make_pair
#define re return
#define pb push_back
#define si set<int>
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
#define mod 1000000007
#define INF 1000000007
#define x1 XZVJDFADSPFOE
#define y1 GASDIJSLDAEJF
#define x2 DFDAJKVOHKWIW
#define y2 PSFSAODSXVNMQ
#define LLINF 0x3f3f3f3f3f3f3f3fLL
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
ll quickpower(ll n,ll k){
	ll ans=1;
	while(k){
		if(k%2){
			ans*=n;
			ans%=mod;
		}
		n*=n;
		n%=mod;
		k/=2;
	}
	return ans;
}
string int_to_string(int n)
{
	string s="";
	while(n)
	{
		int now=n%10;
		s+=now+'0';
		n/=10;
	}
	reverse(s.begin(),s.end());
	return s;
}
int string_to_int(string s)
{
	int n=0;
	rep(i,s.size())
	{
		n*=10;
		n+=s[i]-'0';
	}
	return n;
}
int main()
{
	ios::sync_with_stdio(0);
	//think twice,code once
	ll a,b,n;
	cin>>a>>b>>n;
	ll use=min((b-1),n);
	cout<<(a*use/b)<<endl;
	return 0;
}



Measured memory_bytes: 3640
#include<iostream>
#include<string>
int main(){
        std::string S;
        std::cin >> S;
        if(S[0]==S[1] && S[2] == S[3] && S[1] != S[2]) std::cout << "Yes";
        else if(S[0]==S[3] && S[2] == S[1] && S[3] != S[2]) std::cout << "Yes";
        else if(S[0]==S[2] && S[1] == S[3] && S[0] != S[1]) std::cout << "Yes";
        else std::cout <<"No";
}

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

bool pal(long int i)
{
	long int other=0,temp=i,j;
         vector <int >v1,v2;
         while(temp!=0)
           {
           	  v1.push_back(temp%10);
           	  temp/=10;
           }
         for(j=v1.size()-1;j>=0;j--)
           {
           	  v2.push_back(v1[j]);
           }
         if(v1==v2)
           return true;
         else
           return false;
}

int main() {
	long int a,b,i;
	cin>>a>>b;
	long int count=0;
	for(i=a;i<=b;i++)
	  {
	     if(pal(i)==true)
	       ++count;
	  }
	cout<<count<<"\n";  
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
//#pragma GCC target("avx2")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << "\n";
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

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

    int h, w; cin >> h >> w;
    vector<string> m(h);
    REP(i, h) cin >> m[i];

    auto f = [&](int y, int x) -> int {
        int cnt = 0;
        FOR(i, -1, 2) FOR(j, -1, 2) {
            if (i == 0 && j == 0) continue;
            int cy = y + i, cx = x + j;
            if (cy < 0 || cy >= h || cx < 0 || cx >= w) continue;
            cnt += m[cy][cx] == '#';
        }

        return cnt;
    };

    REP(i, h) {
        REP(j, w) {
            if (m[i][j] == '#') cout << "#";
            else cout << f(i, j);
        }
        cout << endl;
    }
}

Measured memory_bytes: 3588
package main

import (
	"bufio"
	"fmt"
	"os"
)

var rdr = bufio.NewReader(os.Stdin)

func myReadLine() string {
	buf := make([]byte, 0, bufio.MaxScanTokenSize)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func calc(sa string, sb string, sc string) string {
	result := "a"
	for {
		if result == "a" {
			if sa == "" {
				return "A"
			}
			result = sa[:1]
			sa = sa[1:]
		} else if result == "b" {
			if sb == "" {
				return "B"
			}
			result = sb[:1]
			sb = sb[1:]
		} else if result == "c" {
			if sc == "" {
				return "C"
			}
			result = sc[:1]
			sc = sc[1:]
		}
	}
}

func main() {
	sa := myReadLine()
	sb := myReadLine()
	sc := myReadLine()
	fmt.Printf("%v\n", calc(sa, sb, sc))
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
const int maxn=100005;
const int inf=0x3f3f3f3f;
int n,m,used[maxn],mmin[maxn],id[maxn],a[maxn];
vector<int> G[maxn];
void dfs(int u,int f,int cc) {
    used[u]=cc;
    if (a[u]<mmin[cc]) {
        mmin[cc]=a[u];
        id[cc]=u;
    }
    for (int i=0;i<(int)G[u].size();++i) {
        int v=G[u][i];
        if (v==f)
            continue;
        dfs(v,u,cc);
    }
}
int main()
{
    scanf("%d%d",&n,&m);
    for (int i=0;i<n;++i)
        scanf("%d",&a[i]);
    while (m--) {
        int u,v;
        scanf("%d%d",&u,&v);
        G[u].push_back(v);
        G[v].push_back(u);
    }
    memset(used,-1,sizeof used);
    memset(mmin,0x3f,sizeof mmin);
    int cc=0,cnt=0;
    for (int i=0;i<n;++i)
        if (!(~used[i]))
            dfs(i,-1,++cc);
    if (cc==1)
        return 0*puts("0");
    long long res=0;
    for (int i=1;i<=cc;++i)
        res+=mmin[i],a[id[i]]=inf,++cnt;
    sort(a,a+n);
    for (int i=0;i<n;++i)
        if (a[i]!=inf&&cnt<cc+cc-2)
            res+=a[i],++cnt;
    if (cnt<cc+cc-2)
        return 0*puts("Impossible");
    cout<<res<<endl;
    return 0;
}


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

int main() {
  string s;
  cin >> s;
  int ans = -1, ans2 = -1;
  rep(i, s.length()) {
    if (i + 1 > s.length()) break;
    if (s[i] == s[i + 1]) ans = i + 1, ans2 = i + 2;
    if (i + 2 > s.length()) break;
    if (s[i] == s[i + 2]) ans = i + 1, ans2 = i + 3;
  }
  cout << ans << " " << ans2 << endl;
}

Measured memory_bytes: 512
from collections import Counter

n,m = map(int,input().split())

class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.rank = [0] * (n)
        self.size = [1] * (n)
    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]
    # 併合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self.size[y] += self.size[x]
        else:
            self.par[y] = x
            self.size[x] += self.size[y]
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
    # 同じ集合に属するか判定
    def same(self, x, y):
        return self.find(x) == self.find(y)
    # すべての頂点に対して親を検索する
    def all_find(self):
        for n in range(len(self.par)):
            self.find(n)

uf = UnionFind(n)

for _ in range(m):
    x,y,z = map(int,input().split())
    x -= 1
    y -= 1
    uf.union(x,y)

root = set([])

for i in range(n):
    root.add(uf.find(i))

print(len(root))

Measured memory_bytes: 17892
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

int main(void)
{
    int n, k, q;
    cin >> n >> k >> q;
    int a[n];
    REP(i, n)
    {
        a[i] = k - q;
    }

    REP(i, q)
    {
        int t;
        cin >> t;
        t--;
        a[t]++;
    }
    REP(i, n)
    {
        if (a[i] > 0)
        {
            Yes(1);
        }
        else
        {
            Yes(0);
        }
    }
}

Measured memory_bytes: 1024
#include<stdio.h>
#define N 100

int main(){

  int i,j,k,l,n;
  int p[N],M[N][N];

  scanf("%d",&n);

  for(i=1;i<=n;i++){
    scanf("%d%d",&p[i-1],&p[i]);
  }

  for(i=1;i<=n;i++) {
    M[i][i]=0;
  }

  for(l=2;l<=n;l++){
    for(i=1;i<=(n-l)+1;i++){
      j=i+l-1;
      M[i][j]=(1<<21);
    for(k=i;k<=j-1;k++){
      if(M[i][j]>M[i][k]+M[k+1][j]+p[i-1]*p[k]*p[j])
      M[i][j]=M[i][k]+M[k+1][j]+p[i-1]*p[k]*p[j];
      }
    }
  }
  printf("%d\n",M[1][n]);
  return 0;
}



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

int main(){
    int n;
    vector<int> v;
    
    for(unsigned int i = 0;i < 5;i++){
        cin >> n;
        v.push_back(n);
    }
    
    sort(v.begin(), v.end(), greater<int>());
    
    for(int i = 0;i < v.size()-1;i++){
        cout << v.at(i) << " ";
    }cout << v.at(v.size()-1) << endl;
}

Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++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; }
typedef long long ll;
const long long INF = 1LL << 60;


int main(){
   int n; cin >> n;
   vector<ll> a(n),s(n+1,0),t(n+1,0);
   ll sum = 0;
   REP(i,n) cin >> a[i];
   
   for(int i = 0; i < n; ++i) s[i+1] = s[i] + a[i];
   for(int i = n-1; i >= 0; --i) t[n - i] = t[n - i - 1] + a[i];

   ll ans = INF;
   for(int i = 1; i < n; ++i){
       chmin(ans,abs(s[i]-t[n-i]));
   }
   cout << ans << endl;
   
}

Measured memory_bytes: 4992
#21:25
n,m,t = map(int,input().split())
arrive_time = list(map(int,input().split()))

#
list_time = [0]*(t+m+1)

for i in arrive_time:
    # out of bounsの場合どうしよう
    list_time[i-m] += 1
    list_time[i+m] -= 1

for i in range(1,t):
    list_time[i] += list_time[i-1]

print(sum(x==0 for x in list_time[:t]))



Measured memory_bytes: 5736
n, x = map(int, input().split())

a, p = [1], [1]
for i in range(n):
  a.append(a[i] * 2+3) 
  p.append(p[i] * 2+1) 
  
def f(n,x):
  if n == 0:
    return 0 if x <= 0 else 1
  elif x <= 1 + a[n-1]:
    return f(n-1, x-1)
  else:
    return p[n-1] + 1 + f(n-1, x-2-a[n-1])
    
    
print(f(n, x))

Measured memory_bytes: 3064
#include <cstdio>
#include <algorithm>
#include <iostream>
using namespace std;
int c[2][111];
int m[2];
int main(void)
{
  while(1){
    int n;
    cin >> n;
    if(!n) break;
    for(int i = 0; i < n; i++){
      cin >> c[0][i];
    }
    sort(c[0],c[0]+n);
    m[0] = 0,m[1] = 0;
    for(int i = 1; i <= 2 * n; i++){
      if(c[0][m[0]] == i){
	m[0]++;
      }else{
	c[1][m[1]] = i;
	m[1]++;
      }
    }

    int p = 0;
    int trash = 0;
    while(m[0] && m[1]){
      int i;
      for(i = 0; i < n; i++){
	if(c[p][i] > trash){
	  m[p]--;
	  trash = c[p][i];
	  c[p][i] = -1;
	  break;
	}
      }
      if(i == n){
	trash = 0;
      }
      p = (p+1)%2;
    }
    cout << m[1] << endl << m[0] << endl;
   }
}

Measured memory_bytes: 1180
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <deque>
#include <string.h>
using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

int N, K;
const int MAX_N = 100000;
ll a[MAX_N];

int main(){
  cin >> N >> K;
  REP(i, N) cin >> a[i];
  
  ll sum = 0;
  REP(i, N) {
    if(a[i] > 0) sum += a[i];
  }

  ll b[N - K + 1], x[N - K + 1];

  ll cb = 0, cx = sum;
  REP(i, N - K + 1) {
    if(i == 0) {
      REP(j, K) {
        cb += a[j];
        if(a[j] > 0) cx -= a[j];
      }
      b[i] = cb;
      x[i] = cx;
    } else {
      cb += a[i + K - 1] - a[i - 1];
      b[i] = cb;
      if(a[i + K - 1] > 0) cx -= a[i + K - 1];
      if(a[i - 1] > 0) cx += a[i - 1];
      x[i] = cx;
    }
  }

  ll ans = 0;
  REP(i, N - K + 1) {
    // cout << b[i] << ", " << x[i] << endl;
    ans = max(ans, x[i]);
    ans = max(ans, x[i] + b[i]);
  }

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 2560
#include<iostream>
using namespace std;
long long min(long long a,long long b)
{
  return (a<b)?a:b;
}
int main()
{
  long long a,b,c;
  cin>>a>>b>>c;
  cout<<min(min(a+b,a+c),b+c);
  return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
  int n;
  cin >> n;
  int h[n];
  int ans=0;
  for(int i=0;i<n;i++){
    cin >> h[i];
  }
  for(int i=0;i<n;i++){
    int a=1;
    for(int j=0;j<i;j++){
      if(h[j]> h[i]){
        a=0;
        break;
      }
    }
    if(a==1) ans++;
  }

  cout << ans << endl;
}


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

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

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

    ofstream w_file("output.txt", ios::out);

    ll N, T;
    cin >> N >> T;
    vector<pair<ll, ll>> dish(N);
    Rep (i, N) {
        ll A, B;
        cin >> A >> B;
        dish[i] = make_pair(A, B);
    }


    vector<vector<ll>> prev(N+1, vector<ll>(T+1, 0));
    vector<vector<ll>> dp(N+1, vector<ll>(T+1, 0));
    Rep (i, N) {
        ll a = dish[i].first, b = dish[i].second;
        Rep (j, T+1) {
            if (dp[i+1][j] > dp[i][j]) prev[i+1][j] = j;
            chmax(dp[i+1][j], dp[i][j]);
            if (j-a >= 0) {
                if (dp[i+1][j-a] > dp[i][j]) prev[i+1][j-a] = j;
                chmax(dp[i+1][j-a], dp[i][j] + b);
            }
        }
    }

    Rep (i, T+1) {
        w_file << i << " " << dp[N][i] << "\n";
    }

    ll cur = 1;
    vector<ll> used(N, false);
    for (ll i = N-1; i >= 0; i--) {
        ll a = dish[i].first;
        ll b = dish[i].second;
        if (dp[i+1][cur] - b == dp[i][cur+a]) {
            used[i] = true;
            // cout << i << "\n";
            cur += a;
        }
    }

    ll now = 0;
    Rep (i, N) {
        if (used[i] == false) {
            if (dish[i].second > now) {
                now = dish[i].second;
            }
        }
    }

    // cout << now << "\n";

    cout << max(dp[N][0], dp[N][1] + now) << "\n";
}

Measured memory_bytes: 141312
#include<iostream>
using namespace std;
int main(){
  double ans,nc=0,count=0;
  int sa,sv,answer=0,ansk;
  char c;
  while(cin>>sa>>c>>sv){
    answer += sa * sv;
    nc += sv;
    count++;
  }
  ans = nc / count;
  ans +=0.5;
  ansk = ans;
  cout << answer << endl << ansk << endl;
  return 0;
}

Measured memory_bytes: 1160
import java.util.Scanner;
public class Main{
    public static void main(String[] aa){
        Scanner s = new Scanner(System.in);
        String st;
         
        int i,now=0,m;
        while(true){
        st = s.next();
        if(st.charAt(0)=='-')break;
        m =s.nextInt();
           for(i=0;i<m;i++){
            now+=s.nextInt();
           }
           for(i=0;i<st.length();i++){
               System.out.print(st.charAt((now+i)%st.length()));
           }
           System.out.println();
           now=0;
       }
    }   
}


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

using ll = long long;

void solve(long long N, std::vector<long long> A, long long Q, std::vector<long long> B, std::vector<long long> C){
    map<ll, ll> mp;
    ll ans = 0;
    for(int i = 0;i < N;i++){
        mp[A[i]]++;
        ans += A[i];
    }
    for(int i = 0;i < Q;i++){
        mp[C[i]] += mp[B[i]];
        ans -= mp[B[i]] * B[i];
        ans += mp[B[i]] * C[i];
        mp[B[i]] = 0;
        cout<<ans<<endl;
    }
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    long long Q;
    scanf("%lld",&Q);
    std::vector<long long> B(Q);
    std::vector<long long> C(Q);
    for(int i = 0 ; i < Q ; i++){
        scanf("%lld",&B[i]);
        scanf("%lld",&C[i]);
    }
    solve(N, std::move(A), Q, std::move(B), std::move(C));
    return 0;
}


Measured memory_bytes: 11408
#!/usr/bin/python3
# -*- coding: utf-8 -*-

def rotate_n(p):
    temp = p['top']
    p['top'] = p['south']
    p['south'] = p['bot']
    p['bot'] = p['north']
    p['north'] = temp

def rotate_s(p):
    temp = p['top']
    p['top'] = p['north']
    p['north'] = p['bot']
    p['bot'] = p['south']
    p['south'] = temp

def rotate_e(p):
    temp = p['top']
    p['top'] = p['west']
    p['west'] = p['bot']
    p['bot'] = p['east']
    p['east'] = temp

def rotate_w(p):
    temp = p['top']
    p['top'] = p['east']
    p['east'] = p['bot']
    p['bot'] = p['west']
    p['west'] = temp

import sys

face = sys.stdin.readline().split()
command = sys.stdin.readline().strip()

position = {'top':face[0], 'bot':face[5], 'east':face[2],
            'west':face[3], 'south':face[1], 'north': face[4]}

for roll in command:
    if roll == 'N':
        rotate_n(position)
    elif roll == 'S':
        rotate_s(position)
    elif roll == 'E':
        rotate_e(position)
    elif roll == 'W':
        rotate_w(position)
    else:
        raise ValueError

print(position['top'])



Measured memory_bytes: 5580
dic ={'a':'A','b':'B','c':'C','d':'D','e':'E','f':'F','g':'G',\
      'h':'H','i':'I','j':'J','k':'K','l':'L','m':'M','n':'N',\
      'o':'O','p':'P','q':'Q','r':'R','s':'S','t':'T','u':'U',\
      'v':'V','w':'W','x':'X','y':'Y','z':'Z',' ':' ','.':'.'}
 
 
array = map(str, raw_input())


output = ''
for ar in array:
    output += dic[ar]

print output

Measured memory_bytes: 4228
#include<bits/stdc++.h>
using namespace std;
long long n, x;
int main(int argc, char const *argv[]) {
    cin >> n >> x;
    int f = 0;
    long long sum = n;
    n -= x;
    while(x){
        if(n%x==0)sum+=n*2-x;
        else sum += (n/x)*x*2;
        long long t = x;
        x = n%x;
        n = t;
    }
    cout << sum;
    return 0;
}


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

int main() {
	int K;
	cin >> K;

	if(K % 2 == 0){
		cout << -1 << endl;
		return 0;
	}

	ll num=7, ans=1;
	while(ans <= 1e6){
		if(num % K == 0){
			cout << ans << endl;
			return 0;
		}else{
			num = num % K;
			num = num*10+7;
			ans++;
		}
	}

	cout << -1 << endl;
}



Measured memory_bytes: 3632
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <bitset>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef long long LL;

typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<string, int> PSI;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define REP(i,n)  for(int i=0; i<(n); i++)

//constant
//--------------------------------------------
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
const LL MOD = 1e9+7; 
//vector <vector<int>> x(20, vector<int> (20)), y(20,vector<int> (20));
/*int counter_1 (int x) {
    if(x == 0) return 0;
    return counter_1(x >> 1) + (x & 1);
}*/

//int Counter(int x)
/*int factorial(int n) {
    if (n > 0) {
        return n * factorial(n - 1);
    } else {
        return 1;
    }
}*/
/*bool pairCompare(const P& firstElof, const P& secondElof)
{
    return firstElof.second > secondElof.second;
}*/


/*long nCr(int n, int r)
{
       if(n==r) return dp[n][r] = 1;
       if(r==0) return dp[n][r] = 1;
       if(r==1) return dp[n][r] = n;
       if(dp[n][r]) return dp[n][r];
       return dp[n][r] = nCr(n-1,r) + nCr(n-1,r-1);
}*/

int main(){
    int th, ta, ah, aa;
    cin >> th >> ta >> ah >> aa;
    int cntt=ah/ta;
    int cnta=th/aa;
    if(ah%ta!=0) cntt++;
    if(th%aa!=0) cnta++;
    //cout << cntt << ' ' << cnta << endl;
    if(cntt<=cnta) cout << "Yes" << endl;
    else cout << "No" << endl;
   
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int MAXN=2e5+69,INF=1e17;
int n;
int a[MAXN];
int dp[MAXN][3];
signed main(){
    cin>>n;
    for(int i=1;i<=n;i++)cin>>a[i];
    for(int i=1;i<=n;i++)for(int j=0;j<3;j++)dp[i][j]=-INF;
    dp[1][0]=a[1];
    for(int i=3;i<=n;i+=2)dp[i][0]=dp[i-2][0]+a[i];
    dp[2][1]=a[2];
    for(int i=4;i<=n;i+=2)dp[i][1]=max(dp[i-3][0],dp[i-2][1])+a[i];
    for(int i=3;i<=n;i++){
        dp[i][2]=dp[i-2][2]+a[i];
        dp[i][2]=max(dp[i][2],dp[i-3][1]+a[i]);
        if(i>=4)dp[i][2]=max(dp[i][2],dp[i-4][0]+a[i]);
    }
    int p=n&1;
    cout<<max(dp[n-1][p],dp[n][p+1]);
}

Measured memory_bytes: 9856
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7 # 998244353
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    n = int(input())
    res = []
    digit = 0
    while n:
        if (n >> digit) & 1:
            res.append('1')
            coef = 1 if digit & 1 == 0 else -1
            n -= coef * (1 << digit)
        else:
            res.append('0')
        digit += 1
    res = ''.join(res[::-1]) if res else '0'
    print(res)
resolve()

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

int main(void) {
  int n,m,l,j=0;
  cin >> n>>m>>l;
  int b[m];
  for(int i=0;i<m;i++){
    cin>>b[i];
  }
  for(int x=0;x<n;x++){
    int q=0;
    for (int i = 0; i <m; i++) {
      int p;
      cin>>p;
      q+=p*b[i];
    }
    q+=l;
    if(q>0){
      j++;
    }
  }
  cout<<j<<endl;


  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstring>
#include <math.h>
#include<cstdio>
using namespace std;
int a[47][47],inf=999999;
void init()
{
    for(int i=0; i<=47; i++)
        for(int j=0; j<=47; j++)
        {
            if(i==j)
                a[i][j]=0;
            else
                a[i][j]=inf;
        }
}
void floyd(int x)
{
    for(int k=0; k<=x; k++)
        for(int i=0; i<=x; i++)
            for(int j=0; j<=x; j++)
                if(a[i][j]>a[i][k]+a[k][j])
                    a[i][j]=a[i][k]+a[k][j];
}
int main()
{
    int n;
    while(scanf("%d",&n)&&n)
    {
        init();
        int max1=0,x,y,z;
        for(int i=0; i<n; i++)
        {
            scanf("%d%d%d",&x,&y,&z);
            if(x>max1)
                max1=x;
            if(y>max1)
                max1=y;
            if(a[x][y]>z)
                a[x][y]=a[y][x]=z;
        }
        floyd(max1);
        int max2=inf,u,sum;
        for(int i=0; i<=max1; i++)
        {
            sum=0;
            for(int j=0; j<=max1; j++)
            {
                 sum+=a[i][j];
            }
            if(sum<max2)
            {
                max2=sum;
                u=i;
            }
        }
        printf("%d %d\n",u,max2);
    }
    return 0;
}

Measured memory_bytes: 3112
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
const int N = 1005;
int dp[N][N];
char str[N];
int main()
{
    int n,m;
    dp[1][1] = 1;
    scanf("%d %d",&n,&m);
    for(int i=1;i<=n;i++)
    {
        scanf(" %s",str+1);
        for(int j=1;j<=m;j++)
        {
            if(i==1&&j==1)  continue;
            if(str[j]=='#') continue;
            dp[i][j] = (dp[i-1][j]+dp[i][j-1])%mod;
        }
    }
    printf("%d\n",dp[n][m]);
    return 0;
}


Measured memory_bytes: 4224
#include<iostream>
#include<string>
using namespace std;
string a;
int len,flag;
int main()
{
    cin>>a;
    len=a.length();
    for(int i=0;i<len;i++)
    {
        if(a[i]=='C')
        {
            for(int k=i+1;k<len;k++)
            {
                if(a[k]=='F')
                {
                    flag=1;
                }
            }
        }
    }
    if(flag==1)
    {
        cout<<"Yes";
    }
    else cout<<"No";
    return 0;
}


Measured memory_bytes: 384
import java.util.*;
 
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		if( (a<=b && a+w>=b) || (b<=a && b+w>=a) ){
			System.out.println(0);
		}else{
			System.out.println( Math.min( Math.abs(b-a-w), Math.abs(a-b-w)));
		}
		return;
	}
}

Measured memory_bytes: 21844
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int r = sc.nextInt();

		if (r < 1200) {
			System.out.println("ABC");
		} else if (r < 2800) {
			System.out.println("ARC");
		} else {
			System.out.println("AGC");
		}

		sc.close();
	}
}

Measured memory_bytes: 22612
using System;
using System.Collections;
using System.Linq;
class Program
{
    public static int Main()
    {
        int n = int.Parse(Console.ReadLine());
        int[] a = Console.ReadLine().Split(' ').Select(p => int.Parse(p)).ToArray();
        int[] a2 = new int[n + 2];
        for (int i = 1; i <= n; i++)
            a2[i] = a[i - 1];

        long cost = 0;
        for (int i = 0; i < n + 1; i++)
            cost += Math.Abs(a2[i] - a2[i + 1]);

        for (int i = 1; i <= n; i++)
        {
            long ans = cost - Math.Abs(a2[i - 1] - a2[i]) - Math.Abs(a2[i + 1] - a2[i]) + Math.Abs(a2[i - 1] - a2[i + 1]);
            Console.WriteLine(ans);
        }

        return 0;
    }
}

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

int main(){

	while(true){

		int n;
		cin >> n;

		if(n == 0){
			break;
		}

		int* a = new int[n];
		int* b = new int[n];

		for(int i = 0; i < n; i++){
			cin >> a[i] >> b[i];
		}

		int a_total = 0;
		int b_total = 0;

		for(int i = 0; i < n; i++){
			if(a[i] > b[i]){
				a_total += a[i] + b[i];
			}
			else if(a[i] < b[i]){
				b_total += a[i] + b[i];
			}
			else{
				a_total += a[i];
				b_total += b[i];
			}
		}

		cout << a_total << " " << b_total << endl;

	}
}

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

//定数
const long long MOD1=1000000007;
const long long MOD2=998244353;
const long double PI=3.1415926535897932;
const long long MAXLL=9223372036854775807;
const long long INF=2305843009213693951;
const long long dx[]={0,1,0,-1,1,-1,1,-1};
const long long dy[]={1,0,-1,0,1,1,-1,-1};

//型名省略
#define ll long long
#define ull unsigned long long
#define ld long double
#define uld unsigned long double
#define pll pair<long long,long long>
#define tll(n) array<long long,(int)(n)>
#define pcc pair<char,char>
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vp vector<pair<long long,long long>>
#define vt(n) vector<array<long long,(int)(n)>>
#define umap unordered_map
#define uset unordered_set
#define Lqueue priority_queue<long long>
#define Squeue priority_queue<long long,vector<long long>,greater<long long>>
#define Fi first
#define Se second
#define mp make_pair
#define eb emplace_back

//マクロ
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rbf(a,x) for(auto& a:x)
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s);i<(long long)(n);i++)
#define Maxe(x) *max_element((x).begin(),(x).end())
#define Mine(x) *min_element((x).begin(),(x).end())
#define Size(x) ((long long)(x).size())
#define lin(s) getline(cin,(s))

//MAX,MIN
template<class T,class U> auto max(T a,U b){return a>b?a:b;}
template<class T,class U> auto min(T a,U b){return a<b?a:b;}

//最大公約数,最小公倍数
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a,long long b){return a/gcd(a,b)*b;}

//累乗
template<typename t>
constexpr t mypow(t a,long long b){
    if(b==0)return 1;
    if(a==0)return 0;
    t x=1;
    while(b>0){
        if(b&1LL)x*=a;
        a*=a;
        b>>=1LL;
        }
    return x;
}
#define pow mypow

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

//組み合わせ O(r)
template<typename t>
constexpr t nCr(t n,long long r){
    if(r==0)return 1;
    if(n==0)return 0;
    if(n<r)return 0;
    t x=1;
    for(long long i=1;i<=r;i++){
        x*=n-i+1;
        x/=i;
    }
    return x;
}

//main関数
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll m,d;
    cin>>m>>d;
    vl check(101,0);
    rep(i,d){
        if((i+1)%10<2||(i+1)/10<2)continue;
        check[(i+1)%10*((i+1)/10)-1]++;
    }
    ll res=0;
    rep(i,m)res+=check[i];
    cout<<res<<endl;
}

Measured memory_bytes: 3656
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <assert.h>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <stdlib.h>
#include <math.h>
#include <string>
#include <time.h>
#include <string.h>
#include <queue>
#include <complex>
#include <iomanip>
#include <stack>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
ll mod=1e9;
double eps=1e-7;
ll exp(ll x,ll y){if(y<0) return 0; ll ret=1;for(;y;y>>=1,x=(x*x)%mod){if(y&1)ret=(ret*x)%mod;}return ret;}
ull pexp(ull x,ull y){if(y<0) return 0; ull ret=1; for(;y;y>>=1,x=(x*x)){if(y&1)ret=(ret*x);}return ret;}
ll gcd(ll x,ll y){if(!x||!y) return x+y; return x%y==0?y:gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll bsum(ll u,ll b){ll ret=0;if(u<b)return u;while(u){ret+=u%b;u/=b;}return ret;}
ll prival(ll u,ll p){ll cn=0;while(u%p==0){cn++;u=u/p;}return cn;}
ll minv(ll a,ll b){return 1<a?b-minv(b%a,a)*b/a:1;}
ll extm(ll a,ll b){ll ret=0;while(a!=0){if(a%2==1){ret+=b;ret%=mod;}a>>=1;b=(2*b)%mod;}return ret;}   
ll eaphi(ll x){ll t=x,ret=x,i;for(i=2;i*i<=x;i++){if(t%i==0){ret-=ret/i;while(t%i==0) t/=i;}}if(t!=1) ret-=ret/t;return ret;}
ll eadivc(ll x){ll ret=0;ll i;for(i=1;i*i<=x;i++){if(x%i==0 && i*i!=x) ret+=2;if(x%i==0 && i*i==x) ret+=1;}return ret;}
ll eadivs(ll x){ll ret=0;ll i;for(i=1;i*i<=x;i++){if(x%i==0 && i*i!=x) ret+=i+x/i;if(x%i==0 && i*i==x) ret+=i;}return ret;}
ll ndig(ll x, ll b){ll ret=0;while(x){x/=b; ret++;}return ret;}
ll rev(ll n, ll b){ll ret=0;while(n){ret=b*ret+n%b; n/=b;}return ret;}
ll sq(ll x){ll t=(ll)sqrt(x); for(ll i=t-2 ; i<=t+2 ; i++) if(i*i==x) return abs(i); return -1;}
ll extexp(ll x,ll y){if(y<0) return 0; ll ret=1;for(;y;y>>=1,x=extm(x,x)){if(y&1)ret=extm(ret,x);}return ret;}
bool isprime(ll x){if(x<=1) return false; for(ll i=2;i*i<=x;i++){if(x%i==0){return false;}}return true;}
ll ans=1e15, n, vv[111];

int main(void)
{
	ll i, j; cin>>n;
	for(i=1 ; i<=n ; i++) cin>>vv[i];
	for(i=-100 ; i<=100 ; i++)
	{
		ll cc=0;
		for(j=1 ; j<=n ; j++) cc+=(vv[j]-i)*(vv[j]-i);
		ans=min(ans,cc);
	}
	cout<<ans; return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int i,n,max=0;
  scanf("%d",&n);
  int a[n],count=0;
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
    
  }
  for(i=1;i<n;i++){
    if(a[i-1]>=a[i]) count++;
    else{
      if(max<count) max=count;
       count=0;
    }
     if(max<count) max=count;
  }printf("%d",max);
  return 0;
}

Measured memory_bytes: 512